diff options
| -rw-r--r-- | git.c | 10 | ||||
| -rw-r--r-- | keyword.c | 14 | ||||
| -rw-r--r-- | keyword.h | 4 | 
3 files changed, 16 insertions, 12 deletions
| @@ -89,7 +89,7 @@ static linked_list *parse_dsv_str(const char *str, const char *delm) {  	return tail;  } -static void parse_patch_list(void *ctx, void *ret, const keyword *key, keyword_val val) { +static int parse_patch_list(void *ctx, void *ret, const keyword *key, keyword_val val) {  	/* Do we actually have a "patches" keyword? */  	if (key->type == TYPE_STRING) {  		const char *root = (const char *)ctx; @@ -113,11 +113,13 @@ static void parse_patch_list(void *ctx, void *ret, const keyword *key, keyword_v  			}  			cleanup_linked_list(patch_list); +			return 1;  		}  	} +	return -1;  } -static void parse_comment_reply(void *ctx, void *ret, const keyword *key, keyword_val val) { +static int parse_comment_reply(void *ctx, void *ret, const keyword *key, keyword_val val) {  	linked_list *comment_list = *(linked_list **)ctx;  	comment *comment = (comment *)ret; @@ -129,7 +131,7 @@ static void parse_comment_reply(void *ctx, void *ret, const keyword *key, keywor  			/* Do we have a match? */  			if (comment->reply == reply) { -				return; +				return 1;  			}  		}  	} @@ -158,7 +160,7 @@ static void parse_comment_reply(void *ctx, void *ret, const keyword *key, keywor  		/* Did we find a reply in the list? */  		if (found_reply) { -			return; +			return 1;  		}  	} @@ -29,10 +29,12 @@ keyword_val get_keyword_value(const keyword *key, char *value, int *error) {  	return val;  } -void set_keyword(const keyword *key, keyword_val val, void *ret, void *ctx) { -	if (key->callback != NULL) { -		key->callback(ctx, ret, key, val); +int set_keyword(const keyword *key, keyword_val val, void *ret, void *ctx) { +	const int callback_ret = (key->callback != NULL) ? key->callback(ctx, ret, key, val) : 0; +	if (callback_ret < 0 || callback_ret > 0) { +		return (callback_ret > 0) ? 0 : 5;  	} else { +		char *tmp_ret = (char *)get_keyword_offset_ptr(key, ret);  		char *tmp_ret = (char *)ret;  		size_t offset = -1;  		for (int i = 0; (int64_t)key->offsets[i] >= 0; ++i) { @@ -48,8 +50,9 @@ void set_keyword(const keyword *key, keyword_val val, void *ret, void *ctx) {  			case TYPE_TIME	: *(time_t *)(tmp_ret+offset) = val.t; break;  			case TYPE_STRING: *(char **)(tmp_ret+offset) = val.str; break;  			case TYPE_FLOAT	: *(float *)(tmp_ret+offset) = val.f; break; -			default		: break; +			default		: return 6; break;  		} +		return 0;  	}  } @@ -73,8 +76,7 @@ int parse_keywords(const keyword **keys, char *key, char *value, void *ret, void  		val = parse_keyword(keys[i], key, value, &error);  		if (!error) { -			set_keyword(keys[i], val, ret, ctx); -			return 0; +			return set_keyword(keys[i], val, ret, ctx);  		}  	}  	return error; @@ -6,7 +6,7 @@  typedef enum keyword_type keyword_type;  typedef struct keyword keyword;  typedef union keyword_val keyword_val; -typedef void (keyword_cb)(void *ctx, void *ret, const keyword *key, keyword_val val); +typedef int (keyword_cb)(void *ctx, void *ret, const keyword *key, keyword_val val);  enum keyword_type {  	TYPE_NONE, @@ -35,7 +35,7 @@ union keyword_val {  };  extern keyword_val get_keyword_value(const keyword *key, char *value, int *error); -extern void set_keyword(const keyword *key, keyword_val val, void *ret, void *ctx); +extern int set_keyword(const keyword *key, keyword_val val, void *ret, void *ctx);  extern keyword_val parse_keyword(const keyword *key, char *key_str, char *value, int *error);  extern int parse_keywords(const keyword **keys, char *key, char *value, void *ret, void *ctx);  #endif | 
