fix documentation of --compare
[metastore.git] / metaentry.h
blobc2c9e016d3c87c8f036f35f0c60579099c26d009
1 /*
2 * Various functions to work with meta entries.
4 * Copyright (C) 2007 David Härdeman <david@hardeman.nu>
6 * This program is free software; you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the
8 * Free Software Foundation version 2 of the License.
9 *
10 * This program is distributed in the hope that it will be useful, but
11 * WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * General Public License for more details.
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
21 /* Data structure to hold all metadata for a file */
22 struct metaentry {
23 struct metaentry *next;
24 char *path;
25 char *owner;
26 char *group;
27 mode_t mode;
28 time_t mtime;
29 long mtimensec;
30 unsigned int xattrs;
31 char **xattr_names;
32 ssize_t *xattr_lvalues;
33 char **xattr_values;
36 #define HASH_INDEXES 1024
38 /* Data structure to hold a number of metadata entries */
39 struct metahash {
40 struct metaentry *bucket[HASH_INDEXES];
41 unsigned int count;
44 /* Recurses opath and adds metadata entries to the metaentry list */
45 void mentries_recurse_path(const char *opath, struct metahash **mhash);
47 /* Stores a metaentry list to a file */
48 void mentries_tofile(const struct metahash *mhash, const char *path);
50 /* Creates a metaentry list from a file */
51 void mentries_fromfile(struct metahash **mhash, const char *path);
53 /* Searches haystack for an xattr matching xattr number n in needle */
54 int mentry_find_xattr(struct metaentry *haystack,
55 struct metaentry *needle,
56 int n);
58 #define DIFF_NONE 0x00
59 #define DIFF_OWNER 0x01
60 #define DIFF_GROUP 0x02
61 #define DIFF_MODE 0x04
62 #define DIFF_TYPE 0x08
63 #define DIFF_MTIME 0x10
64 #define DIFF_XATTR 0x20
65 #define DIFF_ADDED 0x40
66 #define DIFF_DELE 0x80
68 /* Compares lists of real and stored metadata and calls pfunc for each */
69 void mentries_compare(struct metahash *mhashreal,
70 struct metahash *mhashstored,
71 void (*pfunc)(struct metaentry *real,
72 struct metaentry *stored,
73 int cmp),
74 int do_mtime);