diff options
Diffstat (limited to 'WWW/Library/Implementation/HTAssoc.c')
-rw-r--r-- | WWW/Library/Implementation/HTAssoc.c | 62 |
1 files changed, 30 insertions, 32 deletions
diff --git a/WWW/Library/Implementation/HTAssoc.c b/WWW/Library/Implementation/HTAssoc.c index f3bfff9e..112f70a9 100644 --- a/WWW/Library/Implementation/HTAssoc.c +++ b/WWW/Library/Implementation/HTAssoc.c @@ -1,20 +1,20 @@ /* MODULE HTAssoc.c -** ASSOCIATION LIST FOR STORING NAME-VALUE PAIRS. -** NAMES NOT CASE SENSITIVE, AND ONLY COMMON LENGTH -** IS CHECKED (allows abbreviations; well, length is -** taken from lookup-up name, so if table contains -** a shorter abbrev it is not found). -** AUTHORS: -** AL Ari Luotonen luotonen@dxcern.cern.ch -** -** HISTORY: -** -** -** BUGS: -** -** -*/ + * ASSOCIATION LIST FOR STORING NAME-VALUE PAIRS. + * NAMES NOT CASE SENSITIVE, AND ONLY COMMON LENGTH + * IS CHECKED (allows abbreviations; well, length is + * taken from lookup-up name, so if table contains + * a shorter abbrev it is not found). + * AUTHORS: + * AL Ari Luotonen luotonen@dxcern.cern.ch + * + * HISTORY: + * + * + * BUGS: + * + * + */ #include <HTUtils.h> @@ -22,18 +22,18 @@ #include <LYLeaks.h> -HTAssocList *HTAssocList_new (void) +HTAssocList *HTAssocList_new(void) { return HTList_new(); } - -void HTAssocList_delete (HTAssocList * alist) +void HTAssocList_delete(HTAssocList *alist) { if (alist) { HTAssocList *cur = alist; HTAssoc *assoc; - while (NULL != (assoc = (HTAssoc*)HTList_nextObject(cur))) { + + while (NULL != (assoc = (HTAssoc *) HTList_nextObject(cur))) { FREE(assoc->name); FREE(assoc->value); FREE(assoc); @@ -43,16 +43,16 @@ void HTAssocList_delete (HTAssocList * alist) } } - -void HTAssocList_add (HTAssocList * alist, - const char * name, - const char * value) +void HTAssocList_add(HTAssocList *alist, + const char *name, + const char *value) { HTAssoc *assoc; if (alist) { - if (!(assoc = (HTAssoc*)malloc(sizeof(HTAssoc)))) - outofmem(__FILE__, "HTAssoc_add"); + if (!(assoc = (HTAssoc *) malloc(sizeof(HTAssoc)))) + outofmem(__FILE__, "HTAssoc_add"); + assoc->name = NULL; assoc->value = NULL; @@ -60,23 +60,21 @@ void HTAssocList_add (HTAssocList * alist, StrAllocCopy(assoc->name, name); if (value) StrAllocCopy(assoc->value, value); - HTList_addObject(alist, (void*)assoc); + HTList_addObject(alist, (void *) assoc); } else { - CTRACE((tfp, "HTAssoc_add: ERROR: assoc list NULL!!\n")); + CTRACE((tfp, "HTAssoc_add: ERROR: assoc list NULL!!\n")); } } - -char *HTAssocList_lookup (HTAssocList * alist, - const char * name) +char *HTAssocList_lookup(HTAssocList *alist, + const char *name) { HTAssocList *cur = alist; HTAssoc *assoc; - while (NULL != (assoc = (HTAssoc*)HTList_nextObject(cur))) { + while (NULL != (assoc = (HTAssoc *) HTList_nextObject(cur))) { if (!strncasecomp(assoc->name, name, strlen(name))) return assoc->value; } return NULL; } - |