1: /* $Header$ */ 2: 3: /* 4: * Author: Peter J. Nicklin 5: */ 6: 7: /* 8: * pbchgkey() substitutes newkey for oldkey. Returns integer NO if buffer 9: * space exceeded, otherwise YES. 10: */ 11: #include "null.h" 12: #include "pdbuf.h" 13: #include "yesno.h" 14: 15: pbchgkey(oldkey, newkey) 16: char *oldkey; /* old key string */ 17: char *newkey; /* new key string */ 18: { 19: register char *bp; /* buffer pointer */ 20: char *pbfndkey(); /* find key */ 21: char *strncpy(); /* copy n characters */ 22: int chgklen; /* incremental key string length */ 23: int newklen; /* new key string length */ 24: int pbstretch(); /* stretch buffer */ 25: int strlen(); /* string length */ 26: 27: if ((bp = pbfndkey(newkey)) != NULL) 28: pbrmkey(oldkey); 29: else if ((bp = pbfndkey(oldkey)) != NULL) 30: { 31: newklen = strlen(newkey); 32: chgklen = newklen - strlen(oldkey); 33: if (pbstretch(bp, chgklen) == NO) 34: return(NO); 35: strncpy(bp, newkey, newklen); 36: } 37: return(YES); 38: }