|
DataMuseum.dkPresents historical artifacts from the history of: DKUUG/EUUG Conference tapes |
This is an automatic "excavation" of a thematic subset of
See our Wiki for more about DKUUG/EUUG Conference tapes Excavated with: AutoArchaeologist - Free & Open Source Software. |
top - downloadIndex: ┃ T l ┃
Length: 1294 (0x50e) Types: TextFile Names: »lastlog.c«
└─⟦a0efdde77⟧ Bits:30001252 EUUGD11 Tape, 1987 Spring Conference Helsinki └─ ⟦this⟧ »EUUGD11/euug-87hel/sec8/mcp/src/lastlog.c«
#include <sys/file.h> #include <stdio.h> #include <sys/types.h> #include <lastlog.h> #include "sysdep.h" #include "mem.h" #include "save.h" static struct lastlog zero; struct lastlog ll; long lseek(); int LL_FileDes = UNDEFINED; setllent() { if (LL_FileDes == UNDEFINED) { LL_FileDes = open(LASTLOG, O_RDONLY); if (LL_FileDes < 0) { perr(LASTLOG); goodbye(1); } } lseek(LL_FileDes, (long)0, L_SET)<0&&perr("setllent: lseek failed?!"); return; } endllent() { if (LL_FileDes == UNDEFINED) return; (void) close(LL_FileDes); LL_FileDes = UNDEFINED; return; } struct lastlog * getllent() { if (LL_FileDes == UNDEFINED) setllent(); if (read(LL_FileDes, (char *)&ll, sizeof ll) != sizeof ll) return(&zero); else return(&ll); } struct lastlog * getlluid(uid) int uid; { if (LL_FileDes == UNDEFINED) setllent(); lseek(LL_FileDes, (long)(uid * sizeof(struct lastlog)), L_SET)<0 && perr("getlluid: lseek failed!?"); return(getllent()); } addllent(lp, uid) struct lastlog *lp; int uid; { int fd; fd = open(LASTLOG, O_WRONLY); if (fd < 0) { perr(LASTLOG); return; } lseek(fd, (long)(uid * sizeof(struct lastlog)), L_SET)<0&& panic("addllent: lseek failed!?"); (void) write(fd, (char *)lp, sizeof(struct lastlog)); (void) close(fd); return; }