diff options
author | citats <citats@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-08-06 02:12:54 +0000 |
---|---|---|
committer | citats <citats@f38db490-d61c-443f-a65b-d21fe96a405b> | 2004-08-06 02:12:54 +0000 |
commit | 55a3f3c257aed4d81badbf4ef980f3e9cc0f589a (patch) | |
tree | 0d12a7d28b4749706e1fafc0b2ac955d6d589ebe /apps/app_verbose.c | |
parent | 78a64af8adb18ccc112dd19c95f6b1f47113b844 (diff) |
Add app_verbose.c to cvs (bug 2212)
git-svn-id: http://svn.digium.com/svn/asterisk/trunk@3581 f38db490-d61c-443f-a65b-d21fe96a405b
Diffstat (limited to 'apps/app_verbose.c')
-rwxr-xr-x | apps/app_verbose.c | 107 |
1 files changed, 107 insertions, 0 deletions
diff --git a/apps/app_verbose.c b/apps/app_verbose.c new file mode 100755 index 000000000..7585d7902 --- /dev/null +++ b/apps/app_verbose.c @@ -0,0 +1,107 @@ +/* + * Asterisk -- A telephony toolkit for Linux. + * + * Verbose application + * + * Copyright (c) 2004 Tilghman Lesher. All rights reserved. + * + * Tilghman Lesher <app_verbose_v001@the-tilghman.com> + * + * This code is released by the author with no restrictions on usage. + * + */ + +#include <stdio.h> +#include <stdlib.h> +#include <unistd.h> +#include <string.h> +#include <asterisk/options.h> +#include <asterisk/logger.h> +#include <asterisk/channel.h> +#include <asterisk/pbx.h> +#include <asterisk/module.h> + + +static char *tdesc = "Send verbose output"; + +static char *app_verbose = "Verbose"; + +static char *verbose_synopsis = "Send arbitrary text to verbose output"; + +static char *verbose_descrip = +"Verbose([<level>|]<message>)\n" +" level must be an integer value. If not specified, defaults to 0." +" Always returns 0.\n"; + +STANDARD_LOCAL_USER; + +LOCAL_USER_DECL; + +static int verbose_exec(struct ast_channel *chan, void *data) +{ + char *vtext; + int vsize; + + if (data) { + vtext = ast_strdupa((char *)data); + if (vtext) { + char *tmp = strsep(&vtext, "|,"); + if (vtext) { + if (sscanf(tmp, "%d", &vsize) != 1) { + vsize = 0; + ast_log(LOG_WARNING, "'%s' is not a verboser number\n", vtext); + } + } else { + vtext = tmp; + vsize = 0; + } + if (option_verbose >= vsize) { + switch (vsize) { + case 1: + ast_verbose(VERBOSE_PREFIX_1 "%s\n", vtext); + break; + case 2: + ast_verbose(VERBOSE_PREFIX_2 "%s\n", vtext); + break; + case 3: + ast_verbose(VERBOSE_PREFIX_3 "%s\n", vtext); + break; + default: + ast_verbose(VERBOSE_PREFIX_4 "%s\n", vtext); + } + } + } else { + ast_log(LOG_ERROR, "Out of memory\n"); + } + } + + return 0; +} + +int unload_module(void) +{ + STANDARD_HANGUP_LOCALUSERS; + return ast_unregister_application(app_verbose); +} + +int load_module(void) +{ + return ast_register_application(app_verbose, verbose_exec, verbose_synopsis, verbose_descrip); +} + +char *description(void) +{ + return tdesc; +} + +int usecount(void) +{ + int res; + STANDARD_USECOUNT(res); + return res; +} + +char *key() +{ + return ASTERISK_GPL_KEY; +} |