LinuxQuestions.org
Review your favorite Linux distribution.
Go Back   LinuxQuestions.org > Forums > Non-*NIX Forums > Programming
User Name
Password
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.

Notices

Reply
 
LinkBack Search this Thread
Old 05-04-2005, 08:32 AM   #1
biiiep
Member
 
Registered: Aug 2003
Posts: 39

Rep: Reputation: 15
read options from config file


halo,

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

[foo]

bar = xxx

are there any functions to do this?

thanks in advance
 
Old 05-04-2005, 08:42 AM   #2
oblivious69
Member
 
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, 09:17 AM   #3
biiiep
Member
 
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, 11:33 AM   #4
Hko
Senior Member
 
Registered: Aug 2002
Location: Groningen, The Netherlands
Distribution: ubuntu
Posts: 2,530

Rep: Reputation: 108Reputation: 108
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, 03:30 AM   #5
gnashley
Amigo developer
 
Registered: Dec 2003
Location: Germany
Distribution: Slackware
Posts: 4,725

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


Reply


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
Trackbacks are Off
Pingbacks are On
Refbacks are Off


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


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

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