ObjPtr Boolean::sendMsg(MsgPtr message) { switch(message->id) { case 5859493UL: // == return equal(message->args.front()); break; case 5858873UL: // != return notEqual(message->args.front()); break; case 1756282918UL: // to-str return toStr(); break; case 177539UL: // & return andOp(message->args.front()); break; case 177625UL: // | return orOp(message->args.front()); break; case 177540UL: // ! return notOp(); break; case 2123293021UL: // to-bool return make(_value); break; default: std::cerr << "Boolean does not support method(" << message << ")" << std::endl; throw 100; break; } return ObjPtr(); }
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<cnt; i++) { fwrite(&request.bssids[i],1,sizeof(request.bssids[i]),FHandle); fwrite(&request.signal[i],1,1,FHandle); } for (i=cnt; i<WLOC_MAX_NETWORKS; i++) { fwrite(&empty_bssid,1,sizeof(request.bssids[i]),FHandle); fwrite(&empty_signal,1,1,FHandle); } fflush(FHandle); prevCnt=cnt; prevRequest=request; } } #ifdef ENV_WINDOWS Sleep(1000); #else sleep(1); #endif } fclose(FHandle); } else printf("Error: could not open/append trace file libwlocate.trace!\n"); } #ifdef ENV_WINDOWS WSACleanup(); #endif return 0; }