View | Details | Raw Unified | Return to bug 121130
Collapse All | Expand All

(-)Makefile (-7 / +2 lines)
Lines 7-20 Link Here
7
7
8
PORTNAME=	wmwave
8
PORTNAME=	wmwave
9
PORTVERSION=	0.4
9
PORTVERSION=	0.4
10
PORTREVISION=	3
10
PORTREVISION=	4
11
CATEGORIES=	net
11
CATEGORIES=	net
12
MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
12
MASTER_SITES=	${MASTER_SITE_SOURCEFORGE}
13
MASTER_SITE_SUBDIR=	${PORTNAME}
13
MASTER_SITE_SUBDIR=	${PORTNAME}
14
DISTNAME=	${PORTNAME}-${PORTVERSION:S/./-/}
14
DISTNAME=	${PORTNAME}-${PORTVERSION:S/./-/}
15
EXTRACT_SUFX=	.tgz
15
EXTRACT_SUFX=	.tgz
16
16
17
MAINTAINER=	ports@FreeBSD.org
17
MAINTAINER=	benjsc@FreeBSD.org
18
COMMENT=	Display 802.11 status in the WindowMaker Dock
18
COMMENT=	Display 802.11 status in the WindowMaker Dock
19
19
20
MAKEFILE=	${FILESDIR}/Makefile
20
MAKEFILE=	${FILESDIR}/Makefile
Lines 30-38 Link Here
30
do-configure:
30
do-configure:
31
31
32
.include <bsd.port.pre.mk>
32
.include <bsd.port.pre.mk>
33
34
.if ${OSVERSION} >= 700042
35
BROKEN=		Does not compile with GCC 4.2
36
.endif
37
38
.include <bsd.port.post.mk>
33
.include <bsd.port.post.mk>
(-)files/patch-wmwave.c (-580 / +120 lines)
Lines 1-45 Link Here
1
--- wmwave.c.orig	Fri Aug 29 23:52:38 2003
1
--- wmwave.c.orig	2008-02-27 09:24:06.628732284 +1030
2
+++ wmwave.c	Fri Aug 29 23:52:43 2003
2
+++ wmwave.c	2008-02-27 09:32:07.088117765 +1030
3
@@ -1,38 +1,23 @@
3
@@ -29,6 +29,18 @@
4
 /*
4
  *
5
- * wmtop.c -- WindowMaker process view dock app
5
  * Revision 1.1  1999/08/15 15:39:18  carsten
6
- * Derived by Carsten Schuermann   carsten@schuermann.org
6
  * Added wmwave project to repository
7
- * http://www.schuermann.org/~carsten
8
- * from
9
- * Dan Piponi dan@tanelorn.demon.co.uk
10
- * http://www.tanelorn.demon.co.uk
11
- * who derived it 
12
- * from code originally contained in wmsysmon by Dave Clark (clarkd@skynet.ca)
13
+ * $Id$
14
+ * 
15
+ * wmwave.c -- WindowMaker IEEE802.11 status dock app
16
+ *             based on wmtop.c from Dan Piponi
17
+ * 
18
  * This software is licensed through the GNU General Public License.
19
- * $Log: wmwave.c,v $
20
- * Revision 1.7  1999/08/20 13:44:21  carsten
21
- * version 0.4 complete
22
- *
23
- * Revision 1.6  1999/08/19 17:58:52  carsten
24
- * Almost final version
25
- *
26
- * Revision 1.5  1999/08/19 13:54:30  carsten
27
- * done
28
- *
29
- * Revision 1.4  1999/08/19 11:14:50  carsten
30
- * hookup to /proc/net/wirless complete
31
- *
32
- * Revision 1.3  1999/08/19 02:39:07  carsten
33
- * improved design and hooked it up
34
- *
35
- * Revision 1.2  1999/08/16 03:45:34  carsten
36
- * Added dots
37
- *
38
- * Revision 1.1  1999/08/15 15:39:18  carsten
39
- * Added wmwave project to repository
40
- *
41
+ * 
7
+ * 
42
+ * Authors (in reverse chronological order):
8
+ * Authors (in reverse chronological order):
9
+ * Benjamin Close <benjsc@freebsd.org>
43
+ * Hendrik Scholz <hscholz@raisdorf.net>
10
+ * Hendrik Scholz <hscholz@raisdorf.net>
44
+ * Bruce M. Simpson <bms@spc.org>
11
+ * Bruce M. Simpson <bms@spc.org>
45
+ * Carsten Schuermann <carsten@schuermann.org>
12
+ * Carsten Schuermann <carsten@schuermann.org>
Lines 49-236 Link Here
49
+ * The FreeBSD version of this software is released under the GNU GPL, and
16
+ * The FreeBSD version of this software is released under the GNU GPL, and
50
+ * forms part of the Consume Project <URL: http://www.consume.net/>.
17
+ * forms part of the Consume Project <URL: http://www.consume.net/>.
51
+ * 
18
+ * 
19
  *
52
  */
20
  */
53
 
21
 
54
-
22
@@ -57,6 +69,22 @@
55
 #include <stdlib.h>
23
 #include <X11/xpm.h>
56
 #include <stdio.h>
24
 #include <X11/extensions/shape.h>
57
 #include <time.h>
58
@@ -45,313 +30,384 @@
59
 #include <limits.h>
60
 #include <errno.h>
61
 #include <signal.h>
62
+#include <sysexits.h>
63
 
25
 
64
+#include <sys/types.h>
65
 #include <sys/wait.h>
66
 #include <sys/stat.h>
67
 #include <sys/param.h>
68
-#include <sys/types.h>
69
 #include <sys/ioctl.h>
70
 #include <sys/time.h>
71
+#include <sys/socket.h>
26
+#include <sys/socket.h>
72
+#include <sys/sockio.h>
27
+#include <sys/sockio.h>
73
+
74
+#include <netdb.h>
28
+#include <netdb.h>
75
+#include <net/if.h>
29
+#include <net/if.h>
76
+#include <net/if_var.h>
30
+#include <net/if_var.h>
77
+#include <net/route.h>
31
+#include <net/route.h>
78
+#include <net/ethernet.h>
32
+#include <net/ethernet.h>
79
+
80
+#include <netinet/in.h>
33
+#include <netinet/in.h>
81
+#include <netinet/in_systm.h>
34
+#include <netinet/in_systm.h>
82
+#include <netinet/in_var.h>
35
+#include <netinet/in_var.h>
83
+#include <netinet/ip.h>
36
+#include <netinet/ip.h>
84
+#include <netinet/ip_var.h>
37
+#include <netinet/ip_var.h>
85
+#include <arpa/inet.h>
38
+#include <arpa/inet.h>
86
+
39
+#include <net80211/ieee80211.h>
87
+#include <dev/wi/if_wavelan_ieee.h>
40
+#include <net80211/ieee80211_crypto.h>
41
+#include <net80211/ieee80211_ioctl.h>
88
 
42
 
89
 #include <X11/Xlib.h>
90
 #include <X11/xpm.h>
91
 #include <X11/extensions/shape.h>
92
 
93
-
94
 #include "wmgeneral.h"
43
 #include "wmgeneral.h"
95
-
96
 #include "wmwave-master.xpm"
97
 
44
 
98
-char wmwave_mask_bits[64*64];
45
@@ -66,7 +94,9 @@
99
-int wmwave_mask_width = 64;
46
 int wmwave_mask_width = 64;
100
-int wmwave_mask_height = 64;
47
 int wmwave_mask_height = 64;
101
-
48
 
102
-#define WMWAVE_VERSION "0.4"
49
-#define WMWAVE_VERSION "0.4"
103
+char            wmwave_mask_bits[64 * 64];
104
+int             wmwave_mask_width = 64;
105
+int             wmwave_mask_height = 64;
106
+
107
+#define WMWAVE_DEFAULT_INTERFACE	"wi0"
108
+#define WMWAVE_VERSION			"0.4_FreeBSD-2"
50
+#define WMWAVE_VERSION			"0.4_FreeBSD-2"
109
+
51
+#define WMWAVE_DEFAULT_INTERFACE	"wi0"
110
+int             update_rate = 100000;
111
+char            *ProgName;
112
+char			*iface = WMWAVE_DEFAULT_INTERFACE;
52
+char			*iface = WMWAVE_DEFAULT_INTERFACE;
113
+time_t          curtime;
114
+time_t          prevtime;
115
+int             mode = 0;	/* default: no card detected */
116
+int             screen = 0;	/* default: Quality screen is displayed */
117
+
118
+void            usage(void);
119
+void            printversion(void);
120
+void            BlitString(char *name, int x, int y);
121
+void            BlitNum(int num, int x, int y);
122
+void            wmwave_routine(int, char **);
123
+void            DrawBar(float percent, int dx, int dy);
124
+void            DrawGreenBar(float percent, int dx, int dy);
125
 
126
-int update_rate=100000;
127
-
128
-char *ProgName;
129
-
130
-time_t curtime;
131
-time_t prevtime;
132
-
133
-int mode = 0;    // default: no card detected
134
-int screen = 0;  // default: Quality screen is displayed
135
-
136
-void usage(void);
137
-void printversion(void);
138
-void BlitString(char *name, int x, int y);
139
-void BlitNum(int num, int x, int y);
140
-void wmwave_routine(int, char **);
141
-void DrawBar(float percent, int dx, int dy);
142
-void DrawGreenBar(float percent, int dx, int dy);
143
+inline void
144
+DrawBar(float percent, int dx, int dy)
145
+{
146
+	int             tx;
147
 
148
-inline void DrawBar(float percent, int dx, int dy) {
149
-  int tx;
150
-  
151
-  tx = (float)((float)54 * ((float)percent / (float)100.0));
152
-  copyXPMArea(67, 36, tx, 4, dx, dy);
153
-  copyXPMArea(67, 43, 54-tx, 4, dx+tx, dy); 
154
+	tx = (float)((float)54 * ((float)percent / (float)100.0));
155
+	copyXPMArea(67, 36, tx, 4, dx, dy);
156
+	copyXPMArea(67, 43, 54 - tx, 4, dx + tx, dy);
157
 }
158
 
159
 
160
-inline void DrawGreenBar(float percent, int dx, int dy) {
161
-  int tx;
162
-  
163
-  tx = (float)((float)54 * ((float)percent / (float)100.0));
164
-  copyXPMArea(67, 58, tx, 4, dx, dy);
165
-  copyXPMArea(67, 43, 54-tx, 4, dx+tx, dy); 
166
+inline void
167
+DrawGreenBar(float percent, int dx, int dy)
168
+{
169
+	int             tx;
170
+
171
+	tx = (float)((float)54 * ((float)percent / (float)100.0));
172
+	copyXPMArea(67, 58, tx, 4, dx, dy);
173
+	copyXPMArea(67, 43, 54 - tx, 4, dx + tx, dy);
174
 }
175
 
176
-inline void DrawRedDot() {
177
-  copyXPMArea(80, 65, 6, 6, 52, 5);
178
+inline void
179
+DrawRedDot()
180
+{
181
+	copyXPMArea(80, 65, 6, 6, 52, 5);
182
 }
183
 
184
-inline void DrawYellowDot() {
185
-  copyXPMArea(86, 65, 6, 6, 52, 5);
186
+inline void
187
+DrawYellowDot()
188
+{
189
+	copyXPMArea(86, 65, 6, 6, 52, 5);
190
 }
191
 
53
 
192
-inline void DrawGreenDot() {
54
 int update_rate=100000;
193
-  copyXPMArea(92, 65, 6, 6, 52, 5);
194
+inline void
195
+DrawGreenDot()
196
+{
197
+	copyXPMArea(92, 65, 6, 6, 52, 5);
198
 }
199
 
55
 
200
-inline void DrawEmptyDot() {
56
@@ -125,65 +155,100 @@
201
-  copyXPMArea(98, 65, 6, 6, 52, 5);
202
+inline void
203
+DrawEmptyDot()
204
+{
205
+	copyXPMArea(98, 65, 6, 6, 52, 5);
206
 }
207
 
208
-float min (float x, float y) {
209
-  if (x < y) {return x;}
210
-  else {return y;}
211
+/*
212
+ * XXX: redefining min() to operate on floats is a bad idea;
213
+ * changed to _fmin().
214
+ */
215
+float
216
+_fmin(float x, float y)
217
+{
218
+	if (x < y) {
219
+		return x;
220
+	} else {
221
+		return y;
222
+	}
223
 }
57
 }
224
 
58
 
225
 /*
59
 /*
226
- * Find CPU times for all processes
60
- * Find CPU times for all processes
227
+ * XXX: Fetch OS-specific wireless statistics.
61
+ * XXX: Fetch OS-specific wireless statistics.
228
+ * 
62
+ * 
229
+ * These are: quality, signal, noise. On NetBSD, the 
63
+ * These are: quality, signal, noise. On NetBSD, the
230
+ * statistics kept on an AP-basis for the driver are valid.
64
+ * statistics kept on an AP-basis for the driver are valid.
231
+ * On FreeBSD, it is necessary to interrogate the WICACHE.
65
+ * On FreeBSD, we make use of the net80211 layer to display the
232
+ * For the purposes of keeping things simple, this code will only
66
+ * required stats.
233
+ * look at the first slot in the WICACHE table.
234
  */
67
  */
235
-void DisplayWireless(void) {
68
-void DisplayWireless(void) {
236
-  FILE *wireless;   // File handle for /proc/net/wireless
69
-  FILE *wireless;   // File handle for /proc/net/wireless
Lines 284-693 Link Here
284
-	DrawGreenBar(0.0, 4, 55);
117
-	DrawGreenBar(0.0, 4, 55);
285
-	break;
118
-	break;
286
-      };
119
-      };
287
+void
120
+void DisplayWireless(void)
288
+DisplayWireless(void)
289
+{
121
+{
290
+        struct ifreq             ifr;
122
+    struct ifreq             ifr;
291
+        struct wi_req            wireq;
123
+    struct ieee80211req      ireq;
292
+        struct wi_sigcache      *wisigsp;
124
+    union {
293
+        int                     *wisigsnp, s, mode, err;
125
+	struct ieee80211req_sta_req stareq;
294
+	float  	                 link, level, noise;
126
+	uint8_t buf[24*1024];
295
+	enum {
127
+    } u;
296
+		MODE_NO_CARD = 0,
128
+    int                      s, mode, err;
297
+		MODE_HAVE_CARD = 1
129
+    float	                 link, level, noise;
298
+	};
130
+    enum {
131
+	MODE_NO_CARD = 0,
132
+	MODE_HAVE_CARD = 1
133
+    };
299
+
134
+
300
+    s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
135
+    s = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP);
301
+    if (s == -1) 
136
+    if (s == -1)
302
+    	errx(errno, "socket");
137
+	errx(errno, "socket");
303
+    bzero(&ifr, sizeof(ifr));
138
+    bzero(&ifr, sizeof(ifr));
304
+    strncpy(ifr.ifr_name, iface, strlen(iface));
139
+    strncpy(ifr.ifr_name, iface, strlen(iface));
305
+    bzero(&wireq, sizeof(wireq));
306
+    wireq.wi_type = WI_RID_COMMS_QUALITY;
307
+    wireq.wi_len = WI_MAX_DATALEN;
308
+    ifr.ifr_data = (void *) &wireq;
309
+
140
+
310
+    err = ioctl(s, SIOCGWAVELAN, (caddr_t)&ifr);
141
+    memset(&ireq, 0, sizeof(ireq));
311
+    if (err < 0) {
142
+    strncpy(ireq.i_name, iface, sizeof(ireq.i_name));
312
+		mode = MODE_NO_CARD;
143
+
313
+		goto draw;
144
+    // Get the currently associated ap
145
+    ireq.i_type = IEEE80211_IOC_BSSID;
146
+    ireq.i_data = u.stareq.is_u.macaddr;
147
+    ireq.i_len = IEEE80211_ADDR_LEN;
148
+    err = ioctl(s, SIOCG80211, &ireq);
149
+    if ( err >= 0 ){
150
+
151
+	// Get the station info for the ap
152
+	memset(&ireq, 0, sizeof(ireq));
153
+	strncpy(ireq.i_name, iface, sizeof(ireq.i_name));
154
+	ireq.i_type = IEEE80211_IOC_STA_INFO;
155
+	ireq.i_data = &u;
156
+	ireq.i_len  = sizeof(u);
157
+	err = ioctl(s, SIOCG80211, &ireq);
158
+	if ( err >= 0 ){
159
+	    const struct ieee80211req_sta_info *si = u.stareq.info;
160
+	    mode = MODE_HAVE_CARD;
161
+	    // net80211 doesn't have a link quality field so we base it on the
162
+	    // noise/signal level
163
+	    link = (si->isi_rssi-si->isi_noise)/2;
164
+	    level = si->isi_rssi/2;
165
+	    noise = abs(si->isi_noise);
166
+	}
314
     }
167
     }
315
-  else {
168
-  else {
316
-    printf ("Wirless device /proc/net/wireless not found\nEnable radio networking and recompile your kernel\n");
169
-    printf ("Wirless device /proc/net/wireless not found\nEnable radio networking and recompile your kernel\n");
317
-    exit (0);
170
-    exit (0);
318
-  }
171
-  }
319
-}
320
-
321
-/* SIGCHLD handler */
322
-void sig_chld(int signo)
323
-{
324
-  waitpid((pid_t) -1, NULL, WNOHANG);
325
-  signal(SIGCHLD, sig_chld);
326
-}
327
-
328
-int main(int argc, char *argv[]) {
329
-  int i;
330
-  
331
-  /* Parse Command Line */
332
-  
333
-  signal(SIGCHLD, sig_chld);
334
-  ProgName = argv[0];
335
-  if (strlen(ProgName) >= 5)
336
-    ProgName += (strlen(ProgName) - 5);
337
-  
338
-  for (i=1; i<argc; i++) {
339
-    char *arg = argv[i];
340
-    
341
-    if (*arg=='-') {
342
-      switch (arg[1]) {
343
-      case 'd' :
344
-	if (strcmp(arg+1, "display")) {
345
-	  usage();
346
-	  exit(1);
347
-	}
348
-	break;
349
-      case 'g' :
350
-	if (strcmp(arg+1, "geometry")) {
351
-	  usage();
352
-	  exit(1);
353
-	}
354
-	break;
355
-      case 'v' :
356
-	printversion();
357
-	exit(0);
358
-	break;
359
-      case 'r':
360
-	if (argc > (i+1)) {
361
-	  update_rate = (atoi(argv[i+1]) * 1000);
362
-	  i++;
363
+
172
+
364
+	mode = MODE_HAVE_CARD;
173
+    if (err < 0) {
365
+	link = wireq.wi_val[0];
174
+	mode = MODE_NO_CARD;
366
+	level = wireq.wi_val[1];
175
+    }
367
+	noise = wireq.wi_val[2];
368
+
176
+
369
+draw:
177
+draw:
370
+	/*
178
+    /*
371
+	 * Print channel information, and signal ratio
179
+     * Print channel information, and signal ratio
372
+	 */
180
+     */
373
+	switch (mode) {
181
+    switch (mode) {
374
+	case MODE_HAVE_CARD:
182
+	case MODE_HAVE_CARD:
375
+		BlitString("Quality", 4, 4);
183
+	    BlitString("Quality", 4, 4);
376
+		if (link <= 10) {
184
+	    if (link <= 10) {
377
+			DrawRedDot();
185
+		DrawRedDot();
378
+		} else if (link <= 20) {
186
+	    } else if (link <= 20) {
379
+			DrawYellowDot();
187
+		DrawYellowDot();
380
+		} else {
188
+	    } else {
381
+			DrawGreenDot();
189
+		DrawGreenDot();
382
+		};
190
+	    };
383
+		BlitString("Quality  ", 4, 18);
191
+	    BlitString("Quality  ", 4, 18);
384
+		DrawBar(_fmin((int)(link * 1.8), 100.0), 4, 27);
192
+	    DrawBar(min((int)(link * 1.8), 100.0), 4, 27);
385
+		BlitString("Signal   ", 4, 32);
193
+	    BlitString("Signal   ", 4, 32);
386
+		DrawGreenBar(_fmin((int)(level * 0.3), 100.0), 4, 41);
194
+	    DrawGreenBar(min((int)(level * 0.3), 100.0), 4, 41);
387
+		BlitString("Noise    ", 4, 46);
195
+	    BlitString("Noise    ", 4, 46);
388
+		DrawGreenBar(_fmin((int)(noise * 0.3), 100.0), 4, 55);
196
+	    DrawGreenBar(min((int)(noise * 0.3), 100.0), 4, 55);
389
+		break;
197
+	    break;
390
+	case MODE_NO_CARD:
198
+	case MODE_NO_CARD:
391
+	default:
199
+	default:
392
+		BlitString("NO CARD", 4, 4);
200
+	    BlitString("NO CARD", 4, 4);
393
+		DrawEmptyDot();
201
+	    DrawEmptyDot();
394
+		BlitString("         ", 4, 18);
202
+	    BlitString("         ", 4, 18);
395
+		DrawBar(0.0, 4, 27);
203
+	    DrawBar(0.0, 4, 27);
396
+		BlitString("         ", 4, 32);
204
+	    BlitString("         ", 4, 32);
397
+		DrawGreenBar(0.0, 4, 41);
205
+	    DrawGreenBar(0.0, 4, 41);
398
+		BlitString("         ", 4, 46);
206
+	    BlitString("         ", 4, 46);
399
+		DrawGreenBar(0.0, 4, 55);
207
+	    DrawGreenBar(0.0, 4, 55);
400
+		break;
208
+	    break;
401
+	};
209
+    };
402
+	close(s);
210
+    close(s);
403
+}
211
 }
404
+
212
 
405
+void
213
 /* SIGCHLD handler */
406
+sig_chld(int signo)
214
@@ -208,6 +273,11 @@
407
+{
215
     
408
+	waitpid((pid_t) - 1, NULL, WNOHANG);
216
     if (*arg=='-') {
409
+	signal(SIGCHLD, sig_chld);
217
       switch (arg[1]) {
410
+}
218
+      case 'i':
411
+
219
+	  if (argc > (i + 1)) {
412
+int
220
+	      iface = argv[i+1];
413
+main(int argc, char *argv[])
221
+	  }
414
+{
222
+	  break;
415
+	int             i;
223
       case 'd' :
416
+
224
 	if (strcmp(arg+1, "display")) {
417
+
225
 	  usage();
418
+	signal(SIGCHLD, sig_chld);
226
@@ -345,6 +415,7 @@
419
+
227
   fprintf(stderr, "\nWmwave - Carsten Schuermann <carsten@schuermann.org>  http://www.schuermann.org/~dockapps\n\n");
420
+	ProgName = argv[0];
228
   fprintf(stderr, "usage:\n");
421
+	if (strlen(ProgName) >= 5)
229
   fprintf(stderr, "    -display <display name>\n");
422
+		ProgName += (strlen(ProgName) - 5);
230
+  fprintf(stderr, "    -i        		 interface to use (default to wi0)\n");
423
+
231
   fprintf(stderr, "    -r                        update rate in milliseconds (default:100)\n");
424
+	for (i = 1; i < argc; i++) {
232
   fprintf(stderr, "\n");
425
+		char           *arg = argv[i];
426
+
427
+		if (*arg == '-') {
428
+			switch (arg[1]) {
429
+			case 'i':
430
+				if (argc > (i + 1)) {
431
+					iface = argv[i+1];
432
+					if (strncmp("wi", iface, 2) != 0) {
433
+						fprintf(stderr, "error: you "
434
+					"must specify a wiX interface.\n");
435
+						usage();
436
+						exit(EX_USAGE);
437
+					}
438
+				}
439
+				break;
440
+			case 'd':
441
+				if (strcmp(arg + 1, "display")) {
442
+					usage();
443
+					exit(EX_USAGE);
444
+				}
445
+				break;
446
+			case 'g':
447
+				if (strcmp(arg + 1, "geometry")) {
448
+					usage();
449
+					exit(EX_USAGE);
450
+				}
451
+				break;
452
+			case 'v':
453
+				printversion();
454
+				exit(EX_OK);
455
+				break;
456
+			case 'r':
457
+				if (argc > (i + 1)) {
458
+					update_rate = (atoi(argv[i+1]) * 1000);
459
+					i++;
460
+				}
461
+				break;
462
+			default:
463
+				usage();
464
+				exit(EX_USAGE);
465
+				break;
466
+			}
467
+		}
468
 	}
469
-	break;
470
-      default:
471
-	usage();
472
-	exit(0);
473
-	break;
474
-      }
475
-    }
476
-  }
477
-  
478
-  wmwave_routine(argc, argv);
479
-  
480
-  return 0;
481
+
482
+	wmwave_routine(argc, argv);
483
+
484
+	exit(EX_OK);
485
 }
486
 
487
 /*
488
  * Main loop
489
  */
490
-void wmwave_routine(int argc, char **argv) {
491
-  XEvent Event;
492
-  struct timeval tv={0,0};
493
-  struct timeval last={0,0};
494
-  
495
-  createXBMfromXPM(wmwave_mask_bits, wmwave_master_xpm, wmwave_mask_width, wmwave_mask_height);
496
-  
497
-  openXwindow(argc, argv, wmwave_master_xpm, wmwave_mask_bits, wmwave_mask_width, wmwave_mask_height);
498
-  
499
-  RedrawWindow();
500
-  
501
-  
502
-  while (1) {
503
-    
504
-    curtime = time(0);
505
-    
506
-    if (1) {
507
-      memcpy(&last, &tv, sizeof(tv));
508
-      
509
-      /*
510
-       * Update display
511
-       */
512
-      DisplayWireless();
513
-      
514
-      RedrawWindow();
515
-    }
516
-    
517
-    /*
518
-     * X Events
519
-     */
520
-    while (XPending(display)) {
521
-      XNextEvent(display, &Event);
522
-      switch (Event.type) {
523
-      case Expose:
524
+void
525
+wmwave_routine(int argc, char **argv)
526
+{
527
+	XEvent          Event;
528
+	struct timeval  tv = {0, 0};
529
+	struct timeval  last = {0, 0};
530
+
531
+	createXBMfromXPM(wmwave_mask_bits, wmwave_master_xpm, wmwave_mask_width, wmwave_mask_height);
532
+
533
+	openXwindow(argc, argv, wmwave_master_xpm, wmwave_mask_bits, wmwave_mask_width, wmwave_mask_height);
534
+
535
 	RedrawWindow();
536
-	break;
537
-      case DestroyNotify:
538
-	XCloseDisplay(display);
539
-	exit(0);
540
-      case ButtonPress:
541
-	switch (screen) {
542
-	case 0: screen=1; break;
543
-	case 1: screen=0; break;
544
-	};
545
-	break;
546
-      }
547
-    }
548
-    
549
-    usleep(update_rate);
550
-  }
551
+
552
+	for (;;) {
553
+		curtime = time(0);
554
+		memcpy(&last, &tv, sizeof(tv));
555
+
556
+		/*
557
+		 * Update display
558
+		 */
559
+		DisplayWireless();
560
+		RedrawWindow();
561
+
562
+		/*
563
+		 * X Events
564
+		 */
565
+		while (XPending(display)) {
566
+			XNextEvent(display, &Event);
567
+			switch (Event.type) {
568
+			case Expose:
569
+				RedrawWindow();
570
+				break;
571
+			case DestroyNotify:
572
+				XCloseDisplay(display);
573
+				exit(EX_OK);
574
+			case ButtonPress:
575
+				switch (screen) {
576
+				case 0:
577
+					screen = 1;
578
+					break;
579
+				case 1:
580
+					screen = 0;
581
+					break;
582
+				};
583
+				break;
584
+			}
585
+		}
586
+		usleep(update_rate);
587
+	}
588
 }
589
 
590
 /*
591
  * Blits a string at given co-ordinates
592
  */
593
-void BlitString(char *name, int x, int y) {
594
-  int	i;
595
-  int	c;
596
-  int	k;
597
-  
598
-  k = x;
599
-  for (i=0; name[i]; i++)
600
-    {
601
-      
602
-      c = toupper(name[i]); 
603
-      if (c >= 'A' && c <= 'Z')
604
-        {   // its a letter
605
-		 c -= 'A';
606
-	copyXPMArea(c * 6, 74, 6, 8, k, y);
607
-	k += 6;
608
-	} else
609
-	  if (c>='0' && c<='9') {   // its a number or symbol
610
-					 c -= '0';
611
-	  copyXPMArea(c * 6, 64, 6, 8, k, y);
612
-	  k += 6;
613
-	  } else {
614
-	    copyXPMArea(5, 84, 6, 8, k, y);
615
-	    k += 6;
616
-	    
617
-	  }
618
-    }
619
+void
620
+BlitString(char *name, int x, int y)
621
+{
622
+	int             i;
623
+	int             c;
624
+	int             k;
625
+
626
+	k = x;
627
+	for (i = 0; name[i]; i++) {
628
+
629
+		c = toupper(name[i]);
630
+		if (c >= 'A' && c <= 'Z') {	/* its a letter */
631
+			c -= 'A';
632
+			copyXPMArea(c * 6, 74, 6, 8, k, y);
633
+			k += 6;
634
+		} else if (c >= '0' && c <= '9') {
635
+			/* its a number or symbol */
636
+			c -= '0';
637
+			copyXPMArea(c * 6, 64, 6, 8, k, y);
638
+			k += 6;
639
+		} else {
640
+			copyXPMArea(5, 84, 6, 8, k, y);
641
+			k += 6;
642
+
643
+		}
644
+	}
645
 }
646
 
647
-void BlitNum(int num, int x, int y) {
648
-  char buf[1024];
649
-  int newx=x;
650
-  
651
-  sprintf(buf, "%03i", num);
652
-  
653
-  BlitString(buf, newx, y);
654
+void
655
+BlitNum(int num, int x, int y)
656
+{
657
+	char            buf[1024];
658
+	int             newx = x;
659
+
660
+	sprintf(buf, "%03i", num);
661
+	BlitString(buf, newx, y);
662
 }
663
 
664
 /*
665
  * Usage
666
  */
667
-void usage(void) {
668
-  fprintf(stderr, "\nWmwave - Carsten Schuermann <carsten@schuermann.org>  http://www.schuermann.org/~dockapps\n\n");
669
-  fprintf(stderr, "usage:\n");
670
-  fprintf(stderr, "    -display <display name>\n");
671
-  fprintf(stderr, "    -r                        update rate in milliseconds (default:100)\n");
672
-  fprintf(stderr, "\n");
673
+void
674
+usage(void)
675
+{
676
+	fprintf(stderr, "\rwmwave 0.4 - by Bruce M Simpson <bms@spc.org> et al. \n");
677
+	fprintf(stderr, "usage:\n");
678
+	fprintf(stderr, "    -display  <display name>\n");
679
+	fprintf(stderr, "    -i        interface to use (default to wi0)\n");
680
+	fprintf(stderr, "    -r        update rate in milliseconds (default:100)\n");
681
+	fprintf(stderr, "\n");
682
 }
683
 
684
 /*
685
  * printversion
686
  */
687
-void printversion(void) {
688
-  fprintf(stderr, "wmwave v%s\n", WMWAVE_VERSION);
689
+void
690
+printversion(void)
691
+{
692
+	fprintf(stderr, "wmwave v%s\n", WMWAVE_VERSION);
693
 }
233
 }

Return to bug 121130