Article View: comp.os.msdos.programmer
Article #1072Table lookup ...
From: Binod Taterway
Date: Thu, 20 Aug 1992 14:47
Date: Thu, 20 Aug 1992 14:47
38 lines
1716 bytes
1716 bytes
Could some one shed some light on how best to implement the following.
I have a configuration file that contains parameter-value pairs like
the following:
xyz_directory = c:\xyz
feature1 = 20
feature2 = 10
feature3 =
For every parameter, I want to define a global variable (I will use a
structure) with the same name as parameter name. So I have a table as
follows:
struct p_table {
char *parameter_name;/* name of the parameter */
bool specified; /* whether or not it is user-specified */
short type; /* Integer, string, long, etc. */
char *default_value; /* Default value */
char *value; /* User-specified value */
} P_TABLE;
P_TABLE p_table[] = {
{"xyz_directory", TRUE, TYPE_STRING, "c:\xyz_orig", "c:\xyz"},
{"feature1", TRUE, TYPE_INTEGER, "100", "20"},
{"feature2", TRUE, TYPE_INTEGER, "200", "10"},
{"feature3", FALSE, TYPE_INTEGER, "300", NULL}
}
Though not implemented yet, I am not convinced if this the best
approach. If you know of any other approaches to reading a
configuration file, please throw in your two cents. Thanks.
--
- Binod Taterway
Sr. User Consultant (LUCC)
E-mail: bt00@Lehigh.EDU
Technical Details
Message-ID:
<LUBKT.92Aug20094704@synergy.CC.Lehigh.EDU>Path:
arc1-ca.pugleaf.net!sparky!uunet!paladin.american.edu!darwin.sura.net!jvnc.net!netnews.upenn.edu!netnews.cc.lehigh.edu!netnews.cc.lehigh.edu!lubktShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!paladin.american.edu!darwin.sura.net!jvnc.net!netnews.upenn.edu!netnews.cc.lehigh.edu!netnews.cc.lehigh.edu!lubkt From: lubkt@synergy.CC.Lehigh.EDU (Binod Taterway) Newsgroups: comp.os.msdos.programmer Subject: Table lookup ... Message-ID: <LUBKT.92Aug20094704@synergy.CC.Lehigh.EDU> Date: 20 Aug 92 14:47:04 GMT Sender: usenet@chili.cc.lehigh.edu Distribution: comp.os.msdos.programmer Organization: Lehigh University, Bethlehem, PA Lines: 38 Nntp-Posting-Host: synergy.cc.lehigh.edu