Bad zero comparison for sas_ss_flags on powerpc
[qemu/ar7.git] / qapi / qmp-registry.c
blob25c89ad098a2a655a6bf9eb9a0f4f94119f24e65
1 /*
2 * Core Definitions for QAPI/QMP Dispatch
4 * Copyright IBM, Corp. 2011
6 * Authors:
7 * Anthony Liguori <aliguori@us.ibm.com>
8 * Michael Roth <mdroth@us.ibm.com>
10 * This work is licensed under the terms of the GNU LGPL, version 2.1 or later.
11 * See the COPYING.LIB file in the top-level directory.
15 #include "qapi/qmp-core.h"
17 static QTAILQ_HEAD(QmpCommandList, QmpCommand) qmp_commands =
18 QTAILQ_HEAD_INITIALIZER(qmp_commands);
20 void qmp_register_command(const char *name, QmpCommandFunc *fn)
22 QmpCommand *cmd = g_malloc0(sizeof(*cmd));
24 cmd->name = name;
25 cmd->type = QCT_NORMAL;
26 cmd->fn = fn;
27 cmd->enabled = true;
28 QTAILQ_INSERT_TAIL(&qmp_commands, cmd, node);
31 QmpCommand *qmp_find_command(const char *name)
33 QmpCommand *cmd;
35 QTAILQ_FOREACH(cmd, &qmp_commands, node) {
36 if (strcmp(cmd->name, name) == 0) {
37 return cmd;
40 return NULL;
43 void qmp_disable_command(const char *name)
45 QmpCommand *cmd;
47 QTAILQ_FOREACH(cmd, &qmp_commands, node) {
48 if (strcmp(cmd->name, name) == 0) {
49 cmd->enabled = false;
50 return;
55 bool qmp_command_is_enabled(const char *name)
57 QmpCommand *cmd;
59 QTAILQ_FOREACH(cmd, &qmp_commands, node) {
60 if (strcmp(cmd->name, name) == 0) {
61 return cmd->enabled;
65 return false;
68 char **qmp_get_command_list(void)
70 QmpCommand *cmd;
71 int count = 1;
72 char **list_head, **list;
74 QTAILQ_FOREACH(cmd, &qmp_commands, node) {
75 count++;
78 list_head = list = g_malloc0(count * sizeof(char *));
80 QTAILQ_FOREACH(cmd, &qmp_commands, node) {
81 *list = strdup(cmd->name);
82 list++;
85 return list_head;