Author: remi
Date: 2009-09-04 13:14:05 +0200 (Fri, 04 Sep 2009)
New Revision: 5329

Modified:
   software_suite_v2/software/tux_wifi_channel/trunk/Makefile.unix
   software_suite_v2/software/tux_wifi_channel/trunk/Makefile.win32
   software_suite_v2/software/tux_wifi_channel/trunk/VERSION
   software_suite_v2/software/tux_wifi_channel/trunk/wifi_channel_unix.c
   software_suite_v2/software/tux_wifi_channel/trunk/wifi_channel_win32.c
Log:
* Updated version to 0.0.2
* Compile to library and binary
* Export get_wifi_channel method
* Updated makefiles

Modified: software_suite_v2/software/tux_wifi_channel/trunk/Makefile.unix
===================================================================
--- software_suite_v2/software/tux_wifi_channel/trunk/Makefile.unix     
2009-09-03 15:21:09 UTC (rev 5328)
+++ software_suite_v2/software/tux_wifi_channel/trunk/Makefile.unix     
2009-09-04 11:14:05 UTC (rev 5329)
@@ -1,16 +1,17 @@
 CC = gcc
 OBJ_DIR = ./
 C_INCLUDE_DIRS =
-CFLAGS = -pipe -Wall -g2 -O0
+CFLAGS = -pipe -Wall -g2 -O0 -fPIC
 LIB_DIRS = -L./
 LIBS = 
-LDFLAGS = -pipe
+LDFLAGS = -pipe -shared
 
 .PHONY: make clean
 
 make:
        $(CC) -c $(CFLAGS) wifi_channel_unix.c $(C_INCLUDE_DIRS) -o 
$(OBJ_DIR)/main.o
-       $(CC) -o "tux_wifi_channel" $(OBJ_DIR)/main.o $(LIB_DIRS) $(LIBS) 
$(LDFLAGS)
+       $(CC) -o "tux_wifi_channel" $(OBJ_DIR)/main.o $(LIB_DIRS) $(LIBS) -pipe
+       $(CC) -o "libtuxwifichannel.so" $(OBJ_DIR)/main.o $(LIB_DIRS) $(LIBS) 
$(LDFLAGS)
        -...@rm -fR $(OBJ_DIR)/*.o
 
 clean:

Modified: software_suite_v2/software/tux_wifi_channel/trunk/Makefile.win32
===================================================================
--- software_suite_v2/software/tux_wifi_channel/trunk/Makefile.win32    
2009-09-03 15:21:09 UTC (rev 5328)
+++ software_suite_v2/software/tux_wifi_channel/trunk/Makefile.win32    
2009-09-04 11:14:05 UTC (rev 5329)
@@ -1,16 +1,18 @@
 CC = gcc
 OBJ_DIR = ./
+OUTPUT_DIR = ./
 C_INCLUDE_DIRS = -I"C:\MinGWStudio\MinGW\include\ddk"
 CFLAGS = -pipe -Wall -g2 -O0
 LIB_DIRS = -L./
-LIBS = 
-LDFLAGS = -pipe
+LIBS =
+LDFLAGS = -pipe -shared 
-Wl,--output-def,"$(OUTPUT_DIR)\libtuxwifichannel.def",--out-implib,"$(OUTPUT_DIR)\libtuxwifichannel.a"
 -s
 
 .PHONY: make clean
 
 make:
        $(CC) -c $(CFLAGS) wifi_channel_win32.c $(C_INCLUDE_DIRS) -o 
$(OBJ_DIR)/main.o
-       $(CC) -o "tux_wifi_channel.exe" $(OBJ_DIR)/main.o $(LIB_DIRS) $(LIBS) 
$(LDFLAGS)
+       $(CC) -o "tux_wifi_channel.exe" $(OBJ_DIR)/main.o $(LIB_DIRS) $(LIBS) 
-pipe
+       $(CC) -o "libtuxwifichannel.dll" $(OBJ_DIR)/main.o $(LIB_DIRS) $(LIBS) 
$(LDFLAGS)
        -...@rm -fR $(OBJ_DIR)/*.o
 
 clean:

Modified: software_suite_v2/software/tux_wifi_channel/trunk/VERSION
===================================================================
--- software_suite_v2/software/tux_wifi_channel/trunk/VERSION   2009-09-03 
15:21:09 UTC (rev 5328)
+++ software_suite_v2/software/tux_wifi_channel/trunk/VERSION   2009-09-04 
11:14:05 UTC (rev 5329)
@@ -1 +1 @@
-tux_wifi_channel_0.0.1
\ No newline at end of file
+tux_wifi_channel_0.0.2
\ No newline at end of file

Modified: software_suite_v2/software/tux_wifi_channel/trunk/wifi_channel_unix.c
===================================================================
--- software_suite_v2/software/tux_wifi_channel/trunk/wifi_channel_unix.c       
2009-09-03 15:21:09 UTC (rev 5328)
+++ software_suite_v2/software/tux_wifi_channel/trunk/wifi_channel_unix.c       
2009-09-04 11:14:05 UTC (rev 5329)
@@ -24,34 +24,35 @@
 #include <string.h>
 
 static int find_channel(char * iface);
+
 /**
- * \brief Program entry point.
+ * \brief Get the currently used wifi channel.
+ *        You can define a prior SSID name in the first argument.
  * Return the current used channel or -1.
  */
-int main(int argc, char *argv[])
+int get_wifi_channel(char *requested_SSID)
 {
     int channel = -1;
     int chan = 0;
     FILE *pcmd;
     char buff[80];
     char iface[10];
-    memset(&iface, NULL ,sizeof(iface)); 
+    memset(&iface, NULL ,sizeof(iface));
 
-
     /* Try to read the file containing the wireless card informations */
     pcmd = popen("cat /proc/net/wireless | grep : ", "r");
-    
+
     /* If the command is done without problem, read the output stream */
     if (pcmd != NULL)
     {
-       while (fgets(buff, 80, pcmd))
-       {
-            /* Try to find ":" which indicate a new iface line */
-           if (strstr(buff, ":") != NULL)
-           {
-               sscanf(strtok(buff, ":"), "%s", iface);
+        while (fgets(buff, 80, pcmd))
+        {
+                /* Try to find ":" which indicate a new iface line */
+            if (strstr(buff, ":") != NULL)
+            {
+                sscanf(strtok(buff, ":"), "%s", iface);
                 /* And try to determine the channel */
-               chan = find_channel(iface);
+                chan = find_channel(iface);
                 /* If the channel has been found, break the loop.
                  * Otherwise, continue with the next iface (if exists) */
                 if (chan > 0)
@@ -59,16 +60,24 @@
                     channel = chan;
                     break;
                 }
-           }
-       }
+            }
+        }
     }
-    printf("[UNIX] Channel found : %d\n", channel);
     fclose(pcmd);
-
     return channel;
 }
 
-/** 
+/**
+ * \brief Program entry point.
+ * Return the current used channel or -1.
+ */
+int main(int argc, char *argv[])
+{
+    char *requested_SSID = "";
+    return get_wifi_channel(requested_SSID);
+}
+
+/**
  * Find the channel of the current wireless interface.
  * @param iface : the interface name.
  * @return the channel, or -1 if no channels has been found.
@@ -78,7 +87,7 @@
     FILE *pcmd;
     char buff[80];
     char cmd[sizeof(iface)+sizeof("iwconfig ")+1];
-    memset(&cmd, NULL ,sizeof(cmd)); 
+    memset(&cmd, NULL ,sizeof(cmd));
     float frequency;
 
     /* Include the iface to the command */

Modified: software_suite_v2/software/tux_wifi_channel/trunk/wifi_channel_win32.c
===================================================================
--- software_suite_v2/software/tux_wifi_channel/trunk/wifi_channel_win32.c      
2009-09-03 15:21:09 UTC (rev 5328)
+++ software_suite_v2/software/tux_wifi_channel/trunk/wifi_channel_win32.c      
2009-09-04 11:14:05 UTC (rev 5329)
@@ -449,23 +449,16 @@
 }
 
 /**
- * \brief Program entry point.
+ * \brief Get the currently used wifi channel.
  *        You can define a prior SSID name in the first argument.
  * Return the current used channel or -1.
  */
-int main(int argc, char *argv[])
+int get_wifi_channel(char *requested_SSID)
 {
     int channel = -1;
-    char *requested_SSID = "";
     DWORD dwVersion = 0;
     DWORD dwMajorVersion = 0;
 
-    /* Set SSID name to search */
-    if (argc > 1)
-    {
-        requested_SSID = argv[1];
-    }
-
     /* Get the Windows version. */
     dwVersion = GetVersion();
     dwMajorVersion = (DWORD)(LOBYTE(LOWORD(dwVersion)));
@@ -503,8 +496,6 @@
                 }
             }
         }
-
-        printf("[XP] Channel found : %d\n", channel);
     }
     /* Version is vista or more recently */
     else
@@ -512,7 +503,7 @@
         /*
          * This way to retrieve the Wifi channel currently used is a bit 
tricky.
          * Previously, an easiest code was written, but was parsing directly 
the
-         * strings. 
+         * strings.
          * The major problem is that netsh return translated strings. So it's
          * it's almost impossible to do it working for all languages !
          *
@@ -561,7 +552,7 @@
                     (strstr(buff, "BSSID") == NULL))
                 {
                     sscanf(strrchr(buff, ':'), ": %s", &current_SSID[0]);
-                    /* If the current scanned SSID is the requested one, 
+                    /* If the current scanned SSID is the requested one,
                      * continue */
                     if (strcmp(current_SSID,requested_SSID) == 0)
                     {
@@ -590,7 +581,24 @@
             }
             fclose(pcmd);
         }
-        printf("[VISTA] Channel found : %d\n", channel);
     }
     return channel;
 }
+
+/**
+ * \brief Program entry point.
+ *        You can define a prior SSID name in the first argument.
+ * Return the current used channel or -1.
+ */
+int main(int argc, char *argv[])
+{
+    char *requested_SSID = "";
+
+    /* Set SSID name to search */
+    if (argc > 1)
+    {
+        requested_SSID = argv[1];
+    }
+    printf("Wifi channel is : %d\n", get_wifi_channel(requested_SSID));
+    return get_wifi_channel(requested_SSID);
+}


------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Tux-droid-svn mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/tux-droid-svn

Reply via email to