+2005-05-30 Hrvoje Niksic <hniksic@xemacs.org>
+
+ * init.c (cmd_spec_header): Don't split the string along the
+ commas using cmd_vector; just append the new value using
+ vec_append instead.
+
+ * utils.c (vec_append): New function.
+
2005-05-27 Andreas Beckmann <debian@abeckmann.de>
* html-url.c (tag_handle_link): Mark the content from the <link
{ "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 },
}
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
xfree (v2);
return v1;
}
+
+/* Append a freshly allocated copy of STR to VEC. If VEC is NULL, it
+ is allocated as needed. Return the new value of the vector. */
+
+char **
+vec_append (char **vec, const char *str)
+{
+ int cnt; /* count of vector elements, including
+ the one we're about to append */
+ if (vec != NULL)
+ {
+ for (cnt = 0; vec[cnt]; cnt++)
+ ;
+ ++cnt;
+ }
+ else
+ cnt = 1;
+ /* Reallocate the array to fit the new element and the NULL. */
+ vec = xrealloc (vec, (cnt + 1) * sizeof (char *));
+ /* Append a copy of STR to the vector. */
+ vec[cnt - 1] = xstrdup (str);
+ vec[cnt] = NULL;
+ return vec;
+}
\f
/* Sometimes it's useful to create "sets" of strings, i.e. special
hash tables where you want to store strings as keys and merely
void free_vec PARAMS ((char **));
char **merge_vecs PARAMS ((char **, char **));
+char **vec_append PARAMS ((char **, const char *));
void string_set_add PARAMS ((struct hash_table *, const char *));
int string_set_contains PARAMS ((struct hash_table *, const char *));