From: Paul Eggert Date: Wed, 30 Mar 2005 05:24:05 +0000 (+0000) Subject: (who): New arg OPTIONS. All uses changed. X-Git-Tag: CPPI-1_12~1145 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=78abb1a7573d5a187630f2908183f9a5efa13ac7;p=platform%2Fupstream%2Fcoreutils.git (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. --- diff --git a/src/who.c b/src/who.c index c69285fa4..3d9d023e7 100644 --- a/src/who.c +++ b/src/who.c @@ -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 */ + 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 */ - who (argv[optind]); - break; - - case 2: /* who */ - my_line_only = true; - who (UTMP_FILE); + who (argv[optind], 0); break; default: /* lose */