[digraphanalysis-cvs] digraphanalysis/src/digraph_analyze main.c,
Status: Planning
Brought to you by:
jbreker
|
From: Jeff B. <jb...@us...> - 2005-09-19 22:04:00
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src/digraph_analyze In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3325 Modified Files: main.c Log Message: remove option to resume, implement in the future Index: main.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/digraph_analyze/main.c,v retrieving revision 1.3 retrieving revision 1.4 diff -C2 -d -r1.3 -r1.4 *** main.c 18 Sep 2005 13:40:51 -0000 1.3 --- main.c 19 Sep 2005 22:03:51 -0000 1.4 *************** *** 24,30 **** struct graph *analyze_msd(struct graph *); struct list *analyze_subgraphs(struct graph *); - void dump_partial_analysis(struct graph *, struct graph *, struct list *); struct graph *read_input(FILE *); - int resume_analysis(char **, char **, struct graph **, struct graph **, struct list **); void usage(void); int write_output(FILE *, struct graph *, struct list *); --- 24,28 ---- *************** *** 112,116 **** char *inputfile = NULL; char *outputfile = NULL; - char *resumefile = NULL; int rtncode = EX_OK; struct list *subgraphs = NULL; --- 110,113 ---- *************** *** 118,122 **** /* Parse arguments */ ! while((c = getopt(argc, argv, "i:o:r:")) != -1) switch (c) { --- 115,119 ---- /* Parse arguments */ ! while((c = getopt(argc, argv, "i:o:")) != -1) switch (c) { *************** *** 127,133 **** outputfile = optarg; break; - case 'r': - resumefile = optarg; - break; default: usage(); --- 124,127 ---- *************** *** 135,143 **** } - /* Load the resume file if given - */ - if(resumefile != NULL) - resume_analysis(&inputfile, &outputfile, &graph_raw, &graph_msd, &subgraphs); - /* Open the input file or stdin if no file given */ --- 129,132 ---- *************** *** 199,207 **** } void usage(void) { extern char *__progname; ! fprintf(stderr, "usage: %s [[-i <inputfile>] [-o <outputfile]] || [-r <resumefile>]\n", __progname); return; --- 188,236 ---- } + struct graph *read_input(FILE *filein) + { + struct graph *graph = NULL; + + graph = graph_new(list_new(alias_compare, alias_print), list_new(node_compare, node_print)); + + while((line = read_line(filein)) != NULL) + { + type = get_field(&line); + node1 = node_new(get_field(&line)); + if((node_tmp = graph_add_node(graph, node1)) != node1) + { + node_free(node1); + node1 = node_tmp; + } + if(strcmp(type, "n") == 0) + { + alias1 = alias_new(get_field(&line), get_field(&line), node1); + if((alias_tmp = graph_add_alias(graph, alias)) != alias1) + alias_free(alias1); + } + else + if(strcmp(type. "e") == 0) + { + node2 = node_new(get_field(&line)); + if((node_tmp = graph_add_node(graph, node2)) != node2) + { + node_free(node2); + node2 = node_tmp; + } + node_add_link(node1, node2); + } + else + err(ER_DATAERR, "type(%s) is not valid!\n", type); + } + /* *line should == '\0' by now (ie at the very end of what got returned by read_line */ + + return graph; + } + void usage(void) { extern char *__progname; ! fprintf(stderr, "usage: %s [-i <inputfile>] [-o <outputfile]\n", __progname); return; |