function. When adding a new command, simply add it to the list,
but be sure to keep the list sorted alphabetically, as
command_by_name depends on it. Also, be sure to add any entries
- that allocate memory (e.g. cmd_string and cmd_vector guys) to the
+ that allocate memory (e.g. cmd_string and cmd_vector) to the
cleanup() function below. */
static struct {
{ "forcehtml", &opt.force_html, cmd_boolean },
{ "ftppasswd", &opt.ftp_passwd, cmd_string }, /* deprecated */
{ "ftppassword", &opt.ftp_passwd, cmd_string },
- { "ftpuser", &opt.ftp_user, cmd_string },
{ "ftpproxy", &opt.ftp_proxy, cmd_string },
+ { "ftpuser", &opt.ftp_user, cmd_string },
{ "glob", &opt.ftp_glob, cmd_boolean },
- { "header", &opt.user_headers, cmd_spec_header },
+ { "header", NULL, cmd_spec_header },
{ "htmlextension", &opt.html_extension, cmd_boolean },
{ "htmlify", NULL, cmd_spec_htmlify },
{ "httpkeepalive", &opt.http_keep_alive, cmd_boolean },
setval_internal (int comind, const char *com, const char *val)
{
assert (0 <= comind && comind < countof (commands));
- DEBUGP (("Setting %s (%d) to %s\n", com, comind, val));
+ DEBUGP (("Setting %s (%s) to %s\n", com, commands[comind].name, val));
return ((*commands[comind].action) (com, val, commands[comind].place));
}
{
char *com, *val;
int comind;
- int status = parse_line (opt, &com, &val, &comind);
- if (status == 1)
+ switch (parse_line (opt, &com, &val, &comind))
{
+ case line_ok:
if (!setval_internal (comind, com, val))
exit (2);
xfree (com);
xfree (val);
- }
- else if (status == 0)
- {
+ break;
+ default:
fprintf (stderr, _("%s: Invalid --execute command `%s'\n"),
exec_name, opt);
exit (2);
}
static int
-cmd_spec_header (const char *com, const char *val, void *place)
+cmd_spec_header (const char *com, const char *val, void *place_ignored)
{
+ /* Empty value means reset the list of headers. */
+ if (*val == '\0')
+ {
+ free_vec (opt.user_headers);
+ opt.user_headers = NULL;
+ return 1;
+ }
+
if (!check_user_specified_header (val))
{
fprintf (stderr, _("%s: %s: Invalid header `%s'.\n"),
exec_name, com, val);
return 0;
}
- return cmd_vector (com, val, place);
+ opt.user_headers = vec_append (opt.user_headers, val);
+ return 1;
}
static int
static int
cmd_spec_useragent (const char *com, const char *val, void *place_ignored)
{
- /* Just check for empty string and newline, so we don't throw total
- junk to the server. */
- if (!*val || strchr (val, '\n'))
+ /* Disallow embedded newlines. */
+ if (strchr (val, '\n'))
{
fprintf (stderr, _("%s: %s: Invalid value `%s'.\n"),
exec_name, com, val);
free_vec (opt.follow_tags);
free_vec (opt.ignore_tags);
xfree_null (opt.progress_type);
- xfree (opt.ftp_acc);
xfree_null (opt.ftp_user);
xfree_null (opt.ftp_passwd);
xfree_null (opt.ftp_proxy);
# ifdef HAVE_SSL
xfree_null (opt.cert_file);
xfree_null (opt.private_key);
+ xfree_null (opt.ca_directory);
+ xfree_null (opt.ca_cert);
+ xfree_null (opt.random_file);
+ xfree_null (opt.egd_file);
# endif
xfree_null (opt.bind_address);
xfree_null (opt.cookies_input);