Author: biurrun Date: Thu Oct 22 16:16:18 2009 New Revision: 1289 Log: Replace ugly #ifdef + printf blocks by a proper dbg_printf macro. Modified: trunk/tools/iwlist_parser.c Modified: trunk/tools/iwlist_parser.c ============================================================================== --- trunk/tools/iwlist_parser.c Thu Oct 22 16:01:55 2009 (r1288) +++ trunk/tools/iwlist_parser.c Thu Oct 22 16:16:18 2009 (r1289) @@ -27,6 +27,12 @@ //#define USESTEP 0 //#define DEBUG 1 +#ifdef DEBUG +#define dbg_printf(...) printf(__VA_ARGS__) +#else +#define dbg_printf(...) +#endif + bool essidflag; //Look for one SSID only bool fileflag; //Use a file rather than stdin? bool selectByQualityFlag; @@ -146,9 +152,7 @@ char * pTokens = strtok(strBuffer, " "); while (pTokens != 0) { -#ifdef DEBUG - printf("Token is: %s\n", pTokens); -#endif + dbg_printf("Token is: %s\n", pTokens); //Parse Cell ID if (strcmp(pTokens, "Cell") == 0) { #ifdef USESTEP @@ -160,9 +164,7 @@ pTokens = strtok(NULL, " "); iCellNumber = atoi(pTokens); -#ifdef DEBUG - printf("Cell Nr. %i \n", iCellNumber); -#endif + dbg_printf("Cell Nr. %i \n", iCellNumber); step = 2; pTokens = strtok(NULL, " "); continue; @@ -179,9 +181,7 @@ pTokens = strtok(NULL, " "); strncpy(strMAC[iCellNumber - 1], pTokens, 17); -#ifdef DEBUG - printf("MAC Address %s \n", strMAC[iCellNumber - 1]); -#endif + dbg_printf("MAC Address %s \n", strMAC[iCellNumber - 1]); strMAC[iCellNumber - 1][17] = '\0'; step = 3; pTokens = strtok(NULL, " "); @@ -215,9 +215,7 @@ //iSignalStrength[iCellNumber - 1] = atoi(tmp); iQuality[iCellNumber-1] = atoi(tmp); -#ifdef DEBUG - printf("Quality: %i \n", iQuality[iCellNumber-1]); -#endif + dbg_printf("Quality: %i \n", iQuality[iCellNumber-1]); step = 1; pTokens = strtok(NULL, " "); continue; @@ -270,9 +268,7 @@ j++; } strEssid[iCellNumber - 1][j] = '\0'; -#ifdef DEBUG printf("Essid: %s \n", strEssid[iCellNumber-1]); -#endif step = 4; pTokens = strtok(NULL, " "); continue; @@ -305,9 +301,7 @@ if ( iQuality[i] > iBestQuality) { iBestQuality = iQuality[i]; iIndexCell = i; - #ifdef DEBUG - printf("Set index for best Cell to: %i\n", i); - #endif + dbg_printf("Set index for best Cell to: %i\n", i); foundBest = true; } } else { @@ -315,9 +309,7 @@ if ( iSignalStrength[i] != 0 && (int)iSignalStrength[i] > iBestStrength) { iBestStrength = iSignalStrength[i]; iIndexCell = i; - #ifdef DEBUG - printf("Set index for best Cell to: %i\n", i); - #endif + dbg_printf("Set index for best Cell to: %i\n", i); foundBest = true; }