1: /* $Header$ */
   2: 
   3: /*
   4:  * Author: Peter J. Nicklin
   5:  */
   6: 
   7: /*
   8:  * pputstring() adds id=string to each entry corresponding to key. If id
   9:  * already exists, the corresponding string is replaced by string. If
  10:  * key not found, a new entry 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: pputstring(key, id, string, pdbp)
  20:     char *key;          /* key string */
  21:     char *id;           /* string identifier */
  22:     char *string;           /* string argument */
  23:     PDB *pdbp;          /* database stream */
  24: {
  25:     char *pbfndkey();       /* find key */
  26:     int foundkey;           /* found key flag */
  27:     int pbaddkey();         /* add key */
  28:     int pbaddstring();      /* add string field */
  29:     int pgetent();          /* load next entry into buffer */
  30:     int pputent();          /* write buffer to database */
  31:     void pbclear();         /* clear buffer */
  32:     void rewindpdb();       /* rewind database */
  33: 
  34:     rewindpdb(pdbp);
  35:     foundkey = NO;
  36:     while (pgetent(pdbp) != EOF)
  37:         {
  38:         if (pbfndkey(key) != NULL)
  39:             {       /* key exists */
  40:             pbaddstring(id, string);
  41:             foundkey = YES;
  42:             }
  43:         pputent(pdbp);
  44:         }
  45:     if (foundkey == NO)
  46:         {           /* new entry */
  47:         pbclear();
  48:         pbaddkey(key);
  49:         pbaddstring(id, string);
  50:         pputent(pdbp);
  51:         }
  52: }

Defined functions

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