From owner-FreeBSD-users-jp@jp.freebsd.org  Fri Oct 18 13:24:39 1996
Received: by mail.jp.freebsd.org (8.7.3+2.6Wbeta5/8.7.3) id NAA22965
	Fri, 18 Oct 1996 13:24:39 +0900 (JST)
Received: by mail.jp.freebsd.org (8.7.3+2.6Wbeta5/8.7.3) with SMTP id NAA22960
	for <FreeBSD-users-jp@jp.freebsd.org>; Fri, 18 Oct 1996 13:24:37 +0900 (JST)
Received: from uucp1.iij.ad.jp (uucp1.iij.ad.jp [192.244.176.73]) by mail0.iij.ad.jp (8.6.12+2.4W/3.3W9-MAIL) with ESMTP id NAA26415 for <FreeBSD-users-jp@jp.freebsd.org>; Fri, 18 Oct 1996 13:24:34 +0900
Received: (from uucp@localhost) by uucp1.iij.ad.jp (8.6.12+2.4W/3.3W9-UUCP) with UUCP id NAA27095 for FreeBSD-users-jp@jp.freebsd.org; Fri, 18 Oct 1996 13:24:34 +0900
Received: from xxx.fct.kgc.co.jp by yyy.kgc.co.jp (8.7.5/3.4W4:96080715) id NAA09906; Fri, 18 Oct 1996 13:21:16 +0900 (JST)
Received: from localhost by xxx.fct.kgc.co.jp (8.7.5/3.3W8:95062916) id NAA08321; Fri, 18 Oct 1996 13:19:15 +0900 (JST)
Message-Id: <199610180419.NAA08321@xxx.fct.kgc.co.jp>
To: FreeBSD-users-jp@jp.freebsd.org
In-reply-to: Ito Kazumitsu's message of 11 Sep 1996 10:29:36 +0900
References: <9518.842352566@johp425.htk.hitachi-cable.co.jp>  <199609102330.IAA08474@kiri.toba-cmt.ac.jp>
	<12124.842403330@johp425.htk.hitachi-cable.co.jp>
Date: Fri, 18 Oct 1996 13:19:14 +0900
From: Toshihiro Kanda <candy@fct.kgc.co.jp>
Reply-To: FreeBSD-users-jp@jp.freebsd.org
X-Distribute: distribute [version 2.1 (Alpha) patchlevel=19]
X-Sequence: FreeBSD-users-jp 5388
Subject: [FreeBSD-users-jp 5388] Re: Laptop survey
Errors-To: owner-FreeBSD-users-jp@jp.freebsd.org
Sender: owner-FreeBSD-users-jp@jp.freebsd.org

$B$9$_$^$;$s!#$A$H8E$$$s$G$9$,!#(B

> $B$?$H$($P(B
>   fetch -o foo.html http://www.jp.FreeBSD.org/
>   fetch http://www.jp.freebsd.org/jpg/daemon1.jpg
>     (-o $B;XDj$r>JN,$9$k$H%+%l%s%H%G%#%l%/%H%j$N(B daemon1.jpg $B$K(B
>      $BF~$k$i$7$$(B)
>   fetch -o /foo/bar.jpg fetch http://www.jp.freebsd.org/jpg/daemon1.jpg
> $B$J$I$H$7$^$9!%(B

  fetch(1) $B$O(B proxy $B$rDL$7$F$O;H$($J$$$_$?$$$J$N$G!"(Bquick & dirty hack 
$B$7$F!"(BHTTP $B$@$1(B proxy $B7PM3$G;H$($k$h$&$K$7$^$7$?!#;H$$J}$O(B

   fetch -X http://proxy.domain:port URL

$B$G$9!#$@$+$i$I!<$7$?(B? $B$9$_$^$;$s!#$Z$3$Z$3!#(B

diff -ur /usr/src/usr.bin/fetch/Makefile ./Makefile
--- /usr/src/usr.bin/fetch/Makefile	Wed Jun 19 18:32:11 1996
+++ ./Makefile	Thu Oct 17 10:30:04 1996
@@ -1,4 +1,4 @@
-PROG = fetch
+PROG = feti
 SRCS = main.c
 
 DPADD=  ${LIBFTPIO}
diff -ur /usr/src/usr.bin/fetch/main.c ./main.c
--- /usr/src/usr.bin/fetch/main.c	Fri Jul  5 09:25:31 1996
+++ ./main.c	Thu Oct 17 10:30:48 1996
@@ -65,6 +65,8 @@
 int mirror = 0;
 int restart = 0;
 time_t modtime;
+static int proxy_mode;
+static char *proxy_host;
 
 FILE *file = 0;
 
@@ -77,7 +79,7 @@
 void
 usage ()
 {
-    fprintf (stderr, "usage: %s [-D:HINPMV:Lqpr] [-o outputfile] <-f file -h host [-c dir]| URL>\n", progname);
+    fprintf (stderr, "usage: %s [-D:HINPMV:LX:qpr] [-o outputfile] <-f file -h host [-c dir]| URL>\n", progname);
     exit (1);
 }
 
@@ -120,11 +122,15 @@
 
 	progname = s ? s+1 : argv[0];
 
-	while ((c = getopt (argc, argv, "D:HINPMV:Lqc:f:h:o:pmr")) != EOF) {
+	while ((c = getopt (argc, argv, "D:HINPMV:LX:qc:f:h:o:pmr")) != EOF) {
 		switch (c) {
 		      case 'D': case 'H': case 'I': case 'N': case 'L': case 'V': 
 			break;	/* ncftp compatibility */
 
+		      case 'X':
+		      	proxy_host = optarg;
+		      	break;
+
 		      case 'q': 
 			verbose = 0;
 
@@ -166,7 +172,12 @@
 	if (argv[0]) {
 		if (host || change_to_dir || file_to_get)
 		    usage ();
-		parse (argv[0]);
+		if (proxy_host != NULL) {
+			parse (proxy_host);
+			file_to_get = argv[0];
+		}
+		else
+			parse (argv[0]);
 	} else {
 		if (!host || !file_to_get)
 		    usage ();
@@ -375,12 +386,16 @@
 		/* http://host.name/file/name */
 		char *q;
 		s += 7;
-		p = strchr (s, '/');
-		if (!p) {
-			fprintf (stderr, "%s: no filename??\n", progname);
-			usage ();
+		if (proxy_host == NULL) {
+			p = strchr (s, '/');
+			if (!p) {
+				fprintf (stderr, "%s: no filename??\n", progname);
+				usage ();
+			}
+			*p++ = 0;
 		}
-		*p++ = 0;
+		else
+			p = s + strlen(s);
 		q = strchr (s, ':');
 		if (q && q < p) {
 			*q++ = 0;
@@ -469,7 +484,10 @@
 	restart = 0;
 
 	s = http_open ();
-	sprintf (str, "GET /%s HTTP/1.0\n\n", file_to_get);
+	if (proxy_host)
+		sprintf (str, "GET %s HTTP/1.0\n\n", file_to_get);
+	else
+		sprintf (str, "GET /%s HTTP/1.0\n\n", file_to_get);
 	i = strlen (str);
 	if (i != write (s, str, i))
 	    err (1, 0);
