mirror of
https://github.com/signalwire/freeswitch.git
synced 2025-04-14 08:05:37 +00:00
optimize pcre and fix autoheadache
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@386 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
b1ab21b5ca
commit
9cfa0cf916
@ -93,7 +93,7 @@ freeswitch_SOURCES = src/switch.c
|
|||||||
freeswitch_CFLAGS = $(AM_CFLAGS)
|
freeswitch_CFLAGS = $(AM_CFLAGS)
|
||||||
freeswitch_LDFLAGS = -lfreeswitch
|
freeswitch_LDFLAGS = -lfreeswitch
|
||||||
nodist_freeswitch_SOURCES = src/include/switch_version.h
|
nodist_freeswitch_SOURCES = src/include/switch_version.h
|
||||||
BUILT_SOURCES = depends version
|
BUILT_SOURCES = version depends
|
||||||
CLEANFILES = src/include/switch_version.h
|
CLEANFILES = src/include/switch_version.h
|
||||||
|
|
||||||
version: Makefile
|
version: Makefile
|
||||||
@ -111,8 +111,7 @@ nodepends: .nodepends
|
|||||||
yesdepends:
|
yesdepends:
|
||||||
rm .nodepends
|
rm .nodepends
|
||||||
|
|
||||||
|
.depend:
|
||||||
depends:
|
|
||||||
./buildlib.sh . install sqlite-3.2.8.tar.gz --prefix=$(PREFIX) --disable-tcl --enable-threadsafe
|
./buildlib.sh . install sqlite-3.2.8.tar.gz --prefix=$(PREFIX) --disable-tcl --enable-threadsafe
|
||||||
./buildlib.sh . install apr-1.2.2.tar.gz --prefix=$(PREFIX)
|
./buildlib.sh . install apr-1.2.2.tar.gz --prefix=$(PREFIX)
|
||||||
./buildlib.sh . install apr-util-1.2.2.tar.gz --with-apr=../apr-1.2.2 --prefix=$(PREFIX)
|
./buildlib.sh . install apr-util-1.2.2.tar.gz --with-apr=../apr-1.2.2 --prefix=$(PREFIX)
|
||||||
@ -120,6 +119,10 @@ depends:
|
|||||||
cp libs/libresample-0.1.3/*.a $(PREFIX)/lib
|
cp libs/libresample-0.1.3/*.a $(PREFIX)/lib
|
||||||
cp libs/libresample-0.1.3/include/* $(PREFIX)/include
|
cp libs/libresample-0.1.3/include/* $(PREFIX)/include
|
||||||
ranlib $(PREFIX)/lib/libresample.a
|
ranlib $(PREFIX)/lib/libresample.a
|
||||||
|
touch .depend
|
||||||
|
|
||||||
|
depends: .depend
|
||||||
|
|
||||||
|
|
||||||
modules: $(NAME)
|
modules: $(NAME)
|
||||||
@echo making modules
|
@echo making modules
|
||||||
|
@ -300,7 +300,7 @@ freeswitch_SOURCES = src/switch.c
|
|||||||
freeswitch_CFLAGS = $(AM_CFLAGS)
|
freeswitch_CFLAGS = $(AM_CFLAGS)
|
||||||
freeswitch_LDFLAGS = -lfreeswitch
|
freeswitch_LDFLAGS = -lfreeswitch
|
||||||
nodist_freeswitch_SOURCES = src/include/switch_version.h
|
nodist_freeswitch_SOURCES = src/include/switch_version.h
|
||||||
BUILT_SOURCES = depends version
|
BUILT_SOURCES = version depends
|
||||||
CLEANFILES = src/include/switch_version.h
|
CLEANFILES = src/include/switch_version.h
|
||||||
all: $(BUILT_SOURCES)
|
all: $(BUILT_SOURCES)
|
||||||
$(MAKE) $(AM_MAKEFLAGS) all-recursive
|
$(MAKE) $(AM_MAKEFLAGS) all-recursive
|
||||||
@ -983,7 +983,7 @@ nodepends: .nodepends
|
|||||||
yesdepends:
|
yesdepends:
|
||||||
rm .nodepends
|
rm .nodepends
|
||||||
|
|
||||||
depends:
|
.depend:
|
||||||
./buildlib.sh . install sqlite-3.2.8.tar.gz --prefix=$(PREFIX) --disable-tcl --enable-threadsafe
|
./buildlib.sh . install sqlite-3.2.8.tar.gz --prefix=$(PREFIX) --disable-tcl --enable-threadsafe
|
||||||
./buildlib.sh . install apr-1.2.2.tar.gz --prefix=$(PREFIX)
|
./buildlib.sh . install apr-1.2.2.tar.gz --prefix=$(PREFIX)
|
||||||
./buildlib.sh . install apr-util-1.2.2.tar.gz --with-apr=../apr-1.2.2 --prefix=$(PREFIX)
|
./buildlib.sh . install apr-util-1.2.2.tar.gz --with-apr=../apr-1.2.2 --prefix=$(PREFIX)
|
||||||
@ -991,6 +991,9 @@ depends:
|
|||||||
cp libs/libresample-0.1.3/*.a $(PREFIX)/lib
|
cp libs/libresample-0.1.3/*.a $(PREFIX)/lib
|
||||||
cp libs/libresample-0.1.3/include/* $(PREFIX)/include
|
cp libs/libresample-0.1.3/include/* $(PREFIX)/include
|
||||||
ranlib $(PREFIX)/lib/libresample.a
|
ranlib $(PREFIX)/lib/libresample.a
|
||||||
|
touch .depend
|
||||||
|
|
||||||
|
depends: .depend
|
||||||
|
|
||||||
modules: $(NAME)
|
modules: $(NAME)
|
||||||
@echo making modules
|
@echo making modules
|
||||||
|
@ -52,9 +52,10 @@ switch_caller_extension *dialplan_hunt(switch_core_session *session)
|
|||||||
char *var, *val;
|
char *var, *val;
|
||||||
char app[1024] = "";
|
char app[1024] = "";
|
||||||
int catno = -1;
|
int catno = -1;
|
||||||
char *regex = NULL;
|
|
||||||
char *exten_name = NULL;
|
char *exten_name = NULL;
|
||||||
pcre *re = NULL;
|
pcre *re = NULL;
|
||||||
|
int match_count = 0;
|
||||||
|
int ovector[30];
|
||||||
|
|
||||||
channel = switch_core_session_get_channel(session);
|
channel = switch_core_session_get_channel(session);
|
||||||
caller_profile = switch_channel_get_caller_profile(channel);
|
caller_profile = switch_channel_get_caller_profile(channel);
|
||||||
@ -69,12 +70,11 @@ switch_caller_extension *dialplan_hunt(switch_core_session *session)
|
|||||||
|
|
||||||
while (switch_config_next_pair(&cfg, &var, &val)) {
|
while (switch_config_next_pair(&cfg, &var, &val)) {
|
||||||
if (cfg.catno != catno) { /* new category */
|
if (cfg.catno != catno) { /* new category */
|
||||||
regex = NULL;
|
|
||||||
catno = cfg.catno;
|
catno = cfg.catno;
|
||||||
exten_name = cfg.category;
|
exten_name = cfg.category;
|
||||||
|
cleanre();
|
||||||
|
match_count = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
if (!strcasecmp(var, "regex")) {
|
if (!strcasecmp(var, "regex")) {
|
||||||
const char *error = NULL;
|
const char *error = NULL;
|
||||||
@ -88,15 +88,13 @@ switch_caller_extension *dialplan_hunt(switch_core_session *session)
|
|||||||
&erroffset, /* for error offset */
|
&erroffset, /* for error offset */
|
||||||
NULL); /* use default character tables */
|
NULL); /* use default character tables */
|
||||||
if (error) {
|
if (error) {
|
||||||
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "ERROR: %d %s\n", erroffset, error);
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "COMPILE ERROR: %d [%s]\n", erroffset, error);
|
||||||
cleanre();
|
cleanre();
|
||||||
|
switch_channel_hangup(channel);
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
} else if (!strcasecmp(var, "match")) {
|
|
||||||
int rc;
|
|
||||||
int ovector[30];
|
|
||||||
|
|
||||||
rc = pcre_exec(
|
match_count = pcre_exec(
|
||||||
re, /* result of pcre_compile() */
|
re, /* result of pcre_compile() */
|
||||||
NULL, /* we didn't study the pattern */
|
NULL, /* we didn't study the pattern */
|
||||||
caller_profile->destination_number, /* the subject string */
|
caller_profile->destination_number, /* the subject string */
|
||||||
@ -105,16 +103,17 @@ switch_caller_extension *dialplan_hunt(switch_core_session *session)
|
|||||||
0, /* default options */
|
0, /* default options */
|
||||||
ovector, /* vector of integers for substring information */
|
ovector, /* vector of integers for substring information */
|
||||||
sizeof(ovector) / sizeof(ovector[0])); /* number of elements (NOT size in bytes) */
|
sizeof(ovector) / sizeof(ovector[0])); /* number of elements (NOT size in bytes) */
|
||||||
|
} else if (match_count > 0 && !strcasecmp(var, "match")) {
|
||||||
|
if (!re) {
|
||||||
if (rc > 0) {
|
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "ERROR: match without regex in %s line %d\n", cfg.path, cfg.lineno);
|
||||||
|
continue;
|
||||||
|
} else {
|
||||||
char newval[1024] = "";
|
char newval[1024] = "";
|
||||||
char index[10] = "";
|
char index[10] = "";
|
||||||
char replace[128] = "";
|
char replace[128] = "";
|
||||||
int x, y=0, z=0, num = 0;
|
int x, y=0, z=0, num = 0;
|
||||||
char *data;
|
char *data;
|
||||||
|
|
||||||
|
|
||||||
for (x = 0; x < sizeof(newval) && x < strlen(val);) {
|
for (x = 0; x < sizeof(newval) && x < strlen(val);) {
|
||||||
if (val[x] == '$') {
|
if (val[x] == '$') {
|
||||||
x++;
|
x++;
|
||||||
@ -127,7 +126,7 @@ switch_caller_extension *dialplan_hunt(switch_core_session *session)
|
|||||||
z = 0;
|
z = 0;
|
||||||
num = atoi(index);
|
num = atoi(index);
|
||||||
|
|
||||||
if (pcre_copy_substring(caller_profile->destination_number, ovector, rc, num, replace, sizeof(replace)) > 0) {
|
if (pcre_copy_substring(caller_profile->destination_number, ovector, match_count, num, replace, sizeof(replace)) > 0) {
|
||||||
int r;
|
int r;
|
||||||
for(r = 0; r < strlen(replace); r++) {
|
for(r = 0; r < strlen(replace); r++) {
|
||||||
newval[y++] = replace[r];
|
newval[y++] = replace[r];
|
||||||
@ -161,11 +160,9 @@ switch_caller_extension *dialplan_hunt(switch_core_session *session)
|
|||||||
|
|
||||||
switch_caller_extension_add_application(session, extension, app, data);
|
switch_caller_extension_add_application(session, extension, app, data);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
switch_config_close_file(&cfg);
|
switch_config_close_file(&cfg);
|
||||||
|
|
||||||
if (extension) {
|
if (extension) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user