#include <stdlib.h>
#include <stdio.h>
#include "asterisk.h"
#include "asterisk/module.h"
#include "asterisk/channel.h"
#include "asterisk/pbx.h"
#include "asterisk/utils.h"
#include "asterisk/lock.h"
#include "asterisk/file.h"
#include "asterisk/logger.h"
#include "asterisk/options.h"
#include "asterisk/enum.h"
Go to the source code of this file.
Functions | |
char * | description (void) |
Provides a description of the module. | |
char * | function_enum (struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) |
char * | function_txtcidname (struct ast_channel *chan, char *cmd, char *data, char *buf, size_t len) |
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. | |
Variables | |
ast_custom_function | enum_function |
LOCAL_USER_DECL | |
STANDARD_LOCAL_USER | |
char * | synopsis = "Syntax: ENUMLOOKUP(number[,Method-type[,options|record#[,zone-suffix]]])\n" |
char * | tdesc = "ENUM Related Functions" |
ast_custom_function | txtcidname_function |
Definition in file func_enum.c.
|
Provides a description of the module.
Definition at line 224 of file func_enum.c. 00225 {
00226 return tdesc;
00227 }
|
|
Definition at line 54 of file func_enum.c. References ast_get_enum(), ast_log(), ast_strlen_zero(), LOCAL_USER_ACF_ADD, LOCAL_USER_REMOVE, LOG_WARNING, s, and synopsis. 00055 { 00056 int res=0; 00057 char tech[80]; 00058 char dest[256] = ""; 00059 char *zone; 00060 char *options; 00061 struct localuser *u; 00062 char *params[4]; 00063 char *p = data; 00064 char *s; 00065 int i = 0; 00066 00067 00068 if (ast_strlen_zero(data)) { 00069 ast_log(LOG_WARNING, synopsis); 00070 return ""; 00071 } 00072 00073 do { 00074 if(i>3){ 00075 ast_log(LOG_WARNING, synopsis); 00076 return ""; 00077 } 00078 params[i++] = p; 00079 p = strchr(p, '|'); 00080 if(p){ 00081 *p = '\0'; 00082 p++; 00083 } 00084 } while(p); 00085 00086 if(i < 1){ 00087 ast_log(LOG_WARNING, synopsis); 00088 return ""; 00089 } 00090 00091 if( (i > 1 && strlen(params[1]) == 0) || i < 2){ 00092 ast_copy_string(tech, "sip", sizeof(tech)); 00093 } else { 00094 ast_copy_string(tech, params[1], sizeof(tech)); 00095 } 00096 00097 if( (i > 3 && strlen(params[3]) == 0) || i<4){ 00098 zone = "e164.arpa"; 00099 } else { 00100 zone = params[3]; 00101 } 00102 00103 if( (i > 2 && strlen(params[2]) == 0) || i<3){ 00104 options = "1"; 00105 } else { 00106 options = params[2]; 00107 } 00108 00109 /* strip any '-' signs from number */ 00110 p = params[0]; 00111 /* 00112 while(*p == '+'){ 00113 p++; 00114 } 00115 */ 00116 s = p; 00117 i = 0; 00118 while(*p && *s){ 00119 if(*s == '-'){ 00120 s++; 00121 } else { 00122 p[i++] = *s++; 00123 } 00124 } 00125 p[i] = 0; 00126 00127 LOCAL_USER_ACF_ADD(u); 00128 00129 res = ast_get_enum(chan, p, dest, sizeof(dest), tech, sizeof(tech), zone, options); 00130 00131 LOCAL_USER_REMOVE(u); 00132 00133 p = strchr(dest, ':'); 00134 if(p && strncasecmp(tech, "ALL", sizeof(tech))) { 00135 ast_copy_string(buf, p+1, sizeof(dest)); 00136 } else { 00137 ast_copy_string(buf, dest, sizeof(dest)); 00138 } 00139 00140 return buf; 00141 }
|
|
Definition at line 158 of file func_enum.c. References ast_get_txt(), ast_log(), ast_strlen_zero(), LOCAL_USER_ACF_ADD, LOCAL_USER_REMOVE, and LOG_WARNING. 00159 { 00160 int res; 00161 char tech[80]; 00162 char txt[256] = ""; 00163 char dest[80]; 00164 struct localuser *u; 00165 00166 LOCAL_USER_ACF_ADD(u); 00167 00168 buf[0] = '\0'; 00169 00170 if (ast_strlen_zero(data)) { 00171 ast_log(LOG_WARNING, "TXTCIDNAME requires an argument (number)\n"); 00172 LOCAL_USER_REMOVE(u); 00173 return buf; 00174 } 00175 00176 res = ast_get_txt(chan, data, dest, sizeof(dest), tech, sizeof(tech), txt, sizeof(txt)); 00177 00178 if (!ast_strlen_zero(txt)) 00179 ast_copy_string(buf, txt, len); 00180 00181 LOCAL_USER_REMOVE(u); 00182 00183 return buf; 00184 }
|
|
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 238 of file func_enum.c. 00239 {
00240 return ASTERISK_GPL_KEY;
00241 }
|
|
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 213 of file func_enum.c. References ast_custom_function_register(), enum_function, and txtcidname_function. 00214 { 00215 int res; 00216 00217 res = ast_custom_function_register(&enum_function); 00218 if (!res) 00219 ast_custom_function_register(&txtcidname_function); 00220 00221 return res; 00222 }
|
|
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 203 of file func_enum.c. References ast_custom_function_unregister(), enum_function, and txtcidname_function. 00204 { 00205 ast_custom_function_unregister(&enum_function); 00206 ast_custom_function_unregister(&txtcidname_function); 00207 00208 STANDARD_HANGUP_LOCALUSERS; 00209 00210 return 0; 00211 }
|
|
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 229 of file func_enum.c. References STANDARD_USECOUNT. 00230 { 00231 int res; 00232 00233 STANDARD_USECOUNT(res); 00234 00235 return res; 00236 }
|
|
Definition at line 146 of file func_enum.c. Referenced by load_module(), and unload_module(). |
|
Definition at line 52 of file func_enum.c. |
|
Definition at line 50 of file func_enum.c. |
|
Definition at line 48 of file func_enum.c. Referenced by function_enum(). |
|
Definition at line 201 of file func_enum.c. |
|
Definition at line 189 of file func_enum.c. Referenced by load_module(), and unload_module(). |