summaryrefslogtreecommitdiff
path: root/file/file.h
diff options
context:
space:
mode:
authorWerner Almesberger <werner@almesberger.net>2016-08-17 21:07:13 -0300
committerWerner Almesberger <werner@almesberger.net>2016-08-17 21:07:13 -0300
commit265b34fd1c1e5771adae3052b3e459d5eac597c7 (patch)
treebfd27907916e3605f2b5d9d4ae13acaaa82ec797 /file/file.h
parentbf8cc205a5a7fc21f139f23c6462519f9d4eb192 (diff)
downloadeeshow-265b34fd1c1e5771adae3052b3e459d5eac597c7.tar.gz
eeshow-265b34fd1c1e5771adae3052b3e459d5eac597c7.tar.bz2
eeshow-265b34fd1c1e5771adae3052b3e459d5eac597c7.zip
eeshow/: move file and history access to file/
Diffstat (limited to 'file/file.h')
-rw-r--r--file/file.h45
1 files changed, 45 insertions, 0 deletions
diff --git a/file/file.h b/file/file.h
new file mode 100644
index 0000000..8f6c855
--- /dev/null
+++ b/file/file.h
@@ -0,0 +1,45 @@
+/*
+ * file/file.h - Open and read a file
+ *
+ * Written 2016 by Werner Almesberger
+ * Copyright 2016 by Werner Almesberger
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ */
+
+#ifndef FILE_FILE_H
+#define FILE_FILE_H
+
+#include <stdbool.h>
+#include <stdio.h>
+
+
+struct file {
+ FILE *file; /* NULL if using a version control system */
+ void *vcs; /* VCS descriptor or NULL */
+ const char *name; /* name/designator given to file_open */
+ unsigned lineno;
+ const struct file *related; /* NULL if not related to anything */
+};
+
+
+void *file_oid(const struct file *file);
+bool file_oid_eq(const void *a, const void *b);
+
+bool file_cat(const struct file *file, void *user, const char *line);
+
+char *file_graft_relative(const char *base, const char *name);
+
+bool file_open(struct file *file, const char *name,
+ const struct file *related);
+bool file_open_revision(struct file *file, const char *rev, const char *name,
+ const struct file *related);
+bool file_read(struct file *file,
+ bool (*parse)(const struct file *file, void *user, const char *line),
+ void *user);
+void file_close(struct file *file);
+
+#endif /* !FILE_FILE_H */