move parser functions from vl.c to qemu-option.c
[sdk/emulator/qemu.git] / qemu-option.h
1 /*
2  * Commandline option parsing functions
3  *
4  * Copyright (c) 2003-2008 Fabrice Bellard
5  * Copyright (c) 2009 Kevin Wolf <kwolf@redhat.com>
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a copy
8  * of this software and associated documentation files (the "Software"), to deal
9  * in the Software without restriction, including without limitation the rights
10  * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
11  * copies of the Software, and to permit persons to whom the Software is
12  * furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice shall be included in
15  * all copies or substantial portions of the Software.
16  *
17  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
18  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
21  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
22  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
23  * THE SOFTWARE.
24  */
25
26 #ifndef QEMU_OPTIONS_H
27 #define QEMU_OPTIONS_H
28
29 enum QEMUOptionParType {
30     OPT_FLAG,
31     OPT_NUMBER,
32     OPT_SIZE,
33     OPT_STRING,
34 };
35
36 typedef struct QEMUOptionParameter {
37     const char *name;
38     enum QEMUOptionParType type;
39     union {
40         uint64_t n;
41         char* s;
42     } value;
43     const char *help;
44 } QEMUOptionParameter;
45
46
47 const char *get_opt_name(char *buf, int buf_size, const char *p, char delim);
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);
55
56
57 /*
58  * The following functions take a parameter list as input. This is a pointer to
59  * the first element of a QEMUOptionParameter array which is terminated by an
60  * entry with entry->name == NULL.
61  */
62
63 QEMUOptionParameter *get_option_parameter(QEMUOptionParameter *list,
64     const char *name);
65 int set_option_parameter(QEMUOptionParameter *list, const char *name,
66     const char *value);
67 int set_option_parameter_int(QEMUOptionParameter *list, const char *name,
68     uint64_t value);
69 QEMUOptionParameter *parse_option_parameters(const char *param,
70     QEMUOptionParameter *list, QEMUOptionParameter *dest);
71 void free_option_parameters(QEMUOptionParameter *list);
72 void print_option_parameters(QEMUOptionParameter *list);
73 void print_option_help(QEMUOptionParameter *list);
74
75 #endif