/*
- * Extended `who' command, version 1.11.
+ * Extended `who' command, version 1.12.
*
- * (c) 1996--2003 Martin Mares <mj@ucw.cz>
+ * (c) 1996--2010 Martin Mares <mj@ucw.cz>
*
* 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.
}
{
- struct tm *tm;
- char *days[] = { "Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat" };
now = time(NULL);
- tm = localtime(&now);
- 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);
+ struct tm *tm = localtime(&now);
+ strftime(line, sizeof(line), "%a %Y-%m-%d %H.%M:%S", tm);
+ printf(" on %s\n", line);
}
}
{
int i = 3;
fgets(line, 256, f);
- *strchr(line, '\n') = 0;
- z = line-1;
+ z = strchr(line, '\n');
+ if (z)
+ *z = 0;
+ z = line;
while (i-- && z)
{
- *z = '/';
+ if (z > line)
+ *z = '/';
z = strchr(z, ' ');
}
if (z)
putchar(' ');
puttime((unsigned)u->total_time/(unsigned)HZ);
putchar(' ');
- for (c = u->proc->cmd_line; *c; c++)
+ for (c = (unsigned char *) u->proc->cmd_line; *c; c++)
{
if (*c < 0x20 || (*c >= 0x7f && *c < 0xa0))
putchar(' ');