[digraphanalysis-cvs] digraphanalysis/src analysis.c, graph.c, graph.h, list.h, main.c, node.c, outp
Status: Planning
Brought to you by:
jbreker
|
From: Jeff B. <jb...@us...> - 2005-05-27 14:24:55
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv338/src Modified Files: analysis.c graph.c graph.h list.h main.c node.c output.c Log Message: compiles finishes condensation of list code Index: graph.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/graph.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** graph.h 17 May 2005 14:30:26 -0000 1.2 --- graph.h 27 May 2005 14:24:45 -0000 1.3 *************** *** 30,33 **** --- 30,34 ---- }; + int graph_compare(void *, void *); struct graph *graph_new(struct list *, struct list *); Index: output.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/output.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** output.c 24 May 2005 22:40:45 -0000 1.5 --- output.c 27 May 2005 14:24:45 -0000 1.6 *************** *** 16,19 **** --- 16,20 ---- */ + #include <sys/queue.h> #include <sys/types.h> #include <sys/stat.h> *************** *** 22,25 **** --- 23,29 ---- #include <sysexits.h> + #include "alias.h" + #include "list.h" + #include "node.h" #include "output.h" *************** *** 56,60 **** FILE *filep; struct graph *graph; ! struct graphlink *graph_link; int i; int j; --- 60,64 ---- FILE *filep; struct graph *graph; ! struct listlink *graph_link; int i; int j; *************** *** 62,66 **** float last_msd; struct node *node; ! struct nodelink *node_link; i = k = 1; --- 66,70 ---- float last_msd; struct node *node; ! struct listlink *node_link; i = k = 1; *************** *** 73,91 **** graph_link = LIST_FIRST(graph_list); /* If the size of this web of trust is 1 then the remaining are of size 1, so group them all together */ ! if(nodelist_size(((struct graph *) graph_link->graph)->node_list) == 1) break; fprintf(filep, "<div class=\"wottable\"><div class=\"wottable_title\">Web Of Trust %d</div>\n", i); fprintf(filep, "<table><tr><td>Rank</td><td>KeyID</td><td>Name</td><td>MSD</td></tr>\n"); ! graph = (struct graph *) graph_link->graph; while(!LIST_EMPTY(graph->node_list)) { node_link = LIST_FIRST(graph->node_list); ! node = (struct node *) node_link->node; if(node->msd != last_msd) j = k; ++k; last_msd = node->msd; ! alias = aliaslist_find(graph->alias_list, node->uid); fprintf(filep, "<tr><td>%d</td><td><a href=\"%s/%s\">%s</a></td><td>%s</td><td>%f</td></tr>\n", j, node->uiddir, node->uid, node->uid, ((alias != NULL)?(alias->name):""), node->msd); LIST_REMOVE(node_link, list); --- 77,95 ---- graph_link = LIST_FIRST(graph_list); /* If the size of this web of trust is 1 then the remaining are of size 1, so group them all together */ ! if(list_size(((struct graph *) graph_link->object)->node_list) == 1) break; fprintf(filep, "<div class=\"wottable\"><div class=\"wottable_title\">Web Of Trust %d</div>\n", i); fprintf(filep, "<table><tr><td>Rank</td><td>KeyID</td><td>Name</td><td>MSD</td></tr>\n"); ! graph = (struct graph *) graph_link->object; while(!LIST_EMPTY(graph->node_list)) { node_link = LIST_FIRST(graph->node_list); ! node = (struct node *) node_link->object; if(node->msd != last_msd) j = k; ++k; last_msd = node->msd; ! alias = list_find(graph->alias_list, alias_new(node->uid, "", NULL)); fprintf(filep, "<tr><td>%d</td><td><a href=\"%s/%s\">%s</a></td><td>%s</td><td>%f</td></tr>\n", j, node->uiddir, node->uid, node->uid, ((alias != NULL)?(alias->name):""), node->msd); LIST_REMOVE(node_link, list); *************** *** 106,114 **** while(graph_link != NULL) { ! graph = graph_link->graph; LIST_FOREACH(node_link, graph->node_list, list) { ! node = (struct node *) node_link->node; ! alias = aliaslist_find(graph->alias_list, node->uid); fprintf(filep, "<tr><td><a href=\"%s/%s\">%s</a></td><td>%s</td></tr>\n", node->uiddir, node->uid, node->uid, ((alias != NULL)?(alias->name):"")); } --- 110,118 ---- while(graph_link != NULL) { ! graph = graph_link->object; LIST_FOREACH(node_link, graph->node_list, list) { ! node = (struct node *) node_link->object; ! alias = list_find(graph->alias_list, alias_new(node->uid, "", NULL)); fprintf(filep, "<tr><td><a href=\"%s/%s\">%s</a></td><td>%s</td></tr>\n", node->uiddir, node->uid, node->uid, ((alias != NULL)?(alias->name):"")); } *************** *** 148,154 **** { struct alias *alias; ! struct nodelink *node_link; ! struct nodelist *nodes_we_link_to; ! struct nodelist *tmp_nodelist; FILE *filep; unsigned int tmp_size; --- 152,158 ---- { struct alias *alias; ! struct listlink *node_link; ! struct list *nodes_we_link_to; ! struct list *tmp_nodelist; FILE *filep; unsigned int tmp_size; *************** *** 162,209 **** fprintf(filep, "Keyid: %s\n", node->uid); ! alias = aliaslist_find(graph->alias_list, node->uid); fprintf(filep, "Name: %s \n\n", alias->name); fprintf(filep, "Signatures to this key:\n"); ! nodelist_print(filep, node->links); ! tmp_size = nodelist_size(node->links); fprintf(filep, " Total: %u signature%s to this key from this set.\n\n", tmp_size, ((tmp_size == 1)?"":"s")); ! nodes_we_link_to = nodelist_new(); LIST_FOREACH(node_link, graph->node_list, list) ! if(nodelist_find(((struct node *) node_link->node)->links, node) != NULL) ! nodelist_add(nodes_we_link_to, node_link->node); fprintf(filep, "Signatures from this key:\n"); ! nodelist_print(filep, nodes_we_link_to); ! tmp_size = nodelist_size(nodes_we_link_to); fprintf(filep, " Total: %u signature%s from this key to this set.\n\n", tmp_size, ((tmp_size == 1)?"":"s")); fprintf(filep, "MSD: %.4f\n\n", node->msd); ! tmp_nodelist = nodelist_subtract(graph->node_list, nodelist_union(node->links, nodes_we_link_to)); fprintf(filep, "This key has not signed, nor been signed by:\n"); ! nodelist_print(filep, tmp_nodelist); fprintf(filep, " Total: %u key%s in this set.\n\n", tmp_size, ((tmp_size == 1)?"":"s")); ! tmp_nodelist = nodelist_subtract(node->links, nodes_we_link_to); fprintf(filep, "This key has not signed, but has been signed by:\n"); ! nodelist_print(filep, tmp_nodelist); ! tmp_size = nodelist_size(tmp_nodelist); fprintf(filep, " Total: %u key%s in this set.\n\n", tmp_size, ((tmp_size == 1)?"":"s")); ! nodelist_free(tmp_nodelist); ! tmp_nodelist = nodelist_subtract(nodes_we_link_to, node->links); fprintf(filep, "This key has signed, but has not been signed by:\n"); ! nodelist_print(filep, tmp_nodelist); ! tmp_size = nodelist_size(tmp_nodelist); fprintf(filep, " Total: %u key%s in this set.\n\n", tmp_size, ((tmp_size == 1)?"":"s")); ! nodelist_free(tmp_nodelist); ! tmp_nodelist = nodelist_intersection(node->links, nodes_we_link_to); fprintf(filep, "This key has signed and has been signed by:\n"); ! nodelist_print(filep, tmp_nodelist); ! tmp_size = nodelist_size(tmp_nodelist); fprintf(filep, " Total: %u key%s in this set.\n\n", tmp_size, ((tmp_size == 1)?"":"s")); ! nodelist_free(tmp_nodelist); fclose(filep); chdir(".."); --- 166,213 ---- fprintf(filep, "Keyid: %s\n", node->uid); ! alias = list_find(graph->alias_list, alias_new(node->uid, "", NULL)); fprintf(filep, "Name: %s \n\n", alias->name); fprintf(filep, "Signatures to this key:\n"); ! list_print(filep, node->links); ! tmp_size = list_size(node->links); fprintf(filep, " Total: %u signature%s to this key from this set.\n\n", tmp_size, ((tmp_size == 1)?"":"s")); ! nodes_we_link_to = list_new(node_compare); LIST_FOREACH(node_link, graph->node_list, list) ! if(list_find(((struct node *) node_link->object)->links, node) != NULL) ! list_add(nodes_we_link_to, node_link->object); fprintf(filep, "Signatures from this key:\n"); ! list_print(filep, nodes_we_link_to); ! tmp_size = list_size(nodes_we_link_to); fprintf(filep, " Total: %u signature%s from this key to this set.\n\n", tmp_size, ((tmp_size == 1)?"":"s")); fprintf(filep, "MSD: %.4f\n\n", node->msd); ! tmp_nodelist = list_subtract(graph->node_list, list_union(node->links, nodes_we_link_to)); fprintf(filep, "This key has not signed, nor been signed by:\n"); ! list_print(filep, tmp_nodelist); fprintf(filep, " Total: %u key%s in this set.\n\n", tmp_size, ((tmp_size == 1)?"":"s")); ! tmp_nodelist = list_subtract(node->links, nodes_we_link_to); fprintf(filep, "This key has not signed, but has been signed by:\n"); ! list_print(filep, tmp_nodelist); ! tmp_size = list_size(tmp_nodelist); fprintf(filep, " Total: %u key%s in this set.\n\n", tmp_size, ((tmp_size == 1)?"":"s")); ! list_free(tmp_nodelist); ! tmp_nodelist = list_subtract(nodes_we_link_to, node->links); fprintf(filep, "This key has signed, but has not been signed by:\n"); ! list_print(filep, tmp_nodelist); ! tmp_size = list_size(tmp_nodelist); fprintf(filep, " Total: %u key%s in this set.\n\n", tmp_size, ((tmp_size == 1)?"":"s")); ! list_free(tmp_nodelist); ! tmp_nodelist = list_intersection(node->links, nodes_we_link_to); fprintf(filep, "This key has signed and has been signed by:\n"); ! list_print(filep, tmp_nodelist); ! tmp_size = list_size(tmp_nodelist); fprintf(filep, " Total: %u key%s in this set.\n\n", tmp_size, ((tmp_size == 1)?"":"s")); ! list_free(tmp_nodelist); fclose(filep); chdir(".."); *************** *** 216,220 **** { struct node *node; ! struct nodelink *node_link; char *uid; char *name; --- 220,224 ---- { struct node *node; ! struct listlink *node_link; char *uid; char *name; *************** *** 222,228 **** LIST_FOREACH(node_link, graph->node_list, list) { ! node = node_link->node; uid = node->uid; ! name = aliaslist_find(graph->alias_list, uid)->name; fprintf(filep, " %s %s\n", uid, name); } --- 226,232 ---- LIST_FOREACH(node_link, graph->node_list, list) { ! node = node_link->object; uid = node->uid; ! name = ((struct alias *) list_find(graph->alias_list, alias_new(uid, "", NULL)))->name; fprintf(filep, " %s %s\n", uid, name); } Index: node.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/node.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** node.c 24 May 2005 22:40:45 -0000 1.13 --- node.c 27 May 2005 14:24:45 -0000 1.14 *************** *** 27,31 **** { free(node->uid); ! nodelist_free(node->links); free(node); } --- 27,31 ---- { free(node->uid); ! list_free(node->links); free(node); } Index: main.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.c,v retrieving revision 1.13 retrieving revision 1.14 diff -C2 -d -r1.13 -r1.14 *** main.c 17 May 2005 00:12:45 -0000 1.13 --- main.c 27 May 2005 14:24:45 -0000 1.14 *************** *** 30,33 **** --- 30,34 ---- #include "alias.h" #include "graph.h" + #include "list.h" #include "main.h" #include "node.h" *************** *** 40,44 **** char *output_dir; ! graph = graph_new(aliaslist_new(), nodelist_new()); output_dir = NULL; --- 41,45 ---- char *output_dir; ! graph = graph_new(list_new(alias_compare), list_new(node_compare)); output_dir = NULL; Index: graph.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/graph.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** graph.c 24 May 2005 22:40:45 -0000 1.5 --- graph.c 27 May 2005 14:24:45 -0000 1.6 *************** *** 23,28 **** int ! graph_compare(struct graph *graph1, struct graph *graph2) { return list_compare(graph1->node_list, graph2->node_list); } --- 23,34 ---- int ! graph_compare(void *arg1, void *arg2) { + struct graph *graph1; + struct graph *graph2; + + graph1 = arg1; + graph2 = arg2; + return list_compare(graph1->node_list, graph2->node_list); } Index: list.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/list.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** list.h 24 May 2005 22:40:45 -0000 1.7 --- list.h 27 May 2005 14:24:45 -0000 1.8 *************** *** 21,24 **** --- 21,26 ---- #include <sys/queue.h> + #include <stdio.h> + struct listlink { Index: analysis.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/analysis.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** analysis.c 24 May 2005 22:40:45 -0000 1.2 --- analysis.c 27 May 2005 14:24:45 -0000 1.3 *************** *** 71,75 **** /* Create the list, to add the msd sorted graphs to. */ ! graph_list = graphlist_new(); /* Iterate through our copy of the original graph's node list. --- 71,75 ---- /* Create the list, to add the msd sorted graphs to. */ ! graph_list = list_new(graph_compare); /* Iterate through our copy of the original graph's node list. *************** *** 85,89 **** /* Add the first node from the node list to our msd sorted node list. And remove it from the non msd sorted node list. */ ! list_add_msd(node_list_msd1, LIST_FIRST(node_list)->object); list_remove(node_list, LIST_FIRST(node_list)->object); --- 85,89 ---- /* Add the first node from the node list to our msd sorted node list. And remove it from the non msd sorted node list. */ ! list_add(node_list_msd1, LIST_FIRST(node_list)->object); list_remove(node_list, LIST_FIRST(node_list)->object); *************** *** 103,107 **** if(node_distance(node_link2->object, node_link1->object)) { ! list_add_msd(node_list_msd1, node_link2->object); list_remove(node_list, node_link2->object); } --- 103,107 ---- if(node_distance(node_link2->object, node_link1->object)) { ! list_add(node_list_msd1, node_link2->object); list_remove(node_list, node_link2->object); } *************** *** 110,114 **** /* Add strongly connected nodelist to the graphlist. */ ! graphlist_add(graph_list, graph_new(alias_list, node_list_msd1)); /* Free the 2nd nodelist so as to not leak memory. --- 110,114 ---- /* Add strongly connected nodelist to the graphlist. */ ! list_add(graph_list, graph_new(alias_list, node_list_msd1)); /* Free the 2nd nodelist so as to not leak memory. |