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