Welcome to the most active Linux Forum on the web.
Go Back > Forums > Non-*NIX Forums > Programming
User Name
Programming This forum is for all programming questions.
The question does not have to be directly related to Linux and any language is fair game.


  Search this Thread
Old 05-04-2005, 09:32 AM   #1
Registered: Aug 2003
Posts: 39

Rep: Reputation: 15
read options from config file


i want to read options from my c-program which are written in an config file in the normal way like most config file

for example


bar = xxx

are there any functions to do this?

thanks in advance
Old 05-04-2005, 09:42 AM   #2
Registered: May 2005
Distribution: debian
Posts: 79

Rep: Reputation: 15
I don't know about functions that can handle this, but look into string tokenizers.
Old 05-04-2005, 10:17 AM   #3
Registered: Aug 2003
Posts: 39

Original Poster
Rep: Reputation: 15
aren't there any other useful functions, because it is used often and in many programs?
Old 05-04-2005, 12:33 PM   #4
Senior Member
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 110Reputation: 110
AFAIK there are none. And think it's a bit strange as well. getopt() exists for a long time, but general config file parser do not exist apparently...

You could copy some functions for it from a free software source.

One option that comes close may be to use XML config files and use a XML-parser library. But if your program is simple, this may be an overkill.
Old 05-05-2005, 04:30 AM   #5
Amigo developer
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,880

Rep: Reputation: 563Reputation: 563Reputation: 563Reputation: 563Reputation: 563Reputation: 563
Check out mkxf86config from It contains two short functions: checkbootparam and getbootparam that are for parsing options from /proc/cmdline.
You can use those or modify to suit.


Thread Tools Search this Thread
Search this Thread:

Advanced Search

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
Read parameters from config file (file parser?) alaios Programming 8 07-09-2012 12:29 PM
logrotate appeares to not read the config file zby Debian 1 06-30-2004 11:34 AM
Snort refuses to read config file stakhous Linux - Security 4 05-07-2004 09:48 AM
Samba config to allow Windows read-only file attribute changes percheron Linux - Networking 8 09-13-2003 12:56 AM
Unable to read config file............ FXRS Linux - Software 7 07-03-2003 09:36 AM > Forums > Non-*NIX Forums > Programming

All times are GMT -5. The time now is 10:34 AM.

Main Menu
Write for LQ is looking for people interested in writing Editorials, Articles, Reviews, and more. If you'd like to contribute content, let us know.
Main Menu
RSS1  Latest Threads
RSS1  LQ News
Twitter: @linuxquestions
Facebook: linuxquestions Google+: linuxquestions
Open Source Consulting | Domain Registration