X-Git-Url: https://git.deb.at/w?a=blobdiff_plain;f=options.c;fp=options.c;h=fb5c7a635d61e10c8340e774bf280e1766bdb555;hb=208968222b63ab08f95b0ad6d882cfc4ab22dda5;hp=fe75878abb225b056e950f0c2a34cceaba7f9d72;hpb=efc9a360c599ac2317853a6ff3ca6c3d208b7316;p=pkg%2Fabook.git diff --git a/options.c b/options.c index fe75878..fb5c7a6 100644 --- a/options.c +++ b/options.c @@ -283,12 +283,41 @@ opt_parse_set(buffer *b) return "unknown option"; } +static char * +opt_parse_customfield(buffer *b) +{ + char *p, num[5]; + int n; + size_t len; + + find_token_start(b); + + p = b -> ptr; + + find_token_end(b); + + memset(num, 0, sizeof(num)); + + if((len = (b -> ptr - p)) > sizeof(num)) + return "invalid custom field number"; + + strncpy(num, p, min(sizeof(num), len)); + n = atoi(num); + + find_token_start(b); + + if(change_custom_field_name(b->ptr, n) == -1) + return "invalid custom field number"; + + return NULL; +} static struct { char *token; char * (*func) (buffer *line); } opt_parsers[] = { { "set", opt_parse_set }, + { "customfield", opt_parse_customfield }, { NULL } };