.links: Drop obsolete `lib-config.in' file.
[u/mdw/catacomb] / cc.h
diff --git a/cc.h b/cc.h
index 2e0503a..f3a03f3 100644 (file)
--- a/cc.h
+++ b/cc.h
@@ -44,6 +44,9 @@
 #include <string.h>
 #include <time.h>
 
+#include <sys/types.h>
+#include <sys/stat.h>
+
 #include <mLib/dstr.h>
 
 #include "key.h"
@@ -326,6 +329,18 @@ extern const encodeops *getencoding(const char */*ename*/);
 
 /*----- File hashing ------------------------------------------------------*/
 
+typedef struct fhashstate {
+  const gchash *gch;
+  unsigned f;
+  struct fhent *ents;
+} fhashstate;
+
+#define FHF_BINARY 0x100u
+#define FHF_PROGRESS 0x200u
+#define FHF_JUNK 0x400u
+
+#define FHF_MASK 0xff00u
+
 /* --- @gethash@ --- *
  *
  * Arguments:  @const char *name@ = pointer to name string
@@ -337,10 +352,43 @@ extern const encodeops *getencoding(const char */*ename*/);
 
 extern const gchash *gethash(const char */*name*/);
 
+/* --- @describefile@ --- *
+ *
+ * Arguments:  @const struct stat *st@ = pointer to file state
+ *
+ * Returns:    A snappy one-word description of the file.
+ */
+
+extern const char *describefile(const struct stat */*st*/);
+
+/* --- @fhash_init@ ---*
+ *
+ * Arguments:  @fhashstate *fh@ = pointer to fhash state to initialize
+ *             @const gchash *gch@ = hash class to set
+ *             @unsigned f@ initial flags to set
+ *
+ * Returns:    ---
+ *
+ * Use:                Initializes an @fhashstate@ structure.
+ */
+
+extern void fhash_init(fhashstate */*fh*/,
+                      const gchash */*gch*/, unsigned /*f*/);
+
+/* --- @fhash_free@ --- *
+ *
+ * Arguments:  @fhashstate *fh@ = pointer to fhash state to free
+ *
+ * Returns:    ---
+ *
+ * Use:                Frees an fhash state.
+ */
+
+extern void fhash_free(fhashstate */*fh*/);
+
 /* --- @fhash@ --- *
  *
- * Arguments:  @const gchash *gch@ = pointer to hash function to use
- *             @unsigned f@ = flags to set
+ * Arguments:  @fhashstate *fh@ = pointer to fhash state
  *             @const char *file@ = file name to be hashed (null for stdin)
  *             @void *buf@ = pointer to hash output buffer
  *
@@ -349,13 +397,26 @@ extern const gchash *gethash(const char */*name*/);
  * Use:                Hashes a file.
  */
 
-#define FHF_BINARY 256u
-#define FHF_PROGRESS 512u
+extern int fhash(fhashstate */*fh*/, const char */*file*/, void */*buf*/);
 
-#define FHF_MASK 3840
+/* --- @fhash_junk@ --- *
+ *
+ * Arguments:  @fhashstate *fh@ = pointer to fhash state
+ *             @void (*func)(const char *, const struct stat *, void *)@
+ *             @void *p@ = pointer to pass to function
+ *
+ * Returns:    Positive if any junk was found, negative on error, zero if
+ *             everything was fine.
+ *
+ * Use:                Reports junk files in any directories covered by the hash
+ *             state.
+ */
 
-extern int fhash(const gchash */*gch*/, unsigned /*f*/,
-                const char */*file*/, void */*buf*/);
+extern int fhash_junk(fhashstate */*fh*/,
+                     int (*/*func*/)(const char *,
+                                     const struct stat *,
+                                     void *),
+                     void */*p*/);
 
 /* --- @hfparse@ --- *
  *