File: utmp_users.c

package info (click to toggle)
ngetty 1.1-3.1
  • links: PTS
  • area: main
  • in suites: buster
  • size: 392 kB
  • sloc: ansic: 1,588; makefile: 206; sh: 193; asm: 100
file content (18 lines) | stat: -rw-r--r-- 357 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
#include <unistd.h>
#include <fcntl.h>
#include "lib.h"

unsigned long utmp_users() /*EXTRACT_INCL*/ {
  unsigned long u=0;
#ifdef USE_LIBC_UTMP
  struct utmp_type *ut;
  f_setutent();
#else
  struct utmp_type ut[1];
  int fd = open(Utmp_File, O_RDONLY);
#endif
  while (f_getutent())
    if (ut->ut_type == USER_PROCESS) u++;
  f_endutent();
  return u;
}