wmclockmon: replace deprecated `GTK_WIDGET_SET_FLAGS`
[dockapps.git] / wmifinfo / nwn.c
blob281b665c1a06953087108e7c8489a69f6c1a0fba
2 /*
3 * This code reads the /proc/driver/poldhu/eth# file for the No Wires Needed poldhu
4 * cards. Since there seems to be no official range for the 'Quality' value I assume
5 * it's between 0 and 15, and multiply by 4 to get the range 0-63...
7 * $Id: nwn.c,v 1.2 2002/09/15 14:31:41 ico Exp $
9 */
11 #ifdef ENABLE_NWN_SUPPORT
13 #include <stdio.h>
14 #include <string.h>
16 #define POLDHUPATH "/proc/driver/poldhu/%s"
17 #define SWALLOWPATH "/proc/driver/swallow/%s"
19 int nwn_get_link(char *ifname)
21 FILE *f;
22 char buf[256];
23 char *key, *val;
24 char *p;
25 char bssid[32] = "";
26 int inbssid = 0;
27 int link = 0;
29 sprintf(buf, POLDHUPATH, ifname);
30 f = fopen(buf, "r");
32 if(f == NULL) {
33 sprintf(buf, SWALLOWPATH, ifname);
34 f = fopen(buf, "r");
37 if(f == NULL) {
38 return(0);
41 while(fgets(buf, sizeof(buf), f)) {
42 p = strchr(buf, '\n');
43 if(p) *p=0;
45 p = strchr(buf, ':');
47 if(p) {
48 *p=0;
49 key = buf;
50 val = p+2;
51 p--;
52 while((*p == ' ') || (*p == '\t')) {
53 *p=0;
54 p--;
57 if(strcmp(key, "Current BSSID") == 0) {
58 strcpy(bssid, val);
61 if((strcmp(key, "BSSID") == 0) &&
62 (strcmp(val, bssid) == 0)) {
63 inbssid = 1;
66 if((inbssid == 1) &&
67 (strcmp(key, "Quality") == 0)) {
68 sscanf(val, "%X", (unsigned int *) &link);
69 link *= 4;
70 inbssid = 0;
75 fclose(f);
77 return(link);
80 #endif