[lug] Advice on writing a config file (probably XML)

Mr Viggy LittleViggy at alum.manhattan.edu
Sun Dec 14 09:14:45 MST 2003


Lex and YACC are really good for things like scripting, and like Mr 
Klein said, are probably overkill for a simple config file.

I had used XML in the past for a config type file, however it wasn't 
really just simple profiles.  The config file actually "described" the 
way the program should behave (it was a "wizard" type app, and each top 
level XML block described a single page).

I would suggest, if your configs are going to remain simple, go with 
something like:

[BLOCK_NAME]
Attribute=Value

Yes, this is the Micro$soft INI file format, but it's pretty simple to 
setup, understand, read and write.

My $0.02...

Viggy

Timothy C. Klein wrote:
> * Jon Bowman (solarisjon at gawab.com) wrote:
> 
>>Hi I'm looking for some advice. I'm writing a Gnome application
>>to 
>>handle wireless profiles. Anyway I need to keep track of the
>>profiles,
>>data in the profile for example would include
>>
>>ESSID, WEP KEY, Network Device amongst some others
>>
>>Anyway I assume XML is probably the cleanest way to write a
>>config
>>file. Never having done this before or used XML does anyone have
>>any
>>recommendation / pointers to get me started. The application is
>>written
>>in C so are there any libraries / functions I can make use of ?
>>
>>Any help , advise and pointers or just personal experience would
>>be
>>appreciated.
> 
> 
> I don't really know what advantages XML would have, but LEX and YACC
> (flex and bison versions from GNU) are tailor made for this job. Lex is
> pretty darn easy to learn, but is probably not enough (it is the lexical
> analyzer, so it tokenizes for you). YACC (the part that understands a
> grammar built up from tokens) is harder to learn, but could generate the
> beginnings of a compiler if you wanted. Probably overkill for a simple
> config-file, but parsing a language is what these tools were built to
> do.
> 
> If you ever plan on your config file getting big and full-featured,
> these two tools would make a whole lot of sense.
> 
> Tim
> --
> ==============================================
> == Timothy Klein || teece at silverklein.net   ==
> == ---------------------------------------- ==
> == Hello_World.c: 17 Errors, 31 Warnings... ==
> ==============================================
> _______________________________________________
> Web Page:  http://lug.boulder.co.us
> Mailing List: http://lists.lug.boulder.co.us/mailman/listinfo/lug
> Join us on IRC: lug.boulder.co.us port=6667 channel=#colug
> 
> .
> 




More information about the LUG mailing list