Mon Mar 20 08:25:48 2006

Asterisk developer's documentation


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

app_txtcidname.c File Reference

Caller*id name lookup - Look up the caller's name via DNS. More...

#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"

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 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

char * app = "TXTCIDName"
char * descrip
 LOCAL_USER_DECL
 STANDARD_LOCAL_USER
char * synopsis = "Lookup caller name from TXT record"
char * tdesc = "TXTCIDName"


Detailed Description

Caller*id name lookup - Look up the caller's name via DNS.

Definition in file app_txtcidname.c.


Function Documentation

char* description void   ) 
 

Provides a description of the module.

Returns:
a short description of your 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;
 }

Returns:
ASTERISK_GPL_KEY

Definition at line 161 of file app_txtcidname.c.

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.

Returns:
int Always 0.

Definition at line 144 of file app_txtcidname.c.

References app, ast_register_application(), descrip, synopsis, and txtcidname_exec().

00145 {
00146    return ast_register_application(app, txtcidname_exec, synopsis, descrip);
00147 }

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(), ast_channel::context, dep_warning, ast_channel::exten, LOCAL_USER_ADD, LOCAL_USER_REMOVE, LOG_DEBUG, LOG_ERROR, LOG_WARNING, option_debug, pbx_builtin_setvar_helper(), and ast_channel::priority.

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).

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

Definition at line 133 of file app_txtcidname.c.

References app, and ast_unregister_application().

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.

Returns:
The module's usecount.

Definition at line 154 of file app_txtcidname.c.

References STANDARD_USECOUNT.

00155 {
00156    int res;
00157    STANDARD_USECOUNT(res);
00158    return res;
00159 }


Variable Documentation

char* app = "TXTCIDName" [static]
 

Definition at line 51 of file app_txtcidname.c.

Referenced by load_module(), and unload_module().

char* descrip [static]
 

Definition at line 55 of file app_txtcidname.c.

Referenced by load_module().

LOCAL_USER_DECL
 

Definition at line 47 of file app_txtcidname.c.

STANDARD_LOCAL_USER
 

Definition at line 45 of file app_txtcidname.c.

char* synopsis = "Lookup caller name from TXT record" [static]
 

Definition at line 53 of file app_txtcidname.c.

Referenced by load_module().

char* tdesc = "TXTCIDName" [static]
 

Definition at line 49 of file app_txtcidname.c.


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