RE: [HACKERS] [OT] flex, yacc, and bison

From: "Jackson, DeJuan" <djackson(at)cpsgroup(dot)com>
To: Dmitry Samersoff <dms(at)wplus(dot)net>, Vince Vielhaber <vev(at)michvhf(dot)com>
Cc: pgsql-hackers(at)postgresql(dot)org, Jackson(at)woland(dot)wplus(dot)net
Subject: RE: [HACKERS] [OT] flex, yacc, and bison
Date: 1999-08-19 15:33:20
Message-ID: D05EF808F2DFD211AE4A00105AA1B5D248565A@cpsmail
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Thanks guys, for all the help.
The reason that I was thinking 'grammar parser' was that the spec of this
format may change. I was looking for something that would be quick, but
easily extended as the grammar changed/evolved. Also my next project will
need the same functionality if not an extension of the same grammar.
Again thanks,
-DEJ

> -----Original Message-----
>
> 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 ...

Browse pgsql-hackers by date

  From Date Subject
Next Message The Hermit Hacker 1999-08-19 15:39:06 RE: [HACKERS] Tangent ... you know what's scary?
Previous Message The Hermit Hacker 1999-08-19 15:31:54 Re: [HACKERS] Tangent ... you know what's scary?