From: <kev...@us...> - 2003-10-22 07:30:48
|
Update of /cvsroot/bidwatcher/bidwatcher In directory sc8-pr-cvs1:/tmp/cvs-serv28726 Modified Files: Tag: STABLE_1_3 bidwatcher.cpp bidwatcher.h helpers.cpp netstuff.cpp Log Message: Changed DPRINTF to be comply with older specs where variadic macros were not allowed. This should work better with the compaq c++ compiler. Index: bidwatcher.cpp =================================================================== RCS file: /cvsroot/bidwatcher/bidwatcher/Attic/bidwatcher.cpp,v retrieving revision 1.171.2.6 retrieving revision 1.171.2.7 diff -u -d -r1.171.2.6 -r1.171.2.7 --- bidwatcher.cpp 17 Oct 2003 20:56:34 -0000 1.171.2.6 +++ bidwatcher.cpp 22 Oct 2003 04:37:48 -0000 1.171.2.7 @@ -34,7 +34,6 @@ #include <sys/time.h> #include <sys/socket.h> #include <stdlib.h> -#include <stdio.h> #include <netdb.h> // Handle strict Ansi compliance with gcc 3.1 while retaining @@ -91,21 +90,6 @@ // This should probably get turned off for normal builds. // #define DEBUG_NETWORK -void DPRINTF(gchar *file, - int line, - unsigned short usDbgLevel, - gchar *pcszFormat, - ...) { -#if (DEBUGGING >= 0) - if(DEBUGGING >= usDbgLevel) { - va_list vl; - va_start(vl, pcszFormat); - Logger(file, line, pcszFormat, vl); - va_end(vl); - } -#endif -} - bool dbug = FALSE; bool configOpen=FALSE; bool commentOpen=FALSE; @@ -274,30 +258,6 @@ // Thanks to Bob Beaty -FILE *logger_out = 0; - - -// Thanks to pfv -int Logger(gchar *file, int line, gchar *format, va_list ap) -{ - gint n; - -#if DEBUGGING>=DLOW - char *timeBuff; - timeBuff = getTimeStamp(); -#endif - - if (!logger_out) - logger_out = stderr; - fprintf(logger_out, LOCUS, file, line -#if DEBUGGING>=DLOW - , timeBuff -#endif - ); - n = vfprintf(logger_out, format, ap); - return n; -} - /* * getTimeStamp * Construct a current timestamp for us. @@ -345,7 +305,7 @@ len = strlen(ERR_STRING) + strlen(arg) + 1; err = (char *) malloc(len); snprintf(err, len, "%s%s", ERR_STRING, arg); - DPRINTF(__HERE__, DLOW, "ErrorArg: %s || ErrorPassed: %s\n", arg, err); + DPRINTF(DLOW, ("ErrorArg: %s || ErrorPassed: %s\n", arg, err)); showBidStatus(err, TRUE); } @@ -384,7 +344,7 @@ // static buffer or something. int len = strlen(ERR_STRING) + strlen(arg) + 1; - DPRINTF(__HERE__, DLOW, "errLen = %i\n", len); + DPRINTF(DLOW, ("errLen = %i\n", len)); stat->msg = (char *) malloc(len); memset(stat->msg, 0, len); strncpy(stat->msg, arg, strlen(arg)); @@ -540,7 +500,7 @@ break; default: showError("Update failed: Network error"); - DPRINTF(__HERE__, DHIGH, "getuserbids2 returned %d\n", retval); + DPRINTF(DHIGH, ("getuserbids2 returned %d\n", retval)); } if (aucIdx != 0) Update(-1, FALSE); @@ -763,7 +723,7 @@ } snipebuff[x] = 0; - DPRINTF(__HERE__, DLOW, "Snipe key is %s\n", snipebuff); + DPRINTF(DLOW, ("Snipe key is %s\n", snipebuff)); strcpy(snipeKey, snipebuff); sprintf(lineBuff, "Pre-bid on %lu SUCCEEDED: %d at %.2f", ItemNumber, snipeQty, snipeAmount); @@ -773,7 +733,7 @@ ItemNumber, returnVal); } showBidStatus(lineBuff, FALSE); - DPRINTF(__HERE__, DHIGH, "%s\n", lineBuff); + DPRINTF(DHIGH, ("%s\n", lineBuff)); free(Buff); } @@ -792,7 +752,7 @@ url, ItemNumber, snipeKey, authID, authPASS, snipeAmount, snipeQty); - DPRINTF(__HERE__, DHIGH, "Bid(%s)\n", bidurl->url); + DPRINTF(DHIGH, ("Bid(%s)\n", bidurl->url)); g_free(url); @@ -1141,7 +1101,7 @@ /* gdk_font_unref(fixed_font); gdk_font_unref(clean14); - DPRINTF(__HERE__, 1, "Using: %s\n", gtk_entry_get_text(GTK_ENTRY(confwindow->fontfixtext))); + DPRINTF(DLOW, ("Using: %s\n", gtk_entry_get_text(GTK_ENTRY(confwindow->fontfixtext)))); fixed_font = gdk_font_load(gtk_entry_get_text(GTK_ENTRY(confwindow->fontfixtext))); clean14 = gdk_font_load(gtk_entry_get_text(GTK_ENTRY(confwindow->fontcleantext))); @@ -1741,7 +1701,7 @@ "Snipe Key :\n"); char info[256]; - DPRINTF(__HERE__, DLOW, "myauc->CurrentBid == %.2f\n", myauc->CurrentBid); + DPRINTF(DLOW, ("myauc->CurrentBid == %.2f\n", myauc->CurrentBid)); sprintf(info, "Item Number : %lu", myauc->ItemNumber); gtk_window_set_title(GTK_WINDOW(window), info); @@ -2788,7 +2748,7 @@ fprintf(file, " mybid %.2f %d\n", auction[i]->myBidAmount, auction[i]->myBidQuantity); #ifdef DEBUGCONFIG - DPRINTF(__HERE__, DMED, " writing: mybid %.2f %d\n",auction[i]->myBidAmount, auction[i]->myBidQuantity); + DPRINTF(DMED, (" writing: mybid %.2f %d\n",auction[i]->myBidAmount, auction[i]->myBidQuantity)); #endif if (auction[i]->isSnipe) fprintf(file, " snipe %.2f %d\n",auction[i]->snipeAmount, auction[i]->snipeQty); @@ -3209,7 +3169,7 @@ // caller having to do it themselves. If we did not do it this way the // caller would have to duplicate this loop if he did not want to take // the chance of the user seeing an "error" message. - DPRINTF(__HERE__, DLOW, "The auction %d is already in the list.\n", auction[i]->ItemNumber); + DPRINTF(DLOW, ("The auction %d is already in the list.\n", auction[i]->ItemNumber)); showStatus(" adding auction..."); updateInProgress = FALSE; return; @@ -3430,11 +3390,11 @@ if (bigUpdate()) { // Try again later. gtk_timeout_add(2*60*1000, bigdelay_callback, NULL); - DPRINTF(__HERE__, DHIGH, "Next bigUpdate() in 2 minutes.\n"); + DPRINTF(DHIGH, ("Next bigUpdate() in 2 minutes.\n")); } else { gtk_timeout_add(BIGDELAY, bigdelay_callback, NULL); - DPRINTF(__HERE__, DHIGH, "Next bigUpdate() in %i minutes.\n", - BIGDELAY/60/1000); + DPRINTF(DHIGH, ("Next bigUpdate() in %i minutes.\n", + BIGDELAY/60/1000)); } return FALSE; @@ -3667,7 +3627,7 @@ recognized = 1; } - if (!recognized) DPRINTF(__HERE__, DHIGH, "Unrecognized option %s\n",which); + if (!recognized) DPRINTF(DHIGH, ("Unrecognized option %s\n", which)); } else if (!strcasecmp(keyword, "user")) { fscanf(file, "%s %s", authID, authPASS); @@ -3917,7 +3877,7 @@ Buff = StripAndTab(Buff2); free(Buff2); ids = ParseList(Buff); - //DPRINTF(__HERE__, 1, "Buff=%s\n", Buff); + //DPRINTF(DLOW, ("Buff=%s\n", Buff)); free(Buff); if (ids[0] == 0) { // This is OK, we just have no items bid on. @@ -3964,7 +3924,7 @@ if (!trackListings) return GUA_SUCCESS; - DPRINTF(__HERE__, DMED, "Getting user listings.\n"); + DPRINTF(DMED, ("Getting user listings.\n")); if (strlen(authID) < 2) return -1; @@ -3982,7 +3942,7 @@ blackLED(); showStatus(""); - DPRINTF(__HERE__, DLOW, "GetUserListings.returnval=%i\n", returnVal); + DPRINTF(DLOW, ("GetUserListings.returnval=%i\n", returnVal)); if (returnVal != NET_SUCCESS) { free(Buff); @@ -4355,7 +4315,7 @@ struct tm * timeStruct = localtime(&time_now); gmt_time = timeStruct->tm_gmtoff; if (timeStruct->tm_isdst) { - DPRINTF(__HERE__, DHIGH, "Adjusted for DST\n"); + DPRINTF(DHIGH, ("Adjusted for DST\n")); gmt_time -= 60*60; // correct for daylight saving time } #elif defined(HAVE_TZNAME) // this may not work... @@ -4640,7 +4600,7 @@ // not using this for now. compile with -DDEBUGGING=# for now. // if (argc > 1 && !strcmp(argv[1], "-d")) dbug = TRUE; - DPRINTF(__HERE__, DHIGH, "Debugging Engaged...\n"); + DPRINTF(DHIGH, ("Debugging Engaged...\n")); fixed_font = gdk_font_load("-*-fixed-medium-r-normal-*-*-120-*-*-c-*-iso8859-15"); clean14 = gdk_font_load("-misc-fixed-medium-r-normal-*-*-130-*-*-*-*-iso8859-15"); Index: bidwatcher.h =================================================================== RCS file: /cvsroot/bidwatcher/bidwatcher/Attic/bidwatcher.h,v retrieving revision 1.74.2.3 retrieving revision 1.74.2.4 diff -u -d -r1.74.2.3 -r1.74.2.4 --- bidwatcher.h 12 Oct 2003 04:17:19 -0000 1.74.2.3 +++ bidwatcher.h 22 Oct 2003 04:37:48 -0000 1.74.2.4 @@ -72,11 +72,9 @@ #define __HERE__ __FILE__, __LINE__ #define LOGIT(c) Logger ## c -void DPRINTF(gchar *file, - int line, - unsigned short usDbgLevel, - gchar *pcszFormat, - ...); + +#define LOGPREFIX printf(LOCUS, __HERE__, getTimeStamp()) +#define DPRINTF(n, d) if(DEBUGGING>=n) LOGPREFIX, printf d // is this the DEC c++ compiler? #if !defined (__DECCXX) @@ -88,9 +86,6 @@ # warning DEBUGGING is off. # endif #endif - -extern FILE *logger_out; /* default==stderr */ -int Logger(gchar *file, int line, gchar *format, va_list ap); extern double avg_load_time; Index: helpers.cpp =================================================================== RCS file: /cvsroot/bidwatcher/bidwatcher/Attic/helpers.cpp,v retrieving revision 1.90.2.4 retrieving revision 1.90.2.5 diff -u -d -r1.90.2.4 -r1.90.2.5 --- helpers.cpp 17 Oct 2003 17:50:58 -0000 1.90.2.4 +++ helpers.cpp 22 Oct 2003 04:37:48 -0000 1.90.2.5 @@ -543,7 +543,7 @@ fprintf(stderr, "Bid failed - unable to parse eBay's response.\n"); - DPRINTF(__HERE__, DHIGH, "%s", Buff); + DPRINTF(DHIGH, ("%s", Buff)); return ERROR; } @@ -880,9 +880,9 @@ auc->CurrentBid = atof(buf); - DPRINTF(__HERE__, DLOW, "buf='%s'\n", buf); - DPRINTF(__HERE__, DLOW, "Price is '%.2f'/'%.2f'\n", auc->CurrentBid, auc->FirstBid); - DPRINTF(__HERE__, DLOW, "Currency is '%s'\n", auc->currency); + DPRINTF(DLOW, ("buf='%s'\n", buf)); + DPRINTF(DLOW, ("Price is '%.2f'/'%.2f'\n", auc->CurrentBid, auc->FirstBid)); + DPRINTF(DLOW, ("Currency is '%s'\n", auc->currency)); } ////////////////////////////////////////////////////////////////////////////// @@ -977,7 +977,7 @@ } } - DPRINTF(__HERE__, DHIGH, "Auction Type=%i\n", auc_type); + DPRINTF(DHIGH, ("Auction Type=%i\n", auc_type)); AuctionType = auc_type; while (streamBuff) { @@ -994,7 +994,7 @@ if (LineData[0]!=0) { int matchedPhrase = ReturnBidVarNum(LineData, auc_type); if (matchedPhrase != 0) - DPRINTF(__HERE__, DLOW, "MATCHED :%i (%s)\n", matchedPhrase, LineData); + DPRINTF(DLOW, ("MATCHED :%i (%s)\n", matchedPhrase, LineData)); //printf("LD:%s:%i\n", LineData, strlen(LineData)); @@ -1011,7 +1011,7 @@ if (!CurrentBid) { streamBuff.getline(LineData, 1024, '\n'); - DPRINTF(__HERE__, DLOW, "LDCB: %s\n", LineData); + DPRINTF(DLOW, ("LDCB: %s\n", LineData)); parseprice(LineData, this, FALSE); streamBuff.getline(LineData, 1024, '\n'); @@ -1029,13 +1029,13 @@ case 17: if (!FirstBid && !CurrentBid) { streamBuff.getline(LineData, 1024, '\n'); - DPRINTF(__HERE__, DLOW, "LDFB: %s\n", LineData); + DPRINTF(DLOW, ("LDFB: %s\n", LineData)); parseprice(LineData, this, TRUE); } break; case 20: // "Price:" - BuyItNow Only. case 28: - DPRINTF(__HERE__, DLOW, "This is a BuyItNow\n"); + DPRINTF(DLOW, ("This is a BuyItNow\n")); isBuyItNow = 1; reserveMet = 'b'; if (!CurrentBid && !FirstBid) { @@ -1056,7 +1056,7 @@ if (!BidCount) { char bc[80]; streamBuff.getline(LineData, 1024, '\n'); - DPRINTF(__HERE__, DLOW, "LDBC: %s\n", LineData); + DPRINTF(DLOW, ("LDBC: %s\n", LineData)); // if instead of the number of bids an item has "Purchases" and // there was no time left in the auction the auction is not endless if (!strncmp(LineData, "Purchases", strlen("Purchases")) && @@ -1068,7 +1068,7 @@ bc[cnt] = LineData[cnt]; bc[cnt] = 0; BidCount = atoi(bc); - DPRINTF(__HERE__, DLOW, "BidCount: %i\n", BidCount); + DPRINTF(DLOW, ("BidCount: %i\n", BidCount)); } } break; @@ -1106,7 +1106,7 @@ case 9: // time ending if (!Ends[0]) { //streamBuff.getline(LineData, 1024, '\n'); - //DPRINTF(__HERE__, DLOW, "LDE: %s\n", LineData); + //DPRINTF(DLOW, ("LDE: %s\n", LineData)); strncpy(Ends, LineData + strlen("Ends "), 50); translate_date(Ends); } @@ -1287,7 +1287,7 @@ // now We'll parse the High Bidder and Seller's ratings off their names // and assign them to .SellerRate and .BidderRate strcpy(newName, Seller); - DPRINTF(__HERE__, DLOW, "Seller: %s %s\n", Seller, SellerRate); + DPRINTF(DLOW, ("Seller: %s %s\n", Seller, SellerRate)); scratch = strtok(newName, " "); @@ -1327,7 +1327,7 @@ strcpy(BidderRate, "(0)"); } - DPRINTF(__HERE__, DLOW, "HighBidder: %s %s\n", HighBidder, BidderRate); + DPRINTF(DLOW, ("HighBidder: %s %s\n", HighBidder, BidderRate)); } return TRUE; @@ -1459,9 +1459,9 @@ time_t theTime = mktime(&ebay_time) - new_time_t; - DPRINTF(__HERE__, DHIGH, "Our time: %li eBay time: %li\n", + DPRINTF(DHIGH, ("Our time: %li eBay time: %li\n", new_time_t, - mktime(&ebay_time)); + mktime(&ebay_time))); return theTime; } Index: netstuff.cpp =================================================================== RCS file: /cvsroot/bidwatcher/bidwatcher/Attic/netstuff.cpp,v retrieving revision 1.46.2.2 retrieving revision 1.46.2.3 diff -u -d -r1.46.2.2 -r1.46.2.3 --- netstuff.cpp 12 Oct 2003 04:22:11 -0000 1.46.2.2 +++ netstuff.cpp 22 Oct 2003 04:37:48 -0000 1.46.2.3 @@ -110,7 +110,7 @@ URL::URL(char *newurl, URL *proxy) { - DPRINTF(__HERE__, DMED, "New URL(%s).\n", newurl); + DPRINTF(DMED, ("New URL(%s).\n", newurl)); hostinfo = (struct hostent *) malloc(sizeof(struct hostent)); memset(hostinfo, 0, sizeof(struct hostent)); numaddrs = 0; @@ -121,7 +121,7 @@ } URL::URL(char *newurl, URL *proxy, char *user, char *pass) { - DPRINTF(__HERE__, DMED, "New URL(%s).\n", newurl); + DPRINTF(DMED, ("New URL(%s).\n", newurl)); hostinfo = (struct hostent *) malloc(sizeof(struct hostent)); memset(hostinfo, 0, sizeof(struct hostent)); numaddrs = 0; @@ -134,7 +134,7 @@ URL::~URL() { // Clean this memory waster up. int i; - DPRINTF(__HERE__, DMED, "Destroying URL(%s)\n", url); + DPRINTF(DMED, ("Destroying URL(%s)\n", url)); // If we are using a proxy, don't kill this. if (!useproxy && hostinfo) { @@ -501,11 +501,11 @@ g_free(time_since_pkt); g_free(time_since_start); - DPRINTF(__HERE__, DLOW, "Redirection detected: %s%s\n", url->hoststring, url->url); + DPRINTF(DLOW, ("Redirection detected: %s%s\n", url->hoststring, url->url)); /* Terminal point for recursion. */ if (redir > MAX_REDIR) { - DPRINTF(__HERE__, DLOW, "Maximum redirection reached.\n"); + DPRINTF(DLOW, ("Maximum redirection reached.\n")); showError("Maximum redirection reached!"); return NET_MAXREDIR; } |