]> Git Repo - qemu.git/blame - qapi/qapi-util.c
net: don't use set/get_pointer() in set/get_netdev()
[qemu.git] / qapi / qapi-util.c
CommitLineData
9e7dac7c
PL
1/*
2 * QAPI util functions
3 *
4 * Authors:
5 * Hu Tao <[email protected]>
6 * Peter Lieven <[email protected]>
7 *
8 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
9 * See the COPYING.LIB file in the top-level directory.
10 *
11 */
12
13#include "qemu-common.h"
14#include "qapi/error.h"
15#include "qapi/util.h"
16
17int qapi_enum_parse(const char *lookup[], const char *buf,
18 int max, int def, Error **errp)
19{
20 int i;
21
22 if (!buf) {
23 return def;
24 }
25
26 for (i = 0; i < max; i++) {
27 if (!strcmp(buf, lookup[i])) {
28 return i;
29 }
30 }
31
32 error_setg(errp, "invalid parameter value: %s", buf);
33 return def;
34}
This page took 0.034439 seconds and 4 git commands to generate.