[digraphanalysis-cvs] digraphanalysis/utils/gpg2dot gpg2dot.c,
Status: Planning
Brought to you by:
jbreker
|
From: Jeff B. <jb...@us...> - 2005-05-27 14:24:54
|
Update of /cvsroot/digraphanalysis/digraphanalysis/utils/gpg2dot In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv338/utils/gpg2dot Modified Files: gpg2dot.c Log Message: compiles finishes condensation of list code Index: gpg2dot.c =================================================================== RCS file: /cvsroot/digraphanalysis/digraphanalysis/utils/gpg2dot/gpg2dot.c,v retrieving revision 1.1 retrieving revision 1.2 diff -C2 -d -r1.1 -r1.2 *** gpg2dot.c 16 Mar 2005 21:47:17 -0000 1.1 --- gpg2dot.c 27 May 2005 14:24:45 -0000 1.2 *************** *** 25,57 **** char *do_pub(void); void do_sig(char *); unsigned int encode(char *); void func001(unsigned int); char *get_keyid(); char *get_name(); - unsigned int - encode(char *string) - { - return (tolower(toascii((*string))) * 1000000) + (tolower(toascii(*(string + 1))) * 1000) + (tolower(toascii(*(string + 2)))); - } - - /* Advances over 'n' colons. - */ - void - func001(unsigned int n) - { - char c; - unsigned int i; - - i = 0; - while (i < n) - if ((c = fgetc(stdin)) == ':') - ++i; - else - if(feof(stdin) || ferror(stdin)) - exit(EX_IOERR); - return; - } /* Handle a sig line. */ --- 25,36 ---- char *do_pub(void); void do_sig(char *); + char *do_uid(char *); unsigned int encode(char *); void func001(unsigned int); + char *get_fingerprint(); char *get_keyid(); char *get_name(); /* Handle a sig line. */ *************** *** 89,93 **** func001(5); name = get_name(); ! fprintf(stdout, "\"%s\" = \"%s\";\n", keyid, name); while (((c = fgetc(stdin)) != '\n') && (feof(stdin) == 0)) if (ferror(stdin)) --- 68,72 ---- func001(5); name = get_name(); ! fprintf(stdout, "\"%s\" [label=\"%s\"];\n", keyid, name); while (((c = fgetc(stdin)) != '\n') && (feof(stdin) == 0)) if (ferror(stdin)) *************** *** 98,101 **** --- 77,150 ---- } + /* Handle a uid line. + */ + char * + do_uid(char *keyid_p) + { + char c, *keyid, *name; + + func001(7); + keyid = get_fingerprint() + 24; + func001(2); + name = get_name(); + /* fprintf(stdout, "\"%s\" = \"%s\";\n", keyid_p, keyid); + */ while (((c = fgetc(stdin)) != '\n') && (feof(stdin) == 0)) + if (ferror(stdin)) + exit(EX_IOERR); + free(name); + + return keyid_p; + } + + unsigned int + encode(char *string) + { + return (tolower(toascii((*string))) * 1000000) + (tolower(toascii(*(string + 1))) * 1000) + (tolower(toascii(*(string + 2)))); + } + + /* Advances over 'n' colons. + */ + void + func001(unsigned int n) + { + char c; + unsigned int i; + + i = 0; + + while (i < n) + if ((c = fgetc(stdin)) == ':') + ++i; + else + if(feof(stdin) || ferror(stdin)) + exit(EX_IOERR); + return; + } + + /* Obtain the fingerprint from stdin. + */ + char * + get_fingerprint() + { + char c, *fingerprint; + unsigned int i; + + fingerprint = malloc(41); + + for (i = 0; i < 40; ++i) + { + c = fgetc(stdin); + if (feof(stdin) || ferror(stdin)) + exit(EX_IOERR); + c = toupper(c); + if (!isxdigit(c)) + exit(EX_DATAERR); + *(fingerprint + i) = (char) c; + } + *(fingerprint + 40) = '\0'; + + return fingerprint; + } + /* Obtain the keyid from stdin. */ *************** *** 169,173 **** type = malloc(4); ! fprintf(stdout, "digraph {\n"); while (feof(stdin) == 0) --- 218,222 ---- type = malloc(4); ! fprintf(stdout, "digraph gpg2dot {\n"); while (feof(stdin) == 0) *************** *** 193,196 **** --- 242,248 ---- do_sig(keyid_p); break; + case (117105100): /* uid */ + keyid_p = do_uid(keyid_p); + break; default: break_while = 1; *************** *** 204,207 **** --- 256,287 ---- } break; + case (117105100): /* uid */ + keyid_p = do_uid(keyid_p); + while (feof(stdin) == 0) + { + fgets(type, 4, stdin); + if (feof(stdin) || ferror(stdin)) + exit(EX_IOERR); + switch (encode(type)) + { + case (112117098): /* pub */ + keyid_p = do_pub(); + break; + case (115105103): /* sig */ + do_sig(keyid_p); + break; + case (117105100): /* uid */ + keyid_p = do_uid(keyid_p); + break; + default: + break_while = 1; + break; + } + if(break_while) + { + break_while = 0; + break; + } + } default: break; |