| File src/options.c changed (mode: 100644) (index df5ef66f8..c79b90dc0) |
| ... |
... |
static struct opt_t * add_option_inner(const char *name, enum opt_type type, |
| 48 |
48 |
static const char * extract_option(const char *cmd, char *buf, int replace); |
static const char * extract_option(const char *cmd, char *buf, int replace); |
| 49 |
49 |
static int process_option(const char *cmd); |
static int process_option(const char *cmd); |
| 50 |
50 |
static const char * skip_alphas(const char *cmd); |
static const char * skip_alphas(const char *cmd); |
|
51 |
|
static void print_options(void); |
| 51 |
52 |
static struct opt_t * get_option(const char *option); |
static struct opt_t * get_option(const char *option); |
| 52 |
53 |
static struct opt_t * find_option(const char *option); |
static struct opt_t * find_option(const char *option); |
| 53 |
54 |
static int set_on(struct opt_t *opt); |
static int set_on(struct opt_t *opt); |
| |
| ... |
... |
process_option(const char *cmd) |
| 285 |
286 |
p = skip_alphas(cmd); |
p = skip_alphas(cmd); |
| 286 |
287 |
|
|
| 287 |
288 |
snprintf(option, p - cmd + 1, "%s", cmd); |
snprintf(option, p - cmd + 1, "%s", cmd); |
|
289 |
|
|
|
290 |
|
if(strcmp(option, "all") == 0) |
|
291 |
|
{ |
|
292 |
|
print_options(); |
|
293 |
|
return 0; |
|
294 |
|
} |
|
295 |
|
|
| 288 |
296 |
opt = get_option(option); |
opt = get_option(option); |
| 289 |
297 |
if(opt == NULL) |
if(opt == NULL) |
| 290 |
298 |
{ |
{ |
| |
| ... |
... |
skip_alphas(const char *cmd) |
| 356 |
364 |
return cmd; |
return cmd; |
| 357 |
365 |
} |
} |
| 358 |
366 |
|
|
|
367 |
|
static void |
|
368 |
|
print_options(void) |
|
369 |
|
{ |
|
370 |
|
int i; |
|
371 |
|
for(i = 0; i < options_count; i++) |
|
372 |
|
{ |
|
373 |
|
if(options[i].full != NULL) |
|
374 |
|
continue; |
|
375 |
|
set_print(&options[i]); |
|
376 |
|
} |
|
377 |
|
} |
|
378 |
|
|
| 359 |
379 |
static struct opt_t * |
static struct opt_t * |
| 360 |
380 |
get_option(const char *option) |
get_option(const char *option) |
| 361 |
381 |
{ |
{ |
| |
| ... |
... |
set_print(struct opt_t *opt) |
| 724 |
744 |
if(opt->type == OPT_BOOL) |
if(opt->type == OPT_BOOL) |
| 725 |
745 |
{ |
{ |
| 726 |
746 |
snprintf(buf, sizeof(buf), "%s%s", |
snprintf(buf, sizeof(buf), "%s%s", |
| 727 |
|
opt->val.bool_val ? "" : "no", opt->name); |
|
|
747 |
|
opt->val.bool_val ? " " : "no", opt->name); |
| 728 |
748 |
} |
} |
| 729 |
749 |
else if(opt->type == OPT_INT) |
else if(opt->type == OPT_INT) |
| 730 |
750 |
{ |
{ |
| 731 |
|
snprintf(buf, sizeof(buf), "%s=%d", opt->name, opt->val.int_val); |
|
|
751 |
|
snprintf(buf, sizeof(buf), " %s=%d", opt->name, opt->val.int_val); |
| 732 |
752 |
} |
} |
| 733 |
753 |
else if(opt->type == OPT_STR || opt->type == OPT_STRLIST) |
else if(opt->type == OPT_STR || opt->type == OPT_STRLIST) |
| 734 |
754 |
{ |
{ |
| 735 |
|
snprintf(buf, sizeof(buf), "%s=%s", opt->name, |
|
|
755 |
|
snprintf(buf, sizeof(buf), " %s=%s", opt->name, |
| 736 |
756 |
opt->val.str_val ? opt->val.str_val : ""); |
opt->val.str_val ? opt->val.str_val : ""); |
| 737 |
757 |
} |
} |
| 738 |
758 |
else if(opt->type == OPT_ENUM) |
else if(opt->type == OPT_ENUM) |
| 739 |
759 |
{ |
{ |
| 740 |
|
snprintf(buf, sizeof(buf), "%s=%s", opt->name, opt->vals[opt->val.enum_item]); |
|
|
760 |
|
snprintf(buf, sizeof(buf), " %s=%s", opt->name, |
|
761 |
|
opt->vals[opt->val.enum_item]); |
| 741 |
762 |
} |
} |
| 742 |
763 |
else if(opt->type == OPT_SET) |
else if(opt->type == OPT_SET) |
| 743 |
764 |
{ |
{ |
| 744 |
765 |
int i, first = 1; |
int i, first = 1; |
| 745 |
|
snprintf(buf, sizeof(buf), "%s=", opt->name); |
|
|
766 |
|
snprintf(buf, sizeof(buf), " %s=", opt->name); |
| 746 |
767 |
for(i = 0; i < opt->val_count; i++) |
for(i = 0; i < opt->val_count; i++) |
| 747 |
768 |
if(opt->val.set_items & (1 << i)) |
if(opt->val.set_items & (1 << i)) |
| 748 |
769 |
{ |
{ |
| |
| ... |
... |
complete_option(const char *buf, int bool_only) |
| 854 |
875 |
} |
} |
| 855 |
876 |
|
|
| 856 |
877 |
len = strlen(buf); |
len = strlen(buf); |
|
878 |
|
if(strncmp(buf, "all", len) == 0) |
|
879 |
|
add_completion("all"); |
| 857 |
880 |
for(i = 0; i < options_count; i++) |
for(i = 0; i < options_count; i++) |
| 858 |
881 |
{ |
{ |
| 859 |
882 |
if(options[i].full != NULL) |
if(options[i].full != NULL) |