1: /* $Header$ */
   2: 
   3: /*
   4:  * Author: Peter J. Nicklin
   5:  */
   6: 
   7: /*
   8:  * pputflag() adds flag to each entry corresponding to key. The entry is
   9:  * not changed if flag already exists. If key not found, a new entry
  10:  * is added to the database.
  11:  */
  12: #include <stdio.h>
  13: #include "null.h"
  14: #include "path.h"
  15: #include "pdb.h"
  16: #include "yesno.h"
  17: 
  18: void
  19: pputflag(key, flag, pdbp)
  20:     char *key;          /* key string */
  21:     char *flag;         /* flag string */
  22:     PDB *pdbp;          /* database stream */
  23: {
  24:     char *pbfndkey();       /* find key */
  25:     int foundkey;           /* found key flag */
  26:     int pbaddflag();        /* add flag field */
  27:     int pbaddkey();         /* add key */
  28:     int pgetent();          /* load next entry into buffer */
  29:     int pputent();          /* write buffer to database */
  30:     void pbclear();         /* clear buffer */
  31:     void rewindpdb();       /* rewind database */
  32: 
  33:     rewindpdb(pdbp);
  34:     foundkey = NO;
  35:     while (pgetent(pdbp) != EOF)
  36:         {
  37:         if (pbfndkey(key) != NULL)
  38:             {       /* key exists */
  39:             pbaddflag(flag);
  40:             foundkey = YES;
  41:             }
  42:         pputent(pdbp);
  43:         }
  44:     if (foundkey == NO)
  45:         {           /* new entry */
  46:         pbclear();
  47:         pbaddkey(key);
  48:         pbaddflag(flag);
  49:         pputent(pdbp);
  50:         }
  51: }

Defined functions

pputflag defined in line 18; never used
Last modified: 1985-07-03
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 614
Valid CSS Valid XHTML 1.0 Strict