From a1e745ad3b306d1e5173588e39d71b132466365e Mon Sep 17 00:00:00 2001 From: Mark Wooding Date: Sun, 22 Jan 2012 13:12:14 +0000 Subject: [PATCH] cc.h: Reorder the declarations. Split the file into chunks with their own type definitions and so on, rather than having one big section of type definitions. This header file is getting a bit unwieldy, and I'm going to be adding more stuff to it. It probably ought to be split into pieces. --- cc.h | 204 +++++++++++++++++++++++++++++++++---------------------------------- 1 file changed, 102 insertions(+), 102 deletions(-) diff --git a/cc.h b/cc.h index 6f92978..b7a2b27 100644 --- a/cc.h +++ b/cc.h @@ -51,16 +51,7 @@ #include "ghash.h" #include "gmac.h" -/*----- Data structures ---------------------------------------------------*/ - -/* --- Progress indicators --- */ - -typedef struct fprogress { - const char *bp; - off_t o, sz, olast; - time_t start, last; - char name[24]; -} fprogress; +/*----- Cryptographic object tables ---------------------------------------*/ /* --- Key encapsulation --- */ @@ -90,59 +81,6 @@ struct kemtab { extern const struct kemtab kemtab[]; -/* --- Signing --- */ - -typedef struct sig { - const struct sigops *ops; - key_packdef *kp; - void *kd; - const gchash *ch; - ghash *h; -} sig; - -typedef struct sigops { - const key_fetchdef *kf; /* Key fetching structure */ - size_t kdsz; /* Size of the key-data structure */ - sig *(*init)(key */*k*/, void */*kd*/, const gchash */*hc*/); - int (*doit)(sig */*s*/, dstr */*d*/); - const char *(*check)(sig */*s*/); - void (*destroy)(sig */*s*/); -} sigops; - -struct sigtab { - const char *name; - const sigops *signops; - const sigops *verifyops; - const gchash *ch; -}; - -extern const struct sigtab sigtab[]; - -/* --- Data encoding --- */ - -typedef struct enc { - const struct encops *ops; - FILE *fp; -} enc; - -typedef struct encops { - const char *name; - const char *rmode, *wmode; - int nraw, ncook; - enc *(*initenc)(FILE */*fp*/, const char */*msg*/); - enc *(*initdec)(FILE */*fp*/, - int (*/*func*/)(const char *, void *), void */*p*/); - int (*read)(enc */*e*/, void */*p*/, size_t /*sz*/); - int (*write)(enc */*e*/, const void */*p*/, size_t /*sz*/); - int (*encdone)(enc */*e*/); - int (*decdone)(enc */*e*/); - void (*destroy)(enc */*e*/); -} encops; - -extern const encops enctab[]; - -/*----- Functions provided ------------------------------------------------*/ - /* --- @getkem@ --- * * * Arguments: @key *k@ = the key to load @@ -183,6 +121,34 @@ extern int setupkem(kem */*k*/, dstr */*d*/, extern void freekem(kem */*k*/); +/* --- Signing --- */ + +typedef struct sig { + const struct sigops *ops; + key_packdef *kp; + void *kd; + const gchash *ch; + ghash *h; +} sig; + +typedef struct sigops { + const key_fetchdef *kf; /* Key fetching structure */ + size_t kdsz; /* Size of the key-data structure */ + sig *(*init)(key */*k*/, void */*kd*/, const gchash */*hc*/); + int (*doit)(sig */*s*/, dstr */*d*/); + const char *(*check)(sig */*s*/); + void (*destroy)(sig */*s*/); +} sigops; + +struct sigtab { + const char *name; + const sigops *signops; + const sigops *verifyops; + const gchash *ch; +}; + +extern const struct sigtab sigtab[]; + /* --- @getsig@ --- * * * Arguments: @key *k@ = the key to load @@ -207,6 +173,31 @@ extern sig *getsig(key */*k*/, const char */*app*/, int /*wantpriv*/); extern void freesig(sig */*s*/); +/*----- File encodings ----------------------------------------------------*/ + +/* --- Data encoding --- */ + +typedef struct enc { + const struct encops *ops; + FILE *fp; +} enc; + +typedef struct encops { + const char *name; + const char *rmode, *wmode; + int nraw, ncook; + enc *(*initenc)(FILE */*fp*/, const char */*msg*/); + enc *(*initdec)(FILE */*fp*/, + int (*/*func*/)(const char *, void *), void */*p*/); + int (*read)(enc */*e*/, void */*p*/, size_t /*sz*/); + int (*write)(enc */*e*/, const void */*p*/, size_t /*sz*/); + int (*encdone)(enc */*e*/); + int (*decdone)(enc */*e*/); + void (*destroy)(enc */*e*/); +} encops; + +extern const encops enctab[]; + /* --- @getenc@ --- * * * Arguments: @const char *enc@ = name of wanted encoding @@ -298,6 +289,8 @@ Options:\n\ extern int cmd_encode(int /*argc*/, char */*argv*/[]); extern int cmd_decode(int /*argc*/, char */*argv*/[]); +/*----- Lists of things ---------------------------------------------------*/ + /* --- @LIST(STRING, FP, END-TEST, NAME-EXPR)@ --- * * * Produce list of things. Requires @i@ and @w@ variables in scope. @@ -365,47 +358,15 @@ struct listent { extern int displaylists(const struct listent */*listtab*/, char *const /*argv*/[]); -/*----- Subcommand dispatch -----------------------------------------------*/ - -typedef struct cmd { - const char *name; - int (*cmd)(int /*argc*/, char */*argv*/[]); - const char *usage; - const char *help; -} cmd; - -extern void version(FILE */*fp*/); -extern void help_global(FILE */*fp*/); - -/* --- @findcmd@ --- * - * - * Arguments: @const cmd *cmds@ = pointer to command table - * @const char *name@ = a command name - * - * Returns: Pointer to the command structure. - * - * Use: Looks up a command by name. If the command isn't found, an - * error is reported and the program is terminated. - */ - -const cmd *findcmd(const cmd */*cmds*/, const char */*name*/); - -/* --- @sc_help@ --- * - * - * Arguments: @const cmd *cmds@ = pointer to command table - * @FILE *fp@ = output file handle - * @char *const *argv@ = remaining arguments - * - * Returns: --- - * - * Use: Prints a help message, maybe with help about subcommands. - */ - -extern void sc_help(const cmd */*cmds*/, FILE */*fp*/, - char *const */*argv*/); - /*----- Progress indicators -----------------------------------------------*/ +typedef struct fprogress { + const char *bp; + off_t o, sz, olast; + time_t start, last; + char name[24]; +} fprogress; + /* --- @fprogress_init@ --- * * * Arguments: @fprogress *f@ = progress context to be initialized @@ -456,6 +417,45 @@ extern void fprogress_clear(fprogress */*f*/); extern void fprogress_done(fprogress */*f*/); +/*----- Subcommand dispatch -----------------------------------------------*/ + +typedef struct cmd { + const char *name; + int (*cmd)(int /*argc*/, char */*argv*/[]); + const char *usage; + const char *help; +} cmd; + +extern void version(FILE */*fp*/); +extern void help_global(FILE */*fp*/); + +/* --- @findcmd@ --- * + * + * Arguments: @const cmd *cmds@ = pointer to command table + * @const char *name@ = a command name + * + * Returns: Pointer to the command structure. + * + * Use: Looks up a command by name. If the command isn't found, an + * error is reported and the program is terminated. + */ + +const cmd *findcmd(const cmd */*cmds*/, const char */*name*/); + +/* --- @sc_help@ --- * + * + * Arguments: @const cmd *cmds@ = pointer to command table + * @FILE *fp@ = output file handle + * @char *const *argv@ = remaining arguments + * + * Returns: --- + * + * Use: Prints a help message, maybe with help about subcommands. + */ + +extern void sc_help(const cmd */*cmds*/, FILE */*fp*/, + char *const */*argv*/); + /*----- That's all, folks -------------------------------------------------*/ #ifdef __cplusplus -- 2.11.0