X-Git-Url: http://git.silcnet.org/gitweb/?a=blobdiff_plain;f=lib%2Fsilcutil%2Ftests%2Ftest_silchashtable.c;h=742b372872c9e7172f21b9e8c26d450110946390;hb=562927f2871fedc49ec9e3e7e74bf93cbcafb71e;hp=21b3fca3364c2da61ea6b337d02c9de1b8e57045;hpb=40f8443d8d3a6577336ee66d18e04d9ac4d956bb;p=silc.git diff --git a/lib/silcutil/tests/test_silchashtable.c b/lib/silcutil/tests/test_silchashtable.c index 21b3fca3..742b3728 100644 --- a/lib/silcutil/tests/test_silchashtable.c +++ b/lib/silcutil/tests/test_silchashtable.c @@ -49,7 +49,7 @@ SilcBool add_entries() e = silc_calloc(1, sizeof(*e)); if (!e) return FALSE; - snprintf(e->name, sizeof(e->name), "%d", i); + silc_snprintf(e->name, sizeof(e->name), "%d", i); e->val = i; silc_hash_table_add(t, (void *)e, (void *)e->name); @@ -99,7 +99,7 @@ SilcBool del_n_entries_foreach() for (i = 0; i < count; i++) { memset(&f, 0, sizeof(f)); - snprintf(f.name, sizeof(f.name), "%d", i); + silc_snprintf(f.name, sizeof(f.name), "%d", i); f.val = i; silc_hash_table_find_foreach(t, &f, del_foreach, NULL); @@ -120,7 +120,7 @@ SilcBool alloc_table() SILC_LOG_DEBUG(("Allocating hash table with %d entries (%s)", count, auto_rehash ? "auto rehash" : "no auto rehash")); - t = silc_hash_table_alloc(0, hash_entry, NULL, + t = silc_hash_table_alloc(NULL, 0, hash_entry, NULL, hash_compare, NULL, hash_destructor, NULL, auto_rehash); @@ -169,7 +169,7 @@ SilcBool find_entries() for (i = 0; i < count; i++) { memset(&f, 0, sizeof(f)); - snprintf(f.name, sizeof(f.name), "%d", i); + silc_snprintf(f.name, sizeof(f.name), "%d", i); f.val = i; /* Find */ @@ -208,19 +208,38 @@ SilcBool dump_table() int main(int argc, char **argv) { SilcBool success = FALSE; + SilcGetOptStruct op = SILC_GETOPT_INIT; + int opt; int i; - if (argc > 1 && !strcmp(argv[1], "-d")) { - silc_log_debug(TRUE); - silc_log_debug_hexdump(TRUE); - silc_log_quick(TRUE); - silc_log_set_debug_string("*table*"); - } - - if (argc > 1 && !strcmp(argv[1], "-D")) { - silc_log_debug(TRUE); - dump = TRUE; - silc_log_set_debug_string("*table*"); + while ((opt = silc_getopt(argc, argv, "de::D", &op)) != -1) { + switch (opt) { + case 'd': + silc_log_debug(TRUE); + silc_log_debug_hexdump(TRUE); + silc_log_quick(TRUE); + silc_log_set_debug_string("*table*,*errno*"); + break; + + case 'D': + silc_log_debug(TRUE); + dump = TRUE; + silc_log_set_debug_string("*table*,*errno*"); + break; + + case 'e': + silc_log_debug(TRUE); + fprintf(stderr, "%s\n", op.opt_arg); + if (op.opt_arg) { + dump = TRUE; + silc_log_set_debug_string(op.opt_arg); + } + break; + + default: + exit(1); + break; + } } if (!alloc_table())