void update_last_caller() { int fd, fdb; char filename[80], backup[80]; long stamp; struct _lastcall lc; stamp = time (NULL); memset ((char *)&lastcall, 0, sizeof (struct _lastcall)); sprintf (backup, "%sLASTCALL.BAK", config.sys_path); sprintf (filename, "%sLASTCALL.BBS", config.sys_path); unlink (backup); rename (filename, backup); fdb = shopen (backup, O_RDONLY|O_BINARY); if (fdb == -1) return; fd = cshopen (filename, O_RDONLY|O_BINARY|O_CREAT, S_IREAD|S_IWRITE); while (read(fdo, (char *)&lc, sizeof(struct _lastcall)) == sizeof(struct _lastcall)) { if (stamp - lc.timestamp < 86400L) write (fd, (char *)&lc, sizeof (struct _lastcall)); } close (fd); close (fdo); }
word FindProtocol(sword protocol, struct _proto *pro) { char fname[PATHLEN], *p; long seekit; word ret=FALSE; int fd; /* Handle a user-specified protocol.max file */ p=PRM(protocol_max); if (*p) strcpy(fname, p); else sprintf(fname, "%sprotocol.max", PRM(sys_path)); if ((fd=shopen(fname, O_RDONLY | O_BINARY | O_NOINHERIT))==-1) { cant_open(fname); return FALSE; } seekit=sizeof(struct _proto)*protocol; if (lseek(fd, seekit, SEEK_SET)==seekit && read(fd, (char *)pro, sizeof(struct _proto))==sizeof(struct _proto)) { ret=TRUE; } close(fd); return ret; }
static void near Update_Lastuser(void) { char temp[80]; struct _usr user; int lu; #ifdef TTYVIDEO if (displaymode != VIDEO_IBM) return; #endif sprintf(temp, task_num ? lastusxx_bbs : lastuser_bbs, original_path, task_num); if ((lu=shopen(temp, O_RDONLY | O_BINARY))==-1) WinPutstr(win_stat, 4, 16, wfc_no_last_caller); else { if (read(lu, (char *)&user, sizeof(struct _usr))==sizeof(struct _usr)) { /* Make sure that WFC window isn't scrolled by a long name */ user.name[20]='\0'; WinPutstr(win_stat, 4, 16, user.name); } close(lu); } WinSync(win_stat, FALSE); }
HPRM PrmFileOpen(char *pszFile, int iAbortOnError) { char pszName[PATHLEN]; int fd; /* descriptor for .prm file */ long lSize; /* file size */ size_t stHeap; /* size of variable-length heap */ HPRM hp; /* handle to be returned to caller */ if ((hp = malloc(sizeof *hp))==NULL) { if (iAbortOnError) PrmAbort(pszFile, 0, iAbortOnError); else return NULL; } if ((fd=shopen(pszFile, O_RDONLY | O_BINARY))==-1) { /* Try adding a default .prm extension */ strcpy(pszName, pszFile); strcat(pszName, ".prm"); if ((fd=shopen(pszName, O_RDONLY | O_BINARY))==-1) { if (iAbortOnError) PrmAbort(pszFile, 1, iAbortOnError); else { free(hp); return NULL; } } } if (read(fd, (char *)&hp->mp, sizeof hp->mp) != sizeof hp->mp) { if (iAbortOnError) PrmAbort(pszFile, 2, iAbortOnError); else { close(fd); free(hp); return NULL; } } if (hp->mp.id != 'M' || hp->mp.version != CTL_VER || hp->mp.heap_offset != sizeof(struct m_pointers)) { if (iAbortOnError) PrmAbort(pszFile, 3, iAbortOnError); else { close(fd); free(hp); return NULL; } } /* Figure out the size of the variable-length heap */ lSize = lseek(fd, 0L, SEEK_END); stHeap = (size_t)(lSize - (long)sizeof(struct m_pointers)); lseek(fd, (long)sizeof(struct m_pointers), SEEK_SET); if ((hp->pszHeap = malloc(stHeap))==NULL) { if (iAbortOnError) PrmAbort(pszFile, 0, iAbortOnError); else { close(fd); free(hp); return NULL; } } /* Read in the variable-length heap */ if (read(fd, hp->pszHeap, stHeap) != stHeap) { if (iAbortOnError) PrmAbort(pszFile, 2, iAbortOnError); else { close(fd); free(hp); return NULL; } } close(fd); return hp; }