version 1.1, 1997/02/03 01:02:37 |
version 1.2, 1997/02/03 01:05:37 |
|
|
|
/* $OpenBSD$ */ |
/* $NetBSD: fetch.c,v 1.2 1997/02/01 10:45:00 lukem Exp $ */ |
/* $NetBSD: fetch.c,v 1.2 1997/02/01 10:45:00 lukem Exp $ */ |
|
|
/*- |
/*- |
|
|
*/ |
*/ |
|
|
#ifndef lint |
#ifndef lint |
static char rcsid[] = "$NetBSD: fetch.c,v 1.2 1997/02/01 10:45:00 lukem Exp $"; |
static char rcsid[] = "$OpenBSD$"; |
#endif /* not lint */ |
#endif /* not lint */ |
|
|
/* |
/* |
|
|
oldintr = NULL; |
oldintr = NULL; |
if (setjmp(httpabort)) { |
if (setjmp(httpabort)) { |
if (oldintr) |
if (oldintr) |
(void) signal(SIGINT, oldintr); |
(void)signal(SIGINT, oldintr); |
goto cleanup_http_get; |
goto cleanup_http_get; |
} |
} |
oldintr = signal(SIGINT, aborthttp); |
oldintr = signal(SIGINT, aborthttp); |
|
|
} |
} |
if (hash && !progress) { |
if (hash && !progress) { |
while (bytes >= hashbytes) { |
while (bytes >= hashbytes) { |
(void) putchar('#'); |
(void)putchar('#'); |
hashbytes += mark; |
hashbytes += mark; |
} |
} |
(void) fflush(stdout); |
(void)fflush(stdout); |
} |
} |
} |
} |
if (hash && !progress && bytes > 0) { |
if (hash && !progress && bytes > 0) { |
if (bytes < mark) |
if (bytes < mark) |
(void) putchar('#'); |
(void)putchar('#'); |
(void) putchar('\n'); |
(void)putchar('\n'); |
(void) fflush(stdout); |
(void)fflush(stdout); |
} |
} |
if (len != 0) { |
if (len != 0) { |
warn("Reading from socket"); |
warn("Reading from socket"); |
|
|
} |
} |
progressmeter(1); |
progressmeter(1); |
if (verbose) |
if (verbose) |
printf("Successfully retrieved file.\n"); |
puts("Successfully retrieved file."); |
(void) signal(SIGINT, oldintr); |
(void)signal(SIGINT, oldintr); |
|
|
close(s); |
close(s); |
close(out); |
close(out); |
if (proxy) |
if (proxy) |
free(proxy); |
free(proxy); |
return(0); |
return (0); |
|
|
improper: |
improper: |
warnx("improper response from %s", host); |
warnx("improper response from %s", host); |
|
|
close(s); |
close(s); |
if (proxy) |
if (proxy) |
free(proxy); |
free(proxy); |
return(-1); |
return (-1); |
} |
} |
|
|
/* |
/* |
|
|
{ |
{ |
|
|
alarmtimer(0); |
alarmtimer(0); |
printf("\nhttp fetch aborted\n"); |
puts("\nhttp fetch aborted"); |
(void) fflush(stdout); |
(void)fflush(stdout); |
longjmp(httpabort, 1); |
longjmp(httpabort, 1); |
} |
} |
|
|
|
|
* files of the form "host:path", "ftp://host/path" using the |
* files of the form "host:path", "ftp://host/path" using the |
* ftp protocol, and files of the form "http://host/path" using |
* ftp protocol, and files of the form "http://host/path" using |
* the http protocol. |
* the http protocol. |
* If path has a trailing "/", then return(-1); |
* If path has a trailing "/", then return (-1); |
* the path will be cd-ed into and the connection remains open, |
* the path will be cd-ed into and the connection remains open, |
* and the function will return -1 (to indicate the connection |
* and the function will return -1 (to indicate the connection |
* is alive). |
* is alive). |
|
|
if (setjmp(toplevel)) { |
if (setjmp(toplevel)) { |
if (connected) |
if (connected) |
disconnect(0, NULL); |
disconnect(0, NULL); |
return(argpos + 1); |
return (argpos + 1); |
} |
} |
(void) signal(SIGINT, intr); |
(void)signal(SIGINT, intr); |
(void) signal(SIGPIPE, lostpeer); |
(void)signal(SIGPIPE, lostpeer); |
|
|
/* |
/* |
* Loop through as long as there's files to fetch. |
* Loop through as long as there's files to fetch. |