Hi Michael,
anbei schicke ich dir eine patch reihe. Die patches beinhalten im wesentlichen die posix Implementierung in der libwlocate. Ich habe es sowohl für Linux und Windows getestet.
Du kannst die patches über den Befehl git am --ignore-whitespace <patch file> hinzufügen nachdem du sie heruntergeladen hast. Den ersten Patch solltest du mit git am --ignore-whitespace --scissors <patch file> anwenden um diese Nachricht nicht mit in der commitmessage zu haben.
Schöne Grüße Tarek -- >8 --
Signed-off-by: Jan-Tarek Butt tarek@ring0.de --- master/connect.c | 532 +++++------ master/connect.h | 36 +- master/iwlist.c | 962 ++++++++++---------- master/libwlocate.dsp | 254 +++--- master/libwlocate.dsw | 106 +-- master/libwlocate.sln | 62 +- master/libwlocate.vcproj | 602 ++++++------- master/locdemo/LocDemoApp.cpp | 92 +- master/locdemo/LocDemoApp.h | 60 +- master/locdemo/LocDemoWin.cpp | 1052 +++++++++++----------- master/locdemo/LocDemoWin.h | 112 +-- master/locdemo/Makefile | 60 +- master/locdemo/Makefile.QNX | 60 +- master/locdemo/README | 34 +- master/locdemo/locdemo.dsp | 222 ++--- master/locdemo/locdemo.dsw | 58 +- master/locdemo/setup_data/LocDemo/DEBIAN/preinst | 16 +- master/locdemo/setup_data/LocDemo/DEBIAN/prerm | 18 +- master/locdemo/win_setup.nsi | 184 ++-- master/trace.dsp | 204 ++--- master/trace.dsw | 58 +- master/wlan.c | 510 +++++------ master/wlan.h | 48 +- 23 files changed, 2671 insertions(+), 2671 deletions(-)
diff --git a/master/connect.c b/master/connect.c index 4d91e34..793bdd2 100755 --- a/master/connect.c +++ b/master/connect.c @@ -1,266 +1,266 @@ -/** - * libwlocate - WLAN-based location service - * Copyright (C) 2010 Oxygenic/VWP virtual_worlds(at)gmx.de - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -#include <string.h> -#include <stdio.h> -#include <math.h> - -#ifdef ENV_WINDOWS - #include <winsock2.h> - #define MSG_NOSIGNAL 0 -#else - #include <sys/socket.h> - #include <sys/types.h> - #include <sys/ioctl.h> - #include <netinet/in.h> - #include <arpa/inet.h> - #include <unistd.h> - #include <netdb.h> -#endif - -#ifndef ENV_WINDOWSCE - #include <fcntl.h> - #include <errno.h> -#else - #ifndef EAGIAN - #define EAGAIN 11 // really the correct value? there is no errno.h for WinCE - #endif -#endif - - -#ifdef ENV_QNX - #define MSG_NOSIGNAL 0 -#endif - - -static int util_thread_sleep(int msecs) -{ -#ifdef ENV_WINDOWS - Sleep(msecs); -#else - usleep(msecs*1000); -#endif - return msecs; -} - - - -/** -Receive data from a socket connection -@param[in] sock the identifier of the opened socket connection -@param[in] data the memory area where the received data have to be stored into -@param[in] len the maximum length of data that have to be read -@param[in] termStr an optional termination string; when this value is not NULL and the character - defined here is received the function returns -@param[in] timeout when this time is exceeded the function returns also if not all data could - be read; this parameter is valid only in case the socket is non-blocking -*/ -int tcp_recv(int sock,char *data, int len,const char *termStr,long timeout) -{ - long /*size_t*/ rc; - long ctr=0,readLen=0; - #ifdef ENV_WINDOWS - long err; - #endif - - // data from source client side - while (readLen<len) - { - rc = recv(sock,data+readLen,1/*len-readLen*/,MSG_NOSIGNAL); - if (rc>0) - { - readLen+=rc; - if (termStr) - { - if (readLen+1<len) data[readLen+1]=0; - if (strstr(data,termStr)) return readLen; - } - if (readLen>=len) return readLen; - } - else if (rc==0) return readLen; - else - { -#ifdef ENV_WINDOWS - err=GetLastError(); - if ((err!=EAGAIN) && (err!=WSAEWOULDBLOCK)) -#else - if ((errno!=EAGAIN) && (errno!=EINPROGRESS) && (errno!=0)) -#endif - return readLen; - ctr+=10; - util_thread_sleep(10); - } - if (ctr>timeout) break; - } - return readLen; -} - - - -/** -Send data to a socket connection -@param[in] sock the identifier of the opened socket connection -@param[in] msg the data that have to be send -@param[in] len the length of the data -@param[in] msecs when this time is exceeded the function returns also if not all data could - be sent; this parameter is valid only in case the socket is non-blocking -*/ -int tcp_send(int sock, const char *msg,int len,int msecs) -{ - int rlen=0; - int ctr=0,val; -#ifdef ENV_WINDOWS - int errno; -#else - - errno=0; -#endif - while ((rlen<len) && (ctr<msecs)) - { -#ifdef ENV_LINUX - val=send(sock,msg+rlen,len-rlen,MSG_NOSIGNAL); -#else - val=send(sock,msg+rlen,len-rlen,0); -#endif - if (val>=0) rlen+=val; - else - { -#ifndef ENV_WINDOWS - if (errno==EAGAIN) ctr-=2; // in case of eagain we expect a longer send-timeout -#else - errno=WSAGetLastError(); - if (errno==WSAEWOULDBLOCK) ctr-=2; // in case of eagain we expect a longer send-timeout -#endif - else if (errno!=0) - { - rlen=-1; - break; - } -#ifndef ENV_WINDOWS - errno=0; -#endif - } - if (rlen<len) - { - util_thread_sleep(2); - ctr+=2; - } - if ((rlen==0) && (ctr>msecs/2)) break; - } - return rlen; -} - - - -/** -Closes an opened socket connection -@param[in] sock the socket that has to be closed -*/ -void tcp_closesocket (int sock) -{ -#ifdef ENV_WINDOWS - shutdown(sock,SD_SEND); - shutdown(sock,SD_RECEIVE); - closesocket(sock); -#else - shutdown(sock,SHUT_WR); - shutdown(sock,SHUT_RD); - if (close (sock)<0) perror("close failed"); -#endif -} - - - -/** -Tries to establish a client connection to a (remote) server socket -@param[in] address address of the remote server in style a.b.c.d or www.domain.tld -@param[in] port number to connect with -@return the socket identifier of the established connection or a value <=0 in case of an - error -*/ -int tcp_connect_to(const char *address,unsigned short connect_port) -{ - struct sockaddr_in a; - struct hostent *host; - int s; - unsigned long nl; - - s = socket (AF_INET, SOCK_STREAM, 0); - if (s<0) - { -#ifndef ENV_WINDOWSCE - perror("Can't create socket"); -#endif - return -1; - } - - memset (&a, 0, sizeof (a)); - a.sin_port = htons (connect_port); - a.sin_family = AF_INET; - a.sin_addr.s_addr =inet_addr(address); - if (a.sin_addr.s_addr==INADDR_NONE) - { - host = gethostbyname (address); // deprecated by posix standard? - if (host) - { - memcpy (&nl, host->h_addr, sizeof(unsigned long)); - a.sin_addr.s_addr = nl; - } - else - { -#ifndef ENV_WINDOWSCE - perror("Getting hostname"); -#endif - tcp_closesocket(s); - return -1; - } - } - if (connect (s, (struct sockaddr *) &a, sizeof (a)) < 0) - { -#ifndef ENV_WINDOWSCE - perror("No connection"); -#endif - tcp_closesocket (s); - return -1; - } - return s; -} - - - -/** -Configures the blocking mode of an opened socket -@param[in] sock identifier of the socket to configure -@param[in] block 1 to set the socket to blocking mode, 0 to set it to non-blocking -*/ -void tcp_set_blocking(int sock,char block) -{ - int flags; - -#ifndef ENV_WINDOWS - flags=fcntl(sock,F_GETFL, 0); - if (block) flags&=~O_NONBLOCK; - else flags|=O_NONBLOCK; - fcntl(sock,F_SETFL, flags); -#else - if (block) flags=0; - else flags=13; - ioctlsocket(sock,FIONBIO,(unsigned long*)&flags); -#endif -} - +/** + * libwlocate - WLAN-based location service + * Copyright (C) 2010 Oxygenic/VWP virtual_worlds(at)gmx.de + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +#include <string.h> +#include <stdio.h> +#include <math.h> + +#ifdef ENV_WINDOWS + #include <winsock2.h> + #define MSG_NOSIGNAL 0 +#else + #include <sys/socket.h> + #include <sys/types.h> + #include <sys/ioctl.h> + #include <netinet/in.h> + #include <arpa/inet.h> + #include <unistd.h> + #include <netdb.h> +#endif + +#ifndef ENV_WINDOWSCE + #include <fcntl.h> + #include <errno.h> +#else + #ifndef EAGIAN + #define EAGAIN 11 // really the correct value? there is no errno.h for WinCE + #endif +#endif + + +#ifdef ENV_QNX + #define MSG_NOSIGNAL 0 +#endif + + +static int util_thread_sleep(int msecs) +{ +#ifdef ENV_WINDOWS + Sleep(msecs); +#else + usleep(msecs*1000); +#endif + return msecs; +} + + + +/** +Receive data from a socket connection +@param[in] sock the identifier of the opened socket connection +@param[in] data the memory area where the received data have to be stored into +@param[in] len the maximum length of data that have to be read +@param[in] termStr an optional termination string; when this value is not NULL and the character + defined here is received the function returns +@param[in] timeout when this time is exceeded the function returns also if not all data could + be read; this parameter is valid only in case the socket is non-blocking +*/ +int tcp_recv(int sock,char *data, int len,const char *termStr,long timeout) +{ + long /*size_t*/ rc; + long ctr=0,readLen=0; + #ifdef ENV_WINDOWS + long err; + #endif + + // data from source client side + while (readLen<len) + { + rc = recv(sock,data+readLen,1/*len-readLen*/,MSG_NOSIGNAL); + if (rc>0) + { + readLen+=rc; + if (termStr) + { + if (readLen+1<len) data[readLen+1]=0; + if (strstr(data,termStr)) return readLen; + } + if (readLen>=len) return readLen; + } + else if (rc==0) return readLen; + else + { +#ifdef ENV_WINDOWS + err=GetLastError(); + if ((err!=EAGAIN) && (err!=WSAEWOULDBLOCK)) +#else + if ((errno!=EAGAIN) && (errno!=EINPROGRESS) && (errno!=0)) +#endif + return readLen; + ctr+=10; + util_thread_sleep(10); + } + if (ctr>timeout) break; + } + return readLen; +} + + + +/** +Send data to a socket connection +@param[in] sock the identifier of the opened socket connection +@param[in] msg the data that have to be send +@param[in] len the length of the data +@param[in] msecs when this time is exceeded the function returns also if not all data could + be sent; this parameter is valid only in case the socket is non-blocking +*/ +int tcp_send(int sock, const char *msg,int len,int msecs) +{ + int rlen=0; + int ctr=0,val; +#ifdef ENV_WINDOWS + int errno; +#else + + errno=0; +#endif + while ((rlen<len) && (ctr<msecs)) + { +#ifdef ENV_LINUX + val=send(sock,msg+rlen,len-rlen,MSG_NOSIGNAL); +#else + val=send(sock,msg+rlen,len-rlen,0); +#endif + if (val>=0) rlen+=val; + else + { +#ifndef ENV_WINDOWS + if (errno==EAGAIN) ctr-=2; // in case of eagain we expect a longer send-timeout +#else + errno=WSAGetLastError(); + if (errno==WSAEWOULDBLOCK) ctr-=2; // in case of eagain we expect a longer send-timeout +#endif + else if (errno!=0) + { + rlen=-1; + break; + } +#ifndef ENV_WINDOWS + errno=0; +#endif + } + if (rlen<len) + { + util_thread_sleep(2); + ctr+=2; + } + if ((rlen==0) && (ctr>msecs/2)) break; + } + return rlen; +} + + + +/** +Closes an opened socket connection +@param[in] sock the socket that has to be closed +*/ +void tcp_closesocket (int sock) +{ +#ifdef ENV_WINDOWS + shutdown(sock,SD_SEND); + shutdown(sock,SD_RECEIVE); + closesocket(sock); +#else + shutdown(sock,SHUT_WR); + shutdown(sock,SHUT_RD); + if (close (sock)<0) perror("close failed"); +#endif +} + + + +/** +Tries to establish a client connection to a (remote) server socket +@param[in] address address of the remote server in style a.b.c.d or www.domain.tld +@param[in] port number to connect with +@return the socket identifier of the established connection or a value <=0 in case of an + error +*/ +int tcp_connect_to(const char *address,unsigned short connect_port) +{ + struct sockaddr_in a; + struct hostent *host; + int s; + unsigned long nl; + + s = socket (AF_INET, SOCK_STREAM, 0); + if (s<0) + { +#ifndef ENV_WINDOWSCE + perror("Can't create socket"); +#endif + return -1; + } + + memset (&a, 0, sizeof (a)); + a.sin_port = htons (connect_port); + a.sin_family = AF_INET; + a.sin_addr.s_addr =inet_addr(address); + if (a.sin_addr.s_addr==INADDR_NONE) + { + host = gethostbyname (address); // deprecated by posix standard? + if (host) + { + memcpy (&nl, host->h_addr, sizeof(unsigned long)); + a.sin_addr.s_addr = nl; + } + else + { +#ifndef ENV_WINDOWSCE + perror("Getting hostname"); +#endif + tcp_closesocket(s); + return -1; + } + } + if (connect (s, (struct sockaddr *) &a, sizeof (a)) < 0) + { +#ifndef ENV_WINDOWSCE + perror("No connection"); +#endif + tcp_closesocket (s); + return -1; + } + return s; +} + + + +/** +Configures the blocking mode of an opened socket +@param[in] sock identifier of the socket to configure +@param[in] block 1 to set the socket to blocking mode, 0 to set it to non-blocking +*/ +void tcp_set_blocking(int sock,char block) +{ + int flags; + +#ifndef ENV_WINDOWS + flags=fcntl(sock,F_GETFL, 0); + if (block) flags&=~O_NONBLOCK; + else flags|=O_NONBLOCK; + fcntl(sock,F_SETFL, flags); +#else + if (block) flags=0; + else flags=13; + ioctlsocket(sock,FIONBIO,(unsigned long*)&flags); +#endif +} + diff --git a/master/connect.h b/master/connect.h index e4a05e5..114ecb7 100755 --- a/master/connect.h +++ b/master/connect.h @@ -1,21 +1,21 @@ -/** - * libwlocate - WLAN-based location service - * Copyright (C) 2010 Oxygenic/VWP virtual_worlds(at)gmx.de - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - +/** + * libwlocate - WLAN-based location service + * Copyright (C) 2010 Oxygenic/VWP virtual_worlds(at)gmx.de + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + #ifndef CONNECT_H #define CONNECT_H
diff --git a/master/iwlist.c b/master/iwlist.c index 5d1b130..e1a731a 100755 --- a/master/iwlist.c +++ b/master/iwlist.c @@ -1,481 +1,481 @@ -/* - * Wireless Tools - * - * Jean II - HPLB '99 - HPL 99->07 - * - * This tool can access various piece of information on the card - * not part of iwconfig... - * You need to link this code against "iwlist.c" and "-lm". - * - * This file is released under the GPL license. - * Copyright (c) 1997-2007 Jean Tourrilhes jt@hpl.hp.com - */ - -#include "iwlib.h" /* Header */ -#include "libwlocate.h" -#include <sys/time.h> - -static struct wloc_req *g_request; -static struct iwscan_state state; - -/****************************** TYPES ******************************/ - -/* - * Scan state and meta-information, used to decode events... - */ -typedef struct iwscan_state -{ - /* State */ - int ap_num; /* Access Point number 1->N */ - int val_index; /* Value in table 0->(N-1) */ -} iwscan_state; - -/* - * Bit to name mapping - */ -typedef struct iwmask_name -{ - unsigned int mask; /* bit mask for the value */ - const char * name; /* human readable name for the value */ -} iwmask_name; - -/* - * Types of authentication parameters - */ -typedef struct iw_auth_descr -{ - int value; /* Type of auth value */ - const char * label; /* User readable version */ - const struct iwmask_name * names; /* Names for this value */ - const int num_names; /* Number of names */ -} iw_auth_descr; - -/**************************** CONSTANTS ****************************/ - -#define IW_SCAN_HACK 0x8000 - -#define IW_EXTKEY_SIZE (sizeof(struct iw_encode_ext) + IW_ENCODING_TOKEN_MAX) - - - -/***************************** SCANNING *****************************/ -/* - * This one behave quite differently from the others - * - * Note that we don't use the scanning capability of iwlib (functions - * iw_process_scan() and iw_scan()). The main reason is that - * iw_process_scan() return only a subset of the scan data to the caller, - * for example custom elements and bitrates are ommited. Here, we - * do the complete job... - */ - -/*------------------------------------------------------------------*/ -/* - * Print one element from the scanning results - */ -static inline void -print_scanning_token(struct stream_descr * stream, /* Stream of events */ - struct iw_event * event, /* Extracted token */ - struct iwscan_state * state, - struct iw_range * iw_range, /* Range info */ - int has_range) -{ - int i; - char buffer[128]; - - if (state->ap_num>=WLOC_MAX_NETWORKS) - return; - /* Now, let's decode the event */ - switch(event->cmd) - { - case SIOCGIWAP: -// printf(" Cell %02d - Address: %s\n", state->ap_num, iw_saether_ntop(&event->u.ap_addr, buffer)); - state->ap_num++; - for (i=0; i<6; i++) - g_request->bssids[state->ap_num-1][i]=(event->u.ap_addr.sa_data[i] & 0xFF); - break; - case IWEVQUAL: - { -// if (iw_range->max_qual.qual==0) g_request->signal[state->ap_num-1]=abs(event->u.qual.qual); -// else g_request->signal[state->ap_num-1]=100.0*event->u.qual.qual/iw_range->max_qual.qual; -// printf(" Signal: %d\n",g_request->signal[state->ap_num-1]); - break; - } - default: - break; - } /* switch(event->cmd) */ -} - -/*------------------------------------------------------------------*/ -/* - * Perform a scanning on one device - */ -static int -print_scanning_info(int skfd, - char * ifname, - char * args[], /* Command line args */ - int count) /* Args count */ -{ - struct iwreq wrq; - struct iw_scan_req scanopt; /* Options for 'set' */ - int scanflags = 0; /* Flags for scan */ - unsigned char * buffer = NULL; /* Results */ - int buflen = IW_SCAN_MAX_DATA; /* Min for compat WE<17 */ - struct iw_range range; - int has_range; - struct timeval tv; /* Select timeout */ - int timeout = 15000000; /* 15s */ - - /* Avoid "Unused parameter" warning */ - args = args; count = count; - - /* Debugging stuff */ -/* if((IW_EV_LCP_PK2_LEN != IW_EV_LCP_PK_LEN) || (IW_EV_POINT_PK2_LEN != IW_EV_POINT_PK_LEN)) - { - fprintf(stderr, "*** Please report to jt@hpl.hp.com your platform details\n"); - fprintf(stderr, "*** and the following line :\n"); - fprintf(stderr, "*** IW_EV_LCP_PK2_LEN = %zu ; IW_EV_POINT_PK2_LEN = %zu\n\n", - IW_EV_LCP_PK2_LEN, IW_EV_POINT_PK2_LEN); - }*/ - - /* Get range stuff */ - has_range = (iw_get_range_info(skfd, ifname, &range) >= 0); - - /* Check if the interface could support scanning. */ - if (range.we_version_compiled==0) range.we_version_compiled=29; - if((!has_range) || (range.we_version_compiled < 14)) - { - fprintf(stderr, "%-8.16s Interface doesn't support scanning.\n\n", - ifname); - return(-1); - } - - /* Init timeout value -> 250ms between set and first get */ - tv.tv_sec = 0; - tv.tv_usec = 250000; - - /* Clean up set args */ - memset(&scanopt, 0, sizeof(scanopt)); - - /* Parse command line arguments and extract options. - * Note : when we have enough options, we should use the parser - * from iwconfig... */ -/* while(count > 0) - { - - count--; - - if(!strncmp(args[0], "essid", 5)) - { - if(count < 1) - { - fprintf(stderr, "Too few arguments for scanning option [%s]\n", - args[0]); - return(-1); - } - args++; - count--; - - scanopt.essid_len = strlen(args[0]); - memcpy(scanopt.essid, args[0], scanopt.essid_len); - if(scanopt.bssid.sa_family == 0) - { - scanopt.bssid.sa_family = ARPHRD_ETHER; - memset(scanopt.bssid.sa_data, 0xff, ETH_ALEN); - } - scanflags |= IW_SCAN_THIS_ESSID; - } - else - if(!strncmp(args[0], "last", 4)) - { - scanflags |= IW_SCAN_HACK; - } - else - { - fprintf(stderr, "Invalid scanning option [%s]\n", args[0]); - return(-1); - } - - args++; - }*/ - - /* Check if we have scan options */ -/* if(scanflags) - { - wrq.u.data.pointer = (caddr_t) &scanopt; - wrq.u.data.length = sizeof(scanopt); - wrq.u.data.flags = scanflags; - } - else*/ - { - wrq.u.data.pointer = NULL; - wrq.u.data.flags = 0; - wrq.u.data.length = 0; - } - - /* If only 'last' was specified on command line, don't trigger a scan */ -/* if(scanflags == IW_SCAN_HACK) - { - tv.tv_usec = 0; - } - else*/ - { - /* Initiate Scanning */ - if(iw_set_ext(skfd, ifname, SIOCSIWSCAN, &wrq) < 0) - { - if((errno != EPERM) || (scanflags != 0)) - { - fprintf(stderr, "%-8.16s Interface doesn't support scanning : %s\n\n", - ifname, strerror(errno)); - return(-1); - } - /* If we don't have the permission to initiate the scan, we may - * still have permission to read left-over results. - * But, don't wait !!! */ -#if 0 - /* Not cool, it display for non wireless interfaces... */ - fprintf(stderr, "%-8.16s (Could not trigger scanning, just reading left-over results)\n", ifname); -#endif - tv.tv_usec = 0; - } - } - timeout -= tv.tv_usec; - - /* Forever */ - while(1) - { - fd_set rfds; /* File descriptors for select */ - int last_fd; /* Last fd */ - int ret; - - /* Guess what ? We must re-generate rfds each time */ - FD_ZERO(&rfds); - last_fd = -1; - - /* In here, add the rtnetlink fd in the list */ - - /* Wait until something happens */ - ret = select(last_fd + 1, &rfds, NULL, NULL, &tv); - - /* Check if there was an error */ - if(ret < 0) - { - if(errno == EAGAIN || errno == EINTR) - continue; - fprintf(stderr, "Unhandled signal - exiting...\n"); - return(-1); - } - - /* Check if there was a timeout */ - if(ret == 0) - { - unsigned char * newbuf; - - realloc: - /* (Re)allocate the buffer - realloc(NULL, len) == malloc(len) */ - newbuf = (unsigned char*)realloc(buffer, buflen); - if(newbuf == NULL) - { - if(buffer) - free(buffer); - fprintf(stderr, "%s: Allocation failed\n", __FUNCTION__); - return(-1); - } - buffer = newbuf; - - /* Try to read the results */ - wrq.u.data.pointer = buffer; - wrq.u.data.flags = 0; - wrq.u.data.length = buflen; - if(iw_get_ext(skfd, ifname, SIOCGIWSCAN, &wrq) < 0) - { - /* Check if buffer was too small (WE-17 only) */ - if((errno == E2BIG) && (range.we_version_compiled > 16)) - { - /* Some driver may return very large scan results, either - * because there are many cells, or because they have many - * large elements in cells (like IWEVCUSTOM). Most will - * only need the regular sized buffer. We now use a dynamic - * allocation of the buffer to satisfy everybody. Of course, - * as we don't know in advance the size of the array, we try - * various increasing sizes. Jean II */ - - /* Check if the driver gave us any hints. */ - if(wrq.u.data.length > buflen) - buflen = wrq.u.data.length; - else - buflen *= 2; - - /* Try again */ - goto realloc; - } - - /* Check if results not available yet */ - if(errno == EAGAIN) - { - /* Restart timer for only 100ms*/ - tv.tv_sec = 0; - tv.tv_usec = 100000; - timeout -= tv.tv_usec; - if(timeout > 0) - continue; /* Try again later */ - } - - /* Bad error */ - free(buffer); - fprintf(stderr, "%-8.16s Failed to read scan data : %s\n\n", - ifname, strerror(errno)); - return(-2); - } - else - /* We have the results, go to process them */ - break; - } - - /* In here, check if event and event type - * if scan event, read results. All errors bad & no reset timeout */ - } - - if(wrq.u.data.length) - { - struct iw_event iwe; - struct stream_descr stream; - int ret; - - state.ap_num = 0; - state.val_index = 0; -#ifdef DEBUG - /* Debugging code. In theory useless, because it's debugged ;-) */ - int i; - printf("Scan result %d [%02X", wrq.u.data.length, buffer[0]); - for(i = 1; i < wrq.u.data.length; i++) - printf(":%02X", buffer[i]); - printf("]\n"); -#endif - printf("%-8.16s Scan completed :\n", ifname); - iw_init_event_stream(&stream, (char *) buffer, wrq.u.data.length); - do - { - /* Extract an event and print it */ - ret = iw_extract_event_stream(&stream, &iwe, - range.we_version_compiled); - if(ret > 0) - print_scanning_token(&stream, &iwe, &state, - &range, has_range); - } - while(ret > 0); - printf("\n"); - } - else - printf("%-8.16s No scan results\n\n", ifname); - - free(buffer); - return(0); -} - -/*********************** FREQUENCIES/CHANNELS ***********************/ - -/*------------------------------------------------------------------*/ -/* - * Power Management types of values - */ -static const unsigned int pm_type_flags[] = { - IW_POWER_PERIOD, - IW_POWER_TIMEOUT, - IW_POWER_SAVING, -}; -static const int pm_type_flags_size = (sizeof(pm_type_flags)/sizeof(pm_type_flags[0])); - - - -/************************* COMMON UTILITIES *************************/ -/* - * This section was initially written by Michael Tokarev mjt@tls.msk.ru - * but heavily modified by me ;-) - */ - -/*------------------------------------------------------------------*/ -/* - * Map command line arguments to the proper procedure... - */ -typedef struct iwlist_entry { - const char * cmd; /* Command line shorthand */ - iw_enum_handler fn; /* Subroutine */ - int max_count; - const char * argsname; /* Args as human readable string */ -} iwlist_cmd; - -static const struct iwlist_entry iwlist_cmds[] = { - { "scanning", print_scanning_info, -1, "[essid NNN] [last]" }, - { NULL, NULL, 0, 0 }, -}; - -/*------------------------------------------------------------------*/ -/* - * Find the most appropriate command matching the command line - */ -static inline const iwlist_cmd * -find_command(const char * cmd) -{ - const iwlist_cmd * found = NULL; - int ambig = 0; - unsigned int len = strlen(cmd); - int i; - - /* Go through all commands */ - for(i = 0; iwlist_cmds[i].cmd != NULL; ++i) - { - /* No match -> next one */ - if(strncasecmp(iwlist_cmds[i].cmd, cmd, len) != 0) - continue; - - /* Exact match -> perfect */ - if(len == strlen(iwlist_cmds[i].cmd)) - return &iwlist_cmds[i]; - - /* Partial match */ - if(found == NULL) - /* First time */ - found = &iwlist_cmds[i]; - else - /* Another time */ - if (iwlist_cmds[i].fn != found->fn) - ambig = 1; - } - - if(found == NULL) - { - fprintf(stderr, "iwlist: unknown command `%s' (check 'iwlist --help').\n", cmd); - return NULL; - } - - if(ambig) - { - fprintf(stderr, "iwlist: command `%s' is ambiguous (check 'iwlist --help').\n", cmd); - return NULL; - } - - return found; -} - - - -int iw_fill_structure(struct wloc_req *request) -{ - int skfd; - /* Create a channel to the NET kernel. */ - if((skfd = iw_sockets_open()) < 0) - { - perror("socket"); - return -1; - } - g_request=request; - - /* do the actual work */ - iw_enum_devices(skfd,print_scanning_info,NULL,-1); - - /* Close the socket. */ - iw_sockets_close(skfd); - - return state.ap_num; -} +/* + * Wireless Tools + * + * Jean II - HPLB '99 - HPL 99->07 + * + * This tool can access various piece of information on the card + * not part of iwconfig... + * You need to link this code against "iwlist.c" and "-lm". + * + * This file is released under the GPL license. + * Copyright (c) 1997-2007 Jean Tourrilhes jt@hpl.hp.com + */ + +#include "iwlib.h" /* Header */ +#include "libwlocate.h" +#include <sys/time.h> + +static struct wloc_req *g_request; +static struct iwscan_state state; + +/****************************** TYPES ******************************/ + +/* + * Scan state and meta-information, used to decode events... + */ +typedef struct iwscan_state +{ + /* State */ + int ap_num; /* Access Point number 1->N */ + int val_index; /* Value in table 0->(N-1) */ +} iwscan_state; + +/* + * Bit to name mapping + */ +typedef struct iwmask_name +{ + unsigned int mask; /* bit mask for the value */ + const char * name; /* human readable name for the value */ +} iwmask_name; + +/* + * Types of authentication parameters + */ +typedef struct iw_auth_descr +{ + int value; /* Type of auth value */ + const char * label; /* User readable version */ + const struct iwmask_name * names; /* Names for this value */ + const int num_names; /* Number of names */ +} iw_auth_descr; + +/**************************** CONSTANTS ****************************/ + +#define IW_SCAN_HACK 0x8000 + +#define IW_EXTKEY_SIZE (sizeof(struct iw_encode_ext) + IW_ENCODING_TOKEN_MAX) + + + +/***************************** SCANNING *****************************/ +/* + * This one behave quite differently from the others + * + * Note that we don't use the scanning capability of iwlib (functions + * iw_process_scan() and iw_scan()). The main reason is that + * iw_process_scan() return only a subset of the scan data to the caller, + * for example custom elements and bitrates are ommited. Here, we + * do the complete job... + */ + +/*------------------------------------------------------------------*/ +/* + * Print one element from the scanning results + */ +static inline void +print_scanning_token(struct stream_descr * stream, /* Stream of events */ + struct iw_event * event, /* Extracted token */ + struct iwscan_state * state, + struct iw_range * iw_range, /* Range info */ + int has_range) +{ + int i; + char buffer[128]; + + if (state->ap_num>=WLOC_MAX_NETWORKS) + return; + /* Now, let's decode the event */ + switch(event->cmd) + { + case SIOCGIWAP: +// printf(" Cell %02d - Address: %s\n", state->ap_num, iw_saether_ntop(&event->u.ap_addr, buffer)); + state->ap_num++; + for (i=0; i<6; i++) + g_request->bssids[state->ap_num-1][i]=(event->u.ap_addr.sa_data[i] & 0xFF); + break; + case IWEVQUAL: + { +// if (iw_range->max_qual.qual==0) g_request->signal[state->ap_num-1]=abs(event->u.qual.qual); +// else g_request->signal[state->ap_num-1]=100.0*event->u.qual.qual/iw_range->max_qual.qual; +// printf(" Signal: %d\n",g_request->signal[state->ap_num-1]); + break; + } + default: + break; + } /* switch(event->cmd) */ +} + +/*------------------------------------------------------------------*/ +/* + * Perform a scanning on one device + */ +static int +print_scanning_info(int skfd, + char * ifname, + char * args[], /* Command line args */ + int count) /* Args count */ +{ + struct iwreq wrq; + struct iw_scan_req scanopt; /* Options for 'set' */ + int scanflags = 0; /* Flags for scan */ + unsigned char * buffer = NULL; /* Results */ + int buflen = IW_SCAN_MAX_DATA; /* Min for compat WE<17 */ + struct iw_range range; + int has_range; + struct timeval tv; /* Select timeout */ + int timeout = 15000000; /* 15s */ + + /* Avoid "Unused parameter" warning */ + args = args; count = count; + + /* Debugging stuff */ +/* if((IW_EV_LCP_PK2_LEN != IW_EV_LCP_PK_LEN) || (IW_EV_POINT_PK2_LEN != IW_EV_POINT_PK_LEN)) + { + fprintf(stderr, "*** Please report to jt@hpl.hp.com your platform details\n"); + fprintf(stderr, "*** and the following line :\n"); + fprintf(stderr, "*** IW_EV_LCP_PK2_LEN = %zu ; IW_EV_POINT_PK2_LEN = %zu\n\n", + IW_EV_LCP_PK2_LEN, IW_EV_POINT_PK2_LEN); + }*/ + + /* Get range stuff */ + has_range = (iw_get_range_info(skfd, ifname, &range) >= 0); + + /* Check if the interface could support scanning. */ + if (range.we_version_compiled==0) range.we_version_compiled=29; + if((!has_range) || (range.we_version_compiled < 14)) + { + fprintf(stderr, "%-8.16s Interface doesn't support scanning.\n\n", + ifname); + return(-1); + } + + /* Init timeout value -> 250ms between set and first get */ + tv.tv_sec = 0; + tv.tv_usec = 250000; + + /* Clean up set args */ + memset(&scanopt, 0, sizeof(scanopt)); + + /* Parse command line arguments and extract options. + * Note : when we have enough options, we should use the parser + * from iwconfig... */ +/* while(count > 0) + { + + count--; + + if(!strncmp(args[0], "essid", 5)) + { + if(count < 1) + { + fprintf(stderr, "Too few arguments for scanning option [%s]\n", + args[0]); + return(-1); + } + args++; + count--; + + scanopt.essid_len = strlen(args[0]); + memcpy(scanopt.essid, args[0], scanopt.essid_len); + if(scanopt.bssid.sa_family == 0) + { + scanopt.bssid.sa_family = ARPHRD_ETHER; + memset(scanopt.bssid.sa_data, 0xff, ETH_ALEN); + } + scanflags |= IW_SCAN_THIS_ESSID; + } + else + if(!strncmp(args[0], "last", 4)) + { + scanflags |= IW_SCAN_HACK; + } + else + { + fprintf(stderr, "Invalid scanning option [%s]\n", args[0]); + return(-1); + } + + args++; + }*/ + + /* Check if we have scan options */ +/* if(scanflags) + { + wrq.u.data.pointer = (caddr_t) &scanopt; + wrq.u.data.length = sizeof(scanopt); + wrq.u.data.flags = scanflags; + } + else*/ + { + wrq.u.data.pointer = NULL; + wrq.u.data.flags = 0; + wrq.u.data.length = 0; + } + + /* If only 'last' was specified on command line, don't trigger a scan */ +/* if(scanflags == IW_SCAN_HACK) + { + tv.tv_usec = 0; + } + else*/ + { + /* Initiate Scanning */ + if(iw_set_ext(skfd, ifname, SIOCSIWSCAN, &wrq) < 0) + { + if((errno != EPERM) || (scanflags != 0)) + { + fprintf(stderr, "%-8.16s Interface doesn't support scanning : %s\n\n", + ifname, strerror(errno)); + return(-1); + } + /* If we don't have the permission to initiate the scan, we may + * still have permission to read left-over results. + * But, don't wait !!! */ +#if 0 + /* Not cool, it display for non wireless interfaces... */ + fprintf(stderr, "%-8.16s (Could not trigger scanning, just reading left-over results)\n", ifname); +#endif + tv.tv_usec = 0; + } + } + timeout -= tv.tv_usec; + + /* Forever */ + while(1) + { + fd_set rfds; /* File descriptors for select */ + int last_fd; /* Last fd */ + int ret; + + /* Guess what ? We must re-generate rfds each time */ + FD_ZERO(&rfds); + last_fd = -1; + + /* In here, add the rtnetlink fd in the list */ + + /* Wait until something happens */ + ret = select(last_fd + 1, &rfds, NULL, NULL, &tv); + + /* Check if there was an error */ + if(ret < 0) + { + if(errno == EAGAIN || errno == EINTR) + continue; + fprintf(stderr, "Unhandled signal - exiting...\n"); + return(-1); + } + + /* Check if there was a timeout */ + if(ret == 0) + { + unsigned char * newbuf; + + realloc: + /* (Re)allocate the buffer - realloc(NULL, len) == malloc(len) */ + newbuf = (unsigned char*)realloc(buffer, buflen); + if(newbuf == NULL) + { + if(buffer) + free(buffer); + fprintf(stderr, "%s: Allocation failed\n", __FUNCTION__); + return(-1); + } + buffer = newbuf; + + /* Try to read the results */ + wrq.u.data.pointer = buffer; + wrq.u.data.flags = 0; + wrq.u.data.length = buflen; + if(iw_get_ext(skfd, ifname, SIOCGIWSCAN, &wrq) < 0) + { + /* Check if buffer was too small (WE-17 only) */ + if((errno == E2BIG) && (range.we_version_compiled > 16)) + { + /* Some driver may return very large scan results, either + * because there are many cells, or because they have many + * large elements in cells (like IWEVCUSTOM). Most will + * only need the regular sized buffer. We now use a dynamic + * allocation of the buffer to satisfy everybody. Of course, + * as we don't know in advance the size of the array, we try + * various increasing sizes. Jean II */ + + /* Check if the driver gave us any hints. */ + if(wrq.u.data.length > buflen) + buflen = wrq.u.data.length; + else + buflen *= 2; + + /* Try again */ + goto realloc; + } + + /* Check if results not available yet */ + if(errno == EAGAIN) + { + /* Restart timer for only 100ms*/ + tv.tv_sec = 0; + tv.tv_usec = 100000; + timeout -= tv.tv_usec; + if(timeout > 0) + continue; /* Try again later */ + } + + /* Bad error */ + free(buffer); + fprintf(stderr, "%-8.16s Failed to read scan data : %s\n\n", + ifname, strerror(errno)); + return(-2); + } + else + /* We have the results, go to process them */ + break; + } + + /* In here, check if event and event type + * if scan event, read results. All errors bad & no reset timeout */ + } + + if(wrq.u.data.length) + { + struct iw_event iwe; + struct stream_descr stream; + int ret; + + state.ap_num = 0; + state.val_index = 0; +#ifdef DEBUG + /* Debugging code. In theory useless, because it's debugged ;-) */ + int i; + printf("Scan result %d [%02X", wrq.u.data.length, buffer[0]); + for(i = 1; i < wrq.u.data.length; i++) + printf(":%02X", buffer[i]); + printf("]\n"); +#endif + printf("%-8.16s Scan completed :\n", ifname); + iw_init_event_stream(&stream, (char *) buffer, wrq.u.data.length); + do + { + /* Extract an event and print it */ + ret = iw_extract_event_stream(&stream, &iwe, + range.we_version_compiled); + if(ret > 0) + print_scanning_token(&stream, &iwe, &state, + &range, has_range); + } + while(ret > 0); + printf("\n"); + } + else + printf("%-8.16s No scan results\n\n", ifname); + + free(buffer); + return(0); +} + +/*********************** FREQUENCIES/CHANNELS ***********************/ + +/*------------------------------------------------------------------*/ +/* + * Power Management types of values + */ +static const unsigned int pm_type_flags[] = { + IW_POWER_PERIOD, + IW_POWER_TIMEOUT, + IW_POWER_SAVING, +}; +static const int pm_type_flags_size = (sizeof(pm_type_flags)/sizeof(pm_type_flags[0])); + + + +/************************* COMMON UTILITIES *************************/ +/* + * This section was initially written by Michael Tokarev mjt@tls.msk.ru + * but heavily modified by me ;-) + */ + +/*------------------------------------------------------------------*/ +/* + * Map command line arguments to the proper procedure... + */ +typedef struct iwlist_entry { + const char * cmd; /* Command line shorthand */ + iw_enum_handler fn; /* Subroutine */ + int max_count; + const char * argsname; /* Args as human readable string */ +} iwlist_cmd; + +static const struct iwlist_entry iwlist_cmds[] = { + { "scanning", print_scanning_info, -1, "[essid NNN] [last]" }, + { NULL, NULL, 0, 0 }, +}; + +/*------------------------------------------------------------------*/ +/* + * Find the most appropriate command matching the command line + */ +static inline const iwlist_cmd * +find_command(const char * cmd) +{ + const iwlist_cmd * found = NULL; + int ambig = 0; + unsigned int len = strlen(cmd); + int i; + + /* Go through all commands */ + for(i = 0; iwlist_cmds[i].cmd != NULL; ++i) + { + /* No match -> next one */ + if(strncasecmp(iwlist_cmds[i].cmd, cmd, len) != 0) + continue; + + /* Exact match -> perfect */ + if(len == strlen(iwlist_cmds[i].cmd)) + return &iwlist_cmds[i]; + + /* Partial match */ + if(found == NULL) + /* First time */ + found = &iwlist_cmds[i]; + else + /* Another time */ + if (iwlist_cmds[i].fn != found->fn) + ambig = 1; + } + + if(found == NULL) + { + fprintf(stderr, "iwlist: unknown command `%s' (check 'iwlist --help').\n", cmd); + return NULL; + } + + if(ambig) + { + fprintf(stderr, "iwlist: command `%s' is ambiguous (check 'iwlist --help').\n", cmd); + return NULL; + } + + return found; +} + + + +int iw_fill_structure(struct wloc_req *request) +{ + int skfd; + /* Create a channel to the NET kernel. */ + if((skfd = iw_sockets_open()) < 0) + { + perror("socket"); + return -1; + } + g_request=request; + + /* do the actual work */ + iw_enum_devices(skfd,print_scanning_info,NULL,-1); + + /* Close the socket. */ + iw_sockets_close(skfd); + + return state.ap_num; +} diff --git a/master/libwlocate.dsp b/master/libwlocate.dsp index a0bdac8..01b1809 100755 --- a/master/libwlocate.dsp +++ b/master/libwlocate.dsp @@ -1,127 +1,127 @@ -# Microsoft Developer Studio Project File - Name="libwlocate" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 - -CFG=libwlocate - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "libwlocate.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "libwlocate.mak" CFG="libwlocate - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "libwlocate - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE "libwlocate - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "libwlocate - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBWLOCATE_EXPORTS" /YX /FD /c -# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBWLOCATE_EXPORTS" /D "ENV_WINDOWS" /YX /FD /c -# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x407 /d "NDEBUG" -# ADD RSC /l 0x407 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /dll /machine:I386 - -!ELSEIF "$(CFG)" == "libwlocate - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "Debug" -# PROP BASE Intermediate_Dir "Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "Debug" -# PROP Intermediate_Dir "Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBWLOCATE_EXPORTS" /YX /FD /GZ /c -# ADD CPP /nologo /Zp1 /MDd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBWLOCATE_EXPORTS" /D "ENV_WINDOWS" /FR /YX /FD /GZ /c -# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 -# ADD BASE RSC /l 0x407 /d "_DEBUG" -# ADD RSC /l 0x407 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept -# Begin Special Build Tool -SOURCE="$(InputPath)" -PostBuild_Cmds=copy Debug\libwlocate.dll C:\Windows\system32 -# End Special Build Tool - -!ENDIF - -# Begin Target - -# Name "libwlocate - Win32 Release" -# Name "libwlocate - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\connect.c -# End Source File -# Begin Source File - -SOURCE=.\libwlocate.c -# End Source File -# Begin Source File - -SOURCE=.\wlan.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# Begin Source File - -SOURCE=.\wlan.h -# End Source File -# Begin Source File - -SOURCE=.\wlanapi_cust.h -# End Source File -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# End Group -# End Target -# End Project +# Microsoft Developer Studio Project File - Name="libwlocate" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102 + +CFG=libwlocate - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "libwlocate.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "libwlocate.mak" CFG="libwlocate - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "libwlocate - Win32 Release" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE "libwlocate - Win32 Debug" (based on "Win32 (x86) Dynamic-Link Library") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "libwlocate - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBWLOCATE_EXPORTS" /YX /FD /c +# ADD CPP /nologo /MT /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBWLOCATE_EXPORTS" /D "ENV_WINDOWS" /YX /FD /c +# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x407 /d "NDEBUG" +# ADD RSC /l 0x407 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386 +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /dll /machine:I386 + +!ELSEIF "$(CFG)" == "libwlocate - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "Debug" +# PROP BASE Intermediate_Dir "Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "Debug" +# PROP Intermediate_Dir "Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBWLOCATE_EXPORTS" /YX /FD /GZ /c +# ADD CPP /nologo /Zp1 /MDd /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "LIBWLOCATE_EXPORTS" /D "ENV_WINDOWS" /FR /YX /FD /GZ /c +# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32 +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept +# Begin Special Build Tool +SOURCE="$(InputPath)" +PostBuild_Cmds=copy Debug\libwlocate.dll C:\Windows\system32 +# End Special Build Tool + +!ENDIF + +# Begin Target + +# Name "libwlocate - Win32 Release" +# Name "libwlocate - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\connect.c +# End Source File +# Begin Source File + +SOURCE=.\libwlocate.c +# End Source File +# Begin Source File + +SOURCE=.\wlan.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# Begin Source File + +SOURCE=.\wlan.h +# End Source File +# Begin Source File + +SOURCE=.\wlanapi_cust.h +# End Source File +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/master/libwlocate.dsw b/master/libwlocate.dsw index 66166cd..b7e5b72 100755 --- a/master/libwlocate.dsw +++ b/master/libwlocate.dsw @@ -1,53 +1,53 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "libwlocate"=.\libwlocate.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "locdemo"=.\locdemo\locdemo.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Project: "trace"=.\trace.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "libwlocate"=.\libwlocate.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "locdemo"=.\locdemo\locdemo.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Project: "trace"=.\trace.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/master/libwlocate.sln b/master/libwlocate.sln index 2c737a4..74b9a82 100755 --- a/master/libwlocate.sln +++ b/master/libwlocate.sln @@ -1,31 +1,31 @@ -? -Microsoft Visual Studio Solution File, Format Version 12.00 -# Visual Studio 2012 -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libwlocate", "libwlocate.vcxproj", "{123462F3-4EA1-4F63-B1BC-0A2B52DAB9DB}" -EndProject -Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "trace", "trace.vcxproj", "{751B5C2A-5743-443F-8CA6-0A9287C39758}" -EndProject -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - Template|Win32 = Template|Win32 - EndGlobalSection - GlobalSection(ProjectConfigurationPlatforms) = postSolution - {123462F3-4EA1-4F63-B1BC-0A2B52DAB9DB}.Debug|Win32.ActiveCfg = Debug|Win32 - {123462F3-4EA1-4F63-B1BC-0A2B52DAB9DB}.Debug|Win32.Build.0 = Debug|Win32 - {123462F3-4EA1-4F63-B1BC-0A2B52DAB9DB}.Release|Win32.ActiveCfg = Release|Win32 - {123462F3-4EA1-4F63-B1BC-0A2B52DAB9DB}.Release|Win32.Build.0 = Release|Win32 - {123462F3-4EA1-4F63-B1BC-0A2B52DAB9DB}.Template|Win32.ActiveCfg = Release|Win32 - {123462F3-4EA1-4F63-B1BC-0A2B52DAB9DB}.Template|Win32.Build.0 = Release|Win32 - {751B5C2A-5743-443F-8CA6-0A9287C39758}.Debug|Win32.ActiveCfg = Debug|Win32 - {751B5C2A-5743-443F-8CA6-0A9287C39758}.Debug|Win32.Build.0 = Debug|Win32 - {751B5C2A-5743-443F-8CA6-0A9287C39758}.Release|Win32.ActiveCfg = Release|Win32 - {751B5C2A-5743-443F-8CA6-0A9287C39758}.Release|Win32.Build.0 = Release|Win32 - {751B5C2A-5743-443F-8CA6-0A9287C39758}.Template|Win32.ActiveCfg = Template|Win32 - {751B5C2A-5743-443F-8CA6-0A9287C39758}.Template|Win32.Build.0 = Template|Win32 - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal + +Microsoft Visual Studio Solution File, Format Version 12.00 +# Visual Studio 2012 +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "libwlocate", "libwlocate.vcxproj", "{123462F3-4EA1-4F63-B1BC-0A2B52DAB9DB}" +EndProject +Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "trace", "trace.vcxproj", "{751B5C2A-5743-443F-8CA6-0A9287C39758}" +EndProject +Global + GlobalSection(SolutionConfigurationPlatforms) = preSolution + Debug|Win32 = Debug|Win32 + Release|Win32 = Release|Win32 + Template|Win32 = Template|Win32 + EndGlobalSection + GlobalSection(ProjectConfigurationPlatforms) = postSolution + {123462F3-4EA1-4F63-B1BC-0A2B52DAB9DB}.Debug|Win32.ActiveCfg = Debug|Win32 + {123462F3-4EA1-4F63-B1BC-0A2B52DAB9DB}.Debug|Win32.Build.0 = Debug|Win32 + {123462F3-4EA1-4F63-B1BC-0A2B52DAB9DB}.Release|Win32.ActiveCfg = Release|Win32 + {123462F3-4EA1-4F63-B1BC-0A2B52DAB9DB}.Release|Win32.Build.0 = Release|Win32 + {123462F3-4EA1-4F63-B1BC-0A2B52DAB9DB}.Template|Win32.ActiveCfg = Release|Win32 + {123462F3-4EA1-4F63-B1BC-0A2B52DAB9DB}.Template|Win32.Build.0 = Release|Win32 + {751B5C2A-5743-443F-8CA6-0A9287C39758}.Debug|Win32.ActiveCfg = Debug|Win32 + {751B5C2A-5743-443F-8CA6-0A9287C39758}.Debug|Win32.Build.0 = Debug|Win32 + {751B5C2A-5743-443F-8CA6-0A9287C39758}.Release|Win32.ActiveCfg = Release|Win32 + {751B5C2A-5743-443F-8CA6-0A9287C39758}.Release|Win32.Build.0 = Release|Win32 + {751B5C2A-5743-443F-8CA6-0A9287C39758}.Template|Win32.ActiveCfg = Template|Win32 + {751B5C2A-5743-443F-8CA6-0A9287C39758}.Template|Win32.Build.0 = Template|Win32 + EndGlobalSection + GlobalSection(SolutionProperties) = preSolution + HideSolutionNode = FALSE + EndGlobalSection +EndGlobal diff --git a/master/libwlocate.vcproj b/master/libwlocate.vcproj index 5bf63ed..70afa1c 100755 --- a/master/libwlocate.vcproj +++ b/master/libwlocate.vcproj @@ -1,301 +1,301 @@ -<?xml version="1.0" encoding="Windows-1252"?> -<VisualStudioProject - ProjectType="Visual C++" - Version="8,00" - Name="libwlocate" - ProjectGUID="{409710FC-8708-4C87-B387-69F6A1E33DF7}" - > - <Platforms> - <Platform - Name="Win32" - /> - </Platforms> - <ToolFiles> - </ToolFiles> - <Configurations> - <Configuration - Name="Debug|Win32" - OutputDirectory=".\Debug" - IntermediateDirectory=".\Debug" - ConfigurationType="2" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="false" - CharacterSet="2" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - PreprocessorDefinitions="_DEBUG" - MkTypLibCompatible="true" - SuppressStartupBanner="true" - TargetEnvironment="1" - TypeLibraryName=".\Debug/libwlocate.tlb" - HeaderFileName="" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="0" - PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS,ENV_WINDOWS" - MinimalRebuild="true" - BasicRuntimeChecks="3" - RuntimeLibrary="3" - StructMemberAlignment="1" - PrecompiledHeaderFile=".\Debug/libwlocate.pch" - AssemblerListingLocation=".\Debug/" - ObjectFile=".\Debug/" - ProgramDataBaseFileName=".\Debug/" - BrowseInformation="1" - WarningLevel="3" - SuppressStartupBanner="true" - DebugInformationFormat="4" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="_DEBUG" - Culture="1031" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - AdditionalDependencies="odbc32.lib odbccp32.lib wsock32.lib" - OutputFile=".\Debug/libwlocate.dll" - LinkIncremental="2" - SuppressStartupBanner="true" - GenerateDebugInformation="true" - ProgramDatabaseFile=".\Debug/libwlocate.pdb" - ImportLibrary=".\Debug/libwlocate.lib" - TargetMachine="1" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - SuppressStartupBanner="true" - OutputFile=".\Debug/libwlocate.bsc" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCWebDeploymentTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Release|Win32" - OutputDirectory=".\Release" - IntermediateDirectory=".\Release" - ConfigurationType="2" - InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops" - UseOfMFC="0" - ATLMinimizesCRunTimeLibraryUsage="false" - CharacterSet="2" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCWebServiceProxyGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - PreprocessorDefinitions="NDEBUG" - MkTypLibCompatible="true" - SuppressStartupBanner="true" - TargetEnvironment="1" - TypeLibraryName=".\Release/libwlocate.tlb" - HeaderFileName="" - /> - <Tool - Name="VCCLCompilerTool" - Optimization="2" - InlineFunctionExpansion="1" - PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS,ENV_WINDOWS" - StringPooling="true" - RuntimeLibrary="0" - EnableFunctionLevelLinking="true" - PrecompiledHeaderFile=".\Release/libwlocate.pch" - AssemblerListingLocation=".\Release/" - ObjectFile=".\Release/" - ProgramDataBaseFileName=".\Release/" - WarningLevel="3" - SuppressStartupBanner="true" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - PreprocessorDefinitions="NDEBUG" - Culture="1031" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - AdditionalDependencies="odbc32.lib odbccp32.lib wsock32.lib" - OutputFile=".\Release/libwlocate.dll" - LinkIncremental="1" - SuppressStartupBanner="true" - ProgramDatabaseFile=".\Release/libwlocate.pdb" - ImportLibrary=".\Release/libwlocate.lib" - TargetMachine="1" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCManifestTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - SuppressStartupBanner="true" - OutputFile=".\Release/libwlocate.bsc" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCAppVerifierTool" - /> - <Tool - Name="VCWebDeploymentTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - </Configurations> - <References> - </References> - <Files> - <Filter - Name="Source Files" - Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" - > - <File - RelativePath="connect.c" - > - <FileConfiguration - Name="Debug|Win32" - > - <Tool - Name="VCCLCompilerTool" - PreprocessorDefinitions="" - /> - </FileConfiguration> - <FileConfiguration - Name="Release|Win32" - > - <Tool - Name="VCCLCompilerTool" - PreprocessorDefinitions="" - /> - </FileConfiguration> - </File> - <File - RelativePath="libwlocate.c" - > - <FileConfiguration - Name="Debug|Win32" - > - <Tool - Name="VCCLCompilerTool" - PreprocessorDefinitions="" - /> - </FileConfiguration> - <FileConfiguration - Name="Release|Win32" - > - <Tool - Name="VCCLCompilerTool" - PreprocessorDefinitions="" - /> - </FileConfiguration> - </File> - <File - RelativePath="wlan.c" - > - <FileConfiguration - Name="Debug|Win32" - > - <Tool - Name="VCCLCompilerTool" - PreprocessorDefinitions="" - /> - </FileConfiguration> - <FileConfiguration - Name="Release|Win32" - > - <Tool - Name="VCCLCompilerTool" - PreprocessorDefinitions="" - /> - </FileConfiguration> - </File> - </Filter> - <Filter - Name="Header Files" - Filter="h;hpp;hxx;hm;inl" - > - <File - RelativePath=".\libwlocate.h" - > - </File> - <File - RelativePath="wlan.h" - > - </File> - <File - RelativePath=".\wlanapi_cust.h" - > - </File> - </Filter> - <Filter - Name="Resource Files" - Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" - > - </Filter> - </Files> - <Globals> - </Globals> -</VisualStudioProject> +<?xml version="1.0" encoding="Windows-1252"?> +<VisualStudioProject + ProjectType="Visual C++" + Version="8,00" + Name="libwlocate" + ProjectGUID="{409710FC-8708-4C87-B387-69F6A1E33DF7}" + > + <Platforms> + <Platform + Name="Win32" + /> + </Platforms> + <ToolFiles> + </ToolFiles> + <Configurations> + <Configuration + Name="Debug|Win32" + OutputDirectory=".\Debug" + IntermediateDirectory=".\Debug" + ConfigurationType="2" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="false" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="_DEBUG" + MkTypLibCompatible="true" + SuppressStartupBanner="true" + TargetEnvironment="1" + TypeLibraryName=".\Debug/libwlocate.tlb" + HeaderFileName="" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="0" + PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS,ENV_WINDOWS" + MinimalRebuild="true" + BasicRuntimeChecks="3" + RuntimeLibrary="3" + StructMemberAlignment="1" + PrecompiledHeaderFile=".\Debug/libwlocate.pch" + AssemblerListingLocation=".\Debug/" + ObjectFile=".\Debug/" + ProgramDataBaseFileName=".\Debug/" + BrowseInformation="1" + WarningLevel="3" + SuppressStartupBanner="true" + DebugInformationFormat="4" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="_DEBUG" + Culture="1031" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="odbc32.lib odbccp32.lib wsock32.lib" + OutputFile=".\Debug/libwlocate.dll" + LinkIncremental="2" + SuppressStartupBanner="true" + GenerateDebugInformation="true" + ProgramDatabaseFile=".\Debug/libwlocate.pdb" + ImportLibrary=".\Debug/libwlocate.lib" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + SuppressStartupBanner="true" + OutputFile=".\Debug/libwlocate.bsc" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + <Configuration + Name="Release|Win32" + OutputDirectory=".\Release" + IntermediateDirectory=".\Release" + ConfigurationType="2" + InheritedPropertySheets="$(VCInstallDir)VCProjectDefaults\UpgradeFromVC60.vsprops" + UseOfMFC="0" + ATLMinimizesCRunTimeLibraryUsage="false" + CharacterSet="2" + > + <Tool + Name="VCPreBuildEventTool" + /> + <Tool + Name="VCCustomBuildTool" + /> + <Tool + Name="VCXMLDataGeneratorTool" + /> + <Tool + Name="VCWebServiceProxyGeneratorTool" + /> + <Tool + Name="VCMIDLTool" + PreprocessorDefinitions="NDEBUG" + MkTypLibCompatible="true" + SuppressStartupBanner="true" + TargetEnvironment="1" + TypeLibraryName=".\Release/libwlocate.tlb" + HeaderFileName="" + /> + <Tool + Name="VCCLCompilerTool" + Optimization="2" + InlineFunctionExpansion="1" + PreprocessorDefinitions="_CRT_SECURE_NO_WARNINGS,ENV_WINDOWS" + StringPooling="true" + RuntimeLibrary="0" + EnableFunctionLevelLinking="true" + PrecompiledHeaderFile=".\Release/libwlocate.pch" + AssemblerListingLocation=".\Release/" + ObjectFile=".\Release/" + ProgramDataBaseFileName=".\Release/" + WarningLevel="3" + SuppressStartupBanner="true" + /> + <Tool + Name="VCManagedResourceCompilerTool" + /> + <Tool + Name="VCResourceCompilerTool" + PreprocessorDefinitions="NDEBUG" + Culture="1031" + /> + <Tool + Name="VCPreLinkEventTool" + /> + <Tool + Name="VCLinkerTool" + AdditionalDependencies="odbc32.lib odbccp32.lib wsock32.lib" + OutputFile=".\Release/libwlocate.dll" + LinkIncremental="1" + SuppressStartupBanner="true" + ProgramDatabaseFile=".\Release/libwlocate.pdb" + ImportLibrary=".\Release/libwlocate.lib" + TargetMachine="1" + /> + <Tool + Name="VCALinkTool" + /> + <Tool + Name="VCManifestTool" + /> + <Tool + Name="VCXDCMakeTool" + /> + <Tool + Name="VCBscMakeTool" + SuppressStartupBanner="true" + OutputFile=".\Release/libwlocate.bsc" + /> + <Tool + Name="VCFxCopTool" + /> + <Tool + Name="VCAppVerifierTool" + /> + <Tool + Name="VCWebDeploymentTool" + /> + <Tool + Name="VCPostBuildEventTool" + /> + </Configuration> + </Configurations> + <References> + </References> + <Files> + <Filter + Name="Source Files" + Filter="cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" + > + <File + RelativePath="connect.c" + > + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="VCCLCompilerTool" + PreprocessorDefinitions="" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + > + <Tool + Name="VCCLCompilerTool" + PreprocessorDefinitions="" + /> + </FileConfiguration> + </File> + <File + RelativePath="libwlocate.c" + > + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="VCCLCompilerTool" + PreprocessorDefinitions="" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + > + <Tool + Name="VCCLCompilerTool" + PreprocessorDefinitions="" + /> + </FileConfiguration> + </File> + <File + RelativePath="wlan.c" + > + <FileConfiguration + Name="Debug|Win32" + > + <Tool + Name="VCCLCompilerTool" + PreprocessorDefinitions="" + /> + </FileConfiguration> + <FileConfiguration + Name="Release|Win32" + > + <Tool + Name="VCCLCompilerTool" + PreprocessorDefinitions="" + /> + </FileConfiguration> + </File> + </Filter> + <Filter + Name="Header Files" + Filter="h;hpp;hxx;hm;inl" + > + <File + RelativePath=".\libwlocate.h" + > + </File> + <File + RelativePath="wlan.h" + > + </File> + <File + RelativePath=".\wlanapi_cust.h" + > + </File> + </Filter> + <Filter + Name="Resource Files" + Filter="ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" + > + </Filter> + </Files> + <Globals> + </Globals> +</VisualStudioProject> diff --git a/master/locdemo/LocDemoApp.cpp b/master/locdemo/LocDemoApp.cpp index 947fdac..10e2211 100755 --- a/master/locdemo/LocDemoApp.cpp +++ b/master/locdemo/LocDemoApp.cpp @@ -1,46 +1,46 @@ -/** - * LocDemo - a demo GUI application that uses libwlocate to display the - * current geographic position - * Copyright (C) 2010 Oxygenic/VWP virtual_worlds(at)gmx.de - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -#include "LocDemoApp.h" -#include "LocDemoWin.h" - -#include <wx/socket.h> - - - -IMPLEMENT_APP(LocDemoApp) - - - -bool LocDemoApp::OnInit() -{ - LocDemoWin *myWin; - - wxLog::EnableLogging(false); - wxInitAllImageHandlers(); - wxSocketBase::Initialize(); - - myWin = new LocDemoWin(wxT("OpenWLANMap Location Demo")); - if (!wxApp::OnInit()) return false; - myWin->Show(true); - return true; -} - - - +/** + * LocDemo - a demo GUI application that uses libwlocate to display the + * current geographic position + * Copyright (C) 2010 Oxygenic/VWP virtual_worlds(at)gmx.de + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +#include "LocDemoApp.h" +#include "LocDemoWin.h" + +#include <wx/socket.h> + + + +IMPLEMENT_APP(LocDemoApp) + + + +bool LocDemoApp::OnInit() +{ + LocDemoWin *myWin; + + wxLog::EnableLogging(false); + wxInitAllImageHandlers(); + wxSocketBase::Initialize(); + + myWin = new LocDemoWin(wxT("OpenWLANMap Location Demo")); + if (!wxApp::OnInit()) return false; + myWin->Show(true); + return true; +} + + + diff --git a/master/locdemo/LocDemoApp.h b/master/locdemo/LocDemoApp.h index 1a17ffa..9c3c635 100755 --- a/master/locdemo/LocDemoApp.h +++ b/master/locdemo/LocDemoApp.h @@ -1,30 +1,30 @@ -/** - * LocDemo - a demo GUI application that uses libwlocate to display the - * current geographic position - * Copyright (C) 2010 Oxygenic/VWP virtual_worlds(at)gmx.de - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -#include <wx/wx.h> - -class LocDemoApp : public wxApp -{ -public: - virtual bool OnInit(); - -private: - wxString m_mac; -}; - +/** + * LocDemo - a demo GUI application that uses libwlocate to display the + * current geographic position + * Copyright (C) 2010 Oxygenic/VWP virtual_worlds(at)gmx.de + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +#include <wx/wx.h> + +class LocDemoApp : public wxApp +{ +public: + virtual bool OnInit(); + +private: + wxString m_mac; +}; + diff --git a/master/locdemo/LocDemoWin.cpp b/master/locdemo/LocDemoWin.cpp index 2403d72..76fa8ad 100755 --- a/master/locdemo/LocDemoWin.cpp +++ b/master/locdemo/LocDemoWin.cpp @@ -1,526 +1,526 @@ -/** - * LocDemo - a demo GUI application that uses libwlocate to display the - * current geographic position - * Copyright (C) 2010-2014 Oxygenic/VWP virtual_worlds(at)gmx.de - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -#include <list> - -#include "LocDemoWin.h" - -#include <wx/sstream.h> -#include <wx/protocol/http.h> -#include <wx/file.h> -#include <wx/sizer.h> -#include <wx/stdpaths.h> -#include <wx/filename.h> -#include <wx/timer.h> - -#include "libwlocate.h" - -using namespace std; - -#define X_OFFSET 162 - -extern "C" -{ - extern int get_position(struct wloc_req *request,double *lat,double *lon,char *quality,short *ccode); -} - -IMPLEMENT_CLASS(LocDemoWin, wxFrame) - -BEGIN_EVENT_TABLE(LocDemoWin, wxFrame) - EVT_BUTTON(wxID_ANY,LocDemoWin::OnButton) - EVT_PAINT(LocDemoWin::OnPaint) - EVT_TIMER(1,LocDemoWin::OnTimer) -END_EVENT_TABLE() - - -/** -* Main constructor, here the window and the ui-elements on the left are created and added to some sizers -*/ -LocDemoWin::LocDemoWin(const wxString& title) - :wxFrame(NULL, wxID_ANY, title, wxPoint(20,0), wxSize(930,768),wxMINIMIZE_BOX|wxMAXIMIZE_BOX|wxSYSTEM_MENU|wxCAPTION|wxCLOSE_BOX|wxCLIP_CHILDREN) -{ - wxInt32 x,y; - - for (x=-1; x<=1; x++) - for (y=-1; y<=1; y++) locTile[x+1][y+1]=NULL; - - m_zoom=17; - m_traceMode=false; - - SetBackgroundColour(*wxWHITE); - wxFlexGridSizer *fSizer=new wxFlexGridSizer(1,2,2,2); - this->SetSizer(fSizer); - fSizer->AddGrowableCol(0,1); - fSizer->AddGrowableCol(1,10); - wxPanel *rootPanel=new wxPanel(this);//,WXID_ANY,wxDefaultPos,wxSize(X_OFFSET,750)); - fSizer->Add(rootPanel); - - wxGridSizer *gSizer=new wxGridSizer(12,1,2,2); - rootPanel->SetBackgroundColour(*wxWHITE); - rootPanel->SetSizer(gSizer); - - wxStaticText *text=new wxStaticText(rootPanel,wxID_ANY,_T("")); - gSizer->Add(text,0,wxALIGN_LEFT); - updateButton=new wxButton(rootPanel,wxID_ANY,_T("Update Position")); - gSizer->Add(updateButton,1,wxEXPAND); - - text=new wxStaticText(rootPanel,wxID_ANY,_T("Latitude:")); - gSizer->Add(text,0,wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); - m_latField=new wxTextCtrl(rootPanel,wxID_ANY,wxEmptyString,wxDefaultPosition,wxDefaultSize,wxTE_READONLY); - gSizer->Add(m_latField,1,wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); - - text=new wxStaticText(rootPanel,wxID_ANY,_T("Longitude:")); - gSizer->Add(text,0,wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); - m_lonField=new wxTextCtrl(rootPanel,wxID_ANY,wxEmptyString,wxDefaultPosition,wxDefaultSize,wxTE_READONLY); - gSizer->Add(m_lonField,1,wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); - - text=new wxStaticText(rootPanel,wxID_ANY,_T("Quality:")); - gSizer->Add(text,0,wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); - m_qualityField=new wxTextCtrl(rootPanel,wxID_ANY,wxEmptyString,wxDefaultPosition,wxDefaultSize,wxTE_READONLY); - gSizer->Add(m_qualityField,1,wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); - - text=new wxStaticText(rootPanel,wxID_ANY,_T("Country:")); - gSizer->Add(text,0,wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); - m_countryField=new wxTextCtrl(rootPanel,wxID_ANY,wxEmptyString,wxDefaultPosition,wxDefaultSize,wxTE_READONLY); - gSizer->Add(m_countryField,1,wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); - - m_followPathCB=new wxCheckBox(rootPanel,wxID_ANY,_T("Update cyclically")); - gSizer->Add(m_followPathCB,1,wxEXPAND); - - zoomInButton=new wxButton(rootPanel,wxID_ANY,_T("Zoom In")); - gSizer->Add(zoomInButton,1,wxEXPAND); - zoomOutButton=new wxButton(rootPanel,wxID_ANY,_T("Zoom Out")); - gSizer->Add(zoomOutButton,1,wxEXPAND); - - traceButton=new wxButton(rootPanel,wxID_ANY,_T("Load Tracefile")); - gSizer->Add(traceButton,1,wxEXPAND); - - infoButton=new wxButton(rootPanel,wxID_ANY,_T("About")); - gSizer->Add(infoButton,1,wxEXPAND); - - SetDoubleBuffered(true); - - getLocation(false,NULL); - - m_timer = new wxTimer(this,1); - m_timer->Start(8000); -} - - - -LocDemoWin::~LocDemoWin() -{ - wxInt32 x,y; - - for (x=-1; x<=1; x++) - for (y=-1; y<=1; y++) if (locTile[x+1][y+1]) delete locTile[x+1][y+1]; -} - - -/** - * Timer callback function, it is called cyclically and in case the m_followPathCB check box is - * checked it updates the current position by calling getLocation() - */ -void LocDemoWin::OnTimer(wxTimerEvent& WXUNUSED(event)) -{ - if (m_followPathCB->GetValue()) - { - m_timer->Stop(); - getLocation(true,NULL); - Refresh(); - m_timer->Start(); - } -} - - - -/** - * Gets the horizontal part of a tile number out of a given position - * @param[in] lon the longitude to get the tile number for - * @param[in] z the zoom level to get the tile number for - * @return the tiles x number - */ -static int long2tilex(double lon, int z) -{ - return (int)(floor((lon + 180.0) / 360.0 * pow(2.0, z))); -} - - - -/** - * Gets the vertical part of a tile number out of a given position - * @param[in] lat the latitude to get the tile number for - * @param[in] z the zoom level to get the tile number for - * @return the tiles y number - */ -static int lat2tiley(double lat, int z) -{ - return (int)(floor((1.0 - log( tan(lat * M_PI/180.0) + 1.0 / cos(lat * M_PI/180.0)) / M_PI) / 2.0 * pow(2.0, z))); -} - - - -/** - * Gets the longitude of the side edge of a tile out of a given horizontal - * tile number - * @param[in] x the horizontal tile number - * @param[in] z the zoom level to get the tile number for - * @return the longitude of the left position of the tile - */ -static double tilex2long(int x, int z) -{ - return x / pow(2.0, z) * 360.0 - 180; -} - - - -/** - * Gets the latitude of the upper side of a tile out of a given vertical - * tile number - * @param[in] y the vertical tile number - * @param[in] z the zoom level to get the tile number for - * @return the latitude of the upper position of the tile - */ -static double tiley2lat(int y, int z) -{ - double n = M_PI - 2.0 * M_PI * y / pow(2.0, z); - return 180.0 / M_PI * atan(0.5 * (exp(n) - exp(-n))); -} - - - -/** - * The paint callback, here the map tiles, the path (if it has a size >=2) - * and the current position including its deviation are drawn - */ -void LocDemoWin::OnPaint(wxPaintEvent& WXUNUSED(event)) -{ - wxInt32 x,y; - double tileLat1,tileLon1,tileLat2,tileLon2; - wxPaintDC dc(this); - wxPen borderPen(*wxRED,3); - wxPen pathPen(*wxBLUE,2); - list<double>::iterator itLat,itLon; - - for (x=-1; x<=1; x++) - for (y=-1; y<=1; y++) - { - if (locTile[x+1][y+1]) - { - dc.DrawBitmap(*locTile[x+1][y+1],((x+1)*256)+X_OFFSET,(y+1)*256,false); - } - } - - tileLat1=tiley2lat(m_tileY,m_zoom); - tileLat2=tiley2lat(m_tileY+1,m_zoom); - tileLon1=tilex2long(m_tileX,m_zoom); - tileLon2=tilex2long(m_tileX+1,m_zoom); - - dc.SetBrush(*wxTRANSPARENT_BRUSH); - if (m_latList.size()>1) - { - double currY,currX,prevY,prevX; - - dc.SetPen(pathPen); - itLat=m_latList.begin(); itLat++; - itLon=m_lonList.begin(); itLon++; - prevY=256+ (256.0*(*itLat-tileLat1)/(tileLat2-tileLat1)); - prevX=256+X_OFFSET+(256.0*(*itLon-tileLon1)/(tileLon2-tileLon1)); - for ( ; itLat!= m_latList.end(); itLat++ ) - { - currY=256+ (256.0*(*itLat-tileLat1)/(tileLat2-tileLat1)); - currX=256+X_OFFSET+(256.0*(*itLon-tileLon1)/(tileLon2-tileLon1)); - dc.DrawLine(prevX,prevY,currX,currY); - prevY=currY; - prevX=currX; - itLon++; - } - } - - y=256+ (256.0*(m_lat-tileLat1)/(tileLat2-tileLat1)); - x=256+X_OFFSET+(256.0*(m_lon-tileLon1)/(tileLon2-tileLon1)); - - if ((x!=0) && (y!=0)) - { - wxFloat64 zoomFactor; - - dc.SetPen(borderPen); - if (m_quality>0) - { - zoomFactor=pow(2.0,(17.0-m_zoom)); - dc.DrawCircle(x,y,(120-m_quality)/zoomFactor); - } - else - { - zoomFactor=pow(2.0,(10.0-m_zoom)); - dc.DrawCircle(x,y,130/zoomFactor); - } - } -} - - - -/** - * This method updates the internal locTile array that holds bitmaps of the tiles that have to be - * displayed currently. To get the tile images it first tries to load a local PNG image. In case - * that fails the TAH server is connected to download and save a tile image in PNG format. Then it - * tries again to load the local PNG image - now it should be successful because it was downloaded - * just one step before. - * @param[in] lat the latitude of the current position which has to be displayed in center tile - * @param[in] lon the longitude of the current position which has to be displayed in center tile - */ -void LocDemoWin::updateTiles(wxFloat64 lat,wxFloat64 lon) -{ - wxInt32 x,y; - wxHTTP *get; - wxString path; - wxInputStream *httpStream; - wxImage *tmpImage; - - m_tileX=long2tilex(lon,m_zoom); - m_tileY=lat2tiley(lat,m_zoom); - - for (x=-1; x<=1; x++) - for (y=-1; y<=1; y++) - { - if (locTile[x+1][y+1]) delete locTile[x+1][y+1]; - locTile[x+1][y+1]=NULL; - - if (!wxFile::Exists(wxStandardPaths::Get().GetUserDataDir()+wxFileName::GetPathSeparator()+wxString::Format(_T("tile_%d_%d_%d.png"),m_zoom,m_tileX+x,m_tileY+y))) - { - get=new wxHTTP(); - get->SetTimeout(10); // 10 seconds of timeout instead of 10 minutes ... - get->SetHeader(_T("User-Agent"),_T("LocDemo libwlocate demo application")); - while (!get->Connect(_T("a.tile.openstreetmap.org"))) - wxSleep(5); - - path=wxString::Format(_T("/%d/%d/%d.png"),m_zoom,m_tileX+x,m_tileY+y); - httpStream = get->GetInputStream(path); - if (get->GetError() == wxPROTO_NOERR) - { - wxFile *FHandle; - - wxFileName::Mkdir(wxStandardPaths::Get().GetUserDataDir()); - path=wxStandardPaths::Get().GetUserDataDir()+wxFileName::GetPathSeparator()+wxString::Format(_T("tile_%d_%d_%d.png"),m_zoom,m_tileX+x,m_tileY+y); - FHandle=new wxFile(path,wxFile::write); - if ((FHandle) && (FHandle->IsOpened())) - { - void *mem; - - mem=malloc(httpStream->GetSize()); - if (mem) - { - httpStream->Read(mem,httpStream->GetSize()); - FHandle->Write(mem,httpStream->GetSize()); - delete FHandle; - free(mem); - } - } - wxDELETE(httpStream); - } - get->Close(); - delete get; - } - path=wxStandardPaths::Get().GetUserDataDir()+wxFileName::GetPathSeparator()+wxString::Format(_T("tile_%d_%d_%d.png"),m_zoom,m_tileX+x,m_tileY+y); - tmpImage=new wxImage(path,wxBITMAP_TYPE_PNG); - if ((tmpImage) && (tmpImage->Ok())) - { - locTile[x+1][y+1]=new wxBitmap(*tmpImage); - delete tmpImage; - } - } -} - - - -/** - * Here the current geolocation is evaluated by calling the related function of libwlocate. - * Afterwards the tiles are updated and drawn. - * @param[in] silent if this value is set to true no splash screen is displayed during - * position and tile update - */ -void LocDemoWin::getLocation(bool silent,struct wloc_req *requestData) -{ - wxInt32 ret; - wxFrame *splash=NULL; - - if (!silent) - { - splash = new wxFrame(NULL,wxID_ANY,_T("Getting Position Data and Map"),wxDefaultPosition,wxSize(500,80),wxSTAY_ON_TOP|wxFRAME_NO_TASKBAR|wxCAPTION); - new wxStaticText(splash,wxID_ANY,_T("Operation in progress, please wait..."),wxPoint(20,30)); - splash->Center(); -#ifndef _DEBUG - splash->Show(); -#endif - } - - m_lat=0; - m_lon=0; - m_quality=0; - if (!requestData) ret=wloc_get_location(&m_lat,&m_lon,&m_quality,&m_ccode); - else - { - ret=get_position(requestData,&m_lat,&m_lon,&m_quality,&m_ccode); - if (ret!=WLOC_OK) printf("Loading trace location failed..."); - } - if (ret==WLOC_OK) - { - char country[3]={0,0,0}; - wxMBConvUTF8 conv; - wchar_t wc[3]; - - m_latField->SetValue(_T("")); *m_latField<<m_lat; - m_lonField->SetValue(_T("")); *m_lonField<<m_lon; - if (m_quality<0) m_quality=1; - if (m_quality>0) - { - m_latList.push_back(m_lat); - m_lonList.push_back(m_lon); - } - else if (m_traceMode) return; // do not use IP-Data only in case of trace mode - - m_qualityField->SetValue(_T("")); *m_qualityField<<m_quality; - if (!m_followPathCB->GetValue()) - { - if (m_quality==0) m_zoom=10; - else - { - if (!m_traceMode) m_zoom=17; - } - } - if (wloc_get_country_from_code(m_ccode,country)==WLOC_OK) - { - conv.MB2WC(wc,country,3); - m_countryField->SetValue(_T("")); *m_countryField<<wc; - } - else m_countryField->SetValue(_T("?")); - - updateTiles(m_lat,m_lon); - if (!silent) splash->Close(); - delete splash; - } - else if (!requestData) - { - m_latField->SetValue(_T("---")); - m_lonField->SetValue(_T("---")); - m_qualityField->SetValue(_T("---")); - m_countryField->SetValue(_T("--")); - splash->Close(); - delete splash; - if (ret==WLOC_CONNECTION_ERROR) - wxMessageBox(_T("Could not connect to server and retrieve data!"),_T("Error"),wxOK|wxICON_ERROR); - else if (ret==WLOC_LOCATION_ERROR) - wxMessageBox(_T("Could not retrieve location, no data available for your position!"),_T("Error"),wxOK|wxICON_ERROR); - else - wxMessageBox(_T("Could not retrieve location, an unidentified error happened :-("),_T("Error"),wxOK|wxICON_ERROR); - } -} - - - -/** - * The button event handler, here the functionality of the zoom and about buttons are managed - */ -void LocDemoWin::OnButton(wxCommandEvent &event) -{ - if (event.GetId()==updateButton->GetId()) - { - getLocation(false,NULL); - Refresh(); - } - else if (event.GetId()==zoomOutButton->GetId()) - { - if (m_zoom>2) m_zoom--; - updateTiles(m_lat,m_lon); - Refresh(); - } - else if (event.GetId()==zoomInButton->GetId()) - { - if (m_zoom<17) m_zoom++; - updateTiles(m_lat,m_lon); - Refresh(); - } - else if (event.GetId()==traceButton->GetId()) - { - FILE *FHandle; - wxInt32 i,ret=1; - struct wloc_req requestData,prevData; - wxPaintEvent pEvent; - - wxFileDialog* openFileDialog=new wxFileDialog( this,_T("Load trace file"),wxEmptyString,wxEmptyString,_T("Trace-File |*.trace|All files|*.*"),wxFD_OPEN, wxDefaultPosition); - if ( openFileDialog->ShowModal() == wxID_OK ) - { - wxString path; - wxMBConvLibc conv; - char cPath[300+1]; - - path=openFileDialog->GetDirectory()+wxFileName::GetPathSeparator()+openFileDialog->GetFilename(); - conv.WC2MB(cPath,path,300); - memset(&requestData,0,sizeof(struct wloc_req)); - memset(&prevData,0,sizeof(struct wloc_req)); - m_followPathCB->SetValue(false); - m_latList.clear(); - m_lonList.clear(); - Refresh(); - FHandle=fopen(cPath,"rb"); - if (FHandle) - { - m_traceMode=true; - memset(&requestData,0,sizeof(struct wloc_req)); - while (ret>0) - { - for (i=0; i<WLOC_MAX_NETWORKS; i++) - { - char signal_unused; - - fread(&requestData.bssids[i],1,sizeof(requestData.bssids[i]),FHandle); - ret=fread(&signal_unused,1,1,FHandle); - } - if (notEqual(&requestData,&prevData)) getLocation(true,&requestData); - prevData=requestData; - OnPaint(pEvent); - } - fclose(FHandle); - } - else wxMessageBox(_T("Could not find trace file!"),_T("Error"),wxOK|wxICON_ERROR); - m_traceMode=false; - } - } - else if (event.GetId()==infoButton->GetId()) wxMessageBox(_T("LocDemo Version 2.0 is (c) 2010-2014 by Oxy/VWP\nIt demonstrates the usage of libwlocate and is available under the terms of the GNU Public License\nFor more details please refer to http://www.openwlanmap.org%22),_T(%22Information%22),wxOK%7CwxICON_INFORMATI...); -} - - - -bool LocDemoWin::notEqual(struct wloc_req *data1,struct wloc_req *data2) -{ - wxUint32 i,j; - - for (i=0; i<WLOC_MAX_NETWORKS; i++) - { -// if (data1->signal[i]!=data2->signal[i]) return true; - for (j=0; j<6; j++) - { - if (data1->bssids[i][j]!=data2->bssids[i][j]) return true; - } - } - return false; -} - - - +/** + * LocDemo - a demo GUI application that uses libwlocate to display the + * current geographic position + * Copyright (C) 2010-2014 Oxygenic/VWP virtual_worlds(at)gmx.de + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +#include <list> + +#include "LocDemoWin.h" + +#include <wx/sstream.h> +#include <wx/protocol/http.h> +#include <wx/file.h> +#include <wx/sizer.h> +#include <wx/stdpaths.h> +#include <wx/filename.h> +#include <wx/timer.h> + +#include "libwlocate.h" + +using namespace std; + +#define X_OFFSET 162 + +extern "C" +{ + extern int get_position(struct wloc_req *request,double *lat,double *lon,char *quality,short *ccode); +} + +IMPLEMENT_CLASS(LocDemoWin, wxFrame) + +BEGIN_EVENT_TABLE(LocDemoWin, wxFrame) + EVT_BUTTON(wxID_ANY,LocDemoWin::OnButton) + EVT_PAINT(LocDemoWin::OnPaint) + EVT_TIMER(1,LocDemoWin::OnTimer) +END_EVENT_TABLE() + + +/** +* Main constructor, here the window and the ui-elements on the left are created and added to some sizers +*/ +LocDemoWin::LocDemoWin(const wxString& title) + :wxFrame(NULL, wxID_ANY, title, wxPoint(20,0), wxSize(930,768),wxMINIMIZE_BOX|wxMAXIMIZE_BOX|wxSYSTEM_MENU|wxCAPTION|wxCLOSE_BOX|wxCLIP_CHILDREN) +{ + wxInt32 x,y; + + for (x=-1; x<=1; x++) + for (y=-1; y<=1; y++) locTile[x+1][y+1]=NULL; + + m_zoom=17; + m_traceMode=false; + + SetBackgroundColour(*wxWHITE); + wxFlexGridSizer *fSizer=new wxFlexGridSizer(1,2,2,2); + this->SetSizer(fSizer); + fSizer->AddGrowableCol(0,1); + fSizer->AddGrowableCol(1,10); + wxPanel *rootPanel=new wxPanel(this);//,WXID_ANY,wxDefaultPos,wxSize(X_OFFSET,750)); + fSizer->Add(rootPanel); + + wxGridSizer *gSizer=new wxGridSizer(12,1,2,2); + rootPanel->SetBackgroundColour(*wxWHITE); + rootPanel->SetSizer(gSizer); + + wxStaticText *text=new wxStaticText(rootPanel,wxID_ANY,_T("")); + gSizer->Add(text,0,wxALIGN_LEFT); + updateButton=new wxButton(rootPanel,wxID_ANY,_T("Update Position")); + gSizer->Add(updateButton,1,wxEXPAND); + + text=new wxStaticText(rootPanel,wxID_ANY,_T("Latitude:")); + gSizer->Add(text,0,wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); + m_latField=new wxTextCtrl(rootPanel,wxID_ANY,wxEmptyString,wxDefaultPosition,wxDefaultSize,wxTE_READONLY); + gSizer->Add(m_latField,1,wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); + + text=new wxStaticText(rootPanel,wxID_ANY,_T("Longitude:")); + gSizer->Add(text,0,wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); + m_lonField=new wxTextCtrl(rootPanel,wxID_ANY,wxEmptyString,wxDefaultPosition,wxDefaultSize,wxTE_READONLY); + gSizer->Add(m_lonField,1,wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); + + text=new wxStaticText(rootPanel,wxID_ANY,_T("Quality:")); + gSizer->Add(text,0,wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); + m_qualityField=new wxTextCtrl(rootPanel,wxID_ANY,wxEmptyString,wxDefaultPosition,wxDefaultSize,wxTE_READONLY); + gSizer->Add(m_qualityField,1,wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); + + text=new wxStaticText(rootPanel,wxID_ANY,_T("Country:")); + gSizer->Add(text,0,wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); + m_countryField=new wxTextCtrl(rootPanel,wxID_ANY,wxEmptyString,wxDefaultPosition,wxDefaultSize,wxTE_READONLY); + gSizer->Add(m_countryField,1,wxALIGN_LEFT|wxALIGN_CENTER_VERTICAL); + + m_followPathCB=new wxCheckBox(rootPanel,wxID_ANY,_T("Update cyclically")); + gSizer->Add(m_followPathCB,1,wxEXPAND); + + zoomInButton=new wxButton(rootPanel,wxID_ANY,_T("Zoom In")); + gSizer->Add(zoomInButton,1,wxEXPAND); + zoomOutButton=new wxButton(rootPanel,wxID_ANY,_T("Zoom Out")); + gSizer->Add(zoomOutButton,1,wxEXPAND); + + traceButton=new wxButton(rootPanel,wxID_ANY,_T("Load Tracefile")); + gSizer->Add(traceButton,1,wxEXPAND); + + infoButton=new wxButton(rootPanel,wxID_ANY,_T("About")); + gSizer->Add(infoButton,1,wxEXPAND); + + SetDoubleBuffered(true); + + getLocation(false,NULL); + + m_timer = new wxTimer(this,1); + m_timer->Start(8000); +} + + + +LocDemoWin::~LocDemoWin() +{ + wxInt32 x,y; + + for (x=-1; x<=1; x++) + for (y=-1; y<=1; y++) if (locTile[x+1][y+1]) delete locTile[x+1][y+1]; +} + + +/** + * Timer callback function, it is called cyclically and in case the m_followPathCB check box is + * checked it updates the current position by calling getLocation() + */ +void LocDemoWin::OnTimer(wxTimerEvent& WXUNUSED(event)) +{ + if (m_followPathCB->GetValue()) + { + m_timer->Stop(); + getLocation(true,NULL); + Refresh(); + m_timer->Start(); + } +} + + + +/** + * Gets the horizontal part of a tile number out of a given position + * @param[in] lon the longitude to get the tile number for + * @param[in] z the zoom level to get the tile number for + * @return the tiles x number + */ +static int long2tilex(double lon, int z) +{ + return (int)(floor((lon + 180.0) / 360.0 * pow(2.0, z))); +} + + + +/** + * Gets the vertical part of a tile number out of a given position + * @param[in] lat the latitude to get the tile number for + * @param[in] z the zoom level to get the tile number for + * @return the tiles y number + */ +static int lat2tiley(double lat, int z) +{ + return (int)(floor((1.0 - log( tan(lat * M_PI/180.0) + 1.0 / cos(lat * M_PI/180.0)) / M_PI) / 2.0 * pow(2.0, z))); +} + + + +/** + * Gets the longitude of the side edge of a tile out of a given horizontal + * tile number + * @param[in] x the horizontal tile number + * @param[in] z the zoom level to get the tile number for + * @return the longitude of the left position of the tile + */ +static double tilex2long(int x, int z) +{ + return x / pow(2.0, z) * 360.0 - 180; +} + + + +/** + * Gets the latitude of the upper side of a tile out of a given vertical + * tile number + * @param[in] y the vertical tile number + * @param[in] z the zoom level to get the tile number for + * @return the latitude of the upper position of the tile + */ +static double tiley2lat(int y, int z) +{ + double n = M_PI - 2.0 * M_PI * y / pow(2.0, z); + return 180.0 / M_PI * atan(0.5 * (exp(n) - exp(-n))); +} + + + +/** + * The paint callback, here the map tiles, the path (if it has a size >=2) + * and the current position including its deviation are drawn + */ +void LocDemoWin::OnPaint(wxPaintEvent& WXUNUSED(event)) +{ + wxInt32 x,y; + double tileLat1,tileLon1,tileLat2,tileLon2; + wxPaintDC dc(this); + wxPen borderPen(*wxRED,3); + wxPen pathPen(*wxBLUE,2); + list<double>::iterator itLat,itLon; + + for (x=-1; x<=1; x++) + for (y=-1; y<=1; y++) + { + if (locTile[x+1][y+1]) + { + dc.DrawBitmap(*locTile[x+1][y+1],((x+1)*256)+X_OFFSET,(y+1)*256,false); + } + } + + tileLat1=tiley2lat(m_tileY,m_zoom); + tileLat2=tiley2lat(m_tileY+1,m_zoom); + tileLon1=tilex2long(m_tileX,m_zoom); + tileLon2=tilex2long(m_tileX+1,m_zoom); + + dc.SetBrush(*wxTRANSPARENT_BRUSH); + if (m_latList.size()>1) + { + double currY,currX,prevY,prevX; + + dc.SetPen(pathPen); + itLat=m_latList.begin(); itLat++; + itLon=m_lonList.begin(); itLon++; + prevY=256+ (256.0*(*itLat-tileLat1)/(tileLat2-tileLat1)); + prevX=256+X_OFFSET+(256.0*(*itLon-tileLon1)/(tileLon2-tileLon1)); + for ( ; itLat!= m_latList.end(); itLat++ ) + { + currY=256+ (256.0*(*itLat-tileLat1)/(tileLat2-tileLat1)); + currX=256+X_OFFSET+(256.0*(*itLon-tileLon1)/(tileLon2-tileLon1)); + dc.DrawLine(prevX,prevY,currX,currY); + prevY=currY; + prevX=currX; + itLon++; + } + } + + y=256+ (256.0*(m_lat-tileLat1)/(tileLat2-tileLat1)); + x=256+X_OFFSET+(256.0*(m_lon-tileLon1)/(tileLon2-tileLon1)); + + if ((x!=0) && (y!=0)) + { + wxFloat64 zoomFactor; + + dc.SetPen(borderPen); + if (m_quality>0) + { + zoomFactor=pow(2.0,(17.0-m_zoom)); + dc.DrawCircle(x,y,(120-m_quality)/zoomFactor); + } + else + { + zoomFactor=pow(2.0,(10.0-m_zoom)); + dc.DrawCircle(x,y,130/zoomFactor); + } + } +} + + + +/** + * This method updates the internal locTile array that holds bitmaps of the tiles that have to be + * displayed currently. To get the tile images it first tries to load a local PNG image. In case + * that fails the TAH server is connected to download and save a tile image in PNG format. Then it + * tries again to load the local PNG image - now it should be successful because it was downloaded + * just one step before. + * @param[in] lat the latitude of the current position which has to be displayed in center tile + * @param[in] lon the longitude of the current position which has to be displayed in center tile + */ +void LocDemoWin::updateTiles(wxFloat64 lat,wxFloat64 lon) +{ + wxInt32 x,y; + wxHTTP *get; + wxString path; + wxInputStream *httpStream; + wxImage *tmpImage; + + m_tileX=long2tilex(lon,m_zoom); + m_tileY=lat2tiley(lat,m_zoom); + + for (x=-1; x<=1; x++) + for (y=-1; y<=1; y++) + { + if (locTile[x+1][y+1]) delete locTile[x+1][y+1]; + locTile[x+1][y+1]=NULL; + + if (!wxFile::Exists(wxStandardPaths::Get().GetUserDataDir()+wxFileName::GetPathSeparator()+wxString::Format(_T("tile_%d_%d_%d.png"),m_zoom,m_tileX+x,m_tileY+y))) + { + get=new wxHTTP(); + get->SetTimeout(10); // 10 seconds of timeout instead of 10 minutes ... + get->SetHeader(_T("User-Agent"),_T("LocDemo libwlocate demo application")); + while (!get->Connect(_T("a.tile.openstreetmap.org"))) + wxSleep(5); + + path=wxString::Format(_T("/%d/%d/%d.png"),m_zoom,m_tileX+x,m_tileY+y); + httpStream = get->GetInputStream(path); + if (get->GetError() == wxPROTO_NOERR) + { + wxFile *FHandle; + + wxFileName::Mkdir(wxStandardPaths::Get().GetUserDataDir()); + path=wxStandardPaths::Get().GetUserDataDir()+wxFileName::GetPathSeparator()+wxString::Format(_T("tile_%d_%d_%d.png"),m_zoom,m_tileX+x,m_tileY+y); + FHandle=new wxFile(path,wxFile::write); + if ((FHandle) && (FHandle->IsOpened())) + { + void *mem; + + mem=malloc(httpStream->GetSize()); + if (mem) + { + httpStream->Read(mem,httpStream->GetSize()); + FHandle->Write(mem,httpStream->GetSize()); + delete FHandle; + free(mem); + } + } + wxDELETE(httpStream); + } + get->Close(); + delete get; + } + path=wxStandardPaths::Get().GetUserDataDir()+wxFileName::GetPathSeparator()+wxString::Format(_T("tile_%d_%d_%d.png"),m_zoom,m_tileX+x,m_tileY+y); + tmpImage=new wxImage(path,wxBITMAP_TYPE_PNG); + if ((tmpImage) && (tmpImage->Ok())) + { + locTile[x+1][y+1]=new wxBitmap(*tmpImage); + delete tmpImage; + } + } +} + + + +/** + * Here the current geolocation is evaluated by calling the related function of libwlocate. + * Afterwards the tiles are updated and drawn. + * @param[in] silent if this value is set to true no splash screen is displayed during + * position and tile update + */ +void LocDemoWin::getLocation(bool silent,struct wloc_req *requestData) +{ + wxInt32 ret; + wxFrame *splash=NULL; + + if (!silent) + { + splash = new wxFrame(NULL,wxID_ANY,_T("Getting Position Data and Map"),wxDefaultPosition,wxSize(500,80),wxSTAY_ON_TOP|wxFRAME_NO_TASKBAR|wxCAPTION); + new wxStaticText(splash,wxID_ANY,_T("Operation in progress, please wait..."),wxPoint(20,30)); + splash->Center(); +#ifndef _DEBUG + splash->Show(); +#endif + } + + m_lat=0; + m_lon=0; + m_quality=0; + if (!requestData) ret=wloc_get_location(&m_lat,&m_lon,&m_quality,&m_ccode); + else + { + ret=get_position(requestData,&m_lat,&m_lon,&m_quality,&m_ccode); + if (ret!=WLOC_OK) printf("Loading trace location failed..."); + } + if (ret==WLOC_OK) + { + char country[3]={0,0,0}; + wxMBConvUTF8 conv; + wchar_t wc[3]; + + m_latField->SetValue(_T("")); *m_latField<<m_lat; + m_lonField->SetValue(_T("")); *m_lonField<<m_lon; + if (m_quality<0) m_quality=1; + if (m_quality>0) + { + m_latList.push_back(m_lat); + m_lonList.push_back(m_lon); + } + else if (m_traceMode) return; // do not use IP-Data only in case of trace mode + + m_qualityField->SetValue(_T("")); *m_qualityField<<m_quality; + if (!m_followPathCB->GetValue()) + { + if (m_quality==0) m_zoom=10; + else + { + if (!m_traceMode) m_zoom=17; + } + } + if (wloc_get_country_from_code(m_ccode,country)==WLOC_OK) + { + conv.MB2WC(wc,country,3); + m_countryField->SetValue(_T("")); *m_countryField<<wc; + } + else m_countryField->SetValue(_T("?")); + + updateTiles(m_lat,m_lon); + if (!silent) splash->Close(); + delete splash; + } + else if (!requestData) + { + m_latField->SetValue(_T("---")); + m_lonField->SetValue(_T("---")); + m_qualityField->SetValue(_T("---")); + m_countryField->SetValue(_T("--")); + splash->Close(); + delete splash; + if (ret==WLOC_CONNECTION_ERROR) + wxMessageBox(_T("Could not connect to server and retrieve data!"),_T("Error"),wxOK|wxICON_ERROR); + else if (ret==WLOC_LOCATION_ERROR) + wxMessageBox(_T("Could not retrieve location, no data available for your position!"),_T("Error"),wxOK|wxICON_ERROR); + else + wxMessageBox(_T("Could not retrieve location, an unidentified error happened :-("),_T("Error"),wxOK|wxICON_ERROR); + } +} + + + +/** + * The button event handler, here the functionality of the zoom and about buttons are managed + */ +void LocDemoWin::OnButton(wxCommandEvent &event) +{ + if (event.GetId()==updateButton->GetId()) + { + getLocation(false,NULL); + Refresh(); + } + else if (event.GetId()==zoomOutButton->GetId()) + { + if (m_zoom>2) m_zoom--; + updateTiles(m_lat,m_lon); + Refresh(); + } + else if (event.GetId()==zoomInButton->GetId()) + { + if (m_zoom<17) m_zoom++; + updateTiles(m_lat,m_lon); + Refresh(); + } + else if (event.GetId()==traceButton->GetId()) + { + FILE *FHandle; + wxInt32 i,ret=1; + struct wloc_req requestData,prevData; + wxPaintEvent pEvent; + + wxFileDialog* openFileDialog=new wxFileDialog( this,_T("Load trace file"),wxEmptyString,wxEmptyString,_T("Trace-File |*.trace|All files|*.*"),wxFD_OPEN, wxDefaultPosition); + if ( openFileDialog->ShowModal() == wxID_OK ) + { + wxString path; + wxMBConvLibc conv; + char cPath[300+1]; + + path=openFileDialog->GetDirectory()+wxFileName::GetPathSeparator()+openFileDialog->GetFilename(); + conv.WC2MB(cPath,path,300); + memset(&requestData,0,sizeof(struct wloc_req)); + memset(&prevData,0,sizeof(struct wloc_req)); + m_followPathCB->SetValue(false); + m_latList.clear(); + m_lonList.clear(); + Refresh(); + FHandle=fopen(cPath,"rb"); + if (FHandle) + { + m_traceMode=true; + memset(&requestData,0,sizeof(struct wloc_req)); + while (ret>0) + { + for (i=0; i<WLOC_MAX_NETWORKS; i++) + { + char signal_unused; + + fread(&requestData.bssids[i],1,sizeof(requestData.bssids[i]),FHandle); + ret=fread(&signal_unused,1,1,FHandle); + } + if (notEqual(&requestData,&prevData)) getLocation(true,&requestData); + prevData=requestData; + OnPaint(pEvent); + } + fclose(FHandle); + } + else wxMessageBox(_T("Could not find trace file!"),_T("Error"),wxOK|wxICON_ERROR); + m_traceMode=false; + } + } + else if (event.GetId()==infoButton->GetId()) wxMessageBox(_T("LocDemo Version 2.0 is (c) 2010-2014 by Oxy/VWP\nIt demonstrates the usage of libwlocate and is available under the terms of the GNU Public License\nFor more details please refer to http://www.openwlanmap.org%22),_T(%22Information%22),wxOK%7CwxICON_INFORMATI...); +} + + + +bool LocDemoWin::notEqual(struct wloc_req *data1,struct wloc_req *data2) +{ + wxUint32 i,j; + + for (i=0; i<WLOC_MAX_NETWORKS; i++) + { +// if (data1->signal[i]!=data2->signal[i]) return true; + for (j=0; j<6; j++) + { + if (data1->bssids[i][j]!=data2->bssids[i][j]) return true; + } + } + return false; +} + + + diff --git a/master/locdemo/LocDemoWin.h b/master/locdemo/LocDemoWin.h index ecc8c5b..3e50464 100755 --- a/master/locdemo/LocDemoWin.h +++ b/master/locdemo/LocDemoWin.h @@ -1,56 +1,56 @@ -/** - * LocDemo - a demo GUI application that uses libwlocate to display the - * current geographic position - * Copyright (C) 2010 Oxygenic/VWP virtual_worlds(at)gmx.de - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -#include <wx/wx.h> -#include <wx/spinctrl.h> - -#include <list> - -class LocDemoWin : public wxFrame -{ -public: - LocDemoWin(const wxString& title); - virtual ~LocDemoWin(); - -private: - void OnButton(wxCommandEvent &event); - void OnPaint(wxPaintEvent& event); - void OnTimer(wxTimerEvent& event); - void updateTiles(wxFloat64 lat,wxFloat64 lon); - void getLocation(bool silent,struct wloc_req *requestData); - bool notEqual(struct wloc_req *data1,struct wloc_req *prevData); - - - wxButton *updateButton,*infoButton,*zoomInButton,*zoomOutButton,*traceButton; - wxBitmap *locTile[3][3]; - wxInt32 m_tileX,m_tileY; - wxTextCtrl *m_latField,*m_lonField,*m_qualityField,*m_countryField; - wxCheckBox *m_followPathCB; - double m_lat,m_lon; - char m_quality; - short m_ccode; - wxByte m_zoom; - wxTimer *m_timer; - std::list<double> m_latList,m_lonList; - bool m_traceMode; - - DECLARE_CLASS(LocDemoWin) - DECLARE_EVENT_TABLE() -}; - +/** + * LocDemo - a demo GUI application that uses libwlocate to display the + * current geographic position + * Copyright (C) 2010 Oxygenic/VWP virtual_worlds(at)gmx.de + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +#include <wx/wx.h> +#include <wx/spinctrl.h> + +#include <list> + +class LocDemoWin : public wxFrame +{ +public: + LocDemoWin(const wxString& title); + virtual ~LocDemoWin(); + +private: + void OnButton(wxCommandEvent &event); + void OnPaint(wxPaintEvent& event); + void OnTimer(wxTimerEvent& event); + void updateTiles(wxFloat64 lat,wxFloat64 lon); + void getLocation(bool silent,struct wloc_req *requestData); + bool notEqual(struct wloc_req *data1,struct wloc_req *prevData); + + + wxButton *updateButton,*infoButton,*zoomInButton,*zoomOutButton,*traceButton; + wxBitmap *locTile[3][3]; + wxInt32 m_tileX,m_tileY; + wxTextCtrl *m_latField,*m_lonField,*m_qualityField,*m_countryField; + wxCheckBox *m_followPathCB; + double m_lat,m_lon; + char m_quality; + short m_ccode; + wxByte m_zoom; + wxTimer *m_timer; + std::list<double> m_latList,m_lonList; + bool m_traceMode; + + DECLARE_CLASS(LocDemoWin) + DECLARE_EVENT_TABLE() +}; + diff --git a/master/locdemo/Makefile b/master/locdemo/Makefile index cc469c0..a38075a 100755 --- a/master/locdemo/Makefile +++ b/master/locdemo/Makefile @@ -1,32 +1,32 @@ -PROGRAM = LocDemo - -INCLUDEDIRS = -I/usr/X11R6/include -I.. $(shell wx-config --cflags) $(shell pkg-config gtk+-2.0 --cflags) - +PROGRAM = LocDemo + +INCLUDEDIRS = -I/usr/X11R6/include -I.. $(shell wx-config --cflags) $(shell pkg-config gtk+-2.0 --cflags) + LIBDIRS = -L/usr/X11R6/lib -L/usr/lib -L..
-LIBS = $(shell wx-config --libs) -lwlocate - -DBGFLAGS = -O2 -g0 -DNDEBUG -STRIP=strip -ifeq ($(DEBUG),1) -DBGFLAGS = -O0 -g3 -DNOSPLASH -STRIP=ls -al -endif - -CXXSOURCES = LocDemoApp.cpp LocDemoWin.cpp - -CXXOBJECTS = $(CXXSOURCES:.cpp=.o) -CXXFLAGS = -Wall -Wno-unused-local-typedefs -DESRI_UNIX -DENV_LINUX $(INCLUDEDIRS) $(DBGFLAGS) -CXX = g++ - -LDFLAGS = $(LIBDIRS) $(LIBS) - -all: $(PROGRAM) - -$(PROGRAM): $(CXXOBJECTS) - $(CXX) -o $@ $(CXXOBJECTS) $(LDFLAGS) - $(STRIP) $(PROGRAM) - -clean: - $(RM) -f $(CXXOBJECTS) $(PROGRAM) - +LIBS = $(shell wx-config --libs) -lwlocate + +DBGFLAGS = -O2 -g0 -DNDEBUG +STRIP=strip +ifeq ($(DEBUG),1) +DBGFLAGS = -O0 -g3 -DNOSPLASH +STRIP=ls -al +endif + +CXXSOURCES = LocDemoApp.cpp LocDemoWin.cpp + +CXXOBJECTS = $(CXXSOURCES:.cpp=.o) +CXXFLAGS = -Wall -Wno-unused-local-typedefs -DESRI_UNIX -DENV_LINUX $(INCLUDEDIRS) $(DBGFLAGS) +CXX = g++ + +LDFLAGS = $(LIBDIRS) $(LIBS) + +all: $(PROGRAM) + +$(PROGRAM): $(CXXOBJECTS) + $(CXX) -o $@ $(CXXOBJECTS) $(LDFLAGS) + $(STRIP) $(PROGRAM) + +clean: + $(RM) -f $(CXXOBJECTS) $(PROGRAM) + diff --git a/master/locdemo/Makefile.QNX b/master/locdemo/Makefile.QNX index eff9e5c..4f4d446 100755 --- a/master/locdemo/Makefile.QNX +++ b/master/locdemo/Makefile.QNX @@ -1,30 +1,30 @@ -PROGRAM = LocDemo - -INCLUDEDIRS = -I/usr/X11R6/include -I.. $(shell wx-config --cflags) $(shell pkg-config gtk+-2.0 --cflags) - -LIBDIRS = -L/usr/X11R6/lib -L/usr/lib - -LIBS = $(shell wx-config --libs) -lph -lwlocate - -DBGFLAGS = -O2 -g0 -DNDEBUG -ifeq ($(DEBUG),1) -DBGFLAGS = -O0 -g3 -DNOSPLASH -endif - -CXXSOURCES = LocDemoApp.cpp LocDemoWin.cpp - -CXXOBJECTS = $(CXXSOURCES:.cpp=.o) -CXXFLAGS = -Wall -DESRI_UNIX -DENV_QNX $(INCLUDEDIRS) $(DBGFLAGS) -CXX = g++ - -LDFLAGS = $(LIBDIRS) $(LIBS) - -all: $(PROGRAM) - -$(PROGRAM): $(CXXOBJECTS) - $(CXX) -o $@ $(CXXOBJECTS) $(LDFLAGS) - strip $(PROGRAM) - -clean: - $(RM) -f $(CXXOBJECTS) $(PROGRAM) - +PROGRAM = LocDemo + +INCLUDEDIRS = -I/usr/X11R6/include -I.. $(shell wx-config --cflags) $(shell pkg-config gtk+-2.0 --cflags) + +LIBDIRS = -L/usr/X11R6/lib -L/usr/lib + +LIBS = $(shell wx-config --libs) -lph -lwlocate + +DBGFLAGS = -O2 -g0 -DNDEBUG +ifeq ($(DEBUG),1) +DBGFLAGS = -O0 -g3 -DNOSPLASH +endif + +CXXSOURCES = LocDemoApp.cpp LocDemoWin.cpp + +CXXOBJECTS = $(CXXSOURCES:.cpp=.o) +CXXFLAGS = -Wall -DESRI_UNIX -DENV_QNX $(INCLUDEDIRS) $(DBGFLAGS) +CXX = g++ + +LDFLAGS = $(LIBDIRS) $(LIBS) + +all: $(PROGRAM) + +$(PROGRAM): $(CXXOBJECTS) + $(CXX) -o $@ $(CXXOBJECTS) $(LDFLAGS) + strip $(PROGRAM) + +clean: + $(RM) -f $(CXXOBJECTS) $(PROGRAM) + diff --git a/master/locdemo/README b/master/locdemo/README index 4836144..ccafaaa 100755 --- a/master/locdemo/README +++ b/master/locdemo/README @@ -1,17 +1,17 @@ -This is a demo application that makes use of libwlocate. It uses this library -to get the current geographic position, then downloads the related map tiles -from the OpenStreetMap project (please refer to http://www.openstreetmap.org -for detail) and displays them within the main screen. The calculated geographic -position is highlighted with a red circle. Its radius differs and depends on -the quality of the returned location result. - -Additionally it can be used to load a libwlocate.trace file as generated by the -command line tool lwtrace to track the positions where a user has been. This -file contains WLAN data which are converted to geographic positions by LocDemo. -These positions form a path that are drawn into the LocDemo map. This function -can be used to track positions a user has been. - -This application uses the wxWidgets toolkit (from http://www.wxwidgets.org ) -for the user interface. To compile it from source the related wxWidgets -development files are required. - +This is a demo application that makes use of libwlocate. It uses this library +to get the current geographic position, then downloads the related map tiles +from the OpenStreetMap project (please refer to http://www.openstreetmap.org +for detail) and displays them within the main screen. The calculated geographic +position is highlighted with a red circle. Its radius differs and depends on +the quality of the returned location result. + +Additionally it can be used to load a libwlocate.trace file as generated by the +command line tool lwtrace to track the positions where a user has been. This +file contains WLAN data which are converted to geographic positions by LocDemo. +These positions form a path that are drawn into the LocDemo map. This function +can be used to track positions a user has been. + +This application uses the wxWidgets toolkit (from http://www.wxwidgets.org ) +for the user interface. To compile it from source the related wxWidgets +development files are required. + diff --git a/master/locdemo/locdemo.dsp b/master/locdemo/locdemo.dsp index a1af5f7..a38508b 100755 --- a/master/locdemo/locdemo.dsp +++ b/master/locdemo/locdemo.dsp @@ -1,111 +1,111 @@ -# Microsoft Developer Studio Project File - Name="locdemo" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Application" 0x0101 - -CFG=locdemo - Win32 DLL Unicode Release -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "locdemo.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "locdemo.mak" CFG="locdemo - Win32 DLL Unicode Release" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "locdemo - Win32 DLL Unicode Release" (based on "Win32 (x86) Application") -!MESSAGE "locdemo - Win32 DLL Unicode Debug" (based on "Win32 (x86) Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -MTL=midl.exe -RSC=rc.exe - -!IF "$(CFG)" == "locdemo - Win32 DLL Unicode Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "vc_mswudll" -# PROP BASE Intermediate_Dir "vc_mswudll\locdemo" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "vc_mswudll" -# PROP Intermediate_Dir "vc_mswudll\locdemo" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MD /W4 /GR /O2 /I ".....\lib\vc_dll\mswu" /I ".....\include" /I "." /I ".....\samples" /D "WIN32" /D "__WXMSW__" /D "_UNICODE" /D "WXUSINGDLL" /D "_WINDOWS" /D "NOPCH" /Fd"vc_mswudll\locdemo.pdb" /FD /EHsc /c -# ADD CPP /nologo /MD /W4 /GR /O2 /I "C:\wxWidgets-2.8\lib\vc_dll\mswu" /I ".....\lib\vc_dll\mswu" /I "C:\wxWidgets-2.8\include" /I "." /I ".." /D "WIN32" /D "__WXMSW__" /D "_UNICODE" /D "WXUSINGDLL" /D "_WINDOWS" /D "NOPCH" /D "ENV_WINDOWS" /D "ENV_EDITOR" /FR /Fd"vc_mswudll\locdemo.pdb" /FD /EHsc /c -# ADD BASE MTL /nologo /D "WIN32" /D "__WXMSW__" /D "_UNICODE" /D "WXUSINGDLL" /D "_WINDOWS" /D "NOPCH" /mktyplib203 /win32 -# ADD MTL /nologo /D "WIN32" /D "__WXMSW__" /D "_UNICODE" /D "WXUSINGDLL" /D "_WINDOWS" /D "NOPCH" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /i ".....\lib\vc_dll\mswu" /i ".....\include" /i "." /i ".....\samples" /d "__WXMSW__" /d "_UNICODE" /d "WXUSINGDLL" /d "_WINDOWS" /d "NOPCH" -# ADD RSC /l 0x409 /i ".....\lib\vc_dll\mswu" /i ".....\include" /i "." /i ".....\samples" /d "__WXMSW__" /d "_UNICODE" /d "WXUSINGDLL" /d "_WINDOWS" /d "NOPCH" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 wxmsw28u_core.lib wxbase28u.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregexu.lib wxexpat.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib odbc32.lib /nologo /subsystem:windows /machine:I386 /libpath:".....\lib\vc_dll" -# SUBTRACT BASE LINK32 /pdb:none -# ADD LINK32 wxbase28u_net.lib wxmsw28u_xrc.lib wxbase28u_xml.lib wxmsw28u_adv.lib wxmsw28u_core.lib wxbase28u.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregexu.lib wxexpat.lib netapi32.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib odbc32.lib ../Release/libwlocate.lib /nologo /subsystem:windows /machine:I386 /out:"LocDemo.exe" /libpath:"..\Release\" /libpath:"C:\wxWidgets-2.8\lib\vc_dll" -# SUBTRACT LINK32 /pdb:none - -!ELSEIF "$(CFG)" == "locdemo - Win32 DLL Unicode Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "vc_mswuddll" -# PROP BASE Intermediate_Dir "vc_mswuddll\locdemo" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "vc_mswuddll" -# PROP Intermediate_Dir "vc_mswuddll\locdemo" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /MDd /W4 /Gm /GR /Zi /Od /I ".....\lib\vc_dll\mswud" /I ".....\include" /I "." /I ".....\samples" /D "WIN32" /D "_DEBUG" /D "__WXMSW__" /D "__WXDEBUG__" /D "_UNICODE" /D "WXUSINGDLL" /D "_WINDOWS" /D "NOPCH" /Fd"vc_mswuddll\locdemo.pdb" /FD /EHsc /c -# ADD CPP /nologo /MDd /W4 /Gm /GR /ZI /Od /I "C:\wxWidgets-2.8\lib\vc_dll\mswud" /I "C:\wxWidgets-2.8\include" /I "." /I ".." /D "WIN32" /D "_DEBUG" /D "__WXMSW__" /D "__WXDEBUG__" /D "_UNICODE" /D "WXUSINGDLL" /D "_WINDOWS" /D "NOPCH" /D "ENV_EDITOR" /D "ENV_WINDOWS" /FR /Fd"vc_mswuddll\locdemo.pdb" /FD /EHsc /c -# ADD BASE MTL /nologo /D "WIN32" /D "_DEBUG" /D "__WXMSW__" /D "__WXDEBUG__" /D "_UNICODE" /D "WXUSINGDLL" /D "_WINDOWS" /D "NOPCH" /mktyplib203 /win32 -# ADD MTL /nologo /D "WIN32" /D "_DEBUG" /D "__WXMSW__" /D "__WXDEBUG__" /D "_UNICODE" /D "WXUSINGDLL" /D "_WINDOWS" /D "NOPCH" /mktyplib203 /win32 -# ADD BASE RSC /l 0x409 /i ".....\lib\vc_dll\mswud" /i ".....\include" /i "." /i ".....\samples" /d "_DEBUG" /d "__WXMSW__" /d "__WXDEBUG__" /d "_UNICODE" /d "WXUSINGDLL" /d "_WINDOWS" /d "NOPCH" -# ADD RSC /l 0x409 /i ".....\lib\vc_dll\mswud" /i ".....\include" /i "." /i ".....\samples" /d "_DEBUG" /d "__WXMSW__" /d "__WXDEBUG__" /d "_UNICODE" /d "WXUSINGDLL" /d "_WINDOWS" /d "NOPCH" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 wxmsw28ud_core.lib wxbase28ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexud.lib wxexpatd.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib odbc32.lib /nologo /subsystem:windows /debug /machine:I386 /libpath:".....\lib\vc_dll" -# SUBTRACT BASE LINK32 /pdb:none -# ADD LINK32 wxmsw28ud_xrc.lib wxbase28ud_xml.lib wxmsw28ud_adv.lib wxmsw28ud_core.lib wxbase28ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexud.lib wxexpatd.lib netapi32.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib odbc32.lib libwlocate.lib wxbase28ud_net.lib /nologo /subsystem:windows /debug /machine:I386 /out:"LocDemo.exe" /libpath:"..\Debug\" /libpath:"C:\wxWidgets-2.8\lib\vc_dll" -# SUBTRACT LINK32 /pdb:none - -!ENDIF - -# Begin Target - -# Name "locdemo - Win32 DLL Unicode Release" -# Name "locdemo - Win32 DLL Unicode Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "" -# Begin Source File - -SOURCE=.\LocDemoApp.cpp -# End Source File -# Begin Source File - -SOURCE=.\LocDemoWin.cpp -# End Source File -# End Group -# Begin Source File - -SOURCE=.\icon.ico -# End Source File -# End Target -# End Project +# Microsoft Developer Studio Project File - Name="locdemo" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Application" 0x0101 + +CFG=locdemo - Win32 DLL Unicode Release +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "locdemo.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "locdemo.mak" CFG="locdemo - Win32 DLL Unicode Release" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "locdemo - Win32 DLL Unicode Release" (based on "Win32 (x86) Application") +!MESSAGE "locdemo - Win32 DLL Unicode Debug" (based on "Win32 (x86) Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +MTL=midl.exe +RSC=rc.exe + +!IF "$(CFG)" == "locdemo - Win32 DLL Unicode Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "vc_mswudll" +# PROP BASE Intermediate_Dir "vc_mswudll\locdemo" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "vc_mswudll" +# PROP Intermediate_Dir "vc_mswudll\locdemo" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MD /W4 /GR /O2 /I ".....\lib\vc_dll\mswu" /I ".....\include" /I "." /I ".....\samples" /D "WIN32" /D "__WXMSW__" /D "_UNICODE" /D "WXUSINGDLL" /D "_WINDOWS" /D "NOPCH" /Fd"vc_mswudll\locdemo.pdb" /FD /EHsc /c +# ADD CPP /nologo /MD /W4 /GR /O2 /I "C:\wxWidgets-2.8\lib\vc_dll\mswu" /I ".....\lib\vc_dll\mswu" /I "C:\wxWidgets-2.8\include" /I "." /I ".." /D "WIN32" /D "__WXMSW__" /D "_UNICODE" /D "WXUSINGDLL" /D "_WINDOWS" /D "NOPCH" /D "ENV_WINDOWS" /D "ENV_EDITOR" /FR /Fd"vc_mswudll\locdemo.pdb" /FD /EHsc /c +# ADD BASE MTL /nologo /D "WIN32" /D "__WXMSW__" /D "_UNICODE" /D "WXUSINGDLL" /D "_WINDOWS" /D "NOPCH" /mktyplib203 /win32 +# ADD MTL /nologo /D "WIN32" /D "__WXMSW__" /D "_UNICODE" /D "WXUSINGDLL" /D "_WINDOWS" /D "NOPCH" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /i ".....\lib\vc_dll\mswu" /i ".....\include" /i "." /i ".....\samples" /d "__WXMSW__" /d "_UNICODE" /d "WXUSINGDLL" /d "_WINDOWS" /d "NOPCH" +# ADD RSC /l 0x409 /i ".....\lib\vc_dll\mswu" /i ".....\include" /i "." /i ".....\samples" /d "__WXMSW__" /d "_UNICODE" /d "WXUSINGDLL" /d "_WINDOWS" /d "NOPCH" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 wxmsw28u_core.lib wxbase28u.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregexu.lib wxexpat.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib odbc32.lib /nologo /subsystem:windows /machine:I386 /libpath:".....\lib\vc_dll" +# SUBTRACT BASE LINK32 /pdb:none +# ADD LINK32 wxbase28u_net.lib wxmsw28u_xrc.lib wxbase28u_xml.lib wxmsw28u_adv.lib wxmsw28u_core.lib wxbase28u.lib wxtiff.lib wxjpeg.lib wxpng.lib wxzlib.lib wxregexu.lib wxexpat.lib netapi32.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib odbc32.lib ../Release/libwlocate.lib /nologo /subsystem:windows /machine:I386 /out:"LocDemo.exe" /libpath:"..\Release\" /libpath:"C:\wxWidgets-2.8\lib\vc_dll" +# SUBTRACT LINK32 /pdb:none + +!ELSEIF "$(CFG)" == "locdemo - Win32 DLL Unicode Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "vc_mswuddll" +# PROP BASE Intermediate_Dir "vc_mswuddll\locdemo" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "vc_mswuddll" +# PROP Intermediate_Dir "vc_mswuddll\locdemo" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /MDd /W4 /Gm /GR /Zi /Od /I ".....\lib\vc_dll\mswud" /I ".....\include" /I "." /I ".....\samples" /D "WIN32" /D "_DEBUG" /D "__WXMSW__" /D "__WXDEBUG__" /D "_UNICODE" /D "WXUSINGDLL" /D "_WINDOWS" /D "NOPCH" /Fd"vc_mswuddll\locdemo.pdb" /FD /EHsc /c +# ADD CPP /nologo /MDd /W4 /Gm /GR /ZI /Od /I "C:\wxWidgets-2.8\lib\vc_dll\mswud" /I "C:\wxWidgets-2.8\include" /I "." /I ".." /D "WIN32" /D "_DEBUG" /D "__WXMSW__" /D "__WXDEBUG__" /D "_UNICODE" /D "WXUSINGDLL" /D "_WINDOWS" /D "NOPCH" /D "ENV_EDITOR" /D "ENV_WINDOWS" /FR /Fd"vc_mswuddll\locdemo.pdb" /FD /EHsc /c +# ADD BASE MTL /nologo /D "WIN32" /D "_DEBUG" /D "__WXMSW__" /D "__WXDEBUG__" /D "_UNICODE" /D "WXUSINGDLL" /D "_WINDOWS" /D "NOPCH" /mktyplib203 /win32 +# ADD MTL /nologo /D "WIN32" /D "_DEBUG" /D "__WXMSW__" /D "__WXDEBUG__" /D "_UNICODE" /D "WXUSINGDLL" /D "_WINDOWS" /D "NOPCH" /mktyplib203 /win32 +# ADD BASE RSC /l 0x409 /i ".....\lib\vc_dll\mswud" /i ".....\include" /i "." /i ".....\samples" /d "_DEBUG" /d "__WXMSW__" /d "__WXDEBUG__" /d "_UNICODE" /d "WXUSINGDLL" /d "_WINDOWS" /d "NOPCH" +# ADD RSC /l 0x409 /i ".....\lib\vc_dll\mswud" /i ".....\include" /i "." /i ".....\samples" /d "_DEBUG" /d "__WXMSW__" /d "__WXDEBUG__" /d "_UNICODE" /d "WXUSINGDLL" /d "_WINDOWS" /d "NOPCH" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 wxmsw28ud_core.lib wxbase28ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexud.lib wxexpatd.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib odbc32.lib /nologo /subsystem:windows /debug /machine:I386 /libpath:".....\lib\vc_dll" +# SUBTRACT BASE LINK32 /pdb:none +# ADD LINK32 wxmsw28ud_xrc.lib wxbase28ud_xml.lib wxmsw28ud_adv.lib wxmsw28ud_core.lib wxbase28ud.lib wxtiffd.lib wxjpegd.lib wxpngd.lib wxzlibd.lib wxregexud.lib wxexpatd.lib netapi32.lib kernel32.lib user32.lib gdi32.lib comdlg32.lib winspool.lib winmm.lib shell32.lib comctl32.lib ole32.lib oleaut32.lib uuid.lib rpcrt4.lib advapi32.lib wsock32.lib odbc32.lib libwlocate.lib wxbase28ud_net.lib /nologo /subsystem:windows /debug /machine:I386 /out:"LocDemo.exe" /libpath:"..\Debug\" /libpath:"C:\wxWidgets-2.8\lib\vc_dll" +# SUBTRACT LINK32 /pdb:none + +!ENDIF + +# Begin Target + +# Name "locdemo - Win32 DLL Unicode Release" +# Name "locdemo - Win32 DLL Unicode Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "" +# Begin Source File + +SOURCE=.\LocDemoApp.cpp +# End Source File +# Begin Source File + +SOURCE=.\LocDemoWin.cpp +# End Source File +# End Group +# Begin Source File + +SOURCE=.\icon.ico +# End Source File +# End Target +# End Project diff --git a/master/locdemo/locdemo.dsw b/master/locdemo/locdemo.dsw index 7f49b9b..673a097 100755 --- a/master/locdemo/locdemo.dsw +++ b/master/locdemo/locdemo.dsw @@ -1,29 +1,29 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "bombs"=.\locdemo.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "bombs"=.\locdemo.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/master/locdemo/setup_data/LocDemo/DEBIAN/preinst b/master/locdemo/setup_data/LocDemo/DEBIAN/preinst index 82b6c88..e66b659 100755 --- a/master/locdemo/setup_data/LocDemo/DEBIAN/preinst +++ b/master/locdemo/setup_data/LocDemo/DEBIAN/preinst @@ -1,8 +1,8 @@ -#!/bin/sh - -if [ -x /sbin/LocDemo ]; then - rm -f /sbin/LocDemo -fi -if [ -x /etc/init.d/wlocd ]; then - /etc/init.d/wlocd stop -fi +#!/bin/sh + +if [ -x /sbin/LocDemo ]; then + rm -f /sbin/LocDemo +fi +if [ -x /etc/init.d/wlocd ]; then + /etc/init.d/wlocd stop +fi diff --git a/master/locdemo/setup_data/LocDemo/DEBIAN/prerm b/master/locdemo/setup_data/LocDemo/DEBIAN/prerm index b099c40..e926d95 100755 --- a/master/locdemo/setup_data/LocDemo/DEBIAN/prerm +++ b/master/locdemo/setup_data/LocDemo/DEBIAN/prerm @@ -1,9 +1,9 @@ -#!/bin/sh - -/etc/init.d/wlocd stop -rm /etc/rc5.d/S99wlocd -rm /etc/rc5.d/K01wlocd -rm /etc/rc3.d/S99wlocd -rm /etc/rc3.d/K01wlocd -rm /etc/rc2.d/S99wlocd -rm /etc/rc2.d/K01wlocd +#!/bin/sh + +/etc/init.d/wlocd stop +rm /etc/rc5.d/S99wlocd +rm /etc/rc5.d/K01wlocd +rm /etc/rc3.d/S99wlocd +rm /etc/rc3.d/K01wlocd +rm /etc/rc2.d/S99wlocd +rm /etc/rc2.d/K01wlocd diff --git a/master/locdemo/win_setup.nsi b/master/locdemo/win_setup.nsi index d02ceae..9480bd1 100755 --- a/master/locdemo/win_setup.nsi +++ b/master/locdemo/win_setup.nsi @@ -1,92 +1,92 @@ -!include Library.nsh -var ALREADY_INSTALLED - -Name "LocDemo - WLAN location demo" -OutFile "locdemo_install.exe" - -SetCompress auto -SetDatablockOptimize on -CRCCheck on -; AutoCloseWindow false ; (can be true for the window go away automatically at end) -ShowInstDetails nevershow ; (can be show to have them shown, or nevershow to disable) -; SetDateSave off ; (can be on to have files restored to their orginal date) - -LicenseText "Please read the license agreement before installing and using the software:" -LicenseData "../COPYING" - -InstallDir "$PROGRAMFILES\LocDemo" -DirText "Select the directory to install the LocDemo software into:" - -InstProgressFlags smooth - -Section "" ; (default section) - -SetOutPath "$INSTDIR" -File "LocDemo.exe" -File "..\Release\lwtrace.exe" -File "icon.ico" - -File "CAcert_Root_Certificates.msi" -ExecWait '"msiexec" /quiet /i "$INSTDIR\CAcert_Root_Certificates.msi"' - -!insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "..\Release\libwlocate.dll" "$SYSDIR\libwlocate.dll" "$SYSDIR" - -!insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "C:\wxWidgets-2.8\lib\vc_dll\wxbase28u_net_vc_custom.dll" "$SYSDIR\wxbase28u_net_vc_custom.dll" "$SYSDIR" -!insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "C:\wxWidgets-2.8\lib\vc_dll\wxbase28u_odbc_vc_custom.dll" "$SYSDIR\wxbase28u_odbc_vc_custom.dll" "$SYSDIR" -!insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "C:\wxWidgets-2.8\lib\vc_dll\wxbase28u_vc_custom.dll" "$SYSDIR\wxbase28u_vc_custom.dll" "$SYSDIR" -!insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "C:\wxWidgets-2.8\lib\vc_dll\wxbase28u_xml_vc_custom.dll" "$SYSDIR\wxbase28u_xml_vc_custom.dll" "$SYSDIR" -!insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "C:\wxWidgets-2.8\lib\vc_dll\wxmsw28u_adv_vc_custom.dll" "$SYSDIR\wxmsw28u_adv_vc_custom.dll" "$SYSDIR" -!insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "C:\wxWidgets-2.8\lib\vc_dll\wxmsw28u_aui_vc_custom.dll" "$SYSDIR\wxmsw28u_aui_vc_custom.dll" "$SYSDIR" -!insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "C:\wxWidgets-2.8\lib\vc_dll\wxmsw28u_core_vc_custom.dll" "$SYSDIR\wxmsw28u_core_vc_custom.dll" "$SYSDIR" -!insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "C:\wxWidgets-2.8\lib\vc_dll\wxmsw28u_gl_vc_custom.dll" "$SYSDIR\wxmsw28u_gl_vc_custom.dll" "$SYSDIR" -!insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "C:\wxWidgets-2.8\lib\vc_dll\wxmsw28u_html_vc_custom.dll" "$SYSDIR\wxmsw28u_html_vc_custom.dll" "$SYSDIR" -!insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "C:\wxWidgets-2.8\lib\vc_dll\wxmsw28u_media_vc_custom.dll" "$SYSDIR\wxmsw28u_media_vc_custom.dll" "$SYSDIR" -!insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "C:\wxWidgets-2.8\lib\vc_dll\wxmsw28u_richtext_vc_custom.dll" "$SYSDIR\wxmsw28u_richtext_vc_custom.dll" "$SYSDIR" -!insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "C:\wxWidgets-2.8\lib\vc_dll\wxmsw28u_xrc_vc_custom.dll" "$SYSDIR\wxmsw28u_xrc_vc_custom.dll" "$SYSDIR" - -; write out uninstaller -WriteUninstaller "$INSTDIR\uninstall.exe" -WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LocDemo" "DisplayName" "LocDemo" -WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LocDemo" "UninstallString" "$INSTDIR\uninstall.exe" - -Sectionend - -Section -startmenu - -CreateDirectory "$SMPROGRAMS\LocDemo" -CreateShortCut "$SMPROGRAMS\LocDemo\LocDemo.lnk" "$INSTDIR\LocDemo.exe" "" "$INSTDIR\icon.ico" 0 -CreateShortCut "$SMPROGRAMS\LocDemo\trace.lnk" "$INSTDIR\trace.exe" "" "" 0 -CreateShortCut "$SMPROGRAMS\LocDemo\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 - -Sectionend - - -; begin uninstall settings/section -UninstallText "This will uninstall the LocDemo software from your system" - -Section Uninstall - -DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\LocDemo" - -Delete "$INSTDIR*.*" -RMDir /r $INSTDIR -Delete "$SMPROGRAMS\LocDemo*.*" -RMDir "$SMPROGRAMS\LocDemo" - -!insertmacro UnInstallLib DLL SHARED REBOOT_NOTPROTECTED "$SYSDIR\libwlocate.dll" - -!insertmacro UnInstallLib DLL SHARED REBOOT_NOTPROTECTED "$SYSDIR\wxbase28u_net_vc_custom.dll" -!insertmacro UnInstallLib DLL SHARED REBOOT_NOTPROTECTED "$SYSDIR\wxbase28u_odbc_vc_custom.dll" -!insertmacro UnInstallLib DLL SHARED REBOOT_NOTPROTECTED "$SYSDIR\wxbase28u_vc_custom.dll" -!insertmacro UnInstallLib DLL SHARED REBOOT_NOTPROTECTED "$SYSDIR\wxbase28u_xml_vc_custom.dll" -!insertmacro UnInstallLib DLL SHARED REBOOT_NOTPROTECTED "$SYSDIR\wxmsw28u_adv_vc_custom.dll" -!insertmacro UnInstallLib DLL SHARED REBOOT_NOTPROTECTED "$SYSDIR\wxmsw28u_aui_vc_custom.dll" -!insertmacro UnInstallLib DLL SHARED REBOOT_NOTPROTECTED "$SYSDIR\wxmsw28u_core_vc_custom.dll" -!insertmacro UnInstallLib DLL SHARED REBOOT_NOTPROTECTED "$SYSDIR\wxmsw28u_gl_vc_custom.dll" -!insertmacro UnInstallLib DLL SHARED REBOOT_NOTPROTECTED "$SYSDIR\wxmsw28u_html_vc_custom.dll" -!insertmacro UnInstallLib DLL SHARED REBOOT_NOTPROTECTED "$SYSDIR\wxmsw28u_media_vc_custom.dll" -!insertmacro UnInstallLib DLL SHARED REBOOT_NOTPROTECTED "$SYSDIR\wxmsw28u_richtext_vc_custom.dll" -!insertmacro UnInstallLib DLL SHARED REBOOT_NOTPROTECTED "$SYSDIR\wxmsw28u_xrc_vc_custom.dll" - -SectionEnd ; end of uninstall section - +!include Library.nsh +var ALREADY_INSTALLED + +Name "LocDemo - WLAN location demo" +OutFile "locdemo_install.exe" + +SetCompress auto +SetDatablockOptimize on +CRCCheck on +; AutoCloseWindow false ; (can be true for the window go away automatically at end) +ShowInstDetails nevershow ; (can be show to have them shown, or nevershow to disable) +; SetDateSave off ; (can be on to have files restored to their orginal date) + +LicenseText "Please read the license agreement before installing and using the software:" +LicenseData "../COPYING" + +InstallDir "$PROGRAMFILES\LocDemo" +DirText "Select the directory to install the LocDemo software into:" + +InstProgressFlags smooth + +Section "" ; (default section) + +SetOutPath "$INSTDIR" +File "LocDemo.exe" +File "..\Release\lwtrace.exe" +File "icon.ico" + +File "CAcert_Root_Certificates.msi" +ExecWait '"msiexec" /quiet /i "$INSTDIR\CAcert_Root_Certificates.msi"' + +!insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "..\Release\libwlocate.dll" "$SYSDIR\libwlocate.dll" "$SYSDIR" + +!insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "C:\wxWidgets-2.8\lib\vc_dll\wxbase28u_net_vc_custom.dll" "$SYSDIR\wxbase28u_net_vc_custom.dll" "$SYSDIR" +!insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "C:\wxWidgets-2.8\lib\vc_dll\wxbase28u_odbc_vc_custom.dll" "$SYSDIR\wxbase28u_odbc_vc_custom.dll" "$SYSDIR" +!insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "C:\wxWidgets-2.8\lib\vc_dll\wxbase28u_vc_custom.dll" "$SYSDIR\wxbase28u_vc_custom.dll" "$SYSDIR" +!insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "C:\wxWidgets-2.8\lib\vc_dll\wxbase28u_xml_vc_custom.dll" "$SYSDIR\wxbase28u_xml_vc_custom.dll" "$SYSDIR" +!insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "C:\wxWidgets-2.8\lib\vc_dll\wxmsw28u_adv_vc_custom.dll" "$SYSDIR\wxmsw28u_adv_vc_custom.dll" "$SYSDIR" +!insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "C:\wxWidgets-2.8\lib\vc_dll\wxmsw28u_aui_vc_custom.dll" "$SYSDIR\wxmsw28u_aui_vc_custom.dll" "$SYSDIR" +!insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "C:\wxWidgets-2.8\lib\vc_dll\wxmsw28u_core_vc_custom.dll" "$SYSDIR\wxmsw28u_core_vc_custom.dll" "$SYSDIR" +!insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "C:\wxWidgets-2.8\lib\vc_dll\wxmsw28u_gl_vc_custom.dll" "$SYSDIR\wxmsw28u_gl_vc_custom.dll" "$SYSDIR" +!insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "C:\wxWidgets-2.8\lib\vc_dll\wxmsw28u_html_vc_custom.dll" "$SYSDIR\wxmsw28u_html_vc_custom.dll" "$SYSDIR" +!insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "C:\wxWidgets-2.8\lib\vc_dll\wxmsw28u_media_vc_custom.dll" "$SYSDIR\wxmsw28u_media_vc_custom.dll" "$SYSDIR" +!insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "C:\wxWidgets-2.8\lib\vc_dll\wxmsw28u_richtext_vc_custom.dll" "$SYSDIR\wxmsw28u_richtext_vc_custom.dll" "$SYSDIR" +!insertmacro InstallLib DLL $ALREADY_INSTALLED REBOOT_NOTPROTECTED "C:\wxWidgets-2.8\lib\vc_dll\wxmsw28u_xrc_vc_custom.dll" "$SYSDIR\wxmsw28u_xrc_vc_custom.dll" "$SYSDIR" + +; write out uninstaller +WriteUninstaller "$INSTDIR\uninstall.exe" +WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LocDemo" "DisplayName" "LocDemo" +WriteRegStr HKLM "Software\Microsoft\Windows\CurrentVersion\Uninstall\LocDemo" "UninstallString" "$INSTDIR\uninstall.exe" + +Sectionend + +Section -startmenu + +CreateDirectory "$SMPROGRAMS\LocDemo" +CreateShortCut "$SMPROGRAMS\LocDemo\LocDemo.lnk" "$INSTDIR\LocDemo.exe" "" "$INSTDIR\icon.ico" 0 +CreateShortCut "$SMPROGRAMS\LocDemo\trace.lnk" "$INSTDIR\trace.exe" "" "" 0 +CreateShortCut "$SMPROGRAMS\LocDemo\Uninstall.lnk" "$INSTDIR\uninstall.exe" "" "$INSTDIR\uninstall.exe" 0 + +Sectionend + + +; begin uninstall settings/section +UninstallText "This will uninstall the LocDemo software from your system" + +Section Uninstall + +DeleteRegKey HKEY_LOCAL_MACHINE "SOFTWARE\Microsoft\Windows\CurrentVersion\Uninstall\LocDemo" + +Delete "$INSTDIR*.*" +RMDir /r $INSTDIR +Delete "$SMPROGRAMS\LocDemo*.*" +RMDir "$SMPROGRAMS\LocDemo" + +!insertmacro UnInstallLib DLL SHARED REBOOT_NOTPROTECTED "$SYSDIR\libwlocate.dll" + +!insertmacro UnInstallLib DLL SHARED REBOOT_NOTPROTECTED "$SYSDIR\wxbase28u_net_vc_custom.dll" +!insertmacro UnInstallLib DLL SHARED REBOOT_NOTPROTECTED "$SYSDIR\wxbase28u_odbc_vc_custom.dll" +!insertmacro UnInstallLib DLL SHARED REBOOT_NOTPROTECTED "$SYSDIR\wxbase28u_vc_custom.dll" +!insertmacro UnInstallLib DLL SHARED REBOOT_NOTPROTECTED "$SYSDIR\wxbase28u_xml_vc_custom.dll" +!insertmacro UnInstallLib DLL SHARED REBOOT_NOTPROTECTED "$SYSDIR\wxmsw28u_adv_vc_custom.dll" +!insertmacro UnInstallLib DLL SHARED REBOOT_NOTPROTECTED "$SYSDIR\wxmsw28u_aui_vc_custom.dll" +!insertmacro UnInstallLib DLL SHARED REBOOT_NOTPROTECTED "$SYSDIR\wxmsw28u_core_vc_custom.dll" +!insertmacro UnInstallLib DLL SHARED REBOOT_NOTPROTECTED "$SYSDIR\wxmsw28u_gl_vc_custom.dll" +!insertmacro UnInstallLib DLL SHARED REBOOT_NOTPROTECTED "$SYSDIR\wxmsw28u_html_vc_custom.dll" +!insertmacro UnInstallLib DLL SHARED REBOOT_NOTPROTECTED "$SYSDIR\wxmsw28u_media_vc_custom.dll" +!insertmacro UnInstallLib DLL SHARED REBOOT_NOTPROTECTED "$SYSDIR\wxmsw28u_richtext_vc_custom.dll" +!insertmacro UnInstallLib DLL SHARED REBOOT_NOTPROTECTED "$SYSDIR\wxmsw28u_xrc_vc_custom.dll" + +SectionEnd ; end of uninstall section + diff --git a/master/trace.dsp b/master/trace.dsp index 03e875a..588b0c6 100755 --- a/master/trace.dsp +++ b/master/trace.dsp @@ -1,102 +1,102 @@ -# Microsoft Developer Studio Project File - Name="trace" - Package Owner=<4> -# Microsoft Developer Studio Generated Build File, Format Version 6.00 -# ** DO NOT EDIT ** - -# TARGTYPE "Win32 (x86) Console Application" 0x0103 - -CFG=trace - Win32 Debug -!MESSAGE This is not a valid makefile. To build this project using NMAKE, -!MESSAGE use the Export Makefile command and run -!MESSAGE -!MESSAGE NMAKE /f "trace.mak". -!MESSAGE -!MESSAGE You can specify a configuration when running NMAKE -!MESSAGE by defining the macro CFG on the command line. For example: -!MESSAGE -!MESSAGE NMAKE /f "trace.mak" CFG="trace - Win32 Debug" -!MESSAGE -!MESSAGE Possible choices for configuration are: -!MESSAGE -!MESSAGE "trace - Win32 Release" (based on "Win32 (x86) Console Application") -!MESSAGE "trace - Win32 Debug" (based on "Win32 (x86) Console Application") -!MESSAGE - -# Begin Project -# PROP AllowPerConfigDependencies 0 -# PROP Scc_ProjName "" -# PROP Scc_LocalPath "" -CPP=cl.exe -RSC=rc.exe - -!IF "$(CFG)" == "trace - Win32 Release" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 0 -# PROP BASE Output_Dir "Release" -# PROP BASE Intermediate_Dir "Release" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 0 -# PROP Output_Dir "Release" -# PROP Intermediate_Dir "Release" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c -# ADD CPP /nologo /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "ENV_WINDOWS" /YX /FD /c -# ADD BASE RSC /l 0x407 /d "NDEBUG" -# ADD RSC /l 0x407 /d "NDEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 -# ADD LINK32 Release/libwlocate.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /subsystem:console /machine:I386 /out:"Release/lwtrace.exe" - -!ELSEIF "$(CFG)" == "trace - Win32 Debug" - -# PROP BASE Use_MFC 0 -# PROP BASE Use_Debug_Libraries 1 -# PROP BASE Output_Dir "trace___Win32_Debug" -# PROP BASE Intermediate_Dir "trace___Win32_Debug" -# PROP BASE Target_Dir "" -# PROP Use_MFC 0 -# PROP Use_Debug_Libraries 1 -# PROP Output_Dir "trace___Win32_Debug" -# PROP Intermediate_Dir "trace___Win32_Debug" -# PROP Ignore_Export_Lib 0 -# PROP Target_Dir "" -# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c -# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "ENV_WINDOWS" /FR /YX /FD /GZ /c -# ADD BASE RSC /l 0x407 /d "_DEBUG" -# ADD RSC /l 0x407 /d "_DEBUG" -BSC32=bscmake.exe -# ADD BASE BSC32 /nologo -# ADD BSC32 /nologo -LINK32=link.exe -# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept -# ADD LINK32 Debug/libwlocate.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /subsystem:console /debug /machine:I386 /out:"trace___Win32_Debug/lwtrace.exe" /pdbtype:sept - -!ENDIF - -# Begin Target - -# Name "trace - Win32 Release" -# Name "trace - Win32 Debug" -# Begin Group "Source Files" - -# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" -# Begin Source File - -SOURCE=.\trace.c -# End Source File -# End Group -# Begin Group "Header Files" - -# PROP Default_Filter "h;hpp;hxx;hm;inl" -# End Group -# Begin Group "Resource Files" - -# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" -# End Group -# End Target -# End Project +# Microsoft Developer Studio Project File - Name="trace" - Package Owner=<4> +# Microsoft Developer Studio Generated Build File, Format Version 6.00 +# ** DO NOT EDIT ** + +# TARGTYPE "Win32 (x86) Console Application" 0x0103 + +CFG=trace - Win32 Debug +!MESSAGE This is not a valid makefile. To build this project using NMAKE, +!MESSAGE use the Export Makefile command and run +!MESSAGE +!MESSAGE NMAKE /f "trace.mak". +!MESSAGE +!MESSAGE You can specify a configuration when running NMAKE +!MESSAGE by defining the macro CFG on the command line. For example: +!MESSAGE +!MESSAGE NMAKE /f "trace.mak" CFG="trace - Win32 Debug" +!MESSAGE +!MESSAGE Possible choices for configuration are: +!MESSAGE +!MESSAGE "trace - Win32 Release" (based on "Win32 (x86) Console Application") +!MESSAGE "trace - Win32 Debug" (based on "Win32 (x86) Console Application") +!MESSAGE + +# Begin Project +# PROP AllowPerConfigDependencies 0 +# PROP Scc_ProjName "" +# PROP Scc_LocalPath "" +CPP=cl.exe +RSC=rc.exe + +!IF "$(CFG)" == "trace - Win32 Release" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 0 +# PROP BASE Output_Dir "Release" +# PROP BASE Intermediate_Dir "Release" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 0 +# PROP Output_Dir "Release" +# PROP Intermediate_Dir "Release" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c +# ADD CPP /nologo /W3 /GX /O2 /D "NDEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "ENV_WINDOWS" /YX /FD /c +# ADD BASE RSC /l 0x407 /d "NDEBUG" +# ADD RSC /l 0x407 /d "NDEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386 +# ADD LINK32 Release/libwlocate.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /subsystem:console /machine:I386 /out:"Release/lwtrace.exe" + +!ELSEIF "$(CFG)" == "trace - Win32 Debug" + +# PROP BASE Use_MFC 0 +# PROP BASE Use_Debug_Libraries 1 +# PROP BASE Output_Dir "trace___Win32_Debug" +# PROP BASE Intermediate_Dir "trace___Win32_Debug" +# PROP BASE Target_Dir "" +# PROP Use_MFC 0 +# PROP Use_Debug_Libraries 1 +# PROP Output_Dir "trace___Win32_Debug" +# PROP Intermediate_Dir "trace___Win32_Debug" +# PROP Ignore_Export_Lib 0 +# PROP Target_Dir "" +# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c +# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /D "_DEBUG" /D "WIN32" /D "_CONSOLE" /D "_MBCS" /D "ENV_WINDOWS" /FR /YX /FD /GZ /c +# ADD BASE RSC /l 0x407 /d "_DEBUG" +# ADD RSC /l 0x407 /d "_DEBUG" +BSC32=bscmake.exe +# ADD BASE BSC32 /nologo +# ADD BSC32 /nologo +LINK32=link.exe +# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept +# ADD LINK32 Debug/libwlocate.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib wsock32.lib /nologo /subsystem:console /debug /machine:I386 /out:"trace___Win32_Debug/lwtrace.exe" /pdbtype:sept + +!ENDIF + +# Begin Target + +# Name "trace - Win32 Release" +# Name "trace - Win32 Debug" +# Begin Group "Source Files" + +# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat" +# Begin Source File + +SOURCE=.\trace.c +# End Source File +# End Group +# Begin Group "Header Files" + +# PROP Default_Filter "h;hpp;hxx;hm;inl" +# End Group +# Begin Group "Resource Files" + +# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe" +# End Group +# End Target +# End Project diff --git a/master/trace.dsw b/master/trace.dsw index b88d807..aeab66f 100755 --- a/master/trace.dsw +++ b/master/trace.dsw @@ -1,29 +1,29 @@ -Microsoft Developer Studio Workspace File, Format Version 6.00 -# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! - -############################################################################### - -Project: "trace"=.\trace.dsp - Package Owner=<4> - -Package=<5> -{{{ -}}} - -Package=<4> -{{{ -}}} - -############################################################################### - -Global: - -Package=<5> -{{{ -}}} - -Package=<3> -{{{ -}}} - -############################################################################### - +Microsoft Developer Studio Workspace File, Format Version 6.00 +# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE! + +############################################################################### + +Project: "trace"=.\trace.dsp - Package Owner=<4> + +Package=<5> +{{{ +}}} + +Package=<4> +{{{ +}}} + +############################################################################### + +Global: + +Package=<5> +{{{ +}}} + +Package=<3> +{{{ +}}} + +############################################################################### + diff --git a/master/wlan.c b/master/wlan.c index 0cd32b1..754af7e 100755 --- a/master/wlan.c +++ b/master/wlan.c @@ -1,255 +1,255 @@ -/** - * libwlocate - WLAN-based location service - * Copyright (C) 2010-2012 Oxygenic/VWP virtual_worlds(at)gmx.de - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -#ifdef ENV_WINDOWS -#include <windows.h> -#include <objbase.h> -#include <wtypes.h> - -#if (_MSC_VER>1400) - #include <wlanapi.h> - #pragma comment(lib, "wlanapi.lib") -#endif -#include "wlanapi_cust.h" -#endif - -#include "libwlocate.h" - -#include <stdio.h> -#include <stdlib.h> - -#ifdef ENV_WINDOWS -/** - * Works with Windows Vista and newer - */ -static int WinMethod1(struct wloc_req *request) -{ -#if (_MSC_VER<=1400) - static HINSTANCE wlan_library=NULL; -#endif - HANDLE hClient = NULL; - DWORD dwCurVersion = 0; - DWORD dwResult = 0; - int iRet = 0,i,j,cnt; - WCHAR GuidString[40] = {0}; - PWLAN_INTERFACE_INFO_LIST pIfList = NULL; - PWLAN_INTERFACE_INFO pIfInfo = NULL; - PWLAN_BSS_LIST pBssList=NULL; - PWLAN_BSS_ENTRY pBssEntry=NULL; - -#if (_MSC_VER<=1400) - if (!wlan_library) - { - wlan_library = LoadLibrary("wlanapi"); - if (!wlan_library) return 0; - WlanOpenHandle = (WlanOpenHandleFunction)GetProcAddress(wlan_library, "WlanOpenHandle"); - WlanEnumInterfaces = (WlanEnumInterfacesFunction)GetProcAddress(wlan_library, "WlanEnumInterfaces"); - WlanGetNetworkBssList = (WlanGetNetworkBssListFunction)GetProcAddress(wlan_library, "WlanGetNetworkBssList"); - WlanCloseHandle = (WlanCloseHandleFunction)GetProcAddress(wlan_library, "WlanCloseHandle"); - WlanFreeMemory = (WlanFreeMemoryFunction)GetProcAddress(wlan_library, "WlanFreeMemory"); - if ((!WlanOpenHandle) || (!WlanEnumInterfaces) || (!WlanGetNetworkBssList) || - (!WlanCloseHandle) || (!WlanFreeMemory)) - { - FreeLibrary(wlan_library); - wlan_library=NULL; - return 0; - } - } -#endif - dwResult = WlanOpenHandle(1, NULL, &dwCurVersion, &hClient); - if (dwResult != ERROR_SUCCESS) return 0; - - dwResult = WlanEnumInterfaces(hClient, NULL, &pIfList); - if (dwResult != ERROR_SUCCESS) - { - WlanCloseHandle(hClient,NULL); - return 0; - } - cnt=-1; - for (i = 0; i < (int) pIfList->dwNumberOfItems; i++) - { - pIfInfo = (WLAN_INTERFACE_INFO *) &pIfList->InterfaceInfo[i]; - dwResult=WlanGetNetworkBssList(hClient,&pIfInfo->InterfaceGuid,NULL,dot11_BSS_type_any,FALSE,NULL,&pBssList); - if (dwResult!=ERROR_SUCCESS) continue; - for (j=0; j<(int)pBssList->dwNumberOfItems; j++) - { - char *c; - - cnt++; - pBssEntry=&pBssList->wlanBssEntries[j]; - c=(char*)&pBssList->wlanBssEntries[j]; - memcpy(request->bssids[cnt],pBssEntry->dot11Bssid,6); -// request->signal[cnt]=(char)pBssEntry->uLinkQuality; - if (cnt>=WLOC_MAX_NETWORKS) break; - } - if (pBssList != NULL) WlanFreeMemory(pBssList); // ??? - if (cnt>=WLOC_MAX_NETWORKS) break; - } - if (pIfList != NULL) WlanFreeMemory(pIfList); - WlanCloseHandle(hClient,NULL); - return cnt+1; -} - - -/** - * Works with Windows XP >=SP2 and newer, outdated with Windows Vista and newer - */ -static int WinMethod2(struct wloc_req *request) -{ - static HINSTANCE wzc_library=NULL; - INTFS_KEY_TABLE interface_list; - ADAPTER_INFO adapter_info; - INTF_ENTRY interface_data; - DWORD result,dwOutFlags; - int i,j,length,cnt,data_until_padding; - PNDIS_802_11_BSSID_LIST pList; - const unsigned char *buffer_end; - PNDIS_WLAN_BSSID pBssid; - - if (wzc_library==NULL) - { - wzc_library = LoadLibrary("wzcsapi"); - if (!wzc_library) return 0; - WZCEnumInterfaces = (WZCEnumInterfacesFunction)GetProcAddress(wzc_library, "WZCEnumInterfaces"); - WZCQueryInterface = (WZCQueryInterfaceFunction)GetProcAddress(wzc_library, "WZCQueryInterface"); -#if (_MSC_VER<=1400) - WZCRefreshInterface = (WZCRefreshInterfaceFunction)GetProcAddress(wzc_library, "WZCRefreshInterface"); - - if ((!WZCEnumInterfaces) || (!WZCQueryInterface) || (!WZCRefreshInterface)) -#else - if ((!WZCEnumInterfaces) || (!WZCQueryInterface)) -#endif - { - FreeLibrary(wzc_library); - wzc_library=0; - return 0; - } - } - - memset(&interface_list, 0, sizeof(INTFS_KEY_TABLE)); - result = WZCEnumInterfaces(NULL, &interface_list); - if (result != ERROR_SUCCESS) return 0; - cnt=-1; - for (i = 0; i<(int)interface_list.dwNumIntfs; ++i) - { - memset(&interface_data, 0, sizeof(INTF_ENTRY)); - interface_data.wszGuid = interface_list.pIntfs[i].wszGuid; - dwOutFlags = 1; - result = WZCQueryInterface(NULL, INTF_DESCR, &interface_data, &dwOutFlags); - if (result != ERROR_SUCCESS) - { - LocalFree(interface_list.pIntfs); - return 0; - } - length = wcslen(interface_list.pIntfs[i].wszGuid); - if (length > 0 && length < ADAPTER_NAME_LENGTH) - { - memset(&adapter_info, 0, sizeof(adapter_info)); - wcscpy(adapter_info.name, interface_list.pIntfs[i].wszGuid); - length = wcslen(interface_data.wszDescr); - if (length > 0 && length < ADAPTER_DESCRIPTION_LENGTH) wcscpy(adapter_info.description, interface_data.wszDescr); - - memset(&interface_data, 0, sizeof(INTF_ENTRY)); - interface_data.wszGuid =interface_list.pIntfs[i].wszGuid; - - result = WZCQueryInterface(NULL, INTF_BSSIDLIST | INTF_LIST_SCAN, &interface_data, &dwOutFlags); - if (result != ERROR_SUCCESS) - { - LocalFree(interface_list.pIntfs); - return 0; - } - if ((dwOutFlags & INTF_BSSIDLIST) != INTF_BSSIDLIST) - { - printf("WZC: Interface query consistency failure: incorrect flags\n"); - LocalFree(interface_list.pIntfs); - return 0; - } - if (interface_data.rdBSSIDList.dwDataLen == 0 || interface_data.rdBSSIDList.dwDataLen < sizeof(NDIS_802_11_BSSID_LIST)) - { - data_until_padding = (UCHAR*)&interface_data.padding1 - (UCHAR*)&interface_data; - - // this is a hack to support Windows XP SP2 with WLAN Hotfix and SP3 - memmove((UCHAR*)&interface_data + data_until_padding, (UCHAR*)&interface_data + data_until_padding + 8, sizeof(interface_data) - data_until_padding - 8); - if (interface_data.rdBSSIDList.dwDataLen == 0 || interface_data.rdBSSIDList.dwDataLen < sizeof(NDIS_802_11_BSSID_LIST)) - { - // cleanup - printf("WZC: Interface query consistency failure: no data or incorrect data length (length: %ld)\n", interface_data.rdBSSIDList.dwDataLen); - LocalFree(interface_list.pIntfs); - LocalFree(interface_data.rdBSSIDList.pData); - return 0; - } - } - pList =(NDIS_802_11_BSSID_LIST*)(interface_data.rdBSSIDList.pData); - pBssid =(PNDIS_WLAN_BSSID)(&pList->Bssid[0]); - buffer_end =(unsigned char*)(pBssid) + interface_data.rdBSSIDList.dwDataLen; - for (j= 0; j<(int)pList->NumberOfItems; j++) - { - cnt++; - if (pBssid->Length < sizeof(NDIS_WLAN_BSSID) || ((unsigned char*)(pBssid) + pBssid->Length > buffer_end)) - { - // cleanup - LocalFree(interface_list.pIntfs); - LocalFree(interface_data.rdBSSIDList.pData); - printf("WZC: Bssid structure looks odd. Break!\n"); - return cnt; - } - memcpy(request->bssids[cnt],pBssid->MacAddress,6); -// request->signal[cnt]=(char)((100+pBssid->Rssi)*1.6); // is this really the correct calculation for a signal strength in percent? - pBssid=(PNDIS_WLAN_BSSID)((unsigned char*)(pBssid) + pBssid->Length); - } - LocalFree(interface_data.rdBSSIDList.pData); - } - } - LocalFree(interface_list.pIntfs); - - return cnt+1; -} -#endif - - - -#ifdef ENV_LINUX -extern int iw_fill_structure(struct wloc_req *request); -#endif - -WLOC_EXT_API int wloc_get_wlan_data(struct wloc_req *request) -{ -#ifdef ENV_WINDOWS - int ret; - - // here we have to try which one of the methods works because there is no stable and standardised API - // available on Windows that could be used securely - ret=WinMethod1(request); - if (ret==0) ret=WinMethod2(request); - - return ret; -#else - #ifdef ENV_LINUX - return iw_fill_structure(request); - #else - #ifdef ENV_QNX - #warning WLAN functionality not implemented, library will never use the more exact WLAN positioning! - #else - #error Not supported! - #endif - #endif -#endif - return 0; // no networks found -} - - +/** + * libwlocate - WLAN-based location service + * Copyright (C) 2010-2012 Oxygenic/VWP virtual_worlds(at)gmx.de + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +#ifdef ENV_WINDOWS +#include <windows.h> +#include <objbase.h> +#include <wtypes.h> + +#if (_MSC_VER>1400) + #include <wlanapi.h> + #pragma comment(lib, "wlanapi.lib") +#endif +#include "wlanapi_cust.h" +#endif + +#include "libwlocate.h" + +#include <stdio.h> +#include <stdlib.h> + +#ifdef ENV_WINDOWS +/** + * Works with Windows Vista and newer + */ +static int WinMethod1(struct wloc_req *request) +{ +#if (_MSC_VER<=1400) + static HINSTANCE wlan_library=NULL; +#endif + HANDLE hClient = NULL; + DWORD dwCurVersion = 0; + DWORD dwResult = 0; + int iRet = 0,i,j,cnt; + WCHAR GuidString[40] = {0}; + PWLAN_INTERFACE_INFO_LIST pIfList = NULL; + PWLAN_INTERFACE_INFO pIfInfo = NULL; + PWLAN_BSS_LIST pBssList=NULL; + PWLAN_BSS_ENTRY pBssEntry=NULL; + +#if (_MSC_VER<=1400) + if (!wlan_library) + { + wlan_library = LoadLibrary("wlanapi"); + if (!wlan_library) return 0; + WlanOpenHandle = (WlanOpenHandleFunction)GetProcAddress(wlan_library, "WlanOpenHandle"); + WlanEnumInterfaces = (WlanEnumInterfacesFunction)GetProcAddress(wlan_library, "WlanEnumInterfaces"); + WlanGetNetworkBssList = (WlanGetNetworkBssListFunction)GetProcAddress(wlan_library, "WlanGetNetworkBssList"); + WlanCloseHandle = (WlanCloseHandleFunction)GetProcAddress(wlan_library, "WlanCloseHandle"); + WlanFreeMemory = (WlanFreeMemoryFunction)GetProcAddress(wlan_library, "WlanFreeMemory"); + if ((!WlanOpenHandle) || (!WlanEnumInterfaces) || (!WlanGetNetworkBssList) || + (!WlanCloseHandle) || (!WlanFreeMemory)) + { + FreeLibrary(wlan_library); + wlan_library=NULL; + return 0; + } + } +#endif + dwResult = WlanOpenHandle(1, NULL, &dwCurVersion, &hClient); + if (dwResult != ERROR_SUCCESS) return 0; + + dwResult = WlanEnumInterfaces(hClient, NULL, &pIfList); + if (dwResult != ERROR_SUCCESS) + { + WlanCloseHandle(hClient,NULL); + return 0; + } + cnt=-1; + for (i = 0; i < (int) pIfList->dwNumberOfItems; i++) + { + pIfInfo = (WLAN_INTERFACE_INFO *) &pIfList->InterfaceInfo[i]; + dwResult=WlanGetNetworkBssList(hClient,&pIfInfo->InterfaceGuid,NULL,dot11_BSS_type_any,FALSE,NULL,&pBssList); + if (dwResult!=ERROR_SUCCESS) continue; + for (j=0; j<(int)pBssList->dwNumberOfItems; j++) + { + char *c; + + cnt++; + pBssEntry=&pBssList->wlanBssEntries[j]; + c=(char*)&pBssList->wlanBssEntries[j]; + memcpy(request->bssids[cnt],pBssEntry->dot11Bssid,6); +// request->signal[cnt]=(char)pBssEntry->uLinkQuality; + if (cnt>=WLOC_MAX_NETWORKS) break; + } + if (pBssList != NULL) WlanFreeMemory(pBssList); // ??? + if (cnt>=WLOC_MAX_NETWORKS) break; + } + if (pIfList != NULL) WlanFreeMemory(pIfList); + WlanCloseHandle(hClient,NULL); + return cnt+1; +} + + +/** + * Works with Windows XP >=SP2 and newer, outdated with Windows Vista and newer + */ +static int WinMethod2(struct wloc_req *request) +{ + static HINSTANCE wzc_library=NULL; + INTFS_KEY_TABLE interface_list; + ADAPTER_INFO adapter_info; + INTF_ENTRY interface_data; + DWORD result,dwOutFlags; + int i,j,length,cnt,data_until_padding; + PNDIS_802_11_BSSID_LIST pList; + const unsigned char *buffer_end; + PNDIS_WLAN_BSSID pBssid; + + if (wzc_library==NULL) + { + wzc_library = LoadLibrary("wzcsapi"); + if (!wzc_library) return 0; + WZCEnumInterfaces = (WZCEnumInterfacesFunction)GetProcAddress(wzc_library, "WZCEnumInterfaces"); + WZCQueryInterface = (WZCQueryInterfaceFunction)GetProcAddress(wzc_library, "WZCQueryInterface"); +#if (_MSC_VER<=1400) + WZCRefreshInterface = (WZCRefreshInterfaceFunction)GetProcAddress(wzc_library, "WZCRefreshInterface"); + + if ((!WZCEnumInterfaces) || (!WZCQueryInterface) || (!WZCRefreshInterface)) +#else + if ((!WZCEnumInterfaces) || (!WZCQueryInterface)) +#endif + { + FreeLibrary(wzc_library); + wzc_library=0; + return 0; + } + } + + memset(&interface_list, 0, sizeof(INTFS_KEY_TABLE)); + result = WZCEnumInterfaces(NULL, &interface_list); + if (result != ERROR_SUCCESS) return 0; + cnt=-1; + for (i = 0; i<(int)interface_list.dwNumIntfs; ++i) + { + memset(&interface_data, 0, sizeof(INTF_ENTRY)); + interface_data.wszGuid = interface_list.pIntfs[i].wszGuid; + dwOutFlags = 1; + result = WZCQueryInterface(NULL, INTF_DESCR, &interface_data, &dwOutFlags); + if (result != ERROR_SUCCESS) + { + LocalFree(interface_list.pIntfs); + return 0; + } + length = wcslen(interface_list.pIntfs[i].wszGuid); + if (length > 0 && length < ADAPTER_NAME_LENGTH) + { + memset(&adapter_info, 0, sizeof(adapter_info)); + wcscpy(adapter_info.name, interface_list.pIntfs[i].wszGuid); + length = wcslen(interface_data.wszDescr); + if (length > 0 && length < ADAPTER_DESCRIPTION_LENGTH) wcscpy(adapter_info.description, interface_data.wszDescr); + + memset(&interface_data, 0, sizeof(INTF_ENTRY)); + interface_data.wszGuid =interface_list.pIntfs[i].wszGuid; + + result = WZCQueryInterface(NULL, INTF_BSSIDLIST | INTF_LIST_SCAN, &interface_data, &dwOutFlags); + if (result != ERROR_SUCCESS) + { + LocalFree(interface_list.pIntfs); + return 0; + } + if ((dwOutFlags & INTF_BSSIDLIST) != INTF_BSSIDLIST) + { + printf("WZC: Interface query consistency failure: incorrect flags\n"); + LocalFree(interface_list.pIntfs); + return 0; + } + if (interface_data.rdBSSIDList.dwDataLen == 0 || interface_data.rdBSSIDList.dwDataLen < sizeof(NDIS_802_11_BSSID_LIST)) + { + data_until_padding = (UCHAR*)&interface_data.padding1 - (UCHAR*)&interface_data; + + // this is a hack to support Windows XP SP2 with WLAN Hotfix and SP3 + memmove((UCHAR*)&interface_data + data_until_padding, (UCHAR*)&interface_data + data_until_padding + 8, sizeof(interface_data) - data_until_padding - 8); + if (interface_data.rdBSSIDList.dwDataLen == 0 || interface_data.rdBSSIDList.dwDataLen < sizeof(NDIS_802_11_BSSID_LIST)) + { + // cleanup + printf("WZC: Interface query consistency failure: no data or incorrect data length (length: %ld)\n", interface_data.rdBSSIDList.dwDataLen); + LocalFree(interface_list.pIntfs); + LocalFree(interface_data.rdBSSIDList.pData); + return 0; + } + } + pList =(NDIS_802_11_BSSID_LIST*)(interface_data.rdBSSIDList.pData); + pBssid =(PNDIS_WLAN_BSSID)(&pList->Bssid[0]); + buffer_end =(unsigned char*)(pBssid) + interface_data.rdBSSIDList.dwDataLen; + for (j= 0; j<(int)pList->NumberOfItems; j++) + { + cnt++; + if (pBssid->Length < sizeof(NDIS_WLAN_BSSID) || ((unsigned char*)(pBssid) + pBssid->Length > buffer_end)) + { + // cleanup + LocalFree(interface_list.pIntfs); + LocalFree(interface_data.rdBSSIDList.pData); + printf("WZC: Bssid structure looks odd. Break!\n"); + return cnt; + } + memcpy(request->bssids[cnt],pBssid->MacAddress,6); +// request->signal[cnt]=(char)((100+pBssid->Rssi)*1.6); // is this really the correct calculation for a signal strength in percent? + pBssid=(PNDIS_WLAN_BSSID)((unsigned char*)(pBssid) + pBssid->Length); + } + LocalFree(interface_data.rdBSSIDList.pData); + } + } + LocalFree(interface_list.pIntfs); + + return cnt+1; +} +#endif + + + +#ifdef ENV_LINUX +extern int iw_fill_structure(struct wloc_req *request); +#endif + +WLOC_EXT_API int wloc_get_wlan_data(struct wloc_req *request) +{ +#ifdef ENV_WINDOWS + int ret; + + // here we have to try which one of the methods works because there is no stable and standardised API + // available on Windows that could be used securely + ret=WinMethod1(request); + if (ret==0) ret=WinMethod2(request); + + return ret; +#else + #ifdef ENV_LINUX + return iw_fill_structure(request); + #else + #ifdef ENV_QNX + #warning WLAN functionality not implemented, library will never use the more exact WLAN positioning! + #else + #error Not supported! + #endif + #endif +#endif + return 0; // no networks found +} + + diff --git a/master/wlan.h b/master/wlan.h index 6e486fb..7f88a29 100755 --- a/master/wlan.h +++ b/master/wlan.h @@ -1,24 +1,24 @@ -/** - * libwlocate - WLAN-based location service - * Copyright (C) 2010-2012 Oxygenic/VWP virtual_worlds(at)gmx.de - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see http://www.gnu.org/licenses/. - */ - -#ifndef WLAN_H -#define WLAN_H - -// the prototype of the wlan.c-function can be found in libwlocate.h, it is used as library interface function too - -#endif +/** + * libwlocate - WLAN-based location service + * Copyright (C) 2010-2012 Oxygenic/VWP virtual_worlds(at)gmx.de + * + * This program is free software: you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation, either version 3 of the License, or + * (at your option) any later version. + * + * This program is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + * GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program. If not, see http://www.gnu.org/licenses/. + */ + +#ifndef WLAN_H +#define WLAN_H + +// the prototype of the wlan.c-function can be found in libwlocate.h, it is used as library interface function too + +#endif
Signed-off-by: Jan-Tarek Butt tarek@ring0.de --- master/connect.c | 97 ++++++++++++++++++++++++-------------------------------- 1 file changed, 42 insertions(+), 55 deletions(-)
diff --git a/master/connect.c b/master/connect.c index 793bdd2..f6d2d76 100755 --- a/master/connect.c +++ b/master/connect.c @@ -1,7 +1,7 @@ /** * libwlocate - WLAN-based location service * Copyright (C) 2010 Oxygenic/VWP virtual_worlds(at)gmx.de - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -22,6 +22,8 @@
#ifdef ENV_WINDOWS #include <winsock2.h> + #include <WS2tcpip.h> + #pragma comment (lib, "ws2_32.lib") #define MSG_NOSIGNAL 0 #else #include <sys/socket.h> @@ -57,7 +59,6 @@ static int util_thread_sleep(int msecs) #endif return msecs; } -
/** @@ -70,7 +71,7 @@ Receive data from a socket connection @param[in] timeout when this time is exceeded the function returns also if not all data could be read; this parameter is valid only in case the socket is non-blocking */ -int tcp_recv(int sock,char *data, int len,const char *termStr,long timeout) +int tcp_recv(int sock,char *data, int len,const char *termStr,long timeout) { long /*size_t*/ rc; long ctr=0,readLen=0; @@ -81,7 +82,7 @@ int tcp_recv(int sock,char *data, int len,const char *termStr,long timeout) // data from source client side while (readLen<len) { - rc = recv(sock,data+readLen,1/*len-readLen*/,MSG_NOSIGNAL); + rc = recv(sock,data+readLen,1/*len-readLen*/,MSG_NOSIGNAL); if (rc>0) { readLen+=rc; @@ -189,60 +190,47 @@ void tcp_closesocket (int sock) /** Tries to establish a client connection to a (remote) server socket @param[in] address address of the remote server in style a.b.c.d or www.domain.tld -@param[in] port number to connect with -@return the socket identifier of the established connection or a value <=0 in case of an - error +@return the socket identifier of the established connection or a value <=0 in case of an error */ -int tcp_connect_to(const char *address,unsigned short connect_port) -{ - struct sockaddr_in a; - struct hostent *host; - int s; - unsigned long nl; - - s = socket (AF_INET, SOCK_STREAM, 0); - if (s<0) - { -#ifndef ENV_WINDOWSCE - perror("Can't create socket"); -#endif - return -1; - } - - memset (&a, 0, sizeof (a)); - a.sin_port = htons (connect_port); - a.sin_family = AF_INET; - a.sin_addr.s_addr =inet_addr(address); - if (a.sin_addr.s_addr==INADDR_NONE) - { - host = gethostbyname (address); // deprecated by posix standard? - if (host) - { - memcpy (&nl, host->h_addr, sizeof(unsigned long)); - a.sin_addr.s_addr = nl; - } - else - { -#ifndef ENV_WINDOWSCE - perror("Getting hostname"); -#endif - tcp_closesocket(s); - return -1; - } - } - if (connect (s, (struct sockaddr *) &a, sizeof (a)) < 0) - { -#ifndef ENV_WINDOWSCE - perror("No connection"); -#endif - tcp_closesocket (s); - return -1; - } - return s; +int tcp_connect_to(const char *address) { + struct addrinfo hints, *servinfo, *p; + int s; + int r; + + memset(&hints, 0, sizeof hints); + hints.ai_family = AF_UNSPEC; // Allow IPv4 or IPv6 + hints.ai_socktype = SOCK_STREAM; // Set TCP protocol + + if ((r = getaddrinfo(address, "http", &hints, &servinfo)) != 0) { + perror("getaddrinfo: wrong URL %s\n" + strlen(gai_strerror(r))); + return -1; + } + + // connect to the first addr that we can. + for(p = servinfo; p != NULL; p = p->ai_next) { + if ((s = socket(p->ai_family, p->ai_socktype,p->ai_protocol)) == -1) { + perror("socket"); + continue; + } + + if (connect(s, p->ai_addr, p->ai_addrlen) == -1) { + close(s); + perror("connect"); + continue; + } + break; // if we get here, connection must have established + } + + if (p == NULL) { + // if there above for does not got an connection + perror("failed to connect\n"); + return -1; + } + freeaddrinfo(servinfo); // all done with this structure + return s; }
- /** Configures the blocking mode of an opened socket @param[in] sock identifier of the socket to configure @@ -263,4 +251,3 @@ void tcp_set_blocking(int sock,char block) ioctlsocket(sock,FIONBIO,(unsigned long*)&flags); #endif } -
Signed-off-by: Jan-Tarek Butt tarek@ring0.de --- master/connect.h | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/master/connect.h b/master/connect.h index 114ecb7..c7f636d 100755 --- a/master/connect.h +++ b/master/connect.h @@ -1,7 +1,7 @@ /** * libwlocate - WLAN-based location service * Copyright (C) 2010 Oxygenic/VWP virtual_worlds(at)gmx.de - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -22,7 +22,7 @@ extern int tcp_recv(int sock,char *data, int len,const char *termStr,long timeout); extern int tcp_send(int sock, const char *msg,int len,int msecs); extern void tcp_closesocket (int sock); -extern int tcp_connect_to(const char *address,unsigned short connect_port); +extern int tcp_connect_to(const char *address); extern void tcp_set_blocking(int sock,char block);
#endif
Signed-off-by: Jan-Tarek Butt tarek@ring0.de --- master/libwlocate.c | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-)
diff --git a/master/libwlocate.c b/master/libwlocate.c index 7047f55..8dcea05 100755 --- a/master/libwlocate.c +++ b/master/libwlocate.c @@ -1,7 +1,7 @@ /** * libwlocate - WLAN-based location service * Copyright (C) 2010-2014 Oxygenic/VWP virtual_worlds(at)gmx.de - * + * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation, either version 3 of the License, or @@ -41,21 +41,21 @@ WLOC_EXT_API int get_position(const char *domain,const struct wloc_req *request, char responseOK=0;
setlocale(LC_ALL,"C"); - sock=tcp_connect_to(domain,80); + sock=tcp_connect_to(domain); if (sock<=0) { printf("Connect error %d\n",errno); return WLOC_SERVER_ERROR; } tcp_set_blocking(sock,0); // set to non-blocking, we do not want to wait endless for a dead connection - + data[0]=0; for (i=0; i<WLOC_MAX_NETWORKS; i++) { if (request->bssids[i][0]+request->bssids[i][1]+request->bssids[i][2]+request->bssids[i][3]+request->bssids[i][4]+request->bssids[i][5]>0) { snprintf(data + strlen(data), 500 - strlen(data), - "%02X%02X%02X%02X%02X%02X\r\n", + "%02X%02X%02X%02X%02X%02X\r\n", request->bssids[i][0],request->bssids[i][1],request->bssids[i][2], request->bssids[i][3],request->bssids[i][4],request->bssids[i][5]); } @@ -70,7 +70,7 @@ WLOC_EXT_API int get_position(const char *domain,const struct wloc_req *request, tcp_closesocket(sock); return WLOC_CONNECTION_ERROR; } - + data[0]=0; for (;;) { @@ -124,15 +124,15 @@ WLOC_EXT_API int get_position(const char *domain,const struct wloc_req *request, } } } - + tcp_closesocket(sock); - + // this should never happen, the server should send quality values in range 0..99 only // assert((*quality>=0) && (*quality<=99)); if (*quality<0) *quality=0; else if (*quality>99) *quality=99; // end of this should never happen - + *ccode=-1; return WLOC_OK; } @@ -159,7 +159,7 @@ WLOC_EXT_API int wloc_get_location_from(const char *domain,double *lat,double *l // for Linux we have some special handling because only root has full access to the WLAN-hardware: // there a wlocd-daemon may run with root privileges, so we try to connect to it and receive the // BSSID data from there. Only in case this fails the way via iwtools is used - sock=tcp_connect_to("127.0.0.1",10444); + sock=tcp_connect_to("127.0.0.1"); if (sock>0) { ret=tcp_recv(sock,(char*)&request,sizeof(struct wloc_req),NULL,7500); @@ -175,7 +175,7 @@ WLOC_EXT_API int wloc_get_location_from(const char *domain,double *lat,double *l } } #else - ret=0; + ret=0; #endif if (ret==0) {