annotate spopt.c @ 3:5a977ccbc7a9 default tip

Empty changelog
author darius
date Sat, 06 Dec 1997 05:41:29 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
3
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
1 /* $Id: spopt.c,v 1.1.1.1 1997/12/06 05:41:31 darius Exp $ */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
2
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
3 #ifdef SHORT_PACKETS
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
4 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
5 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
6 #include "copyright.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
7
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
8 #include <stdio.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
9 #include <ctype.h>
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
10 #include "Wlib.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
11 #include "defs.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
12 #include "struct.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
13 #include "data.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
14 #include "packets.h"
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
15
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
16 /*
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
17 * Refresh item i
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
18 */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
19
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
20 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
21 sprefresh(i)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
22 int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
23 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
24 char buf[BUFSIZ];
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
25
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
26 switch (i) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
27
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
28 case SPK_VFIELD:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
29 sprintf(buf, "%seceive variable and short packets",
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
30 recv_short ? "R" : "Don't r");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
31 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
32 case SPK_MFIELD:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
33 sprintf(buf, "%seceive messages", recv_mesg ? "R" : "Don't r");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
34 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
35 case SPK_KFIELD:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
36 sprintf(buf, "%seceive kill messages", recv_kmesg ? "R" : "Don't r");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
37 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
38 case SPK_WFIELD:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
39 sprintf(buf, "%seceive warning messages", recv_warn ? "R" : "Don't r");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
40 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
41 case SPK_TFIELD:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
42 sprintf(buf, "Receive threshold: %s_", recv_threshold_s);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
43 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
44 case SPK_WHYFIELD:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
45 sprintf(buf, "%sdd why dead messages", why_dead ? "A" : "Don't a");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
46 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
47 case SPK_DONE:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
48 sprintf(buf, "Done");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
49 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
50 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
51
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
52 W_WriteText(spWin, 0, i, textColor, buf, strlen(buf), 0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
53 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
54
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
55 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
56 spwindow()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
57 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
58 register int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
59
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
60 for (i = 0; i < SPK_NUMFIELDS; i++)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
61 sprefresh(i);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
62
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
63 /* Map window */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
64 W_MapWindow(spWin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
65 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
66
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
67 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
68 spdone()
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
69 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
70 /* Unmap window */
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
71 W_UnmapWindow(spWin);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
72 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
73
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
74 void
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
75 spaction(data)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
76 W_Event *data;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
77 {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
78 int v;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
79 register int i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
80 register char *cp;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
81
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
82 switch (data->y) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
83
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
84 case SPK_VFIELD:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
85 if (data->type == W_EV_BUTTON) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
86 if (recv_short)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
87 sendShortReq(SPK_VOFF);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
88 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
89 sendShortReq(SPK_VON);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
90 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
91 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
92
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
93 case SPK_MFIELD:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
94 if (data->type == W_EV_BUTTON) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
95 if (recv_mesg)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
96 sendShortReq(SPK_MOFF);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
97 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
98 sendShortReq(SPK_MON);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
99 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
100 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
101
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
102 case SPK_KFIELD:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
103 if (data->type == W_EV_BUTTON) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
104 if (recv_kmesg)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
105 sendShortReq(SPK_M_NOKILLS);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
106 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
107 sendShortReq(SPK_M_KILLS);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
108 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
109 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
110
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
111 case SPK_WFIELD:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
112 if (data->type == W_EV_BUTTON) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
113 if (recv_warn)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
114 sendShortReq(SPK_M_NOWARN);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
115 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
116 sendShortReq(SPK_M_WARN);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
117 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
118 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
119
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
120 case SPK_TFIELD:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
121 if (data->type == W_EV_KEY) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
122 switch (data->key) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
123 case '\b':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
124 case '\177':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
125 cp = recv_threshold_s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
126 i = strlen(cp);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
127 if (i > 0) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
128 cp += i - 1;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
129 *cp = '\0';
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
130 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
131 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
132 case '\025':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
133 case '\030':
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
134 recv_threshold_s[0] = '\0';
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
135 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
136
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
137 default:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
138 if (data->key >= '0' && data->key <= '9') {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
139 cp = recv_threshold_s;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
140 i = strlen(cp);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
141 if (i < 4) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
142 cp += i;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
143 cp[1] = '\0';
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
144 cp[0] = data->key;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
145 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
146 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
147 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
148 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
149 sprefresh(SPK_TFIELD);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
150 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
151 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
152
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
153 case SPK_WHYFIELD:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
154 if (F_feature_packets && data->type == W_EV_BUTTON) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
155 if (why_dead)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
156 sendFeature("WHY_DEAD", 'S', 0, 0, 0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
157 else
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
158 sendFeature("WHY_DEAD", 'S', 1, 0, 0);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
159 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
160 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
161 case SPK_DONE:
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
162
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
163 if (data->type == W_EV_BUTTON) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
164 if (sscanf(recv_threshold_s, "%d", &v) != 1)
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
165 strcpy(recv_threshold_s, "0");
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
166 else if (recv_threshold != v) {
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
167 recv_threshold = v;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
168 sendThreshold(recv_threshold);
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
169 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
170 spdone();
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
171 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
172 break;
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
173
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
174 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
175 }
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
176
5a977ccbc7a9 Empty changelog
darius
parents:
diff changeset
177 #endif