cc-hash.c, hashsum.c: Move hash-file parsing stuff to `cc-hash.c'.
[u/mdw/catacomb] / cc.h
diff --git a/cc.h b/cc.h
index 04ff17f..2e0503a 100644 (file)
--- 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