1: /* $Header$ */ 2: 3: /* 4: * Author: Peter J. Nicklin 5: */ 6: 7: /* 8: * pfndent() loads a database entry corresponding to key into the current 9: * working buffer CURPBUF. Database must be open for reading only. 10: * Returns integer YES if key found, otherwise NO. 11: */ 12: #include <stdio.h> 13: #include "null.h" 14: #include "path.h" 15: #include "pdb.h" 16: #include "yesno.h" 17: 18: pfndent(key, pdbp) 19: char *key; /* key string */ 20: PDB *pdbp; /* database stream */ 21: { 22: char *pbfndkey(); /* find key */ 23: char *sprintf(); /* print output to string */ 24: int pgetent(); /* load next entry into buffer */ 25: void rewindpdb(); /* rewind database */ 26: 27: if ((pdbp->flag&_PERR) != 0) 28: return(NO); 29: if ((pdbp->flag&(_PWRITE|_PAPPEND)) != 0) 30: { 31: sprintf(pdbp->perr, "%s must be read access only", pdbp->path); 32: pdbp->flag |= _PERR; 33: return(NO); 34: } 35: rewindpdb(pdbp); 36: while (pgetent(pdbp) != EOF) 37: if (pbfndkey(key) != NULL) 38: return(YES); 39: return(NO); 40: }