#include <stdlib.h>
#include <unistd.h>
#include <string.h>
#include <ctype.h>
#include "asterisk.h"
#include "asterisk/logger.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/options.h"
#include "asterisk/module.h"
#include "asterisk/enum.h"
#include "asterisk/utils.h"
#include "asterisk/app.h"
Include dependency graph for app_txtcidname.c:
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. | |
static int | txtcidname_exec (struct ast_channel *chan, void *data) |
int | unload_module (void) |
Cleanup all module structures, sockets, etc. | |
int | usecount (void) |
Provides a usecount. | |
Variables | |
static char * | app = "TXTCIDName" |
static char * | descrip |
LOCAL_USER_DECL | |
STANDARD_LOCAL_USER | |
static char * | synopsis = "Lookup caller name from TXT record" |
static char * | tdesc = "TXTCIDName" |
Definition in file app_txtcidname.c.
char* description | ( | void | ) |
Provides a description of the module.
Definition at line 149 of file app_txtcidname.c.
00150 { 00151 return tdesc; 00152 }
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; }
Definition at line 161 of file app_txtcidname.c.
References ASTERISK_GPL_KEY.
00162 { 00163 return ASTERISK_GPL_KEY; 00164 }
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.
Definition at line 144 of file app_txtcidname.c.
References ast_register_application(), and txtcidname_exec().
00145 { 00146 return ast_register_application(app, txtcidname_exec, synopsis, descrip); 00147 }
static int txtcidname_exec | ( | struct ast_channel * | chan, | |
void * | data | |||
) | [static] |
Definition at line 65 of file app_txtcidname.c.
References AST_APP_ARG, AST_DECLARE_APP_ARGS, ast_get_txt(), ast_goto_if_exists(), ast_log(), AST_STANDARD_APP_ARGS, ast_strdupa, ast_strlen_zero(), localuser::chan, ast_channel::context, dep_warning, LOCAL_USER_ADD, LOCAL_USER_REMOVE, LOG_DEBUG, LOG_ERROR, LOG_WARNING, option_debug, option_priority_jumping, parse(), and pbx_builtin_setvar_helper().
Referenced by load_module().
00066 { 00067 int res=0; 00068 char tech[80]; 00069 char txt[256] = ""; 00070 char dest[80]; 00071 struct localuser *u; 00072 static int dep_warning = 0; 00073 char *parse = NULL; 00074 int priority_jump = 0; 00075 AST_DECLARE_APP_ARGS(args, 00076 AST_APP_ARG(cidnum); 00077 AST_APP_ARG(options); 00078 ); 00079 00080 LOCAL_USER_ADD(u); 00081 00082 if (!dep_warning) { 00083 ast_log(LOG_WARNING, "The TXTCIDName application has been deprecated in favor of the TXTCIDNAME dialplan function.\n"); 00084 dep_warning = 1; 00085 } 00086 00087 if (ast_strlen_zero(data)) { 00088 ast_log(LOG_WARNING, "TXTCIDName requires an argument (extension[|options])\n"); 00089 LOCAL_USER_REMOVE(u); 00090 return(0); 00091 } 00092 00093 parse = ast_strdupa(data); 00094 if (!parse) { 00095 ast_log(LOG_ERROR, "Out of memory!\n"); 00096 LOCAL_USER_REMOVE(u); 00097 return -1; 00098 } 00099 00100 AST_STANDARD_APP_ARGS(args,parse); 00101 00102 if (args.options) { 00103 if (strchr(args.options, 'j')) 00104 priority_jump = 1; 00105 } 00106 00107 if (!res) { 00108 res = ast_get_txt(chan, data, dest, sizeof(dest), tech, sizeof(tech), txt, sizeof(txt)); 00109 } 00110 00111 /* Parse it out */ 00112 if (res > 0) { 00113 if (!ast_strlen_zero(txt)) { 00114 pbx_builtin_setvar_helper(chan, "TXTCIDNAME", txt); 00115 pbx_builtin_setvar_helper(chan, "TXTCIDNAMESTATUS", "SUCCESS"); 00116 if (option_debug > 1) 00117 ast_log(LOG_DEBUG, "TXTCIDNAME got '%s'\n", txt); 00118 } 00119 } 00120 if (!res) { 00121 /* Look for a "busy" place */ 00122 if (priority_jump || option_priority_jumping) 00123 ast_goto_if_exists(chan, chan->context, chan->exten, chan->priority + 101); 00124 pbx_builtin_setvar_helper(chan, "TXTCIDNAMESTATUS", "FAILED"); 00125 } else if (res > 0) 00126 res = 0; 00127 00128 LOCAL_USER_REMOVE(u); 00129 00130 return res; 00131 }
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).
Definition at line 133 of file app_txtcidname.c.
References ast_unregister_application(), and STANDARD_HANGUP_LOCALUSERS.
00134 { 00135 int res; 00136 00137 res = ast_unregister_application(app); 00138 00139 STANDARD_HANGUP_LOCALUSERS; 00140 00141 return res; 00142 }
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.
Definition at line 154 of file app_txtcidname.c.
References STANDARD_USECOUNT.
00155 { 00156 int res; 00157 STANDARD_USECOUNT(res); 00158 return res; 00159 }
char* app = "TXTCIDName" [static] |
Definition at line 51 of file app_txtcidname.c.
char* descrip [static] |
Definition at line 55 of file app_txtcidname.c.
Definition at line 47 of file app_txtcidname.c.
Definition at line 45 of file app_txtcidname.c.
Definition at line 53 of file app_txtcidname.c.
char* tdesc = "TXTCIDName" [static] |
Definition at line 49 of file app_txtcidname.c.