WebGet & WebPost Utilities
Je kunt niet meer dan 25 onderwerpen selecteren Onderwerpen moeten beginnen met een letter of nummer, kunnen streepjes bevatten ('-') en kunnen maximaal 35 tekens lang zijn.
 
 

79 regels
1.9 KiB

/**
* @PROJECT WebGet Downloader
* @COPYRIGHT See COPYING in the top level directory
* @FILE webpost.c
* @PURPOSE Web POST Operation Dumper
* @DEVELOPERS Al Globus <globus@nas.nasa.gov>
* Rafal Kupiec <belliash@asiotec.eu.org>
* Jef Poskanzer <jef@mail.acme.com>
*/
#include <stdio.h>
#include <stdlib.h>
#include <signal.h>
#include "libweb.h"
int main(int argc, char** argv) {
int argn;
char* referer;
char* user_agent;
char* auth_token;
int ncookies;
char* cookies[MAX_COOKIES];
char* header_name;
char* header_value;
argv0 = argv[0];
argn = 1;
timeout = 60;
referer = (char*) 0;
user_agent = "http_post";
auth_token = (char*) 0;
ncookies = 0;
header_name = (char*) 0;
header_value = (char*) 0;
verbose = 0;
while(argn < argc && argv[argn][0] == '-' && argv[argn][1] != '\0') {
if(strcmp(argv[argn], "-t") == 0 && argn + 1 < argc) {
++argn;
timeout = atoi(argv[argn]);
} else if(strcmp(argv[argn], "-r") == 0 && argn + 1 < argc) {
++argn;
referer = argv[argn];
} else if(strcmp(argv[argn], "-u") == 0 && argn + 1 < argc) {
++argn;
user_agent = argv[argn];
} else if(strcmp(argv[argn], "-a") == 0 && argn + 1 < argc) {
++argn;
auth_token = argv[argn];
} else if(strcmp(argv[argn], "-c") == 0 && argn + 1 < argc) {
if(ncookies >= MAX_COOKIES) {
(void) fprintf(stderr, "%s: too many cookies\n", argv0);
exit(1);
}
++argn;
cookies[ncookies++] = argv[argn];
} else if(strcmp(argv[argn], "-h") == 0 && argn + 2 < argc) {
++argn;
header_name = argv[argn];
++argn;
header_value = argv[argn];
} else if(strcmp(argv[argn], "-v") == 0) {
verbose = 1;
} else {
usage();
}
++argn;
}
if(argn >= argc) {
usage();
}
url = argv[argn];
++argn;
(void) signal(SIGALRM, sigcatch);
postURL(url, referer, user_agent, auth_token, ncookies, cookies, header_name, header_value, &(argv[argn]), argc - argn);
exit(0);
}