LinuxQuestions.org
Latest LQ Deal: Latest LQ Deals
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
  Search this Thread
Old 01-17-2004, 06:25 PM   #1
nmoog
Member
 
Registered: Sep 2003
Location: Sydney
Distribution: Debian
Posts: 70

Rep: Reputation: 15
Standard way to read config files?


Newbie C (and/or C++) programming question!

Since many configuration options are set up in plain text config files, is there are standard way to read and parse them?

I could write my own version, but it would probably not be the most efficient way, and wound just be reinventing the wheel...

Thanks
 
Old 01-17-2004, 06:36 PM   #2
jtshaw
Senior Member
 
Registered: Nov 2000
Location: Seattle, WA USA
Distribution: Ubuntu @ Home, RHEL @ Work
Posts: 3,892
Blog Entries: 1

Rep: Reputation: 67
The answer is..... no

There really isn't a default standard way linux configuration files are layed out.

Sometimes the option labes are one word, sometimes they are multiple. Sometimes the option value is one word/value, sometimes it is multiple. Sometimes there are " or some other character around values, sometimes not. It really is inconsistant.
 
Old 01-17-2004, 07:32 PM   #3
synna
Member
 
Registered: Jan 2004
Posts: 40

Rep: Reputation: 15
It depend on what do you need to store. For short info use something like :
info as string separated by a special char (say 29 so user never use it).

But it as some big disadvantage : it can be really hard to extend. If your project grow it can be a whole part to rewrite.

I would suggest you to write it as xml files. There's a lot of parser for xml files like libxml or QT. Some of the job is already done but you have to learn some basis of xml....

I think this is the best way since it's extensible and a very powerfull way of storing things...
And more it can be edited...

Hope this help...
 
Old 01-17-2004, 09:46 PM   #4
nmoog
Member
 
Registered: Sep 2003
Location: Sydney
Distribution: Debian
Posts: 70

Original Poster
Rep: Reputation: 15
Yeah thanks. I really have no need for it at the moment, but I am pretty new to linux and having edited a million linux config files that essentially looked the same I was just wondering why it was that way!
 
Old 01-19-2004, 11:17 AM   #5
LogicG8
Member
 
Registered: Jun 2003
Location: Long Island, NY
Distribution: Gentoo Unstable (what a misnomer)
Posts: 380

Rep: Reputation: 30
Config files are the same mostly out of convention.
There are no rules or convenient libraries it's just
that people do it the same way b/c it is easy and
there isn't really a need to do it differently.
 
  


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



Similar Threads
Thread Thread Starter Forum Replies Last Post
teaching standard init config... Kronocide Linux - General 7 11-26-2005 11:47 AM
How to config CDRom to read udf files satimis *BSD 16 06-25-2004 09:31 PM
generic parser to read/write linux config files amitchandel Linux - Software 1 06-14-2004 04:00 PM
How does linux read config files? Thaidog Linux - Newbie 13 05-31-2004 12:14 PM
how to run KDE without firt running standard window menager... xfree config.... hunter_one Linux - Software 1 10-29-2003 09:42 AM

LinuxQuestions.org > Forums > Non-*NIX Forums > Programming

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

Main Menu
Advertisement
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
Open Source Consulting | Domain Registration