Statistics
| Branch: | Revision:

root / qemu-option.h @ db08adf5

History | View | Annotate | Download (2.4 kB)

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

    
50

    
51
/*
52
 * The following functions take a parameter list as input. This is a pointer to
53
 * the first element of a QEMUOptionParameter array which is terminated by an
54
 * entry with entry->name == NULL.
55
 */
56

    
57
QEMUOptionParameter *get_option_parameter(QEMUOptionParameter *list,
58
    const char *name);
59
int set_option_parameter(QEMUOptionParameter *list, const char *name,
60
    const char *value);
61
int set_option_parameter_int(QEMUOptionParameter *list, const char *name,
62
    uint64_t value);
63
QEMUOptionParameter *parse_option_parameters(const char *param,
64
    QEMUOptionParameter *list, QEMUOptionParameter *dest);
65
void free_option_parameters(QEMUOptionParameter *list);
66
void print_option_parameters(QEMUOptionParameter *list);
67
void print_option_help(QEMUOptionParameter *list);
68

    
69
#endif