libwlocate-0.0git20130108/ 0000775 0001750 0001750 00000000000 12073004177 012634 5 ustar jr jr libwlocate-0.0git20130108/connect.h 0000775 0001750 0001750 00000002172 12073002423 014433 0 ustar jr jr /**
* 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 .
*/
#ifndef CONNECT_H
#define CONNECT_H
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 void tcp_set_blocking(int sock,char block);
#endif
libwlocate-0.0git20130108/libwlocate.vcproj 0000664 0001750 0001750 00000014340 12073002423 016200 0 ustar jr jr
libwlocate-0.0git20130108/trace.c 0000775 0001750 0001750 00000010331 12073002423 014067 0 ustar jr jr /**
* test for 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 .
*/
#include "libwlocate.h"
#include
#include
#include
#include
#include
#include
#include
#ifdef ENV_LINUX
#include
#endif
#ifdef ENV_WINDOWS
#include
#endif
char notEqual(struct wloc_req *data1,struct wloc_req *data2,int num)
{
int i,j;
for (i=0; isignal[i]!=data2->signal[i]) return 1;
for (j=0; j<6; j++)
{
if (data1->bssids[i][j]!=data2->bssids[i][j]) return 1;
}
}
return 0;
}
int main(int argc,char *argv[])
{
int ret,i,cnt=0,prevCnt=0;
double lat,lon;
char quality;
short ccode;
char country[3];
FILE *FHandle;
struct wloc_req request,prevRequest;
unsigned char empty_bssid[6]={0,0,0,0,0,0};
unsigned char empty_signal=0;
#ifdef ENV_WINDOWS
WSADATA wsaData;
WSAStartup((MAKEWORD(1, 1)), &wsaData);
#endif
if ((argc>1) && (strncmp(argv[1],"-h",2)==0)) // test WLAN geolocation instead of writing the WLAN data into a trace file
{
printf("lwtrace\n\tscan available WLAN networks, and write them into a file libwlocate.trace for later geolocation\n");
printf("lwtrace -t\n\ttest geolocation functionality and evaluate the current position out of available WLAN data immediately\n");
}
else if ((argc>1) && (strncmp(argv[1],"-t",2)==0)) // test WLAN geolocation instead of writing the WLAN data into a trace file
{
ret=wloc_get_location(&lat,&lon,&quality,&ccode); // call the library function to get the position...
//...check the return value afterwards...
if (ret==WLOC_CONNECTION_ERROR) printf("Error: could not communicate with server!\n");
else if (ret==WLOC_LOCATION_ERROR) printf("Error: could not calculate your location, the given WLAN networks are unknown!\n");
//...and print the position only in case the call was successful
else if (ret==WLOC_OK)
{
printf("Your location: %f (lat) %f (lon)\nQuality: %d %%\n",lat,lon,quality);
country[2]=0;
if (wloc_get_country_from_code(ccode,country)==WLOC_OK) printf("Country: %d - %s\n",ccode,country);
else printf("Country: unknown\n");
}
else printf("Error: failed due to an unknown error!\n");
}
else
{
FHandle=fopen("libwlocate.trace","ab");
if (FHandle)
{
memset(&prevRequest,0,sizeof(struct wloc_req));
while (true)
{
if (cnt>0)
{
if ((cnt==prevCnt) && (!notEqual(&request,&prevRequest,cnt)))
{
for (i=0; i