mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-03-13 20:50:41 +00:00
cleanup a tiny bit
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@8203 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
a68c60c1f1
commit
9194729a83
@ -29,6 +29,7 @@
|
|||||||
* mod_perl.c -- Perl
|
* mod_perl.c -- Perl
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
|
|
||||||
#ifdef __ICC
|
#ifdef __ICC
|
||||||
#pragma warning (disable:1419)
|
#pragma warning (disable:1419)
|
||||||
#endif
|
#endif
|
||||||
@ -47,8 +48,6 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_perl_load);
|
|||||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_perl_shutdown);
|
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_perl_shutdown);
|
||||||
SWITCH_MODULE_DEFINITION(mod_perl, mod_perl_load, mod_perl_shutdown, NULL);
|
SWITCH_MODULE_DEFINITION(mod_perl, mod_perl_load, mod_perl_shutdown, NULL);
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static STRLEN n_a;
|
static STRLEN n_a;
|
||||||
|
|
||||||
static struct {
|
static struct {
|
||||||
@ -57,7 +56,6 @@ static struct {
|
|||||||
char *xml_handler;
|
char *xml_handler;
|
||||||
} globals;
|
} globals;
|
||||||
|
|
||||||
|
|
||||||
static void Perl_safe_eval(PerlInterpreter *my_perl, const char *string, int tf)
|
static void Perl_safe_eval(PerlInterpreter *my_perl, const char *string, int tf)
|
||||||
{
|
{
|
||||||
char *st = switch_mprintf("eval { %s }; $__ERR = $@", string);
|
char *st = switch_mprintf("eval { %s }; $__ERR = $@", string);
|
||||||
@ -89,7 +87,6 @@ static perl_parse_and_execute (PerlInterpreter *my_perl, char *input_code, char
|
|||||||
{
|
{
|
||||||
int error = 0;
|
int error = 0;
|
||||||
|
|
||||||
|
|
||||||
if (*input_code == '~') {
|
if (*input_code == '~') {
|
||||||
char *buff = input_code + 1;
|
char *buff = input_code + 1;
|
||||||
perl_parse(my_perl, xs_init, 3, embedding, NULL);
|
perl_parse(my_perl, xs_init, 3, embedding, NULL);
|
||||||
@ -108,8 +105,6 @@ static perl_parse_and_execute (PerlInterpreter *my_perl, char *input_code, char
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
static void perl_function(switch_core_session_t *session, char *data)
|
static void perl_function(switch_core_session_t *session, char *data)
|
||||||
{
|
{
|
||||||
char *uuid = switch_core_session_get_uuid(session);
|
char *uuid = switch_core_session_get_uuid(session);
|
||||||
@ -197,7 +192,6 @@ SWITCH_STANDARD_API(perl_api_function) {
|
|||||||
if (session) {
|
if (session) {
|
||||||
uuid = switch_core_session_get_uuid(session);
|
uuid = switch_core_session_get_uuid(session);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
switch_snprintf(code, sizeof(code),
|
switch_snprintf(code, sizeof(code),
|
||||||
"use lib '%s/perl';\n"
|
"use lib '%s/perl';\n"
|
||||||
@ -210,7 +204,6 @@ SWITCH_STANDARD_API(perl_api_function) {
|
|||||||
|
|
||||||
SWITCH_GLOBAL_dirs.base_dir,
|
SWITCH_GLOBAL_dirs.base_dir,
|
||||||
switch_str_nil(uuid)
|
switch_str_nil(uuid)
|
||||||
|
|
||||||
);
|
);
|
||||||
|
|
||||||
perl_parse(my_perl, xs_init, 3, embedding, NULL);
|
perl_parse(my_perl, xs_init, 3, embedding, NULL);
|
||||||
@ -235,11 +228,9 @@ SWITCH_STANDARD_API(perl_api_function) {
|
|||||||
Perl_safe_eval(my_perl, "undef(*);", TRUE);
|
Perl_safe_eval(my_perl, "undef(*);", TRUE);
|
||||||
destroy_perl(&my_perl);
|
destroy_perl(&my_perl);
|
||||||
|
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
static switch_xml_t perl_fetch(const char *section,
|
static switch_xml_t perl_fetch(const char *section,
|
||||||
const char *tag_name,
|
const char *tag_name,
|
||||||
const char *key_name,
|
const char *key_name,
|
||||||
@ -282,7 +273,6 @@ static switch_xml_t perl_fetch(const char *section,
|
|||||||
sv_setpv(this, section);
|
sv_setpv(this, section);
|
||||||
hv_store(hash, "section", 7, this, 0);
|
hv_store(hash, "section", 7, this, 0);
|
||||||
|
|
||||||
|
|
||||||
if (switch_strlen_zero(tag_name)) {
|
if (switch_strlen_zero(tag_name)) {
|
||||||
tag_name = "";
|
tag_name = "";
|
||||||
}
|
}
|
||||||
@ -299,7 +289,6 @@ static switch_xml_t perl_fetch(const char *section,
|
|||||||
sv_setpv(this, key_name);
|
sv_setpv(this, key_name);
|
||||||
hv_store(hash, "key_name", 8, this, 0);
|
hv_store(hash, "key_name", 8, this, 0);
|
||||||
|
|
||||||
|
|
||||||
if (switch_strlen_zero(key_value)) {
|
if (switch_strlen_zero(key_value)) {
|
||||||
key_value = "";
|
key_value = "";
|
||||||
}
|
}
|
||||||
@ -312,7 +301,6 @@ static switch_xml_t perl_fetch(const char *section,
|
|||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
if (params) {
|
if (params) {
|
||||||
for (hp = params->headers; hp; hp = hp->next) {
|
for (hp = params->headers; hp; hp = hp->next) {
|
||||||
this = newSV(strlen(hp->value)+1);
|
this = newSV(strlen(hp->value)+1);
|
||||||
@ -344,16 +332,13 @@ static switch_xml_t perl_fetch(const char *section,
|
|||||||
}
|
}
|
||||||
|
|
||||||
return xml;
|
return xml;
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
static switch_status_t do_config(void)
|
static switch_status_t do_config(void)
|
||||||
{
|
{
|
||||||
|
|
||||||
char *cf = "perl.conf";
|
char *cf = "perl.conf";
|
||||||
switch_xml_t cfg, xml, settings, param;
|
switch_xml_t cfg, xml, settings, param;
|
||||||
|
|
||||||
|
|
||||||
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
|
if (!(xml = switch_xml_open_cfg(cf, &cfg, NULL))) {
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "open of %s failed\n", cf);
|
||||||
return SWITCH_STATUS_TERM;
|
return SWITCH_STATUS_TERM;
|
||||||
@ -375,13 +360,11 @@ static switch_status_t do_config(void)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
switch_xml_free(xml);
|
switch_xml_free(xml);
|
||||||
|
|
||||||
return SWITCH_STATUS_SUCCESS;
|
return SWITCH_STATUS_SUCCESS;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
SWITCH_MODULE_LOAD_FUNCTION(mod_perl_load)
|
SWITCH_MODULE_LOAD_FUNCTION(mod_perl_load)
|
||||||
{
|
{
|
||||||
switch_application_interface_t *app_interface;
|
switch_application_interface_t *app_interface;
|
||||||
@ -397,15 +380,10 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_perl_load)
|
|||||||
}
|
}
|
||||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Allocated perl intrepreter.\n");
|
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_INFO, "Allocated perl intrepreter.\n");
|
||||||
|
|
||||||
|
|
||||||
perl_construct(my_perl);
|
perl_construct(my_perl);
|
||||||
perl_parse(my_perl, xs_init, 3, embedding, NULL);
|
perl_parse(my_perl, xs_init, 3, embedding, NULL);
|
||||||
perl_run(my_perl);
|
perl_run(my_perl);
|
||||||
globals.my_perl = my_perl;
|
globals.my_perl = my_perl;
|
||||||
|
|
||||||
//switch_snprintf(code, sizeof(code), "use lib '%s/perl';use freeswitch\n", SWITCH_GLOBAL_dirs.base_dir);
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/* connect my internal structure to the blank pointer passed to me */
|
/* connect my internal structure to the blank pointer passed to me */
|
||||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user