home *** CD-ROM | disk | FTP | other *** search
/ Boldly Go Collection / version40.iso / TS / 17A / DRWIN101.ZIP / CFGUTIL.H < prev    next >
C/C++ Source or Header  |  1991-10-24  |  2KB  |  51 lines

  1. #ifndef __CFGUTIL_H
  2. #define __CFGUTIL_H
  3.  
  4.  
  5. typedef enum {                         //codes for data types
  6.   CFG_CUSTOM=0,                        //use custom load function
  7.   CFG_CHAR=1,                          //single character
  8.   CFG_BYTE,                            //byte -- u-char handled like an int
  9.   CFG_INT,                             //decimal int
  10.   CFG_UINT,                            //unsigned int
  11.   CFG_LONG,                            //long int
  12.   CFG_ULONG,                           //unsigned long
  13.   CFG_DOUBLE,                          //double floating point
  14.   CFG_STRING,                          //string of chars
  15.  
  16.   CFG_NOLOAD=0x0100,                   //don't load this item
  17.   CFG_NOSAVE=0x0200,                   //don't save this item
  18.   CFG_QUOTES=0x0400,                   //use quotes when saving char/string
  19.   CFG_HEX   =0x0800,                   //hex output (with "0x")
  20.  
  21.   CFG_XBYTE  =CFG_BYTE  |CFG_HEX,      //hex byte
  22.   CFG_XINT   =CFG_UINT  |CFG_HEX,      //hex int
  23.   CFG_XLONG  =CFG_ULONG |CFG_HEX,      //hex long
  24.   CFG_QCHAR  =CFG_CHAR  |CFG_QUOTES,   //char with quotes
  25.   CFG_QSTRING=CFG_STRING|CFG_QUOTES,   //string with quotes
  26.  
  27.   CFG_TYPE_MASK=0x00FF,                //used to mask off types listed above
  28. } CFG_VALUE_TYPE;
  29.  
  30. #define CFG_LOAD   0                   //control flag for custom function
  31. #define CFG_SAVE   1
  32. #define CFG_WRITE  0                   //overwrite file on save
  33. #define CFG_APPEND 1                   //append on save
  34.  
  35. typedef int (*CFG_FUNC)(int item,void* val,char* str,int loadsave);
  36.  
  37. typedef struct {                       //auto-variable loading struct
  38.   char* name;                          //name of the field
  39.   CFG_VALUE_TYPE type;                 //type of value being loaded
  40.   void* val;                           //pointer to data value
  41.   CFG_FUNC func;                       //load/save func
  42. } CFG_TYPE;
  43.  
  44.  
  45. int  cfg_load(char* fn,char* obj,CFG_TYPE* ini,int n);
  46. int  cfg_save(char* fn,char* obj,CFG_TYPE* ini,int n,int append);
  47.  
  48.  
  49. #endif
  50.  
  51.