digraphanalysis-cvs Mailing List for The Digraph Analysis Project (Page 5)
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-04-14 03:24:50
|
Update of /cvsroot/digraphanalysis/digraphanalysis/utils/gpg2digraph In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24866/digraphanalysis/utils/gpg2digraph Modified Files: gpg2digraph.c Log Message: merging branch:JBREKER into MAIN Index: gpg2digraph.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/utils/gpg2digraph/gpg2digraph.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** gpg2digraph.c 16 Mar 2005 22:00:34 -0000 1.1 --- gpg2digraph.c 14 Apr 2005 03:24:28 -0000 1.2 *************** *** 25,30 **** --- 25,32 ---- char *do_pub(void); void do_sig(char *); + char *do_uid(void); unsigned int encode(char *); void func001(unsigned int); + char *get_fingerprint(); char *get_keyid(); char *get_name(); *************** *** 98,101 **** --- 100,148 ---- } + /* Handle a uid line. + */ + char * + do_uid() + { + char c, *keyid, *name; + + func001(7); + keyid = get_fingerprint() + 24; + func001(2); + name = get_name(); + fprintf(stdout, "n:%u:%s:%u:%s\n", strlen(keyid), keyid, strlen(name), name); + while (((c = fgetc(stdin)) != '\n') && (feof(stdin) == 0)) + if (ferror(stdin)) + exit(EX_IOERR); + free(name); + + return keyid; + } + + /* 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. */ *************** *** 191,194 **** --- 238,244 ---- do_sig(keyid_p); break; + case (117105100): /* uid */ + keyid_p = do_uid(); + break; default: break_while = 1; *************** *** 202,205 **** --- 252,283 ---- } break; + case (117105100): /* uid */ + keyid_p = do_uid(); + 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(); + break; + default: + break_while = 1; + break; + } + if(break_while) + { + break_while = 0; + break; + } + } default: break; |
|
From: Jeff B. <jb...@us...> - 2005-04-14 03:24:50
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv24866/digraphanalysis/src Modified Files: list.c list.h main.c main.h Added Files: node.c node.h Removed Files: keydata.c keydata.h pgpkey.c pgpkey.h Log Message: merging branch:JBREKER into MAIN --- NEW FILE: node.h --- /* $Id: node.h,v 1.2 2005/04/14 03:24:28 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 _NODE_H_ #define _NODE_H_ #include "list.h" struct pgpkey_s { char *keyid; float msd; char *name; struct list_t *signatures; }; typedef struct pgpkey_s pgpkey_t; int pgpkey_compare(void *, void *); int pgpkey_compare_msd(void *, void *); unsigned int pgpkey_distance(pgpkey_t *, pgpkey_t *); void pgpkey_msd(pgpkey_t *, struct list_t *); pgpkey_t *pgpkey_new(char *, char *); #endif /* _NODE_H_ */ --- keydata.c DELETED --- --- pgpkey.c DELETED --- Index: main.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** main.h 18 Mar 2005 20:42:22 -0000 1.1 --- main.h 14 Apr 2005 03:24:28 -0000 1.2 *************** *** 23,33 **** #include "list.h" ! #include "pgpkey.h" ! int analyze_key(pgpkey_t *, list_t *, list_t *, list_t *, list_t *, list_t *); ! int do_analysis(list_t *, char *); ! void output_file(pgpkey_t *, list_t *, list_t *, list_t *, list_t *); ! list_t *parse_keyring(char *); ! void print_list(FILE *, list_t *); void usage(void); int wot_compare(void *, void *); --- 23,33 ---- #include "list.h" ! #include "node.h" ! int analyze_key(pgpkey_t *, struct list_t *, struct list_t *, struct list_t *, struct list_t *, struct list_t *); ! int do_analysis(struct list_t *, char *); ! void output_file(pgpkey_t *, struct list_t *, struct list_t *, struct list_t *, struct list_t *); ! struct list_t *parse_keyring(void); ! void print_list(FILE *, struct list_t *); void usage(void); int wot_compare(void *, void *); --- pgpkey.h DELETED --- Index: list.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/list.h,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** list.h 18 Mar 2005 20:42:22 -0000 1.1 --- list.h 14 Apr 2005 03:24:28 -0000 1.2 *************** *** 17,49 **** #ifndef _LIST_H_ - #define _LIST_H_ ! struct node_s ! { ! void *object; ! struct node_s *next, *prev; ! }; ! struct list_s { ! int (*compare) (void *, void *); ! unsigned int size; ! struct node_s *head, *tail; }; ! typedef struct list_s list_t; ! typedef struct node_s node_t; ! int list_add_object(list_t *, void *); ! list_t *list_duplicate(list_t *); ! void *list_find_object(list_t *, void *); ! void list_free(list_t *); ! list_t *list_merge_list(list_t *, list_t *); ! list_t *list_new(int (*) (void *, void *)); ! node_t *list_new_node(void *, node_t *, node_t *); ! void list_remove(list_t *, void *); ! list_t *list_resort(list_t *); ! list_t *list_union(list_t *, list_t *); #endif --- 17,43 ---- #ifndef _LIST_H_ #define _LIST_H_ ! #include <sys/queue.h> ! struct node_t { ! void *object; ! LIST_ENTRY(node_t) entries; }; ! LIST_HEAD(list_t, node_t); ! 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 --- keydata.h DELETED --- Index: list.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/list.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** list.c 18 Mar 2005 20:42:22 -0000 1.1 --- list.c 14 Apr 2005 03:24:28 -0000 1.2 *************** *** 16,19 **** --- 16,21 ---- */ + #include <sys/queue.h> + #include <errno.h> #include <stdio.h> *************** *** 23,97 **** /* Returns: ! * -1 on error ! * 0 if object was not added (ie a compare() call returned 0 with one of the already present objects) ! * 1 if the object was added ! * ! * This might be more usefull if we returned the object that is in the list or NULL on error */ ! int list_add_object(list_t *list, void *object) { int i; ! node_t *iter; ! ! iter = list->head; ! ! if(iter == NULL) ! { ! if((list->head = list->tail = list_new_node(object, NULL, NULL)) == NULL) ! return -1; ! ++(list->size); ! return 1; ! } ! while(iter->next != NULL) ! { ! if((i = list->compare(object, iter->object)) < 0) { ! if((iter = list_new_node(object, iter, iter->prev)) == NULL) ! return -1; ! if(iter->prev == NULL) ! list->head = iter; else ! iter->prev->next = iter; ! iter->next->prev = iter; ! ++(list->size); ! return 1; } - else - if(i == 0) - return 0; - iter = iter->next; - } - if((i = list->compare(object, iter->object)) < 0) - { - if((iter = list_new_node(object, iter, iter->prev)) == NULL) - return -1; - if(iter->prev == NULL) - list->head = iter; - else - iter->prev->next = iter; - iter->next->prev = iter; - ++(list->size); - return 1; - } - else - if(i == 0) - return 0; - if((iter->next = list->tail = list_new_node(object, NULL, iter)) == NULL) - return -1; - ++(list->size); ! return 1; } /* Returns NULL on error */ ! list_t *list_duplicate(list_t *list) { ! list_t *ret_list; ! if((ret_list = list_new(list->compare)) == NULL) return NULL; ! if(list_merge_list(ret_list, list) == NULL) return NULL; --- 25,71 ---- /* 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; ! 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; ! } else ! if(i == 0) ! return iter->object; ! else ! if(LIST_NEXT(iter, entries) == NULL) ! LIST_INSERT_AFTER(iter, tmpnode, entries); } ! return object; } /* 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; *************** *** 99,139 **** } ! void list_free(list_t *list) { ! node_t *iter; ! iter = list->head; while(iter != NULL) { ! list->head = iter->next; ! free(iter); ! iter = list->head; } ! free(list); ! list = NULL; ! ! return; } ! void *list_find_object(list_t *list, void *object) { ! int i; ! node_t *iter; ! iter = list->head; while(iter != NULL) { ! if((i = list->compare(iter->object, object)) == 0) ! return iter->object; ! else ! if(i > 0) ! break; ! iter = iter->next; } ! return NULL; } --- 73,113 ---- } ! 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); } ! free(list); ! list = NULL; ! ! return; } *************** *** 142,157 **** * list1 on success */ ! list_t *list_merge_list(list_t *list1, list_t *list2) { ! node_t *iter; ! ! iter = list2->head; ! while(iter != NULL) ! { ! if(list_add_object(list1, iter->object) == -1) ! return NULL; ! iter = iter->next; ! } return list1; --- 116,125 ---- * 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; *************** *** 160,173 **** /* Returns NULL on error */ ! list_t *list_new(int (*compare) (void *, void *)) { ! list_t *list; ! if((list = (list_t *) malloc(sizeof(list_t))) == NULL) return NULL; ! list->compare = compare; ! list->size = 0; ! list->head = list->tail = NULL; return list; --- 128,139 ---- /* 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; *************** *** 176,213 **** /* Returns NULL on error */ ! node_t *list_new_node(void *object, node_t *next, node_t *prev) { ! node_t *node; ! if((node = (node_t *) malloc(sizeof(node_t))) == NULL) return NULL; node->object = object; - node->next = next; - node->prev = prev; return node; } ! void list_remove(list_t *list, void *object) { ! node_t *iter; int i; ! iter = list->head; while(iter != NULL) { ! if((i = list->compare(iter->object, object)) == 0) { ! --(list->size); ! if(iter->next != NULL) ! iter->next->prev = iter->prev; ! else ! list->tail = iter->prev; ! if(iter->prev != NULL) ! iter->prev->next = iter->next; else ! list->head = iter->next; free(iter); break; --- 142,172 ---- /* 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; node->object = object; return node; } ! 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; *************** *** 216,220 **** if(i < 0) break; ! iter = iter->next; } --- 175,179 ---- if(i < 0) break; ! iter = LIST_NEXT(iter, entries); } *************** *** 223,240 **** /* Optimize with quicksort or heapsort I think */ ! list_t *list_resort(list_t *list) { ! node_t *iter, *tmpiter; ! iter = list->head; ! list->head = list->tail = NULL; ! list->size = 0; while(iter != NULL) { ! if(list_add_object(list, iter->object) == -1) ! return NULL; tmpiter = iter; ! iter = iter->next; free(tmpiter); } --- 182,197 ---- /* 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); } *************** *** 243,259 **** } /* Return * NULL on error * list on success */ ! list_t *list_union(list_t *list1, list_t *list2) { ! list_t *list; ! if((list = list_new(list1->compare)) == NULL) return NULL; ! if(list_merge_list(list, list1) == NULL) ! return NULL; ! return list_merge_list(list, list2); } --- 200,226 ---- } + 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; } Index: main.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.c,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** main.c 19 Mar 2005 03:29:05 -0000 1.2 --- main.c 14 Apr 2005 03:24:28 -0000 1.3 *************** *** 20,78 **** #include <ctype.h> #include <libgen.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> - #include "keydata.h" #include "list.h" #include "main.h" ! #include "pgpkey.h" ! int analyze_key(pgpkey_t *key, list_t *keys, list_t *nnlist, list_t *nslist, list_t *snlist, list_t *sslist) { ! node_t *iter; ! iter = keys->head; pgpkey_msd(key, keys); while(iter != NULL) { ! if(list_find_object(key->signatures, iter->object) != NULL) ! { ! if(list_find_object(((pgpkey_t *) iter->object)->signatures, key) != NULL) ! { ! if(list_add_object(sslist, iter->object) == -1) ! { ! return -1; ! } ! } else ! { ! if(list_add_object(nslist, iter->object) == -1) ! { ! return -1; ! } ! } ! } else ! { ! if(list_find_object(((pgpkey_t *) iter->object)->signatures, key) != NULL) ! { ! if(list_add_object(snlist, iter->object) == -1) ! { ! return -1; ! } ! } else ! { ! if(list_add_object(nnlist, iter->object) == -1) ! { ! return -1; ! } ! } ! } ! iter = iter->next; } --- 20,55 ---- #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 "list.h" #include "main.h" ! #include "node.h" ! int analyze_key(pgpkey_t *key, struct list_t *keys, struct list_t *nnlist, struct list_t *nslist, struct list_t *snlist, struct list_t *sslist) { ! struct node_t *iter; ! iter = LIST_FIRST(keys); pgpkey_msd(key, keys); while(iter != NULL) { ! if(list_find_object(key->signatures, iter->object, pgpkey_compare) != NULL) ! if(list_find_object(((pgpkey_t *) iter->object)->signatures, key, pgpkey_compare) != NULL) ! list_add_object(sslist, iter->object, pgpkey_compare); else ! list_add_object(nslist, iter->object, pgpkey_compare); else ! if(list_find_object(((pgpkey_t *) iter->object)->signatures, key, pgpkey_compare) != NULL) ! list_add_object(snlist, iter->object, pgpkey_compare); else ! list_add_object(nnlist, iter->object, pgpkey_compare); ! iter = LIST_NEXT(iter, entries); } *************** *** 84,88 **** * Return -1 on error */ ! int do_analysis(list_t *keys1, char *outputdir) { char *dir; --- 61,65 ---- * Return -1 on error */ ! int do_analysis(struct list_t *keys1, char *outputdir) { char *dir; *************** *** 90,95 **** float last_msd; int i, j, k; ! list_t *keys2, *tmplist1, *tmplist2, *wots, *nnlist, *nslist, *snlist, *sslist; ! node_t *iter1, *iter2; pgpkey_t *key; struct stat *sb; --- 67,72 ---- float last_msd; int i, j, k; ! struct list_t *keys2, *tmplist1, *tmplist2, *wots, *nnlist, *nslist, *snlist, *sslist; ! struct node_t *iter1, *iter2; pgpkey_t *key; struct stat *sb; *************** *** 110,120 **** /* Iterate through the list of keys, analyzing the key and outputting its file */ ! iter1 = keys1->head; ! while(iter1 != NULL) { ! nnlist = list_new(&pgpkey_compare); ! nslist = list_new(&pgpkey_compare); ! snlist = list_new(&pgpkey_compare); ! sslist = list_new(&pgpkey_compare); analyze_key(iter1->object, keys1, nnlist, nslist, snlist, sslist); output_file(iter1->object, nnlist, nslist, snlist, sslist); --- 87,96 ---- /* Iterate through the list of keys, analyzing the key and outputting its file */ ! LIST_FOREACH(iter1, keys1, entries) { ! nnlist = list_new(); ! nslist = list_new(); ! snlist = list_new(); ! sslist = list_new(); analyze_key(iter1->object, keys1, nnlist, nslist, snlist, sslist); output_file(iter1->object, nnlist, nslist, snlist, sslist); *************** *** 123,164 **** list_free(snlist); list_free(sslist); - iter1 = iter1->next; } iter1 = NULL; /* Pull apart the list of keys and seperate them into lists where all the keys can reach one another */ ! keys2 = list_duplicate(keys1); ! wots = list_new(&wot_compare); ! while(keys2->head != NULL) { ! if(((tmplist1 = list_new(&pgpkey_compare_msd)) == NULL) || ! ((tmplist2 = list_new(&pgpkey_compare_msd)) == NULL) || ! (list_add_object(tmplist1, keys2->head->object) == -1)) return -1; ! list_remove(keys2, keys2->head->object); ! while(tmplist1->size != tmplist2->size) { list_free(tmplist2); ! if((tmplist2 = list_duplicate(tmplist1)) == NULL) return -1; ! iter1 = tmplist2->head; while(iter1 != NULL) { ! iter2 = ((pgpkey_t *) iter1->object)->signatures->head; while(iter2 != NULL) { if(pgpkey_distance(iter2->object, iter1->object) != 0) { ! if(list_add_object(tmplist1, iter2->object) == -1) ! return -1; ! list_remove(keys2, iter2->object); } ! iter2 = iter2->next; } ! iter1 = iter1->next; } } ! if(list_add_object(wots, tmplist1) == -1) ! return -1; list_free(tmplist2); tmplist2 = NULL; --- 99,137 ---- list_free(snlist); list_free(sslist); } iter1 = NULL; /* Pull apart the list of keys and seperate them into lists where all the keys can reach one another */ ! keys2 = list_duplicate(keys1, &pgpkey_compare); ! wots = list_new(); ! while(!LIST_EMPTY(keys2)) { ! if(((tmplist1 = list_new()) == NULL) || ! ((tmplist2 = list_new()) == NULL)) return -1; ! list_add_object(tmplist1, LIST_FIRST(keys2)->object, &pgpkey_compare_msd); ! list_remove(keys2, LIST_FIRST(keys2)->object, &pgpkey_compare); ! while(list_size(tmplist1) != list_size(tmplist2)) { list_free(tmplist2); ! if((tmplist2 = list_duplicate(tmplist1, &pgpkey_compare_msd)) == NULL) return -1; ! iter1 = LIST_FIRST(tmplist2); while(iter1 != NULL) { ! iter2 = LIST_FIRST(((pgpkey_t *) iter1->object)->signatures); while(iter2 != NULL) { if(pgpkey_distance(iter2->object, iter1->object) != 0) { ! list_add_object(tmplist1, iter2->object, &pgpkey_compare_msd); ! list_remove(keys2, iter2->object, &pgpkey_compare); } ! iter2 = LIST_NEXT(iter2, entries); } ! iter1 = LIST_NEXT(iter1, entries); } } ! list_add_object(wots, tmplist1, &wot_compare); list_free(tmplist2); tmplist2 = NULL; *************** *** 173,189 **** filep = fopen("report.html", "w"); fprintf(filep, "<html><body>\n"); ! while(wots->head != NULL) { ! iter1 = wots->head; /* If the size of this web of trust is 1 then the remaining are of size 1, so group them all together */ ! if(((list_t *) iter1->object)->size == 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"); ! tmplist1 = (list_t *) iter1->object; ! while(tmplist1->head != NULL) { ! iter2 = tmplist1->head; key = (pgpkey_t *) iter2->object; if(key->msd != last_msd) --- 146,162 ---- filep = fopen("report.html", "w"); fprintf(filep, "<html><body>\n"); ! while(LIST_FIRST(wots) != NULL) { ! iter1 = LIST_FIRST(wots); /* 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 list_t *) iter1->object)) == 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"); ! tmplist1 = (struct list_t *) iter1->object; ! while(LIST_FIRST(tmplist1) != NULL) { ! iter2 = LIST_FIRST(tmplist1); key = (pgpkey_t *) iter2->object; if(key->msd != last_msd) *************** *** 197,206 **** free(dir); dir = NULL; ! list_remove(tmplist1, key); key = NULL; } fprintf(filep, "</table></div>\n"); tmplist1 = iter1->object; ! list_remove(wots, tmplist1); list_free(tmplist1); tmplist1 = NULL; --- 170,179 ---- free(dir); dir = NULL; ! list_remove(tmplist1, key, &pgpkey_compare_msd); key = NULL; } fprintf(filep, "</table></div>\n"); tmplist1 = iter1->object; ! list_remove(wots, tmplist1, &wot_compare); list_free(tmplist1); tmplist1 = NULL; *************** *** 218,222 **** while(iter1 != NULL) { ! iter2 = ((list_t *) iter1->object)->head; key = (pgpkey_t *) iter2->object; dir = (char *) malloc(3); --- 191,195 ---- while(iter1 != NULL) { ! iter2 = LIST_FIRST(((struct list_t *) iter1->object)); key = (pgpkey_t *) iter2->object; dir = (char *) malloc(3); *************** *** 225,229 **** fprintf(filep, "<tr><td><a href=\"%s/%s\">%s</a></td><td>%s</td></tr>\n", dir, key->keyid + 8, key->keyid + 8, key->name); free(dir); ! iter1 = iter1->next; } fprintf(filep, "</table></div>\n"); --- 198,202 ---- fprintf(filep, "<tr><td><a href=\"%s/%s\">%s</a></td><td>%s</td></tr>\n", dir, key->keyid + 8, key->keyid + 8, key->name); free(dir); ! iter1 = LIST_NEXT(iter1, entries); } fprintf(filep, "</table></div>\n"); *************** *** 236,252 **** } int main(int argc, char **argv) { char c; - char *keyring = NULL; char *outputdir = NULL; ! list_t *keys; ! while ((c = getopt(argc, argv, "k:o:")) != -1) switch (c) { - case 'k': - keyring = optarg; - break; case 'o': outputdir = optarg; --- 209,244 ---- } + char *get_field() + { + char c, *string; + size_t 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"); + ++size; + string = (char *) malloc(size); + if(string == NULL) + return NULL; + fgets(string, size, stdin); + *(string + size) = '\0'; + return string; + } + int main(int argc, char **argv) { char c; char *outputdir = NULL; ! struct list_t *keys; ! while ((c = getopt(argc, argv, "o:")) != -1) switch (c) { case 'o': outputdir = optarg; *************** *** 263,267 **** } ! keys = parse_keyring(keyring); do_analysis(keys, outputdir); --- 255,259 ---- } ! keys = parse_keyring(); do_analysis(keys, outputdir); *************** *** 269,278 **** } ! void output_file(pgpkey_t *key, list_t *nnlist, list_t *nslist, list_t *snlist, list_t *sslist) { char *file_dir; FILE *filep; ! list_t *tmp_list; struct stat *sb; file_dir = (char *) malloc(3); --- 261,271 ---- } ! void output_file(pgpkey_t *key, struct list_t *nnlist, struct list_t *nslist, struct list_t *snlist, struct list_t *sslist) { char *file_dir; FILE *filep; ! struct list_t *tmp_list; struct stat *sb; + unsigned int tmp_size; file_dir = (char *) malloc(3); *************** *** 296,308 **** fprintf(filep, "Signatures to this key:\n"); ! tmp_list = list_union(nslist, sslist); print_list(filep, tmp_list); ! fprintf(filep, " Total: %u signature%s to this key from this set.\n\n", tmp_list->size, ((tmp_list->size == 1)?"":"s")); list_free(tmp_list); fprintf(filep, "Signatures from this key:\n"); ! tmp_list = list_union(snlist, sslist); print_list(filep, tmp_list); ! fprintf(filep, " Total: %u signature%s from this key to this set.\n\n", tmp_list->size, ((tmp_list->size == 1)?"":"s")); list_free(tmp_list); --- 289,303 ---- fprintf(filep, "Signatures to this key:\n"); ! tmp_list = list_union(nslist, sslist, &pgpkey_compare); print_list(filep, tmp_list); ! tmp_size = list_size(tmp_list); ! fprintf(filep, " Total: %u signature%s to this key from this set.\n\n", tmp_size, ((tmp_size == 1)?"":"s")); list_free(tmp_list); fprintf(filep, "Signatures from this key:\n"); ! tmp_list = list_union(snlist, sslist, &pgpkey_compare); print_list(filep, tmp_list); ! tmp_size = list_size(tmp_list); ! fprintf(filep, " Total: %u signature%s from this key to this set.\n\n", tmp_size, ((tmp_size == 1)?"":"s")); list_free(tmp_list); *************** *** 311,327 **** fprintf(filep, "This key has not signed, nor been signed by:\n"); print_list(filep, nnlist); ! fprintf(filep, " Total: %u key%s in this set.\n\n", nnlist->size, ((nnlist->size == 1)?"":"s")); fprintf(filep, "This key has not signed, but has been signed by:\n"); print_list(filep, nslist); ! fprintf(filep, " Total: %u key%s in this set.\n\n", nslist->size, ((nslist->size == 1)?"":"s")); fprintf(filep, "This key has signed, but has not been signed by:\n"); print_list(filep, snlist); ! fprintf(filep, " Total: %u key%s in this set.\n\n", snlist->size, ((snlist->size == 1)?"":"s")); fprintf(filep, "This key has signed and has been signed by:\n"); print_list(filep, sslist); ! fprintf(filep, " Total: %u key%s in this set.\n\n", sslist->size, ((sslist->size == 1)?"":"s")); fclose(filep); --- 306,326 ---- fprintf(filep, "This key has not signed, nor been signed by:\n"); print_list(filep, nnlist); ! tmp_size = list_size(nnlist); ! fprintf(filep, " Total: %u key%s in this set.\n\n", tmp_size, ((tmp_size == 1)?"":"s")); fprintf(filep, "This key has not signed, but has been signed by:\n"); print_list(filep, nslist); ! tmp_size = list_size(nslist); ! fprintf(filep, " Total: %u key%s in this set.\n\n", tmp_size, ((tmp_size == 1)?"":"s")); fprintf(filep, "This key has signed, but has not been signed by:\n"); print_list(filep, snlist); ! tmp_size = list_size(snlist); ! fprintf(filep, " Total: %u key%s in this set.\n\n", tmp_size, ((tmp_size == 1)?"":"s")); fprintf(filep, "This key has signed and has been signed by:\n"); print_list(filep, sslist); ! tmp_size = list_size(sslist); ! fprintf(filep, " Total: %u key%s in this set.\n\n", tmp_size, ((tmp_size == 1)?"":"s")); fclose(filep); *************** *** 331,424 **** } ! list_t *parse_keyring(char *keyring) { ! size_t size; ! char *command1 = "gpg --list-sigs --with-colons --no-default-keyring --keyring "; ! char *command2; ! FILE *filep; ! keydata_t *key; ! pgpkey_t *public_key, *tmp_key, *tmp2_key; ! list_t *keys; ! int key_was_added; ! ! public_key = NULL; ! keys = list_new(&pgpkey_compare); ! if(keyring == NULL) ! filep = stdin; ! else ! { ! size = strlen(command1) + strlen(keyring); ! command2 = (char *) malloc(size); ! ! strncpy(command2, command1, size); ! *(command2 + size) = '\0'; ! strncat(command2, keyring, size - strlen(command2)); ! filep = popen(command2, "r"); ! } ! key = keydata_new(); ! while(strcmp(key->type, "nul") == 0) ! { ! key = keydata_read(filep); ! } ! while(strcmp(key->type, "eof") != 0) { ! if(strcmp(key->type, "pub") == 0) ! { ! public_key = pgpkey_new(key->keyid, key->name); ! key_was_added = list_add_object(keys, public_key); ! if(key_was_added == 0) ! { ! tmp_key = list_find_object(keys, public_key); ! list_free(public_key->signatures); ! free(public_key->name); ! free(public_key->keyid); ! free(public_key); ! public_key = tmp_key; ! } ! } ! if(strcmp(key->type, "sig") == 0) { ! if(public_key == NULL) ! fprintf(stderr, "Missing public key, skipping signature!\n"); ! else { ! tmp_key = pgpkey_new(key->keyid, key->name); ! key_was_added = list_add_object(keys, tmp_key); ! if(key_was_added == 0) { ! tmp2_key = list_find_object(keys, tmp_key); ! list_free(tmp_key->signatures); ! free(tmp_key->name); ! free(tmp_key->keyid); ! free(tmp_key); ! tmp_key = tmp2_key; } - list_add_object(public_key->signatures, tmp_key); } } ! if(strcmp(key->type, "sub") == 0) ! public_key = NULL; ! key = keydata_read(filep); } ! if(keyring != NULL) ! pclose(filep); return keys; } ! void print_list(FILE *filep, list_t *list) { ! node_t *node; ! node = list->head; ! while(node != NULL) { ! fprintf(filep, " %s %s\n", ((pgpkey_t *) node->object)->keyid + 8, ((pgpkey_t *) node->object)->name); ! node = node->next; } - return; --- 330,414 ---- } ! struct list_t *parse_keyring() { ! char c, type, *field1, *field2; ! pgpkey_t *key1, *key2, *tmpkey; ! struct list_t *keys; ! keys = list_new(); ! for(c = type = getchar(); c == 'e' || c == 'n'; c = type = getchar()) { ! if(((c = getchar()) != ':') && (c != EOF)) ! errx(EX_DATAERR, "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(((c = getchar()) != ':') && (c != EOF)) ! errx(EX_DATAERR, "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(((c = getchar()) != '\n') && (c != EOF)) ! errx(EX_DATAERR, "Invalid character, %c (ASCII: %d), encountered!\n", c, c); ! ! if(type == 'n') { ! tmpkey = pgpkey_new(field1, field2); ! free(field1); ! if((key1 = list_add_object(keys, tmpkey, &pgpkey_compare)) != tmpkey) { ! free(tmpkey); ! if(*(key1->name) == '\0') { ! key1->name = field2; ! field2 = NULL; } } } ! else ! { ! tmpkey = pgpkey_new(field1, ""); ! free(field1); ! if((key1 = list_add_object(keys, tmpkey, &pgpkey_compare)) != tmpkey) ! free(tmpkey); ! tmpkey = pgpkey_new(field2, ""); ! free(field2); ! if((key2 = list_add_object(keys, tmpkey, &pgpkey_compare)) != tmpkey) ! free(tmpkey); ! list_add_object(key2->signatures, key1, &pgpkey_compare); ! } ! ! ! if(c == EOF) ! break; } ! if(c != EOF) ! errx(EX_DATAERR, "Invalid character, %c (ASCII: %d), encountered!\n", c, c); ! return keys; } ! void print_list(FILE *filep, struct list_t *list) { ! struct node_t *node; ! pgpkey_t *key; ! char *keyid, *name; ! LIST_FOREACH(node, list, entries) { ! key = (pgpkey_t *) node->object; ! keyid = key->keyid + 8; ! name = key->name; ! fprintf(filep, " %s %s\n", keyid, name); } return; *************** *** 429,433 **** extern char *__progname; ! fprintf(stderr, "usage: %s [-k pubring.gpg] -o output_directory\n", __progname); return; } --- 419,423 ---- extern char *__progname; ! fprintf(stderr, "usage: %s -o output_directory\n", __progname); return; } *************** *** 435,447 **** int wot_compare(void *obj1, void *obj2) { ! list_t *wot1 = obj1; ! list_t *wot2 = obj2; if(wot1 == wot2) return 0; ! if(wot1->size == wot2->size) ! return wot1->compare(wot1->head->object, wot2->head->object); ! return wot2->size - wot1->size; } --- 425,438 ---- int wot_compare(void *obj1, void *obj2) { ! struct list_t *wot1 = obj1; ! struct list_t *wot2 = obj2; ! unsigned int wot1size, wot2size; if(wot1 == wot2) return 0; ! if((wot1size = list_size(wot1)) == (wot2size = list_size(wot2))) ! return pgpkey_compare(LIST_FIRST(wot1)->object, LIST_FIRST(wot2)->object); ! return wot2size - wot1size; } --- NEW FILE: node.c --- /* $Id: node.c,v 1.2 2005/04/14 03:24:28 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 <stdlib.h> #include <string.h> #include "list.h" #include "node.h" int pgpkey_compare(void *key1, void *key2) { return strcmp(((pgpkey_t *) key1)->keyid, ((pgpkey_t *) key2)->keyid); } int pgpkey_compare_msd(void *key1, void *key2) { float tmp; tmp = ((pgpkey_t *) key1)->msd - ((pgpkey_t *) key2)->msd; if(tmp == (float) 0) return strcmp(((pgpkey_t *) key1)->keyid, ((pgpkey_t *) key2)->keyid); else if(tmp > (float) 0) return 1; else return (-1); } unsigned int pgpkey_distance(pgpkey_t *keyto, pgpkey_t *keyfrom) { unsigned int distance; unsigned int last_known_size, tmpsize; struct list_t *traversed_keys, *tmp_keys; struct node_t *tmp_node; traversed_keys = list_new(); last_known_size = 0; distance = 1; list_merge_list(traversed_keys, keyto->signatures, &pgpkey_compare); while((tmpsize = list_size(traversed_keys)) != last_known_size) { if(list_find_object(traversed_keys, keyfrom, &pgpkey_compare) != NULL) return distance; last_known_size = tmpsize; ++distance; tmp_keys = traversed_keys; tmp_node = LIST_FIRST(tmp_keys); traversed_keys = list_new(); while(tmp_node != NULL) { list_add_object(traversed_keys, tmp_node->object, &pgpkey_compare); list_merge_list(traversed_keys, ((pgpkey_t *) tmp_node->object)->signatures, &pgpkey_compare); tmp_node = LIST_NEXT(tmp_node, entries); } } return 0; } void pgpkey_msd(pgpkey_t *key, struct list_t *keys) { unsigned int distance, i, num_keys; struct node_t *iter; distance = 0; num_keys = 0; iter = LIST_FIRST(keys); while(iter != NULL) { i = pgpkey_distance(key, (pgpkey_t *) iter->object); if(i > 0) { distance += i; num_keys++; } iter = LIST_NEXT(iter, entries); } key->msd = ((float) distance) / ((float) num_keys); return; } pgpkey_t *pgpkey_new(char *keyid, char *name) { pgpkey_t *pgpkey; pgpkey = (pgpkey_t *) malloc(sizeof(pgpkey_t)); pgpkey->keyid = (char *) malloc(17); strncpy(pgpkey->keyid, keyid, 16); *(pgpkey->keyid + 16) = '\0'; pgpkey->name = (char *) malloc(strlen(name) + 1); strncpy(pgpkey->name, name, strlen(name)); *(pgpkey->name + strlen(name)) = '\0'; pgpkey->signatures = list_new(); pgpkey->msd = 0; return pgpkey; } |
|
From: Jeff B. <jb...@us...> - 2005-04-14 03:15:58
|
Update of /cvsroot/digraphanalysis/digraphanalysis/utils/gpg2digraph In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv21118 Modified Files: Tag: JBREKER gpg2digraph.c Log Message: handle uid's (later this will output a lines (alias) instead of n lines. Index: gpg2digraph.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/utils/gpg2digraph/gpg2digraph.c,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** gpg2digraph.c 16 Mar 2005 22:00:34 -0000 1.1 --- gpg2digraph.c 14 Apr 2005 03:15:46 -0000 1.1.2.1 *************** *** 25,30 **** --- 25,32 ---- char *do_pub(void); void do_sig(char *); + char *do_uid(void); unsigned int encode(char *); void func001(unsigned int); + char *get_fingerprint(); char *get_keyid(); char *get_name(); *************** *** 98,101 **** --- 100,148 ---- } + /* Handle a uid line. + */ + char * + do_uid() + { + char c, *keyid, *name; + + func001(7); + keyid = get_fingerprint() + 24; + func001(2); + name = get_name(); + fprintf(stdout, "n:%u:%s:%u:%s\n", strlen(keyid), keyid, strlen(name), name); + while (((c = fgetc(stdin)) != '\n') && (feof(stdin) == 0)) + if (ferror(stdin)) + exit(EX_IOERR); + free(name); + + return keyid; + } + + /* 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. */ *************** *** 191,194 **** --- 238,244 ---- do_sig(keyid_p); break; + case (117105100): /* uid */ + keyid_p = do_uid(); + break; default: break_while = 1; *************** *** 202,205 **** --- 252,283 ---- } break; + case (117105100): /* uid */ + keyid_p = do_uid(); + 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(); + break; + default: + break_while = 1; + break; + } + if(break_while) + { + break_while = 0; + break; + } + } default: break; |
|
From: Jeff B. <jb...@us...> - 2005-04-12 04:31:06
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv32054 Modified Files: Tag: JBREKER list.c Log Message: sigh 2 hours of work to fix this bug and I am about to give up when I realize the LIST_* macros are expanding out so that everytime it wants to use (elm) its calling list_new_node()... Index: list.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/list.c,v retrieving revision 1.1.2.5 retrieving revision 1.1.2.6 diff -C2 -d -r1.1.2.5 -r1.1.2.6 *** list.c 11 Apr 2005 04:32:39 -0000 1.1.2.5 --- list.c 12 Apr 2005 04:30:58 -0000 1.1.2.6 *************** *** 30,69 **** { int i; ! struct node_t *iter; ! ! iter = LIST_FIRST(list); if(LIST_EMPTY(list)) ! { ! LIST_INSERT_HEAD(list, list_new_node(object), entries); ! return object; ! } ! while(LIST_NEXT(iter, entries) != NULL) ! { ! if((i = compare(object, iter->object)) < 0) { ! if(iter == LIST_FIRST(list)) ! LIST_INSERT_HEAD(list, list_new_node(object), entries); else ! LIST_INSERT_BEFORE(iter, list_new_node(object), entries); ! return object; } ! else ! if(i == 0) ! return iter->object; ! iter = LIST_NEXT(iter, entries); ! } ! if((i = compare(object, iter->object)) < 0) ! { ! if(iter == LIST_FIRST(list)) ! LIST_INSERT_HEAD(list, list_new_node(object), entries); ! else ! LIST_INSERT_BEFORE(iter, list_new_node(object), entries); ! return object; ! } ! else ! if(i == 0) ! return iter->object; ! LIST_INSERT_AFTER(iter, list_new_node(object), entries); return object; } --- 30,59 ---- { 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; ! } else ! if(i == 0) ! return iter->object; ! else ! if(LIST_NEXT(iter, entries) == NULL) ! LIST_INSERT_AFTER(iter, tmpnode, entries); } ! return object; } |
|
From: Jeff B. <jb...@us...> - 2005-04-11 04:32:51
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv26763 Modified Files: Tag: JBREKER list.c main.c Log Message: fix 2 bugs -print_list segfaults on empty lists: fixed by LIST_INIT during list_new() -segfault on LIST_REMOVE: apparently you can't use this to remove the first element. (elm)->field.le_prev is null thus *(elm)->field.le_prev segfaults. Index: main.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.c,v retrieving revision 1.2.2.11 retrieving revision 1.2.2.12 diff -C2 -d -r1.2.2.11 -r1.2.2.12 *** main.c 10 Apr 2005 03:59:48 -0000 1.2.2.11 --- main.c 11 Apr 2005 04:32:39 -0000 1.2.2.12 *************** *** 20,23 **** --- 20,24 ---- #include <ctype.h> + #include <err.h> #include <libgen.h> #include <stdio.h> *************** *** 86,91 **** /* Iterate through the list of keys, analyzing the key and outputting its file */ ! iter1 = LIST_FIRST(keys1); ! while(iter1 != NULL) { nnlist = list_new(); --- 87,91 ---- /* Iterate through the list of keys, analyzing the key and outputting its file */ ! LIST_FOREACH(iter1, keys1, entries) { nnlist = list_new(); *************** *** 99,103 **** list_free(snlist); list_free(sslist); - iter1 = LIST_NEXT(iter1, entries); } iter1 = NULL; --- 99,102 ---- *************** *** 221,225 **** size = size * 10; size = size + c - '0'; - printf("%u", size); } if(c == EOF) --- 220,223 ---- *************** *** 343,359 **** { if(((c = getchar()) != ':') && (c != EOF)) ! errx(EX_DATAERR, "001 Invalid character, %c (ASCII: %d), encountered!\n", c, c); if(c == EOF) break; if((field1 = get_field()) == NULL) ! errx(EX_OSERR, "001 Cannot allocate memory!\n"); if(*field1 == EOF) break; if(((c = getchar()) != ':') && (c != EOF)) ! errx(EX_DATAERR, "002 Invalid character, %c (ASCII: %d), encountered!\n", c, c); if(c == EOF) break; if((field2 = get_field()) == NULL) ! errx(EX_OSERR, "002 Cannot allocate memory!\n"); if(*field2 == EOF) break; --- 341,357 ---- { if(((c = getchar()) != ':') && (c != EOF)) ! errx(EX_DATAERR, "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(((c = getchar()) != ':') && (c != EOF)) ! errx(EX_DATAERR, "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; *************** *** 368,372 **** { free(tmpkey); ! if(key1->name == NULL) { key1->name = field2; --- 366,370 ---- { free(tmpkey); ! if(*(key1->name) == '\0') { key1->name = field2; *************** *** 374,378 **** } } - printf(key1->keyid); } else --- 372,375 ---- *************** *** 387,391 **** free(tmpkey); list_add_object(key2->signatures, key1, &pgpkey_compare); - } --- 384,387 ---- *************** *** 405,411 **** struct node_t *node; ! LIST_FOREACH(node, list, entries) ! fprintf(filep, " %s %s\n", ((pgpkey_t *) node->object)->keyid + 8, ((pgpkey_t *) node->object)->name); return; --- 401,414 ---- struct node_t *node; ! pgpkey_t *key; ! char *keyid, *name; + LIST_FOREACH(node, list, entries) + { + key = (pgpkey_t *) node->object; + keyid = key->keyid + 8; + name = key->name; + fprintf(filep, " %s %s\n", keyid, name); + } return; Index: list.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/list.c,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -C2 -d -r1.1.2.4 -r1.1.2.5 *** list.c 10 Apr 2005 03:59:48 -0000 1.1.2.4 --- list.c 11 Apr 2005 04:32:39 -0000 1.1.2.5 *************** *** 130,134 **** struct node_t *iter; ! for(iter = LIST_FIRST(list2); iter != NULL; iter = LIST_NEXT(iter, entries)) list_add_object(list1, iter->object, compare); --- 130,134 ---- struct node_t *iter; ! LIST_FOREACH(iter, list2, entries) list_add_object(list1, iter->object, compare); *************** *** 145,148 **** --- 145,150 ---- return NULL; + LIST_INIT(list); + return list; } *************** *** 173,177 **** if((i = compare(iter->object, object)) == 0) { ! LIST_REMOVE(iter, entries); free(iter); break; --- 175,182 ---- 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; *************** *** 223,231 **** struct list_t *list; ! if((list = list_new()) == NULL) return NULL; ! if(list_merge_list(list, list1, compare) == NULL) ! return NULL; ! return list_merge_list(list, list2, compare); } --- 228,236 ---- 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; } |
|
From: Jeff B. <jb...@us...> - 2005-04-10 04:00:00
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3187 Modified Files: Tag: JBREKER list.c list.h main.c Log Message: various changes Index: list.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/list.h,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** list.h 4 Apr 2005 03:27:36 -0000 1.1.2.3 --- list.h 10 Apr 2005 03:59:48 -0000 1.1.2.4 *************** *** 29,33 **** LIST_HEAD(list_t, node_t); ! int 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 *)); --- 29,33 ---- LIST_HEAD(list_t, node_t); ! 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 *)); Index: main.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.c,v retrieving revision 1.2.2.10 retrieving revision 1.2.2.11 diff -C2 -d -r1.2.2.10 -r1.2.2.11 *** main.c 9 Apr 2005 05:05:02 -0000 1.2.2.10 --- main.c 10 Apr 2005 03:59:48 -0000 1.2.2.11 *************** *** 24,27 **** --- 24,28 ---- #include <stdlib.h> #include <string.h> + #include <sysexits.h> #include <unistd.h> *************** *** 29,33 **** #include "main.h" #include "node.h" - #include "nodedata.h" int analyze_key(pgpkey_t *key, struct list_t *keys, struct list_t *nnlist, struct list_t *nslist, struct list_t *snlist, struct list_t *sslist) --- 30,33 ---- *************** *** 41,77 **** { if(list_find_object(key->signatures, iter->object, pgpkey_compare) != NULL) - { if(list_find_object(((pgpkey_t *) iter->object)->signatures, key, pgpkey_compare) != NULL) ! { ! if(list_add_object(sslist, iter->object, pgpkey_compare) == -1) ! { ! return -1; ! } ! } else ! { ! if(list_add_object(nslist, iter->object, pgpkey_compare) == -1) ! { ! return -1; ! } ! } ! } else - { if(list_find_object(((pgpkey_t *) iter->object)->signatures, key, pgpkey_compare) != NULL) ! { ! if(list_add_object(snlist, iter->object, pgpkey_compare) == -1) ! { ! return -1; ! } ! } else ! { ! if(list_add_object(nnlist, iter->object, pgpkey_compare) == -1) ! { ! return -1; ! } ! } ! } iter = LIST_NEXT(iter, entries); } --- 41,53 ---- { if(list_find_object(key->signatures, iter->object, pgpkey_compare) != NULL) if(list_find_object(((pgpkey_t *) iter->object)->signatures, key, pgpkey_compare) != NULL) ! list_add_object(sslist, iter->object, pgpkey_compare); else ! list_add_object(nslist, iter->object, pgpkey_compare); else if(list_find_object(((pgpkey_t *) iter->object)->signatures, key, pgpkey_compare) != NULL) ! list_add_object(snlist, iter->object, pgpkey_compare); else ! list_add_object(nnlist, iter->object, pgpkey_compare); iter = LIST_NEXT(iter, entries); } *************** *** 133,139 **** { if(((tmplist1 = list_new()) == NULL) || ! ((tmplist2 = list_new()) == NULL) || ! (list_add_object(tmplist1, LIST_FIRST(keys2)->object, &pgpkey_compare_msd) == -1)) return -1; list_remove(keys2, LIST_FIRST(keys2)->object, &pgpkey_compare); while(list_size(tmplist1) != list_size(tmplist2)) --- 109,115 ---- { if(((tmplist1 = list_new()) == NULL) || ! ((tmplist2 = list_new()) == NULL)) return -1; + list_add_object(tmplist1, LIST_FIRST(keys2)->object, &pgpkey_compare_msd); list_remove(keys2, LIST_FIRST(keys2)->object, &pgpkey_compare); while(list_size(tmplist1) != list_size(tmplist2)) *************** *** 150,155 **** if(pgpkey_distance(iter2->object, iter1->object) != 0) { ! if(list_add_object(tmplist1, iter2->object, &pgpkey_compare_msd) == -1) ! return -1; list_remove(keys2, iter2->object, &pgpkey_compare); } --- 126,130 ---- if(pgpkey_distance(iter2->object, iter1->object) != 0) { ! list_add_object(tmplist1, iter2->object, &pgpkey_compare_msd); list_remove(keys2, iter2->object, &pgpkey_compare); } *************** *** 159,164 **** } } ! if(list_add_object(wots, tmplist1, &wot_compare) == -1) ! return -1; list_free(tmplist2); tmplist2 = NULL; --- 134,138 ---- } } ! list_add_object(wots, tmplist1, &wot_compare); list_free(tmplist2); tmplist2 = NULL; *************** *** 236,239 **** --- 210,237 ---- } + char *get_field() + { + char c, *string; + size_t size = 0; + + while(((c = getchar()) != ':') && (c != EOF)) + { + if(!isdigit(c)) + errx(EX_DATAERR, "Invalid data input!\n"); + size = size * 10; + size = size + c - '0'; + printf("%u", size); + } + if(c == EOF) + errx(EX_DATAERR, "Unexpected termination of data input!\n"); + ++size; + string = (char *) malloc(size); + if(string == NULL) + return NULL; + fgets(string, size, stdin); + *(string + size) = '\0'; + return string; + } + int main(int argc, char **argv) { *************** *** 336,340 **** struct list_t *parse_keyring() { ! char c, type; pgpkey_t *key1, *key2, *tmpkey; struct list_t *keys; --- 334,338 ---- struct list_t *parse_keyring() { ! char c, type, *field1, *field2; pgpkey_t *key1, *key2, *tmpkey; struct list_t *keys; *************** *** 342,364 **** keys = list_new(); ! for(c = type = fgetc(stdin); c == 'e' || c == 'n'; c = type = fgetc(stdin)) { ! if(((c = fgetc(stdin)) != ':') && (c != EOF)) ! errx(EX_DATAERR, "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(((c = fgetc(stdin)) != ':') && (c != EOF)) ! errx(EX_DATAERR, "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(((c = fgetc()) != '\n') && (c != EOF)) errx(EX_DATAERR, "Invalid character, %c (ASCII: %d), encountered!\n", c, c); --- 340,362 ---- keys = list_new(); ! for(c = type = getchar(); c == 'e' || c == 'n'; c = type = getchar()) { ! if(((c = getchar()) != ':') && (c != EOF)) ! errx(EX_DATAERR, "001 Invalid character, %c (ASCII: %d), encountered!\n", c, c); if(c == EOF) break; if((field1 = get_field()) == NULL) ! errx(EX_OSERR, "001 Cannot allocate memory!\n"); if(*field1 == EOF) break; ! if(((c = getchar()) != ':') && (c != EOF)) ! errx(EX_DATAERR, "002 Invalid character, %c (ASCII: %d), encountered!\n", c, c); if(c == EOF) break; if((field2 = get_field()) == NULL) ! errx(EX_OSERR, "002 Cannot allocate memory!\n"); if(*field2 == EOF) ! break; ! if(((c = getchar()) != '\n') && (c != EOF)) errx(EX_DATAERR, "Invalid character, %c (ASCII: %d), encountered!\n", c, c); *************** *** 376,379 **** --- 374,378 ---- } } + printf(key1->keyid); } else Index: list.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/list.c,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** list.c 4 Apr 2005 03:27:36 -0000 1.1.2.3 --- list.c 10 Apr 2005 03:59:48 -0000 1.1.2.4 *************** *** 25,35 **** /* Returns: ! * -1 on error ! * 0 if object was not added (ie a compare() call returned 0 with one of the already present objects) ! * 1 if the object was added ! * ! * This might be more usefull if we returned the object that is in the list or NULL on error */ ! int list_add_object(struct list_t *list, void *object, int (*compare)(void *, void *)) { int i; --- 25,31 ---- /* 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; *************** *** 41,45 **** { LIST_INSERT_HEAD(list, list_new_node(object), entries); ! return 1; } while(LIST_NEXT(iter, entries) != NULL) --- 37,41 ---- { LIST_INSERT_HEAD(list, list_new_node(object), entries); ! return object; } while(LIST_NEXT(iter, entries) != NULL) *************** *** 51,59 **** else LIST_INSERT_BEFORE(iter, list_new_node(object), entries); ! return 1; } else if(i == 0) ! return 0; iter = LIST_NEXT(iter, entries); } --- 47,55 ---- else LIST_INSERT_BEFORE(iter, list_new_node(object), entries); ! return object; } else if(i == 0) ! return iter->object; iter = LIST_NEXT(iter, entries); } *************** *** 64,74 **** else LIST_INSERT_BEFORE(iter, list_new_node(object), entries); ! return 1; } else if(i == 0) ! return 0; LIST_INSERT_AFTER(iter, list_new_node(object), entries); ! return 1; } --- 60,70 ---- else LIST_INSERT_BEFORE(iter, list_new_node(object), entries); ! return object; } else if(i == 0) ! return iter->object; LIST_INSERT_AFTER(iter, list_new_node(object), entries); ! return object; } *************** *** 134,145 **** struct node_t *iter; ! iter = LIST_FIRST(list2); ! ! while(iter != NULL) ! { ! if(list_add_object(list1, iter->object, compare) == -1) ! return NULL; ! iter = LIST_NEXT(iter, entries); ! } return list1; --- 130,135 ---- struct node_t *iter; ! for(iter = LIST_FIRST(list2); iter != NULL; iter = LIST_NEXT(iter, entries)) ! list_add_object(list1, iter->object, compare); return list1; *************** *** 206,211 **** while(iter != NULL) { ! if(list_add_object(list, iter->object, compare) == -1) ! return NULL; tmpiter = iter; iter = LIST_NEXT(iter, entries); --- 196,200 ---- while(iter != NULL) { ! list_add_object(list, iter->object, compare); tmpiter = iter; iter = LIST_NEXT(iter, entries); |
|
From: Jeff B. <jb...@us...> - 2005-04-09 05:05:13
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22566 Modified Files: Tag: JBREKER main.c Removed Files: Tag: JBREKER nodedata.c nodedata.h Log Message: parse digraph input. remove nodedata as its no longer needed. Index: main.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.c,v retrieving revision 1.2.2.9 retrieving revision 1.2.2.10 diff -C2 -d -r1.2.2.9 -r1.2.2.10 *** main.c 9 Apr 2005 03:26:30 -0000 1.2.2.9 --- main.c 9 Apr 2005 05:05:02 -0000 1.2.2.10 *************** *** 336,393 **** struct list_t *parse_keyring() { ! keydata_t *key; ! pgpkey_t *public_key, *tmp_key, *tmp2_key; struct list_t *keys; - int key_was_added; - public_key = NULL; keys = list_new(); ! key = keydata_new(); ! while(strcmp(key->type, "nul") == 0) ! { ! key = keydata_read(); ! } ! while(strcmp(key->type, "eof") != 0) { ! if(strcmp(key->type, "pub") == 0) ! { ! public_key = pgpkey_new(key->keyid, key->name); ! key_was_added = list_add_object(keys, public_key, &pgpkey_compare); ! if(key_was_added == 0) ! { ! tmp_key = list_find_object(keys, public_key, &pgpkey_compare); ! list_free(public_key->signatures); ! free(public_key->name); ! free(public_key->keyid); ! free(public_key); ! public_key = tmp_key; ! } ! } ! if(strcmp(key->type, "sig") == 0) { ! if(public_key == NULL) ! fprintf(stderr, "Missing public key, skipping signature!\n"); ! else { ! tmp_key = pgpkey_new(key->keyid, key->name); ! key_was_added = list_add_object(keys, tmp_key, &pgpkey_compare); ! if(key_was_added == 0) { ! tmp2_key = list_find_object(keys, tmp_key, &pgpkey_compare); ! list_free(tmp_key->signatures); ! free(tmp_key->name); ! free(tmp_key->keyid); ! free(tmp_key); ! tmp_key = tmp2_key; } - list_add_object(public_key->signatures, tmp_key, &pgpkey_compare); } } ! if(strcmp(key->type, "sub") == 0) ! public_key = NULL; ! key = keydata_read(); } return keys; } --- 336,402 ---- struct list_t *parse_keyring() { ! char c, type; ! pgpkey_t *key1, *key2, *tmpkey; struct list_t *keys; keys = list_new(); ! for(c = type = fgetc(stdin); c == 'e' || c == 'n'; c = type = fgetc(stdin)) { ! if(((c = fgetc(stdin)) != ':') && (c != EOF)) ! errx(EX_DATAERR, "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(((c = fgetc(stdin)) != ':') && (c != EOF)) ! errx(EX_DATAERR, "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(((c = fgetc()) != '\n') && (c != EOF)) ! errx(EX_DATAERR, "Invalid character, %c (ASCII: %d), encountered!\n", c, c); ! ! if(type == 'n') { ! tmpkey = pgpkey_new(field1, field2); ! free(field1); ! if((key1 = list_add_object(keys, tmpkey, &pgpkey_compare)) != tmpkey) { ! free(tmpkey); ! if(key1->name == NULL) { ! key1->name = field2; ! field2 = NULL; } } } ! else ! { ! tmpkey = pgpkey_new(field1, ""); ! free(field1); ! if((key1 = list_add_object(keys, tmpkey, &pgpkey_compare)) != tmpkey) ! free(tmpkey); ! tmpkey = pgpkey_new(field2, ""); ! free(field2); ! if((key2 = list_add_object(keys, tmpkey, &pgpkey_compare)) != tmpkey) ! free(tmpkey); ! list_add_object(key2->signatures, key1, &pgpkey_compare); ! ! } ! ! ! if(c == EOF) ! break; } + if(c != EOF) + errx(EX_DATAERR, "Invalid character, %c (ASCII: %d), encountered!\n", c, c); + return keys; } --- nodedata.h DELETED --- --- nodedata.c DELETED --- |
|
From: Jeff B. <jb...@us...> - 2005-04-09 03:26:39
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7846 Modified Files: Tag: JBREKER main.c main.h node.c Log Message: fix bugs that cropped up when converting to LIST_* macros Index: node.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/Attic/node.c,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** node.c 4 Apr 2005 03:27:36 -0000 1.1.2.3 --- node.c 9 Apr 2005 03:26:30 -0000 1.1.2.4 *************** *** 110,114 **** strncpy(pgpkey->name, name, strlen(name)); *(pgpkey->name + strlen(name)) = '\0'; ! pgpkey->signatures = list_new(&pgpkey_compare); pgpkey->msd = 0; --- 110,114 ---- strncpy(pgpkey->name, name, strlen(name)); *(pgpkey->name + strlen(name)) = '\0'; ! pgpkey->signatures = list_new(); pgpkey->msd = 0; Index: main.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.c,v retrieving revision 1.2.2.8 retrieving revision 1.2.2.9 diff -C2 -d -r1.2.2.8 -r1.2.2.9 *** main.c 7 Apr 2005 03:02:47 -0000 1.2.2.8 --- main.c 9 Apr 2005 03:26:30 -0000 1.2.2.9 *************** *** 129,138 **** /* Pull apart the list of keys and seperate them into lists where all the keys can reach one another */ keys2 = list_duplicate(keys1, &pgpkey_compare); ! wots = list_new(&wot_compare); ! while(LIST_EMPTY(keys2)) { ! if(((tmplist1 = list_new(&pgpkey_compare_msd)) == NULL) || ! ((tmplist2 = list_new(&pgpkey_compare_msd)) == NULL) || ! (list_add_object(tmplist1, LIST_FIRST(keys2)->object, &pgpkey_compare) == -1)) return -1; list_remove(keys2, LIST_FIRST(keys2)->object, &pgpkey_compare); --- 129,138 ---- /* Pull apart the list of keys and seperate them into lists where all the keys can reach one another */ keys2 = list_duplicate(keys1, &pgpkey_compare); ! wots = list_new(); ! while(!LIST_EMPTY(keys2)) { ! if(((tmplist1 = list_new()) == NULL) || ! ((tmplist2 = list_new()) == NULL) || ! (list_add_object(tmplist1, LIST_FIRST(keys2)->object, &pgpkey_compare_msd) == -1)) return -1; list_remove(keys2, LIST_FIRST(keys2)->object, &pgpkey_compare); *************** *** 140,144 **** { list_free(tmplist2); ! if((tmplist2 = list_duplicate(tmplist1, &pgpkey_compare)) == NULL) return -1; iter1 = LIST_FIRST(tmplist2); --- 140,144 ---- { list_free(tmplist2); ! if((tmplist2 = list_duplicate(tmplist1, &pgpkey_compare_msd)) == NULL) return -1; iter1 = LIST_FIRST(tmplist2); *************** *** 150,154 **** if(pgpkey_distance(iter2->object, iter1->object) != 0) { ! if(list_add_object(tmplist1, iter2->object, &pgpkey_compare) == -1) return -1; list_remove(keys2, iter2->object, &pgpkey_compare); --- 150,154 ---- if(pgpkey_distance(iter2->object, iter1->object) != 0) { ! if(list_add_object(tmplist1, iter2->object, &pgpkey_compare_msd) == -1) return -1; list_remove(keys2, iter2->object, &pgpkey_compare); *************** *** 159,163 **** } } ! if(list_add_object(wots, tmplist1, &pgpkey_compare) == -1) return -1; list_free(tmplist2); --- 159,163 ---- } } ! if(list_add_object(wots, tmplist1, &wot_compare) == -1) return -1; list_free(tmplist2); *************** *** 197,206 **** free(dir); dir = NULL; ! list_remove(tmplist1, key, &pgpkey_compare); key = NULL; } fprintf(filep, "</table></div>\n"); tmplist1 = iter1->object; ! list_remove(wots, tmplist1, &pgpkey_compare); list_free(tmplist1); tmplist1 = NULL; --- 197,206 ---- free(dir); dir = NULL; ! list_remove(tmplist1, key, &pgpkey_compare_msd); key = NULL; } fprintf(filep, "</table></div>\n"); tmplist1 = iter1->object; ! list_remove(wots, tmplist1, &wot_compare); list_free(tmplist1); tmplist1 = NULL; *************** *** 412,416 **** } ! int wot_compare(void *obj1, void *obj2, int (*compare)(void *, void *)) { struct list_t *wot1 = obj1; --- 412,416 ---- } ! int wot_compare(void *obj1, void *obj2) { struct list_t *wot1 = obj1; *************** *** 422,426 **** if((wot1size = list_size(wot1)) == (wot2size = list_size(wot2))) ! return compare(LIST_FIRST(wot1)->object, LIST_FIRST(wot2)->object); return wot2size - wot1size; --- 422,426 ---- if((wot1size = list_size(wot1)) == (wot2size = list_size(wot2))) ! return pgpkey_compare(LIST_FIRST(wot1)->object, LIST_FIRST(wot2)->object); return wot2size - wot1size; Index: main.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.h,v retrieving revision 1.1.2.4 retrieving revision 1.1.2.5 diff -C2 -d -r1.1.2.4 -r1.1.2.5 *** main.h 4 Apr 2005 03:27:36 -0000 1.1.2.4 --- main.h 9 Apr 2005 03:26:30 -0000 1.1.2.5 *************** *** 31,35 **** void print_list(FILE *, struct list_t *); void usage(void); ! int wot_compare(void *, void *, int (*)(void *, void *)); #endif --- 31,35 ---- void print_list(FILE *, struct list_t *); void usage(void); ! int wot_compare(void *, void *); #endif |
|
From: Jeff B. <jb...@us...> - 2005-04-07 03:02:57
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31439 Modified Files: Tag: JBREKER main.c Log Message: Finish up LIST_* macros. compiles Index: main.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.c,v retrieving revision 1.2.2.7 retrieving revision 1.2.2.8 diff -C2 -d -r1.2.2.7 -r1.2.2.8 *** main.c 4 Apr 2005 16:14:16 -0000 1.2.2.7 --- main.c 7 Apr 2005 03:02:47 -0000 1.2.2.8 *************** *** 84,88 **** * Return -1 on error */ ! int do_analysis(list_t *keys1, char *outputdir) { char *dir; --- 84,88 ---- * Return -1 on error */ ! int do_analysis(struct list_t *keys1, char *outputdir) { char *dir; *************** *** 90,95 **** float last_msd; int i, j, k; ! list_t *keys2, *tmplist1, *tmplist2, *wots, *nnlist, *nslist, *snlist, *sslist; ! node_t *iter1, *iter2; pgpkey_t *key; struct stat *sb; --- 90,95 ---- float last_msd; int i, j, k; ! struct list_t *keys2, *tmplist1, *tmplist2, *wots, *nnlist, *nslist, *snlist, *sslist; ! struct node_t *iter1, *iter2; pgpkey_t *key; struct stat *sb; *************** *** 110,120 **** /* Iterate through the list of keys, analyzing the key and outputting its file */ ! iter1 = keys1->head; while(iter1 != NULL) { ! nnlist = list_new(&pgpkey_compare); ! nslist = list_new(&pgpkey_compare); ! snlist = list_new(&pgpkey_compare); ! sslist = list_new(&pgpkey_compare); analyze_key(iter1->object, keys1, nnlist, nslist, snlist, sslist); output_file(iter1->object, nnlist, nslist, snlist, sslist); --- 110,120 ---- /* Iterate through the list of keys, analyzing the key and outputting its file */ ! iter1 = LIST_FIRST(keys1); while(iter1 != NULL) { ! nnlist = list_new(); ! nslist = list_new(); ! snlist = list_new(); ! sslist = list_new(); analyze_key(iter1->object, keys1, nnlist, nslist, snlist, sslist); output_file(iter1->object, nnlist, nslist, snlist, sslist); *************** *** 123,163 **** list_free(snlist); list_free(sslist); ! iter1 = iter1->next; } iter1 = NULL; /* Pull apart the list of keys and seperate them into lists where all the keys can reach one another */ ! keys2 = list_duplicate(keys1); wots = list_new(&wot_compare); ! while(keys2->head != NULL) { if(((tmplist1 = list_new(&pgpkey_compare_msd)) == NULL) || ((tmplist2 = list_new(&pgpkey_compare_msd)) == NULL) || ! (list_add_object(tmplist1, keys2->head->object) == -1)) return -1; ! list_remove(keys2, keys2->head->object); ! while(tmplist1->size != tmplist2->size) { list_free(tmplist2); ! if((tmplist2 = list_duplicate(tmplist1)) == NULL) return -1; ! iter1 = tmplist2->head; while(iter1 != NULL) { ! iter2 = ((pgpkey_t *) iter1->object)->signatures->head; while(iter2 != NULL) { if(pgpkey_distance(iter2->object, iter1->object) != 0) { ! if(list_add_object(tmplist1, iter2->object) == -1) return -1; ! list_remove(keys2, iter2->object); } ! iter2 = iter2->next; } ! iter1 = iter1->next; } } ! if(list_add_object(wots, tmplist1) == -1) return -1; list_free(tmplist2); --- 123,163 ---- list_free(snlist); list_free(sslist); ! iter1 = LIST_NEXT(iter1, entries); } iter1 = NULL; /* Pull apart the list of keys and seperate them into lists where all the keys can reach one another */ ! keys2 = list_duplicate(keys1, &pgpkey_compare); wots = list_new(&wot_compare); ! while(LIST_EMPTY(keys2)) { if(((tmplist1 = list_new(&pgpkey_compare_msd)) == NULL) || ((tmplist2 = list_new(&pgpkey_compare_msd)) == NULL) || ! (list_add_object(tmplist1, LIST_FIRST(keys2)->object, &pgpkey_compare) == -1)) return -1; ! list_remove(keys2, LIST_FIRST(keys2)->object, &pgpkey_compare); ! while(list_size(tmplist1) != list_size(tmplist2)) { list_free(tmplist2); ! if((tmplist2 = list_duplicate(tmplist1, &pgpkey_compare)) == NULL) return -1; ! iter1 = LIST_FIRST(tmplist2); while(iter1 != NULL) { ! iter2 = LIST_FIRST(((pgpkey_t *) iter1->object)->signatures); while(iter2 != NULL) { if(pgpkey_distance(iter2->object, iter1->object) != 0) { ! if(list_add_object(tmplist1, iter2->object, &pgpkey_compare) == -1) return -1; ! list_remove(keys2, iter2->object, &pgpkey_compare); } ! iter2 = LIST_NEXT(iter2, entries); } ! iter1 = LIST_NEXT(iter1, entries); } } ! if(list_add_object(wots, tmplist1, &pgpkey_compare) == -1) return -1; list_free(tmplist2); *************** *** 173,189 **** filep = fopen("report.html", "w"); fprintf(filep, "<html><body>\n"); ! while(wots->head != NULL) { ! iter1 = wots->head; /* If the size of this web of trust is 1 then the remaining are of size 1, so group them all together */ ! if(((list_t *) iter1->object)->size == 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"); ! tmplist1 = (list_t *) iter1->object; ! while(tmplist1->head != NULL) { ! iter2 = tmplist1->head; key = (pgpkey_t *) iter2->object; if(key->msd != last_msd) --- 173,189 ---- filep = fopen("report.html", "w"); fprintf(filep, "<html><body>\n"); ! while(LIST_FIRST(wots) != NULL) { ! iter1 = LIST_FIRST(wots); /* 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 list_t *) iter1->object)) == 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"); ! tmplist1 = (struct list_t *) iter1->object; ! while(LIST_FIRST(tmplist1) != NULL) { ! iter2 = LIST_FIRST(tmplist1); key = (pgpkey_t *) iter2->object; if(key->msd != last_msd) *************** *** 197,206 **** free(dir); dir = NULL; ! list_remove(tmplist1, key); key = NULL; } fprintf(filep, "</table></div>\n"); tmplist1 = iter1->object; ! list_remove(wots, tmplist1); list_free(tmplist1); tmplist1 = NULL; --- 197,206 ---- free(dir); dir = NULL; ! list_remove(tmplist1, key, &pgpkey_compare); key = NULL; } fprintf(filep, "</table></div>\n"); tmplist1 = iter1->object; ! list_remove(wots, tmplist1, &pgpkey_compare); list_free(tmplist1); tmplist1 = NULL; *************** *** 218,222 **** while(iter1 != NULL) { ! iter2 = ((list_t *) iter1->object)->head; key = (pgpkey_t *) iter2->object; dir = (char *) malloc(3); --- 218,222 ---- while(iter1 != NULL) { ! iter2 = LIST_FIRST(((struct list_t *) iter1->object)); key = (pgpkey_t *) iter2->object; dir = (char *) malloc(3); *************** *** 225,229 **** fprintf(filep, "<tr><td><a href=\"%s/%s\">%s</a></td><td>%s</td></tr>\n", dir, key->keyid + 8, key->keyid + 8, key->name); free(dir); ! iter1 = iter1->next; } fprintf(filep, "</table></div>\n"); --- 225,229 ---- fprintf(filep, "<tr><td><a href=\"%s/%s\">%s</a></td><td>%s</td></tr>\n", dir, key->keyid + 8, key->keyid + 8, key->name); free(dir); ! iter1 = LIST_NEXT(iter1, entries); } fprintf(filep, "</table></div>\n"); *************** *** 408,412 **** extern char *__progname; ! fprintf(stderr, "usage: %s [-k pubring.gpg] -o output_directory\n", __progname); return; } --- 408,412 ---- extern char *__progname; ! fprintf(stderr, "usage: %s -o output_directory\n", __progname); return; } |
|
From: Jeff B. <jb...@us...> - 2005-04-04 16:14:36
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19521 Modified Files: Tag: JBREKER main.c Log Message: more cleanup for LIST_* macros Index: main.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.c,v retrieving revision 1.2.2.6 retrieving revision 1.2.2.7 diff -C2 -d -r1.2.2.6 -r1.2.2.7 *** main.c 4 Apr 2005 03:27:36 -0000 1.2.2.6 --- main.c 4 Apr 2005 16:14:16 -0000 1.2.2.7 *************** *** 239,245 **** { char c; - char *keyring = NULL; char *outputdir = NULL; ! list_t *keys; while ((c = getopt(argc, argv, "o:")) != -1) --- 239,244 ---- { char c; char *outputdir = NULL; ! struct list_t *keys; while ((c = getopt(argc, argv, "o:")) != -1) *************** *** 266,275 **** } ! void output_file(pgpkey_t *key, list_t *nnlist, list_t *nslist, list_t *snlist, list_t *sslist) { char *file_dir; FILE *filep; ! list_t *tmp_list; struct stat *sb; file_dir = (char *) malloc(3); --- 265,275 ---- } ! void output_file(pgpkey_t *key, struct list_t *nnlist, struct list_t *nslist, struct list_t *snlist, struct list_t *sslist) { char *file_dir; FILE *filep; ! struct list_t *tmp_list; struct stat *sb; + unsigned int tmp_size; file_dir = (char *) malloc(3); *************** *** 293,305 **** fprintf(filep, "Signatures to this key:\n"); ! tmp_list = list_union(nslist, sslist); print_list(filep, tmp_list); ! fprintf(filep, " Total: %u signature%s to this key from this set.\n\n", tmp_list->size, ((tmp_list->size == 1)?"":"s")); list_free(tmp_list); fprintf(filep, "Signatures from this key:\n"); ! tmp_list = list_union(snlist, sslist); print_list(filep, tmp_list); ! fprintf(filep, " Total: %u signature%s from this key to this set.\n\n", tmp_list->size, ((tmp_list->size == 1)?"":"s")); list_free(tmp_list); --- 293,307 ---- fprintf(filep, "Signatures to this key:\n"); ! tmp_list = list_union(nslist, sslist, &pgpkey_compare); print_list(filep, tmp_list); ! tmp_size = list_size(tmp_list); ! fprintf(filep, " Total: %u signature%s to this key from this set.\n\n", tmp_size, ((tmp_size == 1)?"":"s")); list_free(tmp_list); fprintf(filep, "Signatures from this key:\n"); ! tmp_list = list_union(snlist, sslist, &pgpkey_compare); print_list(filep, tmp_list); ! tmp_size = list_size(tmp_list); ! fprintf(filep, " Total: %u signature%s from this key to this set.\n\n", tmp_size, ((tmp_size == 1)?"":"s")); list_free(tmp_list); *************** *** 308,324 **** fprintf(filep, "This key has not signed, nor been signed by:\n"); print_list(filep, nnlist); ! fprintf(filep, " Total: %u key%s in this set.\n\n", nnlist->size, ((nnlist->size == 1)?"":"s")); fprintf(filep, "This key has not signed, but has been signed by:\n"); print_list(filep, nslist); ! fprintf(filep, " Total: %u key%s in this set.\n\n", nslist->size, ((nslist->size == 1)?"":"s")); fprintf(filep, "This key has signed, but has not been signed by:\n"); print_list(filep, snlist); ! fprintf(filep, " Total: %u key%s in this set.\n\n", snlist->size, ((snlist->size == 1)?"":"s")); fprintf(filep, "This key has signed and has been signed by:\n"); print_list(filep, sslist); ! fprintf(filep, " Total: %u key%s in this set.\n\n", sslist->size, ((sslist->size == 1)?"":"s")); fclose(filep); --- 310,330 ---- fprintf(filep, "This key has not signed, nor been signed by:\n"); print_list(filep, nnlist); ! tmp_size = list_size(nnlist); ! fprintf(filep, " Total: %u key%s in this set.\n\n", tmp_size, ((tmp_size == 1)?"":"s")); fprintf(filep, "This key has not signed, but has been signed by:\n"); print_list(filep, nslist); ! tmp_size = list_size(nslist); ! fprintf(filep, " Total: %u key%s in this set.\n\n", tmp_size, ((tmp_size == 1)?"":"s")); fprintf(filep, "This key has signed, but has not been signed by:\n"); print_list(filep, snlist); ! tmp_size = list_size(snlist); ! fprintf(filep, " Total: %u key%s in this set.\n\n", tmp_size, ((tmp_size == 1)?"":"s")); fprintf(filep, "This key has signed and has been signed by:\n"); print_list(filep, sslist); ! tmp_size = list_size(sslist); ! fprintf(filep, " Total: %u key%s in this set.\n\n", tmp_size, ((tmp_size == 1)?"":"s")); fclose(filep); |
|
From: Jeff B. <jb...@us...> - 2005-04-04 03:27:46
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv17131 Modified Files: Tag: JBREKER list.c list.h main.c main.h node.c Log Message: more LIST_* macro Index: list.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/list.h,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** list.h 28 Mar 2005 02:09:51 -0000 1.1.2.2 --- list.h 4 Apr 2005 03:27:36 -0000 1.1.2.3 *************** *** 38,41 **** --- 38,42 ---- void list_remove(struct list_t *, void *, int (*)(void *, void *)); struct list_t *list_resort(struct list_t *, int (*)(void *, void *)); + unsigned int list_size(struct list_t *); struct list_t *list_union(struct list_t *, struct list_t *, int (*)(void *, void *)); Index: node.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/Attic/node.c,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** node.c 20 Mar 2005 17:30:48 -0000 1.1.2.2 --- node.c 4 Apr 2005 03:27:36 -0000 1.1.2.3 *************** *** 46,72 **** { unsigned int distance; ! unsigned int last_known_size; ! list_t *traversed_keys, *tmp_keys; ! node_t *tmp_node; ! traversed_keys = list_new(&pgpkey_compare); last_known_size = 0; distance = 1; ! list_merge_list(traversed_keys, keyto->signatures); ! while(traversed_keys->size != last_known_size) { ! if(list_find_object(traversed_keys, keyfrom) != NULL) return distance; ! last_known_size = traversed_keys->size; ++distance; tmp_keys = traversed_keys; ! tmp_node = tmp_keys->head; ! traversed_keys = list_new(&pgpkey_compare); while(tmp_node != NULL) { ! list_add_object(traversed_keys, tmp_node->object); ! list_merge_list(traversed_keys, ((pgpkey_t *) tmp_node->object)->signatures); ! tmp_node = tmp_node->next; } } --- 46,72 ---- { unsigned int distance; ! unsigned int last_known_size, tmpsize; ! struct list_t *traversed_keys, *tmp_keys; ! struct node_t *tmp_node; ! traversed_keys = list_new(); last_known_size = 0; distance = 1; ! list_merge_list(traversed_keys, keyto->signatures, &pgpkey_compare); ! while((tmpsize = list_size(traversed_keys)) != last_known_size) { ! if(list_find_object(traversed_keys, keyfrom, &pgpkey_compare) != NULL) return distance; ! last_known_size = tmpsize; ++distance; tmp_keys = traversed_keys; ! tmp_node = LIST_FIRST(tmp_keys); ! traversed_keys = list_new(); while(tmp_node != NULL) { ! list_add_object(traversed_keys, tmp_node->object, &pgpkey_compare); ! list_merge_list(traversed_keys, ((pgpkey_t *) tmp_node->object)->signatures, &pgpkey_compare); ! tmp_node = LIST_NEXT(tmp_node, entries); } } *************** *** 75,86 **** } ! void pgpkey_msd(pgpkey_t *key, list_t *keys) { unsigned int distance, i, num_keys; ! node_t *iter; distance = 0; num_keys = 0; ! iter = keys->head; while(iter != NULL) --- 75,86 ---- } ! void pgpkey_msd(pgpkey_t *key, struct list_t *keys) { unsigned int distance, i, num_keys; ! struct node_t *iter; distance = 0; num_keys = 0; ! iter = LIST_FIRST(keys); while(iter != NULL) *************** *** 92,96 **** num_keys++; } ! iter = iter->next; } --- 92,96 ---- num_keys++; } ! iter = LIST_NEXT(iter, entries); } Index: main.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.c,v retrieving revision 1.2.2.5 retrieving revision 1.2.2.6 diff -C2 -d -r1.2.2.5 -r1.2.2.6 *** main.c 28 Mar 2005 02:09:51 -0000 1.2.2.5 --- main.c 4 Apr 2005 03:27:36 -0000 1.2.2.6 *************** *** 328,341 **** } ! list_t *parse_keyring() { - size_t size; keydata_t *key; pgpkey_t *public_key, *tmp_key, *tmp2_key; ! list_t *keys; int key_was_added; public_key = NULL; ! keys = list_new(&pgpkey_compare); key = keydata_new(); --- 328,340 ---- } ! struct list_t *parse_keyring() { keydata_t *key; pgpkey_t *public_key, *tmp_key, *tmp2_key; ! struct list_t *keys; int key_was_added; public_key = NULL; ! keys = list_new(); key = keydata_new(); *************** *** 349,356 **** { public_key = pgpkey_new(key->keyid, key->name); ! key_was_added = list_add_object(keys, public_key); if(key_was_added == 0) { ! tmp_key = list_find_object(keys, public_key); list_free(public_key->signatures); free(public_key->name); --- 348,355 ---- { public_key = pgpkey_new(key->keyid, key->name); ! key_was_added = list_add_object(keys, public_key, &pgpkey_compare); if(key_was_added == 0) { ! tmp_key = list_find_object(keys, public_key, &pgpkey_compare); list_free(public_key->signatures); free(public_key->name); *************** *** 367,374 **** { tmp_key = pgpkey_new(key->keyid, key->name); ! key_was_added = list_add_object(keys, tmp_key); if(key_was_added == 0) { ! tmp2_key = list_find_object(keys, tmp_key); list_free(tmp_key->signatures); free(tmp_key->name); --- 366,373 ---- { tmp_key = pgpkey_new(key->keyid, key->name); ! key_was_added = list_add_object(keys, tmp_key, &pgpkey_compare); if(key_was_added == 0) { ! tmp2_key = list_find_object(keys, tmp_key, &pgpkey_compare); list_free(tmp_key->signatures); free(tmp_key->name); *************** *** 377,381 **** tmp_key = tmp2_key; } ! list_add_object(public_key->signatures, tmp_key); } } --- 376,380 ---- tmp_key = tmp2_key; } ! list_add_object(public_key->signatures, tmp_key, &pgpkey_compare); } } *************** *** 388,402 **** } ! void print_list(FILE *filep, list_t *list) { ! node_t *node; ! ! node = list->head; ! while(node != NULL) ! { fprintf(filep, " %s %s\n", ((pgpkey_t *) node->object)->keyid + 8, ((pgpkey_t *) node->object)->name); - node = node->next; - } return; --- 387,396 ---- } ! void print_list(FILE *filep, struct list_t *list) { ! struct node_t *node; ! LIST_FOREACH(node, list, entries) fprintf(filep, " %s %s\n", ((pgpkey_t *) node->object)->keyid + 8, ((pgpkey_t *) node->object)->name); return; *************** *** 412,426 **** } ! int wot_compare(void *obj1, void *obj2) { ! list_t *wot1 = obj1; ! list_t *wot2 = obj2; if(wot1 == wot2) return 0; ! if(wot1->size == wot2->size) ! return wot1->compare(wot1->head->object, wot2->head->object); ! return wot2->size - wot1->size; } --- 406,421 ---- } ! int wot_compare(void *obj1, void *obj2, int (*compare)(void *, void *)) { ! struct list_t *wot1 = obj1; ! struct list_t *wot2 = obj2; ! unsigned int wot1size, wot2size; if(wot1 == wot2) return 0; ! if((wot1size = list_size(wot1)) == (wot2size = list_size(wot2))) ! return compare(LIST_FIRST(wot1)->object, LIST_FIRST(wot2)->object); ! return wot2size - wot1size; } Index: list.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/list.c,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** list.c 28 Mar 2005 02:09:51 -0000 1.1.2.2 --- list.c 4 Apr 2005 03:27:36 -0000 1.1.2.3 *************** *** 216,219 **** --- 216,229 ---- } + unsigned int list_size(struct list_t *list) + { + unsigned int i = 0; + struct node_t *iter; + + LIST_FOREACH(iter, list, entries) + ++i; + + return i; + } /* Return * NULL on error Index: main.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.h,v retrieving revision 1.1.2.3 retrieving revision 1.1.2.4 diff -C2 -d -r1.1.2.3 -r1.1.2.4 *** main.h 28 Mar 2005 02:09:51 -0000 1.1.2.3 --- main.h 4 Apr 2005 03:27:36 -0000 1.1.2.4 *************** *** 31,35 **** void print_list(FILE *, struct list_t *); void usage(void); ! int wot_compare(void *, void *); #endif --- 31,35 ---- void print_list(FILE *, struct list_t *); void usage(void); ! int wot_compare(void *, void *, int (*)(void *, void *)); #endif |
|
From: Jeff B. <jb...@us...> - 2005-03-30 05:20:27
|
Update of /cvsroot/digraphanalysis/www In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv3322 Added Files: index.html Log Message: initial import --- NEW FILE: index.html --- <html> <head> <title> Digraph Analysis </title> </head> <body> <div id="header"> Digraph Analysis </div> <div id="menu"> <a href="http://www.sourceforge.net/projects/digraphanalysis/">project</a> </div> <div id="main"> <div class="entry"> <div class="entry_header"> 2005.04.01 :: Welcome all! </div> Development is going along slow and steady... There are still a few things to do before we enter beta development. <div class="entry_footer"> Jeff Breker </div> </div> </div> <div id="footer"> </div> </body> </html> |
|
From: Jeff B. <jb...@us...> - 2005-03-28 02:10:00
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv29420 Modified Files: Tag: JBREKER list.c list.h main.c main.h node.h Log Message: more LIST_* usage conversion Index: node.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/Attic/node.h,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** node.h 20 Mar 2005 17:30:48 -0000 1.1.2.2 --- node.h 28 Mar 2005 02:09:51 -0000 1.1.2.3 *************** *** 17,21 **** #ifndef _NODE_H_ - #define _NODE_H_ --- 17,20 ---- *************** *** 27,31 **** float msd; char *name; ! list_t *signatures; }; --- 26,30 ---- float msd; char *name; ! struct list_t *signatures; }; *************** *** 35,39 **** int pgpkey_compare_msd(void *, void *); unsigned int pgpkey_distance(pgpkey_t *, pgpkey_t *); ! void pgpkey_msd(pgpkey_t *, list_t *); pgpkey_t *pgpkey_new(char *, char *); --- 34,38 ---- int pgpkey_compare_msd(void *, void *); unsigned int pgpkey_distance(pgpkey_t *, pgpkey_t *); ! void pgpkey_msd(pgpkey_t *, struct list_t *); pgpkey_t *pgpkey_new(char *, char *); Index: list.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/list.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** list.h 28 Mar 2005 00:48:23 -0000 1.1.2.1 --- list.h 28 Mar 2005 02:09:51 -0000 1.1.2.2 *************** *** 17,23 **** #ifndef _LIST_H_ - #define _LIST_H_ struct node_t { --- 17,24 ---- #ifndef _LIST_H_ #define _LIST_H_ + #include <sys/queue.h> + struct node_t { *************** *** 28,41 **** LIST_HEAD(list_t, node_t); ! int list_add_object(struct list_t *, void *); ! struct list_t *list_duplicate(struct list_t *); ! void *list_find_object(struct list_t *, void *); void list_free(struct list_t *); ! struct list_t *list_merge_list(struct list_t *, struct list_t *); ! struct list_t *list_new(int (*) (void *, void *)); ! struct node_t *list_new_node(void *, struct node_t *, struct node_t *); ! void list_remove(struct list_t *, void *); ! struct list_t *list_resort(struct list_t *); ! struct list_t *list_union(struct list_t *, struct list_t *); #endif --- 29,42 ---- LIST_HEAD(list_t, node_t); ! int 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 *)); ! struct list_t *list_union(struct list_t *, struct list_t *, int (*)(void *, void *)); #endif Index: list.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/list.c,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** list.c 28 Mar 2005 00:48:22 -0000 1.1.2.1 --- list.c 28 Mar 2005 02:09:51 -0000 1.1.2.2 *************** *** 16,19 **** --- 16,21 ---- */ + #include <sys/queue.h> + #include <errno.h> #include <stdio.h> *************** *** 29,33 **** * This might be more usefull if we returned the object that is in the list or NULL on error */ ! int list_add_object(struct list_t *list, void *object) { int i; --- 31,35 ---- * This might be more usefull if we returned the object that is in the list or NULL on error */ ! int list_add_object(struct list_t *list, void *object, int (*compare)(void *, void *)) { int i; *************** *** 41,56 **** return 1; } ! while(iter->next != NULL) { ! if((i = list->compare(object, iter->object)) < 0) { ! if((iter = list_new_node(object, iter, iter->prev)) == NULL) ! return -1; ! if(iter->prev == NULL) ! list->head = iter; else ! iter->prev->next = iter; ! iter->next->prev = iter; ! ++(list->size); return 1; } --- 43,54 ---- return 1; } ! while(LIST_NEXT(iter, entries) != NULL) { ! if((i = compare(object, iter->object)) < 0) { ! if(iter == LIST_FIRST(list)) ! LIST_INSERT_HEAD(list, list_new_node(object), entries); else ! LIST_INSERT_BEFORE(iter, list_new_node(object), entries); return 1; } *************** *** 58,73 **** if(i == 0) return 0; ! iter = iter->next; } ! if((i = list->compare(object, iter->object)) < 0) { ! if((iter = list_new_node(object, iter, iter->prev)) == NULL) ! return -1; ! if(iter->prev == NULL) ! list->head = iter; else ! iter->prev->next = iter; ! iter->next->prev = iter; ! ++(list->size); return 1; } --- 56,67 ---- if(i == 0) return 0; ! iter = LIST_NEXT(iter, entries); } ! if((i = compare(object, iter->object)) < 0) { ! if(iter == LIST_FIRST(list)) ! LIST_INSERT_HEAD(list, list_new_node(object), entries); else ! LIST_INSERT_BEFORE(iter, list_new_node(object), entries); return 1; } *************** *** 75,82 **** if(i == 0) return 0; ! if((iter->next = list->tail = list_new_node(object, NULL, iter)) == NULL) ! return -1; ! ++(list->size); ! return 1; } --- 69,73 ---- if(i == 0) return 0; ! LIST_INSERT_AFTER(iter, list_new_node(object), entries); return 1; } *************** *** 84,94 **** /* Returns NULL on error */ ! struct list_t *list_duplicate(struct list_t *list) { struct list_t *ret_list; ! if((ret_list = list_new(list->compare)) == NULL) return NULL; ! if(list_merge_list(ret_list, list) == NULL) return NULL; --- 75,85 ---- /* 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; *************** *** 96,136 **** } ! void list_free(struct list_t *list) { ! node_t *iter; ! iter = list->head; while(iter != NULL) { ! list->head = iter->next; ! free(iter); ! iter = list->head; } ! free(list); ! list = NULL; ! ! return; } ! void *list_find_object(struct list_t *list, void *object) { ! int i; ! node_t *iter; ! iter = list->head; while(iter != NULL) { ! if((i = list->compare(iter->object, object)) == 0) ! return iter->object; ! else ! if(i > 0) ! break; ! iter = iter->next; } ! return NULL; } --- 87,127 ---- } ! 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); } ! free(list); ! list = NULL; ! ! return; } *************** *** 139,153 **** * list1 on success */ ! struct list_t *list_merge_list(struct list_t *list1, struct list_t *list2) { ! node_t *iter; ! iter = list2->head; while(iter != NULL) { ! if(list_add_object(list1, iter->object) == -1) return NULL; ! iter = iter->next; } --- 130,144 ---- * 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; ! iter = LIST_FIRST(list2); while(iter != NULL) { ! if(list_add_object(list1, iter->object, compare) == -1) return NULL; ! iter = LIST_NEXT(iter, entries); } *************** *** 157,171 **** /* Returns NULL on error */ ! struct list_t *list_new(int (*compare) (void *, void *)) { struct list_t *list; ! if((list = (stuct list_t *) malloc(sizeof(struct list_t))) == NULL) return NULL; - list->compare = compare; - list->size = 0; - list->head = list->tail = NULL; - return list; } --- 148,158 ---- /* 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; return list; } *************** *** 173,210 **** /* Returns NULL on error */ ! node_t *list_new_node(void *object, node_t *next, node_t *prev) { ! node_t *node; ! if((node = (node_t *) malloc(sizeof(node_t))) == NULL) return NULL; node->object = object; - node->next = next; - node->prev = prev; return node; } ! void list_remove(struct list_t *list, void *object) { ! node_t *iter; int i; ! iter = list->head; while(iter != NULL) { ! if((i = list->compare(iter->object, object)) == 0) { ! --(list->size); ! if(iter->next != NULL) ! iter->next->prev = iter->prev; ! else ! list->tail = iter->prev; ! if(iter->prev != NULL) ! iter->prev->next = iter->next; ! else ! list->head = iter->next; free(iter); break; --- 160,187 ---- /* 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; node->object = object; return node; } ! 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) { ! LIST_REMOVE(iter, entries); free(iter); break; *************** *** 213,217 **** if(i < 0) break; ! iter = iter->next; } --- 190,194 ---- if(i < 0) break; ! iter = LIST_NEXT(iter, entries); } *************** *** 220,237 **** /* Optimize with quicksort or heapsort I think */ ! struct list_t *list_resort(struct list_t *list) { ! node_t *iter, *tmpiter; ! iter = list->head; ! list->head = list->tail = NULL; ! list->size = 0; while(iter != NULL) { ! if(list_add_object(list, iter->object) == -1) return NULL; tmpiter = iter; ! iter = iter->next; free(tmpiter); } --- 197,213 ---- /* 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) { ! if(list_add_object(list, iter->object, compare) == -1) return NULL; tmpiter = iter; ! iter = LIST_NEXT(iter, entries); free(tmpiter); } *************** *** 244,256 **** * list on success */ ! struct list_t *list_union(struct list_t *list1, struct list_t *list2) { struct list_t *list; ! if((list = list_new(list1->compare)) == NULL) return NULL; ! if(list_merge_list(list, list1) == NULL) return NULL; ! return list_merge_list(list, list2); } --- 220,232 ---- * 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) return NULL; ! if(list_merge_list(list, list1, compare) == NULL) return NULL; ! return list_merge_list(list, list2, compare); } Index: main.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.c,v retrieving revision 1.2.2.4 retrieving revision 1.2.2.5 diff -C2 -d -r1.2.2.4 -r1.2.2.5 *** main.c 20 Mar 2005 17:42:55 -0000 1.2.2.4 --- main.c 28 Mar 2005 02:09:51 -0000 1.2.2.5 *************** *** 31,48 **** #include "nodedata.h" ! int analyze_key(pgpkey_t *key, list_t *keys, list_t *nnlist, list_t *nslist, list_t *snlist, list_t *sslist) { ! node_t *iter; ! iter = keys->head; pgpkey_msd(key, keys); while(iter != NULL) { ! if(list_find_object(key->signatures, iter->object) != NULL) { ! if(list_find_object(((pgpkey_t *) iter->object)->signatures, key) != NULL) { ! if(list_add_object(sslist, iter->object) == -1) { return -1; --- 31,48 ---- #include "nodedata.h" ! int analyze_key(pgpkey_t *key, struct list_t *keys, struct list_t *nnlist, struct list_t *nslist, struct list_t *snlist, struct list_t *sslist) { ! struct node_t *iter; ! iter = LIST_FIRST(keys); pgpkey_msd(key, keys); while(iter != NULL) { ! if(list_find_object(key->signatures, iter->object, pgpkey_compare) != NULL) { ! if(list_find_object(((pgpkey_t *) iter->object)->signatures, key, pgpkey_compare) != NULL) { ! if(list_add_object(sslist, iter->object, pgpkey_compare) == -1) { return -1; *************** *** 51,55 **** else { ! if(list_add_object(nslist, iter->object) == -1) { return -1; --- 51,55 ---- else { ! if(list_add_object(nslist, iter->object, pgpkey_compare) == -1) { return -1; *************** *** 59,65 **** else { ! if(list_find_object(((pgpkey_t *) iter->object)->signatures, key) != NULL) { ! if(list_add_object(snlist, iter->object) == -1) { return -1; --- 59,65 ---- else { ! if(list_find_object(((pgpkey_t *) iter->object)->signatures, key, pgpkey_compare) != NULL) { ! if(list_add_object(snlist, iter->object, pgpkey_compare) == -1) { return -1; *************** *** 68,72 **** else { ! if(list_add_object(nnlist, iter->object) == -1) { return -1; --- 68,72 ---- else { ! if(list_add_object(nnlist, iter->object, pgpkey_compare) == -1) { return -1; *************** *** 74,78 **** } } ! iter = iter->next; } --- 74,78 ---- } } ! iter = LIST_NEXT(iter, entries); } Index: main.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.h,v retrieving revision 1.1.2.2 retrieving revision 1.1.2.3 diff -C2 -d -r1.1.2.2 -r1.1.2.3 *** main.h 20 Mar 2005 17:30:48 -0000 1.1.2.2 --- main.h 28 Mar 2005 02:09:51 -0000 1.1.2.3 *************** *** 25,33 **** #include "node.h" ! int analyze_key(pgpkey_t *, list_t *, list_t *, list_t *, list_t *, list_t *); ! int do_analysis(list_t *, char *); ! void output_file(pgpkey_t *, list_t *, list_t *, list_t *, list_t *); ! list_t *parse_keyring(void); ! void print_list(FILE *, list_t *); void usage(void); int wot_compare(void *, void *); --- 25,33 ---- #include "node.h" ! int analyze_key(pgpkey_t *, struct list_t *, struct list_t *, struct list_t *, struct list_t *, struct list_t *); ! int do_analysis(struct list_t *, char *); ! void output_file(pgpkey_t *, struct list_t *, struct list_t *, struct list_t *, struct list_t *); ! struct list_t *parse_keyring(void); ! void print_list(FILE *, struct list_t *); void usage(void); int wot_compare(void *, void *); |
|
From: Jeff B. <jb...@us...> - 2005-03-28 00:48:31
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv13798/src Modified Files: Tag: JBREKER list.c list.h Log Message: implement LIST_* macros... Index: list.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/list.h,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** list.h 18 Mar 2005 20:42:22 -0000 1.1 --- list.h 28 Mar 2005 00:48:23 -0000 1.1.2.1 *************** *** 20,49 **** #define _LIST_H_ ! struct node_s { void *object; ! struct node_s *next, *prev; ! }; ! ! struct list_s ! { ! int (*compare) (void *, void *); ! unsigned int size; ! struct node_s *head, *tail; }; ! typedef struct list_s list_t; ! typedef struct node_s node_t; ! int list_add_object(list_t *, void *); ! list_t *list_duplicate(list_t *); ! void *list_find_object(list_t *, void *); ! void list_free(list_t *); ! list_t *list_merge_list(list_t *, list_t *); ! list_t *list_new(int (*) (void *, void *)); ! node_t *list_new_node(void *, node_t *, node_t *); ! void list_remove(list_t *, void *); ! list_t *list_resort(list_t *); ! list_t *list_union(list_t *, list_t *); #endif --- 20,41 ---- #define _LIST_H_ ! struct node_t { void *object; ! LIST_ENTRY(node_t) entries; }; ! LIST_HEAD(list_t, node_t); ! int list_add_object(struct list_t *, void *); ! struct list_t *list_duplicate(struct list_t *); ! void *list_find_object(struct list_t *, void *); ! void list_free(struct list_t *); ! struct list_t *list_merge_list(struct list_t *, struct list_t *); ! struct list_t *list_new(int (*) (void *, void *)); ! struct node_t *list_new_node(void *, struct node_t *, struct node_t *); ! void list_remove(struct list_t *, void *); ! struct list_t *list_resort(struct list_t *); ! struct list_t *list_union(struct list_t *, struct list_t *); #endif Index: list.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/list.c,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** list.c 18 Mar 2005 20:42:22 -0000 1.1 --- list.c 28 Mar 2005 00:48:22 -0000 1.1.2.1 *************** *** 29,45 **** * This might be more usefull if we returned the object that is in the list or NULL on error */ ! int list_add_object(list_t *list, void *object) { int i; ! node_t *iter; ! iter = list->head; ! if(iter == NULL) { ! if((list->head = list->tail = list_new_node(object, NULL, NULL)) == NULL) ! return -1; ! ++(list->size); ! return 1; } --- 29,42 ---- * This might be more usefull if we returned the object that is in the list or NULL on error */ ! int list_add_object(struct list_t *list, void *object) { int i; ! struct node_t *iter; ! iter = LIST_FIRST(list); ! if(LIST_EMPTY(list)) { ! LIST_INSERT_HEAD(list, list_new_node(object), entries); return 1; } *************** *** 87,93 **** /* Returns NULL on error */ ! list_t *list_duplicate(list_t *list) { ! list_t *ret_list; if((ret_list = list_new(list->compare)) == NULL) --- 84,90 ---- /* Returns NULL on error */ ! struct list_t *list_duplicate(struct list_t *list) { ! struct list_t *ret_list; if((ret_list = list_new(list->compare)) == NULL) *************** *** 99,103 **** } ! void list_free(list_t *list) { node_t *iter; --- 96,100 ---- } ! void list_free(struct list_t *list) { node_t *iter; *************** *** 118,122 **** } ! void *list_find_object(list_t *list, void *object) { int i; --- 115,119 ---- } ! void *list_find_object(struct list_t *list, void *object) { int i; *************** *** 142,146 **** * list1 on success */ ! list_t *list_merge_list(list_t *list1, list_t *list2) { node_t *iter; --- 139,143 ---- * list1 on success */ ! struct list_t *list_merge_list(struct list_t *list1, struct list_t *list2) { node_t *iter; *************** *** 160,168 **** /* Returns NULL on error */ ! list_t *list_new(int (*compare) (void *, void *)) { ! list_t *list; ! if((list = (list_t *) malloc(sizeof(list_t))) == NULL) return NULL; --- 157,165 ---- /* Returns NULL on error */ ! struct list_t *list_new(int (*compare) (void *, void *)) { ! struct list_t *list; ! if((list = (stuct list_t *) malloc(sizeof(struct list_t))) == NULL) return NULL; *************** *** 190,194 **** } ! void list_remove(list_t *list, void *object) { node_t *iter; --- 187,191 ---- } ! void list_remove(struct list_t *list, void *object) { node_t *iter; *************** *** 223,227 **** /* Optimize with quicksort or heapsort I think */ ! list_t *list_resort(list_t *list) { node_t *iter, *tmpiter; --- 220,224 ---- /* Optimize with quicksort or heapsort I think */ ! struct list_t *list_resort(struct list_t *list) { node_t *iter, *tmpiter; *************** *** 247,253 **** * list on success */ ! list_t *list_union(list_t *list1, list_t *list2) { ! list_t *list; if((list = list_new(list1->compare)) == NULL) --- 244,250 ---- * list on success */ ! struct list_t *list_union(struct list_t *list1, struct list_t *list2) { ! struct list_t *list; if((list = list_new(list1->compare)) == NULL) |
|
From: Jeff B. <jb...@us...> - 2005-03-20 17:43:06
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv23876/src Modified Files: Tag: JBREKER main.c Added Files: Tag: JBREKER nodedata.c nodedata.h Removed Files: Tag: JBREKER keydata.c keydata.h Log Message: Do some renaming from keyringanalysis to digraphanalysis. --- keydata.c DELETED --- --- keydata.h DELETED --- --- NEW FILE: nodedata.h --- /* $Id: nodedata.h,v 1.1.2.1 2005/03/20 17:42:55 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 _NODEDATA_H_ #define _NODEDATA_H_ #include <stdio.h> struct keydata_s { char *type; char *keyid; char *name; }; typedef struct keydata_s keydata_t; keydata_t *keydata_new(void); keydata_t *keydata_read(void); #endif /* _NODEDATA_H_ */ Index: main.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.c,v retrieving revision 1.2.2.3 retrieving revision 1.2.2.4 diff -C2 -d -r1.2.2.3 -r1.2.2.4 *** main.c 20 Mar 2005 17:30:48 -0000 1.2.2.3 --- main.c 20 Mar 2005 17:42:55 -0000 1.2.2.4 *************** *** 26,33 **** #include <unistd.h> - #include "keydata.h" #include "list.h" #include "main.h" #include "node.h" int analyze_key(pgpkey_t *key, list_t *keys, list_t *nnlist, list_t *nslist, list_t *snlist, list_t *sslist) --- 26,33 ---- #include <unistd.h> #include "list.h" #include "main.h" #include "node.h" + #include "nodedata.h" int analyze_key(pgpkey_t *key, list_t *keys, list_t *nnlist, list_t *nslist, list_t *snlist, list_t *sslist) --- NEW FILE: nodedata.c --- /* $Id: nodedata.c,v 1.1.2.1 2005/03/20 17:42:55 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 <ctype.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include "nodedata.h" /* Returns NULL on error. */ keydata_t *keydata_new() { keydata_t *key; if((key = (keydata_t *) malloc(sizeof(keydata_t))) == NULL) return NULL; if((key->keyid = (char *) malloc(17)) == NULL) return NULL; key->name = NULL; if((key->type = (char *) malloc(4)) == NULL) return NULL; return key; } /* Returns NULL on error */ keydata_t *keydata_read() { int c; keydata_t *key; int tmppipe[2]; size_t i; if((key = keydata_new()) == NULL) return NULL; for(i = 0; i < 3; ++i) { while(((c = fgetc(stdin)) == '\n') && (i == 0)); if((c == '\n') && (i != 0)) { while(((c = fgetc(stdin)) != '\n') && (c != EOF)); if(c == EOF) strncpy(key->type, "eof", 4); else strncpy(key->type, "nul", 4); return key; } if(c == EOF) { strncpy(key->type, "eof", 4); return key; } *(key->type + i) = (char) c; } *(key->type + 3) = '\0'; if(strcmp(key->type, "tru") == 0) { while(((c = fgetc(stdin)) != '\n') && (c != EOF)); if(c == EOF) strncpy(key->type, "eof", 4); return key; } if(strcmp(key->type, "sub") == 0) { while(((c = fgetc(stdin)) != '\n') && (c != EOF)); if(c == EOF) strncpy(key->type, "eof", 4); return key; } if((strcmp(key->type, "pub") != 0) && (strcmp(key->type, "sig") != 0)) { while(((c = fgetc(stdin)) != '\n') && (c != EOF)); if(c == EOF) strncpy(key->type, "eof", 4); return key; } i = 0; while(i < 4) { c = fgetc(stdin); if(c == EOF) { strncpy(key->type, "eof", 4); return key; } if(c == ':') ++i; } for(i = 0; i < 16; ++i) { c = fgetc(stdin); if(c == EOF) { strncpy(key->type, "eof", 4); return key; } c = toupper(c); if(!isxdigit(c)) { while(((c = fgetc(stdin)) != '\n') && (c != EOF)); if(c == EOF) strncpy(key->type, "eof", 4); else strncpy(key->type, "nul", 4); return key; } *(key->keyid + i) = (char) c; *(key->keyid + i + 1) = '\0'; } i = 0; while(i < 5) { c = fgetc(stdin); if(c == EOF) { strncpy(key->type, "eof", 4); return key; } if(c == ':') ++i; } pipe(tmppipe); c = fgetc(stdin); if(c == EOF) { strncpy(key->type, "eof", 4); return key; } i = 1; while(c != ':') { ++i; if(i == 0) { while(((c = fgetc(stdin)) != '\n') && (c != EOF)); if(c == EOF) strncpy(key->type, "eof", 4); else strncpy(key->type, "nul", 4); return key; } write(tmppipe[1], &c, 1); c = fgetc(stdin); if(c == EOF) { strncpy(key->type, "eof", 4); return key; } } if((key->name = (char *) malloc(i)) == NULL) return NULL; read(tmppipe[0], key->name, i - 1); close(tmppipe[0]); close(tmppipe[1]); *(key->name + i - 1) = '\0'; if(strcmp(key->name, "[User ID not found]") == 0) { while(((c = fgetc(stdin)) != '\n') && (c != EOF)); if(c == EOF) strncpy(key->type, "eof", 4); else strncpy(key->type, "nul", 4); return key; } i = 0; while(i < 1) { c = fgetc(stdin); if(c == EOF) { strncpy(key->type, "eof", 4); return key; } if(c == ':') ++i; } return key; } |
|
From: Jeff B. <jb...@us...> - 2005-03-20 17:35:41
|
Update of /cvsroot/digraphanalysis/CVSROOT In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv19062 Modified Files: loginfo Log Message: remove version info from mailings add branch info Index: loginfo =================================================================== RCS file: /cvsroot/digraphanalysis/CVSROOT/loginfo,v retrieving revision 1.2 retrieving revision 1.3 diff -C2 -d -r1.2 -r1.3 *** loginfo 19 Mar 2005 03:22:13 -0000 1.2 --- loginfo 20 Mar 2005 17:35:33 -0000 1.3 *************** *** 23,25 **** # ! DEFAULT /cvsroot/sitedocs/CVSROOT/cvstools/syncmail %{sVv} dig...@li... --- 23,25 ---- # ! DEFAULT /cvsroot/sitedocs/CVSROOT/cvstools/syncmail %{st} dig...@li... |
|
From: Jeff B. <jb...@us...> - 2005-03-20 17:30:58
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv15960/src Modified Files: Tag: JBREKER main.c main.h node.c node.h Log Message: #include "pgpkey.h" -> #include "node.h" Index: node.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/Attic/node.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** node.h 20 Mar 2005 17:26:47 -0000 1.1.2.1 --- node.h 20 Mar 2005 17:30:48 -0000 1.1.2.2 *************** *** 16,22 **** */ ! #ifndef _PGPKEY_H_ ! #define _PGPKEY_H_ #include "list.h" --- 16,22 ---- */ ! #ifndef _NODE_H_ ! #define _NODE_H_ #include "list.h" *************** *** 38,40 **** pgpkey_t *pgpkey_new(char *, char *); ! #endif --- 38,40 ---- pgpkey_t *pgpkey_new(char *, char *); ! #endif /* _NODE_H_ */ Index: node.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/Attic/node.c,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** node.c 20 Mar 2005 17:26:47 -0000 1.1.2.1 --- node.c 20 Mar 2005 17:30:48 -0000 1.1.2.2 *************** *** 21,25 **** #include "list.h" ! #include "pgpkey.h" int pgpkey_compare(void *key1, void *key2) --- 21,25 ---- #include "list.h" ! #include "node.h" int pgpkey_compare(void *key1, void *key2) Index: main.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.c,v retrieving revision 1.2.2.2 retrieving revision 1.2.2.3 diff -C2 -d -r1.2.2.2 -r1.2.2.3 *** main.c 20 Mar 2005 04:32:29 -0000 1.2.2.2 --- main.c 20 Mar 2005 17:30:48 -0000 1.2.2.3 *************** *** 29,33 **** #include "list.h" #include "main.h" ! #include "pgpkey.h" int analyze_key(pgpkey_t *key, list_t *keys, list_t *nnlist, list_t *nslist, list_t *snlist, list_t *sslist) --- 29,33 ---- #include "list.h" #include "main.h" ! #include "node.h" int analyze_key(pgpkey_t *key, list_t *keys, list_t *nnlist, list_t *nslist, list_t *snlist, list_t *sslist) Index: main.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.h,v retrieving revision 1.1.2.1 retrieving revision 1.1.2.2 diff -C2 -d -r1.1.2.1 -r1.1.2.2 *** main.h 20 Mar 2005 04:09:14 -0000 1.1.2.1 --- main.h 20 Mar 2005 17:30:48 -0000 1.1.2.2 *************** *** 23,27 **** #include "list.h" ! #include "pgpkey.h" int analyze_key(pgpkey_t *, list_t *, list_t *, list_t *, list_t *, list_t *); --- 23,27 ---- #include "list.h" ! #include "node.h" int analyze_key(pgpkey_t *, list_t *, list_t *, list_t *, list_t *, list_t *); |
|
From: Jeff B. <jb...@us...> - 2005-03-20 17:26:57
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12849/src Added Files: Tag: JBREKER node.c node.h Removed Files: Tag: JBREKER pgpkey.c pgpkey.h Log Message: Do some renaming from keyringanalysis to digraphanalysis. --- pgpkey.h DELETED --- --- NEW FILE: node.h --- /* $Id: node.h,v 1.1.2.1 2005/03/20 17:26:47 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 _PGPKEY_H_ #define _PGPKEY_H_ #include "list.h" struct pgpkey_s { char *keyid; float msd; char *name; list_t *signatures; }; typedef struct pgpkey_s pgpkey_t; int pgpkey_compare(void *, void *); int pgpkey_compare_msd(void *, void *); unsigned int pgpkey_distance(pgpkey_t *, pgpkey_t *); void pgpkey_msd(pgpkey_t *, list_t *); pgpkey_t *pgpkey_new(char *, char *); #endif --- pgpkey.c DELETED --- --- NEW FILE: node.c --- /* $Id: node.c,v 1.1.2.1 2005/03/20 17:26:47 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 <stdlib.h> #include <string.h> #include "list.h" #include "pgpkey.h" int pgpkey_compare(void *key1, void *key2) { return strcmp(((pgpkey_t *) key1)->keyid, ((pgpkey_t *) key2)->keyid); } int pgpkey_compare_msd(void *key1, void *key2) { float tmp; tmp = ((pgpkey_t *) key1)->msd - ((pgpkey_t *) key2)->msd; if(tmp == (float) 0) return strcmp(((pgpkey_t *) key1)->keyid, ((pgpkey_t *) key2)->keyid); else if(tmp > (float) 0) return 1; else return (-1); } unsigned int pgpkey_distance(pgpkey_t *keyto, pgpkey_t *keyfrom) { unsigned int distance; unsigned int last_known_size; list_t *traversed_keys, *tmp_keys; node_t *tmp_node; traversed_keys = list_new(&pgpkey_compare); last_known_size = 0; distance = 1; list_merge_list(traversed_keys, keyto->signatures); while(traversed_keys->size != last_known_size) { if(list_find_object(traversed_keys, keyfrom) != NULL) return distance; last_known_size = traversed_keys->size; ++distance; tmp_keys = traversed_keys; tmp_node = tmp_keys->head; traversed_keys = list_new(&pgpkey_compare); while(tmp_node != NULL) { list_add_object(traversed_keys, tmp_node->object); list_merge_list(traversed_keys, ((pgpkey_t *) tmp_node->object)->signatures); tmp_node = tmp_node->next; } } return 0; } void pgpkey_msd(pgpkey_t *key, list_t *keys) { unsigned int distance, i, num_keys; node_t *iter; distance = 0; num_keys = 0; iter = keys->head; while(iter != NULL) { i = pgpkey_distance(key, (pgpkey_t *) iter->object); if(i > 0) { distance += i; num_keys++; } iter = iter->next; } key->msd = ((float) distance) / ((float) num_keys); return; } pgpkey_t *pgpkey_new(char *keyid, char *name) { pgpkey_t *pgpkey; pgpkey = (pgpkey_t *) malloc(sizeof(pgpkey_t)); pgpkey->keyid = (char *) malloc(17); strncpy(pgpkey->keyid, keyid, 16); *(pgpkey->keyid + 16) = '\0'; pgpkey->name = (char *) malloc(strlen(name) + 1); strncpy(pgpkey->name, name, strlen(name)); *(pgpkey->name + strlen(name)) = '\0'; pgpkey->signatures = list_new(&pgpkey_compare); pgpkey->msd = 0; return pgpkey; } |
|
From: Jeff B. <jb...@us...> - 2005-03-20 04:32:43
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv30948/src Modified Files: Tag: JBREKER keydata.c keydata.h main.c Log Message: More filep to stdin conversion Index: keydata.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/keydata.c,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** keydata.c 18 Mar 2005 20:42:21 -0000 1.1 --- keydata.c 20 Mar 2005 04:32:27 -0000 1.1.2.1 *************** *** 43,47 **** /* Returns NULL on error */ ! keydata_t *keydata_read(FILE *filep) { int c; --- 43,47 ---- /* Returns NULL on error */ ! keydata_t *keydata_read() { int c; *************** *** 55,62 **** for(i = 0; i < 3; ++i) { ! while(((c = fgetc(filep)) == '\n') && (i == 0)); if((c == '\n') && (i != 0)) { ! while(((c = fgetc(filep)) != '\n') && (c != EOF)); if(c == EOF) strncpy(key->type, "eof", 4); --- 55,62 ---- for(i = 0; i < 3; ++i) { ! while(((c = fgetc(stdin)) == '\n') && (i == 0)); if((c == '\n') && (i != 0)) { ! while(((c = fgetc(stdin)) != '\n') && (c != EOF)); if(c == EOF) strncpy(key->type, "eof", 4); *************** *** 75,79 **** if(strcmp(key->type, "tru") == 0) { ! while(((c = fgetc(filep)) != '\n') && (c != EOF)); if(c == EOF) strncpy(key->type, "eof", 4); --- 75,79 ---- if(strcmp(key->type, "tru") == 0) { ! while(((c = fgetc(stdin)) != '\n') && (c != EOF)); if(c == EOF) strncpy(key->type, "eof", 4); *************** *** 82,86 **** if(strcmp(key->type, "sub") == 0) { ! while(((c = fgetc(filep)) != '\n') && (c != EOF)); if(c == EOF) strncpy(key->type, "eof", 4); --- 82,86 ---- if(strcmp(key->type, "sub") == 0) { ! while(((c = fgetc(stdin)) != '\n') && (c != EOF)); if(c == EOF) strncpy(key->type, "eof", 4); *************** *** 89,93 **** if((strcmp(key->type, "pub") != 0) && (strcmp(key->type, "sig") != 0)) { ! while(((c = fgetc(filep)) != '\n') && (c != EOF)); if(c == EOF) strncpy(key->type, "eof", 4); --- 89,93 ---- if((strcmp(key->type, "pub") != 0) && (strcmp(key->type, "sig") != 0)) { ! while(((c = fgetc(stdin)) != '\n') && (c != EOF)); if(c == EOF) strncpy(key->type, "eof", 4); *************** *** 97,101 **** while(i < 4) { ! c = fgetc(filep); if(c == EOF) { --- 97,101 ---- while(i < 4) { ! c = fgetc(stdin); if(c == EOF) { *************** *** 108,112 **** for(i = 0; i < 16; ++i) { ! c = fgetc(filep); if(c == EOF) { --- 108,112 ---- for(i = 0; i < 16; ++i) { ! c = fgetc(stdin); if(c == EOF) { *************** *** 117,121 **** if(!isxdigit(c)) { ! while(((c = fgetc(filep)) != '\n') && (c != EOF)); if(c == EOF) strncpy(key->type, "eof", 4); --- 117,121 ---- if(!isxdigit(c)) { ! while(((c = fgetc(stdin)) != '\n') && (c != EOF)); if(c == EOF) strncpy(key->type, "eof", 4); *************** *** 130,134 **** while(i < 5) { ! c = fgetc(filep); if(c == EOF) { --- 130,134 ---- while(i < 5) { ! c = fgetc(stdin); if(c == EOF) { *************** *** 140,144 **** } pipe(tmppipe); ! c = fgetc(filep); if(c == EOF) { --- 140,144 ---- } pipe(tmppipe); ! c = fgetc(stdin); if(c == EOF) { *************** *** 152,156 **** if(i == 0) { ! while(((c = fgetc(filep)) != '\n') && (c != EOF)); if(c == EOF) strncpy(key->type, "eof", 4); --- 152,156 ---- if(i == 0) { ! while(((c = fgetc(stdin)) != '\n') && (c != EOF)); if(c == EOF) strncpy(key->type, "eof", 4); *************** *** 160,164 **** } write(tmppipe[1], &c, 1); ! c = fgetc(filep); if(c == EOF) { --- 160,164 ---- } write(tmppipe[1], &c, 1); ! c = fgetc(stdin); if(c == EOF) { *************** *** 175,179 **** if(strcmp(key->name, "[User ID not found]") == 0) { ! while(((c = fgetc(filep)) != '\n') && (c != EOF)); if(c == EOF) strncpy(key->type, "eof", 4); --- 175,179 ---- if(strcmp(key->name, "[User ID not found]") == 0) { ! while(((c = fgetc(stdin)) != '\n') && (c != EOF)); if(c == EOF) strncpy(key->type, "eof", 4); *************** *** 185,189 **** while(i < 1) { ! c = fgetc(filep); if(c == EOF) { --- 185,189 ---- while(i < 1) { ! c = fgetc(stdin); if(c == EOF) { Index: keydata.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/keydata.h,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** keydata.h 18 Mar 2005 20:42:22 -0000 1.1 --- keydata.h 20 Mar 2005 04:32:28 -0000 1.1.2.1 *************** *** 32,36 **** keydata_t *keydata_new(void); ! keydata_t *keydata_read(FILE *); #endif --- 32,36 ---- keydata_t *keydata_new(void); ! keydata_t *keydata_read(void); #endif Index: main.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.c,v retrieving revision 1.2.2.1 retrieving revision 1.2.2.2 diff -C2 -d -r1.2.2.1 -r1.2.2.2 *** main.c 20 Mar 2005 04:09:14 -0000 1.2.2.1 --- main.c 20 Mar 2005 04:32:29 -0000 1.2.2.2 *************** *** 331,336 **** { size_t size; - char *command1 = "gpg --list-sigs --with-colons --no-default-keyring --keyring "; - char *command2; keydata_t *key; pgpkey_t *public_key, *tmp_key, *tmp2_key; --- 331,334 ---- *************** *** 344,348 **** while(strcmp(key->type, "nul") == 0) { ! key = keydata_read(stdin); } while(strcmp(key->type, "eof") != 0) --- 342,346 ---- while(strcmp(key->type, "nul") == 0) { ! key = keydata_read(); } while(strcmp(key->type, "eof") != 0) *************** *** 384,388 **** if(strcmp(key->type, "sub") == 0) public_key = NULL; ! key = keydata_read(stdin); } --- 382,386 ---- if(strcmp(key->type, "sub") == 0) public_key = NULL; ! key = keydata_read(); } |
|
From: Jeff B. <jb...@us...> - 2005-03-20 04:09:24
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv16991/src Modified Files: Tag: JBREKER main.c main.h Log Message: Read only from stdin Index: main.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.c,v retrieving revision 1.2 retrieving revision 1.2.2.1 diff -C2 -d -r1.2 -r1.2.2.1 *** main.c 19 Mar 2005 03:29:05 -0000 1.2 --- main.c 20 Mar 2005 04:09:14 -0000 1.2.2.1 *************** *** 243,252 **** list_t *keys; ! while ((c = getopt(argc, argv, "k:o:")) != -1) switch (c) { - case 'k': - keyring = optarg; - break; case 'o': outputdir = optarg; --- 243,249 ---- list_t *keys; ! while ((c = getopt(argc, argv, "o:")) != -1) switch (c) { case 'o': outputdir = optarg; *************** *** 263,267 **** } ! keys = parse_keyring(keyring); do_analysis(keys, outputdir); --- 260,264 ---- } ! keys = parse_keyring(); do_analysis(keys, outputdir); *************** *** 331,340 **** } ! list_t *parse_keyring(char *keyring) { size_t size; char *command1 = "gpg --list-sigs --with-colons --no-default-keyring --keyring "; char *command2; - FILE *filep; keydata_t *key; pgpkey_t *public_key, *tmp_key, *tmp2_key; --- 328,336 ---- } ! list_t *parse_keyring() { size_t size; char *command1 = "gpg --list-sigs --with-colons --no-default-keyring --keyring "; char *command2; keydata_t *key; pgpkey_t *public_key, *tmp_key, *tmp2_key; *************** *** 344,365 **** public_key = NULL; keys = list_new(&pgpkey_compare); - if(keyring == NULL) - filep = stdin; - else - { - size = strlen(command1) + strlen(keyring); - command2 = (char *) malloc(size); - - strncpy(command2, command1, size); - *(command2 + size) = '\0'; - strncat(command2, keyring, size - strlen(command2)); - - filep = popen(command2, "r"); - } key = keydata_new(); while(strcmp(key->type, "nul") == 0) { ! key = keydata_read(filep); } while(strcmp(key->type, "eof") != 0) --- 340,348 ---- public_key = NULL; keys = list_new(&pgpkey_compare); key = keydata_new(); while(strcmp(key->type, "nul") == 0) { ! key = keydata_read(stdin); } while(strcmp(key->type, "eof") != 0) *************** *** 401,409 **** if(strcmp(key->type, "sub") == 0) public_key = NULL; ! key = keydata_read(filep); } - if(keyring != NULL) - pclose(filep); return keys; } --- 384,390 ---- if(strcmp(key->type, "sub") == 0) public_key = NULL; ! key = keydata_read(stdin); } return keys; } Index: main.h =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.h,v retrieving revision 1.1 retrieving revision 1.1.2.1 diff -C2 -d -r1.1 -r1.1.2.1 *** main.h 18 Mar 2005 20:42:22 -0000 1.1 --- main.h 20 Mar 2005 04:09:14 -0000 1.1.2.1 *************** *** 28,32 **** int do_analysis(list_t *, char *); void output_file(pgpkey_t *, list_t *, list_t *, list_t *, list_t *); ! list_t *parse_keyring(char *); void print_list(FILE *, list_t *); void usage(void); --- 28,32 ---- int do_analysis(list_t *, char *); void output_file(pgpkey_t *, list_t *, list_t *, list_t *, list_t *); ! list_t *parse_keyring(void); void print_list(FILE *, list_t *); void usage(void); |
|
From: Jeff B. <jb...@us...> - 2005-03-19 03:29:14
|
Update of /cvsroot/digraphanalysis/digraphanalysis/src In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv7269 Modified Files: main.c Log Message: OpenBSD Style Guide: include all sys/*.h above regular /usr includes Index: main.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/src/main.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** main.c 18 Mar 2005 20:42:22 -0000 1.1 --- main.c 19 Mar 2005 03:29:05 -0000 1.2 *************** *** 16,19 **** --- 16,22 ---- */ + #include <sys/stat.h> + #include <sys/types.h> + #include <ctype.h> #include <libgen.h> *************** *** 21,26 **** #include <stdlib.h> #include <string.h> - #include <sys/stat.h> - #include <sys/types.h> #include <unistd.h> --- 24,27 ---- |