summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRussell Bryant <russell@russellbryant.com>2007-08-07 16:04:03 +0000
committerRussell Bryant <russell@russellbryant.com>2007-08-07 16:04:03 +0000
commitc40a9e281848ce68e70f22995d6b0634b53707a3 (patch)
treea8ae2811ba8fb47a1493b4a4c0fa458e5d035cee
parentb4778de56259f355ae00dde7c4b0c28174c7e87b (diff)
Remove some test code from trunk as it doesn't need to be here. I'm just
going to keep it with a bunch of other changes i have sitting in a branch. git-svn-id: https://origsvn.digium.com/svn/asterisk/trunk@78342 65c4cc65-6c06-0410-ace0-fbb531ad65f3
-rw-r--r--res/res_eventtest.c177
1 files changed, 0 insertions, 177 deletions
diff --git a/res/res_eventtest.c b/res/res_eventtest.c
deleted file mode 100644
index 1085eb57e..000000000
--- a/res/res_eventtest.c
+++ /dev/null
@@ -1,177 +0,0 @@
-/*
- * Asterisk -- An open source telephony toolkit.
- *
- * Copyright (C) 2007, Digium, Inc.
- *
- * Russell Bryant <russell@digium.com>
- *
- * See http://www.asterisk.org for more information about
- * the Asterisk project. Please do not directly contact
- * any of the maintainers of this project for assistance;
- * the project provides a web site, mailing lists and IRC
- * channels for your use.
- *
- * This program is free software, distributed under the terms of
- * the GNU General Public License Version 2. See the LICENSE file
- * at the top of the source tree.
- */
-
-/*!
- * \file
- * \author Russell Bryant <russell@digium.com>
- *
- * \brief Test code for the internal event system
- *
- */
-
-/*** MODULEINFO
- <defaultenabled>no</defaultenabled>
- ***/
-
-#include "asterisk.h"
-
-ASTERISK_FILE_VERSION(__FILE__, "$Revision$");
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <unistd.h>
-
-#include "asterisk/module.h"
-#include "asterisk/event.h"
-#include "asterisk/cli.h"
-
-static void process_event_generic(const struct ast_event *event)
-{
- ast_log(LOG_DEBUG, "Event type: %u\n", ast_event_get_type(event));
-}
-
-static void process_event_mwi(const struct ast_event *event)
-{
- const char *mailbox;
- unsigned int new;
- unsigned int old;
-
- mailbox = ast_event_get_ie_str(event, AST_EVENT_IE_MAILBOX);
- new = ast_event_get_ie_uint(event, AST_EVENT_IE_NEWMSGS);
- old = ast_event_get_ie_uint(event, AST_EVENT_IE_OLDMSGS);
-
- ast_log(LOG_DEBUG, "MWI Event. Mailbox: %s New: %u Old: %u\n",
- mailbox, new, old);
-}
-
-static void ast_event_process(const struct ast_event *event, void *userdata)
-{
- switch (ast_event_get_type(event)) {
- case AST_EVENT_MWI:
- process_event_mwi(event);
- break;
- default:
- process_event_generic(event);
- }
-}
-
-static char *event_gen(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
- struct ast_event *event;
- const char *mailbox = "1234@fakecontext";
- unsigned int new = 5;
- unsigned int old = 12;
- struct ast_event_sub *event_sub;
-
- switch (cmd) {
- case CLI_INIT:
- e->command = "event generate";
- e->usage =
- "Usage: event generate\n"
- " Generate a test event.\n";
- return NULL;
-
- case CLI_GENERATE:
- return NULL; /* no completion */
- }
- if (a->argc != e->args)
- return CLI_SHOWUSAGE;
-
- if (!(event_sub = ast_event_subscribe(AST_EVENT_ALL, ast_event_process,
- NULL, AST_EVENT_IE_END))) {
- return CLI_FAILURE;
- }
-
- if (!(event = ast_event_new(AST_EVENT_MWI,
- AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox,
- AST_EVENT_IE_NEWMSGS, AST_EVENT_IE_PLTYPE_UINT, new,
- AST_EVENT_IE_OLDMSGS, AST_EVENT_IE_PLTYPE_UINT, old,
- AST_EVENT_IE_END))) {
- return CLI_FAILURE;
- }
-
- ast_event_queue_and_cache(event,
- AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR,
- AST_EVENT_IE_END);
-
- /* XXX This is a hack. I should use a timed thread condition instead. */
- usleep(1000000);
-
- ast_event_unsubscribe(event_sub);
-
- return CLI_SUCCESS;
-}
-
-static char *event_get_cached(struct ast_cli_entry *e, int cmd, struct ast_cli_args *a)
-{
- struct ast_event *event;
- const char *mailbox = "1234@fakecontext";
-
- switch (cmd) {
- case CLI_INIT:
- e->command = "event get cached";
- e->usage =
- "Usage: event get cached\n"
- " Test getting an event from the cache.\n";
- return NULL;
-
- case CLI_GENERATE:
- return NULL; /* no completion */
- }
- if (a->argc != e->args)
- return CLI_SHOWUSAGE;
-
- event = ast_event_get_cached(AST_EVENT_MWI,
- AST_EVENT_IE_MAILBOX, AST_EVENT_IE_PLTYPE_STR, mailbox,
- AST_EVENT_IE_END);
-
- if (!event) {
- ast_cli(a->fd, "No event retrieved!\n");
- return CLI_FAILURE;
- }
-
- ast_cli(a->fd, "Got the event. New: %u Old: %u\n",
- ast_event_get_ie_uint(event, AST_EVENT_IE_NEWMSGS),
- ast_event_get_ie_uint(event, AST_EVENT_IE_OLDMSGS));
-
- ast_event_destroy(event);
-
- return CLI_SUCCESS;
-}
-
-static struct ast_cli_entry cli_commands[] = {
- NEW_CLI(event_gen, "Generate a test event"),
- NEW_CLI(event_get_cached, "Get an event from the cache"),
-};
-
-static int load_module(void)
-{
- ast_cli_register_multiple(cli_commands, ARRAY_LEN(cli_commands));
-
- return AST_MODULE_LOAD_SUCCESS;
-}
-
-static int unload_module(void)
-{
- ast_cli_unregister_multiple(cli_commands, ARRAY_LEN(cli_commands));
-
- return 0;
-}
-
-AST_MODULE_INFO_STANDARD(ASTERISK_GPL_KEY, "Test code for the internal event system");