00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025 #include <stdio.h>
00026 #include <stdlib.h>
00027 #include <unistd.h>
00028 #include <string.h>
00029
00030 #include "asterisk.h"
00031
00032 ASTERISK_FILE_VERSION(__FILE__, "$Revision: 24669 $")
00033
00034 #include "asterisk/options.h"
00035 #include "asterisk/logger.h"
00036 #include "asterisk/channel.h"
00037 #include "asterisk/pbx.h"
00038 #include "asterisk/module.h"
00039
00040
00041 static char *tdesc = "Send verbose output";
00042
00043 static char *app_verbose = "Verbose";
00044
00045 static char *verbose_synopsis = "Send arbitrary text to verbose output";
00046
00047 static char *verbose_descrip =
00048 "Verbose([<level>|]<message>)\n"
00049 " level must be an integer value. If not specified, defaults to 0.\n";
00050
00051 STANDARD_LOCAL_USER;
00052
00053 LOCAL_USER_DECL;
00054
00055 static int verbose_exec(struct ast_channel *chan, void *data)
00056 {
00057 char *vtext;
00058 int vsize;
00059 struct localuser *u;
00060
00061 LOCAL_USER_ADD(u);
00062
00063 if (data) {
00064 vtext = ast_strdupa((char *)data);
00065 if (vtext) {
00066 char *tmp = strsep(&vtext, "|");
00067 if (vtext) {
00068 if (sscanf(tmp, "%d", &vsize) != 1) {
00069 vsize = 0;
00070 ast_log(LOG_WARNING, "'%s' is not a verboser number\n", vtext);
00071 }
00072 } else {
00073 vtext = tmp;
00074 vsize = 0;
00075 }
00076 if (option_verbose >= vsize) {
00077 switch (vsize) {
00078 case 0:
00079 ast_verbose("%s\n", vtext);
00080 break;
00081 case 1:
00082 ast_verbose(VERBOSE_PREFIX_1 "%s\n", vtext);
00083 break;
00084 case 2:
00085 ast_verbose(VERBOSE_PREFIX_2 "%s\n", vtext);
00086 break;
00087 case 3:
00088 ast_verbose(VERBOSE_PREFIX_3 "%s\n", vtext);
00089 break;
00090 default:
00091 ast_verbose(VERBOSE_PREFIX_4 "%s\n", vtext);
00092 }
00093 }
00094 } else {
00095 ast_log(LOG_ERROR, "Out of memory\n");
00096 }
00097 }
00098
00099 LOCAL_USER_REMOVE(u);
00100
00101 return 0;
00102 }
00103
00104 int unload_module(void)
00105 {
00106 int res;
00107
00108 res = ast_unregister_application(app_verbose);
00109
00110 STANDARD_HANGUP_LOCALUSERS;
00111
00112 return res;
00113 }
00114
00115 int load_module(void)
00116 {
00117 return ast_register_application(app_verbose, verbose_exec, verbose_synopsis, verbose_descrip);
00118 }
00119
00120 char *description(void)
00121 {
00122 return tdesc;
00123 }
00124
00125 int usecount(void)
00126 {
00127 int res;
00128 STANDARD_USECOUNT(res);
00129 return res;
00130 }
00131
00132 char *key()
00133 {
00134 return ASTERISK_GPL_KEY;
00135 }