version 1.26, 2019/06/20 07:10:56 |
version 1.27, 2019/07/09 14:03:12 |
|
|
struct args_entry { |
struct args_entry { |
u_char flag; |
u_char flag; |
struct args_values values; |
struct args_values values; |
|
u_int count; |
RB_ENTRY(args_entry) entry; |
RB_ENTRY(args_entry) entry; |
}; |
}; |
|
|
|
|
size_t len; |
size_t len; |
char *buf; |
char *buf; |
int i; |
int i; |
|
u_int j; |
struct args_entry *entry; |
struct args_entry *entry; |
struct args_value *value; |
struct args_value *value; |
|
|
|
|
|
|
if (*buf == '\0') |
if (*buf == '\0') |
args_print_add(&buf, &len, "-"); |
args_print_add(&buf, &len, "-"); |
args_print_add(&buf, &len, "%c", entry->flag); |
for (j = 0; j < entry->count; j++) |
|
args_print_add(&buf, &len, "%c", entry->flag); |
} |
} |
|
|
/* Then the flags with arguments. */ |
/* Then the flags with arguments. */ |
|
|
int |
int |
args_has(struct args *args, u_char ch) |
args_has(struct args *args, u_char ch) |
{ |
{ |
return (args_find(args, ch) != NULL); |
struct args_entry *entry; |
|
|
|
entry = args_find(args, ch); |
|
if (entry == NULL) |
|
return (0); |
|
return (entry->count); |
} |
} |
|
|
/* Set argument value in the arguments tree. */ |
/* Set argument value in the arguments tree. */ |
|
|
if (entry == NULL) { |
if (entry == NULL) { |
entry = xcalloc(1, sizeof *entry); |
entry = xcalloc(1, sizeof *entry); |
entry->flag = ch; |
entry->flag = ch; |
|
entry->count = 1; |
TAILQ_INIT(&entry->values); |
TAILQ_INIT(&entry->values); |
RB_INSERT(args_tree, &args->tree, entry); |
RB_INSERT(args_tree, &args->tree, entry); |
} |
} else |
|
entry->count++; |
|
|
if (s != NULL) { |
if (s != NULL) { |
value = xcalloc(1, sizeof *value); |
value = xcalloc(1, sizeof *value); |