1772
|
1 /* uulog.c This program allows viewing the uulog and fileserv log files.
|
|
2 Copyright (C) 1990, 1993 Mark Griffith and Bob Billson
|
|
3
|
|
4 This file is part of the OS-9 UUCP package, UUCPbb.
|
|
5
|
|
6 This program is free software; you can redistribute it and/or modify
|
|
7 it under the terms of the GNU General Public License as published by
|
|
8 the Free Software Foundation; either version 2 of the License, or
|
|
9 (at your option) any later version.
|
|
10
|
|
11 This program is distributed in the hope that it will be useful,
|
|
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
14 GNU General Public License for more details.
|
|
15
|
|
16 You should have received a copy of the GNU General Public License
|
|
17 along with this program; if not, write to the Free Software
|
|
18 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
|
19
|
|
20 The author of UUCPbb, Bob Billson, can be contacted at:
|
|
21 bob@kc2wz.bubble.org or uunet!kc2wz!bob or by snail mail:
|
|
22 21 Bates Way, Westfield, NJ 07090
|
|
23 */
|
|
24
|
|
25 /* Simply reads the uulog file for a specific system name or user name entry
|
|
26 and prints it. Defaults to printing every line if no options are given.
|
|
27
|
|
28 Options:
|
|
29 -s<sysname> -show work to/from the remote <sysname>
|
|
30 -u<username> -show work to/from the user <username>
|
|
31 -d<days> -show log file for <days> days ago. Default is
|
|
32 show today's log file
|
|
33 -f -show fileserver logs, default is UUCP logs
|
|
34
|
|
35 Thanks to Mark for giving his okey dokey to modify his original code and
|
|
36 include it in the UUCPbb package. * Changes and additions done by Bob
|
|
37 Billson <...!uunet!kc2wz!bob> are indicated by 'REB'. */
|
|
38
|
|
39 #define MAIN /* Added -- REB */
|
|
40
|
|
41 #include "uucp.h"
|
|
42
|
|
43 /* Globals */
|
|
44 char sysname[9], username[20], logfile[256], fsysname[9], fusername[20];
|
|
45 void usage(), fatal();
|
|
46
|
|
47
|
2106
|
48 int main(argc, argv)
|
1772
|
49 int argc;
|
|
50 char *argv[];
|
|
51 {
|
|
52 register FILE *fd; /* Changed --REB */
|
|
53 flag all, fserver, dayflag, uulflag; /* */
|
|
54 int option;
|
|
55 char *day, line[256];
|
|
56
|
|
57 all = TRUE;
|
|
58 fserver = FALSE; /* look at uulog files --REB */
|
|
59 uulflag = TRUE;
|
|
60 dayflag = FALSE;
|
|
61
|
|
62 /* Process any command line arguments */
|
|
63 while ((option = getopt (argc, argv, "s:u:d:f?")) != EOF)
|
|
64 switch (tolower (option))
|
|
65 {
|
|
66 case 's':
|
|
67 strcpy (sysname, optarg);
|
|
68 all = FALSE;
|
|
69 break;
|
|
70
|
|
71 case 'u':
|
|
72 strcpy (username, optarg);
|
|
73 all = FALSE;
|
|
74 break;
|
|
75
|
|
76 case 'd': /* changed -- REB */
|
|
77 dayflag = TRUE;
|
|
78 day = optarg;
|
|
79 break;
|
|
80
|
|
81 case 'f':
|
|
82 uulflag = FALSE;
|
|
83 break;
|
|
84
|
|
85 case '?':
|
|
86 usage();
|
|
87 }
|
|
88
|
|
89 if ((logdir = getenv ("LOGDIR")) != NULL)
|
|
90 logdir = strdup (logdir);
|
|
91 else
|
|
92 logdir = LOGDIR;
|
|
93
|
|
94 sprintf (logfile, "%s/%s%s%s",
|
|
95 logdir,
|
|
96 uulflag ? "uulog" : "fileserv",
|
|
97 dayflag ? "." : "",
|
|
98 dayflag ? day : "");
|
|
99
|
|
100 if ((fd = fopen (logfile, "r")) == NULL)
|
|
101 exit (_errmsg (errno, "unable to open '%s'\n", logfile));
|
|
102
|
|
103 putchar ('\n');
|
|
104
|
|
105 /* read uulog files */
|
|
106 if (uulflag)
|
|
107 {
|
|
108 while (fgets (line, sizeof (line), fd) != NULL)
|
|
109 {
|
|
110 sscanf (line, "%s %s", fusername, fsysname);
|
|
111
|
|
112 if (!all)
|
|
113 {
|
|
114 if ((strucmp (fsysname, sysname) == 0)
|
|
115 || (strucmp (fusername, username) == 0))
|
|
116 {
|
|
117 fputs (line, stdout);
|
|
118 fflush (stdout);
|
|
119 }
|
|
120 }
|
|
121 else
|
|
122 {
|
|
123 fputs (line, stdout);
|
|
124 fflush (stdout);
|
|
125 }
|
|
126 }
|
|
127 }
|
|
128 else
|
|
129 {
|
|
130 /* show fileserver logs */
|
|
131 while (fgets (line, sizeof (line), fd) != NULL)
|
|
132 {
|
|
133 fputs (line, stdout);
|
|
134 fflush (stdout);
|
|
135 }
|
|
136 }
|
|
137 fclose (fd);
|
|
138 exit (0);
|
|
139 }
|
|
140
|
|
141
|
|
142
|
|
143 void fatal (msg)
|
|
144 char *msg;
|
|
145 {
|
|
146 fprintf (stderr, "uulog: %s\n", msg);
|
|
147 exit (0);
|
|
148 }
|
|
149
|
|
150
|
|
151
|
|
152 void usage()
|
|
153 {
|
|
154 register char **use;
|
|
155 static char *usetxt[] = {
|
|
156 "uulog: examine uucp or fileserver log files",
|
|
157 " ",
|
|
158 "Usage: uulog [-s<sysname> -u<username> -d<days>] [-f]",
|
|
159 " ",
|
|
160 "Opts: -s<sysname> -show work to/from the remote <sysname>",
|
|
161 " -u<username> -show work to/from the user <username>",
|
|
162 " -d<days> -show log file for <days> days ago. Default is show",
|
|
163 " today's log file",
|
|
164 " -f -show fileserver logs, default is UUCP logs",
|
|
165 " ",
|
|
166 NULL
|
|
167 };
|
|
168
|
|
169 for (use = usetxt; *use != NULL; ++use)
|
|
170 fprintf (stderr, "%s\n", *use);
|
|
171
|
|
172 fprintf (stderr, "v%s (%s) This is free software released under the GNU General Public\n",
|
|
173 version, VERDATE);
|
|
174 fputs ("License. Please send suggestions/bug reports to: bob@kc2wz.bubble.org\n", stderr);
|
|
175 exit (0);
|
|
176 }
|