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