ES1370: QOMify
[qemu/ar7.git] / qapi / qapi-util.c
blob8afb12eb43e97f2c8484115befa50559a32b38f8
1 /*
2 * QAPI util functions
4 * Authors:
5 * Hu Tao <hutao@cn.fujitsu.com>
6 * Peter Lieven <pl@kamp.de>
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.
13 #include "qemu/osdep.h"
14 #include "qemu-common.h"
15 #include "qapi/util.h"
17 int qapi_enum_parse(const char * const lookup[], const char *buf,
18 int max, int def, Error **errp)
20 int i;
22 if (!buf) {
23 return def;
26 for (i = 0; i < max; i++) {
27 if (!strcmp(buf, lookup[i])) {
28 return i;
32 error_setg(errp, "invalid parameter value: %s", buf);
33 return def;