Revision fbc3d96c monitor.c
b/monitor.c | ||
---|---|---|
2908 | 2908 |
|
2909 | 2909 |
#define MAX_ARGS 16 |
2910 | 2910 |
|
2911 |
static int is_valid_option(const char *c, const char *typestr) |
|
2912 |
{ |
|
2913 |
char option[3]; |
|
2914 |
|
|
2915 |
option[0] = '-'; |
|
2916 |
option[1] = *c; |
|
2917 |
option[2] = '\0'; |
|
2918 |
|
|
2919 |
typestr = strstr(typestr, option); |
|
2920 |
return (typestr != NULL); |
|
2921 |
} |
|
2922 |
|
|
2911 | 2923 |
static const mon_cmd_t *monitor_parse_command(Monitor *mon, |
2912 | 2924 |
const char *cmdline, |
2913 | 2925 |
QDict *qdict) |
... | ... | |
3100 | 3112 |
break; |
3101 | 3113 |
case '-': |
3102 | 3114 |
{ |
3103 |
int has_option; |
|
3115 |
const char *tmp = p; |
|
3116 |
int has_option, skip_key = 0; |
|
3104 | 3117 |
/* option */ |
3105 | 3118 |
|
3106 | 3119 |
c = *typestr++; |
... | ... | |
3111 | 3124 |
has_option = 0; |
3112 | 3125 |
if (*p == '-') { |
3113 | 3126 |
p++; |
3114 |
if (*p != c) { |
|
3115 |
monitor_printf(mon, "%s: unsupported option -%c\n", |
|
3116 |
cmdname, *p); |
|
3117 |
goto fail; |
|
3127 |
if(c != *p) { |
|
3128 |
if(!is_valid_option(p, typestr)) { |
|
3129 |
|
|
3130 |
monitor_printf(mon, "%s: unsupported option -%c\n", |
|
3131 |
cmdname, *p); |
|
3132 |
goto fail; |
|
3133 |
} else { |
|
3134 |
skip_key = 1; |
|
3135 |
} |
|
3136 |
} |
|
3137 |
if(skip_key) { |
|
3138 |
p = tmp; |
|
3139 |
} else { |
|
3140 |
p++; |
|
3141 |
has_option = 1; |
|
3118 | 3142 |
} |
3119 |
p++; |
|
3120 |
has_option = 1; |
|
3121 | 3143 |
} |
3122 | 3144 |
qdict_put(qdict, key, qint_from_int(has_option)); |
3123 | 3145 |
} |
Also available in: Unified diff