annotate 3rdparty/packages/uucpbb/src/uulog.c @ 3226:9749d0dfc4a2

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