/*----- 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
#define FHF_BINARY 256u
#define FHF_PROGRESS 512u
-#define FHF_MASK 3840
+#define FHF_MASK 384u
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