Need some links for handling some kind of config file in c or c++

Need some links for handling some kind of config file in c or c++

Post by David Li » Wed, 28 Feb 2001 15:40:48



Hi,

Does anyone has some good links for handling some kind
of configuration file for my programs in c or c++


Thx in advance !

__________________________________________________________

Alcatel Bell Space N.V.                                        
Berkenrodelei 33,          phone : +32 (0)3 829 5658              
B-2660 Hoboken, Belgium.   fax   : +32 (0)3 829 5763              

--

 
 
 

Need some links for handling some kind of config file in c or c++

Post by David Rubi » Wed, 28 Feb 2001 13:49:59



> Hi,

> Does anyone has some good links for handling some kind
> of configuration file for my programs in c or c++

You can use XML for which there are several free parser libraries, or, depending
on how intricate you want your configuration to be, you can write a very simple
key/value parser (each line starts \n, #, or key=value).

No. It is impolite to request information in a newsgroup if you're not going to
take the time to read it.

        david

--
FORTRAN was the language of choice
for the same reason that three-legged races are popular.
        -- Ken Thompson, "Reflections on Trusting Trust"

 
 
 

Need some links for handling some kind of config file in c or c++

Post by Narendranath Nai » Wed, 28 Feb 2001 18:52:33


Please read the abstract given below and also:
ftp://rtfm.mit.edu/pub/usenet/news.answers/news-newusers-intro

[QUOTE]
   If you DO decide to ask a question in news.newusers.questions...

  If, after checking the postings in news.announce.newusers to see if
your question is answered there, and after looking to see if there is
a more appropriate group in which to post it, and after trying to get
help locally, you still think your question belongs in
news.newusers.questions, then go right ahead and post it.

  However, you should keep in mind when preparing your question that
the people who will be reading it and trying to help you are not
mind-readers.  We don't know what your site is like.  There are
thousands of sites on the USENET, and they're all just a little bit
different, so the more details you can provide when asking your
question, the more likely it is that people will be able to help you.

  Try to provide the following information when posting a question.
If you don't know the answers to some of these questions, then try to
find them out from someone at your site and save them so that you can
use them when posting questions in the future:

1. What kind of machine are you working on?  For example: Macintosh,
   VAX, DECstation, IBM PC, PC compatible (which one), Cray, RS/6000.
2. What operating system is it running?  For example: MacOS, MS-DOS,
   UNIX, VM/CMS, VMS.
3. What version of the operating system?  For example: MacOS 7.0,
   Ultrix 4.2 UNIX, BSD 4.3, etc.
4. What news reader (or whatever program you are having trouble with)
   are you using?  What command do you type to start up whatever
   program is giving you trouble?
5. What version of the program is it?
6. If you are trying to interpret some sort of error, what exactly did
   you type to provoke the error, what was the exact error, and how is
   the actual error different from what you expected to happen?  For
   example, if you're trying to figure out why a mail message bounced,
   what address did you send the mail to, and what error message came
   back in the bounced message?
7. What have you done to try to find the answer to your question
   before posting?  If you've tried different possible answers
   already, exactly what have you tried, and what was the result?
8. If you have checked the documentation and cannot understand the
   answer it gives to your question, then what exactly about the
   answer it gives don't you understand?  If there is documentation
   available and you haven't checked it, why not?

If you're not sure whether a particular piece of information will be
helpful, include it.  It can't hurt to provide extra information
(unless, of course, that information takes up several hundred lines of
text :-), and it may just be the key to the solution of your problem.
[QUOTE]


> Hi,

> Does anyone has some good links for handling some kind
> of configuration file for my programs in c or c++


> Thx in advance !

> __________________________________________________________

> Alcatel Bell Space N.V.
> Berkenrodelei 33,          phone : +32 (0)3 829 5658
> B-2660 Hoboken, Belgium.   fax   : +32 (0)3 829 5763

> --

 
 
 

1. Need library to handle config files

OK, this is a very basic question, and since it neither applies to one
specific OS, nor a specific programming language, it's somewhat OT in both
newsgroups. Please forgive my cross-post.

I frequently write programs that read config files which are arranged the
usual way as "key=value" pairs. No big deal. But sometimes there are some
specialties that need to be handled, like:

- Discerning between mandatory and optional parameters
- Depending on how critical the application is, I sometimes
  want to be very fuzzy about missing/invalid/useless parameters,
  sometimes sloppy
- I might want to change and write back parameters (but so far I'm
  a true sucker for the old Unix way: Config files are *only* touched
  in a text editor)
- Handling of sectionated files, i.e. files that have sections for
  different 'devices', each of which can contain the same keys (like
  the XF86Config file)

Of course, it's fairly easy to implement these features as needed by the
individual application. But at some point I'm getting sick of always
re-inventing the wheel with either screenfuls of

if (!strcmp(key, "foo")) {
    interpret key;
    handle errors;

or really dirty things with pre-defined structures of keys and their
properties combined with switch statements. It's just a hell of a lot of
typing.

I've also played with flex but didn't really find that it saved me a lot
of time. Also, I was intimidated by the fact that sometimes the flex
output was bigger than the rest of my code.

In short, I've been thinking about developing a library which builds a
generic, easily accessible database that handles all these cases. On the
other hand, since this is an all-too-common situation, I figured that such
a library might already exist.

And here comes, at last, my question:
Does it?

Thanks,
--Daniel

--
"The obvious mathematical breakthrough would be development of an easy
 way to factor large prime numbers."   -- Bill Gates, "The Road Ahead"

2. 3c5x9B and x86 DU7

3. Need help matching stale NFS file handle to a file, Solaris 2.5

4. Boot Manager diddler to change 'default' boot ?

5. header files needed if object files are available in C++ ?

6. KDAT- Acces Tape Directly

7. Plug-Ins using C++

8. Creative CDRom on SoundBlaster card

9. gcc - Can't locate c++ include files + broken symbolic links

10. how to link (or compile) C and C++ source files

11. C and C++, linking object files

12. pppd dial ins and , "LCP: timeout sending Config-Requests"

13. translating kppp config files to ppp config files