home *** CD-ROM | disk | FTP | other *** search
/ The C Users' Group Library 1994 August / wc-cdrom-cusersgrouplibrary-1994-08.iso / listings / v_08_04 / 8n04071a < prev    next >
Text File  |  1990-03-20  |  2KB  |  62 lines

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