From: | Dmitry Samersoff <dms(at)wplus(dot)net> |
---|---|
To: | Vince Vielhaber <vev(at)michvhf(dot)com> |
Cc: | pgsql-hackers(at)postgreSQL(dot)org, Jackson(at)woland(dot)wplus(dot)net, DeJuan <djackson(at)cpsgroup(dot)com> |
Subject: | RE: [HACKERS] [OT] flex, yacc, and bison |
Date: | 1999-08-19 09:43:49 |
Message-ID: | XFMail.990819134349.dms@wplus.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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(at)wplus(dot)net, ICQ:3161705
http://devnull.wplus.net
* There will come soft rains ...
From | Date | Subject | |
---|---|---|---|
Next Message | Tom Lane | 1999-08-19 13:21:05 | Mail list attachments |
Previous Message | Ansley, Michael | 1999-08-19 09:40:32 | Survey |