Sign Up
Log In
Log In
or
Sign Up
Places
All Projects
Status Monitor
Collapse sidebar
home:kssingvo
bidwatcher
bidwatcher-1.3.17-changes_20051013.patch
Overview
Repositories
Revisions
Requests
Users
Attributes
Meta
File bidwatcher-1.3.17-changes_20051013.patch of Package bidwatcher
--- bidwatcher-1.3.17/helpers.cpp.orig 2005-10-16 11:05:57.000000000 +0200 +++ bidwatcher-1.3.17/helpers.cpp 2005-10-16 11:07:17.000000000 +0200 @@ -28,6 +28,7 @@ // #include "config.h" +#include <iostream> #include <stdio.h> #include <stdlib.h> #ifdef HAVE_SSTREAM @@ -239,7 +240,7 @@ !strcmp(temp, "#8220") || // lower double-quote !strcmp(temp, "#8222") || // upper double-quote !strcmp(temp, "quot") || // double-quote - !strcmp(temp, "#8221") || !strcmp(temp, "rsquo") || + !strcmp(temp, "#8221") || !strcmp(temp, "rsquo") || !strcmp(temp, "ndash") || !strcmp(temp, "trade") || !strcmp(temp, "bull")) return '\"'; @@ -254,7 +255,7 @@ if (!strcmp(temp, "szlig")) return 223; // sz-ligature if (!strcmp(temp, "nbsp") || !strcmp(temp, "copy") || - !strcmp(temp, "#8260") || !strcmp(temp, "#12288") || + !strcmp(temp, "#8260") || !strcmp(temp, "#12288") || !strcmp(temp, "#9674") || !strcmp(temp, "#8730")) return ' '; if (!strcmp(temp, "middot")) // This should be trademark @@ -352,6 +353,7 @@ int buffLength = strlen(stringToStrip); #if DEBUGGING > 0 +#warning "Buffer is double its normal size" char *Buff = (char *) malloc(buffLength*2 + 1); memset(Buff, 0, buffLength*2 + 1); #else @@ -428,6 +430,8 @@ (Buff[BuffIdx-1] != ' ') && (Buff[BuffIdx-1] != '\n')) Buff[BuffIdx++] = ' '; + else if ((BuffIdx > 0) && (c == ' ') && (Buff[BuffIdx-1] != ' ')) + continue; /* ignore -- crunch multiple spaces */ else if ((BuffIdx > 0) && (c == '\n') && (Buff[BuffIdx-1] != '\n')) @@ -600,13 +604,12 @@ // ProcessBid() // takes the html response from making a bid // return values: -// 1 - bid submission was a success - we are the high bidder -// 2 - bid successful, but we were outbid. -// 3 - bid under the current asking price -// 4 - problem with the bid quantity -// 5 - Auction is over. -// 6 - invalid username / password. -// 7 - unknown error +// 1 == PBS_SUCCESS - bid submission was a success - we are the high bidder +// 2 == PBS_BIDTOOLOW - bid too low +// 3 == PBS_BADQUANTITY - quantity problem +// 4 == PBS_AUCTIONOVER - auction had ended before the bid +// 5 == PBS_PREAPPROVAL - pre-approval would have been required +// -1 == ERROR - other problem (unknown, probably bad connection) // ////////////////////////////////////////////////////////////////////////////// int ProcessBid(char *Buff) @@ -980,6 +983,8 @@ char *p = strchr(buf, ':'); if(p) buf = p + 1; int len; + while (*buf == ' ') // ignore leading spaces + buf++; if ((buf[0]=='$') || (buf[0]=='U' && buf[1]=='S')) { strcpy(currency, "$"); } else { @@ -1072,7 +1077,6 @@ } } - int idx=0; int cnt; int ended_early=0; int auc_type=TYPE_EBAY; @@ -1110,46 +1114,24 @@ scratch = strstr(Buff, "eBay: "); if (scratch != NULL) { DPRINTF(DLOW, ("found 'eBay:' in auction, new type, scanning...\n")); - // move past the "eBay: " - scratch += 6; - // move past any whitespace - while (isspace(*scratch)) scratch++; - // copy over the description to a newline - idx = 0; - while (*scratch != '(' && idx<DESCRIPTION_LENGTH-1) { - Description[idx++] = *scratch++; - } - // NULL terminate the description I just parsed off - if (Description[idx-1] == ' ') // cut off last space character - Description[idx-1] = '\0'; - else - Description[idx] = '\0'; + + scratch = parseDescription(scratch, false); DPRINTF(DLOW, ("Auction name = '%s'\n", Description)); + } else { scratch = strstr(Buff, "eBay Motors: "); if (scratch != NULL) { DPRINTF(DLOW, ("found 'eBay Motors:' in auction. New type. Scanning...\n")); - // move past the "eBay Motors:" - scratch += 12; - // move past any whitespace - while (isspace(*scratch)) scratch++; - // copy over the description to a newline - idx = 0; - while (*scratch != '(' && idx<DESCRIPTION_LENGTH-1) { - Description[idx++] = *scratch++; - } - // NULL terminate the description I just parsed off - if (Description[idx-1] == ' ') // cut off last space character - Description[idx-1] = '\0'; - else - Description[idx] = '\0'; + scratch = parseDescription(scratch, true); DPRINTF(DLOW, ("Auction name = '%s'\n", Description)); } else { DPRINTF(DLOW, ("no mandatory matching 'eBay:' nor 'eBay Motors:' in buffer\n")); return FALSE; } + } + StringBuffer streamBuff(Buff); /* Skip everything before the start of auction data */ @@ -1299,10 +1281,15 @@ case 17: case 23: case 25: // "Sold for" - if (!bid_flag) { - streamBuff.getline(LineBuffer.buf(), LineBuffer.size(), '\n'); + if (!bid_flag) { DPRINTF(DLOW, ("LDCB: %s\n", LineBuffer.buf())); - parseprice(LineBuffer.buf(), this, FALSE); + if (!parseprice(LineBuffer.buf(), this, FALSE)) + { + streamBuff.getline(LineBuffer.buf(), LineBuffer.size(), '\n'); + } else { + DPRINTF(DLOW, ("LDCB: %s\n", LineBuffer.buf())); + parseprice(LineBuffer.buf(), this, FALSE); + } bid_flag = 1; isEndless = 0; streamBuff.getline(LineBuffer.buf(), LineBuffer.size(), '\n'); @@ -1314,7 +1301,7 @@ // Not a reserve auction, put the chars back. for (unsigned int i=0; i<=strlen(LineBuffer.buf()); i++) streamBuff.unget(); - } + } break; case 3: // first bid @@ -1335,9 +1322,9 @@ break; case 20: // "Price:" - BuyItNow Only. - case 28: - case 34: - case 35: + case 28: // " Price" + case 34: // " price:" + case 35: // "price:" DPRINTF(DLOW, ("This is a BuyItNow\n")); if (!buynow_flag) { buynow_flag = 1; @@ -1473,19 +1460,17 @@ case 36: if (!Seller[0]) { unsigned int count; + char *p; streamBuff.getline(LineBuffer.buf(), LineBuffer.size(), '\n'); if (*LineBuffer.buf() == '\0') streamBuff.getline(LineBuffer.buf(), LineBuffer.size(), '\n'); STRNZCPY(Seller, LineBuffer.buf()); - for (count=0; count < sizeof(Seller); count++) - { - if (Seller[count] == '(') - { - Seller[count] = 0; // truncate string at first '(' - break; // ignore the rest - } - } + /* Don't cut on '('! "(www.grahamcrackers.com)" is a valid ebay account */ + /* strip only "(private)" away */ + p = strstr(Seller, "(private)"); + if (p) *p='\0'; + // Seller Rate is typicaly in next line, but without leading '(' streamBuff.getline(LineBuffer.buf(), LineBuffer.size(), '\n'); if (!strchr(LineBuffer.buf(), ')')) streamBuff.getline(LineBuffer.buf(), LineBuffer.size(), '\n'); @@ -1521,8 +1506,10 @@ } STRNZCPY(HighBidder, p); - p = strchr(HighBidder, '('); - if(p) *p = 0; + /* Don't cut on '('! "(www.grahamcrackers.com)" is a valid ebay account */ + /* strip only "(private)" away */ + p = strstr(Seller, "(private)"); + if (p) *p='\0'; // Bidder Rate is typicaly in next line, but without leading '(' streamBuff.getline(LineBuffer.buf(), LineBuffer.size(), '\n'); @@ -1554,46 +1541,52 @@ strcpy(HighBidder, "Dutch Auction"); break; - case 29: if (!Feedbackn[0]) { - streamBuff.getline(LineBuffer.buf(), LineBuffer.size(), '\n'); - STRNZCPY(Feedbackn, LineBuffer.buf()); - streamBuff.getline(LineBuffer.buf(), LineBuffer.size(), '\n'); - - char TmpLine[6]; - unsigned int count; - int limit = strlen(LineBuffer.buf()); - int iiii=0; - - for (count=0; count < strlen(LineBuffer.buf()); count++) - { - if (LineBuffer.buf()[count] == ':') - { - LineBuffer.buf()[count] = count; // truncate string at first ':' - for (int fb=count+1; fb < limit; fb++) { - TmpLine[iiii] = LineBuffer.buf()[fb + 1]; - iiii++; - } - } - } - CheckBadChars(Feedbackn,"0123456789"); - if ( strstr(LineBuffer.buf(),"Feedback") != NULL) { - + case 29: // Feedback Score: + if (!Feedbackn[0]) { + char TmpLine[6]; + unsigned int count; + int limit = 0; + int iiii=0; + char *p; + + p = LineBuffer.buf(); + while(!isdigit(*p) && *p) + p++; + if (*p == '\0') { + streamBuff.getline(LineBuffer.buf(), LineBuffer.size(), '\n'); + STRNZCPY(Feedbackn, LineBuffer.buf()); + } else { + STRNZCPY(Feedbackn, p); + } + streamBuff.getline(LineBuffer.buf(), LineBuffer.size(), '\n'); - int a1=6, c1=strlen(Feedbackn); - while (c1 < a1) { /* adds spaces */ - strcat(Feedbackn, " "); - c1++; - } - strcat(Feedbackn,TmpLine); - } - else - { - CheckBadChars(Feedbackn,"123456789"); - STRNZCPY(Feedbackn,"NONE"); - } - } - break; + limit = strlen(LineBuffer.buf()); + for (count=0; count < limit; count++) + { + if (LineBuffer.buf()[count] == ':') { + LineBuffer.buf()[count] = count; // truncate string at first ':' + for (int fb=count+1; fb < limit; fb++) + { + TmpLine[iiii] = LineBuffer.buf()[fb + 1]; + iiii++; + } + } + } + CheckBadChars(Feedbackn,"0123456789"); + if ( strstr(LineBuffer.buf(),"Feedback") != NULL) { + int a1=6, c1=strlen(Feedbackn); + while (c1 < a1) { /* adds spaces */ + strcat(Feedbackn, " "); + c1++; + } + strcat(Feedbackn,TmpLine); + } else { + CheckBadChars(Feedbackn,"123456789"); + STRNZCPY(Feedbackn,"NONE"); + } + } + break; case 15: // reserve auctions @@ -1686,8 +1679,8 @@ reserveMet = 'n'; else if (strstr(LineBuffer.buf(), "reserve met")) reserveMet = 'y'; - DPRINTF(DHIGH, ("Reserve: %c\n", reserveMet)); + default:; break; /* End case 1 of auc_type */ @@ -1766,6 +1759,33 @@ return TRUE; } // end GetAucInfo() +char *auctioninfo::parseDescription(char *scratch, bool motors) { + unsigned int idx, len; + char *end; + + // move past the title + scratch += strlen(motors ? "eBay Motors: " : "eBay: "); + + // move past any whitespace + while (isspace(*scratch)) scratch++; + // copy over the description to a newline + idx = 0; + if ((end = strstr(scratch, "(item")) != NULL) { + len = end - scratch; + len = (len < sizeof(Description)-1) ? len : sizeof(Description-1); + } else { + len = sizeof(Description) - 1; + } + + while (*scratch != '\n' && idx < len) { + Description[idx++] = *scratch++; + } + // NULL terminate the description I just parsed off + Description[idx-1] = '\0'; + + return scratch; +} + void MakeFileName(char * prefix2, char * fileName, bool thisMonth) { char * homedir=getenv("HOME"); --- bidwatcher-1.3.17/bidwatcher.h.orig 2005-10-16 11:09:17.000000000 +0200 +++ bidwatcher-1.3.17/bidwatcher.h 2005-10-16 11:10:24.000000000 +0200 @@ -191,6 +191,7 @@ ~auctioninfo(); int getinfo(); bool parseaucinfo(const char *); + char *parseDescription(char *, bool); void getkey(float bid, int quantity); int bid(bool);
Locations
Projects
Search
Status Monitor
Help
OpenBuildService.org
Documentation
API Documentation
Code of Conduct
Contact
Support
@OBShq
Terms
openSUSE Build Service is sponsored by
The Open Build Service is an
openSUSE project
.
Sign Up
Log In
Places
Places
All Projects
Status Monitor