count_active.c

lpmud/count_active.c · 438 B

From the archive lpmud-1.4.1-A-r11.tar.gz

Download the archive   « Back to the archive contents

#include "os.h"

/*
 * Count the number of active players.
 * A players is supposed to be active, if he has logged in the last
 * 30 days.
 */

int main (int argc, char **argv)
{
  struct stat st;
  int i, num;
  time_t now;

  now = time (0l);
  for (i = 1, num = 0; i < argc; i++) {
    if (stat (argv[i], &st) == -1)
      continue;
    if (now - st.st_mtime < 30 * 24 * 60 * 60)
      num++;
  }
  printf ("%d\n", num);
  return 0;
}

Site Stats

Snippets: 1791
Codebases: 571