to wget, so it can now do funky interactive things with cgi scripts.
" 31 46 1365 /etc/passwd\n"
#define wget_trivial_usage \
- "[-c] [-q] [-O file] url"
+ "[-c|--continue] [-q|--quiet] [-O|--output-document file] [--header 'header: value'] url"
#define wget_full_usage \
"wget retrieves files via HTTP or FTP\n\n" \
"Options:\n" \
" 31 46 1365 /etc/passwd\n"
#define wget_trivial_usage \
- "[-c] [-q] [-O file] url"
+ "[-c|--continue] [-q|--quiet] [-O|--output-document file] [--header 'header: value'] url"
#define wget_full_usage \
"wget retrieves files via HTTP or FTP\n\n" \
"Options:\n" \
#include <arpa/inet.h>
#include <netdb.h>
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#include <getopt.h>
+
#include "busybox.h"
/* Stupid libc5 doesn't define this... */
char *proxy;
char *s, buf[512];
struct stat sbuf;
-
+ char extra_headers[1024];
+ char *extra_headers_ptr = extra_headers;
+ int extra_headers_left = sizeof(extra_headers);
+ int which_long_opt = 0, option_index = -1;
struct host_info server, target;
FILE *sfp = NULL; /* socket to web/ftp server */
FILE *output; /* socket to web server */
int quiet_flag = FALSE; /* Be verry, verry quiet... */
+#define LONG_HEADER 1
+ struct option long_options[] = {
+ { "continue", 0, NULL, 'c' },
+ { "quiet", 0, NULL, 'q' },
+ { "output-document", 1, NULL, 'O' },
+ { "header", 1, &which_long_opt, LONG_HEADER },
+ { 0, 0, 0, 0 }
+ };
/*
* Crack command line.
*/
- while ((n = getopt(argc, argv, "cqO:")) != EOF) {
+ while ((n = getopt_long(argc, argv, "cqO:", long_options, &option_index)) != EOF) {
switch (n) {
case 'c':
++do_continue;
*/
fname_out = optarg;
break;
+ case 0:
+ switch (which_long_opt) {
+ case LONG_HEADER: {
+ int arglen = strlen(optarg);
+ if(extra_headers_left - arglen - 2 <= 0)
+ error_msg_and_die("extra_headers buffer too small(need %i)", extra_headers_left - arglen);
+ strcpy(extra_headers_ptr, optarg);
+ extra_headers_ptr += arglen;
+ extra_headers_left -= ( arglen + 2 );
+ *extra_headers_ptr++ = '\r';
+ *extra_headers_ptr++ = '\n';
+ *(extra_headers_ptr + 1) = 0;
+ break;
+ }
+ }
+ break;
default:
show_usage();
}
}
+ fprintf(stderr, "extra_headers='%s'\n", extra_headers);
if (argc - optind != 1)
show_usage();
if (do_continue)
fprintf(sfp, "Range: bytes=%ld-\r\n", beg_range);
+ if(extra_headers_left < sizeof(extra_headers))
+ fprintf(sfp,extra_headers);
fprintf(sfp,"Connection: close\r\n\r\n");
/*
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: wget.c,v 1.38 2001/05/13 00:55:54 andersen Exp $
+ * $Id: wget.c,v 1.39 2001/05/15 17:51:37 andersen Exp $
*/
" 31 46 1365 /etc/passwd\n"
#define wget_trivial_usage \
- "[-c] [-q] [-O file] url"
+ "[-c|--continue] [-q|--quiet] [-O|--output-document file] [--header 'header: value'] url"
#define wget_full_usage \
"wget retrieves files via HTTP or FTP\n\n" \
"Options:\n" \
#include <arpa/inet.h>
#include <netdb.h>
+#ifndef _GNU_SOURCE
+#define _GNU_SOURCE
+#endif
+#include <getopt.h>
+
#include "busybox.h"
/* Stupid libc5 doesn't define this... */
char *proxy;
char *s, buf[512];
struct stat sbuf;
-
+ char extra_headers[1024];
+ char *extra_headers_ptr = extra_headers;
+ int extra_headers_left = sizeof(extra_headers);
+ int which_long_opt = 0, option_index = -1;
struct host_info server, target;
FILE *sfp = NULL; /* socket to web/ftp server */
FILE *output; /* socket to web server */
int quiet_flag = FALSE; /* Be verry, verry quiet... */
+#define LONG_HEADER 1
+ struct option long_options[] = {
+ { "continue", 0, NULL, 'c' },
+ { "quiet", 0, NULL, 'q' },
+ { "output-document", 1, NULL, 'O' },
+ { "header", 1, &which_long_opt, LONG_HEADER },
+ { 0, 0, 0, 0 }
+ };
/*
* Crack command line.
*/
- while ((n = getopt(argc, argv, "cqO:")) != EOF) {
+ while ((n = getopt_long(argc, argv, "cqO:", long_options, &option_index)) != EOF) {
switch (n) {
case 'c':
++do_continue;
*/
fname_out = optarg;
break;
+ case 0:
+ switch (which_long_opt) {
+ case LONG_HEADER: {
+ int arglen = strlen(optarg);
+ if(extra_headers_left - arglen - 2 <= 0)
+ error_msg_and_die("extra_headers buffer too small(need %i)", extra_headers_left - arglen);
+ strcpy(extra_headers_ptr, optarg);
+ extra_headers_ptr += arglen;
+ extra_headers_left -= ( arglen + 2 );
+ *extra_headers_ptr++ = '\r';
+ *extra_headers_ptr++ = '\n';
+ *(extra_headers_ptr + 1) = 0;
+ break;
+ }
+ }
+ break;
default:
show_usage();
}
}
+ fprintf(stderr, "extra_headers='%s'\n", extra_headers);
if (argc - optind != 1)
show_usage();
if (do_continue)
fprintf(sfp, "Range: bytes=%ld-\r\n", beg_range);
+ if(extra_headers_left < sizeof(extra_headers))
+ fprintf(sfp,extra_headers);
fprintf(sfp,"Connection: close\r\n\r\n");
/*
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
* SUCH DAMAGE.
*
- * $Id: wget.c,v 1.38 2001/05/13 00:55:54 andersen Exp $
+ * $Id: wget.c,v 1.39 2001/05/15 17:51:37 andersen Exp $
*/