From: Josh G. <ja...@us...> - 2003-10-30 09:20:48
|
Update of /cvsroot/gift/giFT/src In directory sc8-pr-cvs1:/tmp/cvs-serv11982/src Modified Files: plugin.c Log Message: case-insensitive plugin lookup Index: plugin.c =================================================================== RCS file: /cvsroot/gift/giFT/src/plugin.c,v retrieving revision 1.58 retrieving revision 1.59 diff -C2 -d -r1.58 -r1.59 *** plugin.c 11 Aug 2003 18:18:51 -0000 1.58 --- plugin.c 30 Oct 2003 09:20:41 -0000 1.59 *************** *** 90,94 **** --- 90,102 ---- assert (p != NULL); + /* this better not happen */ assert (dataset_lookupstr (plugins, p->name) == NULL); + + if (!plugins) + { + plugins = dataset_new (DATASET_LIST); + assert (plugins != NULL); + } + dataset_insert (&plugins, p->name, STRLEN_0(p->name), p, 0); } *************** *** 104,111 **** /* see setup_functbl */ ! static BOOL dummy_bool_false (/*< void >*/) { return FALSE; } ! static BOOL dummy_bool_true (/*< void >*/) { return TRUE; } ! static int dummy_int_zero (/*< void >*/) { return 0; } ! static void dummy_void (/*< void >*/) { /* ... */ } static void *dummy_voidptr_null (/*< void >*/) { return NULL; } --- 112,119 ---- /* see setup_functbl */ ! static BOOL dummy_bool_false (/*< void >*/) { return FALSE; } ! static BOOL dummy_bool_true (/*< void >*/) { return TRUE; } ! static int dummy_int_zero (/*< void >*/) { return 0; } ! static void dummy_void (/*< void >*/) { /* ... */ } static void *dummy_voidptr_null (/*< void >*/) { return NULL; } *************** *** 659,662 **** --- 667,684 ---- /*****************************************************************************/ + static int lookup_casecmp (ds_data_t *key, ds_data_t *value, const char *pname) + { + char *keystr; + + /* store as a char* and check for NUL termination */ + keystr = key->data; + assert (keystr[key->len - 1] == 0); + + if (strcasecmp (keystr, pname) == 0) + return DS_FOUND; + + return DS_NOTFOUND; + } + Protocol *plugin_lookup (const char *pname) { *************** *** 664,668 **** return NULL; ! return dataset_lookupstr (plugins, pname); } --- 686,692 ---- return NULL; ! /* apply a case-insensitive lookup, mainly to comply with RFC1738's ! * specification of the URL scheme */ ! return dataset_find (plugins, DS_FIND(lookup_casecmp), (char *)pname); } |