1
0
mirror of https://github.com/moparisthebest/wget synced 2024-07-03 16:38:41 -04:00

Do not use exit() with a magic number

This commit is contained in:
Giuseppe Scrivano 2014-06-09 08:53:10 +02:00
parent ee5b28367c
commit 087e17be1c
11 changed files with 107 additions and 89 deletions

View File

@ -1,3 +1,17 @@
2014-06-10 Giuseppe Scrivano <gscrivan@redhat.com>
* exits.c: Move WGET_EXIT_* definitions to...
* exits.h: ...here. Add WGET_EXIT_GENERIC_ERROR, WGET_EXIT_PARSE_ERROR.
Remove WGET_EXIT_MINIMUM.
* init.c: Fix calls to exit().
* log.c: Likewise.
* main.c: Likewise.
* mswindows.c: Likewise.
* netrc.c: Likewise.
* utils.c: Likewise.
* warc.c: Likewise.
* Test-stdouterr.px: Likewise.
2014-06-08 Giuseppe Scrivano <gscrivan@redhat.com> 2014-06-08 Giuseppe Scrivano <gscrivan@redhat.com>
* main.c: Make `program_name' not static. * main.c: Make `program_name' not static.

View File

@ -20,24 +20,6 @@
#include "wget.h" #include "wget.h"
#include "exits.h" #include "exits.h"
/* Final exit code possibilities. Exit codes 1 and 2 are reserved
* for situations that lead to direct exits from Wget, not using the
* value of final_exit_status. */
enum
{
WGET_EXIT_SUCCESS = 0,
WGET_EXIT_MINIMUM = 3,
WGET_EXIT_IO_FAIL = WGET_EXIT_MINIMUM,
WGET_EXIT_NETWORK_FAIL = 4,
WGET_EXIT_SSL_AUTH_FAIL = 5,
WGET_EXIT_SERVER_AUTH_FAIL = 6,
WGET_EXIT_PROTOCOL_ERROR = 7,
WGET_EXIT_SERVER_ERROR = 8,
WGET_EXIT_UNKNOWN
};
static int final_exit_status = WGET_EXIT_SUCCESS; static int final_exit_status = WGET_EXIT_SUCCESS;
/* XXX: I don't like that newly-added uerr_t codes will doubtless fall /* XXX: I don't like that newly-added uerr_t codes will doubtless fall

View File

@ -21,6 +21,23 @@ along with Wget. If not, see <http://www.gnu.org/licenses/>. */
#include "wget.h" #include "wget.h"
/* Final exit code possibilities. Exit codes 1 and 2 are reserved
* for situations that lead to direct exits from Wget, not using the
* value of final_exit_status. */
enum
{
WGET_EXIT_SUCCESS = 0,
WGET_EXIT_GENERIC_ERROR = 1,
WGET_EXIT_PARSE_ERROR = 2,
WGET_EXIT_IO_FAIL = 3,
WGET_EXIT_NETWORK_FAIL = 4,
WGET_EXIT_SSL_AUTH_FAIL = 5,
WGET_EXIT_SERVER_AUTH_FAIL = 6,
WGET_EXIT_PROTOCOL_ERROR = 7,
WGET_EXIT_SERVER_ERROR = 8,
WGET_EXIT_UNKNOWN
};
void inform_exit_status (uerr_t err); void inform_exit_status (uerr_t err);

View File

@ -488,7 +488,7 @@ wgetrc_env_file_name (void)
{ {
fprintf (stderr, _("%s: WGETRC points to %s, which doesn't exist.\n"), fprintf (stderr, _("%s: WGETRC points to %s, which doesn't exist.\n"),
exec_name, env); exec_name, env);
exit (1); exit (WGET_EXIT_GENERIC_ERROR);
} }
return xstrdup (env); return xstrdup (env);
} }
@ -660,7 +660,7 @@ initialize (void)
Parsing system wgetrc file (env SYSTEM_WGETRC) failed. Please check\n\ Parsing system wgetrc file (env SYSTEM_WGETRC) failed. Please check\n\
'%s',\n\ '%s',\n\
or specify a different file using --config.\n"), env_sysrc); or specify a different file using --config.\n"), env_sysrc);
exit (2); exit (WGET_EXIT_PARSE_ERROR);
} }
} }
/* Otherwise, if SYSTEM_WGETRC is defined, use it. */ /* Otherwise, if SYSTEM_WGETRC is defined, use it. */
@ -675,7 +675,7 @@ or specify a different file using --config.\n"), env_sysrc);
Parsing system wgetrc file failed. Please check\n\ Parsing system wgetrc file failed. Please check\n\
'%s',\n\ '%s',\n\
or specify a different file using --config.\n"), SYSTEM_WGETRC); or specify a different file using --config.\n"), SYSTEM_WGETRC);
exit (2); exit (WGET_EXIT_PARSE_ERROR);
} }
#endif #endif
/* Override it with your own, if one exists. */ /* Override it with your own, if one exists. */
@ -697,7 +697,7 @@ or specify a different file using --config.\n"), SYSTEM_WGETRC);
/* If there were errors processing either `.wgetrc', abort. */ /* If there were errors processing either `.wgetrc', abort. */
if (!ok) if (!ok)
exit (2); exit (WGET_EXIT_PARSE_ERROR);
xfree (file); xfree (file);
return; return;
@ -856,7 +856,7 @@ setoptval (const char *com, const char *val, const char *optname)
assert (val != NULL); assert (val != NULL);
if (!setval_internal (command_by_name (com), dd_optname, val)) if (!setval_internal (command_by_name (com), dd_optname, val))
exit (2); exit (WGET_EXIT_PARSE_ERROR);
} }
/* Parse OPT into command and value and run it. For example, /* Parse OPT into command and value and run it. For example,
@ -872,14 +872,14 @@ run_command (const char *cmdopt)
{ {
case line_ok: case line_ok:
if (!setval_internal (comind, com, val)) if (!setval_internal (comind, com, val))
exit (2); exit (WGET_EXIT_PARSE_ERROR);
xfree (com); xfree (com);
xfree (val); xfree (val);
break; break;
default: default:
fprintf (stderr, _("%s: Invalid --execute command %s\n"), fprintf (stderr, _("%s: Invalid --execute command %s\n"),
exec_name, quote (cmdopt)); exec_name, quote (cmdopt));
exit (2); exit (WGET_EXIT_PARSE_ERROR);
} }
} }

View File

@ -39,6 +39,7 @@ as that of the covered work. */
#include <errno.h> #include <errno.h>
#include "utils.h" #include "utils.h"
#include "exits.h"
#include "log.h" #include "log.h"
/* 2005-10-25 SMS. /* 2005-10-25 SMS.
@ -547,7 +548,7 @@ logprintf (enum log_options o, const char *fmt, ...)
va_end (args); va_end (args);
if (done && errno == EPIPE) if (done && errno == EPIPE)
exit (1); exit (WGET_EXIT_GENERIC_ERROR);
} }
while (!done); while (!done);
} }
@ -591,7 +592,7 @@ log_init (const char *file, bool appendp)
if (!logfp) if (!logfp)
{ {
fprintf (stderr, "%s: %s: %s\n", exec_name, file, strerror (errno)); fprintf (stderr, "%s: %s: %s\n", exec_name, file, strerror (errno));
exit (1); exit (WGET_EXIT_GENERIC_ERROR);
} }
} }
else else

View File

@ -783,15 +783,15 @@ Recursive accept/reject:\n"),
if (printf (_("GNU Wget %s, a non-interactive network retriever.\n"), if (printf (_("GNU Wget %s, a non-interactive network retriever.\n"),
version_string) < 0) version_string) < 0)
exit (3); exit (WGET_EXIT_IO_FAIL);
if (print_usage (0) < 0) if (print_usage (0) < 0)
exit (3); exit (WGET_EXIT_IO_FAIL);
for (i = 0; i < countof (help); i++) for (i = 0; i < countof (help); i++)
if (fputs (_(help[i]), stdout) < 0) if (fputs (_(help[i]), stdout) < 0)
exit (3); exit (WGET_EXIT_IO_FAIL);
exit (0); exit (WGET_EXIT_SUCCESS);
} }
/* Return a human-readable printed representation of INTERVAL, /* Return a human-readable printed representation of INTERVAL,
@ -890,7 +890,7 @@ print_version (void)
int i; int i;
if (printf (_("GNU Wget %s built on %s.\n\n"), version_string, OS_TYPE) < 0) if (printf (_("GNU Wget %s built on %s.\n\n"), version_string, OS_TYPE) < 0)
exit (3); exit (WGET_EXIT_IO_FAIL);
for (i = 0; compiled_features[i] != NULL; ) for (i = 0; compiled_features[i] != NULL; )
{ {
@ -898,83 +898,83 @@ print_version (void)
while ((line_length > 0) && (compiled_features[i] != NULL)) while ((line_length > 0) && (compiled_features[i] != NULL))
{ {
if (printf ("%s ", compiled_features[i]) < 0) if (printf ("%s ", compiled_features[i]) < 0)
exit (3); exit (WGET_EXIT_IO_FAIL);
line_length -= strlen (compiled_features[i]) + 2; line_length -= strlen (compiled_features[i]) + 2;
i++; i++;
} }
if (printf ("\n") < 0) if (printf ("\n") < 0)
exit (3); exit (WGET_EXIT_IO_FAIL);
} }
if (printf ("\n") < 0) if (printf ("\n") < 0)
exit (3); exit (WGET_EXIT_IO_FAIL);
/* Handle the case when $WGETRC is unset and $HOME/.wgetrc is /* Handle the case when $WGETRC is unset and $HOME/.wgetrc is
absent. */ absent. */
if (printf ("%s\n", wgetrc_title) < 0) if (printf ("%s\n", wgetrc_title) < 0)
exit (3); exit (WGET_EXIT_IO_FAIL);
env_wgetrc = wgetrc_env_file_name (); env_wgetrc = wgetrc_env_file_name ();
if (env_wgetrc && *env_wgetrc) if (env_wgetrc && *env_wgetrc)
{ {
if (printf (_(" %s (env)\n"), env_wgetrc) < 0) if (printf (_(" %s (env)\n"), env_wgetrc) < 0)
exit (3); exit (WGET_EXIT_IO_FAIL);
xfree (env_wgetrc); xfree (env_wgetrc);
} }
user_wgetrc = wgetrc_user_file_name (); user_wgetrc = wgetrc_user_file_name ();
if (user_wgetrc) if (user_wgetrc)
{ {
if (printf (_(" %s (user)\n"), user_wgetrc) < 0) if (printf (_(" %s (user)\n"), user_wgetrc) < 0)
exit (3); exit (WGET_EXIT_IO_FAIL);
xfree (user_wgetrc); xfree (user_wgetrc);
} }
#ifdef SYSTEM_WGETRC #ifdef SYSTEM_WGETRC
if (printf (_(" %s (system)\n"), SYSTEM_WGETRC) < 0) if (printf (_(" %s (system)\n"), SYSTEM_WGETRC) < 0)
exit (3); exit (WGET_EXIT_IO_FAIL);
#endif #endif
#ifdef ENABLE_NLS #ifdef ENABLE_NLS
if (format_and_print_line (locale_title, if (format_and_print_line (locale_title,
LOCALEDIR, LOCALEDIR,
MAX_CHARS_PER_LINE) < 0) MAX_CHARS_PER_LINE) < 0)
exit (3); exit (WGET_EXIT_IO_FAIL);
#endif /* def ENABLE_NLS */ #endif /* def ENABLE_NLS */
if (compilation_string != NULL) if (compilation_string != NULL)
if (format_and_print_line (compile_title, if (format_and_print_line (compile_title,
compilation_string, compilation_string,
MAX_CHARS_PER_LINE) < 0) MAX_CHARS_PER_LINE) < 0)
exit (3); exit (WGET_EXIT_IO_FAIL);
if (link_string != NULL) if (link_string != NULL)
if (format_and_print_line (link_title, if (format_and_print_line (link_title,
link_string, link_string,
MAX_CHARS_PER_LINE) < 0) MAX_CHARS_PER_LINE) < 0)
exit (3); exit (WGET_EXIT_IO_FAIL);
if (printf ("\n") < 0) if (printf ("\n") < 0)
exit (3); exit (WGET_EXIT_IO_FAIL);
/* TRANSLATORS: When available, an actual copyright character /* TRANSLATORS: When available, an actual copyright character
(circle-c) should be used in preference to "(C)". */ (circle-c) should be used in preference to "(C)". */
if (printf (_("\ if (printf (_("\
Copyright (C) %s Free Software Foundation, Inc.\n"), "2014") < 0) Copyright (C) %s Free Software Foundation, Inc.\n"), "2014") < 0)
exit (3); exit (WGET_EXIT_IO_FAIL);
if (fputs (_("\ if (fputs (_("\
License GPLv3+: GNU GPL version 3 or later\n\ License GPLv3+: GNU GPL version 3 or later\n\
<http://www.gnu.org/licenses/gpl.html>.\n\ <http://www.gnu.org/licenses/gpl.html>.\n\
This is free software: you are free to change and redistribute it.\n\ This is free software: you are free to change and redistribute it.\n\
There is NO WARRANTY, to the extent permitted by law.\n"), stdout) < 0) There is NO WARRANTY, to the extent permitted by law.\n"), stdout) < 0)
exit (3); exit (WGET_EXIT_IO_FAIL);
/* TRANSLATORS: When available, please use the proper diacritics for /* TRANSLATORS: When available, please use the proper diacritics for
names such as this one. See en_US.po for reference. */ names such as this one. See en_US.po for reference. */
if (fputs (_("\nOriginally written by Hrvoje Niksic <hniksic@xemacs.org>.\n"), if (fputs (_("\nOriginally written by Hrvoje Niksic <hniksic@xemacs.org>.\n"),
stdout) < 0) stdout) < 0)
exit (3); exit (WGET_EXIT_IO_FAIL);
if (fputs (_("Please send bug reports and questions to <bug-wget@gnu.org>.\n"), if (fputs (_("Please send bug reports and questions to <bug-wget@gnu.org>.\n"),
stdout) < 0) stdout) < 0)
exit (3); exit (WGET_EXIT_IO_FAIL);
exit (0); exit (WGET_EXIT_SUCCESS);
} }
char *program_name; /* Needed by lib/error.c. */ char *program_name; /* Needed by lib/error.c. */
@ -1022,7 +1022,7 @@ main (int argc, char **argv)
if (p == NULL) if (p == NULL)
{ {
fprintf (stderr, _("Memory allocation problem\n")); fprintf (stderr, _("Memory allocation problem\n"));
exit (2); exit (WGET_EXIT_PARSE_ERROR);
} }
for (i = 1; i < argc; i++) for (i = 1; i < argc; i++)
{ {
@ -1073,7 +1073,7 @@ main (int argc, char **argv)
else else
{ {
fprintf (stderr, _("Exiting due to error in %s\n"), optarg); fprintf (stderr, _("Exiting due to error in %s\n"), optarg);
exit (2); exit (WGET_EXIT_PARSE_ERROR);
} }
} }
} }
@ -1103,7 +1103,7 @@ main (int argc, char **argv)
fprintf (stderr, "\n"); fprintf (stderr, "\n");
fprintf (stderr, _("Try `%s --help' for more options.\n"), fprintf (stderr, _("Try `%s --help' for more options.\n"),
exec_name); exec_name);
exit (2); exit (WGET_EXIT_PARSE_ERROR);
} }
/* Find the short option character in the mapping. */ /* Find the short option character in the mapping. */
longindex = optmap[ret - 32]; longindex = optmap[ret - 32];
@ -1173,7 +1173,7 @@ main (int argc, char **argv)
fprintf (stderr, "\n"); fprintf (stderr, "\n");
fprintf (stderr, _("Try `%s --help' for more options.\n"), fprintf (stderr, _("Try `%s --help' for more options.\n"),
exec_name); exec_name);
exit (1); exit (WGET_EXIT_GENERIC_ERROR);
} }
break; break;
} }
@ -1254,14 +1254,14 @@ main (int argc, char **argv)
{ {
fprintf (stderr, _("Can't be verbose and quiet at the same time.\n")); fprintf (stderr, _("Can't be verbose and quiet at the same time.\n"));
print_usage (1); print_usage (1);
exit (1); exit (WGET_EXIT_GENERIC_ERROR);
} }
if (opt.timestamping && opt.noclobber) if (opt.timestamping && opt.noclobber)
{ {
fprintf (stderr, _("\ fprintf (stderr, _("\
Can't timestamp and not clobber old files at the same time.\n")); Can't timestamp and not clobber old files at the same time.\n"));
print_usage (1); print_usage (1);
exit (1); exit (WGET_EXIT_GENERIC_ERROR);
} }
#ifdef ENABLE_IPV6 #ifdef ENABLE_IPV6
if (opt.ipv4_only && opt.ipv6_only) if (opt.ipv4_only && opt.ipv6_only)
@ -1269,7 +1269,7 @@ Can't timestamp and not clobber old files at the same time.\n"));
fprintf (stderr, fprintf (stderr,
_("Cannot specify both --inet4-only and --inet6-only.\n")); _("Cannot specify both --inet4-only and --inet6-only.\n"));
print_usage (1); print_usage (1);
exit (1); exit (WGET_EXIT_GENERIC_ERROR);
} }
#endif #endif
if (opt.output_document) if (opt.output_document)
@ -1281,7 +1281,7 @@ Can't timestamp and not clobber old files at the same time.\n"));
Cannot specify both -k and -O if multiple URLs are given, or in combination\n\ Cannot specify both -k and -O if multiple URLs are given, or in combination\n\
with -p or -r. See the manual for details.\n\n"), stderr); with -p or -r. See the manual for details.\n\n"), stderr);
print_usage (1); print_usage (1);
exit (1); exit (WGET_EXIT_GENERIC_ERROR);
} }
if (opt.page_requisites if (opt.page_requisites
|| opt.recursive) || opt.recursive)
@ -1303,7 +1303,7 @@ for details.\n\n"));
logprintf (LOG_VERBOSE, logprintf (LOG_VERBOSE,
_("File `%s' already there; not retrieving.\n"), _("File `%s' already there; not retrieving.\n"),
opt.output_document); opt.output_document);
exit(1); exit (WGET_EXIT_GENERIC_ERROR);
} }
} }
@ -1327,7 +1327,7 @@ for details.\n\n"));
{ {
fprintf (stderr, fprintf (stderr,
_("WARC output does not work with --spider.\n")); _("WARC output does not work with --spider.\n"));
exit (1); exit (WGET_EXIT_GENERIC_ERROR);
} }
if (opt.always_rest || opt.start_pos >= 0) if (opt.always_rest || opt.start_pos >= 0)
{ {
@ -1354,7 +1354,7 @@ for details.\n\n"));
fprintf (stderr, fprintf (stderr,
_("Cannot specify both --ask-password and --password.\n")); _("Cannot specify both --ask-password and --password.\n"));
print_usage (1); print_usage (1);
exit (1); exit (WGET_EXIT_GENERIC_ERROR);
} }
if (opt.start_pos >= 0 && opt.always_rest) if (opt.start_pos >= 0 && opt.always_rest)
@ -1374,7 +1374,7 @@ for details.\n\n"));
/* #### Something nicer should be printed here -- similar to the /* #### Something nicer should be printed here -- similar to the
pre-1.5 `--help' page. */ pre-1.5 `--help' page. */
fprintf (stderr, _("Try `%s --help' for more options.\n"), exec_name); fprintf (stderr, _("Try `%s --help' for more options.\n"), exec_name);
exit (1); exit (WGET_EXIT_GENERIC_ERROR);
} }
/* Compile the regular expressions. */ /* Compile the regular expressions. */
@ -1397,26 +1397,26 @@ for details.\n\n"));
{ {
opt.acceptregex = opt.regex_compile_fun (opt.acceptregex_s); opt.acceptregex = opt.regex_compile_fun (opt.acceptregex_s);
if (!opt.acceptregex) if (!opt.acceptregex)
exit (1); exit (WGET_EXIT_GENERIC_ERROR);
} }
if (opt.rejectregex_s) if (opt.rejectregex_s)
{ {
opt.rejectregex = opt.regex_compile_fun (opt.rejectregex_s); opt.rejectregex = opt.regex_compile_fun (opt.rejectregex_s);
if (!opt.rejectregex) if (!opt.rejectregex)
exit (1); exit (WGET_EXIT_GENERIC_ERROR);
} }
if (opt.post_data || opt.post_file_name) if (opt.post_data || opt.post_file_name)
{ {
if (opt.post_data && opt.post_file_name) if (opt.post_data && opt.post_file_name)
{ {
fprintf (stderr, _("You cannot specify both --post-data and --post-file.\n")); fprintf (stderr, _("You cannot specify both --post-data and --post-file.\n"));
exit (1); exit (WGET_EXIT_GENERIC_ERROR);
} }
else if (opt.method) else if (opt.method)
{ {
fprintf (stderr, _("You cannot use --post-data or --post-file along with --method. " fprintf (stderr, _("You cannot use --post-data or --post-file along with --method. "
"--method expects data through --body-data and --body-file options")); "--method expects data through --body-data and --body-file options"));
exit (1); exit (WGET_EXIT_GENERIC_ERROR);
} }
} }
if (opt.body_data || opt.body_file) if (opt.body_data || opt.body_file)
@ -1425,12 +1425,12 @@ for details.\n\n"));
{ {
fprintf (stderr, _("You must specify a method through --method=HTTPMethod " fprintf (stderr, _("You must specify a method through --method=HTTPMethod "
"to use with --body-data or --body-file.\n")); "to use with --body-data or --body-file.\n"));
exit (1); exit (WGET_EXIT_GENERIC_ERROR);
} }
else if (opt.body_data && opt.body_file) else if (opt.body_data && opt.body_file)
{ {
fprintf (stderr, _("You cannot specify both --body-data and --body-file.\n")); fprintf (stderr, _("You cannot specify both --body-data and --body-file.\n"));
exit (1); exit (WGET_EXIT_GENERIC_ERROR);
} }
} }
@ -1482,7 +1482,7 @@ for details.\n\n"));
{ {
/* sXXXav : be more specific... */ /* sXXXav : be more specific... */
fprintf (stderr, _("This version does not have support for IRIs\n")); fprintf (stderr, _("This version does not have support for IRIs\n"));
exit(1); exit (WGET_EXIT_GENERIC_ERROR);
} }
#endif #endif
@ -1491,7 +1491,7 @@ for details.\n\n"));
opt.passwd = prompt_for_password (); opt.passwd = prompt_for_password ();
if (opt.passwd == NULL || opt.passwd[0] == '\0') if (opt.passwd == NULL || opt.passwd[0] == '\0')
exit (1); exit (WGET_EXIT_GENERIC_ERROR);
} }
#ifdef USE_WATT32 #ifdef USE_WATT32
@ -1513,7 +1513,7 @@ for details.\n\n"));
if (url == NULL) if (url == NULL)
{ {
fprintf (stderr, _("Memory allocation problem\n")); fprintf (stderr, _("Memory allocation problem\n"));
exit (2); exit (WGET_EXIT_PARSE_ERROR);
} }
for (i = 0; i < nurl; i++, optind++) for (i = 0; i < nurl; i++, optind++)
{ {
@ -1574,7 +1574,7 @@ for details.\n\n"));
if (output_stream == NULL) if (output_stream == NULL)
{ {
perror (opt.output_document); perror (opt.output_document);
exit (1); exit (WGET_EXIT_GENERIC_ERROR);
} }
if (fstat (fileno (output_stream), &st) == 0 && S_ISREG (st.st_mode)) if (fstat (fileno (output_stream), &st) == 0 && S_ISREG (st.st_mode))
output_stream_regular = true; output_stream_regular = true;
@ -1584,7 +1584,7 @@ for details.\n\n"));
fprintf (stderr, _("-k can be used together with -O only if \ fprintf (stderr, _("-k can be used together with -O only if \
outputting to a regular file.\n")); outputting to a regular file.\n"));
print_usage (1); print_usage (1);
exit(1); exit (WGET_EXIT_GENERIC_ERROR);
} }
} }

View File

@ -42,6 +42,7 @@ as that of the covered work. */
#include "utils.h" #include "utils.h"
#include "url.h" #include "url.h"
#include "exits.h"
#ifndef ES_SYSTEM_REQUIRED #ifndef ES_SYSTEM_REQUIRED
#define ES_SYSTEM_REQUIRED 0x00000001 #define ES_SYSTEM_REQUIRED 0x00000001
@ -308,7 +309,7 @@ cleanup:
/* We're the parent. If all is well, terminate. */ /* We're the parent. If all is well, terminate. */
if (rv) if (rv)
exit (0); exit (WGET_EXIT_SUCCESS);
/* We failed, return. */ /* We failed, return. */
} }
@ -461,7 +462,7 @@ ws_startup (void)
{ {
fprintf (stderr, _("%s: Couldn't find usable socket driver.\n"), fprintf (stderr, _("%s: Couldn't find usable socket driver.\n"),
exec_name); exec_name);
exit (1); exit (WGET_EXIT_GENERIC_ERROR);
} }
if (data.wVersion < requested) if (data.wVersion < requested)
@ -469,7 +470,7 @@ ws_startup (void)
fprintf (stderr, _("%s: Couldn't find usable socket driver.\n"), fprintf (stderr, _("%s: Couldn't find usable socket driver.\n"),
exec_name); exec_name);
WSACleanup (); WSACleanup ();
exit (1); exit (WGET_EXIT_GENERIC_ERROR);
} }
atexit (ws_cleanup); atexit (ws_cleanup);

View File

@ -448,7 +448,7 @@ main (int argc, char **argv)
if (argc < 2 || argc > 3) if (argc < 2 || argc > 3)
{ {
fprintf (stderr, _("Usage: %s NETRC [HOSTNAME]\n"), argv[0]); fprintf (stderr, _("Usage: %s NETRC [HOSTNAME]\n"), argv[0]);
exit (1); exit (WGET_EXIT_GENERIC_ERROR);
} }
program_name = argv[0]; program_name = argv[0];
@ -459,7 +459,7 @@ main (int argc, char **argv)
{ {
fprintf (stderr, _("%s: cannot stat %s: %s\n"), argv[0], file, fprintf (stderr, _("%s: cannot stat %s: %s\n"), argv[0], file,
strerror (errno)); strerror (errno));
exit (1); exit (WGET_EXIT_GENERIC_ERROR);
} }
head = parse_netrc (file); head = parse_netrc (file);
@ -498,14 +498,14 @@ main (int argc, char **argv)
/* Exit if we found the target. */ /* Exit if we found the target. */
if (target) if (target)
exit (0); exit (WGET_EXIT_SUCCESS);
a = a->next; a = a->next;
} }
/* Exit with failure if we had a target, success otherwise. */ /* Exit with failure if we had a target, success otherwise. */
if (target) if (target)
exit (1); exit (WGET_EXIT_GENERIC_ERROR);
exit (0); exit (WGET_EXIT_SUCCESS);
} }
#endif /* STANDALONE */ #endif /* STANDALONE */

View File

@ -100,6 +100,8 @@ as that of the covered work. */
#include "test.h" #include "test.h"
#endif #endif
#include "exits.h"
static void static void
memfatal (const char *context, long attempted_size) memfatal (const char *context, long attempted_size)
{ {
@ -123,7 +125,7 @@ memfatal (const char *context, long attempted_size)
exec_name, context, attempted_size); exec_name, context, attempted_size);
} }
exit (1); exit (WGET_EXIT_GENERIC_ERROR);
} }
/* Character property table for (re-)escaping VMS ODS5 extended file /* Character property table for (re-)escaping VMS ODS5 extended file
@ -471,7 +473,7 @@ fork_to_background (void)
{ {
/* parent, error */ /* parent, error */
perror ("fork"); perror ("fork");
exit (1); exit (WGET_EXIT_GENERIC_ERROR);
} }
else if (pid != 0) else if (pid != 0)
{ {
@ -479,7 +481,7 @@ fork_to_background (void)
printf (_("Continuing in background, pid %d.\n"), (int) pid); printf (_("Continuing in background, pid %d.\n"), (int) pid);
if (logfile_changed) if (logfile_changed)
printf (_("Output will be written to %s.\n"), quote (opt.lfilename)); printf (_("Output will be written to %s.\n"), quote (opt.lfilename));
exit (0); /* #### should we use _exit()? */ exit (WGET_EXIT_SUCCESS); /* #### should we use _exit()? */
} }
/* child: give up the privileges and keep running. */ /* child: give up the privileges and keep running. */

View File

@ -56,6 +56,7 @@ as that of the covered work. */
#endif #endif
#include "warc.h" #include "warc.h"
#include "exits.h"
#ifndef O_TEMPORARY #ifndef O_TEMPORARY
#define O_TEMPORARY 0 #define O_TEMPORARY 0
@ -1038,7 +1039,7 @@ warc_init (void)
logprintf (LOG_NOTQUIET, logprintf (LOG_NOTQUIET,
_("Could not read CDX file %s for deduplication.\n"), _("Could not read CDX file %s for deduplication.\n"),
quote (opt.warc_cdx_dedup_filename)); quote (opt.warc_cdx_dedup_filename));
exit(1); exit (WGET_EXIT_GENERIC_ERROR);
} }
} }
@ -1047,7 +1048,7 @@ warc_init (void)
{ {
logprintf (LOG_NOTQUIET, logprintf (LOG_NOTQUIET,
_("Could not open temporary WARC manifest file.\n")); _("Could not open temporary WARC manifest file.\n"));
exit(1); exit (WGET_EXIT_GENERIC_ERROR);
} }
if (opt.warc_keep_log) if (opt.warc_keep_log)
@ -1057,7 +1058,7 @@ warc_init (void)
{ {
logprintf (LOG_NOTQUIET, logprintf (LOG_NOTQUIET,
_("Could not open temporary WARC log file.\n")); _("Could not open temporary WARC log file.\n"));
exit(1); exit (WGET_EXIT_GENERIC_ERROR);
} }
log_set_warc_log_fp (warc_log_fp); log_set_warc_log_fp (warc_log_fp);
} }
@ -1066,7 +1067,7 @@ warc_init (void)
if (! warc_start_new_file (false)) if (! warc_start_new_file (false))
{ {
logprintf (LOG_NOTQUIET, _("Could not open WARC file.\n")); logprintf (LOG_NOTQUIET, _("Could not open WARC file.\n"));
exit(1); exit (WGET_EXIT_GENERIC_ERROR);
} }
if (opt.warc_cdx_enabled) if (opt.warc_cdx_enabled)
@ -1075,7 +1076,7 @@ warc_init (void)
{ {
logprintf (LOG_NOTQUIET, logprintf (LOG_NOTQUIET,
_("Could not open CDX file for output.\n")); _("Could not open CDX file for output.\n"));
exit(1); exit (WGET_EXIT_GENERIC_ERROR);
} }
} }
} }
@ -1103,7 +1104,7 @@ warc_write_metadata (void)
if (warc_tmp_fp == NULL) if (warc_tmp_fp == NULL)
{ {
logprintf (LOG_NOTQUIET, _("Could not open temporary WARC file.\n")); logprintf (LOG_NOTQUIET, _("Could not open temporary WARC file.\n"));
exit(1); exit (WGET_EXIT_GENERIC_ERROR);
} }
fflush (warc_tmp_fp); fflush (warc_tmp_fp);
fprintf (warc_tmp_fp, "%s\n", program_argstring); fprintf (warc_tmp_fp, "%s\n", program_argstring);

View File

@ -21,7 +21,7 @@ my %urls = (
); );
unless(-e "/dev/full") { unless(-e "/dev/full") {
exit(2); # skip exit 2; # skip
} }
my $cmdline = $WgetTest::WGETPATH . " -c http://localhost:{{port}}/somefile.txt -O /dev/full"; my $cmdline = $WgetTest::WGETPATH . " -c http://localhost:{{port}}/somefile.txt -O /dev/full";