home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_08_07 / 8n07124a < prev    next >
Text File  |  1990-06-19  |  2KB  |  69 lines

  1.    1: /*
  2.    2:  *  MDB.H   (Generalized Static/Dynamic
  3.    3:  *                 Array Version)
  4.    4:  *  Program:  Mini-Database
  5.    5:  *  Written by: Leor Zolman
  6.    6:  *  Module:   Program Header File
  7.    7:  */
  8.    8: 
  9.    9: #define TRUE  1
  10.   10: #define FALSE 0
  11.   11: 
  12.   12: #define DYN_ARRAY TRUE
  13.   13: 
  14.   14: /*
  15.   15:  * Prototypes: 
  16.   16:  */
  17.   17: 
  18.   18: int do_menu(struct menu_item *mnu, char *title);
  19.   19: void write_db(char *filename);
  20.   20: int read_db(char *filename);
  21.   21: void edit_db();
  22.   22: void fix_db();  
  23.   23: void backup_db();
  24.   24: void error(char *msg);
  25.   25: struct record *alloc_rec(void);
  26.   26: void free_up();
  27.   27: 
  28.   28: /*
  29.   29:  * Data Definitions:
  30.   30:  */
  31.   31: 
  32.   32: struct record {     /* Database record definition */
  33.   33:   char  active;   /* TRUE if Active, else FALSE */
  34.   34:   char  last[25], first[15];/* Name       */
  35.   35:   long  id;         /* ID Number    */
  36.   36:   int   age;        /* Age        */
  37.   37:   char  gender;       /* M or F     */
  38.   38:   float salary;       /* Annual Salary  */
  39.   39: };
  40.   40: 
  41.   41: #define MAX_RECS  1000 /* Maximum number of records */
  42.   42: 
  43.   43: 
  44.   44: #ifdef MAIN_MODULE    /* Make sure data is only   */
  45.   45: #define EXTERN      /* DEFINED in the main module,  */
  46.   46: #else         /* and declared as EXTERNAL in  */
  47.   47: #define EXTERN  extern  /* the other modules.     */
  48.   48: #endif
  49.   49: 
  50.   50: 
  51.   51: #if DYN_ARRAY     /* Dynamics array allocation: */
  52.   52: #define MAX_TO_ADD  100 /* Limit on # of new records  */
  53.   53: EXTERN  struct  record  *(*recs)[];    /* ptr to array  */
  54.   54: #define RECS  (*recs) /* of ptrs to struct record   */
  55.   55: 
  56.   56: #else           /* Static array allocation: */
  57.   57: EXTERN  struct  record *recs[MAX_RECS]; /* Array of ptr */
  58.   58: #define RECS  recs    /* to struct of type record */
  59.   59: #endif
  60.   60: 
  61.   61: EXTERN  int n_recs;   /* # of records in current db */
  62.   62: EXTERN  int max_recs; /* Max # of recs allowed    */
  63.   63: 
  64.   64: struct menu_item {      /* Menu definition record */
  65.   65:   int action_code;    /* Menu item code     */
  66.   66:   char *descrip;      /* Menu item text     */
  67.   67: };
  68.   68: 
  69.