1: /*	@(#)ucount.c	2.1	SCCS id keyword	*/
   2: #include    <stdio.h>
   3: #include    <utmp.h>
   4: 
   5: # define    reg register
   6: 
   7: typedef struct  utmp    UTMP;
   8: 
   9: static UTMP Utstr;
  10: static  char    UTMPFILE[] = "/etc/utmp";
  11: 
  12: /*
  13:  *	This routine returns the number of users currently logged
  14:  * on the system.  It opens the utmp file, counts users by noting
  15:  * non-null login names, and then closes it.
  16:  */
  17: ucount() {
  18: 
  19:     reg UTMP    *uts;
  20:     reg int     num;
  21:     reg FILE    *inf;
  22:     reg char    *sp;
  23: 
  24:     uts = &Utstr;
  25:     num = 0;
  26:     if ((inf=fopen(UTMPFILE, "r")) == NULL) {
  27:         perror(UTMPFILE);
  28:         exit(1);
  29:     }
  30:     while (fread(uts, 1, sizeof (UTMP), inf) > 0)
  31:         if (uts->ut_name[0] != '\0')
  32:             num++;
  33:     fclose(inf);
  34:     return num;
  35: }

Defined functions

ucount defined in line 17; used 1 times

Defined variables

UTMPFILE defined in line 10; used 2 times
Utstr defined in line 9; used 1 times
  • in line 24

Defined typedef's

UTMP defined in line 7; used 3 times

Defined macros

reg defined in line 5; used 4 times
Last modified: 1981-07-10
Generated: 2016-12-26
Generated by src2html V0.67
page hit count: 708
Valid CSS Valid XHTML 1.0 Strict