summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Härdeman <david@hardeman.nu>2007-05-19 17:26:03 +0200
committerDavid Härdeman <david@hardeman.nu>2007-05-19 17:26:03 +0200
commita4e5b979d910384577750a4672fee44e7c468bd0 (patch)
tree133393bb4876691546a200d626653fb412987783
parent5fed2f9169fdd0585cc83ff0fa8210d97da77cb2 (diff)
Remove the need for a global variable (do_mtime)
-rw-r--r--metaentry.c11
-rw-r--r--metaentry.h20
-rw-r--r--metastore.c6
-rw-r--r--metastore.h3
4 files changed, 22 insertions, 18 deletions
diff --git a/metaentry.c b/metaentry.c
index d8c7cb8..28046f2 100644
--- a/metaentry.c
+++ b/metaentry.c
@@ -515,7 +515,7 @@ mentry_compare_xattr(struct metaentry *left, struct metaentry *right)
}
static int
-mentry_compare(struct metaentry *left, struct metaentry *right)
+mentry_compare(struct metaentry *left, struct metaentry *right, int do_mtime)
{
int retval = DIFF_NONE;
@@ -555,7 +555,8 @@ mentry_compare(struct metaentry *left, struct metaentry *right)
void
mentries_compare(struct metaentry *mheadleft,
struct metaentry *mheadright,
- void (*printfunc)(struct metaentry *, struct metaentry *, int))
+ void (*pfunc)(struct metaentry *, struct metaentry *, int),
+ int do_mtime)
{
struct metaentry *left, *right;
int cmp;
@@ -570,14 +571,14 @@ mentries_compare(struct metaentry *mheadleft,
if (!right)
cmp = DIFF_ADDED;
else
- cmp = mentry_compare(left, right);
- printfunc(left, right, cmp);
+ cmp = mentry_compare(left, right, do_mtime);
+ pfunc(left, right, cmp);
}
for (right = mheadright; right; right = right->next) {
left = mentry_find(right->path, mheadleft);
if (!left)
- printfunc(left, right, DIFF_DELE);
+ pfunc(left, right, DIFF_DELE);
}
}
diff --git a/metaentry.h b/metaentry.h
index 0a2dde1..5e126ce 100644
--- a/metaentry.h
+++ b/metaentry.h
@@ -18,13 +18,17 @@
*
*/
+/* Recurses opath and adds metadata entries to the mhead list */
void mentries_recurse_path(const char *opath, struct metaentry **mhead);
+/* Stores a metadata list to a file */
void mentries_tofile(const struct metaentry *mhead, const char *path);
+/* Creates a metadata list from a file */
void mentries_fromfile(struct metaentry **mhead, const char *path);
-int mentry_find_xattr(struct metaentry *heystack,
+/* Searches haystack for an xattr matching xattr n in needle */
+int mentry_find_xattr(struct metaentry *haystack,
struct metaentry *needle,
int n);
@@ -37,10 +41,12 @@ int mentry_find_xattr(struct metaentry *heystack,
#define DIFF_XATTR 0x20
#define DIFF_ADDED 0x40
#define DIFF_DELE 0x80
-void mentries_compare(struct metaentry *,
- struct metaentry *,
- void (*printfunc)(struct metaentry *,
- struct metaentry *,
- int)
- );
+
+/* Compares two lists of metaentries and calls pfunc for each entry */
+void mentries_compare(struct metaentry *mheadleft,
+ struct metaentry *mheadright,
+ void (*pfunc)(struct metaentry *right,
+ struct metaentry *left,
+ int cmp),
+ int do_mtime);
diff --git a/metastore.c b/metastore.c
index 9ebc8fc..2db4c31 100644
--- a/metastore.c
+++ b/metastore.c
@@ -34,7 +34,7 @@
#include "metaentry.h"
/* Used to signal whether mtimes should be corrected */
-int do_mtime = 0;
+static int do_mtime = 0;
/*
* Prints differences between stored and actual metadata
@@ -318,7 +318,7 @@ main(int argc, char **argv, char **envp)
exit(EXIT_FAILURE);
}
- mentries_compare(mhead, mfhead, compare_print);
+ mentries_compare(mhead, mfhead, compare_print, do_mtime);
break;
case ACTION_SAVE:
@@ -359,7 +359,7 @@ main(int argc, char **argv, char **envp)
exit(EXIT_FAILURE);
}
- mentries_compare(mhead, mfhead, compare_fix);
+ mentries_compare(mhead, mfhead, compare_fix, do_mtime);
break;
case ACTION_HELP:
diff --git a/metastore.h b/metastore.h
index 62c9ff0..fc8ceb1 100644
--- a/metastore.h
+++ b/metastore.h
@@ -33,9 +33,6 @@
#define ACTION_APPLY 0x04
#define ACTION_HELP 0x08
-/* Used to signal whether mtimes should be corrected */
-extern int do_mtime;
-
/* Data structure to hold all metadata for a file */
struct metaentry {
struct metaentry *next;