+/*********************************************************************
+ *
+ * Function : enlist_unique_header
+ *
+ * Description : Make a HTTP header from the two strings name and value,
+ * and append the result into a specified string list,
+ * if & only if there isn't already a header with that name.
+ *
+ * Parameters :
+ * 1 : header = pointer to list 'dummy' header
+ * 2 : first = first string to add to the list (maybe NULL)
+ * 3 : second = number of chars to use for uniqueness test
+ *
+ * Returns : N/A
+ *
+ *********************************************************************/
+void enlist_unique_header(struct list *header, const char *name, const char *value)
+{
+ struct list *last;
+ struct list *cur = header->next;
+ int length;
+ char *dummy;
+
+ if (name == NULL || value == NULL) return;
+
+ dummy = strdup(name);
+ dummy = strsav(dummy, ": ");
+ length = strlen(dummy);
+
+ while (cur != NULL)
+ {
+ if ((cur->str != NULL) &&
+ (0 == strncmp(dummy, cur->str, length)))
+ {
+ /* Already there */
+ return;
+ }
+ cur = cur->next;
+ }
+
+ cur = (struct list *)malloc(sizeof(*cur));
+
+ if (cur != NULL)
+ {
+ cur->str = strsav(dummy, value);
+ cur->next = NULL;
+
+ last = header->last;
+ if (last == NULL)
+ {
+ last = header;
+ }
+ last->next = cur;
+ header->last = cur;
+ }
+}
+
+