From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from eggs.gnu.org ([140.186.70.92]:50423) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QRvpH-0005FU-Aa for qemu-devel@nongnu.org; Wed, 01 Jun 2011 20:31:52 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1QRvpA-00068U-QQ for qemu-devel@nongnu.org; Wed, 01 Jun 2011 20:31:51 -0400 Received: from mout.perfora.net ([74.208.4.194]:54360) by eggs.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1QRpEP-0000w8-1B for qemu-devel@nongnu.org; Wed, 01 Jun 2011 13:29:21 -0400 From: Michael Roth Date: Wed, 1 Jun 2011 12:24:41 -0500 Message-Id: <1306949089-15597-14-git-send-email-mdroth@linux.vnet.ibm.com> In-Reply-To: <1306949089-15597-1-git-send-email-mdroth@linux.vnet.ibm.com> References: <1306949089-15597-1-git-send-email-mdroth@linux.vnet.ibm.com> Subject: [Qemu-devel] [PATCH v1][ 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