Пример #1
0
/*
 *	readboard() 	Function to read in the scoreboard into a static buffer
 *
 *	returns -1 if unable to read in the scoreboard, returns 0 if all is OK
 */
readboard()
	{
	if (lopen(scorefile)<0)
	  { lprcat("Can't read scoreboard\n"); lflush(); return(-1); }
	lrfill((char*)sco,sizeof(sco));		lrfill((char*)winr,sizeof(winr));
	lrclose();  lcreat((char*)0);  return(0);
	}
Пример #2
0
/*
 * readboard()	Function to read in the scoreboard into a static buffer
 *
 * returns -1 if unable to read in the scoreboard, returns 0 if all is OK
 */
int
readboard()
{
	int	i;

	setegid(egid);
	i = lopen(scorefile);
	setegid(gid);
	if (i < 0) {
		lprcat("Can't read scoreboard\n");
		lflush();
		return (-1);
	}
	lrfill((char *) sco, sizeof(sco));
	lrfill((char *) winr, sizeof(winr));
	lrclose();
	lcreat((char *) 0);
	return (0);
}
Пример #3
0
/*
*  readboard()     Function to read in the scoreboard into a static buffer
*
*  returns -1 if unable to read in the scoreboard, returns 0 if all is OK
*/
static int
readboard (void)
{

  if (lopen (scorefile) < 0)
    {

      lprcat ("Can't read scoreboard\n");
      lflush ();

      return -1;
    }

  lrfill ((char *) sco, sizeof (sco));
  lrfill ((char *) winr, sizeof (winr));
  lrclose ();
  lcreat ((char *) 0);
  return 0;
}
Пример #4
0
/*
*  diedlog()   Subroutine to read a log file and print it out in ascii format
*/
void
diedlog (void)
{
  int n;
  char *p;
  struct stat stbuf;

  lcreat ((char *) 0);
  if (lopen (logfile) < 0)
    {
      lprintf ("Can't locate log file <%s>\n", logfile);
      return;
    }
  if (fstat (fd, &stbuf) < 0)
    {
      lprintf ("Can't  stat log file <%s>\n", logfile);
      return;
    }
  for (n = stbuf.st_size / sizeof (struct log_fmt); n > 0; --n)
    {
      lrfill ((char *) &logg, sizeof (struct log_fmt));
      p = ctime ((time_t *) & logg.diedtime);
      p[16] = '\n';
      p[17] = 0;
      lprintf ("Score: %d, Diff: %d,  %s %s on %d at %s", (int) (logg.score),
	       (int) (logg.diff), logg.who, logg.what, (int) (logg.cavelev),
	       p + 4);
#ifdef EXTRA
      if (logg.moves <= 0)
	logg.moves = 1;
      lprintf
	("  Experience Level: %d,  AC: %d,  HP: %d/%d,  Elapsed Time: %d minutes\n",
	 (int) (logg.lev), (int) (logg.ac), (int) (logg.hp),
	 (int) (logg.hpmax), (int) (logg.elapsedtime));

      lprintf
	("  BYTES in: %d, out: %d, moves: %d, deaths: %d, spells cast: %d\n",
	 (int) (logg.bytin), (int) (logg.bytout), (int) (logg.moves),
	 (int) (logg.killed), (int) (logg.spused));
      lprintf ("  out bytes per move: %d", (int) (logg.bytout / logg.moves));
      lprintf ("\n");
#endif
    }
  lflush ();
  lrclose ();
  return;
}
Пример #5
0
/*
 * diedlog() 	Subroutine to read a log file and print it out in ascii format
 */
void
diedlog(void)
{
	int    n;
	char  *p;
	static char  q[] = "?";
	struct stat     stbuf;
	time_t t;

	lcreat((char *) 0);
	if (lopen(logfile) < 0) {
		lprintf("Can't locate log file <%s>\n", logfile);
		return;
	}
	if (fstat(io_infd, &stbuf) < 0) {
		lprintf("Can't  stat log file <%s>\n", logfile);
		return;
	}
	for (n = stbuf.st_size / sizeof(struct log_fmt); n > 0; --n) {
		lrfill((char *) &logg, sizeof(struct log_fmt));
		t = logg.diedtime;
		if ((p = ctime(&t)) == NULL)
			p = q;
		else {
			p[16] = '\n';
			p[17] = 0;
		}
		lprintf("Score: %ld, Diff: %ld,  %s %s on %ld at %s", (long) (logg.score), (long) (logg.diff), logg.who, logg.what, (long) (logg.cavelev), p + 4);
#ifdef EXTRA
		if (logg.moves <= 0)
			logg.moves = 1;
		lprintf("  Experience Level: %ld,  AC: %ld,  HP: %ld/%ld,  Elapsed Time: %ld minutes\n", (long) (logg.lev), (long) (logg.ac), (long) (logg.hp), (long) (logg.hpmax), (long) (logg.elapsedtime));
		lprintf("  CPU time used: %ld seconds,  Machine usage: %ld.%02ld%%\n", (long) (logg.cputime), (long) (logg.usage / 100), (long) (logg.usage % 100));
		lprintf("  BYTES in: %ld, out: %ld, moves: %ld, deaths: %ld, spells cast: %ld\n", (long) (logg.bytin), (long) (logg.bytout), (long) (logg.moves), (long) (logg.killed), (long) (logg.spused));
		lprintf("  out bytes per move: %ld,  time per move: %ld ms\n", (long) (logg.bytout / logg.moves), (long) ((logg.cputime * 1000) / logg.moves));
#endif
	}
	lflush();
	lrclose();
	return;
}