+
+ freez(config->confdir);
+ freez(config->logdir);
+ freez(config->templdir);
+ freez(config->hostname);
+#ifdef FEATURE_EXTERNAL_FILTERS
+ freez(config->temporary_directory);
+#endif
+
+ for (i = 0; i < MAX_LISTENING_SOCKETS; i++)
+ {
+ freez(config->haddr[i]);
+ }
+ freez(config->logfile);
+
+ for (i = 0; i < MAX_AF_FILES; i++)
+ {
+ freez(config->actions_file_short[i]);
+ freez(config->actions_file[i]);
+ freez(config->re_filterfile_short[i]);
+ freez(config->re_filterfile[i]);
+ }
+
+ list_remove_all(config->ordered_client_headers);
+
+ freez(config->admin_address);
+ freez(config->proxy_info_url);
+ freez(config->proxy_args);
+ freez(config->usermanual);
+ freez(config->trusted_cgi_referrer);
+
+#ifdef FEATURE_TRUST
+ freez(config->trustfile);
+ list_remove_all(config->trust_info);
+#endif /* def FEATURE_TRUST */
+
+#ifdef FEATURE_CLIENT_TAGS
+ free_client_specific_tags(config->client_tags);
+#endif
+
+ freez(config);
+}
+
+
+#ifdef FEATURE_GRACEFUL_TERMINATION
+/*********************************************************************
+ *
+ * Function : unload_current_config_file
+ *
+ * Description : Unloads current config file - reset to state at
+ * beginning of program.
+ *
+ * Parameters : None
+ *
+ * Returns : N/A
+ *
+ *********************************************************************/
+void unload_current_config_file(void)
+{
+ if (current_configfile)
+ {
+ current_configfile->unloader = unload_configfile;
+ current_configfile = NULL;
+ }
+}
+#endif
+
+
+#ifdef FEATURE_CLIENT_TAGS
+/*********************************************************************
+ *
+ * Function : register_tag
+ *
+ * Description : Registers a client-specific-tag and its description
+ *
+ * Parameters :
+ * 1 : config: The tag list
+ * 2 : name: The name of the client-specific-tag
+ * 3 : description: The human-readable description for the tag
+ *
+ * Returns : N/A
+ *
+ *********************************************************************/
+static void register_tag(struct client_tag_spec *tag_list,
+ const char *name, const char *description)
+{
+ struct client_tag_spec *new_tag;
+ struct client_tag_spec *last_tag;
+
+ last_tag = tag_list;
+ while (last_tag->next != NULL)
+ {
+ last_tag = last_tag->next;
+ }
+ if (last_tag->name == NULL)
+ {
+ /* First entry */
+ new_tag = last_tag;
+ }
+ else
+ {
+ new_tag = zalloc_or_die(sizeof(struct client_tag_spec));
+ }
+ new_tag->name = strdup_or_die(name);
+ new_tag->description = strdup_or_die(description);
+ if (new_tag != last_tag)
+ {
+ last_tag->next = new_tag;
+ }
+}
+
+
+/*********************************************************************
+ *
+ * Function : free_client_specific_tags
+ *
+ * Description : Frees client-specific tags and their descriptions
+ *
+ * Parameters :
+ * 1 : tag_list: The tag list to free
+ *
+ * Returns : N/A
+ *
+ *********************************************************************/
+static void free_client_specific_tags(struct client_tag_spec *tag_list)
+{
+ struct client_tag_spec *this_tag;
+ struct client_tag_spec *next_tag;
+
+ next_tag = tag_list;
+ do
+ {
+ this_tag = next_tag;
+ next_tag = next_tag->next;
+
+ freez(this_tag->name);
+ freez(this_tag->description);
+
+ if (this_tag != tag_list)
+ {
+ freez(this_tag);
+ }
+ } while (next_tag != NULL);
+}
+#endif /* def FEATURE_CLIENT_TAGS */
+
+
+/*********************************************************************
+ *
+ * Function : parse_numeric_value
+ *
+ * Description : Parse the value of a directive that can only have
+ * a single numeric value. Terminates with a fatal error
+ * if the value is NULL or not numeric.
+ *
+ * Parameters :
+ * 1 : name: The name of the directive. Used for log messages.
+ * 2 : value: The value to parse
+ *
+ *
+ * Returns : The numerical value as integer
+ *
+ *********************************************************************/
+static int parse_numeric_value(const char *name, const char *value)
+{
+ int number;
+ char *endptr;
+
+ assert(name != NULL);
+ assert(value != NULL);
+
+ if ((value == NULL) || (*value == '\0'))
+ {
+ log_error(LOG_LEVEL_FATAL, "Directive %s used without argument", name);
+ }
+
+ number = (int)strtol(value, &endptr, 0);
+ if (*endptr != '\0')
+ {
+ log_error(LOG_LEVEL_FATAL,
+ "Directive '%s' used with non-numerical value: '%s'", name, value);
+ }
+
+ return number;
+
+}
+
+
+/*********************************************************************
+ *
+ * Function : parse_toggle_value
+ *
+ * Description : Parse the value of a directive that can only be
+ * enabled or disabled. Terminates with a fatal error
+ * if the value is NULL or something other than 0 or 1.
+ *
+ * Parameters :
+ * 1 : name: The name of the directive. Used for log messages.
+ * 2 : value: The value to parse
+ *
+ *
+ * Returns : The numerical toggle state
+ *
+ *********************************************************************/
+static int parse_toggle_state(const char *name, const char *value)
+{
+ int toggle_state;
+ assert(name != NULL);
+ assert(value != NULL);
+
+ if ((value == NULL) || (*value == '\0'))
+ {
+ log_error(LOG_LEVEL_FATAL, "Directive %s used without argument", name);
+ }
+
+ toggle_state = atoi(value);
+
+ /*
+ * Also check the length as atoi() doesn't mind
+ * garbage after a valid integer, but we do.
+ */
+ if (((toggle_state != 0) && (toggle_state != 1)) || (strlen(value) != 1))
+ {
+ log_error(LOG_LEVEL_FATAL,
+ "Directive %s used with invalid argument '%s'. Use either '0' or '1'.",
+ name, value);
+ }
+
+ return toggle_state;
+
+}
+
+
+/*********************************************************************
+ *
+ * Function : parse_client_header_order
+ *
+ * Description : Parse the value of the header-order directive
+ *
+ * Parameters :
+ * 1 : ordered_header_list: List to insert the ordered
+ * headers into.
+ * 2 : ordered_headers: The ordered header names separated
+ * by spaces or tabs.
+ *
+ *
+ * Returns : N/A
+ *
+ *********************************************************************/
+static void parse_client_header_order(struct list *ordered_header_list, const char *ordered_headers)
+{
+ char *original_headers_copy;
+ char **vector;
+ size_t max_segments;
+ int number_of_headers;
+ int i;
+
+ assert(ordered_header_list != NULL);
+ assert(ordered_headers != NULL);
+
+ if (ordered_headers == NULL)