RE: [HACKERS] [OT] flex, yacc, and bison - Mailing list pgsql-hackers

From Dmitry Samersoff
Subject RE: [HACKERS] [OT] flex, yacc, and bison
Date
Msg-id XFMail.990819134349.dms@wplus.net
Whole thread Raw
In response to RE: [HACKERS] [OT] flex, yacc, and bison  (Vince Vielhaber <vev@michvhf.com>)
List pgsql-hackers
On 18-Aug-99 Vince Vielhaber wrote:
> 
> On 18-Aug-99 Jackson, DeJuan wrote:
>> I'm trying to write a ncftp_auth deamon that will utilize PostgreSQL.  The
>> base SDK is in C.  I'm adapting it to C++ because I feel like it, but Perl
>> would be a slightly steeper learning curve (sockets and all that).  I'm
>> trying to get a conf file parser such that the login's can be in multiple
>> database and/or on different machines.
> 
> If you're into C/C++ (like I am), it's almost trivial to parse that into
> individual strings.  I was under the impression from your first note that
> C/C++ wasn't an option.   At the minimum, think strtok().   There's also
> strsep() but it's not been one of my favorites.  If you still need actual
> code let me know and I can send you something.

It's my bestst:

int split(char delem, char *str, ... )
{ char *tmp, *_src, *t, **s; int fields = 0;
_src = str;
va_list ap;va_start(ap, str);
if (! (tmp=new char[2048]) )                        return -1;
while(_src) { t = _src;   while (*t && ((*t) != delem) ) ++t;   s = va_arg(ap, char **);   if (!s || !*t)
break;   *s = ( t-_src-1 > 0) ? strndup(_src,t-_src-1) : 0 ;   _src = t+1;  ++ fields; }
 
 return fields;
}


---
Dmitry Samersoff, dms@wplus.net, ICQ:3161705
http://devnull.wplus.net
* There will come soft rains ...


pgsql-hackers by date:

Previous
From: Vince Vielhaber
Date:
Subject: RE: [HACKERS] [OT] flex, yacc, and bison
Next
From: "Natalya S. Makushina"
Date:
Subject: [HACKERS] Problem with query length