+ * Returns : JB_ERR_OK on success
+ * JB_ERR_MEMORY on out-of-memory error.
+ * On error, some (but not all) of src might have
+ * been copied into dest.
+ *
+ *********************************************************************/
+jb_err list_append_list_unique(struct list *dest, const struct list *src)
+{
+ struct list_entry * cur;
+
+ assert(src);
+ assert(dest);
+ assert(list_is_valid(src));
+ assert(list_is_valid(dest));
+
+ for (cur = src->first; cur; cur = cur->next)
+ {
+ if (cur->str)
+ {
+ if (enlist_unique(dest, cur->str, 0))
+ {
+ assert(list_is_valid(src));
+ assert(list_is_valid(dest));
+
+ return JB_ERR_MEMORY;
+ }
+ }
+ }
+
+ assert(list_is_valid(src));
+ assert(list_is_valid(dest));
+
+ return JB_ERR_OK;
+}
+
+
+/*********************************************************************
+ *
+ * Function : list_is_empty
+ *
+ * Description : Test whether a list is empty. Does not change the list.
+ *
+ * Parameters :
+ * 1 : the_list = pointer to list to test.
+ *
+ * Returns : Nonzero if the list contains no entries.
+ *
+ *********************************************************************/
+int list_is_empty(const struct list *the_list)
+{
+ assert(the_list);
+ assert(list_is_valid(the_list));
+
+ return (the_list->first == NULL);
+}
+
+
+/*********************************************************************
+ *
+ * Function : list_contains_item
+ *
+ * Description : Tests whether a list item is already set.
+ * Does not change the list.
+ *
+ * Parameters :
+ * 1 : the_list = list to search in
+ * 2 : str = string to search for
+ *
+ * Returns : TRUE if the item was found,
+ * FALSE otherwise.
+ *
+ *********************************************************************/
+int list_contains_item(const struct list *the_list, const char *str)
+{
+ struct list_entry *entry;
+
+ assert(the_list);
+ assert(list_is_valid(the_list));
+ assert(str);
+
+ for (entry = the_list->first; entry != NULL; entry = entry->next)
+ {
+ if (entry->str == NULL)
+ {
+ /*
+ * NULL pointers are allowed in some lists.
+ * For example for csp->headers in case a
+ * header was removed.
+ */
+ continue;
+ }
+
+ if (0 == strcmp(str, entry->str))
+ {
+ /* Item found */
+ return TRUE;
+ }
+ }
+
+ return FALSE;
+}
+
+
+/*********************************************************************
+ *
+ * Function : new_map
+ *
+ * Description : Create a new, empty map.
+ * Causes program exit if the memory allocation fails.
+ *
+ * Parameters : N/A
+ *
+ * Returns : A new, empty map
+ *
+ *********************************************************************/
+struct map *new_map(void)
+{
+ struct map *empty_map = zalloc(sizeof(struct map));
+
+ if (NULL == empty_map)
+ {
+ exit(1);
+ }
+
+ return empty_map;
+
+}
+
+
+/*********************************************************************
+ *
+ * Function : free_map
+ *
+ * Description : Free the memory occupied by a map and its
+ * dependent strings
+ *
+ * Parameters :
+ * 1 : the_map = map to be freed. May be NULL.
+ *