summaryrefslogtreecommitdiff
path: root/misc/bidwatcher/patches/patch-ac
diff options
context:
space:
mode:
Diffstat (limited to 'misc/bidwatcher/patches/patch-ac')
-rw-r--r--misc/bidwatcher/patches/patch-ac99
1 files changed, 99 insertions, 0 deletions
diff --git a/misc/bidwatcher/patches/patch-ac b/misc/bidwatcher/patches/patch-ac
new file mode 100644
index 00000000000..4ba13261a0c
--- /dev/null
+++ b/misc/bidwatcher/patches/patch-ac
@@ -0,0 +1,99 @@
+$NetBSD: patch-ac,v 1.4 2002/10/12 15:32:15 tron Exp $
+
+--- netstuff.cpp.orig Sat Oct 12 16:16:49 2002
++++ netstuff.cpp Sat Oct 12 16:49:10 2002
+@@ -34,6 +34,7 @@
+ #include <time.h>
+ #include <netinet/in.h>
+ #include <sys/socket.h>
++#include <sys/utsname.h>
+ #include <netdb.h>
+ #include <gtk/gtk.h>
+ #include "bidwatcher.h"
+@@ -51,7 +52,7 @@
+ g_free(ustring);
+
+ char *HtmlBuff;
+- fetchURL(url,&HtmlBuff,TIMEOUT);
++ fetchURL(url,0,&HtmlBuff,TIMEOUT);
+ char *adultcookie=strstr(HtmlBuff,"Set-Cookie");
+ if (adultcookie==NULL) {
+ printf("adult cookie not found\n");
+@@ -143,16 +144,16 @@
+ }
+
+ void URL::create(char *newurl,URL *proxy) {
++ char *hostoff = strstr(newurl, "://") + 3;
++
++ sprintf(hoststring, "%.*s", strcspn(hostoff, "/"), hostoff);
+ if (proxy == NULL) {
+- char *hostoff = strstr(newurl, "://") + 3;
+ char tmpstr[256];
+
+ useproxy = FALSE;
+
+- strncpy(tmpstr, hostoff, strcspn(hostoff, "/"));
+- tmpstr[strcspn(hostoff, "/")] = '\0';
+-
+- if (strlen(tmpstr) < strlen(newurl)) {
++ strcpy(tmpstr, hoststring);
++ if (strlen(tmpstr) < strlen(hostoff)) {
+ strcpy(url, hostoff + strlen(tmpstr));
+ } else url[0] = '\0';
+
+@@ -235,13 +236,17 @@
+ else return FALSE;
+ }
+
+-int fetchURL(URL *url, char **Buff, double timeOut)
++int fetchURL(URL *url, int Post, char **Buff, double timeOut)
+ {
+ int buffLength,recerr;
+ int socketID;
++ char UserAgent[256];
++ char *Host;
+ char lineBuff[1024];
+ char htmlBuff[HUGEBUFF];
+
++ struct utsname utsbuf;
++
+ struct sockaddr_in soc_in;
+ int err;
+ fd_set fds;
+@@ -331,9 +336,26 @@
+ return NET_NETERROR;
+ }
+
++ if (uname(&utsbuf) < 0)
++ UserAgent[0] = '\0';
++ else
++ sprintf(UserAgent, "User-Agent: Mozilla/5.0 (X11; U; %s %s; en-US; rv:1.1) Gecko/20020912\r\n", utsbuf.sysname, utsbuf.machine);
++
+ // send our request for the web page.
+ // XXX: Took out the cookie for now cuz we're not yet using it.
+- sprintf(lineBuff, "GET %s HTTP/1.1\r\nConnection: close\r\nHost: %s\r\nUser-Agent: bidwatcher\r\n\r\n", url->url, url->hostinfo->h_name);
++ if (Post) {
++ int URLLen;
++ char *Args;
++
++ URLLen = strcspn(url->url, "?");
++ Args = &url->url[URLLen];
++ if (*Args != '\0')
++ Args++;
++
++ sprintf(lineBuff, "POST %.*s HTTP/1.1\r\nConnection: close\r\nHost: %s\r\nContent-Length: %d\r\n%s\r\n%s", URLLen, url->url, url->hoststring, strlen(Args), UserAgent, Args);
++ } else {
++ sprintf(lineBuff, "GET %s HTTP/1.1\r\nConnection: close\r\nHost: %s\r\n%s\r\n", url->url, url->hoststring, UserAgent);
++ }
+
+ if (send(socketID, lineBuff, strlen(lineBuff), 0) < 0) {
+ #ifdef DEBUG_NETWORK
+@@ -406,7 +428,7 @@
+ if (checkredir(url,htmlBuff)) {
+ g_free(time_since_pkt);
+ g_free(time_since_start);
+- return fetchURL(url, Buff, timeOut);
++ return fetchURL(url, 0, Buff, timeOut);
+ } else {
+ if (!goodcall) {
+ g_free(time_since_pkt);