| verzia 1.2, 2001/09/28 15:39:21 |
verzia 1.3, 2001/09/28 16:57:04 |
|
|
| /* |
/* |
| * $Log$ |
* $Log$ |
| |
* Revision 1.3 2001/09/28 16:57:04 host8 |
| |
* Source code formated better |
| |
* |
| * Revision 1.2 2001/09/28 15:39:21 host8 |
* Revision 1.2 2001/09/28 15:39:21 host8 |
| * Added keyword substitution |
* Added keyword substitution |
| * |
* |
|
|
| // Function http_set_cookie() {{{ |
// Function http_set_cookie() {{{ |
| void http_set_cookie(char *str) |
void http_set_cookie(char *str) |
| { |
{ |
| if (str!=NULL) { |
if (str != NULL) { |
| if (str==strstr("Set-Cookie: ", str)) { |
if (str == strstr("Set-Cookie: ", str)) { |
| www.cookies = strdup(str + 13); |
www.cookies = strdup(str + 13); |
| } |
} |
| } |
} |
| Riadok 29 void http_set_cookie(char *str) |
|
| Riadok 32 void http_set_cookie(char *str) |
|
| // Function http_set_referer() {{{ |
// Function http_set_referer() {{{ |
| void http_set_referer(char *host, char *file) |
void http_set_referer(char *host, char *file) |
| { |
{ |
| if (host!=NULL&&file!=NULL) { |
if (host != NULL && file != NULL) { |
| if (g.debug) fprintf(stderr, "Setting Referer to '%s%s'\n", |
if (g.debug) fprintf(stderr, "Setting Referer to '%s%s'\n", |
| host, file); |
host, file); |
| free(www.referer); |
free(www.referer); |
| Riadok 46 FILE *http_connect(void) |
|
| Riadok 49 FILE *http_connect(void) |
|
| int i; |
int i; |
| struct sockaddr_in sin; |
struct sockaddr_in sin; |
| |
|
| if (g.gate==AZET) { |
if (g.gate == AZET) { |
| sin.sin_port = htons(AZET_PORT); |
sin.sin_port = htons(AZET_PORT); |
| sin.sin_family = AF_INET; |
sin.sin_family = AF_INET; |
| sin.sin_addr.s_addr = inet_addr(AZET_SERVER); |
sin.sin_addr.s_addr = inet_addr(AZET_SERVER); |
| s = socket(PF_INET, SOCK_STREAM, 0); |
s = socket(PF_INET, SOCK_STREAM, 0); |
| } |
} |
| else if (g.gate==WHIZDIARY) { |
else if (g.gate == WHIZDIARY) { |
| sin.sin_port = htons(WHIZDIARY_PORT); |
sin.sin_port = htons(WHIZDIARY_PORT); |
| sin.sin_family = AF_INET; |
sin.sin_family = AF_INET; |
| sin.sin_addr.s_addr = inet_addr(WHIZDIARY_SERVER); |
sin.sin_addr.s_addr = inet_addr(WHIZDIARY_SERVER); |
| s = socket(PF_INET, SOCK_STREAM, 0); |
s = socket(PF_INET, SOCK_STREAM, 0); |
| } |
} |
| else if (g.gate==SPISNET) { |
else if (g.gate == SPISNET) { |
| sin.sin_port = htons(SPISNET_PORT); |
sin.sin_port = htons(SPISNET_PORT); |
| sin.sin_family = AF_INET; |
sin.sin_family = AF_INET; |
| sin.sin_addr.s_addr = inet_addr(SPISNET_SERVER); |
sin.sin_addr.s_addr = inet_addr(SPISNET_SERVER); |
| Riadok 72 FILE *http_connect(void) |
|
| Riadok 75 FILE *http_connect(void) |
|
| if ((f = fdopen(s, "w+b")) != NULL) |
if ((f = fdopen(s, "w+b")) != NULL) |
| return (f); |
return (f); |
| } |
} |
| if (g.gate==AZET) { |
if (g.gate == AZET) { |
| fprintf(stderr, "Nemozem sa pripojit na %s\n", AZET_SERVER); |
fprintf(stderr, "Nemozem sa pripojit na %s\n", AZET_SERVER); |
| } |
} |
| else if (g.gate==WHIZDIARY) { |
else if (g.gate == WHIZDIARY) { |
| fprintf(stderr, "Nemozem sa pripojit na %s\n", WHIZDIARY_SERVER); |
fprintf(stderr, "Nemozem sa pripojit na %s\n", WHIZDIARY_SERVER); |
| } |
} |
| else if (g.gate==SPISNET) { |
else if (g.gate == SPISNET) { |
| fprintf(stderr, "Nemozem sa pripojit na %s\n", SPISNET_SERVER); |
fprintf(stderr, "Nemozem sa pripojit na %s\n", SPISNET_SERVER); |
| } |
} |
| return(NULL); |
return(NULL); |
| Riadok 97 void http_read_source(FILE *f, char *hos |
|
| Riadok 100 void http_read_source(FILE *f, char *hos |
|
| fprintf(stderr, "\t%.*s\n", (int)(strlen(bla)-2), bla); |
fprintf(stderr, "\t%.*s\n", (int)(strlen(bla)-2), bla); |
| info=0; |
info=0; |
| if (strstr(bla, "HTTP/1.") != NULL) { |
if (strstr(bla, "HTTP/1.") != NULL) { |
| if ((bla+8)==strstr(bla, " 200 OK")) |
if ((bla+8) == strstr(bla, " 200 OK")) |
| http_set_referer(host, file); |
http_set_referer(host, file); |
| } |
} |
| } |
} |
| Riadok 135 int http_request(int method, char *file, |
|
| Riadok 138 int http_request(int method, char *file, |
|
| |
|
| if ((f=http_connect()) == NULL) return(-1); |
if ((f=http_connect()) == NULL) return(-1); |
| if (g.debug) { // Debug code STAHUJEM/POSIELAM {{{ |
if (g.debug) { // Debug code STAHUJEM/POSIELAM {{{ |
| if(method==HTTP_GET) { |
if (method == HTTP_GET) { |
| fprintf(stderr, "STAHUJEM: %s%s\n", host, file); |
fprintf(stderr, "STAHUJEM: %s%s\n", host, file); |
| } |
} |
| else { |
else { |
| fprintf(stderr, "POSIELAM: %s%s\n", host, file); |
fprintf(stderr, "POSIELAM: %s%s\n", host, file); |
| } |
} |
| } // }}} |
} // }}} |
| if (method==HTTP_GET) { |
if (method == HTTP_GET) { |
| fprintf(f, "GET %s HTTP/1.0\r\n", file); |
fprintf(f, "GET %s HTTP/1.0\r\n", file); |
| } |
} |
| else if(method==HTTP_POST) { |
else if (method == HTTP_POST) { |
| fprintf(f, "POST %s HTTP/1.0\r\n", file); |
fprintf(f, "POST %s HTTP/1.0\r\n", file); |
| } |
} |
| else { |
else { |
| Riadok 166 int http_request(int method, char *file, |
|
| Riadok 169 int http_request(int method, char *file, |
|
| |
|
| //fprintf(f, "Accept: text/html, text/plain, audio/mod, image/*, video/*, video/mpeg, application/pgp, application/pgp, application/pdf, message/partial, message/external-body, application/postscript, x-be2, application/andrew-inset, text/richtext, text/enriched\r\nAccept: x-sun-attachment, audio-file, postscript-file, default, mail-file, sun-deskset-message, application/x-metamail-patch, text/sgml, video/mpeg, image/jpeg, image/tiff, image/x-rgb, image/png, image/x-xbitmap, image/x-xbm, image/gif\r\nAccept: application/postscript, */*;q=0.01\r\nAccept-Encoding: gzip, compress\r\nAccept-Language: en\r\n"); |
//fprintf(f, "Accept: text/html, text/plain, audio/mod, image/*, video/*, video/mpeg, application/pgp, application/pgp, application/pdf, message/partial, message/external-body, application/postscript, x-be2, application/andrew-inset, text/richtext, text/enriched\r\nAccept: x-sun-attachment, audio-file, postscript-file, default, mail-file, sun-deskset-message, application/x-metamail-patch, text/sgml, video/mpeg, image/jpeg, image/tiff, image/x-rgb, image/png, image/x-xbitmap, image/x-xbm, image/gif\r\nAccept: application/postscript, */*;q=0.01\r\nAccept-Encoding: gzip, compress\r\nAccept-Language: en\r\n"); |
| //fprintf(f, "Negotiate: trans\r\n"); |
//fprintf(f, "Negotiate: trans\r\n"); |
| if(method==HTTP_POST) { |
if (method == HTTP_POST) { |
| fprintf(f, "Pragma: no-cache\r\n"); |
fprintf(f, "Pragma: no-cache\r\n"); |
| fprintf(f, "Cache-Control: no-cache\r\n"); |
fprintf(f, "Cache-Control: no-cache\r\n"); |
| } |
} |
| fprintf(f, "%s", USER_AGENT); |
fprintf(f, "%s", USER_AGENT); |
| if (www.referer!=NULL) fprintf(f, "Referer: %s\r\n", www.referer); |
if (www.referer != NULL) fprintf(f, "Referer: %s\r\n", www.referer); |
| if (www.cookies!=NULL) { |
if (www.cookies != NULL) { |
| if (g.debug) |
if (g.debug) |
| fprintf(stderr, "Cookie2: $Version=\"1\"\r\nCookie: %s\r\n", |
fprintf(stderr, "Cookie2: $Version=\"1\"\r\nCookie: %s\r\n", |
| www.cookies); |
www.cookies); |
| fprintf(f, "Cookie2: $Version=\"1\"\r\nCookie: %s\r\n", |
fprintf(f, "Cookie2: $Version=\"1\"\r\nCookie: %s\r\n", |
| www.cookies); |
www.cookies); |
| } |
} |
| if (fmt!=NULL) { |
if (fmt != NULL) { |
| va_start(ap, fmt); |
va_start(ap, fmt); |
| vfprintf(f, fmt, ap); |
vfprintf(f, fmt, ap); |
| va_end(ap); |
va_end(ap); |