summaryrefslogtreecommitdiff
path: root/src/metaentry.h
diff options
context:
space:
mode:
authorPrzemyslaw Pawelczyk <przemoc@gmail.com>2015-09-13 22:12:14 +0200
committerPrzemyslaw Pawelczyk <przemoc@gmail.com>2015-09-13 22:12:14 +0200
commit16ab153f3a54194e3217fcf1a235904e4b61623b (patch)
treec27f9326815ebf4454e753028dcb3d388b3c0990 /src/metaentry.h
parent295428a550bb55a509ce15c5e27a0ab173799ebb (diff)
Move source files to src/ directory.
As a bonus you can build out-of-tree now via make -f. It's part of the work related to issue #22.
Diffstat (limited to 'src/metaentry.h')
-rw-r--r--src/metaentry.h97
1 files changed, 97 insertions, 0 deletions
diff --git a/src/metaentry.h b/src/metaentry.h
new file mode 100644
index 0000000..666c5af
--- /dev/null
+++ b/src/metaentry.h
@@ -0,0 +1,97 @@
+/*
+ * Various functions to work with meta entries.
+ *
+ * Copyright (C) 2007 David Härdeman <david@hardeman.nu>
+ *
+ * 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; only version 2 of the License is applicable.
+ *
+ * This program is distributed in the hope that it will be useful, but
+ * WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ */
+
+#ifndef METAENTRY_H
+#define METAENTRY_H
+
+#include <stdbool.h>
+
+#include "settings.h"
+
+/* Data structure to hold all metadata for a file/dir */
+struct metaentry {
+ struct metaentry *next; /* For the metahash chains */
+ struct metaentry *list; /* For creating additional lists of entries */
+
+ char *path;
+ unsigned int pathlen;
+
+ char *owner;
+ char *group;
+ mode_t mode;
+ time_t mtime;
+ long mtimensec;
+
+ unsigned int xattrs;
+ char **xattr_names;
+ ssize_t *xattr_lvalues;
+ char **xattr_values;
+};
+
+#define HASH_INDEXES 1024
+
+/* Data structure to hold a number of metadata entries */
+struct metahash {
+ struct metaentry *bucket[HASH_INDEXES];
+ unsigned int count;
+};
+
+/* Create a metaentry for the file/dir/etc at path */
+struct metaentry *mentry_create(const char *path);
+
+/* Recurses opath and adds metadata entries to the metaentry list */
+void mentries_recurse_path(const char *opath, struct metahash **mhash, msettings *st);
+
+/* Stores a metaentry list to a file */
+void mentries_tofile(const struct metahash *mhash, const char *path);
+
+/* Creates a metaentry list from a file */
+void mentries_fromfile(struct metahash **mhash, const char *path);
+
+/* Searches haystack for an xattr matching xattr number n in needle */
+int mentry_find_xattr(struct metaentry *haystack,
+ struct metaentry *needle,
+ unsigned n);
+
+#define DIFF_NONE 0x00
+#define DIFF_OWNER 0x01
+#define DIFF_GROUP 0x02
+#define DIFF_MODE 0x04
+#define DIFF_TYPE 0x08
+#define DIFF_MTIME 0x10
+#define DIFF_XATTR 0x20
+#define DIFF_ADDED 0x40
+#define DIFF_DELE 0x80
+
+/* Compares two metaentries and returns an int with a bitmask of differences */
+int mentry_compare(struct metaentry *left,
+ struct metaentry *right,
+ msettings *st);
+
+/* Compares lists of real and stored metadata and calls pfunc for each */
+void mentries_compare(struct metahash *mhashreal,
+ struct metahash *mhashstored,
+ void (*pfunc)(struct metaentry *real,
+ struct metaentry *stored,
+ int cmp),
+ msettings *st);
+
+void mentries_dump(struct metahash *mhash);
+
+#endif /* METAENTRY_H */