summaryrefslogtreecommitdiff
path: root/futility/traversal.h
diff options
context:
space:
mode:
Diffstat (limited to 'futility/traversal.h')
-rw-r--r--futility/traversal.h22
1 files changed, 18 insertions, 4 deletions
diff --git a/futility/traversal.h b/futility/traversal.h
index 74c88f5d..531ad6aa 100644
--- a/futility/traversal.h
+++ b/futility/traversal.h
@@ -89,12 +89,26 @@ struct futil_traverse_state_s {
int errors;
};
+
+/*
+ * This tries to match the buffer content to one of the known file types.
+ */
+enum futil_file_type futil_what_file_type_buf(uint8_t *buf, uint32_t len);
+
+/*
+ * This opens a file and tries to match it to one of the known file types. It
+ * fails only if it can't open and scan the file. It's not an error if it
+ * returns FILE_TYPE_UKNOWN.
+ */
+enum futil_file_type futil_what_file_type(const char *filename);
+
/*
- * Traverse the input file using the provided state
- * Return nonzero (but no details) if there were any errors.
+ * Traverse the buffer using the provided state, which should be initialized
+ * before calling. Returns nonzero (but no details) if there were any errors.
*/
-int futil_traverse(int ifd, struct futil_traverse_state_s *state,
- int writeable);
+int futil_traverse(uint8_t *buf, uint32_t len,
+ struct futil_traverse_state_s *state,
+ enum futil_file_type type_hint);
/* These are invoked by the traversal. They also return nonzero on error. */
int futil_cb_show_begin(struct futil_traverse_state_s *state);