-const char list_rcs[] = "$Id: list.c,v 1.22 2010/11/22 10:32:40 fabiankeil Exp $";
+const char list_rcs[] = "$Id: list.c,v 1.28 2012/03/09 16:23:50 fabiankeil Exp $";
/*********************************************************************
*
* File : $Source: /cvsroot/ijbswa/current/list.c,v $
*
* Purpose : Declares functions to handle lists.
- * Functions declared include:
- * `destroy_list', `enlist' and `list_to_text'
*
* Copyright : Written by and Copyright (C) 2001-2007 the SourceForge
* Privoxy team. http://www.privoxy.org/
* Note that the 1000 limit was hit by a real user in tracker 911950;
* removing it for now. Real circular references should eventually
* be caught by the check above, anyway.
- */
+ */
/*
if (entry > 1000)
- {
+ {
return 0;
- }
- */
+ }
+ */
/*
* Check this isn't marked as the last entry, unless of course it's
{
for (cur_entry = the_list->first; cur_entry != NULL; cur_entry = cur_entry->next)
{
- if ( (cur_entry->str != NULL)
+ if ((cur_entry->str != NULL)
&& (0 == strncmp(str, cur_entry->str, num_significant_chars)))
{
/* Already there */
/* Test whole string */
for (cur_entry = the_list->first; cur_entry != NULL; cur_entry = cur_entry->next)
{
- if ( (cur_entry->str != NULL) && (0 == strcmp(str, cur_entry->str)))
+ if ((cur_entry->str != NULL) && (0 == strcmp(str, cur_entry->str)))
{
/* Already there */
return JB_ERR_OK;
if (NULL != header)
{
const size_t bytes_to_compare = strlen(name) + 2;
+ char *p = header;
snprintf(header, header_size, "%s: %s", name, value);
+ /*
+ * The trailing "\r\n" is added by list_to_text(),
+ * if the caller passed them anyway, cut the header
+ * at the first one or dump core if this is a debug
+ * build.
+ */
+ do
+ {
+ if ((*p == '\r') || (*p == '\n'))
+ {
+ assert(*p != '\r');
+ assert(*p != '\n');
+ *p = '\0';
+ }
+ } while (*p++);
result = enlist_unique(the_list, header, bytes_to_compare);
free(header);
assert(list_is_valid(the_list));
if (entry->str == NULL)
{
/*
- * NULL pointers are allowed in some lists.
+ * NULL pointers are allowed in some lists.
* For example for csp->headers in case a
* header was removed.
*/
*
* Note: Since all strings will be free()d in free_map()
* later, set the copy flags for constants or
- * strings that will be independantly free()d.
+ * strings that will be independently free()d.
*
* Note2: This function allows NULL parameters - it
* returns JB_ERR_MEMORY in that case.
if ( (NULL == value)
|| (NULL == name)
- || (NULL == (new_entry = zalloc(sizeof(*new_entry)))) )
+ || (NULL == (new_entry = zalloc(sizeof(*new_entry)))))
{
if ((name != NULL) && (!name_needs_copying))
{
assert(the_map);
assert(name);
-
+
last_entry = the_map->first;
for (cur_entry = the_map->first; cur_entry != NULL; cur_entry = cur_entry->next)
}
/*
- * Update the map's last pointer
+ * Update the map's last pointer
*/
if (cur_entry == the_map->last)
{
the_map->last = last_entry;
}
-
+
/*
* Free the map_entry
*/