[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index] [Thread Index]

Re: netcof

"Sarel J. Botha" <sjb@dundee.lia.net> writes:

> [1  <text/plain; us-ascii (7bit)>]
> Hi all
> [ Can everyone please subscribe to debian-admintool? My To: field is
> looking rather silly :) ]

Pretty Silly, close to get cought in my mass mail spam filter because
of to many CCs. :)

> I'm very happy with the parser. Just need to add some error-checking.
> The interface changed a small bit, as it parses demand{} as well now. Check
> net.conf for details.

Whats net.conf? Did I miss something?

> parse_file() returns a pointer to a t_netconf which looks like this:
> struct t_netconf {
>   t_provider *demand;
>   t_scheme *schemes;
> }

That should be changed asap to netconf_t to go along with size_t,
off_t, pid_t, foo_t, bla_t and many more types that have the "_t" at
the end and not at the front. I think its good style to keep it one way.

> So, after tree = parse_file ("blah");
> demand is a pointer to a linked list of "t_provider"s and schemes is a
> pointer to a linked list of "t_schemes". Check parser.h for details.
> I implemented the options as a linked list as well. use getopt() and
> setopt() to manipulate options.
> That's how it currently works. Any suggestions?
> Can everyone please play with 'test' and try to make it segfault.
> Oh yea, if it returns NULL, the error will be in *errstr (extern). I'm
> working on producing warnings as well, in a linked list of warnings.
> Known bug:
> If a word is longer than 80 chars it'll segfault.
> How should I handle this? Just produce a warning or return NULL and an
> error string?

C or C++?

If it is C, change it to C++ (use g++ instead of gcc is all that you
need apart from removing any compile errors produced by that). :)

If you don't like that, "man snprintf", "man scanf". You have to tell
C that your buffer you are reading to is only 80 chars long, which is
a stupid limit. You should look for a scanf routine that works like
snprintf or write yourself one that allocates and enlarges a C string
(char[]) as it reads along and returns that.

Also libreadline might do some good or maybe a flex lexer. But that
might be overkill.

If its C++, how the fuck did you program that? Use the default string
implementation and iostreams.

> Thanks all

May the Source be with you.

PS: If you have problems with >80 chars strings you probably also have
buffer overrun problems. Consider every literal number except 0, 1 and
in some very rare cases 2 that you see in a program a bug or security
risk which should be looked at closely. Of cause constants such as
M_PI aren't ment here.

Reply to: