int getplid (char *nam) { int fd7, high = 999, no; char *p, *p2; char name[80]; if (havepid != -1) return (havepid); /* already did it */ lflush (); /* flush any pending I/O */ sprintf (name, "%s\n", nam); /* append a \n to name */ if (lopen (playerids) < 0) /* no file, make it */ { if ((fd7 = _creat (playerids, _S_IWRITE)) < 0) return (-1); /* can't make it */ _close (fd7); goto addone; /* now append new playerid record to file */ } for (;;) /* now search for the name in the player id file */ { p = lgetl (); if (p == NULL) break; /* EOF? */ no = atoi (p); /* the id # */ p2 = lgetl (); if (p2 == NULL) break; /* EOF? */ if (no > high) high = no; /* accumulate highest id # */ if (strcmp (p2, name) == 0) /* we found him */ { return (no); /* his id number */ } } lrclose (); /* if we get here, we didn't find him in the file -- put him there */ addone: if (lappend (playerids) < 0) return (-1); /* can't open file for append */ lprintf ("%d\n%s", (int) ++high, name); /* new id # and name */ lwclose (); lcreat ((char *) 0); /* re-open terminal channel */ return (high); }
/* * help function to display the help info * * format of the .larn.help file * * 1st character of file: # of pages of help available (ascii digit) * page (23 lines) for the introductory message (not counted in above) * pages of help text (23 lines per page) */ void help(void) { int i, j; #ifndef VT100 char tmbuf[128]; /* intermediate translation buffer when not a VT100 */ #endif /* VT100 */ if ((j = openhelp()) < 0) /* open the help file and get # pages */ return; for (i = 0; i < 23; i++) /* skip over intro message */ lgetl(); for (; j > 0; j--) { clear(); for (i = 0; i < 23; i++) #ifdef VT100 lprcat(lgetl()); /* print out each line that we read in */ #else /* VT100 */ { tmcapcnv(tmbuf, lgetl()); lprcat(tmbuf); } /* intercept \33's */ #endif /* VT100 */ if (j > 1) { lprcat(" ---- Press "); standout("return"); lprcat(" to exit, "); standout("space"); lprcat(" for more help ---- "); i = 0; while ((i != ' ') && (i != '\n') && (i != '\33')) i = getchr(); if ((i == '\n') || (i == '\33')) { lrclose(); setscroll(); drawscreen(); return; } } } lrclose(); retcont(); drawscreen(); }
/* * function to display the welcome message and background */ void welcome(void) { int i; #ifndef VT100 char tmbuf[128]; /* intermediate translation buffer when not a VT100 */ #endif /* VT100 */ if (openhelp() < 0) /* open the help file */ return; clear(); for (i = 0; i < 23; i++) #ifdef VT100 lprcat(lgetl());/* print out each line that we read in */ #else /* VT100 */ { tmcapcnv(tmbuf, lgetl()); lprcat(tmbuf); } /* intercept \33's */ #endif /* VT100 */ lrclose(); retcont(); /* press return to continue */ }
/* the symbol table entry pointed to by lmte*/ getsym() /* rewritten for vax */ { register int i; long lvalue; char *p; short wvalue; p = lmte; for(i=SYNAMLEN; --i != -1; ) /* 2 may 83 */ *p++ = getc(&ibuf); /* get name */ if (lgetw(&wvalue, &ibuf) == -1) printf(": error reading symbol table entry\n"); else if (lgetl(&lvalue ,&ibuf) == -1) printf(": error reading symbol table entry\n"); /* symbol value */ ((struct symtab *)lmte)->flags = wvalue; ((struct symtab *)lmte)->vl1 = lvalue; #ifdef DEBUG printf("\tname= %s, flags= %o, val= %d\n", ((struct symtab *)lmte)->name, ((struct symtab *)lmte)->flags, ((struct symtab *)lmte)->vl1); #endif }