From: Klaus S. <sin...@us...> - 2006-11-23 11:27:41
|
Update of /cvsroot/bidwatcher/bidwatcher In directory sc8-pr-cvs3.sourceforge.net:/tmp/cvs-serv29834 Modified Files: Tag: STABLE_1_3 helpers.cpp Log Message: changed wrong indenting to become more Unix/GNU style again faster skip, when shipment price is missing in auction fixed wrong dutch auction detection fixed private auction detection (didnt work anymore) Index: helpers.cpp =================================================================== RCS file: /cvsroot/bidwatcher/bidwatcher/Attic/helpers.cpp,v retrieving revision 1.90.2.72 retrieving revision 1.90.2.73 diff -u -d -r1.90.2.72 -r1.90.2.73 --- helpers.cpp 22 Nov 2006 20:39:19 -0000 1.90.2.72 +++ helpers.cpp 23 Nov 2006 11:27:38 -0000 1.90.2.73 @@ -1093,6 +1093,8 @@ } for(i = 0; i < num_ship; i++) { DPRINTF(DLOW, ("parsing: >%s<\n", LineData)); + if (*LineData == '\0') + break; if(!parseprice(currency[i], ship[i], LineData)) { DPRINTF(DLOW, ("shipment price=%0.2f\n", ship[i])); ship[i] = 0; @@ -1211,21 +1213,20 @@ streamBuff.getline(LineBuffer.buf(), LineBuffer.size(), '\n'); if ( strstr(LineBuffer.buf(),"Another buyer used Buy It Now to purchase the item immediately") == NULL ){ - scratch = strstr(Buff, "Another buyer used Buy It Now to purchase the item immediately"); - if (scratch != NULL) { - if (strlen(Comments) > 0) { - if ( strstr(Comments, "Sold! BuyitNow") == NULL) { - strcpy(scratch,"Sold! BuyitNow "); - strcat(scratch,Comments); - strcpy(Comments,scratch); - } - } - else - { - if ( strstr(Comments, "Sold! BuyitNow") == NULL) strcpy(Comments, "Sold! BuyitNow"); - } + scratch = strstr(Buff, "Another buyer used Buy It Now to purchase the item immediately"); + if (scratch != NULL) { + if (strlen(Comments) > 0) { + if ( strstr(Comments, "Sold! BuyitNow") == NULL) { + strcpy(scratch,"Sold! BuyitNow "); + strcat(scratch,Comments); + strcpy(Comments,scratch); } - } + } else { + if ( strstr(Comments, "Sold! BuyitNow") == NULL) + strcpy(Comments, "Sold! BuyitNow"); + } + } + } if ( strstr(LineBuffer.buf(),"Auction ended early with Buy It Now") == NULL ){ scratch = strstr(Buff, "Auction ended early with Buy It Now"); @@ -1236,10 +1237,9 @@ strcat(scratch,Comments); strcpy(Comments,scratch); } - } - else - { - if ( strstr(Comments, "Sold! BuyitNow") == NULL) strcpy(Comments, "Sold! BuyitNow"); + } else { + if ( strstr(Comments, "Sold! BuyitNow") == NULL) + strcpy(Comments, "Sold! BuyitNow"); } } } @@ -1274,27 +1274,30 @@ scratch = strstr(Buff, "price:"); if (scratch != NULL) { scratch = strstr(Buff, "is the winner"); - if (scratch != NULL) isBuyitNow = 0; - else isBuyitNow = 1; + if (scratch != NULL) + isBuyitNow = 0; + else + isBuyitNow = 1; } } if (auc_type == TYPE_EBAYMOTORSCAR) { - scratch = strstr(Buff, "Current bid"); - if (scratch != NULL) { - scratch = strstr(Buff, "Starting bid"); + scratch = strstr(Buff, "Current bid"); if (scratch != NULL) { - // This is totally crazy and will break as soon as they muck with - // the html but it works for now to distinguish a Car auction from - // a part or accessory. Anyone want to offer a better suggestion? + scratch = strstr(Buff, "Starting bid"); + if (scratch != NULL) { + // This is totally crazy and will break as soon as they muck with + // the html but it works for now to distinguish a Car auction from + // a part or accessory. Anyone want to offer a better suggestion? - //Should move us ahead to a $. This check is here to make sure - //we aren't looking at something the seller said in his desc etc. - scratch +=16; + //Should move us ahead to a $. This check is here to make sure + //we aren't looking at something the seller said in his desc etc. + scratch +=16; - if (scratch[0] == '$') auc_type = TYPE_EBAYMOTORS; + if (scratch[0] == '$') + auc_type = TYPE_EBAYMOTORS; + } } } - } DPRINTF(DHIGH, ("Auction Type=%i\n", auc_type)); AuctionType = auc_type; @@ -1393,45 +1396,47 @@ case 34: // " price:" case 35: // "price:" DPRINTF(DLOW, ("This is a BuyItNow\n")); - if (!buynow_flag) { - buynow_flag = 1; + if (!buynow_flag) { + buynow_flag = 1; - int limit = strlen(LineBuffer.buf()); + int limit = strlen (LineBuffer.buf ()); - if ( limit < 7 ) { - strcpy(LineBuffertmp,LineBuffer.buf()); - streamBuff.getline(LineBuffer.buf(), LineBuffer.size(), '\n'); - strcat(LineBuffertmp,LineBuffer.buf()); - strcpy(LineBuffer.buf(),LineBuffertmp); - } + if (limit < 7) { + strcpy (LineBuffertmp, LineBuffer.buf ()); + streamBuff.getline (LineBuffer.buf (), LineBuffer.size (), '\n'); + strcat (LineBuffertmp, LineBuffer.buf ()); + strcpy (LineBuffer.buf (), LineBuffertmp); + } - scratch = strstr(LineBuffer.buf(), ":"); - if (*(scratch+1) == '\n') - streamBuff.getline(LineBuffer.buf(), LineBuffer.size(), '\n'); - //strcpy(LineBuffer.buf(),scratch); - parseprice2(scratch, this, FALSE); - if (!CurrentBid ) { - parseprice(scratch, this, TRUE); - } - if (!BidCount) { - if (!CurrentBid) CurrentBid = BuyitNowPrice; - strcpy(BidderRate, "(0)"); - FirstBid = CurrentBid; - if (has_ended_flag == 0 && !bid_flag) isEndless = 1; - } - } + scratch = strstr (LineBuffer.buf (), ":"); + if (*(scratch + 1) == '\n') + streamBuff.getline (LineBuffer.buf (), LineBuffer.size (), '\n'); + //strcpy(LineBuffer.buf(),scratch); + parseprice2 (scratch, this, FALSE); + if (!CurrentBid) { + parseprice (scratch, this, TRUE); + } + if (!BidCount) { + if (!CurrentBid) + CurrentBid = BuyitNowPrice; + strcpy (BidderRate, "(0)"); + FirstBid = CurrentBid; + if (has_ended_flag == 0 && !bid_flag) + isEndless = 1; + } + } break; case 4: // quantity if (!Quantity && !quant_flag) { - quant_flag=1; - if (strchr(LineBuffer.buf(), ':')) streamBuff.getline(LineBuffer.buf(), LineBuffer.size(), '\n'); + quant_flag=1; + if (strchr(LineBuffer.buf(), ':')) + streamBuff.getline(LineBuffer.buf(), LineBuffer.size(), '\n'); CheckBadChars(LineBuffer.buf(), "0123456789"); Quantity = atoi(LineBuffer.buf()); - DPRINTF(DLOW, ("LDBC: %s\n", LineBuffer.buf())); + DPRINTF(DLOW, ("LDBC: %s\n", LineBuffer.buf())); } break; - case 5: // bid count case 22: if (!BidCount) { @@ -1439,33 +1444,32 @@ // 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 - int limit = strlen(LineBuffer.buf()); + int limit = strlen(LineBuffer.buf()); - if ( limit < 9 ) { - strcpy(LineBuffertmp,LineBuffer.buf()); - streamBuff.getline(LineBuffer.buf(), LineBuffer.size(), '\n'); - strcat(LineBuffertmp,LineBuffer.buf()); - strcpy(LineBuffer.buf(),LineBuffertmp); - } - scratch = strchr(LineBuffer.buf(), ':'); - if(scratch) { - int limit = strlen(scratch); - for ( int i=0; i < limit; i++ ) - { - // strip the ':' off the currentBid; - scratch[i] = scratch[i + 1]; - } - BidCount = atoi(scratch); - if (!BidCount) { - FirstBid = CurrentBid; - strcpy(HighBidder, "--"); - strcpy(BidderRate, "(0)"); - } - } else { - fprintf(stderr, "cannot determine BidCount: propably parser broken\n"); - } - DPRINTF(DLOW, ("BidCount: %i\n", BidCount)); + if ( limit < 9 ) { + strcpy(LineBuffertmp,LineBuffer.buf()); + streamBuff.getline(LineBuffer.buf(), LineBuffer.size(), '\n'); + strcat(LineBuffertmp,LineBuffer.buf()); + strcpy(LineBuffer.buf(),LineBuffertmp); } + scratch = strchr(LineBuffer.buf(), ':'); + if(scratch) { + int limit = strlen(scratch); + for ( int i=0; i < limit; i++ ) { + // strip the ':' off the currentBid; + scratch[i] = scratch[i + 1]; + } + BidCount = atoi(scratch); + if (!BidCount) { + FirstBid = CurrentBid; + strcpy(HighBidder, "--"); + strcpy(BidderRate, "(0)"); + } + } else { + fprintf(stderr, "cannot determine BidCount: propably parser broken\n"); + } + DPRINTF(DLOW, ("BidCount: %i\n", BidCount)); + } break; case 6: // time left if (!TimeLeft[0]) { @@ -1719,7 +1723,8 @@ /* Don't cut on '('! "(www.grahamcrackers.com)" is a valid ebay account */ /* strip only "(private)" away */ p = strstr(HighBidder, "(private)"); - if (p) *p='\0'; + if (p) + *p='\0'; /* remove trailing '(' in name, because its start of the ranking */ p = HighBidder+strlen(HighBidder)-1; if (*p == '(') { @@ -1751,6 +1756,8 @@ // break; case 13: // dutch auction + if (strncmp(LineBuffer.buf(), "This is a private listing.", 26) == 0) + break; streamBuff.getline(LineBuffer.buf(), LineBuffer.size(), '\n'); if (!strcmp(LineBuffer.buf(), "Dutch Auction")) strcpy(HighBidder, "Dutch Auction"); @@ -1936,14 +1943,16 @@ if(!buynow_flag) { isBuyitNow = 0; BuyitNowPrice = 0; + } +DPRINTF(DLOW, ("HighBidder: >%s< >%s<\n", HighBidder, BidderRate)); if (buynow_flag || (!strcmp(HighBidder, "Dutch Auction")) || (!strcmp(HighBidder, "see Dutch high bidders")) || (!strcmp(HighBidder, "--"))) { return TRUE; - } else if (!strcmp(HighBidder, "User ID kept private")) { + } else if (!strcmp(HighBidder, " User ID kept private ")) { strcpy(HighBidder, "private"); // it's nicer to have this text in log return TRUE; } else { |