home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #18 / NN_1992_18.iso / spool / comp / os / msdos / programm / 8662 < prev    next >
Encoding:
Text File  |  1992-08-20  |  1.6 KB  |  51 lines

  1. Path: sparky!uunet!paladin.american.edu!darwin.sura.net!jvnc.net!netnews.upenn.edu!netnews.cc.lehigh.edu!netnews.cc.lehigh.edu!lubkt
  2. From: lubkt@synergy.CC.Lehigh.EDU (Binod Taterway)
  3. Newsgroups: comp.os.msdos.programmer
  4. Subject: Table lookup ...
  5. Message-ID: <LUBKT.92Aug20094704@synergy.CC.Lehigh.EDU>
  6. Date: 20 Aug 92 14:47:04 GMT
  7. Sender: usenet@chili.cc.lehigh.edu
  8. Distribution: comp.os.msdos.programmer
  9. Organization: Lehigh University, Bethlehem, PA
  10. Lines: 38
  11. Nntp-Posting-Host: synergy.cc.lehigh.edu
  12.  
  13.  
  14. Could some one shed some light on how best to implement the following.
  15. I have a configuration file that contains parameter-value pairs like
  16. the following:
  17.  
  18.     xyz_directory    = c:\xyz
  19.     feature1    = 20
  20.     feature2    = 10
  21.     feature3    =
  22.  
  23. For every parameter, I want to define a global variable (I will use a
  24. structure) with the same name as parameter name. So I have a table as
  25. follows: 
  26.  
  27. struct p_table {
  28.     char    *parameter_name;/* name of the parameter */
  29.     bool    specified;     /* whether or not it is user-specified */
  30.     short    type;         /* Integer, string, long, etc. */
  31.     char    *default_value; /* Default value */
  32.     char    *value;     /* User-specified value */
  33. } P_TABLE;
  34.  
  35. P_TABLE p_table[] = {
  36.     {"xyz_directory", TRUE, TYPE_STRING, "c:\xyz_orig", "c:\xyz"},
  37.     {"feature1", TRUE, TYPE_INTEGER, "100", "20"},
  38.     {"feature2", TRUE, TYPE_INTEGER, "200", "10"},
  39.     {"feature3", FALSE, TYPE_INTEGER, "300", NULL}
  40. }
  41.  
  42. Though not implemented yet, I am not convinced if this the best
  43. approach. If you know of any other approaches to reading a
  44. configuration file, please throw in your two cents. Thanks.
  45.  
  46. --
  47.  
  48. - Binod Taterway                     
  49.   Sr. User Consultant (LUCC)
  50.   E-mail: bt00@Lehigh.EDU
  51.