#include <sys/types.h>
#include <stdlib.h>
#include <string.h>
#include "asterisk.h"
#include "asterisk/channel.h"
#include "asterisk/cdr.h"
#include "asterisk/module.h"
#include "asterisk/pbx.h"
#include "asterisk/logger.h"
#include "asterisk/config.h"
#include "asterisk/manager.h"
#include "asterisk/utils.h"
Include dependency graph for app_setcdruserfield.c:
Go to the source code of this file.
Functions | |
static int | action_setcdruserfield (struct mansession *s, struct message *m) |
static int | appendcdruserfield_exec (struct ast_channel *chan, void *data) |
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 | setcdruserfield_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 * | appendcdruserfield_app = "AppendCDRUserField" |
static char * | appendcdruserfield_descrip |
static char * | appendcdruserfield_synopsis = "Append to the CDR user field" |
LOCAL_USER_DECL | |
static char * | setcdruserfield_app = "SetCDRUserField" |
static char * | setcdruserfield_descrip |
static char * | setcdruserfield_synopsis = "Set the CDR user field" |
STANDARD_LOCAL_USER | |
static char * | tdesc = "CDR user field apps" |
Definition in file app_setcdruserfield.c.
|
Definition at line 79 of file app_setcdruserfield.c. References ast_cdr_appenduserfield(), ast_cdr_setuserfield(), ast_get_channel_by_name_locked(), ast_mutex_unlock(), ast_strlen_zero(), ast_true(), astman_get_header(), astman_send_ack(), and astman_send_error(). Referenced by load_module(). 00080 { 00081 struct ast_channel *c = NULL; 00082 char *userfield = astman_get_header(m, "UserField"); 00083 char *channel = astman_get_header(m, "Channel"); 00084 char *append = astman_get_header(m, "Append"); 00085 00086 if (ast_strlen_zero(channel)) { 00087 astman_send_error(s, m, "No Channel specified"); 00088 return 0; 00089 } 00090 if (ast_strlen_zero(userfield)) { 00091 astman_send_error(s, m, "No UserField specified"); 00092 return 0; 00093 } 00094 c = ast_get_channel_by_name_locked(channel); 00095 if (!c) { 00096 astman_send_error(s, m, "No such channel"); 00097 return 0; 00098 } 00099 if (ast_true(append)) 00100 ast_cdr_appenduserfield(c, userfield); 00101 else 00102 ast_cdr_setuserfield(c, userfield); 00103 ast_mutex_unlock(&c->lock); 00104 astman_send_ack(s, m, "CDR Userfield Set"); 00105 return 0; 00106 }
|
|
Definition at line 124 of file app_setcdruserfield.c. References ast_cdr_appenduserfield(), ast_channel::cdr, LOCAL_USER_ADD, and LOCAL_USER_REMOVE. Referenced by load_module(). 00125 { 00126 struct localuser *u; 00127 int res = 0; 00128 00129 LOCAL_USER_ADD(u); 00130 00131 if (chan->cdr && data) { 00132 ast_cdr_appenduserfield(chan, (char*)data); 00133 } 00134 00135 LOCAL_USER_REMOVE(u); 00136 00137 return res; 00138 }
|
|
Provides a description of the module.
Definition at line 164 of file app_setcdruserfield.c. References tdesc. 00165 { 00166 return tdesc; 00167 }
|
|
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 176 of file app_setcdruserfield.c. References ASTERISK_GPL_KEY. 00177 { 00178 return ASTERISK_GPL_KEY; 00179 }
|
|
|
Definition at line 108 of file app_setcdruserfield.c. References ast_cdr_setuserfield(), ast_channel::cdr, LOCAL_USER_ADD, and LOCAL_USER_REMOVE. Referenced by load_module(). 00109 { 00110 struct localuser *u; 00111 int res = 0; 00112 00113 LOCAL_USER_ADD(u); 00114 00115 if (chan->cdr && data) { 00116 ast_cdr_setuserfield(chan, (char*)data); 00117 } 00118 00119 LOCAL_USER_REMOVE(u); 00120 00121 return res; 00122 }
|
|
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 140 of file app_setcdruserfield.c. References appendcdruserfield_app, ast_manager_unregister(), ast_unregister_application(), setcdruserfield_app, and STANDARD_HANGUP_LOCALUSERS. 00141 { 00142 int res; 00143 00144 res = ast_unregister_application(setcdruserfield_app); 00145 res |= ast_unregister_application(appendcdruserfield_app); 00146 res |= ast_manager_unregister("SetCDRUserField"); 00147 00148 STANDARD_HANGUP_LOCALUSERS; 00149 00150 return res; 00151 }
|
|
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 169 of file app_setcdruserfield.c. References STANDARD_USECOUNT. 00170 { 00171 int res; 00172 STANDARD_USECOUNT(res); 00173 return res; 00174 }
|
|
Definition at line 72 of file app_setcdruserfield.c. Referenced by load_module(), and unload_module(). |
|
Definition at line 61 of file app_setcdruserfield.c. Referenced by load_module(). |
|
Definition at line 73 of file app_setcdruserfield.c. Referenced by load_module(). |
|
Definition at line 77 of file app_setcdruserfield.c. |
|
Definition at line 58 of file app_setcdruserfield.c. Referenced by load_module(), and unload_module(). |
|
Definition at line 46 of file app_setcdruserfield.c. Referenced by load_module(). |
|
Definition at line 59 of file app_setcdruserfield.c. Referenced by load_module(). |
|
Definition at line 75 of file app_setcdruserfield.c. |
|
Definition at line 44 of file app_setcdruserfield.c. |