X-Git-Url: https://git.distorted.org.uk/u/mdw/catacomb/blobdiff_plain/18b3351a3791f19a63c0af05640719db8eb5d184..f377eee1983a7c9f33a9920b3bf16180dca909da:/cc.h diff --git a/cc.h b/cc.h index 04ff17f..2e0503a 100644 --- a/cc.h +++ b/cc.h @@ -326,6 +326,17 @@ extern const encodeops *getencoding(const char */*ename*/); /*----- File hashing ------------------------------------------------------*/ +/* --- @gethash@ --- * + * + * Arguments: @const char *name@ = pointer to name string + * + * Returns: Pointer to appropriate hash class. + * + * Use: Chooses a hash function by name. + */ + +extern const gchash *gethash(const char */*name*/); + /* --- @fhash@ --- * * * Arguments: @const gchash *gch@ = pointer to hash function to use @@ -346,6 +357,37 @@ extern const encodeops *getencoding(const char */*ename*/); extern int fhash(const gchash */*gch*/, unsigned /*f*/, const char */*file*/, void */*buf*/); +/* --- @hfparse@ --- * + * + * Arguments: @hfpctx *hfp@ = pointer to the context structure + * + * Returns: A code indicating what happened. + * + * Use: Parses a line from the input file. + */ + +enum { /* Meaning and members set */ + HF_FILE, /* File hash: @dline@ and @hbuf@ */ + HF_ENC, /* Encoding: @ee@ */ + HF_HASH, /* Hash function: @gch@ */ + HF_ESC, /* Name escape: @f@ */ + HF_EOF, /* End of file */ + HF_BAD /* Unrecognized line */ +}; + +typedef struct hfpctx { + unsigned f; /* Flags to read */ +#define HFF_ESCAPE 1u /* File names are escaped */ + FILE *fp; /* Input file to read */ + dstr *dline; /* Line contents, corrupted */ + const gchash *gch; /* Hash function to use */ + const encodeops *ee; /* Encoding to apply to hashes */ + dstr *dfile; /* File name for @HF_FILE@ lines */ + octet *hbuf; /* Output buffer for hash data */ +} hfpctx; + +extern int hfparse(hfpctx */*hfp*/); + /*----- String I/O --------------------------------------------------------*/ #define GSF_RAW 4096u