comparison src/tool-wm.c @ 8:0836fb919dfa

First entry of Paradise Server 2.9 patch 10 Beta
author darius
date Sat, 06 Dec 1997 04:37:05 +0000
parents
children
comparison
equal deleted inserted replaced
7:814de70c9f67 8:0836fb919dfa
1 /*--------------------------------------------------------------------------
2 NETREK II -- Paradise
3
4 Permission to use, copy, modify, and distribute this software and its
5 documentation, or any derivative works thereof, for any NON-COMMERCIAL
6 purpose and without fee is hereby granted, provided that this copyright
7 notice appear in all copies. No representations are made about the
8 suitability of this software for any purpose. This software is provided
9 "as is" without express or implied warranty.
10
11 Xtrek Copyright 1986 Chris Guthrie
12 Netrek (Xtrek II) Copyright 1989 Kevin P. Smith
13 Scott Silvey
14 Paradise II (Netrek II) Copyright 1993 Larry Denys
15 Kurt Olsen
16 Brandon Gillespie
17 --------------------------------------------------------------------------*/
18
19 /*
20 * // overhaul by Brandon Gillespie Sept 17 1994
21 */
22
23 #include "config.h"
24
25 #include <stdio.h>
26 #include <stdlib.h>
27 #include <string.h>
28 #include "defs.h"
29 #include "data.h"
30 #include "struct.h"
31 #include "shmem.h"
32
33 #define CNORMAL "\33[37;0m"
34 #define CBOLD "\33[1m"
35 #define CRED "\33[31m"
36 #define CGREEN "\33[32m"
37 #define CYELLOW "\33[33m"
38 #define CBLUE "\33[34m"
39 #define CMAGENTA "\33[35m"
40 #define CCYAN "\33[36m"
41
42 /* prototypes */
43 void printmes(char mstr[80], int mflags, int mrecpt, int mfrom);
44 void usage(char *me);
45 static int contains(char *str1, char *str2);
46
47 #define PRINT(__x) if (1) {\
48 if (displaykills == 1) \
49 printf("\n%s", __x); \
50 else if (mflags != 169) /* MKILLA) */ \
51 printf("\n%s", __x); \
52 printf(CNORMAL); \
53 }
54 /*
55 * // Global Variables, bad, but this is an easier way to do options // which
56 * are only set once
57 */
58
59 int displaykills = 1;
60 int docolor = 0;
61 char *myname;
62
63 int
64 main(int argc, char **argv)
65 {
66 int i;
67 int oldmctl;
68
69 myname = *argv++;
70 argc--;
71
72 while (argc)
73 {
74 if (argv[0][0] == '-')
75 {
76 switch (argv[0][1])
77 {
78 case 'k':
79 displaykills = 0;
80 break;
81 case 'c':
82 docolor = 1;
83 break;
84 default:
85 usage(argv[0]);
86 break;
87 }
88 }
89 argv++;
90 argc--;
91 }
92
93 openmem(0);
94
95 oldmctl = mctl->mc_current;
96
97 for (i = 0; i <= oldmctl; i++)
98 {
99 printmes(messages[i].m_data,
100 messages[i].m_flags,
101 messages[oldmctl].m_recpt,
102 messages[oldmctl].m_from);
103 }
104
105 fflush(stdout);
106
107 for (;;)
108 {
109 sleep(1);
110 while (oldmctl != mctl->mc_current)
111 {
112 oldmctl++;
113 if (oldmctl == 50)
114 oldmctl = 0;
115 printmes(messages[oldmctl].m_data,
116 messages[oldmctl].m_flags,
117 messages[oldmctl].m_recpt,
118 messages[oldmctl].m_from);
119 fflush(stdout);
120 }
121 }
122 }
123
124 static int
125 contains(char *str1, char *str2)
126 {
127 char *s;
128 int length;
129
130 length = strlen(str2);
131 for (s = str1; *s != 0; s++)
132 {
133 if (*s == *str2 && strncmp(s, str2, length) == 0)
134 return (1);
135 }
136 return (0);
137 }
138
139 void
140 printmes(char mstr[80], int mflags, int mrecpt, int mfrom)
141 {
142 if (docolor)
143 {
144 switch (mflags)
145 {
146 case 17: /* MGOD: */
147 printf(CBOLD);
148 printf(CGREEN);
149 break;
150 case 329: /* MJOIN: */
151 case 297: /* MLEAVE: */
152 case 169: /* MKILLA: */
153 case 101: /* MTAKE: */
154 case 197: /* MBOMB: */
155 case 133: /* MDEST: */
156 case 69: /* M?: */
157 break;
158 default:
159 printf(CBOLD);
160 }
161 }
162 PRINT(mstr);
163 }
164
165 void
166 usage(char *me)
167 {
168 int x;
169 char message[][255] = {
170 "Netrek II message board watching tool.\n",
171 "\t'%s [options]'\n",
172 "\nOptions:\n",
173 "\t-k do not remove kills from listing\n",
174 "\t-c colorized text (need higher than a vt100 term)\n",
175 "\t-h this usage description\n",
176 "\nNo options will list every message, any other option will be interpreted as\n",
177 "a filter, which is a Terrance Chang mod, and I dont know|care what it is for.\n",
178 ""
179 };
180
181 fprintf(stderr, "-- NetrekII (Paradise), %s --\n", PARAVERS);
182 for (x = 0; *message[x] != '\0'; x++)
183 fprintf(stderr, message[x], me);
184
185 exit(1);
186 }