|
|
1.1 ! root 1: # include <stdio.h> ! 2: # include <ingres.h> ! 3: # include <aux.h> ! 4: # include <sccs.h> ! 5: ! 6: SCCSID(@(#)getuser.c 7.1 2/5/81) ! 7: ! 8: /* ! 9: ** GET LINE FROM USER FILE ! 10: ** ! 11: ** Given a user code (a two byte string), this routine returns ! 12: ** the line from .../files/users into `buf'. The users ! 13: ** file is automatically opened, and it is closed if getperm ! 14: ** is called with `code' == 0. ! 15: ** ! 16: ** If `code' == -1 then getuser will reinitialize itself. ! 17: ** This will guarantee that getuser will reopen the file ! 18: ** if (for example) an interrupt occured during the previous ! 19: ** call. ! 20: */ ! 21: ! 22: getuser(code, buf) ! 23: char *code; ! 24: char buf[]; ! 25: { ! 26: static FILE *userf; ! 27: register char c; ! 28: register char *bp; ! 29: extern char *index(); ! 30: ! 31: if (code == 0) ! 32: { ! 33: if (userf != NULL) ! 34: fclose(userf); ! 35: userf = NULL; ! 36: return (0); ! 37: } ! 38: if (code == (char *) -1) ! 39: { ! 40: userf = NULL; ! 41: return (0); ! 42: } ! 43: if (userf == NULL) ! 44: { ! 45: userf = fopen(ztack(Pathname, "/files/users"), "r"); ! 46: if (userf == NULL) ! 47: syserr("getuser: open err"); ! 48: } ! 49: rewind(userf); ! 50: ! 51: for (;;) ! 52: { ! 53: bp = buf; ! 54: if (fgets(bp, MAXLINE, userf) == NULL) ! 55: return (1); ! 56: *index(bp, '\n') = '\0'; ! 57: while ((c = *bp++) != ':') ! 58: if (c == '\0') ! 59: return (1); ! 60: if (bequal(bp, code, 2)) ! 61: return (0); ! 62: } ! 63: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.