Display the UUCP log file.
Copyright (C) 1991, 1992 Ian Lance Taylor
This file is part of the Taylor UUCP package.
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 the Free Software Foundation; either version 2 of the
License, or (at your option) any later version.
This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software
Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
The author of the program may be contacted at ian@airs.com or
c/o Infinity Development Systems, P.O. Box 520, Waltham, MA 02254.
const char uulog_rcsid
[] = "$Id: uulog.c,v 1.1 1993/08/04 19:36:47 jtc Exp $";
/* This is a pretty bad implementation of uulog, which I don't think
is a very useful program anyhow. It only takes a single -s and/or
-u switch. When using HAVE_HDB_LOGGING it requires a system. */
char abProgram
[] = "uulog";
static void ulusage
P((void));
/* Long getopt options. */
static const struct option asLlongopts
[] = { { NULL
, 0, NULL
, 0 } };
/* -D: display Debug file */
/* -f: keep displaying lines forever. */
boolean fforever
= FALSE
;
/* -n lines: number of lines to display. */
const char *zsystem
= NULL
;
/* -S: display Stats file */
const char *zuser
= NULL
;
/* -I: configuration file name. */
const char *zconfig
= NULL
;
/* -x: display uuxqt log file. */
/* Look for a straight number argument, and convert it to -n before
passing the arguments to getopt. */
for (i
= 0; i
< argc
; i
++)
if (argv
[i
][0] == '-' && isdigit (argv
[i
][1]))
znew
= zbufalc (clen
+ 2);
memcpy (znew
+ 2, argv
[i
] + 1, clen
);
while ((iopt
= getopt_long (argc
, argv
, "Df:FI:n:s:Su:xX:", asLlongopts
,
/* Show debugging file. */
/* Keep displaying lines forever for a particular system. */
/* Keep displaying lines forever. */
/* Configuration file name. */
if (fsysdep_other_config (optarg
))
/* Number of lines to display. */
cshow
= (int) strtol (optarg
, (char **) NULL
, 10);
/* Show statistics file. */
/* Display uuxqt log file. */
/* Set debugging level. */
iDebug
|= idebug_parse (optarg
);
/* Long option found and flag set. */
if (optind
!= argc
|| (fstats
&& fdebug
))
iuuconf
= uuconf_init (&puuconf
, (const char *) NULL
, zconfig
);
if (iuuconf
!= UUCONF_SUCCESS
)
ulog_uuconf (LOG_FATAL
, puuconf
, iuuconf
);
iuuconf
= uuconf_debuglevel (puuconf
, &zdebug
);
if (iuuconf
!= UUCONF_SUCCESS
)
ulog_uuconf (LOG_FATAL
, puuconf
, iuuconf
);
iDebug
|= idebug_parse (zdebug
);
iuuconf
= uuconf_logfile (puuconf
, &zlogfile
);
if (iuuconf
!= UUCONF_SUCCESS
)
ulog_uuconf (LOG_FATAL
, puuconf
, iuuconf
);
iuuconf
= uuconf_statsfile (puuconf
, &zstatsfile
);
if (iuuconf
!= UUCONF_SUCCESS
)
ulog_uuconf (LOG_FATAL
, puuconf
, iuuconf
);
iuuconf
= uuconf_debugfile (puuconf
, &zdebugfile
);
if (iuuconf
!= UUCONF_SUCCESS
)
ulog_uuconf (LOG_FATAL
, puuconf
, iuuconf
);
usysdep_initialize (puuconf
, 0);
if (strcmp (zsystem
, "ANY") != 0)
struct uuconf_system ssys
;
iuuconf
= uuconf_system_info (puuconf
, zsystem
, &ssys
);
if (iuuconf
!= UUCONF_SUCCESS
)
if (iuuconf
!= UUCONF_NOT_FOUND
)
ulog_uuconf (LOG_FATAL
, puuconf
, iuuconf
);
ulog (LOG_FATAL
, "%s: System not found", zsystem
);
zsystem
= zbufcpy (ssys
.uuconf_zname
);
(void) uuconf_system_free (puuconf
, &ssys
);
/* We need a system to find a HDB log file. */
zalc
= zbufalc (strlen (zlogfile
)
sprintf (zalc
, zlogfile
, zprogram
, zsystem
);
if (strcmp (zsystem
, "ANY") == 0)
ulog (LOG_ERROR
, "fopen (%s): %s", zfile
, strerror (errno
));
pzshow
= (char **) xmalloc (cshow
* sizeof (char *));
for (ishow
= 0; ishow
< cshow
; ishow
++)
/* Read the log file and output the appropriate lines. */
csystem
= strlen (zsystem
);
while (getline (&zline
, &cline
, e
) > 0)
char *zluser
, *zlsys
, *znext
;
/* Skip any leading whitespace (not that there should be
znext
= zline
+ strspn (zline
, " \t");
#if ! HAVE_TAYLOR_LOGGING
/* The user name is the first field on the line. */
cluser
= strcspn (znext
, " \t");
/* Skip the first field. */
znext
+= strcspn (znext
, " \t");
znext
+= strspn (znext
, " \t");
/* The system is the second field on the line. */
clsys
= strcspn (znext
, " \t");
/* Skip the second field. */
znext
+= strspn (znext
, " \t");
/* The user is the third field on the line. */
cluser
= strcspn (znext
, " \t");
/* The user name is the first field on the line, and the
system name is the second. */
cluser
= strcspn (znext
, " \t");
znext
+= strspn (znext
, " \t");
clsys
= strcspn (znext
, " \t");
/* The first field is system!user. */
clsys
= strcspn (znext
, "!");
clsys
= strcspn (znext
, " \t");
/* See if we should print this line. */
|| strncmp (zsystem
, zlsys
, clsys
) != 0))
|| strncmp (zuser
, zluser
, cluser
) != 0))
/* Output the line, or save it if we are outputting only a
particular number of lines. */
ubuffree ((pointer
) pzshow
[ishow
]);
pzshow
[ishow
] = zbufcpy (zline
);
ishow
= (ishow
+ 1) % cshow
;
/* Output the number of lines requested by the -n option. */
for (i
= 0; i
< cshow
; i
++)
if (pzshow
[ishow
] != NULL
)
printf ("%s", pzshow
[ishow
]);
ishow
= (ishow
+ 1) % cshow
;
/* If -f was not specified, or an error occurred while reading
if (! fforever
|| ferror (e
))
/* Sleep 1 second before going around the loop again. */
/* Avoid errors about not returning a value. */
/* Print a usage message and die. */
"Taylor UUCP version %s, copyright (C) 1991, 1992 Ian Lance Taylor\n",
"Usage: uulog [-n #] [-sf system] [-u user] [-xDSF] [-I file] [-X debug]\n");
" -n: show given number of lines from end of log\n");
" -s: print entries for named system\n");
" -f: follow entries for named system\n");
" -u: print entries for named user\n");
" -x: print uuxqt log rather than uucico log\n");
" -F: follow entries for any system\n");
" -S: show statistics file\n");
" -D: show debugging file\n");
" -X debug: Set debugging level (0 for none, 9 is max)\n");
" -I file: Set configuration file to use\n");
#endif /* HAVE_TAYLOR_CONFIG */