/* GNU's who.
- Copyright (C) 1992-2001 Free Software Foundation, Inc.
+ Copyright (C) 1992-2002 Free Software Foundation, Inc.
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
#include <sys/types.h>
#include "system.h"
-#include "error.h"
+#include "xalloc.h"
#include "readutmp.h"
+#include "error.h"
#include "closeout.h"
/* The official name of this program (e.g., no `g' prefix). */
PIDSTR_DECL_AND_INIT (pidstr);
if (!comment)
- comment =
- (char *) malloc (sizeof (_("id=")) + sizeof (utmp_ent->ut_id) + 1);
+ comment = xmalloc (sizeof (_("id=")) + sizeof (utmp_ent->ut_id) + 1);
sprintf (comment, "%s%.*s", _("id="), sizeof utmp_ent->ut_id,
utmp_ent->ut_id);
if (!exitstr)
- exitstr = (char *) malloc (sizeof (_("term="))
- + INT_STRLEN_BOUND (utmp_ent->ut_exit.e_termination) + 1
- + sizeof (_("exit="))
- + INT_STRLEN_BOUND (utmp_ent->ut_exit.e_exit)
- + 1);
+ exitstr = xmalloc (sizeof (_("term="))
+ + INT_STRLEN_BOUND (utmp_ent->ut_exit.e_termination) + 1
+ + sizeof (_("exit="))
+ + INT_STRLEN_BOUND (utmp_ent->ut_exit.e_exit)
+ + 1);
sprintf (exitstr, "%s%d %s%d", _("term="), utmp_ent->ut_exit.e_termination,
_("exit="), utmp_ent->ut_exit.e_exit);
PIDSTR_DECL_AND_INIT (pidstr);
if (!comment)
- comment =
- (char *) malloc (sizeof (_("id=")) + sizeof (utmp_ent->ut_id) + 1);
+ comment = xmalloc (sizeof (_("id=")) + sizeof (utmp_ent->ut_id) + 1);
sprintf (comment, "%s%s", _("id="), utmp_ent->ut_id);
/* FIXME: add idle time? */
PIDSTR_DECL_AND_INIT (pidstr);
if (!comment)
- comment =
- (char *) malloc (sizeof (_("id=")) + sizeof (utmp_ent->ut_id) + 1);
+ comment = xmalloc (sizeof (_("id=")) + sizeof (utmp_ent->ut_id) + 1);
sprintf (comment, "%s%s", _("id="), utmp_ent->ut_id);
print_line ("", ' ', utmp_ent->ut_line,
#endif
if (!runlevline)
- runlevline = (char *) malloc (sizeof (_("run-level")) + 3);
+ runlevline = xmalloc (sizeof (_("run-level")) + 3);
sprintf (runlevline, "%s %c", _("run-level"), curr);
if (!comment)
- comment = (char *) malloc (sizeof (_("last=")) + 2);
+ comment = xmalloc (sizeof (_("last=")) + 2);
sprintf (comment, "%s%c", _("last="), (last == 'N') ? 'S' : last);
print_line ("", ' ', runlevline, time_string (utmp_ent),