[lug] OT: C Programming Question

Tkil tkil at scrye.com
Fri Dec 14 17:10:00 MST 2001


>>>>> "George" == George Sexton <Sexton> writes:

George> Are there any standard C library routines to read name value
George> pairs from a text file using C?  [e.g.]

George> INTERFACE="eth0"

you can probably get pretty far by using "strsep" if your libc
supports it, or "strtok" if it doesn't.  i don't know of anything that
does it "for you" -- i'd guess that a part of the reason might be the
number of interface decisions that have to be made.

in perl, python, java, or even c++, saying "returning a pair of
strings" isn't too unreasonable; but in c, you avhe to specify the
exact structure, as well as dealing allocation strategy and ownership
of the resulting strings.  (not to mention what happens with strings
with embedded NULs, but those probably don't happen too often in INI
files -- does windows just return them as "sz"?)

t.



More information about the LUG mailing list