From 61ae95ae3d082ca80b3a1fd96b762dffdbe0abc3 Mon Sep 17 00:00:00 2001 From: Martin Mares Date: Tue, 6 Feb 2001 20:34:51 +0000 Subject: [PATCH] See changelogs... --- ChangeLog | 11 ++++++++ Makefile | 2 +- debian/changelog | 12 ++++++++ ywho.c | 72 +++++++++++++++++++++++++++--------------------- 4 files changed, 65 insertions(+), 32 deletions(-) diff --git a/ChangeLog b/ChangeLog index 779e993..50351b5 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,14 @@ +2001-02-06 Martin Mares + + * Released as version 1.9. + + * ywho.c: Killed a Y2K bug. Lots of cosmetic changes. + (readutmp): Better formatting of tty names. + + * nwho.c, nwhod.c, net.h: Pass longer tty names. Unfortunately + this required a change of packet format, hence addition of magic + numbers at the start of the packet. + Sun Mar 28 22:39:37 1999 Martin Mares * ywho.c: Miscellaneous fixes based on bug reports and patch diff --git a/Makefile b/Makefile index efd9196..4b3255e 100644 --- a/Makefile +++ b/Makefile @@ -1,6 +1,6 @@ # Makefile for the ywho toolkit -CFLAGS=-O2 -m486 -fomit-frame-pointer -Wall -Wno-parentheses -malign-loops=0 -malign-jumps=0 -malign-functions=2 +CFLAGS=-O2 -Wall -Wno-parentheses LDFLAGS=-s ROOT=/ REL=ywho-1.9 diff --git a/debian/changelog b/debian/changelog index c7395d7..428380b 100644 --- a/debian/changelog +++ b/debian/changelog @@ -1,3 +1,15 @@ +ywho (1.9-2) unstable; urgency=low + + * Synced with master CVS. + + -- Martin Mares Tue, 6 Feb 2001 21:33:21 +0100 + +ywho (1.9-1) unstable; urgency=low + + * New upstream release + + -- Martin Mares Tue, 6 Feb 2001 21:21:35 +0100 + ywho (1.0) unstable; urgency=low * First released version. diff --git a/ywho.c b/ywho.c index fc7e4df..a36f27d 100644 --- a/ywho.c +++ b/ywho.c @@ -1,7 +1,7 @@ /* * Extended `who' command, version 1.9. * - * (c) 1996--1999 Martin Mares + * (c) 1996--2001 Martin Mares * * This software may be freely distributed and used according to the terms * of the GNU General Public License. See file COPYING in any of the GNU packages. @@ -37,12 +37,11 @@ static struct procrec *first_procrec; struct utrec { struct utrec *next; pid_t login_pid; - char line_id[4]; + char line[UT_LINESIZE]; time_t login_time, click_time, total_time; char user_name[UT_NAMESIZE+1]; int usr; char host_name[MAXHOSTSIZE+1]; - char line_name[12]; int mesg, detach; struct procrec *proc; }; @@ -76,6 +75,7 @@ readutmp(void) { static struct utmp *ut; static struct passwd *pw; + char *z; utmpname(UTMP_FILE); while (ut = getutent()) if (ut->ut_type == USER_PROCESS && ut->ut_user[0]) @@ -87,9 +87,16 @@ readutmp(void) u->next = first_utrec; first_utrec = u; u->login_pid = ut->ut_pid; - u->line_id[0] = ut->ut_id[0]; - u->line_id[1] = ut->ut_id[1]; - u->line_id[2] = 0; + z = ut->ut_line; + if (!strncmp(z, "tty", 3)) + { + if (z[3] >= '0' && z[3] <= '9') + sprintf(u->line, "c%s", z+3); + else + strcpy(u->line, z+3); + } + else if (!strncmp(z, "pts/", 4)) + strcpy(u->line, z+4); u->login_time = ut->ut_time; strcpy_padded(u->user_name, ut->ut_user, UT_NAMESIZE); pw = getpwnam(u->user_name); @@ -101,21 +108,24 @@ readutmp(void) (MAXHOSTSIZE > UT_HOSTSIZE ? UT_HOSTSIZE : MAXHOSTSIZE)); if ((hlen = strlen(u->host_name)) > maxhost) maxhost = hlen; - strcpy(u->line_name, ut->ut_line); - if (*u->line_name) + strcpy(u->line, ut->ut_line); + if (*u->line) { - char *z = u->line_name; - if (!strncmp(u->line_name, "tty", 3)) - z += 3; - if (!strncmp(z, "pts/", 4)) - z += 3; - strncpy(u->line_id, z, 3); - u->line_id[3] = 0; - if (u->line_id[0] == '/') - u->line_id[0] = 'P'; + char *z = u->line; + if (!strncmp(z, "tty", 3)) + { + if (isdigit(z[0])) + sprintf(u->line, "c%s", z+3); + else + strcpy(u->line, z+3); + } + else if (!strncmp(z, "pts/", 4)) + strcpy(u->line, z+4); + else + strcpy(u->line, z); } strcpy(device, "/dev/"); - strcat(device, u->line_name); + strcat(device, ut->ut_line); if (stat(device, &st)) u->mesg = 2; else @@ -190,7 +200,7 @@ static void dispsys(void) { FILE *f; - char line[256], a[32], b[32], c[32]; + char line[256]; char *z, *w; w = NULL; if (f = fopen("/proc/version", "r")) @@ -213,6 +223,7 @@ dispsys(void) } if (f = fopen("/proc/cpuinfo", "r")) { + char a[32], b[32], c[32]; strcpy(a, "???"); b[0] = 0; c[0] = 0; @@ -274,18 +285,20 @@ dispsys(void) int p,q,p1,q1; fgets(line, 256, f); sscanf(line, "%d.%d%d.%d", &p, &p1, &q, &q1); - printf(", up "); + printf(" up "); puttime(p); - printf(", run "); + printf(" run "); puttime(p-q); fclose(f); } { struct tm *tm; + char *days[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" }; now = time(NULL); tm = localtime(&now); - printf(" at %02d-%02d-%02d/%d %02d.%02d:%02d\n", tm->tm_mday, tm->tm_mon+1, - tm->tm_year, (tm->tm_wday+6)%7, tm->tm_hour, tm->tm_min, tm->tm_sec); + printf(" on %s %02d-%02d-%02d %02d.%02d:%02d", days[tm->tm_wday], tm->tm_mday, tm->tm_mon+1, + tm->tm_year%100, tm->tm_hour, tm->tm_min, tm->tm_sec); + printf(" (%u UE)\n", (unsigned int) now); } if (f = fopen("/proc/loadavg", "r")) { @@ -483,14 +496,13 @@ solve(void) u->next = first_utrec; first_utrec = u; u->login_pid = 0; - u->line_id[0] = 0; + u->line[0] = 0; pw = getpwuid(u->usr = m->usr); if (pw) strcpy(u->user_name, pw->pw_name); else sprintf(u->user_name, "<%d>", m->usr); u->host_name[0] = 0; - u->line_name[0] = 0; u->mesg = 3; u->detach = 0; u->proc = NULL; @@ -517,7 +529,7 @@ comp(struct utrec *a, struct utrec *b) return k; if (!a->host_name[0] && b->host_name[0]) return -1; - return strcmp(a->line_id, b->line_id); + return strcmp(a->line, b->line); } static void @@ -553,13 +565,11 @@ show(void) printf("Name Li MD %-*s LogT IdleT RunT Command\n", maxhost, "From"); for(u=first_utrec; u; u=u->next) { - if (isdigit(u->line_id[0])) - sprintf(u->line_id, "c%d", atoi(u->line_id)); - if (!u->line_id[0]) - strcpy(u->line_id, "--"); + if (!u->line[0]) + strcpy(u->line, "--"); printf("%-8.8s %-3s %c%c %-*.*s ", u->user_name, - u->line_id, + u->line, u->mesg ? ' ' : '-', u->detach ? 'D' : ' ', maxhost, -- 2.39.2