# HG changeset patch # User Sebastien Decugis # Date 1319974408 -3600 # Node ID 27fef2ca2cf6d23fd6b3d0cf2633e28aa7daf530 # Parent 99136ec7d9d449e46d72210ba33cf756fd1d86b3 Improved usability of fd_dict_getlistof for vendors and apps diff -r 99136ec7d9d4 -r 27fef2ca2cf6 libfdproto/dictionary.c --- a/libfdproto/dictionary.c Tue Oct 25 21:48:52 2011 +0200 +++ b/libfdproto/dictionary.c Sun Oct 30 12:33:28 2011 +0100 @@ -1968,7 +1968,7 @@ #define NO_VENDOR_NAME "(no vendor)" new->dict_vendors.data.vendor.vendor_name = NO_VENDOR_NAME; new->dict_vendors.datastr_len = CONSTSTRLEN(NO_VENDOR_NAME); - new->dict_vendors.list[0].o = NULL; /* overwrite since element is also sentinel for this list. */ + /* new->dict_vendors.list[0].o = NULL; *//* overwrite since element is also sentinel for this list. */ new->dict_vendors.dico = new; /* Initialize the sentinel for applications */ @@ -1976,7 +1976,7 @@ #define APPLICATION_0_NAME "Diameter Common Messages" new->dict_applications.data.application.application_name = APPLICATION_0_NAME; new->dict_applications.datastr_len = CONSTSTRLEN(APPLICATION_0_NAME); - new->dict_applications.list[0].o = NULL; /* overwrite since since element is also sentinel for this list. */ + /* new->dict_applications.list[0].o = NULL; *//* overwrite since since element is also sentinel for this list. */ new->dict_applications.dico = new; /* Initialize the sentinel for types */ diff -r 99136ec7d9d4 -r 27fef2ca2cf6 tests/testdict.c --- a/tests/testdict.c Tue Oct 25 21:48:52 2011 +0200 +++ b/tests/testdict.c Sun Oct 30 12:33:28 2011 +0100 @@ -136,12 +136,19 @@ enum dict_object_type type; struct dict_object * defvnd=NULL; vendor_id_t vid = 0; + int first = 1; CHECK( 0, fd_dict_getlistof(VENDOR_BY_ID, fd_g_config->cnf_dict, &sentinel)); - for (li = sentinel->next; li != sentinel; li = li->next) { + for (li = sentinel; (li != sentinel) || (first != 0); li = li->next) { + first = 0; CHECK(0, fd_dict_gettype(li->o, &type)); CHECK(DICT_VENDOR, type); +#if 0 + struct dict_vendor_data data; + CHECK( 0, fd_dict_getval(li->o, &data) ); + printf("%d : %s\n", data.vendor_id, data.vendor_name); +#endif } CHECK( 0, fd_dict_search(fd_g_config->cnf_dict, DICT_VENDOR, VENDOR_BY_ID, &vid, &defvnd, ENOENT) );