2 * Copyright (c) 2000-2004 Dag-Erling Coïdan Smørgrav
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer
10 * in this position and unchanged.
11 * 2. Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * 3. The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 #if !defined(NETBSD) && !defined(__minix)
37 #include <sys/param.h>
40 #include <sys/ioctl.h>
43 #include <sys/socket.h>
85 #define MINBUFSIZE 4096
88 int A_flag
; /* -A: do not follow 302 redirects */
89 int a_flag
; /* -a: auto retry */
90 off_t B_size
; /* -B: buffer size */
91 int d_flag
; /* -d: direct connection */
92 int F_flag
; /* -F: restart without checking mtime */
93 int i_flag
; /* -i: fetch file if modified */
94 int l_flag
; /* -l: link rather than copy file: URLs */
95 int m_flag
; /* -[Mm]: mirror mode */
96 char *N_filename
; /* -N: netrc file name */
97 int n_flag
; /* -n: do not preserve modification time */
98 int o_flag
; /* -o: specify output file */
99 int o_directory
; /* output file is a directory */
100 char *o_filename
; /* name of output file */
101 int o_stdout
; /* output file is stdout */
102 int once_flag
; /* -1: stop at first successful file */
103 int R_flag
; /* -R: don't delete partially transferred files */
104 int r_flag
; /* -r: restart previously interrupted transfer */
105 off_t S_size
; /* -S: require size to match */
106 int s_flag
; /* -s: show size, don't fetch */
107 long T_secs
= 120; /* -T: transfer timeout in seconds */
108 int U_flag
; /* -U: do not use high ports */
109 int v_level
= 1; /* -v: verbosity level */
110 int v_tty
; /* stdout is a tty */
111 pid_t pgrp
; /* our process group */
112 long w_secs
; /* -w: retry delay */
113 int family
= PF_UNSPEC
; /* -[46]: address family to use */
115 volatile int sigalrm
; /* SIGALRM received */
117 volatile int siginfo
; /* SIGINFO received */
119 volatile int sigint
; /* SIGINT received */
121 long ftp_timeout
; /* default timeout for FTP transfers */
122 long http_timeout
; /* default timeout for HTTP transfers */
123 char *buf
; /* transfer buffer */
134 fetchRestartCalls
= 0;
143 fetchRestartCalls
= 0;
151 struct timeval start
;
159 * Compute and display ETA
162 stat_eta(struct xferstat
*xs
)
166 off_t received
, expected
;
168 elapsed
= xs
->last
.tv_sec
- xs
->start
.tv_sec
;
169 received
= xs
->rcvd
- xs
->offset
;
170 expected
= xs
->size
- xs
->rcvd
;
171 eta
= (long)((double)elapsed
* expected
/ received
);
173 snprintf(str
, sizeof str
, "%02ldh%02ldm",
174 eta
/ 3600, (eta
% 3600) / 60);
176 snprintf(str
, sizeof str
, "%02ldm%02lds",
182 * Format a number as "xxxx YB" where Y is ' ', 'k', 'M'...
184 static const char *prefixes
= " kMGTP";
186 stat_bytes(off_t bytes
)
189 const char *prefix
= prefixes
;
191 while (bytes
> 9999 && prefix
[1] != '\0') {
195 snprintf(str
, sizeof str
, "%4jd %cB", (intmax_t)bytes
, *prefix
);
200 * Compute and display transfer rate
203 stat_bps(struct xferstat
*xs
)
208 delta
= (xs
->last
.tv_sec
+ (xs
->last
.tv_usec
/ 1.e6
))
209 - (xs
->start
.tv_sec
+ (xs
->start
.tv_usec
/ 1.e6
));
211 snprintf(str
, sizeof str
, "?? Bps");
213 bps
= (xs
->rcvd
- xs
->offset
) / delta
;
214 snprintf(str
, sizeof str
, "%sps", stat_bytes((off_t
)bps
));
220 * Update the stats display
223 stat_display(struct xferstat
*xs
, int force
)
226 #if !defined(__minix)
228 #endif /* !defined(__minix) */
230 /* Minix returns "Not a typewriter error" */
231 #if defined(TIOCGPGRP) && !defined(__minix)
232 /* check if we're the foreground process */
233 if (ioctl(STDERR_FILENO
, TIOCGPGRP
, &ctty_pgrp
) == -1 ||
234 (pid_t
)ctty_pgrp
!= pgrp
)
238 gettimeofday(&now
, NULL
);
239 if (!force
&& now
.tv_sec
<= xs
->last
.tv_sec
)
243 fprintf(stderr
, "\r%-46.46s", xs
->name
);
245 #if HAVE_SETPROCTITLE
246 setproctitle("%s [%s]", xs
->name
, stat_bytes(xs
->rcvd
));
248 fprintf(stderr
, " %s", stat_bytes(xs
->rcvd
));
250 #if HAVE_SETPROCTITLE
251 setproctitle("%s [%d%% of %s]", xs
->name
,
252 (int)((100.0 * xs
->rcvd
) / xs
->size
),
253 stat_bytes(xs
->size
));
255 fprintf(stderr
, "%3d%% of %s",
256 (int)((100.0 * xs
->rcvd
) / xs
->size
),
257 stat_bytes(xs
->size
));
259 fprintf(stderr
, " %s", stat_bps(xs
));
260 if (xs
->size
> 0 && xs
->rcvd
> 0 &&
261 xs
->last
.tv_sec
>= xs
->start
.tv_sec
+ 10)
262 fprintf(stderr
, " %s", stat_eta(xs
));
267 * Initialize the transfer statistics
270 stat_start(struct xferstat
*xs
, const char *name
, off_t size
, off_t offset
)
272 snprintf(xs
->name
, sizeof xs
->name
, "%s", name
);
273 gettimeofday(&xs
->start
, NULL
);
274 xs
->last
.tv_sec
= xs
->last
.tv_usec
= 0;
278 if (v_tty
&& v_level
> 0)
280 else if (v_level
> 0)
281 fprintf(stderr
, "%-46s", xs
->name
);
285 * Update the transfer statistics
288 stat_update(struct xferstat
*xs
, off_t rcvd
)
291 if (v_tty
&& v_level
> 0)
296 * Finalize the transfer statistics
299 stat_end(struct xferstat
*xs
)
301 gettimeofday(&xs
->last
, NULL
);
302 if (v_tty
&& v_level
> 0) {
305 } else if (v_level
> 0) {
306 fprintf(stderr
, " %s %s\n",
307 stat_bytes(xs
->size
), stat_bps(xs
));
311 #if HAVE_TERMIOS_H && !defined(PREFER_GETPASS)
313 read_password(const char *prompt
, char *pwbuf
, size_t pwbuf_len
)
316 tcflag_t saved_flags
;
319 fprintf(stderr
, "%s", prompt
);
320 if (tcgetattr(STDIN_FILENO
, &tios
) != 0)
321 return (fgets(pwbuf
, pwbuf_len
, stdin
) == NULL
);
323 saved_flags
= tios
.c_lflag
;
324 tios
.c_lflag
&= ~ECHO
;
325 tios
.c_lflag
|= ECHONL
|ICANON
;
327 tcsetattr(STDIN_FILENO
, TCSAFLUSH
|TCSASOFT
, &tios
);
329 tcsetattr(STDIN_FILENO
, TCSAFLUSH
, &tios
);
331 nopwd
= (fgets(pwbuf
, pwbuf_len
, stdin
) == NULL
);
332 tios
.c_lflag
= saved_flags
;
334 tcsetattr(STDIN_FILENO
, TCSANOW
|TCSASOFT
, &tios
);
336 tcsetattr(STDIN_FILENO
, TCSANOW
, &tios
);
341 #elif HAVE_GETPASSPHRASE || HAVE_GETPASS
343 read_password(const char *prompt
, char *pwbuf
, size_t pwbuf_len
)
347 #if HAVE_GETPASSPHRASE && !defined(PREFER_GETPASS)
348 pass
= getpassphrase(prompt
);
350 pass
= getpass(prompt
);
352 if (pass
== NULL
|| strlen(pass
) >= pwbuf_len
)
359 read_password(const char *prompt
, char *pwbuf
, size_t pwbuf_len
)
362 fprintf(stderr
, prompt
);
363 return (fgets(pwbuf
, pwbuf_len
, stdin
) == NULL
);
368 * Ask the user for authentication details
371 query_auth(struct url
*URL
)
375 fprintf(stderr
, "Authentication required for <%s://%s:%d/>!\n",
376 URL
->scheme
, URL
->host
, URL
->port
);
378 fprintf(stderr
, "Login: ");
379 if (fgets(URL
->user
, sizeof URL
->user
, stdin
) == NULL
)
381 for (i
= strlen(URL
->user
); i
>= 0; --i
)
382 if (URL
->user
[i
] == '\r' || URL
->user
[i
] == '\n')
385 nopwd
= read_password("Password: ", URL
->pwd
, sizeof(URL
->pwd
));
389 for (i
= strlen(URL
->pwd
); i
>= 0; --i
)
390 if (URL
->pwd
[i
] == '\r' || URL
->pwd
[i
] == '\n')
400 fetch(char *URL
, const char *path
)
425 /* set verbosity level */
432 if ((url
= fetchParseURL(URL
)) == NULL
) {
433 warnx("%s: parse error", URL
);
437 /* if no scheme was specified, take a guess */
440 strcpy(url
->scheme
, SCHEME_FILE
);
441 else if (strncasecmp(url
->host
, "ftp.", 4) == 0)
442 strcpy(url
->scheme
, SCHEME_FTP
);
443 else if (strncasecmp(url
->host
, "www.", 4) == 0)
444 strcpy(url
->scheme
, SCHEME_HTTP
);
459 /* Protocol independent flags */
461 if (stat(path
, &sb
) == 0) {
462 url
->last_modified
= sb
.st_mtime
;
464 } else if (errno
!= ENOENT
) {
465 warn("%s: stat()", path
);
470 /* FTP specific flags */
471 if (strcmp(url
->scheme
, SCHEME_FTP
) == 0) {
476 timeout
= T_secs
? T_secs
: ftp_timeout
;
479 /* HTTP specific flags */
480 if (strcmp(url
->scheme
, SCHEME_HTTP
) == 0) {
485 timeout
= T_secs
? T_secs
: http_timeout
;
488 /* set the protocol timeout. */
489 fetchTimeout
= timeout
;
491 /* just print size */
495 r
= fetchStat(url
, &us
, flags
);
498 if (sigalrm
|| sigint
)
501 warnx("%s", fetchLastErrString
);
507 printf("%jd\n", (intmax_t)us
.size
);
512 * If the -r flag was specified, we have to compare the local
513 * and remote files, so we should really do a fetchStat()
514 * first, but I know of at least one HTTP server that only
515 * sends the content size in response to GET requests, and
516 * leaves it out of replies to HEAD requests. Also, in the
517 * (frequent) case that the local and remote files match but
518 * the local file is truncated, we have sufficient information
519 * before the compare to issue a correct request. Therefore,
520 * we always issue a GET request as if we were sure the local
521 * file was a truncated copy of the remote file; we can drop
522 * the connection later if we change our minds.
527 if (r
== 0 && r_flag
&& S_ISREG(sb
.st_mode
)) {
528 url
->offset
= sb
.st_size
;
529 } else if (r
== -1 || !S_ISREG(sb
.st_mode
)) {
531 * Whatever value sb.st_size has now is either
532 * wrong (if stat(2) failed) or irrelevant (if the
533 * path does not refer to a regular file)
537 if (r
== -1 && errno
!= ENOENT
) {
538 warnx("%s: stat()", path
);
543 /* start the transfer */
546 f
= fetchXGet(url
, &us
, flags
);
549 if (sigalrm
|| sigint
)
551 if (f
== NULL
&& i_flag
&& fetchLastErrCode
== FETCH_UNCHANGED
) {
552 /* URL was not modified, return OK. */
553 printf("%s: not modified\n", URL
);
558 warnx("%s: %s", URL
, fetchLastErrString
);
564 /* check that size is as expected */
567 warnx("%s: size unknown", URL
);
568 } else if (us
.size
!= S_size
) {
569 warnx("%s: size mismatch: expected %jd, actual %jd",
570 URL
, (intmax_t)S_size
, (intmax_t)us
.size
);
575 /* symlink instead of copy */
576 if (l_flag
&& strcmp(url
->scheme
, "file") == 0 && !o_stdout
) {
577 char *name
= fetchUnquotePath(url
);
579 warnx("Can't unquote URL");
582 if (symlink(name
, path
) == -1) {
583 warn("%s: symlink()", path
);
591 if (us
.size
== -1 && !o_stdout
&& v_level
> 0)
592 warnx("%s: size of remote file is not known", URL
);
594 if (sb
.st_size
!= -1)
595 fprintf(stderr
, "local size / mtime: %jd / %ld\n",
596 (intmax_t)sb
.st_size
, (long)sb
.st_mtime
);
598 fprintf(stderr
, "remote size / mtime: %jd / %ld\n",
599 (intmax_t)us
.size
, (long)us
.mtime
);
602 /* open output file */
604 /* output to stdout */
606 } else if (r_flag
&& sb
.st_size
!= -1) {
607 /* resume mode, local file exists */
608 if (!F_flag
&& us
.mtime
&& sb
.st_mtime
!= us
.mtime
) {
609 /* no match! have to refetch */
611 /* if precious, warn the user and give up */
613 warnx("%s: local modification time "
614 "does not match remote", path
);
617 } else if (us
.size
!= -1) {
618 if (us
.size
== sb
.st_size
)
621 if (sb
.st_size
> us
.size
) {
622 /* local file too long! */
623 warnx("%s: local file (%jd bytes) is longer "
624 "than remote file (%jd bytes)", path
,
625 (intmax_t)sb
.st_size
, (intmax_t)us
.size
);
628 /* we got it, open local file */
629 if ((of
= fopen(path
, "a")) == NULL
) {
630 warn("%s: fopen()", path
);
633 /* check that it didn't move under our feet */
634 if (fstat(fileno(of
), &nsb
) == -1) {
636 warn("%s: fstat()", path
);
639 if (nsb
.st_dev
!= sb
.st_dev
||
640 nsb
.st_ino
!= nsb
.st_ino
||
641 nsb
.st_size
!= sb
.st_size
) {
642 warnx("%s: file has changed", URL
);
648 } else if (m_flag
&& sb
.st_size
!= -1) {
649 /* mirror mode, local file exists */
650 if (sb
.st_size
== us
.size
&& sb
.st_mtime
== us
.mtime
)
656 * We don't yet have an output file; either this is a
657 * vanilla run with no special flags, or the local and
658 * remote files didn't match.
661 if (url
->offset
> 0) {
663 * We tried to restart a transfer, but for
664 * some reason gave up - so we have to restart
665 * from scratch if we want the whole file
668 if ((f
= fetchXGet(url
, &us
, flags
)) == NULL
) {
669 warnx("%s: %s", URL
, fetchLastErrString
);
676 /* construct a temp file name */
677 if (sb
.st_size
!= -1 && S_ISREG(sb
.st_mode
)) {
679 asprintf(&tmppath
, "%s.fetch.XXXXXX", path
);
683 if((tmppath
= malloc(sizeof(char)*MINBUFSIZE
)) != NULL
) {
684 len
= snprintf(tmppath
, MINBUFSIZE
, "%s.fetch.XXXXXX", path
);
685 if(len
>= MINBUFSIZE
) {
693 if (tmppath
!= NULL
) {
696 fd
= mkstemp(tmppath
);
698 warn("%s: mkstemp failed", tmppath
);
701 fchown(fd
, sb
.st_uid
, sb
.st_gid
);
702 fchmod(fd
, sb
.st_mode
& ALLPERMS
);
703 of
= fdopen(fd
, "w");
713 of
= fopen(path
, "w");
715 warn("%s: open()", path
);
721 /* start the counter */
722 stat_start(&xs
, path
, us
.size
, count
);
724 sigalrm
= sigint
= 0;
726 /* suck in the data */
729 signal(SIGINFO
, sig_handler
);
732 if (us
.size
!= -1 && us
.size
- count
< B_size
&&
733 us
.size
- count
>= 0)
734 size
= us
.size
- count
;
739 stat_display(&xs
, 1);
743 /* Constant info is better than none. */
745 stat_display(&xs
, 1);
748 if ((ssize
= fetchIO_read(f
, buf
, B_size
)) == 0)
750 if (ssize
== -1 && errno
== EINTR
)
755 stat_update(&xs
, count
+= size
);
756 for (ptr
= buf
; size
> 0; ptr
+= wr
, size
-= wr
) {
757 if ((wr
= fwrite(ptr
, 1, size
, of
)) < size
) {
758 if (ferror(of
) && errno
== EINTR
&& !sigint
)
770 signal(SIGINFO
, SIG_DFL
);
776 * If the transfer timed out or was interrupted, we still want to
777 * set the mtime in case the file is not removed (-r or -R) and
778 * the user later restarts the transfer.
781 /* set mtime of local file */
782 if (!n_flag
&& us
.mtime
&& !o_stdout
&& of
!= NULL
&&
783 (stat(path
, &sb
) != -1) && sb
.st_mode
& S_IFREG
) {
784 struct timeval tv
[2];
787 tv
[0].tv_sec
= (long)(us
.atime
? us
.atime
: us
.mtime
);
788 tv
[1].tv_sec
= (long)us
.mtime
;
789 tv
[0].tv_usec
= tv
[1].tv_usec
= 0;
790 if (utimes(tmppath
? tmppath
: path
, tv
))
791 warn("%s: utimes()", tmppath
? tmppath
: path
);
794 /* timed out or interrupted? */
795 if (fetchLastErrCode
== FETCH_TIMEOUT
)
798 warnx("transfer timed out");
800 warnx("transfer interrupted");
804 /* timeout / interrupt before connection completley established? */
808 if (!sigalrm
&& ferror(of
)) {
809 /* check the status of our files */
810 warn("writing to %s failed", path
);
814 /* did the transfer complete normally? */
815 if (us
.size
!= -1 && count
< us
.size
) {
816 warnx("%s appears to be truncated: %jd/%jd bytes",
817 path
, (intmax_t)count
, (intmax_t)us
.size
);
822 * If the transfer timed out and we didn't know how much to
823 * expect, assume the worst (i.e. we didn't get all of it)
825 if (sigalrm
&& us
.size
== -1) {
826 warnx("%s may be truncated", path
);
832 if (tmppath
!= NULL
&& rename(tmppath
, path
) == -1) {
833 warn("%s: rename()", path
);
838 if (of
&& of
!= stdout
&& !R_flag
&& !r_flag
)
839 if (stat(path
, &sb
) != -1 && (sb
.st_mode
& S_IFREG
))
840 unlink(tmppath
? tmppath
: path
);
841 if (R_flag
&& tmppath
!= NULL
&& sb
.st_size
== -1)
842 rename(tmppath
, path
); /* ignore errors here */
849 if (of
&& of
!= stdout
)
862 fprintf(stderr
, "%s\n%s\n%s\n",
863 "usage: fetch [-146AFMPRUadilmnpqrsv] [-N netrc] [-o outputfile]",
864 " [-S bytes] [-B bytes] [-T seconds] [-w seconds]",
865 " [-h host -f file [-c dir] | URL ...]");
867 fprintf(stderr
, "%s\n%s\n%s\n",
868 "usage: fetch [-146AFMPRUadilmnpqrsv] [-N netrc] [-o outputfile]",
869 " [-S bytes] [-B bytes] [-T seconds] [-w seconds]",
870 " [-h host -f file [-c dir] | URL ...]");
879 main(int argc
, char *argv
[])
887 while ((c
= getopt(argc
, argv
,
888 "14AaB:dFilMmN:no:qRrS:sT:Uvw:")) != -1)
890 while ((c
= getopt(argc
, argv
,
891 "146AaB:dFilMmN:no:qRrS:sT:Uvw:")) != -1)
912 B_size
= (off_t
)strtol(optarg
, &end
, 10);
913 if (*optarg
== '\0' || *end
!= '\0')
914 errx(1, "invalid buffer size (%s)", optarg
);
935 errx(1, "the -m and -r flags "
936 "are mutually exclusive");
953 errx(1, "the -m and -r flags "
954 "are mutually exclusive");
958 S_size
= (off_t
)strtol(optarg
, &end
, 10);
959 if (*optarg
== '\0' || *end
!= '\0')
960 errx(1, "invalid size (%s)", optarg
);
966 T_secs
= strtol(optarg
, &end
, 10);
967 if (*optarg
== '\0' || *end
!= '\0')
968 errx(1, "invalid timeout (%s)", optarg
);
978 w_secs
= strtol(optarg
, &end
, 10);
979 if (*optarg
== '\0' || *end
!= '\0')
980 errx(1, "invalid delay (%s)", optarg
);
995 fetchConnectionCacheInit(10, 1);
997 /* allocate buffer */
998 if (B_size
< MINBUFSIZE
)
1000 if ((buf
= malloc(B_size
)) == NULL
)
1001 errx(1, "%s", strerror(ENOMEM
));
1004 if ((s
= getenv("FTP_TIMEOUT")) != NULL
) {
1005 ftp_timeout
= strtol(s
, &end
, 10);
1006 if (*s
== '\0' || *end
!= '\0' || ftp_timeout
< 0) {
1007 warnx("FTP_TIMEOUT (%s) is not a positive integer", s
);
1011 if ((s
= getenv("HTTP_TIMEOUT")) != NULL
) {
1012 http_timeout
= strtol(s
, &end
, 10);
1013 if (*s
== '\0' || *end
!= '\0' || http_timeout
< 0) {
1014 warnx("HTTP_TIMEOUT (%s) is not a positive integer", s
);
1019 /* signal handling */
1021 sa
.sa_handler
= sig_handler
;
1022 sigemptyset(&sa
.sa_mask
);
1023 sigaction(SIGALRM
, &sa
, NULL
);
1024 sa
.sa_flags
= SA_RESETHAND
;
1025 sigaction(SIGINT
, &sa
, NULL
);
1029 if (strcmp(o_filename
, "-") == 0) {
1032 warnx("-i and -o - are incompatible, dropping -i");
1035 } else if (stat(o_filename
, &sb
) == -1) {
1036 if (errno
== ENOENT
) {
1038 errx(EX_USAGE
, "%s is not a directory",
1041 err(EX_IOERR
, "%s", o_filename
);
1044 if (sb
.st_mode
& S_IFDIR
)
1049 /* check if output is to a tty (for progress report) */
1050 v_tty
= isatty(STDERR_FILENO
);
1056 /* authentication */
1058 fetchAuthMethod
= query_auth
;
1059 if (N_filename
!= NULL
)
1060 setenv("NETRC", N_filename
, 1);
1063 if ((p
= strrchr(*argv
, '/')) == NULL
)
1071 fetchLastErrCode
= 0;
1075 e
= fetch(*argv
, "-");
1076 } else if (o_directory
) {
1078 asprintf(&q
, "%s/%s", o_filename
, p
);
1083 if ((q
= malloc(sizeof(char)*MINBUFSIZE
)) != NULL
) {
1084 len
= snprintf(q
, MINBUFSIZE
, "%s/%s", o_filename
, p
);
1085 if (len
>= MINBUFSIZE
) {
1090 err(1, "Unable to allocate memory");
1094 e
= fetch(*argv
, q
);
1097 e
= fetch(*argv
, o_filename
);
1100 e
= fetch(*argv
, p
);
1104 kill(getpid(), SIGINT
);
1106 if (e
== 0 && once_flag
)
1111 if ((fetchLastErrCode
1112 && fetchLastErrCode
!= FETCH_UNAVAIL
1113 && fetchLastErrCode
!= FETCH_MOVED
1114 && fetchLastErrCode
!= FETCH_URL
1115 && fetchLastErrCode
!= FETCH_RESOLV
1116 && fetchLastErrCode
!= FETCH_UNKNOWN
)) {
1117 if (w_secs
&& v_level
)
1118 fprintf(stderr
, "Waiting %ld seconds "
1119 "before retrying\n", w_secs
);