fix fatal include
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@4471 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
c8dfa63c82
commit
54d483c4f5
|
@ -289,6 +289,7 @@ SWITCH_DECLARE(void) switch_perform_substitution(pcre *re, int match_count, char
|
|||
#define SWITCH_READ_ACCEPTABLE(status) (status == SWITCH_STATUS_SUCCESS || status == SWITCH_STATUS_BREAK)
|
||||
SWITCH_DECLARE(size_t) switch_url_encode(char *url, char *buf, size_t len);
|
||||
SWITCH_DECLARE(char *) switch_url_decode(char *s);
|
||||
SWITCH_DECLARE(switch_status_t) switch_file_exists(const char *filename);
|
||||
SWITCH_END_EXTERN_C
|
||||
|
||||
#endif
|
||||
|
|
|
@ -7,7 +7,7 @@ depends:
|
|||
MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install js --prefix=$(PREFIX) --with-pic --with-nspr=yes
|
||||
MAKE=$(MAKE) $(BASE)/build/buildlib.sh $(BASE) install curl --prefix=$(PREFIX) --without-libidn
|
||||
|
||||
$(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).c
|
||||
$(MODNAME).$(DYNAMIC_LIB_EXTEN): $(MODNAME).c $(MODNAME).h
|
||||
$(CC) $(CFLAGS) -c $(MODNAME).c -o $(MODNAME).o
|
||||
$(CC) $(SOLINK) -o $(MODNAME).$(DYNAMIC_LIB_EXTEN) $(MODNAME).o $(OBJS) $(LDFLAGS)
|
||||
|
||||
|
|
|
@ -2248,7 +2248,9 @@ static JSBool js_include(JSContext *cx, JSObject *obj, uintN argc, jsval *argv,
|
|||
{
|
||||
char *code;
|
||||
if ( argc > 0 && (code = JS_GetStringBytes(JS_ValueToString(cx, argv[0])))) {
|
||||
eval_some_js(code, cx, obj, rval);
|
||||
if (eval_some_js(code, cx, obj, rval) < 0) {
|
||||
return JS_FALSE;
|
||||
}
|
||||
return JS_TRUE;
|
||||
}
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Invalid Arguements\n");
|
||||
|
|
|
@ -81,7 +81,8 @@ int eval_some_js(char *code, JSContext *cx, JSObject *obj, jsval *rval)
|
|||
JSScript *script = NULL;
|
||||
char *cptr;
|
||||
char *path = NULL;
|
||||
int res = 0;
|
||||
char *script_name;
|
||||
int result = 0;
|
||||
|
||||
JS_ClearPendingException(cx);
|
||||
|
||||
|
@ -90,19 +91,28 @@ int eval_some_js(char *code, JSContext *cx, JSObject *obj, jsval *rval)
|
|||
script = JS_CompileScript(cx, obj, cptr, strlen(cptr), "inline", 1);
|
||||
} else {
|
||||
if (*code == '/') {
|
||||
script = JS_CompileFile(cx, obj, code);
|
||||
script_name = code;
|
||||
} else if ((path = switch_mprintf("%s%s%s", SWITCH_GLOBAL_dirs.script_dir, SWITCH_PATH_SEPARATOR, code))) {
|
||||
script = JS_CompileFile(cx, obj, path);
|
||||
switch_safe_free(path);
|
||||
script_name = path;
|
||||
}
|
||||
if (script_name) {
|
||||
if (switch_file_exists(script_name) == SWITCH_STATUS_SUCCESS) {
|
||||
script = JS_CompileFile(cx, obj, script_name);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Cannot Open File: %s\n", script_name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (script) {
|
||||
res = JS_ExecuteScript(cx, obj, script, rval) == JS_TRUE ? 1 : 0;
|
||||
result = JS_ExecuteScript(cx, obj, script, rval) == JS_TRUE ? 1 : 0;
|
||||
JS_DestroyScript(cx, script);
|
||||
} else {
|
||||
result = -1;
|
||||
}
|
||||
|
||||
return res;
|
||||
|
||||
switch_safe_free(path);
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -331,6 +331,20 @@ SWITCH_DECLARE(switch_time_t) switch_str_time(char *in)
|
|||
|
||||
}
|
||||
|
||||
SWITCH_DECLARE(switch_status_t) switch_file_exists(const char *filename)
|
||||
{
|
||||
int32_t wanted = APR_FINFO_TYPE;
|
||||
apr_finfo_t info = {0};
|
||||
if (filename) {
|
||||
apr_stat(&info, filename, wanted, NULL);
|
||||
if (info.filetype != APR_NOFILE) {
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
}
|
||||
return SWITCH_STATUS_FALSE;
|
||||
}
|
||||
|
||||
|
||||
SWITCH_DECLARE(char *) switch_priority_name(switch_priority_t priority)
|
||||
{
|
||||
switch(priority) { /*lol*/
|
||||
|
|
Loading…
Reference in New Issue