wmpager: allow WMPAGER_DEFAULT_INSTALL_DIR to be defined in $FLAGS
[dockapps.git] / wmifinfo / nwn.c
blob427812708d494d679bd9fc729af5f05156e02954
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 */
9 #ifdef ENABLE_NWN_SUPPORT
11 #include <stdio.h>
12 #include <string.h>
14 #define POLDHUPATH "/proc/driver/poldhu/%s"
15 #define SWALLOWPATH "/proc/driver/swallow/%s"
17 int nwn_get_link(char *ifname)
19 FILE *f;
20 char buf[256];
21 char *key, *val;
22 char *p;
23 char bssid[32] = "";
24 int inbssid = 0;
25 int link = 0;
27 sprintf(buf, POLDHUPATH, ifname);
28 f = fopen(buf, "r");
30 if(f == NULL) {
31 sprintf(buf, SWALLOWPATH, ifname);
32 f = fopen(buf, "r");
35 if(f == NULL) {
36 return(0);
39 while(fgets(buf, sizeof(buf), f)) {
40 p = strchr(buf, '\n');
41 if(p) *p=0;
43 p = strchr(buf, ':');
45 if(p) {
46 *p=0;
47 key = buf;
48 val = p+2;
49 p--;
50 while((*p == ' ') || (*p == '\t')) {
51 *p=0;
52 p--;
55 if(strcmp(key, "Current BSSID") == 0) {
56 strcpy(bssid, val);
59 if((strcmp(key, "BSSID") == 0) &&
60 (strcmp(val, bssid) == 0)) {
61 inbssid = 1;
64 if((inbssid == 1) &&
65 (strcmp(key, "Quality") == 0)) {
66 sscanf(val, "%X", &link);
67 link *= 4;
68 inbssid = 0;
73 fclose(f);
75 return(link);
78 #endif