Mon Mar 20 08:20:16 2006

Asterisk developer's documentation


Main Page | Modules | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals | Related Pages

app_verbose.c File Reference

Verbose logging application. More...

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include "asterisk.h"
#include "asterisk/options.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/module.h"

Go to the source code of this file.

Functions

char * description (void)
 Provides a description of the module.
char * key ()
 Returns the ASTERISK_GPL_KEY.
int load_module (void)
 Initialize the module.
int unload_module (void)
 Cleanup all module structures, sockets, etc.
int usecount (void)
 Provides a usecount.
int verbose_exec (struct ast_channel *chan, void *data)

Variables

char * app_verbose = "Verbose"
 LOCAL_USER_DECL
 STANDARD_LOCAL_USER
char * tdesc = "Send verbose output"
char * verbose_descrip
char * verbose_synopsis = "Send arbitrary text to verbose output"


Detailed Description

Verbose logging application.

Definition in file app_verbose.c.


Function Documentation

char* description void   ) 
 

Provides a description of the module.

Returns:
a short description of your module

Definition at line 120 of file app_verbose.c.

00121 {
00122    return tdesc;
00123 }

char* key void   ) 
 

Returns the ASTERISK_GPL_KEY.

This returns the ASTERISK_GPL_KEY, signifiying that you agree to the terms of the GPL stated in the ASTERISK_GPL_KEY. Your module will not load if it does not return the EXACT message:

 char *key(void) {
         return ASTERISK_GPL_KEY;
 }

Returns:
ASTERISK_GPL_KEY

Definition at line 132 of file app_verbose.c.

00133 {
00134    return ASTERISK_GPL_KEY;
00135 }

int load_module void   ) 
 

Initialize the module.

Initialize the Agents module. This function is being called by Asterisk when loading the module. Among other thing it registers applications, cli commands and reads the cofiguration file.

Returns:
int Always 0.

Definition at line 115 of file app_verbose.c.

References app_verbose, ast_register_application(), verbose_descrip, verbose_exec(), and verbose_synopsis.

00116 {
00117    return ast_register_application(app_verbose, verbose_exec, verbose_synopsis, verbose_descrip);
00118 }

int unload_module void   ) 
 

Cleanup all module structures, sockets, etc.

This is called at exit. Any registrations and memory allocations need to be unregistered and free'd here. Nothing else will do these for you (until exit).

Returns:
Zero on success, or non-zero on error.

Definition at line 104 of file app_verbose.c.

References app_verbose, and ast_unregister_application().

00105 {
00106    int res;
00107 
00108    res = ast_unregister_application(app_verbose);
00109 
00110    STANDARD_HANGUP_LOCALUSERS;
00111 
00112    return res; 
00113 }

int usecount void   ) 
 

Provides a usecount.

This function will be called by various parts of asterisk. Basically, all it has to do is to return a usecount when called. You will need to maintain your usecount within the module somewhere. The usecount should be how many channels provided by this module are in use.

Returns:
The module's usecount.

Definition at line 125 of file app_verbose.c.

References STANDARD_USECOUNT.

00126 {
00127    int res;
00128    STANDARD_USECOUNT(res);
00129    return res;
00130 }

int verbose_exec struct ast_channel chan,
void *  data
[static]
 

Definition at line 55 of file app_verbose.c.

References ast_log(), ast_strdupa, ast_verbose(), LOCAL_USER_ADD, LOCAL_USER_REMOVE, LOG_ERROR, LOG_WARNING, option_verbose, strsep(), VERBOSE_PREFIX_1, VERBOSE_PREFIX_2, VERBOSE_PREFIX_3, and VERBOSE_PREFIX_4.

Referenced by load_module().

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 }


Variable Documentation

char* app_verbose = "Verbose" [static]
 

Definition at line 43 of file app_verbose.c.

Referenced by load_module(), and unload_module().

LOCAL_USER_DECL
 

Definition at line 53 of file app_verbose.c.

STANDARD_LOCAL_USER
 

Definition at line 51 of file app_verbose.c.

char* tdesc = "Send verbose output" [static]
 

Definition at line 41 of file app_verbose.c.

char* verbose_descrip [static]
 

Initial value:

"Verbose([<level>|]<message>)\n"
"  level must be an integer value.  If not specified, defaults to 0.\n"

Definition at line 47 of file app_verbose.c.

Referenced by load_module().

char* verbose_synopsis = "Send arbitrary text to verbose output" [static]
 

Definition at line 45 of file app_verbose.c.

Referenced by load_module().


Generated on Mon Mar 20 08:20:16 2006 for Asterisk - the Open Source PBX by  doxygen 1.3.9.1