diff options
author | Paul Eggert <eggert@cs.ucla.edu> | 2005-03-30 05:24:05 +0000 |
---|---|---|
committer | Paul Eggert <eggert@cs.ucla.edu> | 2005-03-30 05:24:05 +0000 |
commit | 78abb1a7573d5a187630f2908183f9a5efa13ac7 (patch) | |
tree | db1ebe3f50f8d6398aa5d96192af9044bea7be16 /src/who.c | |
parent | 08b59778675d670a6dc3e88ce79311388b0c2385 (diff) | |
download | coreutils-78abb1a7573d5a187630f2908183f9a5efa13ac7.tar.xz |
(who): New arg OPTIONS. All uses changed.
(main): Check PIDs when invoked with zero or two arguments.
Omit duplicate code in 2-arg case.
(UT_PID): Moved to ../lib/readutmp.h.
Diffstat (limited to 'src/who.c')
-rw-r--r-- | src/who.c | 21 |
1 files changed, 9 insertions, 12 deletions
@@ -84,12 +84,10 @@ #define IDLESTR_LEN 6 #if HAVE_STRUCT_XTMP_UT_PID -# define UT_PID(U) ((U)->ut_pid) # define PIDSTR_DECL_AND_INIT(Var, Utmp_ent) \ char Var[INT_STRLEN_BOUND (Utmp_ent->ut_pid) + 1]; \ sprintf (Var, "%ld", (long int) (Utmp_ent->ut_pid)) #else -# define UT_PID(U) 0 # define PIDSTR_DECL_AND_INIT(Var, Utmp_ent) \ const char *Var = "" #endif @@ -607,14 +605,15 @@ scan_entries (size_t n, const STRUCT_UTMP *utmp_buf) } } -/* Display a list of who is on the system, according to utmp file filename. */ +/* Display a list of who is on the system, according to utmp file FILENAME. + Use read_utmp OPTIONS to read the file. */ static void -who (const char *filename) +who (const char *filename, int options) { size_t n_users; STRUCT_UTMP *utmp_buf; - if (read_utmp (filename, &n_users, &utmp_buf) != 0) + if (read_utmp (filename, &n_users, &utmp_buf, options) != 0) error (EXIT_FAILURE, errno, "%s", filename); if (short_list) @@ -811,18 +810,16 @@ main (int argc, char **argv) switch (argc - optind) { + case 2: /* who <blurf> <glop> */ + my_line_only = true; + /* Fall through. */ case -1: case 0: /* who */ - who (UTMP_FILE); + who (UTMP_FILE, READ_UTMP_CHECK_PIDS); break; case 1: /* who <utmp file> */ - who (argv[optind]); - break; - - case 2: /* who <blurf> <glop> */ - my_line_only = true; - who (UTMP_FILE); + who (argv[optind], 0); break; default: /* lose */ |