fs_cli add colors on windows and build static
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10938 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
d4ae1a8f1c
commit
c9a4b3af08
|
@ -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=""$(ProjectDir)getopt";"$(ProjectDir)src/include""
|
||||
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"
|
||||
|
|
|
@ -40,7 +40,16 @@ static void handle_SIGINT(int sig)
|
|||
}
|
||||
|
||||
|
||||
static const char* COLORS[] = { ESL_SEQ_DEFAULT_COLOR, ESL_SEQ_FRED, ESL_SEQ_FRED,
|
||||
#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 @@ static void *msg_thread_run(esl_thread_t *me, void *obj)
|
|||
}
|
||||
|
||||
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 @@ int main(int argc, char *argv[])
|
|||
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);
|
||||
|
|
|
@ -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,21 +63,11 @@
|
|||
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"
|
||||
/>
|
||||
|
@ -87,9 +77,6 @@
|
|||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
|
@ -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,19 +126,11 @@
|
|||
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"
|
||||
/>
|
||||
|
@ -161,9 +140,6 @@
|
|||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
|
|
|
@ -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 @@ typedef struct esl_event esl_event_t;
|
|||
#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
|
||||
|
|
Loading…
Reference in New Issue