fsck: offer a function to demote fsck errors to warnings
[git] / fsck.h
1 #ifndef GIT_FSCK_H
2 #define GIT_FSCK_H
3
4 #define FSCK_ERROR 1
5 #define FSCK_WARN 2
6
7 struct fsck_options;
8
9 void fsck_set_msg_type(struct fsck_options *options,
10                 const char *msg_id, const char *msg_type);
11 void fsck_set_msg_types(struct fsck_options *options, const char *values);
12
13 /*
14  * callback function for fsck_walk
15  * type is the expected type of the object or OBJ_ANY
16  * the return value is:
17  *     0        everything OK
18  *     <0       error signaled and abort
19  *     >0       error signaled and do not abort
20  */
21 typedef int (*fsck_walk_func)(struct object *obj, int type, void *data, struct fsck_options *options);
22
23 /* callback for fsck_object, type is FSCK_ERROR or FSCK_WARN */
24 typedef int (*fsck_error)(struct object *obj, int type, const char *message);
25
26 int fsck_error_function(struct object *obj, int type, const char *message);
27
28 struct fsck_options {
29         fsck_walk_func walk;
30         fsck_error error_func;
31         unsigned strict:1;
32         int *msg_type;
33 };
34
35 #define FSCK_OPTIONS_DEFAULT { NULL, fsck_error_function, 0, NULL }
36 #define FSCK_OPTIONS_STRICT { NULL, fsck_error_function, 1, NULL }
37
38 /* descend in all linked child objects
39  * the return value is:
40  *    -1        error in processing the object
41  *    <0        return value of the callback, which lead to an abort
42  *    >0        return value of the first signaled error >0 (in the case of no other errors)
43  *    0         everything OK
44  */
45 int fsck_walk(struct object *obj, void *data, struct fsck_options *options);
46 /* If NULL is passed for data, we assume the object is local and read it. */
47 int fsck_object(struct object *obj, void *data, unsigned long size,
48         struct fsck_options *options);
49
50 #endif