[Freeswitch-svn] [commit] r4508 - in freeswitch/trunk: . src src/include w32/Library

Freeswitch SVN mikej at freeswitch.org
Sat Mar 10 20:07:47 EST 2007


Author: mikej
Date: Sat Mar 10 20:07:47 2007
New Revision: 4508

Modified:
   freeswitch/trunk/Makefile.am
   freeswitch/trunk/src/include/switch_am_config.h.in
   freeswitch/trunk/src/include/switch_types.h
   freeswitch/trunk/src/switch_core.c
   freeswitch/trunk/w32/Library/FreeSwitchCore.vcproj

Log:
push prefix dir from configure instead of from the makefile to clean up the compile line a bit.  Follow-up commit of autotools, please hold.

Modified: freeswitch/trunk/Makefile.am
==============================================================================
--- freeswitch/trunk/Makefile.am	(original)
+++ freeswitch/trunk/Makefile.am	Sat Mar 10 20:07:47 2007
@@ -88,14 +88,6 @@
 
 CORE_CFLAGS     = $(shell $(APR_CONFIG) --cflags --cppflags --includes)
 CORE_CFLAGS    += $(shell $(APU_CONFIG) --includes)
-CORE_CFLAGS    += -DSWITCH_MOD_DIR=\"$(PREFIX)/mod\"
-CORE_CFLAGS    += -DSWITCH_PREFIX_DIR=\"$(PREFIX)\"
-CORE_CFLAGS    += -DSWITCH_CONF_DIR=\"$(PREFIX)/conf\"
-CORE_CFLAGS	   += -DSWITCH_DB_DIR=\"$(PREFIX)/db\"
-CORE_CFLAGS	   += -DSWITCH_LOG_DIR=\"$(PREFIX)/log\"
-CORE_CFLAGS	   += -DSWITCH_SCRIPT_DIR=\"$(PREFIX)/scripts\"
-CORE_CFLAGS	   += -DSWITCH_HTDOCS_DIR=\"$(PREFIX)/htdocs\"
-CORE_CFLAGS	   += -DSWITCH_GRAMMAR_DIR=\"$(PREFIX)/grammar\"
 
 CORE_LDFLAGS    = $(shell $(APR_CONFIG) --link-ld --libs )
 CORE_LDFLAGS   += $(shell $(APU_CONFIG) --link-ld --libs )

Modified: freeswitch/trunk/src/include/switch_am_config.h.in
==============================================================================
--- freeswitch/trunk/src/include/switch_am_config.h.in	(original)
+++ freeswitch/trunk/src/include/switch_am_config.h.in	Sat Mar 10 20:07:47 2007
@@ -9,6 +9,7 @@
 #define SWITCH_SSIZE_T @ssize_t_value@
 
 #define SWITCH_SIZEOF_VOIDP @voidp_size@
+#define SWITCH_PREFIX_DIR @prefix@
 
 @ssize_t_fmt@
 @size_t_fmt@

Modified: freeswitch/trunk/src/include/switch_types.h
==============================================================================
--- freeswitch/trunk/src/include/switch_types.h	(original)
+++ freeswitch/trunk/src/include/switch_types.h	Sat Mar 10 20:07:47 2007
@@ -98,7 +98,6 @@
 #define SWITCH_SEQ_CLEARLINEEND SWITCH_SEQ_ESC SWITCH_SEQ_CLEARLINEEND_CHAR
 #define SWITCH_SEQ_CLEARSCR SWITCH_SEQ_ESC SWITCH_SEQ_CLEARSCR_CHAR SWITCH_SEQ_HOME
 
-
 #ifdef WIN32
 #define SWITCH_PATH_SEPARATOR "\\"
 #else
@@ -107,38 +106,6 @@
 
 #define SWITCH_URL_SEPARATOR "://"
 
-#ifndef SWITCH_PREFIX_DIR
-#define SWITCH_PREFIX_DIR "."
-#endif
-
-#ifndef SWITCH_MOD_DIR
-#define SWITCH_MOD_DIR SWITCH_PREFIX_DIR SWITCH_PATH_SEPARATOR "mod"
-#endif
-
-#ifndef SWITCH_CONF_DIR
-#define SWITCH_CONF_DIR SWITCH_PREFIX_DIR SWITCH_PATH_SEPARATOR "conf"
-#endif
-
-#ifndef SWITCH_LOG_DIR
-#define SWITCH_LOG_DIR SWITCH_PREFIX_DIR SWITCH_PATH_SEPARATOR "log"
-#endif
-
-#ifndef SWITCH_DB_DIR
-#define SWITCH_DB_DIR SWITCH_PREFIX_DIR SWITCH_PATH_SEPARATOR "db"
-#endif
-
-#ifndef SWITCH_SCRIPT_DIR
-#define SWITCH_SCRIPT_DIR SWITCH_PREFIX_DIR SWITCH_PATH_SEPARATOR "scripts"
-#endif
-
-#ifndef SWITCH_HTDOCS_DIR
-#define SWITCH_HTDOCS_DIR SWITCH_PREFIX_DIR SWITCH_PATH_SEPARATOR "htdocs"
-#endif
-
-#ifndef SWITCH_GRAMMAR_DIR
-#define SWITCH_GRAMMAR_DIR SWITCH_PREFIX_DIR SWITCH_PATH_SEPARATOR "grammar"
-#endif
-
 #define SWITCH_ENDPOINT_DISPOSITION_VARIABLE "endpoint_disposition"
 #define SWITCH_EXPORT_VARS_VARIABLE "export_vars"
 #define SWITCH_R_SDP_VARIABLE "switch_r_sdp"

Modified: freeswitch/trunk/src/switch_core.c
==============================================================================
--- freeswitch/trunk/src/switch_core.c	(original)
+++ freeswitch/trunk/src/switch_core.c	Sat Mar 10 20:07:47 2007
@@ -145,7 +145,7 @@
 	switch_media_bug_t *bugs;
 };
 
-SWITCH_DECLARE_DATA switch_directories SWITCH_GLOBAL_dirs;
+SWITCH_DECLARE_DATA switch_directories SWITCH_GLOBAL_dirs = {0};
 
 struct switch_core_runtime {
 	switch_time_t initiated;
@@ -4230,63 +4230,98 @@
 }
 #endif
 
+#ifndef SWITCH_PREFIX_DIR
+#define SWITCH_PREFIX_DIR "."
+#endif
+
 SWITCH_DECLARE(void) switch_core_set_globals(void)
 {
-#ifdef WIN32
 #define BUFSIZE 1024
+#ifdef WIN32
     char lpPathBuffer[BUFSIZE];
 	DWORD dwBufSize=BUFSIZE;
-	char exePath[1024];
+	char base_dir[1024];
 	char *lastbacklash;
-	GetModuleFileName( NULL, exePath, BUFSIZE );
-	lastbacklash = strrchr( exePath, '\\');
-	exePath[(lastbacklash - exePath + 1)] = '\0';
+	GetModuleFileName( NULL, base_dir, BUFSIZE );
+	lastbacklash = strrchr( base_dir, '\\');
+	base_dir[(lastbacklash - base_dir)] = '\0';
+#else
+	char base_dir[1024] = SWITCH_PREFIX_DIR;
+#endif
+
 	if (!SWITCH_GLOBAL_dirs.base_dir && (SWITCH_GLOBAL_dirs.base_dir = (char *) malloc(BUFSIZE))) {
-		snprintf(SWITCH_GLOBAL_dirs.base_dir, BUFSIZE, "%s", exePath);
+		switch_snprintf(SWITCH_GLOBAL_dirs.base_dir, BUFSIZE, "%s", base_dir);
 	}
+
 	if (!SWITCH_GLOBAL_dirs.mod_dir && (SWITCH_GLOBAL_dirs.mod_dir = (char *) malloc(BUFSIZE))) {
-		snprintf(SWITCH_GLOBAL_dirs.mod_dir, BUFSIZE, "%smod", exePath);
+#ifdef SWITCH_MOD_DIR
+		switch_snprintf(SWITCH_GLOBAL_dirs.mod_dir, BUFSIZE, "%s", SWITCH_MOD_DIR);
+#else
+		switch_snprintf(SWITCH_GLOBAL_dirs.mod_dir, BUFSIZE, "%s%smod", base_dir, SWITCH_PATH_SEPARATOR);
+#endif
 	}
+
 	if (!SWITCH_GLOBAL_dirs.conf_dir && (SWITCH_GLOBAL_dirs.conf_dir = (char *) malloc(BUFSIZE))) {
-		snprintf(SWITCH_GLOBAL_dirs.conf_dir, BUFSIZE, "%sconf", exePath);
+#ifdef SWITCH_CONF_DIR
+		switch_snprintf(SWITCH_GLOBAL_dirs.conf_dir, BUFSIZE, "%s", SWITCH_CONF_DIR);
+#else
+		switch_snprintf(SWITCH_GLOBAL_dirs.conf_dir, BUFSIZE, "%s%sconf", base_dir, SWITCH_PATH_SEPARATOR);
+#endif
 	}
+
 	if (!SWITCH_GLOBAL_dirs.log_dir && (SWITCH_GLOBAL_dirs.log_dir = (char *) malloc(BUFSIZE))) {
-		snprintf(SWITCH_GLOBAL_dirs.log_dir, BUFSIZE, "%slog", exePath);
+#ifdef SWITCH_LOG_DIR
+		switch_snprintf(SWITCH_GLOBAL_dirs.log_dir, BUFSIZE, "%s", SWITCH_LOG_DIR);
+#else
+		switch_snprintf(SWITCH_GLOBAL_dirs.log_dir, BUFSIZE, "%s%slog", base_dir, SWITCH_PATH_SEPARATOR);
+#endif
 	}
+
 	if (!SWITCH_GLOBAL_dirs.db_dir && (SWITCH_GLOBAL_dirs.db_dir = (char *) malloc(BUFSIZE))) {
-		snprintf(SWITCH_GLOBAL_dirs.db_dir, BUFSIZE, "%sdb", exePath);
+#ifdef SWITCH_DB_DIR
+		switch_snprintf(SWITCH_GLOBAL_dirs.db_dir, BUFSIZE, "%s", SWITCH_DB_DIR);
+#else
+		switch_snprintf(SWITCH_GLOBAL_dirs.db_dir, BUFSIZE, "%s%sdb", base_dir, SWITCH_PATH_SEPARATOR);
+#endif
 	}
+
 	if (!SWITCH_GLOBAL_dirs.script_dir && (SWITCH_GLOBAL_dirs.script_dir = (char *) malloc(BUFSIZE))) {
-		snprintf(SWITCH_GLOBAL_dirs.script_dir, BUFSIZE, "%sscripts", exePath);
+#ifdef SWITCH_SCRIPT_DIR
+		switch_snprintf(SWITCH_GLOBAL_dirs.script_dir, BUFSIZE, "%s", SWITCH_SCRIPT_DIR);
+#else
+		switch_snprintf(SWITCH_GLOBAL_dirs.script_dir, BUFSIZE, "%s%sscripts", base_dir, SWITCH_PATH_SEPARATOR);
+#endif
 	}
+
 	if (!SWITCH_GLOBAL_dirs.htdocs_dir && (SWITCH_GLOBAL_dirs.htdocs_dir = (char *) malloc(BUFSIZE))) {
-		snprintf(SWITCH_GLOBAL_dirs.htdocs_dir, BUFSIZE, "%shtdocs", exePath);
-	}
-	if (!SWITCH_GLOBAL_dirs.htdocs_dir && (SWITCH_GLOBAL_dirs.grammar_dir = (char *) malloc(BUFSIZE))) {
-		snprintf(SWITCH_GLOBAL_dirs.grammar_dir, BUFSIZE, "%sgrammar", exePath);
+#ifdef SWITCH_HTDOCS_DIR
+		switch_snprintf(SWITCH_GLOBAL_dirs.htdocs_dir, BUFSIZE, "%s", SWITCH_HTDOCS_DIR);
+#else
+		switch_snprintf(SWITCH_GLOBAL_dirs.htdocs_dir, BUFSIZE, "%s%shtdocs", base_dir, SWITCH_PATH_SEPARATOR);
+#endif
 	}
+
+	if (!SWITCH_GLOBAL_dirs.grammar_dir && (SWITCH_GLOBAL_dirs.grammar_dir = (char *) malloc(BUFSIZE))) {
+#ifdef SWITCH_GRAMMAR_DIR
+		switch_snprintf(SWITCH_GLOBAL_dirs.grammar_dir, BUFSIZE, "%s", SWITCH_GRAMMAR_DIR);
 #else
-	SWITCH_GLOBAL_dirs.base_dir = SWITCH_PREFIX_DIR;
-	SWITCH_GLOBAL_dirs.mod_dir = SWITCH_MOD_DIR;
-	if(!SWITCH_GLOBAL_dirs.conf_dir) SWITCH_GLOBAL_dirs.conf_dir = SWITCH_CONF_DIR;
-	if(!SWITCH_GLOBAL_dirs.log_dir) SWITCH_GLOBAL_dirs.log_dir = SWITCH_LOG_DIR;
-	if(!SWITCH_GLOBAL_dirs.db_dir) SWITCH_GLOBAL_dirs.db_dir = SWITCH_DB_DIR;
-	SWITCH_GLOBAL_dirs.script_dir = SWITCH_SCRIPT_DIR;
-	SWITCH_GLOBAL_dirs.htdocs_dir = SWITCH_HTDOCS_DIR;
-	SWITCH_GLOBAL_dirs.grammar_dir = SWITCH_GRAMMAR_DIR;
+		switch_snprintf(SWITCH_GLOBAL_dirs.grammar_dir, BUFSIZE, "%s%sgrammar", base_dir, SWITCH_PATH_SEPARATOR);
 #endif
+	}
+
+	if (!SWITCH_GLOBAL_dirs.temp_dir && (SWITCH_GLOBAL_dirs.temp_dir = (char *) malloc(BUFSIZE))) {
 #ifdef SWITCH_TEMP_DIR
-	SWITCH_GLOBAL_dirs.temp_dir = SWITCH_TEMP_DIR;
+		switch_snprintf(SWITCH_GLOBAL_dirs.temp_dir, BUFSIZE, "%s", SWITCH_TEMP_DIR);
 #else
 #ifdef WIN32
-	GetTempPath(dwBufSize, lpPathBuffer);
-	if (!SWITCH_GLOBAL_dirs.temp_dir && (SWITCH_GLOBAL_dirs.temp_dir = (char *) malloc(BUFSIZE))) {
-		snprintf(SWITCH_GLOBAL_dirs.temp_dir, BUFSIZE, "%s", lpPathBuffer);
-	}
+		GetTempPath(dwBufSize, lpPathBuffer);
+		switch_snprintf(SWITCH_GLOBAL_dirs.temp_dir, BUFSIZE, "%s", lpPathBuffer);
 #else
-	SWITCH_GLOBAL_dirs.temp_dir = "/tmp/";
+		switch_snprintf(SWITCH_GLOBAL_dirs.temp_dir, BUFSIZE, "%s", "/tmp/");
 #endif
 #endif
+	}
+
 }
 
 
@@ -4678,17 +4713,15 @@
 
     switch_yield(1000000);
 
-#ifdef WIN32
-	free(SWITCH_GLOBAL_dirs.base_dir);
-	free(SWITCH_GLOBAL_dirs.mod_dir);
-	free(SWITCH_GLOBAL_dirs.conf_dir);
-	free(SWITCH_GLOBAL_dirs.log_dir);
-	free(SWITCH_GLOBAL_dirs.db_dir);
-	free(SWITCH_GLOBAL_dirs.script_dir);
-	free(SWITCH_GLOBAL_dirs.htdocs_dir);
-	free(SWITCH_GLOBAL_dirs.grammar_dir);
-	free(SWITCH_GLOBAL_dirs.temp_dir);
-#endif
+	switch_safe_free(SWITCH_GLOBAL_dirs.base_dir);
+	switch_safe_free(SWITCH_GLOBAL_dirs.mod_dir);
+	switch_safe_free(SWITCH_GLOBAL_dirs.conf_dir);
+	switch_safe_free(SWITCH_GLOBAL_dirs.log_dir);
+	switch_safe_free(SWITCH_GLOBAL_dirs.db_dir);
+	switch_safe_free(SWITCH_GLOBAL_dirs.script_dir);
+	switch_safe_free(SWITCH_GLOBAL_dirs.htdocs_dir);
+	switch_safe_free(SWITCH_GLOBAL_dirs.grammar_dir);
+	switch_safe_free(SWITCH_GLOBAL_dirs.temp_dir);
 
 	if (runtime.memory_pool) {
 		apr_pool_destroy(runtime.memory_pool);

Modified: freeswitch/trunk/w32/Library/FreeSwitchCore.vcproj
==============================================================================
--- freeswitch/trunk/w32/Library/FreeSwitchCore.vcproj	(original)
+++ freeswitch/trunk/w32/Library/FreeSwitchCore.vcproj	Sat Mar 10 20:07:47 2007
@@ -404,6 +404,26 @@
 			Name="Generated Header Files"
 			>
 			<File
+				RelativePath="..\..\src\include\switch_am_config.h.in"
+				>
+				<FileConfiguration
+					Name="Debug|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCustomBuildTool"
+					/>
+				</FileConfiguration>
+				<FileConfiguration
+					Name="Release|Win32"
+					ExcludedFromBuild="true"
+					>
+					<Tool
+						Name="VCCustomBuildTool"
+					/>
+				</FileConfiguration>
+			</File>
+			<File
 				RelativePath="..\..\src\include\switch_version.h.in"
 				>
 				<FileConfiguration



More information about the Freeswitch-svn mailing list