digraphanalysis-cvs Mailing List for The Digraph Analysis Project (Page 3)
Status: Planning
Brought to you by:
jbreker
You can subscribe to this list here.
| 2005 |
Jan
|
Feb
|
Mar
(10) |
Apr
(31) |
May
(27) |
Jun
(16) |
Jul
(10) |
Aug
|
Sep
(27) |
Oct
|
Nov
|
Dec
|
|---|
|
From: Jeff B. <jb...@us...> - 2005-06-01 20:42:54
|
Update of /cvsroot/digraphanalysis/openbsd-port/misc/digraphanalysis In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8942/digraphanalysis Added Files: Makefile distinfo Log Message: import port --- NEW FILE: Makefile --- # $Id: Makefile,v 1.1 2005/06/01 20:42:40 jbreker Exp $ COMMENT= "A set of unix tools for analysis of information that can be represented as a digraph." DISTNAME= digraphanalysis-2005.05.28-bughunt CATEGORIES= misc HOMEPAGE= http://www.sourceforge.net/projects/digraphanalysis MAINTAINER= Jeff Breker <jb...@sy...> # BSD PERMIT_PACKAGE_CDROM= Yes PERMIT_PACKAGE_FTP= Yes PERMIT_DISTFILES_CDROM= Yes PERMIT_DISTFILES_FTP= Yes MASTER_SITES= ${MASTER_SITE_SOURCEFORGE:=digraphanalysis/} MAKE_FILE= BSDmakefile WRKDIST= w-${PKGNAME}${FLAVOR_EXT}/${DISTNAME}/src/ MANDIR= /usr/local/man/ .include <bsd.port.mk> --- NEW FILE: distinfo --- MD5 (digraphanalysis-2005.05.28-bughunt.tar.gz) = b6349a199326c4b9d27a94808f1c5755 RMD160 (digraphanalysis-2005.05.28-bughunt.tar.gz) = 214030e1161ca889cb787fc0bdddce0dc97f40b1 SHA1 (digraphanalysis-2005.05.28-bughunt.tar.gz) = 5cc8751e2cd993c21df7f0351af97b2b41826623 SIZE (digraphanalysis-2005.05.28-bughunt.tar.gz) = 9341 |
|
From: Jeff B. <jb...@us...> - 2005-06-01 20:42:51
|
Update of /cvsroot/digraphanalysis/openbsd-port/misc/digraphanalysis/pkg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8942/digraphanalysis/pkg Added Files: DESCR PLIST Log Message: import port --- NEW FILE: PLIST --- --- NEW FILE: DESCR --- |
|
From: Jeff B. <jb...@us...> - 2005-06-01 20:41:52
|
Update of /cvsroot/digraphanalysis/openbsd-port/misc/digraphanalysis/pkg In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8404/pkg Log Message: Directory /cvsroot/digraphanalysis/openbsd-port/misc/digraphanalysis/pkg added to the repository |
|
From: Jeff B. <jb...@us...> - 2005-05-31 03:12:46
|
Update of /cvsroot/digraphanalysis/openbsd-port/misc/digraphanalysis In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30319/digraphanalysis Log Message: Directory /cvsroot/digraphanalysis/openbsd-port/misc/digraphanalysis added to the repository |
|
From: Jeff B. <jb...@us...> - 2005-05-31 03:12:18
|
Update of /cvsroot/digraphanalysis/openbsd-port/misc In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30025/misc Log Message: Directory /cvsroot/digraphanalysis/openbsd-port/misc added to the repository |
|
From: Jeff B. <jb...@us...> - 2005-05-31 02:19:47
|
Update of /cvsroot/digraphanalysis/openbsd-port In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5556/openbsd-port Log Message: Directory /cvsroot/digraphanalysis/openbsd-port added to the repository |
|
From: Jeff B. <jb...@us...> - 2005-05-28 20:58:10
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32298/src Modified Files: BSDmakefile alias.c alias.h analysis.c graph.c graph.h list.c list.h main.c node.c node.h output.c Log Message: "bug" fixes :), we now work... almost Index: node.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/node.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** node.c 27 May 2005 14:24:45 -0000 1.14 --- node.c 28 May 2005 20:58:00 -0000 1.15 *************** *** 47,51 **** node->msd = 0; ! node->links = list_new(node_compare); return node; --- 47,51 ---- node->msd = 0; ! node->links = list_new(node_compare, node_print); return node; *************** *** 53,59 **** void ! node_print(FILE *filep, struct node *node) { ! fprintf(filep, "%s\n", node->uid); return; --- 53,59 ---- void ! node_print(FILE *filep, void *node) { ! fprintf(filep, "%s\n", ((struct node *) node)->uid); return; *************** *** 98,102 **** struct listlink *tmp_node; ! traversed_nodes = list_new(node_compare); last_known_size = 0; distance = 1; --- 98,102 ---- struct listlink *tmp_node; ! traversed_nodes = list_new(node_compare, node_print); last_known_size = 0; distance = 1; *************** *** 111,115 **** tmp_nodes = traversed_nodes; tmp_node = LIST_FIRST(tmp_nodes); ! traversed_nodes = list_new(node_compare); while(tmp_node != NULL) { --- 111,115 ---- tmp_nodes = traversed_nodes; tmp_node = LIST_FIRST(tmp_nodes); ! traversed_nodes = list_new(node_compare, node_print); while(tmp_node != NULL) { Index: list.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/list.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** list.c 24 May 2005 22:40:45 -0000 1.5 --- list.c 28 May 2005 20:58:00 -0000 1.6 *************** *** 67,71 **** struct list *ret_list; ! if((ret_list = list_new(list->compare)) != NULL) if(list_merge(ret_list, list) == NULL) { --- 67,71 ---- struct list *ret_list; ! if((ret_list = list_new(list->compare, list->print)) != NULL) if(list_merge(ret_list, list) == NULL) { *************** *** 84,88 **** struct listlink *list_link; ! ret_list = list_new(list->compare); LIST_FOREACH(list_link, list, list) --- 84,88 ---- struct listlink *list_link; ! ret_list = list_new(list->compare, list->print); LIST_FOREACH(list_link, list, list) *************** *** 144,148 **** struct list * ! list_new(int (*compare) (void *, void *)) { struct list *list; --- 144,148 ---- struct list * ! list_new(int (*compare) (void *, void *), void (*print) (FILE *, void *)) { struct list *list; *************** *** 153,156 **** --- 153,157 ---- list->compare = compare; + list->print = print; } *************** *** 235,239 **** struct list *ret_list; ! ret_list = list_new(list1->compare); LIST_FOREACH(iter, list1, list) --- 236,240 ---- struct list *ret_list; ! ret_list = list_new(list1->compare, list1->print); LIST_FOREACH(iter, list1, list) Index: node.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/node.h,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** node.h 24 May 2005 22:40:45 -0000 1.10 --- node.h 28 May 2005 20:58:00 -0000 1.11 *************** *** 36,40 **** void node_free(struct node *); struct node *node_new(char *); ! void node_print(FILE *, struct node *); #endif /* _NODE_H_ */ --- 36,40 ---- void node_free(struct node *); struct node *node_new(char *); ! void node_print(FILE *, void *); #endif /* _NODE_H_ */ Index: BSDmakefile =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/BSDmakefile,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** BSDmakefile 17 May 2005 14:30:26 -0000 1.5 --- BSDmakefile 28 May 2005 20:58:00 -0000 1.6 *************** *** 15,18 **** --- 15,19 ---- # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + DEBUG= -g PROG= digraphanalysis SRCS= alias.c \ Index: list.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/list.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** list.h 27 May 2005 14:24:45 -0000 1.8 --- list.h 28 May 2005 20:58:00 -0000 1.9 *************** *** 51,55 **** struct list *list_merge(struct list *, struct list *); ! struct list *list_new(int (*) (void *, void *)); struct listlink *list_new_node(void *); void list_print(FILE *, --- 51,56 ---- struct list *list_merge(struct list *, struct list *); ! struct list *list_new(int (*) (void *, void *), ! void (*) (FILE *, void *)); struct listlink *list_new_node(void *); void list_print(FILE *, Index: alias.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/alias.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** alias.c 18 May 2005 01:46:55 -0000 1.9 --- alias.c 28 May 2005 20:58:00 -0000 1.10 *************** *** 66,67 **** --- 66,74 ---- } + void + alias_print(FILE *filep, void *alias) + { + fprintf(filep, " %s\n", ((struct alias *) alias)->name); + + return; + } Index: graph.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/graph.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** graph.h 27 May 2005 14:24:45 -0000 1.3 --- graph.h 28 May 2005 20:58:00 -0000 1.4 *************** *** 32,38 **** int graph_compare(void *, void *); struct graph *graph_new(struct list *, struct list *); ! ! struct graph *graphlist_add(struct list *, struct graph *); ! struct list *graphlist_new(); #endif /* _GRAPH_H_ */ --- 32,36 ---- int graph_compare(void *, void *); struct graph *graph_new(struct list *, struct list *); ! void graph_print(FILE *, void *); #endif /* _GRAPH_H_ */ Index: output.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/output.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** output.c 27 May 2005 14:24:45 -0000 1.6 --- output.c 28 May 2005 20:58:00 -0000 1.7 *************** *** 174,178 **** 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) --- 174,178 ---- 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) Index: alias.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/alias.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** alias.h 18 May 2005 01:46:55 -0000 1.7 --- alias.h 28 May 2005 20:58:00 -0000 1.8 *************** *** 33,36 **** --- 33,37 ---- void alias_free(struct alias *); struct alias *alias_new(char *, char *, struct node *); + void alias_print(FILE *, void *); #endif /* _ALIAS_H_ */ Index: graph.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/graph.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** graph.c 27 May 2005 14:24:45 -0000 1.6 --- graph.c 28 May 2005 20:58:00 -0000 1.7 *************** *** 48,50 **** } ! --- 48,55 ---- } ! void ! graph_print(FILE *filep, void *graph) ! { ! /* Iterate through nodelist, find the alias for the node and print both */ ! return; ! } Index: main.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.c,v retrieving revision 1.14 retrieving revision 1.15 diff -C2 -d -r1.14 -r1.15 *** main.c 27 May 2005 14:24:45 -0000 1.14 --- main.c 28 May 2005 20:58:00 -0000 1.15 *************** *** 41,45 **** char *output_dir; ! graph = graph_new(list_new(alias_compare), list_new(node_compare)); output_dir = NULL; --- 41,45 ---- char *output_dir; ! graph = graph_new(list_new(alias_compare, alias_print), list_new(node_compare, alias_print)); output_dir = NULL; Index: analysis.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/analysis.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** analysis.c 27 May 2005 14:24:45 -0000 1.3 --- analysis.c 28 May 2005 20:58:00 -0000 1.4 *************** *** 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. --- 71,75 ---- /* Create the list, to add the msd sorted graphs to. */ ! graph_list = list_new(graph_compare, graph_print); /* Iterate through our copy of the original graph's node list. *************** *** 79,84 **** /* Create two new node lists. */ ! if(((node_list_msd1 = list_new(node_compare_msd)) == NULL) || ! ((node_list_msd2 = list_new(node_compare_msd)) == NULL)) return NULL; --- 79,84 ---- /* Create two new node lists. */ ! if(((node_list_msd1 = list_new(node_compare_msd, node_print)) == NULL) || ! ((node_list_msd2 = list_new(node_compare_msd, node_print)) == NULL)) return NULL; |
|
From: Jeff B. <jb...@us...> - 2005-05-28 20:58:10
|
Update of /cvsroot/digraphanalysis/digraphanalysis/utils/gpg2digraph In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32298/utils/gpg2digraph Modified Files: gpg2digraph.c Log Message: "bug" fixes :), we now work... almost Index: gpg2digraph.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/utils/gpg2digraph/gpg2digraph.c,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** gpg2digraph.c 27 May 2005 14:24:45 -0000 1.5 --- gpg2digraph.c 28 May 2005 20:58:00 -0000 1.6 *************** *** 44,53 **** name = get_name(); if (strcmp(name, "[User ID not found]") != 0) - { fprintf(stdout, "e:%u:%s:%u:%s\n", strlen(keyid_p), keyid_p, strlen(keyid_s), keyid_s); ! while (((c = fgetc(stdin)) != '\n') && (feof(stdin) == 0)) ! if(ferror(stdin)) ! exit(EX_IOERR); ! } free(keyid_s); free(name); --- 44,51 ---- name = get_name(); if (strcmp(name, "[User ID not found]") != 0) fprintf(stdout, "e:%u:%s:%u:%s\n", strlen(keyid_p), keyid_p, strlen(keyid_s), keyid_s); ! while (((c = fgetc(stdin)) != '\n') && (feof(stdin) == 0)) ! if(ferror(stdin)) ! exit(EX_IOERR); free(keyid_s); free(name); *************** *** 242,246 **** break; case (117105100): /* uid */ ! keyid_p = do_uid(keyid_p); break; default: --- 240,244 ---- break; case (117105100): /* uid */ ! do_uid(keyid_p); break; default: *************** *** 256,260 **** break; case (117105100): /* uid */ ! keyid_p = do_uid(keyid_p); while (feof(stdin) == 0) { --- 254,258 ---- break; case (117105100): /* uid */ ! do_uid(keyid_p); while (feof(stdin) == 0) { *************** *** 271,275 **** break; case (117105100): /* uid */ ! keyid_p = do_uid(keyid_p); break; default: --- 269,273 ---- break; case (117105100): /* uid */ ! do_uid(keyid_p); break; default: |
|
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. |
|
From: Jeff B. <jb...@us...> - 2005-05-27 14:24:54
|
Update of /cvsroot/digraphanalysis/digraphanalysis/utils/gpg2dot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv338/utils/gpg2dot Modified Files: gpg2dot.c Log Message: compiles finishes condensation of list code Index: gpg2dot.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/utils/gpg2dot/gpg2dot.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** gpg2dot.c 16 Mar 2005 21:47:17 -0000 1.1 --- gpg2dot.c 27 May 2005 14:24:45 -0000 1.2 *************** *** 25,57 **** char *do_pub(void); void do_sig(char *); unsigned int encode(char *); void func001(unsigned int); char *get_keyid(); char *get_name(); - unsigned int - encode(char *string) - { - return (tolower(toascii((*string))) * 1000000) + (tolower(toascii(*(string + 1))) * 1000) + (tolower(toascii(*(string + 2)))); - } - - /* Advances over 'n' colons. - */ - void - func001(unsigned int n) - { - char c; - unsigned int i; - - i = 0; - while (i < n) - if ((c = fgetc(stdin)) == ':') - ++i; - else - if(feof(stdin) || ferror(stdin)) - exit(EX_IOERR); - return; - } /* Handle a sig line. */ --- 25,36 ---- char *do_pub(void); void do_sig(char *); + char *do_uid(char *); unsigned int encode(char *); void func001(unsigned int); + char *get_fingerprint(); char *get_keyid(); char *get_name(); /* Handle a sig line. */ *************** *** 89,93 **** func001(5); name = get_name(); ! fprintf(stdout, "\"%s\" = \"%s\";\n", keyid, name); while (((c = fgetc(stdin)) != '\n') && (feof(stdin) == 0)) if (ferror(stdin)) --- 68,72 ---- func001(5); name = get_name(); ! fprintf(stdout, "\"%s\" [label=\"%s\"];\n", keyid, name); while (((c = fgetc(stdin)) != '\n') && (feof(stdin) == 0)) if (ferror(stdin)) *************** *** 98,101 **** --- 77,150 ---- } + /* Handle a uid line. + */ + char * + do_uid(char *keyid_p) + { + char c, *keyid, *name; + + func001(7); + keyid = get_fingerprint() + 24; + func001(2); + name = get_name(); + /* fprintf(stdout, "\"%s\" = \"%s\";\n", keyid_p, keyid); + */ while (((c = fgetc(stdin)) != '\n') && (feof(stdin) == 0)) + if (ferror(stdin)) + exit(EX_IOERR); + free(name); + + return keyid_p; + } + + unsigned int + encode(char *string) + { + return (tolower(toascii((*string))) * 1000000) + (tolower(toascii(*(string + 1))) * 1000) + (tolower(toascii(*(string + 2)))); + } + + /* Advances over 'n' colons. + */ + void + func001(unsigned int n) + { + char c; + unsigned int i; + + i = 0; + + while (i < n) + if ((c = fgetc(stdin)) == ':') + ++i; + else + if(feof(stdin) || ferror(stdin)) + exit(EX_IOERR); + return; + } + + /* Obtain the fingerprint from stdin. + */ + char * + get_fingerprint() + { + char c, *fingerprint; + unsigned int i; + + fingerprint = malloc(41); + + for (i = 0; i < 40; ++i) + { + c = fgetc(stdin); + if (feof(stdin) || ferror(stdin)) + exit(EX_IOERR); + c = toupper(c); + if (!isxdigit(c)) + exit(EX_DATAERR); + *(fingerprint + i) = (char) c; + } + *(fingerprint + 40) = '\0'; + + return fingerprint; + } + /* Obtain the keyid from stdin. */ *************** *** 169,173 **** type = malloc(4); ! fprintf(stdout, "digraph {\n"); while (feof(stdin) == 0) --- 218,222 ---- type = malloc(4); ! fprintf(stdout, "digraph gpg2dot {\n"); while (feof(stdin) == 0) *************** *** 193,196 **** --- 242,248 ---- do_sig(keyid_p); break; + case (117105100): /* uid */ + keyid_p = do_uid(keyid_p); + break; default: break_while = 1; *************** *** 204,207 **** --- 256,287 ---- } break; + case (117105100): /* uid */ + keyid_p = do_uid(keyid_p); + while (feof(stdin) == 0) + { + fgets(type, 4, stdin); + if (feof(stdin) || ferror(stdin)) + exit(EX_IOERR); + switch (encode(type)) + { + case (112117098): /* pub */ + keyid_p = do_pub(); + break; + case (115105103): /* sig */ + do_sig(keyid_p); + break; + case (117105100): /* uid */ + keyid_p = do_uid(keyid_p); + break; + default: + break_while = 1; + break; + } + if(break_while) + { + break_while = 0; + break; + } + } default: break; |
|
From: Jeff B. <jb...@us...> - 2005-05-27 14:24:54
|
Update of /cvsroot/digraphanalysis/digraphanalysis/utils/gpg2digraph In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv338/utils/gpg2digraph Modified Files: gpg2digraph.c Log Message: compiles finishes condensation of list code Index: gpg2digraph.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/utils/gpg2digraph/gpg2digraph.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** gpg2digraph.c 26 Apr 2005 03:49:28 -0000 1.4 --- gpg2digraph.c 27 May 2005 14:24:45 -0000 1.5 *************** *** 32,59 **** char *get_name(); - unsigned int - encode(char *string) - { - return (tolower(toascii((*string))) * 1000000) + (tolower(toascii(*(string + 1))) * 1000) + (tolower(toascii(*(string + 2)))); - } - - /* Advances over 'n' colons. - */ - void - func001(unsigned int n) - { - char c; - unsigned int i; - - i = 0; - - while (i < n) - if ((c = fgetc(stdin)) == ':') - ++i; - else - if(feof(stdin) || ferror(stdin)) - exit(EX_IOERR); - return; - } /* Handle a sig line. */ --- 32,35 ---- *************** *** 93,98 **** func001(5); name = get_name(); ! fprintf(stdout, "n:%u:%s\n", strlen(keyid), keyid); ! fprintf(stdout, "a:%u:%s:%u:%s:%u:%s\n", strlen(keyid), keyid, strlen(keyid), keyid, strlen(name), name); while (((c = fgetc(stdin)) != '\n') && (feof(stdin) == 0)) if (ferror(stdin)) --- 69,73 ---- func001(5); name = get_name(); ! fprintf(stdout, "n:%u:%s:%u:%s:%u:%s\n", strlen(keyid), keyid, strlen(keyid), keyid, strlen(name), name); while (((c = fgetc(stdin)) != '\n') && (feof(stdin) == 0)) if (ferror(stdin)) *************** *** 114,118 **** func001(2); name = get_name(); ! fprintf(stdout, "a:%u:%s:%u:%s:%u:%s\n", strlen(keyid_p), keyid_p, strlen(keyid), keyid, strlen(name), name); while (((c = fgetc(stdin)) != '\n') && (feof(stdin) == 0)) if (ferror(stdin)) --- 89,93 ---- func001(2); name = get_name(); ! fprintf(stdout, "n:%u:%s:%u:%s:%u:%s\n", strlen(keyid_p), keyid_p, strlen(keyid), keyid, strlen(name), name); while (((c = fgetc(stdin)) != '\n') && (feof(stdin) == 0)) if (ferror(stdin)) *************** *** 123,126 **** --- 98,126 ---- } + unsigned int + encode(char *string) + { + return (tolower(toascii((*string))) * 1000000) + (tolower(toascii(*(string + 1))) * 1000) + (tolower(toascii(*(string + 2)))); + } + + /* Advances over 'n' colons. + */ + void + func001(unsigned int n) + { + char c; + unsigned int i; + + i = 0; + + while (i < n) + if ((c = fgetc(stdin)) == ':') + ++i; + else + if(feof(stdin) || ferror(stdin)) + exit(EX_IOERR); + return; + } + /* Obtain the fingerprint from stdin. */ |
|
From: Jeff B. <jb...@us...> - 2005-05-24 22:40:55
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6494 Modified Files: analysis.c analysis.h graph.c input.c list.c list.h node.c node.h output.c output.h Log Message: interm commit Index: output.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/output.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** output.c 17 May 2005 00:16:07 -0000 1.4 --- output.c 24 May 2005 22:40:45 -0000 1.5 *************** *** 51,55 **** */ void ! output_report(struct graphlist *graph_list) { struct alias *alias; --- 51,55 ---- */ void ! output_report(struct list *graph_list) { struct alias *alias; Index: node.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/node.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** node.c 18 May 2005 01:46:55 -0000 1.12 --- node.c 24 May 2005 22:40:45 -0000 1.13 *************** *** 21,24 **** --- 21,25 ---- #include "node.h" + #include "list.h" void *************** *** 46,50 **** node->msd = 0; ! node->links = nodelist_new(); return node; --- 47,51 ---- node->msd = 0; ! node->links = list_new(node_compare); return node; *************** *** 59,73 **** } ! int node_compare(struct node *node1, struct node *node2) { ! return strcmp(node1->uid, node2->uid); } ! int node_compare_msd(struct node *node1, struct node *node2) { int i; float float_tmp; ! float_tmp = node1->msd - node2->msd; if(float_tmp == (float) 0) i = node_compare(node1, node2); --- 60,76 ---- } ! int ! node_compare(void *node1, void *node2) { ! return strcmp(((struct node *) node1)->uid, ((struct node *) node2)->uid); } ! int ! node_compare_msd(void *node1, void *node2) { int i; float float_tmp; ! float_tmp = ((struct node *) node1)->msd - ((struct node *) node2)->msd; if(float_tmp == (float) 0) i = node_compare(node1, node2); *************** *** 92,106 **** unsigned int distance; unsigned int last_known_size, tmpsize; ! struct nodelist *traversed_nodes, *tmp_nodes; ! struct nodelink *tmp_node; ! traversed_nodes = nodelist_new(); last_known_size = 0; distance = 1; ! nodelist_merge(traversed_nodes, node1->links); ! while((tmpsize = nodelist_size(traversed_nodes)) != last_known_size) { ! if(nodelist_find(traversed_nodes, node2) != NULL) return distance; last_known_size = tmpsize; --- 95,109 ---- unsigned int distance; unsigned int last_known_size, tmpsize; ! struct list *traversed_nodes, *tmp_nodes; ! struct listlink *tmp_node; ! traversed_nodes = list_new(node_compare); last_known_size = 0; distance = 1; ! list_merge(traversed_nodes, node1->links); ! while((tmpsize = list_size(traversed_nodes)) != last_known_size) { ! if(list_find(traversed_nodes, node2) != NULL) return distance; last_known_size = tmpsize; *************** *** 108,116 **** tmp_nodes = traversed_nodes; tmp_node = LIST_FIRST(tmp_nodes); ! traversed_nodes = nodelist_new(); while(tmp_node != NULL) { ! nodelist_add(traversed_nodes, tmp_node->node); ! nodelist_merge(traversed_nodes, ((struct node *) tmp_node->node)->links); tmp_node = LIST_NEXT(tmp_node, list); } --- 111,119 ---- tmp_nodes = traversed_nodes; tmp_node = LIST_FIRST(tmp_nodes); ! traversed_nodes = list_new(node_compare); while(tmp_node != NULL) { ! list_add(traversed_nodes, tmp_node->object); ! list_merge(traversed_nodes, ((struct node *) tmp_node->object)->links); tmp_node = LIST_NEXT(tmp_node, list); } *************** *** 120,135 **** } ! void node_msd(struct node *node, struct nodelist *nodes) { unsigned int distance, i, num_nodes; ! struct nodelink *iter; distance = 0; num_nodes = 0; - iter = LIST_FIRST(nodes); ! while(iter != NULL) { ! i = node_distance(node, iter->node); if(i > 0) { --- 123,138 ---- } ! void ! node_msd(struct node *node, struct list *nodes) { unsigned int distance, i, num_nodes; ! struct listlink *iter; distance = 0; num_nodes = 0; ! LIST_FOREACH(iter, nodes, list) { ! i = node_distance(node, iter->object); if(i > 0) { *************** *** 137,141 **** num_nodes++; } - iter = LIST_NEXT(iter, list); } --- 140,143 ---- Index: analysis.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/analysis.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** analysis.h 17 May 2005 00:12:45 -0000 1.1 --- analysis.h 24 May 2005 22:40:45 -0000 1.2 *************** *** 22,26 **** void analysis_nodes(struct graph *); ! struct graphlist *analysis_seperate_nodes(struct graph *); int do_analysis(struct graph *, char *); --- 22,26 ---- void analysis_nodes(struct graph *); ! struct list *analysis_seperate_nodes(struct graph *); int do_analysis(struct graph *, char *); Index: list.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/list.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** list.c 18 May 2005 01:46:55 -0000 1.4 --- list.c 24 May 2005 22:40:45 -0000 1.5 *************** *** 22,47 **** #include <stdlib.h> #include "list.h" void * ! list_add(struct list *list, void *object, int (*compare)(void *, void *)) { int i; ! struct node_t *iter, *tmpnode; tmpnode = list_new_node(object); if(LIST_EMPTY(list)) ! LIST_INSERT_HEAD(list, tmpnode, entries); else ! LIST_FOREACH(iter, list, entries) { ! if((i = compare(object, iter->object)) < 0) { if(iter == LIST_FIRST(list)) { ! LIST_INSERT_HEAD(list, tmpnode, entries); } else ! LIST_INSERT_BEFORE(iter, tmpnode, entries); break; } --- 22,52 ---- #include <stdlib.h> + #include "alias.h" + #include "graph.h" + #include "node.h" #include "list.h" void * ! list_add(struct list *list, void *object) { int i; ! struct listlink *iter; ! struct listlink *tmpnode; tmpnode = list_new_node(object); + if(LIST_EMPTY(list)) ! LIST_INSERT_HEAD(list, tmpnode, list); else ! LIST_FOREACH(iter, list, list) { ! if((i = list->compare(object, iter->object)) < 0) { if(iter == LIST_FIRST(list)) { ! LIST_INSERT_HEAD(list, tmpnode, list); } else ! LIST_INSERT_BEFORE(iter, tmpnode, list); break; } *************** *** 50,55 **** return iter->object; else ! if(LIST_NEXT(iter, entries) == NULL) ! LIST_INSERT_AFTER(iter, tmpnode, entries); } --- 55,60 ---- return iter->object; else ! if(LIST_NEXT(iter, list) == NULL) ! LIST_INSERT_AFTER(iter, tmpnode, list); } *************** *** 57,105 **** } ! /* Returns NULL on error ! */ ! struct list_t *list_duplicate(struct list_t *list, int (*compare)(void *, void *)) { ! struct list_t *ret_list; ! if((ret_list = list_new()) == NULL) ! return NULL; ! if(list_merge_list(ret_list, list, compare) == NULL) ! return NULL; return ret_list; } ! void *list_find_object(struct list_t *list, void *object, int (*compare)(void *, void*)) { int i; ! struct node_t *iter; ! iter = LIST_FIRST(list); ! while(iter != NULL) { ! if((i = compare(iter->object, object)) == 0) ! return iter->object; ! else ! if(i > 0) ! break; ! iter = LIST_NEXT(iter, entries); } ! return NULL; } ! void list_free(struct list_t *list) { ! struct node_t *iter; ! ! iter = LIST_FIRST(list); ! while(iter != NULL) { ! LIST_FIRST(list) = LIST_NEXT(iter, entries); free(iter); ! iter = LIST_FIRST(list); } --- 62,127 ---- } ! struct list * ! list_duplicate(struct list *list) { ! struct list *ret_list; ! if((ret_list = list_new(list->compare)) != NULL) ! if(list_merge(ret_list, list) == NULL) ! { ! list_free(ret_list); ! ret_list = NULL; ! } return ret_list; } ! /* ! struct list * ! list_duplicate(struct list *list) ! { ! struct list *ret_list; ! struct listlink *list_link; ! ! ret_list = list_new(list->compare); ! ! LIST_FOREACH(list_link, list, list) ! list_add(ret_list, list_link->object); ! ! return ret_list; ! } ! */ ! ! void * ! list_find(struct list *list, void *object) { + void *ret_object; int i; ! struct listlink *iter; ! iter = NULL; ! ret_object = NULL; ! LIST_FOREACH(iter, list, list) { ! if((i = list->compare(iter->object, object)) == 0) ! ret_object = iter->object; ! if(i >= 0) ! break; } ! return ret_object; } ! void ! list_free(struct list *list) { ! struct listlink *iter; ! for(iter = LIST_FIRST(list); !LIST_EMPTY(list); iter = LIST_FIRST(list)) { ! LIST_REMOVE(iter, list); free(iter); ! iter = NULL; } *************** *** 110,148 **** } ! /* Returns ! * NULL on error ! * list1 on success ! */ ! struct list_t *list_merge_list(struct list_t *list1, struct list_t *list2, int (*compare)(void *, void *)) { ! struct node_t *iter; ! LIST_FOREACH(iter, list2, entries) ! list_add_object(list1, iter->object, compare); return list1; } ! /* Returns NULL on error ! */ ! struct list_t *list_new() { ! struct list_t *list; ! if((list = (struct list_t *) malloc(sizeof(struct list_t))) == NULL) ! return NULL; ! LIST_INIT(list); return list; } ! /* Returns NULL on error ! */ ! struct node_t *list_new_node(void *object) { ! struct node_t *node; ! if((node = (struct node_t *) malloc(sizeof(struct node_t))) == NULL) return NULL; --- 132,167 ---- } ! struct list * ! list_merge(struct list *list1, struct list *list2) { ! struct listlink *iter; ! LIST_FOREACH(iter, list2, list) ! list_add(list1, iter->object); return list1; } ! struct list * ! list_new(int (*compare) (void *, void *)) { ! struct list *list; ! if((list = (struct list *) malloc(sizeof(struct list))) != NULL) ! { ! LIST_INIT(list); ! list->compare = compare; ! } return list; } ! struct listlink * ! list_new_node(void *object) { ! struct listlink *node; ! if((node = (struct listlink *) malloc(sizeof(struct listlink))) == NULL) return NULL; *************** *** 152,598 **** } ! void list_remove(struct list_t *list, void *object, int (*compare)(void *, void *)) { ! struct node_t *iter; int i; ! iter = LIST_FIRST(list); ! while(iter != NULL) { ! if((i = compare(iter->object, object)) == 0) { ! if(iter == LIST_FIRST(list)) ! LIST_FIRST(list) = LIST_NEXT(iter, entries); ! else ! LIST_REMOVE(iter, entries); free(iter); - break; } ! else ! if(i < 0) ! break; ! iter = LIST_NEXT(iter, entries); ! } ! ! return; ! } ! ! /* Optimize with quicksort or heapsort I think */ ! struct list_t *list_resort(struct list_t *list, int (*compare)(void *, void *)) ! { ! struct node_t *iter, *tmpiter; ! ! iter = LIST_FIRST(list); ! LIST_FIRST(list) = NULL; ! ! while(iter != NULL) ! { ! list_add_object(list, iter->object, compare); ! tmpiter = iter; ! iter = LIST_NEXT(iter, entries); ! free(tmpiter); } ! return list; ! } ! ! 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 ! * list on success ! */ ! struct list_t *list_union(struct list_t *list1, struct list_t *list2, int (*compare)(void *, void *)) ! { ! struct list_t *list; ! ! if(((list = list_new()) == NULL) || ! (list_merge_list(list, list1, compare) == NULL) || ! (list_merge_list(list, list2, compare) == NULL)) ! return NULL; ! ! return list; } ! ! struct alias * ! aliaslist_add(struct list *alias_list, struct alias *alias) { ! int i; ! struct listlink *alias_iter, *alias_link; ! ! alias_link = (struct listlink *) malloc(sizeof(struct listlink)); ! alias_link->object = alias; ! if(LIST_EMPTY(alias_list)) ! LIST_INSERT_HEAD(alias_list, alias_link, list); ! else ! LIST_FOREACH(alias_iter, alias_list, list) ! { ! if((i = alias_compare(alias, alias_iter->object)) < 0) ! { ! if(alias_iter == LIST_FIRST(alias_list)) ! LIST_INSERT_HEAD(alias_list, alias_link, list); ! else ! LIST_INSERT_BEFORE(alias_iter, alias_link, list); ! break; ! } ! else ! if(i == 0) ! return alias_iter->object; ! else ! if(LIST_NEXT(alias_iter, list) == NULL) ! LIST_INSERT_AFTER(alias_iter, alias_link, list); ! } ! return alias; } struct list * ! aliaslist_duplicate(struct list *alias_list1) ! { ! struct list *alias_list2; ! struct link *alias_link; ! ! alias_list2 = list_new(alias_compare); ! ! LIST_FOREACH(alias_link, alias_list1, list) ! aliaslist_add(alias_list2, alias_link->alias); ! ! return alias_list2; ! } ! ! /* This should take a struct alias, not a char */ ! struct alias * ! aliaslist_find(struct aliaslist *alias_list, char *uid) ! { ! int i; ! struct aliaslink *alias_link; ! ! alias_link = LIST_FIRST(alias_list); ! ! LIST_FOREACH(alias_link, alias_list, list) ! { ! if((i = strcmp(((struct alias *) alias_link->alias)->uid, uid)) == 0) ! return alias_link->alias; ! else ! if(i > 0) ! break; ! } ! ! return NULL; ! } ! ! void ! aliaslist_free(struct aliaslist *alias_list) ! { ! struct aliaslink *alias_link; ! ! LIST_FOREACH(alias_link, alias_list, list) ! { ! LIST_REMOVE(alias_link, list); ! alias_free(alias_link->alias); ! free(alias_link); ! alias_link = NULL; ! } ! free(alias_list); ! ! return; ! } ! ! struct aliaslist * ! aliaslist_new() ! { ! struct aliaslist *list; ! ! if((list = (struct aliaslist *) malloc(sizeof(struct aliaslist))) != NULL) ! LIST_INIT(list); ! ! return list; ! } ! ! struct graph * ! graphlist_add(struct graphlist *graph_list, struct graph *graph) ! { ! int i; ! struct graphlink *graph_iter, *graph_link; ! ! graph_link = (struct graphlink *) malloc(sizeof(struct graphlink)); ! graph_link->graph = graph; ! ! if(LIST_EMPTY(graph_list)) ! LIST_INSERT_HEAD(graph_list, graph_link, list); ! else ! LIST_FOREACH(graph_iter, graph_list, list) ! { ! if((i = graph_compare(graph, graph_iter->graph)) < 0) ! { ! if(graph_iter == LIST_FIRST(graph_list)) ! LIST_INSERT_HEAD(graph_list, graph_link, list); ! else ! LIST_INSERT_BEFORE(graph_iter, graph_link, list); ! break; ! } ! else ! if(i == 0) ! return graph_iter->graph; ! else ! if(LIST_NEXT(graph_iter, list) == NULL) ! LIST_INSERT_AFTER(graph_iter, graph_link, list); ! } ! ! return graph; ! } ! ! struct graphlist * ! graphlist_new() ! { ! struct graphlist *graphlist; ! ! if((graphlist = (struct graphlist *) malloc(sizeof(struct graphlist))) != NULL) ! LIST_INIT(graphlist); ! ! return graphlist; ! } ! struct node * ! nodelist_add(struct nodelist *node_list, struct node *node) ! { ! int i; ! struct nodelink *node_iter, *node_link; ! ! node_link = (struct nodelink *) malloc(sizeof(struct nodelink)); ! node_link->node = node; ! ! if(LIST_EMPTY(node_list)) ! LIST_INSERT_HEAD(node_list, node_link, list); ! else ! LIST_FOREACH(node_iter, node_list, list) ! { ! if((i = node_compare(node, node_iter->node)) < 0) ! { ! if(node_iter == LIST_FIRST(node_list)) ! LIST_INSERT_HEAD(node_list, node_link, list); ! else ! LIST_INSERT_BEFORE(node_iter, node_link, list); ! break; ! } ! else ! if(i == 0) ! return node_iter->node; ! else ! if(LIST_NEXT(node_iter, list) == NULL) ! LIST_INSERT_AFTER(node_iter, node_link, list); ! } ! ! return node; ! } ! ! struct node * ! nodelist_add_msd(struct nodelist *node_list, struct node *node) { ! int i; ! struct nodelink *node_iter, *node_link; ! ! node_link = (struct nodelink *) malloc(sizeof(struct nodelink)); ! node_link->node = node; ! if(LIST_EMPTY(node_list)) ! LIST_INSERT_HEAD(node_list, node_link, list); ! else ! LIST_FOREACH(node_iter, node_list, list) { ! if((i = node_compare_msd(node, node_iter->node)) < 0) ! { ! if(node_iter == LIST_FIRST(node_list)) ! LIST_INSERT_HEAD(node_list, node_link, list); ! else ! LIST_INSERT_BEFORE(node_iter, node_link, list); ! break; ! } ! else ! if(i == 0) ! return node_iter->node; ! else ! if(LIST_NEXT(node_iter, list) == NULL) ! LIST_INSERT_AFTER(node_iter, node_link, list); } ! return node; } int ! nodelist_compare(struct nodelist *node_list1, struct nodelist *node_list2) ! { ! return nodelist_size(node_list2) - nodelist_size(node_list1); ! } ! ! /* How should we go about duplicating a msd organized list. ! */ ! struct nodelist * ! nodelist_duplicate(struct nodelist *node_list1) ! { ! struct nodelist *node_list2; ! struct nodelink *node_link; ! ! node_list2 = nodelist_new(); ! ! LIST_FOREACH(node_link, node_list1, list) ! nodelist_add(node_list2, node_link->node); ! ! return node_list2; ! } ! ! struct node * ! nodelist_find(struct nodelist *node_list, struct node *node) ! { ! int i; ! struct nodelink *node_link; ! ! LIST_FOREACH(node_link, node_list, list) ! if((i = node_compare(node_link->node, node)) == 0) ! return node_link->node; ! else ! if(i > 0) ! break; ! ! return NULL; ! } ! ! void ! nodelist_free(struct nodelist *node_list) ! { ! struct nodelink *node_link, *tmp_link; ! ! tmp_link = NULL; ! ! LIST_FOREACH(node_link, node_list, list) ! { ! free(tmp_link); ! tmp_link = node_link; ! LIST_REMOVE(node_link, list); ! } ! ! free(node_link); ! free(node_list); ! } ! ! struct nodelist * ! nodelist_intersection(struct nodelist *node_list1, struct nodelist *node_list2) { ! struct nodelink *node_iter; ! struct nodelist *node_list; ! ! node_list = nodelist_new(); ! LIST_FOREACH(node_iter, node_list1, list) ! if(nodelist_find(node_list2, node_iter->node) != NULL) ! nodelist_add(node_list, node_iter->node); ! ! return node_list; } ! struct nodelist * ! nodelist_merge(struct nodelist *node_list1, struct nodelist *node_list2) { ! struct nodelink *node_iter; ! ! LIST_FOREACH(node_iter, node_list2, list) ! nodelist_add(node_list1, node_iter->node); ! ! return node_list1; ! } ! struct nodelist * ! nodelist_new() ! { ! struct nodelist *list; ! if((list = (struct nodelist *) malloc(sizeof(struct nodelist))) != NULL) ! LIST_INIT(list); ! return list; } void ! nodelist_print(FILE *filep, struct nodelist *node_list) { ! struct nodelink *node_link; ! LIST_FOREACH(node_link, node_list, list) ! node_print(filep, node_link->node); return; } ! struct node * ! nodelist_remove(struct nodelist *node_list, struct node *node) ! { ! int i; ! struct node *tmp_node; ! struct nodelink *node_link; ! ! LIST_FOREACH(node_link, node_list, list) ! { ! tmp_node = node_link->node; ! if((i = node_compare(tmp_node, node)) == 0) ! { ! LIST_REMOVE(node_link, list); ! free(node_link); ! return tmp_node; ! } ! else ! if(i > 0) ! break; ! } ! ! return NULL; ! } ! ! unsigned int ! nodelist_size(struct nodelist *node_list) ! { ! struct nodelink *node_iter; ! unsigned int size; ! ! size = 0; ! ! LIST_FOREACH(node_iter, node_list, list) ! ++size; ! ! return size; ! } ! ! struct nodelist * ! nodelist_subtract(struct nodelist *node_list1, struct nodelist *node_list2) { ! struct nodelink *node_link; ! struct nodelist *node_list; ! ! node_list = nodelist_duplicate(node_list1); ! ! LIST_FOREACH(node_link, node_list2, list) ! nodelist_remove(node_list, node_link->node); ! ! return node_list; ! } ! struct nodelist * ! nodelist_union(struct nodelist *node_list1, struct nodelist *node_list2) ! { ! struct nodelist *node_list; ! node_list = nodelist_duplicate(node_list1); ! nodelist_merge(node_list, node_list2); ! return node_list; } - --- 171,270 ---- } ! void * ! list_remove(struct list *list, void *object) { ! void *ret_object; ! struct listlink *iter; int i; ! ret_object = NULL; ! LIST_FOREACH(iter, list, list) { ! if((i = list->compare(iter->object, object)) == 0) { ! ret_object = iter->object; ! LIST_REMOVE(iter, list); free(iter); } ! if(i <= 0) ! break; } ! return ret_object; } ! unsigned int ! list_size(struct list *list) { ! struct listlink *iter; ! unsigned int size; ! LIST_FOREACH(iter, list, list) ! if((size + 1) != 0) ! ++size; ! return size; } struct list * ! list_union(struct list *list1, struct list *list2) { ! struct list *list; ! if((list = list_duplicate(list1)) != NULL) ! if(list_merge(list, list2) == NULL) { ! list_free(list); ! list = NULL; } ! return list; } int ! list_compare(struct list *list1, struct list *list2) { ! return list1->compare(LIST_FIRST(list1)->object, LIST_FIRST(list2)->object); } ! struct list * ! list_intersection(struct list *list1, struct list *list2) { ! struct listlink *iter; ! struct list *ret_list; ! ret_list = list_new(list1->compare); ! LIST_FOREACH(iter, list1, list) ! if(list_find(list2, iter->object) != NULL) ! list_add(ret_list, iter->object); ! return ret_list; } void ! list_print(FILE *filep, struct list *list) { ! struct listlink *iter; ! LIST_FOREACH(iter, list, list) ! list->print(filep, iter->object); return; } ! struct list * ! list_subtract(struct list *list1, struct list *list2) { ! struct listlink *iter; ! struct list *ret_list; ! ret_list = list_duplicate(list1); ! LIST_FOREACH(iter, list2, list) ! list_remove(ret_list, iter->object); ! return ret_list; } Index: node.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/node.h,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** node.h 17 May 2005 14:30:26 -0000 1.9 --- node.h 24 May 2005 22:40:45 -0000 1.10 *************** *** 31,36 **** }; ! int node_compare(struct node *, struct node *); ! int node_compare_msd(struct node *, struct node *); unsigned int node_distance(struct node *, struct node *); void node_free(struct node *); --- 31,36 ---- }; ! int node_compare(void *, void *); ! int node_compare_msd(void *, void *); unsigned int node_distance(struct node *, struct node *); void node_free(struct node *); *************** *** 38,55 **** void node_print(FILE *, struct node *); - struct node *nodelist_add(struct list *, struct node *); - struct node *nodelist_add_msd(struct list *, struct node *); - int nodelist_compare(struct list *, struct list *); - struct list *nodelist_duplicate(struct list *); - struct node *nodelist_find(struct list *, struct node *); - void nodelist_free(struct list *); - struct list *nodelist_intersection(struct list *, struct list *); - struct list *nodelist_merge(struct list *, struct list *); - struct list *nodelist_new(void); - void nodelist_print(FILE *, struct list *); - struct node *nodelist_remove(struct list *, struct node *); - unsigned int nodelist_size(struct list *); - struct list *nodelist_subtract(struct list *, struct list *); - struct list *nodelist_union(struct list *, struct list *); - #endif /* _NODE_H_ */ --- 38,40 ---- Index: output.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/output.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** output.h 16 May 2005 23:59:03 -0000 1.1 --- output.h 24 May 2005 22:40:45 -0000 1.2 *************** *** 24,28 **** int output_main_directory(char *); ! void output_report(struct graphlist *); int output_new_directory(char *); void output_file(struct node *, struct graph *); --- 24,28 ---- int output_main_directory(char *); ! void output_report(struct list *); int output_new_directory(char *); void output_file(struct node *, struct graph *); Index: input.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/input.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** input.c 17 May 2005 00:08:06 -0000 1.1 --- input.c 24 May 2005 22:40:45 -0000 1.2 *************** *** 22,25 **** --- 22,26 ---- #include "graph.h" #include "node.h" + #include "list.h" char * *************** *** 65,69 **** char type; ! for(c = type = getchar(); type == 'e' || type == 'n' || type == 'a'; c = type = getchar()) { if(((c = getchar()) != ':') && (c != EOF)) --- 66,70 ---- char type; ! for(c = type = getchar(); type == 'e' || type == 'n'; c = type = getchar()) { if(((c = getchar()) != ':') && (c != EOF)) *************** *** 75,99 **** if(*field1 == EOF) break; ! if(type != 'n') /* Grab 2nd field for edges and alias' */ { if(((c = getchar()) != ':') && (c != EOF)) ! errx(EX_DATAERR, "2: Invalid character, %c (ASCII: %d), encountered!\n", c, c); if(c == EOF) break; ! if((field2 = get_field()) == NULL) errx(EX_OSERR, "Cannot allocate memory!\n"); ! if(*field2 == EOF) break; - if(type == 'a') /* Grab 3rd field for an alias */ - { - if(((c = getchar()) != ':') && (c != EOF)) - errx(EX_DATAERR, "3: Invalid character, %c (ASCII: %d), encountered!\n", c, c); - if(c == EOF) - break; - if((field3 = get_field()) == NULL) - errx(EX_OSERR, "Cannot allocate memory!\n"); - if(*field3 == EOF) - break; - } } if(((c = getchar()) != '\n') && (c != EOF)) --- 76,97 ---- if(*field1 == EOF) break; ! if(((c = getchar()) != ':') && (c != EOF)) ! errx(EX_DATAERR, "2: Invalid character, %c (ASCII: %d), encountered!\n", c, c); ! if(c == EOF) ! break; ! if((field2 = get_field()) == NULL) ! errx(EX_OSERR, "Cannot allocate memory!\n"); ! if(*field2 == EOF) ! break; ! if(type == 'n') /* Grab 3rd field for an alias */ { if(((c = getchar()) != ':') && (c != EOF)) ! errx(EX_DATAERR, "3: Invalid character, %c (ASCII: %d), encountered!\n", c, c); if(c == EOF) break; ! if((field3 = get_field()) == NULL) errx(EX_OSERR, "Cannot allocate memory!\n"); ! if(*field3 == EOF) break; } if(((c = getchar()) != '\n') && (c != EOF)) *************** *** 102,114 **** switch (type) { ! case 'a': node1 = node_new(field1); free(field1); ! if((node2 = nodelist_add(graph->node_list, node1)) != node1) node_free(node1); alias1 = alias_new(field2, field3, node2); free(field2); free(field3); ! if((alias2 = aliaslist_add(graph->alias_list, alias1)) != alias1) alias_free(alias1); break; --- 100,112 ---- switch (type) { ! case 'n': node1 = node_new(field1); free(field1); ! if((node2 = list_add(graph->node_list, node1)) != node1) node_free(node1); alias1 = alias_new(field2, field3, node2); free(field2); free(field3); ! if((alias2 = list_add(graph->alias_list, alias1)) != alias1) alias_free(alias1); break; *************** *** 116,137 **** node1 = node_new(field1); free(field1); ! if((node2 = nodelist_add(graph->node_list, node1)) != node1) node_free(node1); node1 = node_new(field2); free(field2); ! if((node3 = nodelist_add(graph->node_list, node1)) != node1) node_free(node1); ! if((node1 = nodelist_add(node2->links, node3)) != node3) node_free(node3); break; - /* a lines will eventually be renamed to n lines, when this happens - * the following gets ripped out. - */ - case 'n': - node1 = node_new(field1); - free(field1); - if((node2 = nodelist_add(graph->node_list, node1)) != node1) - node_free(node1); - break; } --- 114,126 ---- node1 = node_new(field1); free(field1); ! if((node2 = list_add(graph->node_list, node1)) != node1) node_free(node1); node1 = node_new(field2); free(field2); ! if((node3 = list_add(graph->node_list, node1)) != node1) node_free(node1); ! if((node1 = list_add(node2->links, node3)) != node3) node_free(node3); break; } Index: list.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/list.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** list.h 18 May 2005 01:46:55 -0000 1.6 --- list.h 24 May 2005 22:40:45 -0000 1.7 *************** *** 34,37 **** --- 34,38 ---- struct listlink *lh_first; int (*compare) (void *, void *); + void (*print) (FILE *, void *); }; *************** *** 49,55 **** struct list *); struct list *list_new(int (*) (void *, void *)); void list_print(FILE *, struct list *); ! void list_remove(struct list *, void *); unsigned int list_size(struct list *); --- 50,57 ---- struct list *); struct list *list_new(int (*) (void *, void *)); + struct listlink *list_new_node(void *); void list_print(FILE *, struct list *); ! void *list_remove(struct list *, void *); unsigned int list_size(struct list *); Index: graph.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/graph.c,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** graph.c 18 May 2005 01:46:55 -0000 1.4 --- graph.c 24 May 2005 22:40:45 -0000 1.5 *************** *** 25,33 **** graph_compare(struct graph *graph1, struct graph *graph2) { ! return nodelist_compare(graph1->node_list, graph2->node_list); } struct graph * ! graph_new(struct aliaslist *alias_list, struct nodelist *node_list) { struct graph *graph; --- 25,33 ---- graph_compare(struct graph *graph1, struct graph *graph2) { ! return list_compare(graph1->node_list, graph2->node_list); } struct graph * ! graph_new(struct list *alias_list, struct list *node_list) { struct graph *graph; Index: analysis.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/analysis.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** analysis.c 17 May 2005 00:12:45 -0000 1.1 --- analysis.c 24 May 2005 22:40:45 -0000 1.2 *************** *** 16,20 **** --- 16,26 ---- */ + #include <sys/queue.h> + #include "analysis.h" + #include "graph.h" + #include "list.h" + #include "node.h" + #include "output.h" /* Analyze the keys and output the results. *************** *** 25,29 **** do_analysis(struct graph *graph, char *outputdir) { ! struct graphlist *graph_list; graph_list = NULL; --- 31,35 ---- do_analysis(struct graph *graph, char *outputdir) { ! struct list *graph_list; graph_list = NULL; *************** *** 39,65 **** analysis_nodes(struct graph *graph) { ! struct nodelink *node_link; LIST_FOREACH(node_link, graph->node_list, list) ! output_file(node_link->node, graph); return; } ! struct graphlist * analysis_seperate_nodes(struct graph *graph) { ! struct aliaslist *alias_list; ! struct graphlist *graph_list; ! struct nodelink *node_link1; ! struct nodelink *node_link2; ! struct nodelist *node_list; ! struct nodelist *node_list_msd1; ! struct nodelist *node_list_msd2; /* Duplicate the graphs alias and node lists so as to not modify the original copies. */ ! alias_list = aliaslist_duplicate(graph->alias_list); ! node_list = nodelist_duplicate(graph->node_list); /* Create the list, to add the msd sorted graphs to. --- 45,71 ---- analysis_nodes(struct graph *graph) { ! struct listlink *node_link; LIST_FOREACH(node_link, graph->node_list, list) ! output_file(node_link->object, graph); return; } ! struct list * analysis_seperate_nodes(struct graph *graph) { ! struct list *alias_list; ! struct list *graph_list; ! struct listlink *node_link1; ! struct listlink *node_link2; ! struct list *node_list; ! struct list *node_list_msd1; ! struct list *node_list_msd2; /* Duplicate the graphs alias and node lists so as to not modify the original copies. */ ! alias_list = list_duplicate(graph->alias_list); ! node_list = list_duplicate(graph->node_list); /* Create the list, to add the msd sorted graphs to. *************** *** 73,102 **** /* Create two new node lists. */ ! if(((node_list_msd1 = nodelist_new()) == NULL) || ! ((node_list_msd2 = nodelist_new()) == NULL)) return NULL; /* Add the first node from the node list to our msd sorted node list. And remove it from the non msd sorted node list. */ ! nodelist_add_msd(node_list_msd1, LIST_FIRST(node_list)->node); ! nodelist_remove(node_list, LIST_FIRST(node_list)->node); /* Add nodes that link to nodes in list2 to list1 then clone list1 onto list2 and repeat until no updates occur. */ ! while(nodelist_size(node_list_msd1) != nodelist_size(node_list_msd2)) { /* Duplicate nodelist1 onto nodelist2. */ ! nodelist_free(node_list_msd2); ! if((node_list_msd2 = nodelist_duplicate(node_list_msd1)) == NULL) return NULL; ! /* Iterate through nodelist2 adding nodes to nodelist1. */ LIST_FOREACH(node_link1, node_list_msd2, list) ! LIST_FOREACH(node_link2, ((struct node *) node_link1->node)->links, list) ! if(node_distance(node_link2->node, node_link1->node)) { ! nodelist_add_msd(node_list_msd1, node_link2->node); ! nodelist_remove(node_list, node_link2->node); } } --- 79,108 ---- /* Create two new node lists. */ ! if(((node_list_msd1 = list_new(node_compare_msd)) == NULL) || ! ((node_list_msd2 = list_new(node_compare_msd)) == NULL)) return NULL; /* 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); /* Add nodes that link to nodes in list2 to list1 then clone list1 onto list2 and repeat until no updates occur. */ ! while(list_size(node_list_msd1) != list_size(node_list_msd2)) { /* Duplicate nodelist1 onto nodelist2. */ ! list_free(node_list_msd2); ! if((node_list_msd2 = list_duplicate(node_list_msd1)) == NULL) return NULL; ! /* Iterate through list2 adding nodes to nodelist1. */ LIST_FOREACH(node_link1, node_list_msd2, list) ! LIST_FOREACH(node_link2, ((struct node *) node_link1->object)->links, list) ! 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); } } *************** *** 108,116 **** /* Free the 2nd nodelist so as to not leak memory. */ ! nodelist_free(node_list_msd2); } /* Free the copy of the node_list. */ ! nodelist_free(node_list); return graph_list; --- 114,122 ---- /* Free the 2nd nodelist so as to not leak memory. */ ! list_free(node_list_msd2); } /* Free the copy of the node_list. */ ! list_free(node_list); return graph_list; |
|
From: Jeff B. <jb...@us...> - 2005-05-18 01:47:12
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13279 Modified Files: alias.c alias.h graph.c list.c list.h node.c Log Message: misc changes Index: alias.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/alias.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** alias.c 17 May 2005 15:16:28 -0000 1.8 --- alias.c 18 May 2005 01:46:55 -0000 1.9 *************** *** 20,27 **** #include "alias.h" int ! alias_compare(struct alias *alias1, struct alias *alias2) { return strcmp(alias1->uid, alias2->uid); } --- 20,31 ---- #include "alias.h" + #include "list.h" int ! alias_compare(void *obj1, void *obj2) { + struct alias *alias1 = obj1; + struct alias *alias2 = obj2; + return strcmp(alias1->uid, alias2->uid); } *************** *** 62,159 **** } - struct alias * - aliaslist_add(struct list *alias_list, struct alias *alias) - { - int i; - struct listlink *alias_iter, *alias_link; - - alias_link = (struct listlink *) malloc(sizeof(struct listlink)); - alias_link->object = alias; - - if(LIST_EMPTY(alias_list)) - LIST_INSERT_HEAD(alias_list, alias_link, list); - else - LIST_FOREACH(alias_iter, alias_list, list) - { - if((i = alias_compare(alias, alias_iter->object)) < 0) - { - if(alias_iter == LIST_FIRST(alias_list)) - LIST_INSERT_HEAD(alias_list, alias_link, list); - else - LIST_INSERT_BEFORE(alias_iter, alias_link, list); - break; - } - else - if(i == 0) - return alias_iter->object; - else - if(LIST_NEXT(alias_iter, list) == NULL) - LIST_INSERT_AFTER(alias_iter, alias_link, list); - } - - return alias; - } - - struct aliaslist * - aliaslist_duplicate(struct aliaslist *alias_list1) - { - struct aliaslist *alias_list2; - struct aliaslink *alias_link; - - alias_list2 = aliaslist_new(); - - LIST_FOREACH(alias_link, alias_list1, list) - aliaslist_add(alias_list2, alias_link->alias); - - return alias_list2; - } - - /* This should take a struct alias, not a char */ - struct alias * - aliaslist_find(struct aliaslist *alias_list, char *uid) - { - int i; - struct aliaslink *alias_link; - - alias_link = LIST_FIRST(alias_list); - - LIST_FOREACH(alias_link, alias_list, list) - { - if((i = strcmp(((struct alias *) alias_link->alias)->uid, uid)) == 0) - return alias_link->alias; - else - if(i > 0) - break; - } - - return NULL; - } - - void - aliaslist_free(struct aliaslist *alias_list) - { - struct aliaslink *alias_link; - - LIST_FOREACH(alias_link, alias_list, list) - { - LIST_REMOVE(alias_link, list); - alias_free(alias_link->alias); - free(alias_link); - alias_link = NULL; - } - free(alias_list); - - return; - } - - struct aliaslist * - aliaslist_new() - { - struct aliaslist *list; - - if((list = (struct aliaslist *) malloc(sizeof(struct aliaslist))) != NULL) - LIST_INIT(list); - - return list; - } - --- 66,67 ---- Index: node.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/node.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** node.c 14 May 2005 02:56:24 -0000 1.11 --- node.c 18 May 2005 01:46:55 -0000 1.12 *************** *** 59,294 **** } - struct node * - nodelist_add(struct nodelist *node_list, struct node *node) - { - int i; - struct nodelink *node_iter, *node_link; - - node_link = (struct nodelink *) malloc(sizeof(struct nodelink)); - node_link->node = node; - - if(LIST_EMPTY(node_list)) - LIST_INSERT_HEAD(node_list, node_link, list); - else - LIST_FOREACH(node_iter, node_list, list) - { - if((i = node_compare(node, node_iter->node)) < 0) - { - if(node_iter == LIST_FIRST(node_list)) - LIST_INSERT_HEAD(node_list, node_link, list); - else - LIST_INSERT_BEFORE(node_iter, node_link, list); - break; - } - else - if(i == 0) - return node_iter->node; - else - if(LIST_NEXT(node_iter, list) == NULL) - LIST_INSERT_AFTER(node_iter, node_link, list); - } - - return node; - } - - struct node * - nodelist_add_msd(struct nodelist *node_list, struct node *node) - { - int i; - struct nodelink *node_iter, *node_link; - - node_link = (struct nodelink *) malloc(sizeof(struct nodelink)); - node_link->node = node; - - if(LIST_EMPTY(node_list)) - LIST_INSERT_HEAD(node_list, node_link, list); - else - LIST_FOREACH(node_iter, node_list, list) - { - if((i = node_compare_msd(node, node_iter->node)) < 0) - { - if(node_iter == LIST_FIRST(node_list)) - LIST_INSERT_HEAD(node_list, node_link, list); - else - LIST_INSERT_BEFORE(node_iter, node_link, list); - break; - } - else - if(i == 0) - return node_iter->node; - else - if(LIST_NEXT(node_iter, list) == NULL) - LIST_INSERT_AFTER(node_iter, node_link, list); - } - - return node; - } - - int - nodelist_compare(struct nodelist *node_list1, struct nodelist *node_list2) - { - return nodelist_size(node_list2) - nodelist_size(node_list1); - } - - /* How should we go about duplicating a msd organized list. - */ - struct nodelist * - nodelist_duplicate(struct nodelist *node_list1) - { - struct nodelist *node_list2; - struct nodelink *node_link; - - node_list2 = nodelist_new(); - - LIST_FOREACH(node_link, node_list1, list) - nodelist_add(node_list2, node_link->node); - - return node_list2; - } - - struct node * - nodelist_find(struct nodelist *node_list, struct node *node) - { - int i; - struct nodelink *node_link; - - LIST_FOREACH(node_link, node_list, list) - if((i = node_compare(node_link->node, node)) == 0) - return node_link->node; - else - if(i > 0) - break; - - return NULL; - } - - void - nodelist_free(struct nodelist *node_list) - { - struct nodelink *node_link, *tmp_link; - - tmp_link = NULL; - - LIST_FOREACH(node_link, node_list, list) - { - free(tmp_link); - tmp_link = node_link; - LIST_REMOVE(node_link, list); - } - - free(node_link); - free(node_list); - } - - struct nodelist * - nodelist_intersection(struct nodelist *node_list1, struct nodelist *node_list2) - { - struct nodelink *node_iter; - struct nodelist *node_list; - - node_list = nodelist_new(); - LIST_FOREACH(node_iter, node_list1, list) - if(nodelist_find(node_list2, node_iter->node) != NULL) - nodelist_add(node_list, node_iter->node); - - return node_list; - } - - struct nodelist * - nodelist_merge(struct nodelist *node_list1, struct nodelist *node_list2) - { - struct nodelink *node_iter; - - LIST_FOREACH(node_iter, node_list2, list) - nodelist_add(node_list1, node_iter->node); - - return node_list1; - } - - struct nodelist * - nodelist_new() - { - struct nodelist *list; - - if((list = (struct nodelist *) malloc(sizeof(struct nodelist))) != NULL) - LIST_INIT(list); - - return list; - } - - void - nodelist_print(FILE *filep, struct nodelist *node_list) - { - struct nodelink *node_link; - - LIST_FOREACH(node_link, node_list, list) - node_print(filep, node_link->node); - - return; - } - - struct node * - nodelist_remove(struct nodelist *node_list, struct node *node) - { - int i; - struct node *tmp_node; - struct nodelink *node_link; - - LIST_FOREACH(node_link, node_list, list) - { - tmp_node = node_link->node; - if((i = node_compare(tmp_node, node)) == 0) - { - LIST_REMOVE(node_link, list); - free(node_link); - return tmp_node; - } - else - if(i > 0) - break; - } - - return NULL; - } - - unsigned int - nodelist_size(struct nodelist *node_list) - { - struct nodelink *node_iter; - unsigned int size; - - size = 0; - - LIST_FOREACH(node_iter, node_list, list) - ++size; - - return size; - } - - struct nodelist * - nodelist_subtract(struct nodelist *node_list1, struct nodelist *node_list2) - { - struct nodelink *node_link; - struct nodelist *node_list; - - node_list = nodelist_duplicate(node_list1); - - LIST_FOREACH(node_link, node_list2, list) - nodelist_remove(node_list, node_link->node); - - return node_list; - } - - struct nodelist * - nodelist_union(struct nodelist *node_list1, struct nodelist *node_list2) - { - struct nodelist *node_list; - - node_list = nodelist_duplicate(node_list1); - nodelist_merge(node_list, node_list2); - - return node_list; - } - int node_compare(struct node *node1, struct node *node2) { --- 59,62 ---- *************** *** 376,378 **** return; } ! --- 144,146 ---- return; } ! Index: list.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/list.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** list.c 17 May 2005 14:30:26 -0000 1.3 --- list.c 18 May 2005 01:46:55 -0000 1.4 *************** *** 222,224 **** return list; ! } --- 222,598 ---- return list; ! } ! ! ! struct alias * ! aliaslist_add(struct list *alias_list, struct alias *alias) ! { ! int i; ! struct listlink *alias_iter, *alias_link; ! ! alias_link = (struct listlink *) malloc(sizeof(struct listlink)); ! alias_link->object = alias; ! ! if(LIST_EMPTY(alias_list)) ! LIST_INSERT_HEAD(alias_list, alias_link, list); ! else ! LIST_FOREACH(alias_iter, alias_list, list) ! { ! if((i = alias_compare(alias, alias_iter->object)) < 0) ! { ! if(alias_iter == LIST_FIRST(alias_list)) ! LIST_INSERT_HEAD(alias_list, alias_link, list); ! else ! LIST_INSERT_BEFORE(alias_iter, alias_link, list); ! break; ! } ! else ! if(i == 0) ! return alias_iter->object; ! else ! if(LIST_NEXT(alias_iter, list) == NULL) ! LIST_INSERT_AFTER(alias_iter, alias_link, list); ! } ! ! return alias; ! } ! ! struct list * ! aliaslist_duplicate(struct list *alias_list1) ! { ! struct list *alias_list2; ! struct link *alias_link; ! ! alias_list2 = list_new(alias_compare); ! ! LIST_FOREACH(alias_link, alias_list1, list) ! aliaslist_add(alias_list2, alias_link->alias); ! ! return alias_list2; ! } ! ! /* This should take a struct alias, not a char */ ! struct alias * ! aliaslist_find(struct aliaslist *alias_list, char *uid) ! { ! int i; ! struct aliaslink *alias_link; ! ! alias_link = LIST_FIRST(alias_list); ! ! LIST_FOREACH(alias_link, alias_list, list) ! { ! if((i = strcmp(((struct alias *) alias_link->alias)->uid, uid)) == 0) ! return alias_link->alias; ! else ! if(i > 0) ! break; ! } ! ! return NULL; ! } ! ! void ! aliaslist_free(struct aliaslist *alias_list) ! { ! struct aliaslink *alias_link; ! ! LIST_FOREACH(alias_link, alias_list, list) ! { ! LIST_REMOVE(alias_link, list); ! alias_free(alias_link->alias); ! free(alias_link); ! alias_link = NULL; ! } ! free(alias_list); ! ! return; ! } ! ! struct aliaslist * ! aliaslist_new() ! { ! struct aliaslist *list; ! ! if((list = (struct aliaslist *) malloc(sizeof(struct aliaslist))) != NULL) ! LIST_INIT(list); ! ! return list; ! } ! ! struct graph * ! graphlist_add(struct graphlist *graph_list, struct graph *graph) ! { ! int i; ! struct graphlink *graph_iter, *graph_link; ! ! graph_link = (struct graphlink *) malloc(sizeof(struct graphlink)); ! graph_link->graph = graph; ! ! if(LIST_EMPTY(graph_list)) ! LIST_INSERT_HEAD(graph_list, graph_link, list); ! else ! LIST_FOREACH(graph_iter, graph_list, list) ! { ! if((i = graph_compare(graph, graph_iter->graph)) < 0) ! { ! if(graph_iter == LIST_FIRST(graph_list)) ! LIST_INSERT_HEAD(graph_list, graph_link, list); ! else ! LIST_INSERT_BEFORE(graph_iter, graph_link, list); ! break; ! } ! else ! if(i == 0) ! return graph_iter->graph; ! else ! if(LIST_NEXT(graph_iter, list) == NULL) ! LIST_INSERT_AFTER(graph_iter, graph_link, list); ! } ! ! return graph; ! } ! ! struct graphlist * ! graphlist_new() ! { ! struct graphlist *graphlist; ! ! if((graphlist = (struct graphlist *) malloc(sizeof(struct graphlist))) != NULL) ! LIST_INIT(graphlist); ! ! return graphlist; ! } ! struct node * ! nodelist_add(struct nodelist *node_list, struct node *node) ! { ! int i; ! struct nodelink *node_iter, *node_link; ! ! node_link = (struct nodelink *) malloc(sizeof(struct nodelink)); ! node_link->node = node; ! ! if(LIST_EMPTY(node_list)) ! LIST_INSERT_HEAD(node_list, node_link, list); ! else ! LIST_FOREACH(node_iter, node_list, list) ! { ! if((i = node_compare(node, node_iter->node)) < 0) ! { ! if(node_iter == LIST_FIRST(node_list)) ! LIST_INSERT_HEAD(node_list, node_link, list); ! else ! LIST_INSERT_BEFORE(node_iter, node_link, list); ! break; ! } ! else ! if(i == 0) ! return node_iter->node; ! else ! if(LIST_NEXT(node_iter, list) == NULL) ! LIST_INSERT_AFTER(node_iter, node_link, list); ! } ! ! return node; ! } ! ! struct node * ! nodelist_add_msd(struct nodelist *node_list, struct node *node) ! { ! int i; ! struct nodelink *node_iter, *node_link; ! ! node_link = (struct nodelink *) malloc(sizeof(struct nodelink)); ! node_link->node = node; ! ! if(LIST_EMPTY(node_list)) ! LIST_INSERT_HEAD(node_list, node_link, list); ! else ! LIST_FOREACH(node_iter, node_list, list) ! { ! if((i = node_compare_msd(node, node_iter->node)) < 0) ! { ! if(node_iter == LIST_FIRST(node_list)) ! LIST_INSERT_HEAD(node_list, node_link, list); ! else ! LIST_INSERT_BEFORE(node_iter, node_link, list); ! break; ! } ! else ! if(i == 0) ! return node_iter->node; ! else ! if(LIST_NEXT(node_iter, list) == NULL) ! LIST_INSERT_AFTER(node_iter, node_link, list); ! } ! ! return node; ! } ! ! int ! nodelist_compare(struct nodelist *node_list1, struct nodelist *node_list2) ! { ! return nodelist_size(node_list2) - nodelist_size(node_list1); ! } ! ! /* How should we go about duplicating a msd organized list. ! */ ! struct nodelist * ! nodelist_duplicate(struct nodelist *node_list1) ! { ! struct nodelist *node_list2; ! struct nodelink *node_link; ! ! node_list2 = nodelist_new(); ! ! LIST_FOREACH(node_link, node_list1, list) ! nodelist_add(node_list2, node_link->node); ! ! return node_list2; ! } ! ! struct node * ! nodelist_find(struct nodelist *node_list, struct node *node) ! { ! int i; ! struct nodelink *node_link; ! ! LIST_FOREACH(node_link, node_list, list) ! if((i = node_compare(node_link->node, node)) == 0) ! return node_link->node; ! else ! if(i > 0) ! break; ! ! return NULL; ! } ! ! void ! nodelist_free(struct nodelist *node_list) ! { ! struct nodelink *node_link, *tmp_link; ! ! tmp_link = NULL; ! ! LIST_FOREACH(node_link, node_list, list) ! { ! free(tmp_link); ! tmp_link = node_link; ! LIST_REMOVE(node_link, list); ! } ! ! free(node_link); ! free(node_list); ! } ! ! struct nodelist * ! nodelist_intersection(struct nodelist *node_list1, struct nodelist *node_list2) ! { ! struct nodelink *node_iter; ! struct nodelist *node_list; ! ! node_list = nodelist_new(); ! LIST_FOREACH(node_iter, node_list1, list) ! if(nodelist_find(node_list2, node_iter->node) != NULL) ! nodelist_add(node_list, node_iter->node); ! ! return node_list; ! } ! ! struct nodelist * ! nodelist_merge(struct nodelist *node_list1, struct nodelist *node_list2) ! { ! struct nodelink *node_iter; ! ! LIST_FOREACH(node_iter, node_list2, list) ! nodelist_add(node_list1, node_iter->node); ! ! return node_list1; ! } ! ! struct nodelist * ! nodelist_new() ! { ! struct nodelist *list; ! ! if((list = (struct nodelist *) malloc(sizeof(struct nodelist))) != NULL) ! LIST_INIT(list); ! ! return list; ! } ! ! void ! nodelist_print(FILE *filep, struct nodelist *node_list) ! { ! struct nodelink *node_link; ! ! LIST_FOREACH(node_link, node_list, list) ! node_print(filep, node_link->node); ! ! return; ! } ! ! struct node * ! nodelist_remove(struct nodelist *node_list, struct node *node) ! { ! int i; ! struct node *tmp_node; ! struct nodelink *node_link; ! ! LIST_FOREACH(node_link, node_list, list) ! { ! tmp_node = node_link->node; ! if((i = node_compare(tmp_node, node)) == 0) ! { ! LIST_REMOVE(node_link, list); ! free(node_link); ! return tmp_node; ! } ! else ! if(i > 0) ! break; ! } ! ! return NULL; ! } ! ! unsigned int ! nodelist_size(struct nodelist *node_list) ! { ! struct nodelink *node_iter; ! unsigned int size; ! ! size = 0; ! ! LIST_FOREACH(node_iter, node_list, list) ! ++size; ! ! return size; ! } ! ! struct nodelist * ! nodelist_subtract(struct nodelist *node_list1, struct nodelist *node_list2) ! { ! struct nodelink *node_link; ! struct nodelist *node_list; ! ! node_list = nodelist_duplicate(node_list1); ! ! LIST_FOREACH(node_link, node_list2, list) ! nodelist_remove(node_list, node_link->node); ! ! return node_list; ! } ! ! struct nodelist * ! nodelist_union(struct nodelist *node_list1, struct nodelist *node_list2) ! { ! struct nodelist *node_list; ! ! node_list = nodelist_duplicate(node_list1); ! nodelist_merge(node_list, node_list2); ! ! return node_list; ! } ! ! Index: alias.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/alias.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** alias.h 17 May 2005 14:30:26 -0000 1.6 --- alias.h 18 May 2005 01:46:55 -0000 1.7 *************** *** 30,42 **** }; ! int alias_compare(struct alias *, struct alias *); void alias_free(struct alias *); struct alias *alias_new(char *, char *, struct node *); - struct alias *aliaslist_add(struct list *, struct alias *); - struct list *aliaslist_duplicate(struct list *); - struct alias *aliaslist_find(struct list *, char *); - void aliaslist_free(struct list *); - struct list *aliaslist_new(void); - #endif /* _ALIAS_H_ */ --- 30,36 ---- }; ! int alias_compare(void *, void *); void alias_free(struct alias *); struct alias *alias_new(char *, char *, struct node *); #endif /* _ALIAS_H_ */ Index: graph.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/graph.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** graph.c 22 Apr 2005 01:55:21 -0000 1.3 --- graph.c 18 May 2005 01:46:55 -0000 1.4 *************** *** 42,87 **** } - struct graph * - graphlist_add(struct graphlist *graph_list, struct graph *graph) - { - int i; - struct graphlink *graph_iter, *graph_link; - - graph_link = (struct graphlink *) malloc(sizeof(struct graphlink)); - graph_link->graph = graph; - - if(LIST_EMPTY(graph_list)) - LIST_INSERT_HEAD(graph_list, graph_link, list); - else - LIST_FOREACH(graph_iter, graph_list, list) - { - if((i = graph_compare(graph, graph_iter->graph)) < 0) - { - if(graph_iter == LIST_FIRST(graph_list)) - LIST_INSERT_HEAD(graph_list, graph_link, list); - else - LIST_INSERT_BEFORE(graph_iter, graph_link, list); - break; - } - else - if(i == 0) - return graph_iter->graph; - else - if(LIST_NEXT(graph_iter, list) == NULL) - LIST_INSERT_AFTER(graph_iter, graph_link, list); - } - - return graph; - } - - struct graphlist * - graphlist_new() - { - struct graphlist *graphlist; - - if((graphlist = (struct graphlist *) malloc(sizeof(struct graphlist))) != NULL) - LIST_INIT(graphlist); - - return graphlist; - } --- 42,44 ---- Index: list.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/list.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** list.h 17 May 2005 15:16:28 -0000 1.5 --- list.h 18 May 2005 01:46:55 -0000 1.6 *************** *** 33,37 **** { struct listlink *lh_first; ! (int) (*compare) (void *, void *); }; --- 33,37 ---- { struct listlink *lh_first; ! int (*compare) (void *, void *); }; *************** *** 41,45 **** struct list *); struct list *list_duplicate(struct list *); ! void *list_find(struct list_t *, void *); void list_free(struct list *); --- 41,45 ---- struct list *); struct list *list_duplicate(struct list *); ! void *list_find(struct list *, void *); void list_free(struct list *); *************** *** 48,52 **** struct list *list_merge(struct list *, struct list *); ! struct list *list_new((int) (*) (void *, void *)); void list_print(FILE *, struct list *); --- 48,52 ---- struct list *list_merge(struct list *, struct list *); ! struct list *list_new(int (*) (void *, void *)); void list_print(FILE *, struct list *); |
|
From: Jeff B. <jb...@us...> - 2005-05-17 15:16:37
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv5723 Modified Files: alias.c list.h Log Message: misc Index: alias.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/alias.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** alias.c 14 May 2005 02:56:24 -0000 1.7 --- alias.c 17 May 2005 15:16:28 -0000 1.8 *************** *** 63,73 **** struct alias * ! aliaslist_add(struct aliaslist *alias_list, struct alias *alias) { int i; ! struct aliaslink *alias_iter, *alias_link; ! alias_link = (struct aliaslink *) malloc(sizeof(struct aliaslink)); ! alias_link->alias = alias; if(LIST_EMPTY(alias_list)) --- 63,73 ---- struct alias * ! aliaslist_add(struct list *alias_list, struct alias *alias) { int i; ! struct listlink *alias_iter, *alias_link; ! alias_link = (struct listlink *) malloc(sizeof(struct listlink)); ! alias_link->object = alias; if(LIST_EMPTY(alias_list)) *************** *** 76,80 **** LIST_FOREACH(alias_iter, alias_list, list) { ! if((i = alias_compare(alias, alias_iter->alias)) < 0) { if(alias_iter == LIST_FIRST(alias_list)) --- 76,80 ---- LIST_FOREACH(alias_iter, alias_list, list) { ! if((i = alias_compare(alias, alias_iter->object)) < 0) { if(alias_iter == LIST_FIRST(alias_list)) *************** *** 86,90 **** else if(i == 0) ! return alias_iter->alias; else if(LIST_NEXT(alias_iter, list) == NULL) --- 86,90 ---- else if(i == 0) ! return alias_iter->object; else if(LIST_NEXT(alias_iter, list) == NULL) Index: list.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/list.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** list.h 17 May 2005 14:30:26 -0000 1.4 --- list.h 17 May 2005 15:16:28 -0000 1.5 *************** *** 27,60 **** }; ! LIST_HEAD(list, listlink); void *list_add(struct list *, ! void *, ! int (*)(void *, void *)); int list_compare(struct list *, struct list *); ! struct list *list_duplicate(struct list *, ! int (*)(void *, void *)); void *list_find(struct list_t *, ! void *, ! int (*)(void *, void *)); void list_free(struct list *); struct list *list_intersection(struct list *, struct list *); struct list *list_merge(struct list *, ! struct list *, ! int (*)(void *, void *)); ! struct list *list_new(void); void list_print(FILE *, struct list *); void list_remove(struct list *, ! void *, ! int (*)(void *, void *)); unsigned int list_size(struct list *); struct list *list_subtract(struct list *, struct list *); struct list *list_union(struct list *, ! struct list *, ! int (*)(void *, void *)); #endif --- 27,61 ---- }; ! /* This is LIST_HEAD(list, listlink); but with a function pointer embedded in ! * it for comparison of objects. ! */ ! struct list ! { ! struct listlink *lh_first; ! (int) (*compare) (void *, void *); ! }; void *list_add(struct list *, ! void *); int list_compare(struct list *, struct list *); ! struct list *list_duplicate(struct list *); void *list_find(struct list_t *, ! void *); void list_free(struct list *); struct list *list_intersection(struct list *, struct list *); struct list *list_merge(struct list *, ! struct list *); ! struct list *list_new((int) (*) (void *, void *)); void list_print(FILE *, struct list *); void list_remove(struct list *, ! void *); unsigned int list_size(struct list *); struct list *list_subtract(struct list *, struct list *); struct list *list_union(struct list *, ! struct list *); #endif |
|
From: Jeff B. <jb...@us...> - 2005-05-17 14:30:35
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28495 Modified Files: BSDmakefile alias.h graph.h list.c list.h node.h Log Message: Start using list for abstraction. Index: graph.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/graph.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** graph.h 18 Apr 2005 14:53:29 -0000 1.1 --- graph.h 17 May 2005 14:30:26 -0000 1.2 *************** *** 24,45 **** #include "node.h" - struct graphlink - { - void *graph; - LIST_ENTRY(graphlink) list; - }; - - LIST_HEAD(graphlist, graphlink); - struct graph { ! struct aliaslist *alias_list; ! struct nodelist *node_list; }; ! struct graph *graph_new(struct aliaslist *, struct nodelist *); ! struct graph *graphlist_add(struct graphlist *, struct graph *); ! struct graphlist *graphlist_new(); #endif /* _GRAPH_H_ */ --- 24,37 ---- #include "node.h" struct graph { ! struct list *alias_list; ! struct list *node_list; }; ! struct graph *graph_new(struct list *, struct list *); ! struct graph *graphlist_add(struct list *, struct graph *); ! struct list *graphlist_new(); #endif /* _GRAPH_H_ */ Index: alias.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/alias.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** alias.h 14 May 2005 02:56:24 -0000 1.5 --- alias.h 17 May 2005 14:30:26 -0000 1.6 *************** *** 23,34 **** #include "node.h" - struct aliaslink - { - void *alias; - LIST_ENTRY(aliaslink) list; - }; - - LIST_HEAD(aliaslist, aliaslink); - struct alias { --- 23,26 ---- *************** *** 38,50 **** }; ! int alias_compare(struct alias *, struct alias *); ! void alias_free(struct alias *); ! struct alias *alias_new(char *, char *, struct node *); ! struct alias *aliaslist_add(struct aliaslist *, struct alias *); ! struct aliaslist *aliaslist_duplicate(struct aliaslist *); ! struct alias *aliaslist_find(struct aliaslist *, char *); ! void aliaslist_free(struct aliaslist *); ! struct aliaslist *aliaslist_new(void); #endif /* _ALIAS_H_ */ --- 30,42 ---- }; ! int alias_compare(struct alias *, struct alias *); ! void alias_free(struct alias *); ! struct alias *alias_new(char *, char *, struct node *); ! struct alias *aliaslist_add(struct list *, struct alias *); ! struct list *aliaslist_duplicate(struct list *); ! struct alias *aliaslist_find(struct list *, char *); ! void aliaslist_free(struct list *); ! struct list *aliaslist_new(void); #endif /* _ALIAS_H_ */ Index: node.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/node.h,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** node.h 14 May 2005 02:56:24 -0000 1.8 --- node.h 17 May 2005 14:30:26 -0000 1.9 *************** *** 23,34 **** #include <stdio.h> - struct nodelink - { - void *node; - LIST_ENTRY(nodelink) list; - }; - - LIST_HEAD(nodelist, nodelink); - struct node { --- 23,26 ---- *************** *** 36,40 **** char *uiddir; float msd; ! struct nodelist *links; /* Other nodes that "sign" this node */ }; --- 28,32 ---- char *uiddir; float msd; ! struct list *links; /* Other nodes that "sign" this node */ }; *************** *** 46,63 **** void node_print(FILE *, struct node *); ! struct node *nodelist_add(struct nodelist *, struct node *); ! struct node *nodelist_add_msd(struct nodelist *, struct node *); ! int nodelist_compare(struct nodelist *, struct nodelist *); ! struct nodelist *nodelist_duplicate(struct nodelist *); ! struct node *nodelist_find(struct nodelist *, struct node *); ! void nodelist_free(struct nodelist *); ! struct nodelist *nodelist_intersection(struct nodelist *, struct nodelist *); ! struct nodelist *nodelist_merge(struct nodelist *, struct nodelist *); ! struct nodelist *nodelist_new(void); ! void nodelist_print(FILE *, struct nodelist *); ! struct node *nodelist_remove(struct nodelist *, struct node *); ! unsigned int nodelist_size(struct nodelist *); ! struct nodelist *nodelist_subtract(struct nodelist *, struct nodelist *); ! struct nodelist *nodelist_union(struct nodelist *, struct nodelist *); #endif /* _NODE_H_ */ --- 38,55 ---- void node_print(FILE *, struct node *); ! struct node *nodelist_add(struct list *, struct node *); ! struct node *nodelist_add_msd(struct list *, struct node *); ! int nodelist_compare(struct list *, struct list *); ! struct list *nodelist_duplicate(struct list *); ! struct node *nodelist_find(struct list *, struct node *); ! void nodelist_free(struct list *); ! struct list *nodelist_intersection(struct list *, struct list *); ! struct list *nodelist_merge(struct list *, struct list *); ! struct list *nodelist_new(void); ! void nodelist_print(FILE *, struct list *); ! struct node *nodelist_remove(struct list *, struct node *); ! unsigned int nodelist_size(struct list *); ! struct list *nodelist_subtract(struct list *, struct list *); ! struct list *nodelist_union(struct list *, struct list *); #endif /* _NODE_H_ */ Index: list.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/list.h,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** list.h 18 Apr 2005 14:53:29 -0000 1.3 --- list.h 17 May 2005 14:30:26 -0000 1.4 *************** *** 29,43 **** LIST_HEAD(list, listlink); ! void *list_add_object(struct list_t *, void *, int (*)(void *, void *)); ! struct list_t *list_duplicate(struct list_t *, int (*)(void *, void *)); ! void *list_find_object(struct list_t *, void *, int (*)(void *, void *)); ! void list_free(struct list_t *); ! struct list_t *list_merge_list(struct list_t *, struct list_t *, int (*)(void *, void *)); ! struct list_t *list_new(); ! struct node_t *list_new_node(void *); ! 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 *)); #endif --- 29,60 ---- LIST_HEAD(list, listlink); ! void *list_add(struct list *, ! void *, ! int (*)(void *, void *)); ! int list_compare(struct list *, ! struct list *); ! struct list *list_duplicate(struct list *, ! int (*)(void *, void *)); ! void *list_find(struct list_t *, ! void *, ! int (*)(void *, void *)); ! void list_free(struct list *); ! struct list *list_intersection(struct list *, ! struct list *); ! struct list *list_merge(struct list *, ! struct list *, ! int (*)(void *, void *)); ! struct list *list_new(void); ! void list_print(FILE *, ! struct list *); ! void list_remove(struct list *, ! void *, ! int (*)(void *, void *)); ! unsigned int list_size(struct list *); ! struct list *list_subtract(struct list *, ! struct list *); ! struct list *list_union(struct list *, ! struct list *, ! int (*)(void *, void *)); #endif Index: list.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/list.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** list.c 14 Apr 2005 03:24:28 -0000 1.2 --- list.c 17 May 2005 14:30:26 -0000 1.3 *************** *** 24,31 **** #include "list.h" ! /* Returns: ! * object that is in the list or NULL on error ! */ ! void *list_add_object(struct list_t *list, void *object, int (*compare)(void *, void *)) { int i; --- 24,29 ---- #include "list.h" ! void * ! list_add(struct list *list, void *object, int (*compare)(void *, void *)) { int i; Index: BSDmakefile =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/BSDmakefile,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** BSDmakefile 17 May 2005 00:12:45 -0000 1.4 --- BSDmakefile 17 May 2005 14:30:26 -0000 1.5 *************** *** 20,23 **** --- 20,24 ---- graph.c \ input.c \ + list.c \ main.c \ node.c \ |
|
From: Jeff B. <jb...@us...> - 2005-05-17 00:16:20
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31308 Modified Files: output.c Log Message: style Index: output.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/output.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** output.c 16 May 2005 23:59:03 -0000 1.3 --- output.c 17 May 2005 00:16:07 -0000 1.4 *************** *** 212,216 **** } ! void output_print_list(FILE *filep, struct graph *graph) { struct node *node; --- 212,217 ---- } ! void ! output_print_list(FILE *filep, struct graph *graph) { struct node *node; |
|
From: Jeff B. <jb...@us...> - 2005-05-17 00:14:22
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30999 Modified Files: main.h Log Message: cleanup Index: main.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.h,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** main.h 17 May 2005 00:08:06 -0000 1.6 --- main.h 17 May 2005 00:14:10 -0000 1.7 *************** *** 17,33 **** #ifndef _MAIN_H_ - #define _MAIN_H_ ! #include <stdio.h> ! ! #include "alias.h" ! #include "graph.h" ! #include "node.h" ! ! void analysis_nodes(struct graph *); ! struct graphlist *analysis_seperate_nodes(struct graph *); ! int do_analysis(struct graph *, char *); ! void usage(void); #endif --- 17,24 ---- #ifndef _MAIN_H_ #define _MAIN_H_ ! int main(int, char **); ! void usage(void); #endif |
|
From: Jeff B. <jb...@us...> - 2005-05-17 00:13:07
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30785 Modified Files: BSDmakefile main.c Added Files: analysis.c analysis.h Log Message: +analysis Index: BSDmakefile =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/BSDmakefile,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** BSDmakefile 17 May 2005 00:08:06 -0000 1.3 --- BSDmakefile 17 May 2005 00:12:45 -0000 1.4 *************** *** 17,20 **** --- 17,21 ---- PROG= digraphanalysis SRCS= alias.c \ + analysis.c \ graph.c \ input.c \ Index: main.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.c,v retrieving revision 1.12 retrieving revision 1.13 diff -C2 -d -r1.12 -r1.13 *** main.c 17 May 2005 00:08:06 -0000 1.12 --- main.c 17 May 2005 00:12:45 -0000 1.13 *************** *** 33,138 **** #include "node.h" - /* Analyze the keys and output the results. - * - * Return -1 on error - */ int ! do_analysis(struct graph *graph, char *outputdir) ! { ! struct graphlist *graph_list; ! ! graph_list = NULL; ! if(output_main_directory(outputdir) == (-1)) ! return (-1); ! analysis_nodes(graph); ! graph_list = analysis_seperate_nodes(graph); ! output_report(graph_list); ! return 0; ! } ! ! void ! analysis_nodes(struct graph *graph) ! { ! struct nodelink *node_link; ! ! LIST_FOREACH(node_link, graph->node_list, list) ! output_file(node_link->node, graph); ! ! return; ! } ! ! struct graphlist * ! analysis_seperate_nodes(struct graph *graph) ! { ! struct aliaslist *alias_list; ! struct graphlist *graph_list; ! struct nodelink *node_link1; ! struct nodelink *node_link2; ! struct nodelist *node_list; ! struct nodelist *node_list_msd1; ! struct nodelist *node_list_msd2; ! ! /* Duplicate the graphs alias and node lists so as to not modify the original copies. ! */ ! alias_list = aliaslist_duplicate(graph->alias_list); ! node_list = nodelist_duplicate(graph->node_list); ! ! /* 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. ! */ ! while(!LIST_EMPTY(node_list)) ! { ! /* Create two new node lists. ! */ ! if(((node_list_msd1 = nodelist_new()) == NULL) || ! ((node_list_msd2 = nodelist_new()) == NULL)) ! return NULL; ! ! /* Add the first node from the node list to our msd sorted node list. And remove it from the non msd sorted node list. ! */ ! nodelist_add_msd(node_list_msd1, LIST_FIRST(node_list)->node); ! nodelist_remove(node_list, LIST_FIRST(node_list)->node); ! ! /* Add nodes that link to nodes in list2 to list1 then clone list1 onto list2 and repeat until no updates occur. ! */ ! while(nodelist_size(node_list_msd1) != nodelist_size(node_list_msd2)) ! { ! /* Duplicate nodelist1 onto nodelist2. ! */ ! nodelist_free(node_list_msd2); ! if((node_list_msd2 = nodelist_duplicate(node_list_msd1)) == NULL) ! return NULL; ! /* Iterate through nodelist2 adding nodes to nodelist1. ! */ ! LIST_FOREACH(node_link1, node_list_msd2, list) ! LIST_FOREACH(node_link2, ((struct node *) node_link1->node)->links, list) ! if(node_distance(node_link2->node, node_link1->node)) ! { ! nodelist_add_msd(node_list_msd1, node_link2->node); ! nodelist_remove(node_list, node_link2->node); ! } ! } ! ! /* 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. ! */ ! nodelist_free(node_list_msd2); ! } ! /* Free the copy of the node_list. ! */ ! nodelist_free(node_list); ! ! return graph_list; ! } ! ! /* DONE ! */ ! int main(int argc, char **argv) { int c; --- 33,38 ---- #include "node.h" int ! main(int argc, char **argv) { int c; *************** *** 163,167 **** } ! void usage(void) { extern char *__progname; --- 63,68 ---- } ! void ! usage(void) { extern char *__progname; --- NEW FILE: analysis.c --- /* $Id: analysis.c,v 1.1 2005/05/17 00:12:45 jbreker Exp $ * * Copyright (C) 2005 Jeff Breker <jb...@sy...> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include "analysis.h" /* Analyze the keys and output the results. * * Return -1 on error */ int do_analysis(struct graph *graph, char *outputdir) { struct graphlist *graph_list; graph_list = NULL; if(output_main_directory(outputdir) == (-1)) return (-1); analysis_nodes(graph); graph_list = analysis_seperate_nodes(graph); output_report(graph_list); return 0; } void analysis_nodes(struct graph *graph) { struct nodelink *node_link; LIST_FOREACH(node_link, graph->node_list, list) output_file(node_link->node, graph); return; } struct graphlist * analysis_seperate_nodes(struct graph *graph) { struct aliaslist *alias_list; struct graphlist *graph_list; struct nodelink *node_link1; struct nodelink *node_link2; struct nodelist *node_list; struct nodelist *node_list_msd1; struct nodelist *node_list_msd2; /* Duplicate the graphs alias and node lists so as to not modify the original copies. */ alias_list = aliaslist_duplicate(graph->alias_list); node_list = nodelist_duplicate(graph->node_list); /* 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. */ while(!LIST_EMPTY(node_list)) { /* Create two new node lists. */ if(((node_list_msd1 = nodelist_new()) == NULL) || ((node_list_msd2 = nodelist_new()) == NULL)) return NULL; /* Add the first node from the node list to our msd sorted node list. And remove it from the non msd sorted node list. */ nodelist_add_msd(node_list_msd1, LIST_FIRST(node_list)->node); nodelist_remove(node_list, LIST_FIRST(node_list)->node); /* Add nodes that link to nodes in list2 to list1 then clone list1 onto list2 and repeat until no updates occur. */ while(nodelist_size(node_list_msd1) != nodelist_size(node_list_msd2)) { /* Duplicate nodelist1 onto nodelist2. */ nodelist_free(node_list_msd2); if((node_list_msd2 = nodelist_duplicate(node_list_msd1)) == NULL) return NULL; /* Iterate through nodelist2 adding nodes to nodelist1. */ LIST_FOREACH(node_link1, node_list_msd2, list) LIST_FOREACH(node_link2, ((struct node *) node_link1->node)->links, list) if(node_distance(node_link2->node, node_link1->node)) { nodelist_add_msd(node_list_msd1, node_link2->node); nodelist_remove(node_list, node_link2->node); } } /* 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. */ nodelist_free(node_list_msd2); } /* Free the copy of the node_list. */ nodelist_free(node_list); return graph_list; } --- NEW FILE: analysis.h --- /* $Id: analysis.h,v 1.1 2005/05/17 00:12:45 jbreker Exp $ * * Copyright (C) 2005 Jeff Breker <jb...@sy...> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef _ANALYSIS_H_ #define _ANALYSIS_H_ #include "graph.h" void analysis_nodes(struct graph *); struct graphlist *analysis_seperate_nodes(struct graph *); int do_analysis(struct graph *, char *); #endif |
|
From: Jeff B. <jb...@us...> - 2005-05-17 00:08:34
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29569 Modified Files: BSDmakefile main.c main.h Added Files: input.c input.h Log Message: +input.c input.h --- NEW FILE: input.h --- /* $Id: input.h,v 1.1 2005/05/17 00:08:06 jbreker Exp $ * * Copyright (C) 2005 Jeff Breker <jb...@sy...> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef _INPUT_H_ #define _INPUT_H_ #include "graph.h" char *get_field(void); void parse_input(struct graph *); #endif --- NEW FILE: input.c --- /* $Id: input.c,v 1.1 2005/05/17 00:08:06 jbreker Exp $ * * Copyright (C) 2005 Jeff Breker <jb...@sy...> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <stdio.h> #include <sysexits.h> #include "alias.h" #include "graph.h" #include "node.h" char * get_field(void) { char c; size_t size; char *string; size = 0; while(((c = getchar()) != ':') && (c != EOF)) { if(!isdigit(c)) errx(EX_DATAERR, "Invalid data input!\n"); size = size * 10; size = size + c - '0'; } if(c == EOF) errx(EX_DATAERR, "Unexpected termination of data input!\n"); string = (char *) malloc(++size); if(string != NULL) fgets(string, size, stdin); return string; } void parse_input(struct graph *graph) { struct alias *alias1; struct alias *alias2; char c; char *field1; char *field2; char *field3; struct node *node1; struct node *node2; struct node *node3; char type; for(c = type = getchar(); type == 'e' || type == 'n' || type == 'a'; c = type = getchar()) { if(((c = getchar()) != ':') && (c != EOF)) errx(EX_DATAERR, "1: Invalid character, %c (ASCII: %d), encountered!\n", c, c); if(c == EOF) break; if((field1 = get_field()) == NULL) errx(EX_OSERR, "Cannot allocate memory!\n"); if(*field1 == EOF) break; if(type != 'n') /* Grab 2nd field for edges and alias' */ { if(((c = getchar()) != ':') && (c != EOF)) errx(EX_DATAERR, "2: Invalid character, %c (ASCII: %d), encountered!\n", c, c); if(c == EOF) break; if((field2 = get_field()) == NULL) errx(EX_OSERR, "Cannot allocate memory!\n"); if(*field2 == EOF) break; if(type == 'a') /* Grab 3rd field for an alias */ { if(((c = getchar()) != ':') && (c != EOF)) errx(EX_DATAERR, "3: Invalid character, %c (ASCII: %d), encountered!\n", c, c); if(c == EOF) break; if((field3 = get_field()) == NULL) errx(EX_OSERR, "Cannot allocate memory!\n"); if(*field3 == EOF) break; } } if(((c = getchar()) != '\n') && (c != EOF)) errx(EX_DATAERR, "4: Invalid character, %c (ASCII: %d), encountered!\n", c, c); switch (type) { case 'a': node1 = node_new(field1); free(field1); if((node2 = nodelist_add(graph->node_list, node1)) != node1) node_free(node1); alias1 = alias_new(field2, field3, node2); free(field2); free(field3); if((alias2 = aliaslist_add(graph->alias_list, alias1)) != alias1) alias_free(alias1); break; case 'e': node1 = node_new(field1); free(field1); if((node2 = nodelist_add(graph->node_list, node1)) != node1) node_free(node1); node1 = node_new(field2); free(field2); if((node3 = nodelist_add(graph->node_list, node1)) != node1) node_free(node1); if((node1 = nodelist_add(node2->links, node3)) != node3) node_free(node3); break; /* a lines will eventually be renamed to n lines, when this happens * the following gets ripped out. */ case 'n': node1 = node_new(field1); free(field1); if((node2 = nodelist_add(graph->node_list, node1)) != node1) node_free(node1); break; } if(c == EOF) break; } if(c != EOF) errx(EX_DATAERR, "5: Invalid character, %c (ASCII: %d), encountered!\n", type, type); return; } Index: BSDmakefile =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/BSDmakefile,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** BSDmakefile 16 May 2005 23:59:03 -0000 1.2 --- BSDmakefile 17 May 2005 00:08:06 -0000 1.3 *************** *** 18,21 **** --- 18,22 ---- SRCS= alias.c \ graph.c \ + input.c \ main.c \ node.c \ Index: main.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.c,v retrieving revision 1.11 retrieving revision 1.12 diff -C2 -d -r1.11 -r1.12 *** main.c 16 May 2005 23:59:03 -0000 1.11 --- main.c 17 May 2005 00:08:06 -0000 1.12 *************** *** 132,162 **** } - char *get_field() - { - char c; - size_t size; - char *string; - - size = 0; - - while(((c = getchar()) != ':') && (c != EOF)) - { - if(!isdigit(c)) - errx(EX_DATAERR, "Invalid data input!\n"); - size = size * 10; - size = size + c - '0'; - } - - if(c == EOF) - errx(EX_DATAERR, "Unexpected termination of data input!\n"); - - string = (char *) malloc(++size); - - if(string != NULL) - fgets(string, size, stdin); - - return string; - } - /* DONE */ --- 132,135 ---- *************** *** 190,288 **** } - void parse_input(struct graph *graph) - { - struct alias *alias1; - struct alias *alias2; - char c; - char *field1; - char *field2; - char *field3; - struct node *node1; - struct node *node2; - struct node *node3; - char type; - - for(c = type = getchar(); type == 'e' || type == 'n' || type == 'a'; c = type = getchar()) - { - if(((c = getchar()) != ':') && (c != EOF)) - errx(EX_DATAERR, "1: Invalid character, %c (ASCII: %d), encountered!\n", c, c); - if(c == EOF) - break; - if((field1 = get_field()) == NULL) - errx(EX_OSERR, "Cannot allocate memory!\n"); - if(*field1 == EOF) - break; - if(type != 'n') /* Grab 2nd field for edges and alias' */ - { - if(((c = getchar()) != ':') && (c != EOF)) - errx(EX_DATAERR, "2: Invalid character, %c (ASCII: %d), encountered!\n", c, c); - if(c == EOF) - break; - if((field2 = get_field()) == NULL) - errx(EX_OSERR, "Cannot allocate memory!\n"); - if(*field2 == EOF) - break; - if(type == 'a') /* Grab 3rd field for an alias */ - { - if(((c = getchar()) != ':') && (c != EOF)) - errx(EX_DATAERR, "3: Invalid character, %c (ASCII: %d), encountered!\n", c, c); - if(c == EOF) - break; - if((field3 = get_field()) == NULL) - errx(EX_OSERR, "Cannot allocate memory!\n"); - if(*field3 == EOF) - break; - } - } - if(((c = getchar()) != '\n') && (c != EOF)) - errx(EX_DATAERR, "4: Invalid character, %c (ASCII: %d), encountered!\n", c, c); - - switch (type) - { - case 'a': - node1 = node_new(field1); - free(field1); - if((node2 = nodelist_add(graph->node_list, node1)) != node1) - node_free(node1); - alias1 = alias_new(field2, field3, node2); - free(field2); - free(field3); - if((alias2 = aliaslist_add(graph->alias_list, alias1)) != alias1) - alias_free(alias1); - break; - case 'e': - node1 = node_new(field1); - free(field1); - if((node2 = nodelist_add(graph->node_list, node1)) != node1) - node_free(node1); - node1 = node_new(field2); - free(field2); - if((node3 = nodelist_add(graph->node_list, node1)) != node1) - node_free(node1); - if((node1 = nodelist_add(node2->links, node3)) != node3) - node_free(node3); - break; - /* a lines will eventually be renamed to n lines, when this happens - * the following gets ripped out. - */ - case 'n': - node1 = node_new(field1); - free(field1); - if((node2 = nodelist_add(graph->node_list, node1)) != node1) - node_free(node1); - break; - } - - - if(c == EOF) - break; - } - - if(c != EOF) - errx(EX_DATAERR, "5: Invalid character, %c (ASCII: %d), encountered!\n", type, type); - - return; - } - void usage(void) { --- 163,166 ---- Index: main.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.h,v retrieving revision 1.5 retrieving revision 1.6 diff -C2 -d -r1.5 -r1.6 *** main.h 16 May 2005 23:59:03 -0000 1.5 --- main.h 17 May 2005 00:08:06 -0000 1.6 *************** *** 29,34 **** struct graphlist *analysis_seperate_nodes(struct graph *); int do_analysis(struct graph *, char *); - char *get_field(void); - void parse_input(struct graph *); void usage(void); --- 29,32 ---- |
|
From: Jeff B. <jb...@us...> - 2005-05-16 23:59:14
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28005 Modified Files: BSDmakefile main.c main.h output.c Added Files: output.h Log Message: +output.h --- NEW FILE: output.h --- /* $Id: output.h,v 1.1 2005/05/16 23:59:03 jbreker Exp $ * * Copyright (C) 2005 Jeff Breker <jb...@sy...> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #ifndef _OUTPUT_H_ #define _OUTPUT_H_ #include <stdio.h> #include "graph.h" int output_main_directory(char *); void output_report(struct graphlist *); int output_new_directory(char *); void output_file(struct node *, struct graph *); void output_print_list(FILE *, struct graph *); #endif Index: output.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/output.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** output.c 14 May 2005 19:34:29 -0000 1.2 --- output.c 16 May 2005 23:59:03 -0000 1.3 *************** *** 16,33 **** */ - #include <sys/stat.h> #include <sys/types.h> - #include <ctype.h> - #include <err.h> #include <libgen.h> - #include <stdio.h> - #include <stdlib.h> - #include <string.h> #include <sysexits.h> - #include <unistd.h> int ! analysis_main_directory(char *outputdir) { char *dir; --- 16,33 ---- */ #include <sys/types.h> + #include <sys/stat.h> #include <libgen.h> #include <sysexits.h> + #include "output.h" + + /* Note: analysis_main_directory -> output_main_directory + * + * Create and enter the main output directory. + */ int ! output_main_directory(char *outputdir) { char *dir; *************** *** 36,51 **** dir = NULL; rtn = 0; ! /* Create and enter the output directory */ if((dir = dirname(outputdir)) == NULL) ! errx(EX_OSERR, "Error on dirname"); if((chdir(dir) == -1) || ! (create_new_directory(outputdir) == -1) || (chdir(outputdir) == -1)) rtn = -1; return rtn; } void ! analysis_output_report(struct graphlist *graph_list) { struct alias *alias; --- 36,55 ---- dir = NULL; rtn = 0; ! if((dir = dirname(outputdir)) == NULL) ! errx(EX_OSERR, "Cannot obtain dirname of %s", outputdir); ! if((chdir(dir) == -1) || ! (output_new_directory(outputdir) == -1) || (chdir(outputdir) == -1)) rtn = -1; + return rtn; } + /* analysis_output_report -> output_report + */ void ! output_report(struct graphlist *graph_list) { struct alias *alias; *************** *** 122,126 **** int ! create_new_directory(char *dirname) { int rtn; --- 126,130 ---- int ! output_new_directory(char *dirname) { int rtn; *************** *** 150,154 **** unsigned int tmp_size; ! create_new_directory(node->uiddir); chdir(node->uiddir); --- 154,158 ---- unsigned int tmp_size; ! output_new_directory(node->uiddir); chdir(node->uiddir); *************** *** 208,212 **** } ! void print_list(FILE *filep, struct graph *graph) { struct node *node; --- 212,216 ---- } ! void output_print_list(FILE *filep, struct graph *graph) { struct node *node; Index: BSDmakefile =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/BSDmakefile,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** BSDmakefile 26 Apr 2005 03:49:27 -0000 1.1 --- BSDmakefile 16 May 2005 23:59:03 -0000 1.2 *************** *** 19,23 **** graph.c \ main.c \ ! node.c .include <bsd.prog.mk> --- 19,24 ---- graph.c \ main.c \ ! node.c \ ! output.c .include <bsd.prog.mk> Index: main.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** main.c 14 May 2005 19:34:29 -0000 1.10 --- main.c 16 May 2005 23:59:03 -0000 1.11 *************** *** 43,51 **** graph_list = NULL; ! if(analysis_main_directory(outputdir) == (-1)) return (-1); analysis_nodes(graph); graph_list = analysis_seperate_nodes(graph); ! analysis_output_report(graph_list); return 0; } --- 43,51 ---- graph_list = NULL; ! if(output_main_directory(outputdir) == (-1)) return (-1); analysis_nodes(graph); graph_list = analysis_seperate_nodes(graph); ! output_report(graph_list); return 0; } Index: main.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** main.h 27 Apr 2005 02:18:26 -0000 1.4 --- main.h 16 May 2005 23:59:03 -0000 1.5 *************** *** 26,40 **** #include "node.h" - int analysis_main_directory(char *); void analysis_nodes(struct graph *); - void analysis_output_report(struct graphlist *); struct graphlist *analysis_seperate_nodes(struct graph *); int do_analysis(struct graph *, char *); char *get_field(void); - void output_file(struct node *, struct graph *); void parse_input(struct graph *); - void print_graph(FILE *, struct nodelist *); void usage(void); - int wot_compare(void *, void *); #endif --- 26,35 ---- |
|
From: Jeff B. <jb...@us...> - 2005-05-14 19:34:38
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28728 Modified Files: main.c output.c Log Message: clean up Index: output.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/output.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** output.c 14 May 2005 19:29:57 -0000 1.1 --- output.c 14 May 2005 19:34:29 -0000 1.2 *************** *** 28,36 **** #include <unistd.h> - #include "alias.h" - #include "graph.h" - #include "main.h" - #include "node.h" - int analysis_main_directory(char *outputdir) --- 28,31 ---- Index: main.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.c,v retrieving revision 1.9 retrieving revision 1.10 diff -C2 -d -r1.9 -r1.10 *** main.c 14 May 2005 03:02:38 -0000 1.9 --- main.c 14 May 2005 19:34:29 -0000 1.10 *************** *** 62,160 **** } - int - analysis_main_directory(char *outputdir) - { - char *dir; - int rtn; - - dir = NULL; - rtn = 0; - /* Create and enter the output directory */ - if((dir = dirname(outputdir)) == NULL) - errx(EX_OSERR, "Error on dirname"); - if((chdir(dir) == -1) || - (create_new_directory(outputdir) == -1) || - (chdir(outputdir) == -1)) - rtn = -1; - /* afaik the call to dirname isn't mangling a copied string it's giving us the address in memory of the actual fs dir label. thus segfaulting (badly) when trying to free it. - free(dir); */ - return rtn; - } - - void - analysis_output_report(struct graphlist *graph_list) - { - struct alias *alias; - FILE *filep; - struct graph *graph; - struct graphlink *graph_link; - int i; - int j; - int k; - float last_msd; - struct node *node; - struct nodelink *node_link; - - i = k = 1; - last_msd = -1.0; - graph_link = NULL; - filep = fopen("report.html", "w"); - fprintf(filep, "<html><body>\n"); - while(!LIST_EMPTY(graph_list)) - { - 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); - } - fprintf(filep, "</table></div>\n"); - LIST_REMOVE(graph_link, list); - - j = k = 1; - last_msd = -1.0; - ++i; - } - - if(graph_link != NULL) - { - fprintf(filep, "<div class=\"wottable\"><div class=\"wottable_title\">Unconnected Keys</div>\n"); - fprintf(filep, "<table><tr><td>KeyID</td><td>Name</td></tr>\n"); - - 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):"")); - } - - graph_link = LIST_NEXT(graph_link, list); - } - fprintf(filep, "</table></div>\n"); - } - - fprintf(filep, "</body></html>\n"); - fclose(filep); - - return; - } - struct graphlist * analysis_seperate_nodes(struct graph *graph) --- 62,65 ---- *************** *** 227,251 **** } - int - create_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; - } - - /* DONE - */ char *get_field() { --- 132,135 ---- *************** *** 283,289 **** char *output_dir; - warnx("DEBUG:001"); graph = graph_new(aliaslist_new(), nodelist_new()); - warnx("DEBUG:002"); output_dir = NULL; --- 167,171 ---- *************** *** 298,302 **** exit(EXIT_FAILURE); } - warnx("DEBUG:003"); if(output_dir == NULL) { --- 180,183 ---- *************** *** 304,383 **** exit(EXIT_FAILURE); } - warnx("DEBUG:004"); parse_input(graph); - warnx("DEBUG:005"); do_analysis(graph, output_dir); - warnx("DEBUG:006"); return EXIT_SUCCESS; } - /* key == node - */ - void - output_file(struct node *node, struct graph *graph) - { - struct alias *alias; - struct nodelink *node_link; - struct nodelist *nodes_we_link_to; - struct nodelist *tmp_nodelist; - FILE *filep; - unsigned int tmp_size; - - create_new_directory(node->uiddir); - - chdir(node->uiddir); - - filep = fopen(node->uid, "a"); - - 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(".."); - - return; - } void parse_input(struct graph *graph) --- 185,192 ---- *************** *** 476,497 **** } - void print_list(FILE *filep, struct graph *graph) - { - struct node *node; - struct nodelink *node_link; - char *uid; - char *name; - - 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); - } - return; - - } - void usage(void) { --- 285,288 ---- |
|
From: Jeff B. <jb...@us...> - 2005-05-14 19:30:06
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv27958 Added Files: output.c Log Message: seperate functions that output data from main.c --- NEW FILE: output.c --- /* $Id: output.c,v 1.1 2005/05/14 19:29:57 jbreker Exp $ * * Copyright (C) 2005 Jeff Breker <jb...@sy...> * * Permission to use, copy, modify, and distribute this software for any * purpose with or without fee is hereby granted, provided that the above * copyright notice and this permission notice appear in all copies. * * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. */ #include <sys/stat.h> #include <sys/types.h> #include <ctype.h> #include <err.h> #include <libgen.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <sysexits.h> #include <unistd.h> #include "alias.h" #include "graph.h" #include "main.h" #include "node.h" int analysis_main_directory(char *outputdir) { char *dir; int rtn; dir = NULL; rtn = 0; /* Create and enter the output directory */ if((dir = dirname(outputdir)) == NULL) errx(EX_OSERR, "Error on dirname"); if((chdir(dir) == -1) || (create_new_directory(outputdir) == -1) || (chdir(outputdir) == -1)) rtn = -1; return rtn; } void analysis_output_report(struct graphlist *graph_list) { struct alias *alias; FILE *filep; struct graph *graph; struct graphlink *graph_link; int i; int j; int k; float last_msd; struct node *node; struct nodelink *node_link; i = k = 1; last_msd = -1.0; graph_link = NULL; filep = fopen("report.html", "w"); fprintf(filep, "<html><body>\n"); while(!LIST_EMPTY(graph_list)) { 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); } fprintf(filep, "</table></div>\n"); LIST_REMOVE(graph_link, list); j = k = 1; last_msd = -1.0; ++i; } if(graph_link != NULL) { fprintf(filep, "<div class=\"wottable\"><div class=\"wottable_title\">Unconnected Keys</div>\n"); fprintf(filep, "<table><tr><td>KeyID</td><td>Name</td></tr>\n"); 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):"")); } graph_link = LIST_NEXT(graph_link, list); } fprintf(filep, "</table></div>\n"); } fprintf(filep, "</body></html>\n"); fclose(filep); return; } int create_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 nodelink *node_link; struct nodelist *nodes_we_link_to; struct nodelist *tmp_nodelist; FILE *filep; unsigned int tmp_size; create_new_directory(node->uiddir); chdir(node->uiddir); filep = fopen(node->uid, "a"); 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(".."); return; } void print_list(FILE *filep, struct graph *graph) { struct node *node; struct nodelink *node_link; char *uid; char *name; 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); } return; } |
|
From: Jeff B. <jb...@us...> - 2005-05-14 03:02:46
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1969 Modified Files: main.c Log Message: remove debug Index: main.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.c,v retrieving revision 1.8 retrieving revision 1.9 diff -C2 -d -r1.8 -r1.9 *** main.c 14 May 2005 02:56:24 -0000 1.8 --- main.c 14 May 2005 03:02:38 -0000 1.9 *************** *** 33,59 **** #include "node.h" - int - create_new_directory(char *dirname) - { - int rtn; - struct stat *sb; - - rtn = 0; - sb = NULL; - warnx("DEBUG:015"); - /* 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; - warnx("DEBUG:016"); - free(sb); - warnx("DEBUG:017"); - return rtn; - } - - /* Analyze the keys and output the results. * --- 33,36 ---- *************** *** 66,79 **** graph_list = NULL; - warnx("DEBUG:007"); if(analysis_main_directory(outputdir) == (-1)) return (-1); - warnx("DEBUG:008"); analysis_nodes(graph); - warnx("DEBUG:009"); graph_list = analysis_seperate_nodes(graph); - warnx("DEBUG:010"); analysis_output_report(graph_list); - warnx("DEBUG:011"); return 0; } --- 43,51 ---- *************** *** 98,102 **** dir = NULL; rtn = 0; - warnx("DEBUG:012"); /* Create and enter the output directory */ if((dir = dirname(outputdir)) == NULL) --- 70,73 ---- *************** *** 106,113 **** (chdir(outputdir) == -1)) rtn = -1; ! warnx("DEBUG:013"); ! /* ? free(dir); */ - warnx("DEBUG:014"); return rtn; } --- 77,82 ---- (chdir(outputdir) == -1)) rtn = -1; ! /* afaik the call to dirname isn't mangling a copied string it's giving us the address in memory of the actual fs dir label. thus segfaulting (badly) when trying to free it. free(dir); */ return rtn; } *************** *** 132,144 **** filep = fopen("report.html", "w"); fprintf(filep, "<html><body>\n"); - warnx("OUTPUT:001"); while(!LIST_EMPTY(graph_list)) { - warnx("OUTPUT:002"); 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; - warnx("OUTPUT:006"); 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"); --- 101,110 ---- *************** *** 147,151 **** while(!LIST_EMPTY(graph->node_list)) { - warnx("OUTPUT:003"); node_link = LIST_FIRST(graph->node_list); node = (struct node *) node_link->node; --- 113,116 ---- *************** *** 168,172 **** if(graph_link != NULL) { - warnx("OUTPUT:004"); fprintf(filep, "<div class=\"wottable\"><div class=\"wottable_title\">Unconnected Keys</div>\n"); fprintf(filep, "<table><tr><td>KeyID</td><td>Name</td></tr>\n"); --- 133,136 ---- *************** *** 174,178 **** while(graph_link != NULL) { - warnx("OUTPUT:005"); graph = graph_link->graph; LIST_FOREACH(node_link, graph->node_list, list) --- 138,141 ---- *************** *** 264,267 **** --- 227,249 ---- } + int + create_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; + } + /* DONE */ |
|
From: Jeff B. <jb...@us...> - 2005-05-14 02:57:59
|
Update of /cvsroot/digraphanalysis/digraphanalysis/utils In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1268 Added Files: BSDmakefile Log Message: initial import --- NEW FILE: BSDmakefile --- # $Id: BSDmakefile,v 1.1 2005/05/14 02:57:50 jbreker Exp $ # # Copyright (C) 2005 Jeff Breker <jb...@sy...> # # Permission to use, copy, modify, and distribute this software for any # purpose with or without fee is hereby granted, provided that the above # copyright notice and this permission notice appear in all copies. # # THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES # WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF # MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR # ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES # WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN # ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF # OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. SUBDIR= gpg2digraph \ gpg2dot .include <bsd.subdir.mk> |
|
From: Jeff B. <jb...@us...> - 2005-05-14 02:56:33
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv1148/src Modified Files: alias.c alias.h main.c node.c node.h Log Message: changes Index: node.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/node.h,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** node.h 25 Apr 2005 04:53:14 -0000 1.7 --- node.h 14 May 2005 02:56:24 -0000 1.8 *************** *** 34,37 **** --- 34,38 ---- { char *uid; /* The primary uid identifier for the node */ + char *uiddir; float msd; struct nodelist *links; /* Other nodes that "sign" this node */ Index: alias.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/alias.h,v retrieving revision 1.4 retrieving revision 1.5 diff -C2 -d -r1.4 -r1.5 *** alias.h 21 Apr 2005 19:03:12 -0000 1.4 --- alias.h 14 May 2005 02:56:24 -0000 1.5 *************** *** 43,46 **** --- 43,47 ---- struct alias *aliaslist_add(struct aliaslist *, struct alias *); + struct aliaslist *aliaslist_duplicate(struct aliaslist *); struct alias *aliaslist_find(struct aliaslist *, char *); void aliaslist_free(struct aliaslist *); Index: alias.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/alias.c,v retrieving revision 1.6 retrieving revision 1.7 diff -C2 -d -r1.6 -r1.7 *** alias.c 21 Apr 2005 19:52:11 -0000 1.6 --- alias.c 14 May 2005 02:56:24 -0000 1.7 *************** *** 53,60 **** else { ! strncpy(alias->uid, uid, strlen(uid)); ! *(alias->uid + strlen(uid)) = '\0'; ! strncpy(alias->name, name, strlen(uid)); ! *(alias->name + strlen(name)) = '\0'; alias->node = node; } --- 53,58 ---- else { ! strlcpy(alias->uid, uid, strlen(uid) + 1); ! strlcpy(alias->name, name, strlen(name) + 1); alias->node = node; } *************** *** 97,100 **** --- 95,112 ---- } + struct aliaslist * + aliaslist_duplicate(struct aliaslist *alias_list1) + { + struct aliaslist *alias_list2; + struct aliaslink *alias_link; + + alias_list2 = aliaslist_new(); + + LIST_FOREACH(alias_link, alias_list1, list) + aliaslist_add(alias_list2, alias_link->alias); + + return alias_list2; + } + /* This should take a struct alias, not a char */ struct alias * Index: node.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/node.c,v retrieving revision 1.10 retrieving revision 1.11 diff -C2 -d -r1.10 -r1.11 *** node.c 25 Apr 2005 15:07:16 -0000 1.10 --- node.c 14 May 2005 02:56:24 -0000 1.11 *************** *** 40,44 **** --- 40,46 ---- len = strlen(uid) + 1; node->uid = (char *) malloc(len); + node->uiddir = (char *) malloc((len >= 3)?3:len); strlcpy(node->uid, uid, len); + strlcpy(node->uiddir, uid, (len >=3)?3:len); node->msd = 0; Index: main.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.c,v retrieving revision 1.7 retrieving revision 1.8 diff -C2 -d -r1.7 -r1.8 *** main.c 27 Apr 2005 02:18:26 -0000 1.7 --- main.c 14 May 2005 02:56:24 -0000 1.8 *************** *** 41,45 **** rtn = 0; sb = NULL; ! /* Allocate memory for sb */ if(((sb = (struct stat *) malloc(sizeof(struct stat))) == NULL) || --- 41,45 ---- rtn = 0; sb = NULL; ! warnx("DEBUG:015"); /* Allocate memory for sb */ if(((sb = (struct stat *) malloc(sizeof(struct stat))) == NULL) || *************** *** 49,55 **** (mkdir(dirname, sb->st_mode) == -1)) rtn = -1; ! free(sb); ! return rtn; } --- 49,55 ---- (mkdir(dirname, sb->st_mode) == -1)) rtn = -1; ! warnx("DEBUG:016"); free(sb); ! warnx("DEBUG:017"); return rtn; } *************** *** 65,77 **** struct graphlist *graph_list; if(analysis_main_directory(outputdir) == (-1)) return (-1); ! analysis_nodes(graph); ! graph_list = analysis_seperate_nodes(graph); ! analysis_output_report(graph_list); ! return 0; } --- 65,79 ---- struct graphlist *graph_list; + graph_list = NULL; + warnx("DEBUG:007"); if(analysis_main_directory(outputdir) == (-1)) return (-1); ! warnx("DEBUG:008"); analysis_nodes(graph); ! warnx("DEBUG:009"); graph_list = analysis_seperate_nodes(graph); ! warnx("DEBUG:010"); analysis_output_report(graph_list); ! warnx("DEBUG:011"); return 0; } *************** *** 96,109 **** dir = NULL; rtn = 0; ! /* Create and enter the output directory */ ! if(((dir = dirname(outputdir)) == NULL) || ! (chdir(dir) == -1) || (create_new_directory(outputdir) == -1) || (chdir(outputdir) == -1)) rtn = -1; ! ! free(dir); ! return rtn; } --- 98,113 ---- dir = NULL; rtn = 0; ! warnx("DEBUG:012"); /* Create and enter the output directory */ ! if((dir = dirname(outputdir)) == NULL) ! errx(EX_OSERR, "Error on dirname"); ! if((chdir(dir) == -1) || (create_new_directory(outputdir) == -1) || (chdir(outputdir) == -1)) rtn = -1; ! warnx("DEBUG:013"); ! /* ? ! free(dir); */ ! warnx("DEBUG:014"); return rtn; } *************** *** 113,117 **** { struct alias *alias; - char *dir; FILE *filep; struct graph *graph; --- 117,120 ---- *************** *** 124,136 **** struct nodelink *node_link; filep = fopen("report.html", "w"); fprintf(filep, "<html><body>\n"); ! while(!LIST_EMPTY(graph_list)) { 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"); --- 127,144 ---- struct nodelink *node_link; + i = k = 1; + last_msd = -1.0; + graph_link = NULL; filep = fopen("report.html", "w"); fprintf(filep, "<html><body>\n"); ! warnx("OUTPUT:001"); while(!LIST_EMPTY(graph_list)) { + warnx("OUTPUT:002"); 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; + warnx("OUTPUT:006"); 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"); *************** *** 139,142 **** --- 147,151 ---- while(!LIST_EMPTY(graph->node_list)) { + warnx("OUTPUT:003"); node_link = LIST_FIRST(graph->node_list); node = (struct node *) node_link->node; *************** *** 145,154 **** ++k; last_msd = node->msd; - dir = (char *) malloc(3); - strncpy(dir, node->uid, 2); - *(dir + 2) = '\0'; 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, dir, node->uid, node->uid, ((alias != NULL)?(alias->name):""), node->msd); ! free(dir); LIST_REMOVE(node_link, list); } --- 154,159 ---- ++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); } *************** *** 163,166 **** --- 168,172 ---- if(graph_link != NULL) { + warnx("OUTPUT:004"); fprintf(filep, "<div class=\"wottable\"><div class=\"wottable_title\">Unconnected Keys</div>\n"); fprintf(filep, "<table><tr><td>KeyID</td><td>Name</td></tr>\n"); *************** *** 168,180 **** while(graph_link != NULL) { graph = graph_link->graph; ! node_link = LIST_FIRST(graph->node_list); ! node = (struct node *) node_link->node; ! dir = (char *) malloc(3); ! strncpy(dir, node->uid, 2); ! *(dir + 2) = '\0'; ! alias = aliaslist_find(graph->alias_list, node->uid); ! fprintf(filep, "<tr><td><a href=\"%s/%s\">%s</a></td><td>%s</td></tr>\n", dir, node->uid, node->uid, ((alias != NULL)?(alias->name):"")); ! free(dir); graph_link = LIST_NEXT(graph_link, list); } --- 174,186 ---- while(graph_link != NULL) { + warnx("OUTPUT:005"); 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):"")); ! } ! graph_link = LIST_NEXT(graph_link, list); } *************** *** 199,218 **** struct nodelist *node_list_msd2; node_list = nodelist_duplicate(graph->node_list); graph_list = graphlist_new(); while(!LIST_EMPTY(node_list)) { if(((node_list_msd1 = nodelist_new()) == NULL) || ((node_list_msd2 = nodelist_new()) == NULL)) return NULL; nodelist_add_msd(node_list_msd1, LIST_FIRST(node_list)->node); ! LIST_REMOVE(LIST_FIRST(node_list), list); while(nodelist_size(node_list_msd1) != nodelist_size(node_list_msd2)) { nodelist_free(node_list_msd2); if((node_list_msd2 = nodelist_duplicate(node_list_msd1)) == NULL) return NULL; LIST_FOREACH(node_link1, node_list_msd2, list) LIST_FOREACH(node_link2, ((struct node *) node_link1->node)->links, list) --- 205,243 ---- struct nodelist *node_list_msd2; + /* Duplicate the graphs alias and node lists so as to not modify the original copies. + */ + alias_list = aliaslist_duplicate(graph->alias_list); node_list = nodelist_duplicate(graph->node_list); + + /* 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. + */ while(!LIST_EMPTY(node_list)) { + /* Create two new node lists. + */ if(((node_list_msd1 = nodelist_new()) == NULL) || ((node_list_msd2 = nodelist_new()) == NULL)) return NULL; + /* Add the first node from the node list to our msd sorted node list. And remove it from the non msd sorted node list. + */ nodelist_add_msd(node_list_msd1, LIST_FIRST(node_list)->node); ! nodelist_remove(node_list, LIST_FIRST(node_list)->node); ! ! /* Add nodes that link to nodes in list2 to list1 then clone list1 onto list2 and repeat until no updates occur. ! */ while(nodelist_size(node_list_msd1) != nodelist_size(node_list_msd2)) { + /* Duplicate nodelist1 onto nodelist2. + */ nodelist_free(node_list_msd2); if((node_list_msd2 = nodelist_duplicate(node_list_msd1)) == NULL) return NULL; + /* Iterate through nodelist2 adding nodes to nodelist1. + */ LIST_FOREACH(node_link1, node_list_msd2, list) LIST_FOREACH(node_link2, ((struct node *) node_link1->node)->links, list) *************** *** 223,229 **** --- 248,262 ---- } } + + /* 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. + */ nodelist_free(node_list_msd2); } + /* Free the copy of the node_list. + */ nodelist_free(node_list); *************** *** 268,272 **** --- 301,307 ---- char *output_dir; + warnx("DEBUG:001"); graph = graph_new(aliaslist_new(), nodelist_new()); + warnx("DEBUG:002"); output_dir = NULL; *************** *** 281,285 **** exit(EXIT_FAILURE); } ! if(output_dir == NULL) { --- 316,320 ---- exit(EXIT_FAILURE); } ! warnx("DEBUG:003"); if(output_dir == NULL) { *************** *** 287,294 **** exit(EXIT_FAILURE); } ! parse_input(graph); do_analysis(graph, output_dir); ! return EXIT_SUCCESS; } --- 322,330 ---- exit(EXIT_FAILURE); } ! warnx("DEBUG:004"); parse_input(graph); + warnx("DEBUG:005"); do_analysis(graph, output_dir); ! warnx("DEBUG:006"); return EXIT_SUCCESS; } *************** *** 298,320 **** output_file(struct node *node, struct graph *graph) { struct nodelink *node_link; struct nodelist *nodes_we_link_to; struct nodelist *tmp_nodelist; - char *file_dir; FILE *filep; unsigned int tmp_size; ! file_dir = (char *) malloc(3); ! strncpy(file_dir, node->uid, 2); ! *(file_dir + 2) = '\0'; ! ! create_new_directory(file_dir); ! chdir(file_dir); ! free(file_dir); filep = fopen(node->uid, "a"); ! fprintf(filep, "Keyid: %s\n\n", node->uid); fprintf(filep, "Signatures to this key:\n"); --- 334,354 ---- output_file(struct node *node, struct graph *graph) { + struct alias *alias; struct nodelink *node_link; struct nodelist *nodes_we_link_to; struct nodelist *tmp_nodelist; FILE *filep; unsigned int tmp_size; ! create_new_directory(node->uiddir); ! chdir(node->uiddir); filep = fopen(node->uid, "a"); ! 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"); *************** *** 365,370 **** } - /* DONE - */ void parse_input(struct graph *graph) { --- 399,402 ---- *************** *** 466,471 **** struct node *node; struct nodelink *node_link; ! ! char *uid, *name; LIST_FOREACH(node_link, graph->node_list, list) --- 498,503 ---- struct node *node; struct nodelink *node_link; ! char *uid; ! char *name; LIST_FOREACH(node_link, graph->node_list, list) |