[Freeswitch-svn] [commit] r10938 - in freeswitch/trunk/libs/esl: . src src/include

FreeSWITCH SVN mikej at freeswitch.org
Tue Dec 23 16:00:46 PST 2008


Author: mikej
Date: Tue Dec 23 19:00:45 2008
New Revision: 10938

Log:
fs_cli add colors on windows and build static

Modified:
   freeswitch/trunk/libs/esl/fs_cli.2008.vcproj
   freeswitch/trunk/libs/esl/fs_cli.c
   freeswitch/trunk/libs/esl/src/esl.2008.vcproj
   freeswitch/trunk/libs/esl/src/include/esl.h

Modified: freeswitch/trunk/libs/esl/fs_cli.2008.vcproj
==============================================================================
--- freeswitch/trunk/libs/esl/fs_cli.2008.vcproj	(original)
+++ freeswitch/trunk/libs/esl/fs_cli.2008.vcproj	Tue Dec 23 19:00:45 2008
@@ -43,7 +43,7 @@
 				Name="VCCLCompilerTool"
 				Optimization="0"
 				AdditionalIncludeDirectories=""$(ProjectDir)getopt";"$(ProjectDir)src/include""
-				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE"
+				PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ESL_DECLARE_STATIC"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="3"
@@ -124,7 +124,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				AdditionalIncludeDirectories="&quot;$(ProjectDir)getopt&quot;;&quot;$(ProjectDir)src/include&quot;"
-				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE"
+				PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS;_CRT_NONSTDC_NO_DEPRECATE;_CRT_SECURE_NO_DEPRECATE;ESL_DECLARE_STATIC"
 				RuntimeLibrary="2"
 				UsePrecompiledHeader="0"
 				WarningLevel="4"

Modified: freeswitch/trunk/libs/esl/fs_cli.c
==============================================================================
--- freeswitch/trunk/libs/esl/fs_cli.c	(original)
+++ freeswitch/trunk/libs/esl/fs_cli.c	Tue Dec 23 19:00:45 2008
@@ -40,8 +40,17 @@
 }
 
 
-static const char* COLORS[] = { ESL_SEQ_DEFAULT_COLOR, ESL_SEQ_FRED, ESL_SEQ_FRED, 
-								ESL_SEQ_FRED, ESL_SEQ_FMAGEN, ESL_SEQ_FCYAN, ESL_SEQ_FGREEN, ESL_SEQ_FYELLOW };
+#ifdef WIN32
+static HANDLE hStdout;
+static WORD wOldColorAttrs;
+static CONSOLE_SCREEN_BUFFER_INFO csbiInfo;
+
+static WORD 
+#else
+static const char*
+#endif
+COLORS[] = { ESL_SEQ_DEFAULT_COLOR, ESL_SEQ_FRED, ESL_SEQ_FRED, 
+			ESL_SEQ_FRED, ESL_SEQ_FMAGEN, ESL_SEQ_FCYAN, ESL_SEQ_FGREEN, ESL_SEQ_FYELLOW };
 
 static void *msg_thread_run(esl_thread_t *me, void *obj)
 {
@@ -77,7 +86,15 @@
 						}
 
 						if (tchannel == 0 || (file && !strcmp(file, "switch_console.c"))) {
+#ifdef WIN32
+							DWORD len = (DWORD) strlen(handle->last_event->body);
+							DWORD outbytes = 0;
+							SetConsoleTextAttribute(hStdout, COLORS[level]);
+							WriteFile(hStdout, handle->last_event->body, len, &outbytes, NULL);
+							SetConsoleTextAttribute(hStdout, wOldColorAttrs);
+#else
 							printf("%s%s%s", COLORS[level], handle->last_event->body, ESL_SEQ_DEFAULT_COLOR);
+#endif
 						}
 						known++;
 					} else if (!strcasecmp(type, "text/disconnect-notice")) {
@@ -320,6 +337,12 @@
 	el_set(el, EL_HIST, history, myhistory);
 	history(myhistory, &ev, H_LOAD, hfile);
 #endif
+#ifdef WIN32
+	hStdout = GetStdHandle(STD_OUTPUT_HANDLE);
+	if (hStdout != INVALID_HANDLE_VALUE && GetConsoleScreenBufferInfo(hStdout, &csbiInfo)) {
+		wOldColorAttrs = csbiInfo.wAttributes;
+	}
+#endif
 
 	snprintf(cmd_str, sizeof(cmd_str), "log info\n\n");
 	esl_send_recv(&handle, cmd_str);

Modified: freeswitch/trunk/libs/esl/src/esl.2008.vcproj
==============================================================================
--- freeswitch/trunk/libs/esl/src/esl.2008.vcproj	(original)
+++ freeswitch/trunk/libs/esl/src/esl.2008.vcproj	Tue Dec 23 19:00:45 2008
@@ -20,7 +20,7 @@
 			Name="Debug|Win32"
 			OutputDirectory="$(SolutionDir)Debug"
 			IntermediateDirectory="$(ConfigurationName)"
-			ConfigurationType="2"
+			ConfigurationType="4"
 			CharacterSet="1"
 			>
 			<Tool
@@ -42,14 +42,14 @@
 				Name="VCCLCompilerTool"
 				Optimization="0"
 				AdditionalIncludeDirectories="include"
-				PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;ESL_EXPORTS"
+				PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;ESL_DECLARE_STATIC"
 				MinimalRebuild="true"
 				BasicRuntimeChecks="3"
 				RuntimeLibrary="3"
 				UsePrecompiledHeader="0"
 				WarningLevel="4"
 				WarnAsError="true"
-				DebugInformationFormat="4"
+				DebugInformationFormat="3"
 				DisableSpecificWarnings="4706;4100"
 				EnablePREfast="true"
 			/>
@@ -63,22 +63,12 @@
 				Name="VCPreLinkEventTool"
 			/>
 			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="Ws2_32.lib"
-				ModuleDefinitionFile=""
-				OptimizeReferences="1"
-				EnableCOMDATFolding="1"
-				RandomizedBaseAddress="1"
-				DataExecutionPrevention="0"
-				ImportLibrary="$(IntDir)/$(TargetName).lib"
+				Name="VCLibrarianTool"
 			/>
 			<Tool
 				Name="VCALinkTool"
 			/>
 			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
 				Name="VCXDCMakeTool"
 			/>
 			<Tool
@@ -88,9 +78,6 @@
 				Name="VCFxCopTool"
 			/>
 			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
 				Name="VCPostBuildEventTool"
 			/>
 		</Configuration>
@@ -98,7 +85,7 @@
 			Name="Release|Win32"
 			OutputDirectory="$(SolutionDir)Release"
 			IntermediateDirectory="$(ConfigurationName)"
-			ConfigurationType="2"
+			ConfigurationType="4"
 			CharacterSet="1"
 			WholeProgramOptimization="1"
 			>
@@ -120,7 +107,7 @@
 			<Tool
 				Name="VCCLCompilerTool"
 				AdditionalIncludeDirectories="include"
-				PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;ESL_EXPORTS"
+				PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;ESL_DECLARE_STATIC"
 				RuntimeLibrary="2"
 				UsePrecompiledHeader="0"
 				WarningLevel="4"
@@ -139,20 +126,12 @@
 				Name="VCPreLinkEventTool"
 			/>
 			<Tool
-				Name="VCLinkerTool"
-				AdditionalDependencies="Ws2_32.lib"
-				ModuleDefinitionFile=""
-				RandomizedBaseAddress="1"
-				DataExecutionPrevention="0"
-				ImportLibrary="$(IntDir)/$(TargetName).lib"
+				Name="VCLibrarianTool"
 			/>
 			<Tool
 				Name="VCALinkTool"
 			/>
 			<Tool
-				Name="VCManifestTool"
-			/>
-			<Tool
 				Name="VCXDCMakeTool"
 			/>
 			<Tool
@@ -162,9 +141,6 @@
 				Name="VCFxCopTool"
 			/>
 			<Tool
-				Name="VCAppVerifierTool"
-			/>
-			<Tool
 				Name="VCPostBuildEventTool"
 			/>
 		</Configuration>

Modified: freeswitch/trunk/libs/esl/src/include/esl.h
==============================================================================
--- freeswitch/trunk/libs/esl/src/include/esl.h	(original)
+++ freeswitch/trunk/libs/esl/src/include/esl.h	Tue Dec 23 19:00:45 2008
@@ -42,6 +42,15 @@
 typedef struct esl_event_header esl_event_header_t;
 typedef struct esl_event esl_event_t;
 
+#ifdef WIN32
+#define ESL_SEQ_FWHITE FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_BLUE | FOREGROUND_INTENSITY
+#define ESL_SEQ_FRED FOREGROUND_RED | FOREGROUND_INTENSITY
+#define ESL_SEQ_FMAGEN FOREGROUND_BLUE | FOREGROUND_RED
+#define ESL_SEQ_FCYAN FOREGROUND_GREEN | FOREGROUND_BLUE
+#define ESL_SEQ_FGREEN FOREGROUND_GREEN
+#define ESL_SEQ_FYELLOW FOREGROUND_RED | FOREGROUND_GREEN | FOREGROUND_INTENSITY
+#define ESL_SEQ_DEFAULT_COLOR ESL_SEQ_FWHITE
+#else
 #define ESL_SEQ_ESC "\033["
 /* Ansi Control character suffixes */
 #define ESL_SEQ_HOME_CHAR 'H'
@@ -95,6 +104,7 @@
 #define ESL_SEQ_CLEARLINE ESL_SEQ_ESC ESL_SEQ_CLEARLINE_CHAR_STR
 #define ESL_SEQ_CLEARLINEEND ESL_SEQ_ESC ESL_SEQ_CLEARLINEEND_CHAR
 #define ESL_SEQ_CLEARSCR ESL_SEQ_ESC ESL_SEQ_CLEARSCR_CHAR ESL_SEQ_HOME
+#endif
 
 #if !defined(_XOPEN_SOURCE) && !defined(__FreeBSD__) && !defined(__NetBSD__)
 #define _XOPEN_SOURCE 600



More information about the Freeswitch-svn mailing list