From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:46627) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QScxu-0005cP-3d for qemu-devel@nongnu.org; Fri, 03 Jun 2011 18:35:39 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QScxs-0001sB-0H for qemu-devel@nongnu.org; Fri, 03 Jun 2011 18:35:37 -0400 Received: from mout.perfora.net ([74.208.4.195]:60381) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QScxr-0001s3-GB for qemu-devel@nongnu.org; Fri, 03 Jun 2011 18:35:35 -0400 From: Michael Roth Date: Fri, 3 Jun 2011 17:33:11 -0500 Message-Id: <1307140399-9023-14-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1307140399-9023-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1307140399-9023-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH v2][ 13/21] qapi: add command registration/lookup functions List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , To: qemu-devel@nongnu.org Cc: aliguori@linux.vnet.ibm.com, Jes.Sorensen@redhat.com, agl@linux.vnet.ibm.com, mdroth@linux.vnet.ibm.com, lcapitulino@redhat.com Registration/lookup functions for that provide a lookup table for dispatching QMP commands. Signed-off-by: Michael Roth --- qapi/qmp-registry.c | 27 +++++++++++++++++++++++++++ 1 files changed, 27 insertions(+), 0 deletions(-) create mode 100644 qapi/qmp-registry.c diff --git a/qapi/qmp-registry.c b/qapi/qmp-registry.c new file mode 100644 index 0000000..f870244 --- /dev/null +++ b/qapi/qmp-registry.c @@ -0,0 +1,27 @@ +#include "qapi/qmp-core.h" + +static QTAILQ_HEAD(, QmpCommand) qmp_commands = + QTAILQ_HEAD_INITIALIZER(qmp_commands); + +void qmp_register_command(const char *name, QmpCommandFunc *fn) +{ + QmpCommand *cmd = qemu_mallocz(sizeof(*cmd)); + + cmd->name = name; + cmd->type = QCT_NORMAL; + cmd->fn = fn; + QTAILQ_INSERT_TAIL(&qmp_commands, cmd, node); +} + +QmpCommand *qmp_find_command(const char *name) +{ + QmpCommand *i; + + QTAILQ_FOREACH(i, &qmp_commands, node) { + if (strcmp(i->name, name) == 0) { + return i; + } + } + return NULL; +} + -- 1.7.0.4