Thread: [digraphanalysis-cvs] digraphanalysis/src graph.c, graph.h, output.c, output.h,
Status: Planning
Brought to you by:
jbreker
|
From: Jeff B. <jb...@us...> - 2005-09-14 01:39:48
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5536 Modified Files: graph.c graph.h output.c output.h Log Message: clean up Index: output.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/output.h,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** output.h 24 May 2005 22:40:45 -0000 1.2 --- output.h 14 Sep 2005 01:39:40 -0000 1.3 *************** *** 27,30 **** --- 27,31 ---- int output_new_directory(char *); void output_file(struct node *, struct graph *); + void output_file_node_list(FILE *, struct graph *, char *); void output_print_list(FILE *, struct graph *); Index: output.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/output.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** output.c 13 Sep 2005 20:03:50 -0000 1.11 --- output.c 14 Sep 2005 01:39:40 -0000 1.12 *************** *** 31,34 **** --- 31,108 ---- #include "output.h" + void + output_file(struct node *node, struct graph *graph) + { + struct alias *alias; + struct listlink *node_link; + struct list *nodes_we_link_to; + struct graph *tmp_graph; + FILE *filep; + + output_new_directory(node->uiddir); + + chdir(node->uiddir); + + filep = fopen(node->uid, "a"); + + 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); + + tmp_graph = graph_new(graph->alias_list, node->links); + output_file_node_list(filep, tmp_graph, "Signatures to this key:"); + graph_free(tmp_graph); + + nodes_we_link_to = list_new(node_compare, node_print); + 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); + + tmp_graph = graph_new(graph->alias_list, nodes_we_link_to); + output_file_node_list(filep, tmp_graph, "Signatures from this key:"); + graph_free(tmp_graph); + + fprintf(filep, "MSD: %.4f\n\n", node->msd); + + tmp_graph = graph_new(graph->alias_list, list_subtract(graph->node_list, list_union(node->links, nodes_we_link_to))); + output_file_node_list(filep, tmp_graph, "This key has not signed, nor been signed by:"); + list_free(tmp_graph->node_list); + graph_free(tmp_graph); + + tmp_graph = graph_new(graph->alias_list, list_subtract(node->links, nodes_we_link_to)); + output_file_node_list(filep, tmp_graph, "This key has not signed, but has been signed by:"); + list_free(tmp_graph->node_list); + graph_free(tmp_graph); + + tmp_graph = graph_new(graph->alias_list, list_subtract(nodes_we_link_to, node->links)); + output_file_node_list(filep, tmp_graph, "This key has signed, but has not been signed by:"); + list_free(tmp_graph->node_list); + graph_free(tmp_graph); + + tmp_graph = graph_new(graph->alias_list, list_intersection(node->links, nodes_we_link_to)); + output_file_node_list(filep, tmp_graph, "This key has signed and has been signed by:"); + list_free(tmp_graph->node_list); + graph_free(tmp_graph); + + fclose(filep); + chdir(".."); + + return; + } + + void + output_file_node_list(FILE *filep, struct graph *graph, char *desc) + { + unsigned int num_nodes; + + fprintf(filep, "%s\n", desc); + graph_print(filep, graph); + num_nodes = list_size(graph->node_list); + fprintf(filep, " Total: %u key%s in this set.\n\n", num_nodes, ((num_nodes == 1)?"":"s")); + + return; + } + /* Create and enter the main output directory. */ *************** *** 53,56 **** --- 127,170 ---- } + /* Create a new directory using the same directory stats as the parent directory. + */ + int + output_new_directory(char *dirname) + { + int rtn; + struct stat *sb; + + rtn = 0; + sb = NULL; + /* Allocate memory for sb */ + if(((sb = (struct stat *) malloc(sizeof(struct stat))) == NULL) || + /* Stat the current working directory for mode value */ + (stat(".", sb) == -1) || + /* Make the new directory with the cwd's mode value */ + (mkdir(dirname, sb->st_mode) == -1)) + rtn = -1; + free(sb); + return rtn; + } + + void + output_print_list(FILE *filep, struct graph *graph) + { + struct node *node; + struct listlink *node_link; + char *uid; + char *name; + + 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); + } + return; + + } + /* Generate the main report. */ *************** *** 129,239 **** return; } - - /* Create a new directory using the same directory stats as the parent directory. - */ - int - output_new_directory(char *dirname) - { - int rtn; - struct stat *sb; - - rtn = 0; - sb = NULL; - /* Allocate memory for sb */ - if(((sb = (struct stat *) malloc(sizeof(struct stat))) == NULL) || - /* Stat the current working directory for mode value */ - (stat(".", sb) == -1) || - /* Make the new directory with the cwd's mode value */ - (mkdir(dirname, sb->st_mode) == -1)) - rtn = -1; - free(sb); - return rtn; - } - - void - output_file(struct node *node, struct graph *graph) - { - struct alias *alias; - struct listlink *node_link; - struct list *nodes_we_link_to; - struct list *tmp_nodelist; - FILE *filep; - unsigned int tmp_size; - - output_new_directory(node->uiddir); - - chdir(node->uiddir); - - filep = fopen(node->uid, "a"); - - 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"); - graph_print(filep, graph_new(graph->alias_list, 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, node_print); - 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"); - graph_print(filep, graph_new(graph->alias_list, 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"); - graph_print(filep, graph_new(graph->alias_list, 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")); - - tmp_nodelist = list_subtract(node->links, nodes_we_link_to); - fprintf(filep, "This key has not signed, but has been signed by:\n"); - graph_print(filep, graph_new(graph->alias_list, 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"); - graph_print(filep, graph_new(graph->alias_list, 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"); - graph_print(filep, graph_new(graph->alias_list, 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(".."); - - return; - } - - void - output_print_list(FILE *filep, struct graph *graph) - { - struct node *node; - struct listlink *node_link; - char *uid; - char *name; - - 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); - } - return; - - } --- 243,244 ---- Index: graph.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/graph.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** graph.c 13 Sep 2005 20:03:50 -0000 1.9 --- graph.c 14 Sep 2005 01:39:40 -0000 1.10 *************** *** 50,58 **** void ! graph_print(FILE *filep, struct graph *graph) { struct listlink *iter; struct alias *alias; LIST_FOREACH(iter, graph->node_list, list) { --- 50,61 ---- void ! graph_print(FILE *filep, void *arg2) { + struct graph *graph; struct listlink *iter; struct alias *alias; + graph = arg2; + LIST_FOREACH(iter, graph->node_list, list) { Index: graph.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/graph.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** graph.h 13 Sep 2005 20:03:50 -0000 1.5 --- graph.h 14 Sep 2005 01:39:40 -0000 1.6 *************** *** 30,36 **** }; ! int graph_compare(void *, void *); ! struct graph *graph_new(struct list *, struct list *); ! void graph_print(FILE *, struct graph *); #endif /* _GRAPH_H_ */ --- 30,37 ---- }; ! int graph_compare(void *, void *); ! void graph_free(struct graph *); ! struct graph *graph_new(struct list *, struct list *); ! void graph_print(FILE *, void *); #endif /* _GRAPH_H_ */ |