Thread: [digraphanalysis-cvs] digraphanalysis/src list.c,JBREKER list.h,JBREKER main.c,JBREKER main.h,JBREKE
Status: Planning
Brought to you by:
jbreker
|
From: Jeff B. <jb...@us...> - 2005-04-04 03:27:46
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17131 Modified Files: Tag: JBREKER list.c list.h main.c main.h node.c Log Message: more LIST_* macro Index: list.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/list.h,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** list.h 28 Mar 2005 02:09:51 -0000 1.1.2.2 --- list.h 4 Apr 2005 03:27:36 -0000 1.1.2.3 *************** *** 38,41 **** --- 38,42 ---- void list_remove(struct list_t *, void *, int (*)(void *, void *)); struct list_t *list_resort(struct list_t *, int (*)(void *, void *)); + unsigned int list_size(struct list_t *); struct list_t *list_union(struct list_t *, struct list_t *, int (*)(void *, void *)); Index: node.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/Attic/node.c,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** node.c 20 Mar 2005 17:30:48 -0000 1.1.2.2 --- node.c 4 Apr 2005 03:27:36 -0000 1.1.2.3 *************** *** 46,72 **** { unsigned int distance; ! unsigned int last_known_size; ! list_t *traversed_keys, *tmp_keys; ! node_t *tmp_node; ! traversed_keys = list_new(&pgpkey_compare); last_known_size = 0; distance = 1; ! list_merge_list(traversed_keys, keyto->signatures); ! while(traversed_keys->size != last_known_size) { ! if(list_find_object(traversed_keys, keyfrom) != NULL) return distance; ! last_known_size = traversed_keys->size; ++distance; tmp_keys = traversed_keys; ! tmp_node = tmp_keys->head; ! traversed_keys = list_new(&pgpkey_compare); while(tmp_node != NULL) { ! list_add_object(traversed_keys, tmp_node->object); ! list_merge_list(traversed_keys, ((pgpkey_t *) tmp_node->object)->signatures); ! tmp_node = tmp_node->next; } } --- 46,72 ---- { unsigned int distance; ! unsigned int last_known_size, tmpsize; ! struct list_t *traversed_keys, *tmp_keys; ! struct node_t *tmp_node; ! traversed_keys = list_new(); last_known_size = 0; distance = 1; ! list_merge_list(traversed_keys, keyto->signatures, &pgpkey_compare); ! while((tmpsize = list_size(traversed_keys)) != last_known_size) { ! if(list_find_object(traversed_keys, keyfrom, &pgpkey_compare) != NULL) return distance; ! last_known_size = tmpsize; ++distance; tmp_keys = traversed_keys; ! tmp_node = LIST_FIRST(tmp_keys); ! traversed_keys = list_new(); while(tmp_node != NULL) { ! list_add_object(traversed_keys, tmp_node->object, &pgpkey_compare); ! list_merge_list(traversed_keys, ((pgpkey_t *) tmp_node->object)->signatures, &pgpkey_compare); ! tmp_node = LIST_NEXT(tmp_node, entries); } } *************** *** 75,86 **** } ! void pgpkey_msd(pgpkey_t *key, list_t *keys) { unsigned int distance, i, num_keys; ! node_t *iter; distance = 0; num_keys = 0; ! iter = keys->head; while(iter != NULL) --- 75,86 ---- } ! void pgpkey_msd(pgpkey_t *key, struct list_t *keys) { unsigned int distance, i, num_keys; ! struct node_t *iter; distance = 0; num_keys = 0; ! iter = LIST_FIRST(keys); while(iter != NULL) *************** *** 92,96 **** num_keys++; } ! iter = iter->next; } --- 92,96 ---- num_keys++; } ! iter = LIST_NEXT(iter, entries); } Index: main.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.c,v retrieving revision 1.2.2.5 retrieving revision 1.2.2.6 diff -C2 -d -r1.2.2.5 -r1.2.2.6 *** main.c 28 Mar 2005 02:09:51 -0000 1.2.2.5 --- main.c 4 Apr 2005 03:27:36 -0000 1.2.2.6 *************** *** 328,341 **** } ! list_t *parse_keyring() { - size_t size; keydata_t *key; pgpkey_t *public_key, *tmp_key, *tmp2_key; ! list_t *keys; int key_was_added; public_key = NULL; ! keys = list_new(&pgpkey_compare); key = keydata_new(); --- 328,340 ---- } ! struct list_t *parse_keyring() { keydata_t *key; pgpkey_t *public_key, *tmp_key, *tmp2_key; ! struct list_t *keys; int key_was_added; public_key = NULL; ! keys = list_new(); key = keydata_new(); *************** *** 349,356 **** { public_key = pgpkey_new(key->keyid, key->name); ! key_was_added = list_add_object(keys, public_key); if(key_was_added == 0) { ! tmp_key = list_find_object(keys, public_key); list_free(public_key->signatures); free(public_key->name); --- 348,355 ---- { public_key = pgpkey_new(key->keyid, key->name); ! key_was_added = list_add_object(keys, public_key, &pgpkey_compare); if(key_was_added == 0) { ! tmp_key = list_find_object(keys, public_key, &pgpkey_compare); list_free(public_key->signatures); free(public_key->name); *************** *** 367,374 **** { tmp_key = pgpkey_new(key->keyid, key->name); ! key_was_added = list_add_object(keys, tmp_key); if(key_was_added == 0) { ! tmp2_key = list_find_object(keys, tmp_key); list_free(tmp_key->signatures); free(tmp_key->name); --- 366,373 ---- { tmp_key = pgpkey_new(key->keyid, key->name); ! key_was_added = list_add_object(keys, tmp_key, &pgpkey_compare); if(key_was_added == 0) { ! tmp2_key = list_find_object(keys, tmp_key, &pgpkey_compare); list_free(tmp_key->signatures); free(tmp_key->name); *************** *** 377,381 **** tmp_key = tmp2_key; } ! list_add_object(public_key->signatures, tmp_key); } } --- 376,380 ---- tmp_key = tmp2_key; } ! list_add_object(public_key->signatures, tmp_key, &pgpkey_compare); } } *************** *** 388,402 **** } ! void print_list(FILE *filep, list_t *list) { ! node_t *node; ! ! node = list->head; ! while(node != NULL) ! { fprintf(filep, " %s %s\n", ((pgpkey_t *) node->object)->keyid + 8, ((pgpkey_t *) node->object)->name); - node = node->next; - } return; --- 387,396 ---- } ! void print_list(FILE *filep, struct list_t *list) { ! struct node_t *node; ! LIST_FOREACH(node, list, entries) fprintf(filep, " %s %s\n", ((pgpkey_t *) node->object)->keyid + 8, ((pgpkey_t *) node->object)->name); return; *************** *** 412,426 **** } ! int wot_compare(void *obj1, void *obj2) { ! list_t *wot1 = obj1; ! list_t *wot2 = obj2; if(wot1 == wot2) return 0; ! if(wot1->size == wot2->size) ! return wot1->compare(wot1->head->object, wot2->head->object); ! return wot2->size - wot1->size; } --- 406,421 ---- } ! int wot_compare(void *obj1, void *obj2, int (*compare)(void *, void *)) { ! struct list_t *wot1 = obj1; ! struct list_t *wot2 = obj2; ! unsigned int wot1size, wot2size; if(wot1 == wot2) return 0; ! if((wot1size = list_size(wot1)) == (wot2size = list_size(wot2))) ! return compare(LIST_FIRST(wot1)->object, LIST_FIRST(wot2)->object); ! return wot2size - wot1size; } Index: list.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/list.c,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** list.c 28 Mar 2005 02:09:51 -0000 1.1.2.2 --- list.c 4 Apr 2005 03:27:36 -0000 1.1.2.3 *************** *** 216,219 **** --- 216,229 ---- } + unsigned int list_size(struct list_t *list) + { + unsigned int i = 0; + struct node_t *iter; + + LIST_FOREACH(iter, list, entries) + ++i; + + return i; + } /* Return * NULL on error Index: main.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.h,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** main.h 28 Mar 2005 02:09:51 -0000 1.1.2.3 --- main.h 4 Apr 2005 03:27:36 -0000 1.1.2.4 *************** *** 31,35 **** void print_list(FILE *, struct list_t *); void usage(void); ! int wot_compare(void *, void *); #endif --- 31,35 ---- void print_list(FILE *, struct list_t *); void usage(void); ! int wot_compare(void *, void *, int (*)(void *, void *)); #endif |