Commit 62c5802efdabe2a24ca9680a1ab9dcbbfbaf43d2
Committed by
Anthony Liguori
1 parent
3b0ba927
move parser functions from vl.c to qemu-option.c
Signed-off-by: Gerd Hoffmann <kraxel@redhat.com> Signed-off-by: Anthony Liguori <aliguori@us.ibm.com>
Showing
4 changed files
with
71 additions
and
71 deletions
qemu-option.c
| ... | ... | @@ -85,6 +85,70 @@ const char *get_opt_value(char *buf, int buf_size, const char *p) |
| 85 | 85 | return p; |
| 86 | 86 | } |
| 87 | 87 | |
| 88 | +int get_next_param_value(char *buf, int buf_size, | |
| 89 | + const char *tag, const char **pstr) | |
| 90 | +{ | |
| 91 | + const char *p; | |
| 92 | + char option[128]; | |
| 93 | + | |
| 94 | + p = *pstr; | |
| 95 | + for(;;) { | |
| 96 | + p = get_opt_name(option, sizeof(option), p, '='); | |
| 97 | + if (*p != '=') | |
| 98 | + break; | |
| 99 | + p++; | |
| 100 | + if (!strcmp(tag, option)) { | |
| 101 | + *pstr = get_opt_value(buf, buf_size, p); | |
| 102 | + if (**pstr == ',') { | |
| 103 | + (*pstr)++; | |
| 104 | + } | |
| 105 | + return strlen(buf); | |
| 106 | + } else { | |
| 107 | + p = get_opt_value(NULL, 0, p); | |
| 108 | + } | |
| 109 | + if (*p != ',') | |
| 110 | + break; | |
| 111 | + p++; | |
| 112 | + } | |
| 113 | + return 0; | |
| 114 | +} | |
| 115 | + | |
| 116 | +int get_param_value(char *buf, int buf_size, | |
| 117 | + const char *tag, const char *str) | |
| 118 | +{ | |
| 119 | + return get_next_param_value(buf, buf_size, tag, &str); | |
| 120 | +} | |
| 121 | + | |
| 122 | +int check_params(char *buf, int buf_size, | |
| 123 | + const char * const *params, const char *str) | |
| 124 | +{ | |
| 125 | + const char *p; | |
| 126 | + int i; | |
| 127 | + | |
| 128 | + p = str; | |
| 129 | + while (*p != '\0') { | |
| 130 | + p = get_opt_name(buf, buf_size, p, '='); | |
| 131 | + if (*p != '=') { | |
| 132 | + return -1; | |
| 133 | + } | |
| 134 | + p++; | |
| 135 | + for (i = 0; params[i] != NULL; i++) { | |
| 136 | + if (!strcmp(params[i], buf)) { | |
| 137 | + break; | |
| 138 | + } | |
| 139 | + } | |
| 140 | + if (params[i] == NULL) { | |
| 141 | + return -1; | |
| 142 | + } | |
| 143 | + p = get_opt_value(NULL, 0, p); | |
| 144 | + if (*p != ',') { | |
| 145 | + break; | |
| 146 | + } | |
| 147 | + p++; | |
| 148 | + } | |
| 149 | + return 0; | |
| 150 | +} | |
| 151 | + | |
| 88 | 152 | /* |
| 89 | 153 | * Searches an option list for an option with the given name |
| 90 | 154 | */ | ... | ... |
qemu-option.h
| ... | ... | @@ -46,6 +46,12 @@ typedef struct QEMUOptionParameter { |
| 46 | 46 | |
| 47 | 47 | const char *get_opt_name(char *buf, int buf_size, const char *p, char delim); |
| 48 | 48 | const char *get_opt_value(char *buf, int buf_size, const char *p); |
| 49 | +int get_next_param_value(char *buf, int buf_size, | |
| 50 | + const char *tag, const char **pstr); | |
| 51 | +int get_param_value(char *buf, int buf_size, | |
| 52 | + const char *tag, const char *str); | |
| 53 | +int check_params(char *buf, int buf_size, | |
| 54 | + const char * const *params, const char *str); | |
| 49 | 55 | |
| 50 | 56 | |
| 51 | 57 | /* | ... | ... |
sysemu.h
| ... | ... | @@ -3,6 +3,7 @@ |
| 3 | 3 | /* Misc. things related to the system emulator. */ |
| 4 | 4 | |
| 5 | 5 | #include "qemu-common.h" |
| 6 | +#include "qemu-option.h" | |
| 6 | 7 | #include "sys-queue.h" |
| 7 | 8 | |
| 8 | 9 | #ifdef _WIN32 |
| ... | ... | @@ -276,13 +277,6 @@ void do_usb_add(Monitor *mon, const char *devname); |
| 276 | 277 | void do_usb_del(Monitor *mon, const char *devname); |
| 277 | 278 | void usb_info(Monitor *mon); |
| 278 | 279 | |
| 279 | -int get_param_value(char *buf, int buf_size, | |
| 280 | - const char *tag, const char *str); | |
| 281 | -int get_next_param_value(char *buf, int buf_size, | |
| 282 | - const char *tag, const char **pstr); | |
| 283 | -int check_params(char *buf, int buf_size, | |
| 284 | - const char * const *params, const char *str); | |
| 285 | - | |
| 286 | 280 | void register_devices(void); |
| 287 | 281 | |
| 288 | 282 | #endif | ... | ... |
vl.c
| ... | ... | @@ -1599,70 +1599,6 @@ static int socket_init(void) |
| 1599 | 1599 | } |
| 1600 | 1600 | #endif |
| 1601 | 1601 | |
| 1602 | -int get_next_param_value(char *buf, int buf_size, | |
| 1603 | - const char *tag, const char **pstr) | |
| 1604 | -{ | |
| 1605 | - const char *p; | |
| 1606 | - char option[128]; | |
| 1607 | - | |
| 1608 | - p = *pstr; | |
| 1609 | - for(;;) { | |
| 1610 | - p = get_opt_name(option, sizeof(option), p, '='); | |
| 1611 | - if (*p != '=') | |
| 1612 | - break; | |
| 1613 | - p++; | |
| 1614 | - if (!strcmp(tag, option)) { | |
| 1615 | - *pstr = get_opt_value(buf, buf_size, p); | |
| 1616 | - if (**pstr == ',') { | |
| 1617 | - (*pstr)++; | |
| 1618 | - } | |
| 1619 | - return strlen(buf); | |
| 1620 | - } else { | |
| 1621 | - p = get_opt_value(NULL, 0, p); | |
| 1622 | - } | |
| 1623 | - if (*p != ',') | |
| 1624 | - break; | |
| 1625 | - p++; | |
| 1626 | - } | |
| 1627 | - return 0; | |
| 1628 | -} | |
| 1629 | - | |
| 1630 | -int get_param_value(char *buf, int buf_size, | |
| 1631 | - const char *tag, const char *str) | |
| 1632 | -{ | |
| 1633 | - return get_next_param_value(buf, buf_size, tag, &str); | |
| 1634 | -} | |
| 1635 | - | |
| 1636 | -int check_params(char *buf, int buf_size, | |
| 1637 | - const char * const *params, const char *str) | |
| 1638 | -{ | |
| 1639 | - const char *p; | |
| 1640 | - int i; | |
| 1641 | - | |
| 1642 | - p = str; | |
| 1643 | - while (*p != '\0') { | |
| 1644 | - p = get_opt_name(buf, buf_size, p, '='); | |
| 1645 | - if (*p != '=') { | |
| 1646 | - return -1; | |
| 1647 | - } | |
| 1648 | - p++; | |
| 1649 | - for (i = 0; params[i] != NULL; i++) { | |
| 1650 | - if (!strcmp(params[i], buf)) { | |
| 1651 | - break; | |
| 1652 | - } | |
| 1653 | - } | |
| 1654 | - if (params[i] == NULL) { | |
| 1655 | - return -1; | |
| 1656 | - } | |
| 1657 | - p = get_opt_value(NULL, 0, p); | |
| 1658 | - if (*p != ',') { | |
| 1659 | - break; | |
| 1660 | - } | |
| 1661 | - p++; | |
| 1662 | - } | |
| 1663 | - return 0; | |
| 1664 | -} | |
| 1665 | - | |
| 1666 | 1602 | /***********************************************************/ |
| 1667 | 1603 | /* Bluetooth support */ |
| 1668 | 1604 | static int nb_hcis; | ... | ... |