提交 62e510c9 authored 作者: Anthony Minessale's avatar Anthony Minessale

general haphazzard rearrangement

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@702 d0543943-73ff-0310-b7d9-9358b9ac24b2
上级 bafc4668
......@@ -40,6 +40,7 @@ AM_CFLAGS += -DSWITCH_PREFIX_DIR=\"$(PREFIX)\"
AM_CFLAGS += -DSWITCH_CONF_DIR=\"$(PREFIX)/conf\"
AM_CFLAGS += -DSWITCH_DB_DIR=\"$(PREFIX)/db\"
AM_CFLAGS += -DSWITCH_LOG_DIR=\"$(PREFIX)/log\"
AM_CFLAGS += -DSWITCH_SCRIPT_DIR=\"$(PREFIX)/scripts\"
libfreeswitch_la_SOURCES = \
......@@ -184,7 +185,7 @@ modwipe:
install_mod: modules
@echo Installing $(NAME)
@mkdir -p $(PREFIX) $(PREFIX)/conf $(PREFIX)/mod $(PREFIX)/db $(PREFIX)/log $(PREFIX)/bin
@mkdir -p $(PREFIX) $(PREFIX)/conf $(PREFIX)/mod $(PREFIX)/db $(PREFIX)/log $(PREFIX)/bin $(PREFIX)/scripts
@if [ -f .libs/$(NAME) ] ; then /bin/cp -p .libs/$(NAME) $(PREFIX)/bin ; else /bin/cp -p ./$(NAME) $(PREFIX)/bin ; fi
@echo Installing Modules
@rm -f build/freeswitch.env
......
......@@ -244,7 +244,8 @@ AM_CFLAGS = -I$(PREFIX)/include $(shell $(APR_CONFIG) --cflags \
-DSWITCH_PREFIX_DIR=\"$(PREFIX)\" \
-DSWITCH_CONF_DIR=\"$(PREFIX)/conf\" \
-DSWITCH_DB_DIR=\"$(PREFIX)/db\" \
-DSWITCH_LOG_DIR=\"$(PREFIX)/log\"
-DSWITCH_LOG_DIR=\"$(PREFIX)/log\" \
-DSWITCH_SCRIPT_DIR=\"$(PREFIX)/scripts\"
AM_LDFLAGS = -L$(PREFIX)/lib $(shell $(APR_CONFIG) --link-ld --libs ) \
$(shell $(APU_CONFIG) --link-ld --libs ) -lsqlite3 -lteletone \
-lresample -lm -L/usr/local/lib/db42 -L/usr/local/lib \
......@@ -1059,7 +1060,7 @@ modwipe:
install_mod: modules
@echo Installing $(NAME)
@mkdir -p $(PREFIX) $(PREFIX)/conf $(PREFIX)/mod $(PREFIX)/db $(PREFIX)/log $(PREFIX)/bin
@mkdir -p $(PREFIX) $(PREFIX)/conf $(PREFIX)/mod $(PREFIX)/db $(PREFIX)/log $(PREFIX)/bin $(PREFIX)/scripts
@if [ -f .libs/$(NAME) ] ; then /bin/cp -p .libs/$(NAME) $(PREFIX)/bin ; else /bin/cp -p ./$(NAME) $(PREFIX)/bin ; fi
@echo Installing Modules
@rm -f build/freeswitch.env
......
......@@ -892,11 +892,16 @@ SWITCH_DECLARE(switch_status) switch_core_directory_close(switch_directory_handl
SWITCH_DECLARE(FILE *) switch_core_data_channel(switch_text_channel channel);
/*!
\brief Set the output console to the desired FILE stream
\param handle the FILE stream
\brief Set the output console to the desired file
\param console the file path
*/
SWITCH_DECLARE(void) switch_core_set_console(FILE *handle);
SWITCH_DECLARE(switch_status) switch_core_set_console(char *console);
/*!
\brief Get the output console
\return the FILE stream
*/
SWITCH_DECLARE(FILE *) switch_core_get_console(void);
/*!
\brief Launch a thread
*/
......
......@@ -41,6 +41,42 @@ extern "C" {
#include <switch.h>
#include <switch_platform.h>
#ifndef SWITCH_PREFIX_DIR
#define SWITCH_PREFIX_DIR "."
#endif
#ifndef SWITCH_MOD_DIR
#define SWITCH_MODDIR "./mod"
#endif
#ifndef SWITCH_CONF_DIR
#define SWITCH_CONF_DIR "./conf"
#endif
#ifndef SWITCH_LOG_DIR
#define SWITCH_LOG_DIR "./log"
#endif
#ifndef SWITCH_DB_DIR
#define SWITCH_DB_DIR "./db"
#endif
#ifndef SWITCH_SCRIPT_DIR
#define SWITCH_SCRIPT_DIR "./scripts"
#endif
struct switch_directories {
char *base_dir;
char *mod_dir;
char *conf_dir;
char *log_dir;
char *db_dir;
char *script_dir;
};
typedef struct switch_directories switch_directories;
extern switch_directories SWITCH_GLOBAL_dirs;
#define SWITCH_RECCOMMENDED_BUFFER_SIZE 131072
#define SWITCH_MAX_CODECS 30
#define SWITCH_MAX_STATE_HANDLERS 30
......
......@@ -60,7 +60,7 @@ endif
endif
CFLAGS += -I$(BASE)/libs/mozilla/js/src -Wall -Wno-format -g -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DHAVE_LOCALTIME_R -DX86_LINUX -DDEBUG -DDEBUG_root -DJS_THREADSAFE -I$(BASE)/libs/mozilla/js/src -I$(BASE)/libs/mozilla/js/src/$(OS_CONFIG)_DBG.OBJ -Wall -Wno-format -g -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DHAVE_LOCALTIME_R -DX86_LINUX -DDEBUG -DDEBUG_root -DJS_THREADSAFE -I$(BASE)/libs/mozilla/nsprpub/dist/include/nspr -I$(OS_CONFIG)_DBG.OBJ
LDFLAGS +=-DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DHAVE_LOCALTIME_R -DX86_LINUX -DDEBUG -DDEBUG_root -DJS_THREADSAFE -I$(BASE)/libs/mozilla/nsprpub/dist/include/nspr -Wall -Wno-format -g -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DHAVE_LOCALTIME_R -DX86_LINUX -DDEBUG -DDEBUG_root -DJS_THREADSAFE -I$(BASE)/libs/mozilla/nsprpub/dist/include/nspr
LDFLAGS +=-DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DHAVE_LOCALTIME_R -DX86_LINUX -DDEBUG -DDEBUG_root -DJS_THREADSAFE -I$(BASE)/libs/mozilla/nsprpub/dist/include/nspr -Wall -Wno-format -g -DXP_UNIX -DSVR4 -DSYSV -D_BSD_SOURCE -DPOSIX_SOURCE -DHAVE_LOCALTIME_R -DX86_LINUX -DDEBUG -DDEBUG_root -DJS_THREADSAFE -I$(BASE)/libs/mozilla/nsprpub/dist/include/nspr -lteletone
OBJS=$(BASE)/libs/mozilla/js/src/$(OS_CONFIG)_DBG.OBJ/libjs.a $(BASE)/libs/mozilla/nsprpub/dist/lib/libnspr4.a
LINKER=$(CC)
......
......@@ -29,14 +29,8 @@
* switch.c -- Main
*
*/
#include <switch.h>
#ifndef SWITCH_LOG_DIR
#ifdef WIN32
#define SWITCH_LOG_DIR ".\\log"
#else
#define SWITCH_LOG_DIR "/usr/local/freeswitch/log"
#endif
#endif
static int RUNNING = 0;
......@@ -82,10 +76,17 @@ int main(int argc, char *argv[])
char sep = '/';
int pid;
nice(-20);
#endif
if (switch_core_init(NULL) != SWITCH_STATUS_SUCCESS) {
fprintf(stderr, "Cannot Initilize\n");
return 255;
}
#ifndef WIN32
if (argv[1] && !strcmp(argv[1], "-stop")) {
pid_t pid = 0;
snprintf(path, sizeof(path), "%s%c%s", SWITCH_LOG_DIR, sep, pfile);
snprintf(path, sizeof(path), "%s%c%s", SWITCH_GLOBAL_dirs.conf_dir, sep, pfile);
if ((f = fopen(path, "r")) == 0) {
fprintf(stderr, "Cannot open pid file %s.\n", path);
return 255;
......@@ -128,7 +129,7 @@ int main(int argc, char *argv[])
#endif
}
snprintf(path, sizeof(path), "%s%c%s", SWITCH_LOG_DIR, sep, pfile);
snprintf(path, sizeof(path), "%s%c%s", SWITCH_GLOBAL_dirs.conf_dir, sep, pfile);
if ((f = fopen(path, "w")) == 0) {
fprintf(stderr, "Cannot open pid file %s.\n", path);
return 255;
......@@ -138,13 +139,13 @@ int main(int argc, char *argv[])
fclose(f);
if (bg) {
snprintf(path, sizeof(path), "%s%c%s", SWITCH_LOG_DIR, sep, lfile);
snprintf(path, sizeof(path), "%s%c%s", SWITCH_GLOBAL_dirs.conf_dir, sep, lfile);
if (switch_core_set_console(path) != SWITCH_STATUS_SUCCESS) {
err = "Cannot open log file\n";
}
if (switch_core_init(bg ? path : NULL) != SWITCH_STATUS_SUCCESS) {
err = "Cannot Initilize\n";
}
if (!err) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Bringing up environment.\n");
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Loading Modules.\n");
......@@ -164,7 +165,7 @@ int main(int argc, char *argv[])
}
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "freeswitch Version %s Started\n\n", SWITCH_VERSION_FULL);
snprintf(path, sizeof(path), "%s%c%s", SWITCH_LOG_DIR, sep, pfile);
snprintf(path, sizeof(path), "%s%c%s", SWITCH_GLOBAL_dirs.conf_dir, sep, pfile);
if (bg) {
bg = 0;
......
......@@ -31,14 +31,6 @@
*/
#include <switch_config.h>
#ifndef SWITCH_CONF_DIR
#ifdef WIN32
#define SWITCH_CONF_DIR ".\\conf"
#else
#define SWITCH_CONF_DIR "/usr/local/freeswitch/conf"
#endif
#endif
SWITCH_DECLARE(int) switch_config_open_file(switch_config *cfg, char *file_path)
{
FILE *f;
......@@ -48,7 +40,7 @@ SWITCH_DECLARE(int) switch_config_open_file(switch_config *cfg, char *file_path)
if (file_path[0] == '/') {
path = file_path;
} else {
snprintf(path_buf, sizeof(path_buf), "%s/%s", SWITCH_CONF_DIR, file_path);
snprintf(path_buf, sizeof(path_buf), "%s/%s", SWITCH_GLOBAL_dirs.conf_dir, file_path);
path = path_buf;
}
......@@ -64,7 +56,7 @@ SWITCH_DECLARE(int) switch_config_open_file(switch_config *cfg, char *file_path)
int last = -1;
char *var, *val;
snprintf(path_buf, sizeof(path_buf), "%s/freeswitch.conf", SWITCH_CONF_DIR);
snprintf(path_buf, sizeof(path_buf), "%s/freeswitch.conf", SWITCH_GLOBAL_dirs.conf_dir);
path = path_buf;
if ((f = fopen(path, "r")) == 0) {
......
......@@ -85,6 +85,8 @@ struct switch_core_session {
void *private_info;
};
switch_directories SWITCH_GLOBAL_dirs;
struct switch_core_runtime {
time_t initiated;
unsigned long session_id;
......@@ -137,9 +139,19 @@ SWITCH_DECLARE(switch_core_db *) switch_core_db_open_file(char *filename)
return db;
}
SWITCH_DECLARE(void) switch_core_set_console(FILE *handle)
SWITCH_DECLARE(switch_status) switch_core_set_console(char *console)
{
if ((runtime.console = fopen(console, "a")) == 0) {
fprintf(stderr, "Cannot open output file %s.\n", console);
return SWITCH_STATUS_FALSE;
}
return SWITCH_STATUS_SUCCESS;
}
SWITCH_DECLARE(FILE *) switch_core_get_console(void)
{
runtime.console = handle;
return runtime.console;
}
SWITCH_DECLARE(FILE *) switch_core_data_channel(switch_text_channel channel)
......@@ -2179,14 +2191,21 @@ static void core_event_handler(switch_event *event)
SWITCH_DECLARE(switch_status) switch_core_init(char *console)
{
memset(&runtime, 0, sizeof(runtime));
SWITCH_GLOBAL_dirs.base_dir = SWITCH_PREFIX_DIR;
SWITCH_GLOBAL_dirs.mod_dir = SWITCH_MOD_DIR;
SWITCH_GLOBAL_dirs.conf_dir = SWITCH_CONF_DIR;
SWITCH_GLOBAL_dirs.log_dir = SWITCH_LOG_DIR;
SWITCH_GLOBAL_dirs.db_dir = SWITCH_DB_DIR;
SWITCH_GLOBAL_dirs.script_dir = SWITCH_SCRIPT_DIR;
#ifdef EMBED_PERL
PerlInterpreter *my_perl;
#endif
if(console) {
if ((runtime.console = fopen(console, "a")) == 0) {
fprintf(stderr, "Cannot open output file %s.\n", console);
return SWITCH_STATUS_FALSE;
}
switch_core_set_console(console);
} else {
runtime.console = stdout;
}
......@@ -2241,7 +2260,6 @@ SWITCH_DECLARE(switch_status) switch_core_init(char *console)
switch_core_hash_init(&runtime.session_table, runtime.memory_pool);
time(&runtime.initiated);
return SWITCH_STATUS_SUCCESS;
}
......
......@@ -259,7 +259,6 @@ SWITCH_DECLARE(switch_status) switch_ivr_play_file(switch_core_session *session,
return SWITCH_STATUS_GENERR;
}
switch_channel_answer(channel);
write_frame.data = abuf;
write_frame.buflen = sizeof(abuf);
......@@ -313,7 +312,6 @@ SWITCH_DECLARE(switch_status) switch_ivr_play_file(switch_core_session *session,
int do_speed = 1;
int last_speed = -1;
if (dtmf_callback || buf) {
/*
dtmf handler function you can hook up to be executed when a digit is dialed during playback
......@@ -414,7 +412,6 @@ SWITCH_DECLARE(switch_status) switch_ivr_play_file(switch_core_session *session,
done = 1;
break;
}
if (done) {
break;
}
......
......@@ -31,13 +31,6 @@
*/
#include <switch_console.h>
#ifndef SWITCH_MOD_DIR
#ifdef WIN32
#define SWITCH_MOD_DIR ".\\mod"
#else
#define SWITCH_MOD_DIR "/usr/local/freeswitch/mod"
#endif
#endif
struct switch_loadable_module {
char *filename;
......@@ -371,7 +364,7 @@ SWITCH_DECLARE(switch_status) switch_loadable_module_init()
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Invalid extension for %s\n", val);
continue;
}
process_module_file((char *) SWITCH_MOD_DIR, (char *) val);
process_module_file((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) val);
}
}
}
......@@ -387,8 +380,8 @@ SWITCH_DECLARE(switch_status) switch_loadable_module_init()
}
if (all) {
if (apr_dir_open(&module_dir_handle, SWITCH_MOD_DIR, loadable_modules.pool) != APR_SUCCESS) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't open directory: %s\n", SWITCH_MOD_DIR);
if (apr_dir_open(&module_dir_handle, SWITCH_GLOBAL_dirs.mod_dir, loadable_modules.pool) != APR_SUCCESS) {
switch_console_printf(SWITCH_CHANNEL_CONSOLE, "Can't open directory: %s\n", SWITCH_GLOBAL_dirs.mod_dir);
return SWITCH_STATUS_GENERR;
}
}
......@@ -413,7 +406,7 @@ SWITCH_DECLARE(switch_status) switch_loadable_module_init()
continue;
}
process_module_file((char *) SWITCH_MOD_DIR, (char *) fname);
process_module_file((char *) SWITCH_GLOBAL_dirs.mod_dir, (char *) fname);
}
apr_dir_close(module_dir_handle);
}
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论