fs_cli now builds on windows, does not yet work

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@10911 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris 2008-12-22 18:53:09 +00:00
parent 63250c91b4
commit d69c309548
6 changed files with 355 additions and 64 deletions

View File

@ -998,7 +998,12 @@ Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "mod_siren", "src\mod\codecs
{1BC8A8EC-E03B-44DF-BCD9-088650F4D29C} = {1BC8A8EC-E03B-44DF-BCD9-088650F4D29C}
EndProjectSection
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "esl", "libs\esl\esl.2008.vcproj", "{CF405366-9558-4AE8-90EF-5E21B51CCB4E}"
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "esl", "libs\esl\src\esl.2008.vcproj", "{CF405366-9558-4AE8-90EF-5E21B51CCB4E}"
EndProject
Project("{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}") = "fs_cli", "libs\esl\fs_cli.2008.vcproj", "{D2FB8043-D208-4AEE-8F18-3B5857C871B9}"
ProjectSection(ProjectDependencies) = postProject
{CF405366-9558-4AE8-90EF-5E21B51CCB4E} = {CF405366-9558-4AE8-90EF-5E21B51CCB4E}
EndProjectSection
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@ -1762,6 +1767,10 @@ Global
{CF405366-9558-4AE8-90EF-5E21B51CCB4E}.Release|Win32.ActiveCfg = Release|Win32
{CF405366-9558-4AE8-90EF-5E21B51CCB4E}.Release|Win32.Build.0 = Release|Win32
{CF405366-9558-4AE8-90EF-5E21B51CCB4E}.Release|x64.ActiveCfg = Release|Win32
{D2FB8043-D208-4AEE-8F18-3B5857C871B9}.Debug|Win32.ActiveCfg = Debug|Win32
{D2FB8043-D208-4AEE-8F18-3B5857C871B9}.Debug|x64.ActiveCfg = Debug|Win32
{D2FB8043-D208-4AEE-8F18-3B5857C871B9}.Release|Win32.ActiveCfg = Release|Win32
{D2FB8043-D208-4AEE-8F18-3B5857C871B9}.Release|x64.ActiveCfg = Release|Win32
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE

258
libs/esl/fs_cli.2008.vcproj Normal file
View File

@ -0,0 +1,258 @@
<?xml version="1.0" encoding="Windows-1252"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="9.00"
Name="fs_cli"
ProjectGUID="{D2FB8043-D208-4AEE-8F18-3B5857C871B9}"
RootNamespace="fs_cli"
Keyword="Win32Proj"
TargetFrameworkVersion="131072"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="..\..\w32\winlibs.vsprops"
CharacterSet="2"
BuildLogFile="$(IntDir)\BuildLog $(ProjectName).htm"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="&quot;$(InputDir)\src\include&quot;"
PreprocessorDefinitions="WIN32;_DEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
RuntimeLibrary="3"
UsePrecompiledHeader="0"
WarningLevel="4"
WarnAsError="true"
DebugInformationFormat="3"
DisableSpecificWarnings="4100;6053;4706"
EnablePREfast="true"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="$(SolutionDir)$(ConfigurationName)/fs_cli.exe"
LinkIncremental="1"
AdditionalLibraryDirectories="$(OutDir)"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/fs_cli.pdb"
SubSystem="1"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
OutputDirectory="$(ConfigurationName)"
IntermediateDirectory="$(ConfigurationName)"
ConfigurationType="1"
InheritedPropertySheets="..\..\w32\winlibs.vsprops"
CharacterSet="2"
BuildLogFile="$(IntDir)\BuildLog $(ProjectName).htm"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="&quot;$(InputDir)\src\include&quot;"
PreprocessorDefinitions="WIN32;NDEBUG;_CONSOLE;_CRT_SECURE_NO_WARNINGS"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
WarningLevel="4"
WarnAsError="true"
DebugInformationFormat="3"
DisableSpecificWarnings="4100;6053;4706"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
OutputFile="$(SolutionDir)$(ConfigurationName)/fs_cli.exe"
LinkIncremental="1"
AdditionalLibraryDirectories="$(OutDir)"
GenerateDebugInformation="true"
ProgramDatabaseFile="$(OutDir)/fs_cli.pdb"
SubSystem="1"
OptimizeReferences="2"
EnableCOMDATFolding="2"
RandomizedBaseAddress="1"
DataExecutionPrevention="0"
TargetMachine="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="Source Files"
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath="fs_cli.c"
>
</File>
</Filter>
<Filter
Name="Header Files"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath="..\..\src\include\switch.h"
>
</File>
<File
RelativePath="..\..\src\include\switch_buffer.h"
>
</File>
<File
RelativePath="..\..\src\include\switch_caller.h"
>
</File>
<File
RelativePath="..\..\src\include\switch_channel.h"
>
</File>
<File
RelativePath="..\..\src\include\switch_config.h"
>
</File>
<File
RelativePath="..\..\src\include\switch_console.h"
>
</File>
<File
RelativePath="..\..\src\include\switch_core.h"
>
</File>
<File
RelativePath="..\..\src\include\switch_frame.h"
>
</File>
<File
RelativePath="..\..\src\include\switch_loadable_module.h"
>
</File>
<File
RelativePath="..\..\src\include\switch_module_interfaces.h"
>
</File>
<File
RelativePath="..\..\src\include\switch_types.h"
>
</File>
<File
RelativePath="..\..\src\include\switch_utils.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx"
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>

View File

@ -2,13 +2,20 @@
#include <stdlib.h>
#include <esl.h>
#include <signal.h>
#include <sys/select.h>
#ifdef WIN32
#define strdup(src) _strdup(src)
#define usleep(time) Sleep(time/1000)
#else
#include <sys/select.h>
#include <histedit.h>
#define HAVE_EDITLINE
#endif
static char prompt_str[512] = "";
static char hostname[512] = "";
#ifdef HAVE_EDITLINE
static char *prompt(EditLine * e)
{
return prompt_str;
@ -17,6 +24,8 @@ static char *prompt(EditLine * e)
static EditLine *el;
static History *myhistory;
static HistEvent ev;
#endif
static int running = 1;
static int thread_running = 0;
@ -149,8 +158,8 @@ static int get_profile(const char *name, cli_profile_t **profile)
int main(int argc, char *argv[])
{
esl_handle_t handle = {{0}};
int count;
const char *line;
int count = 0;
const char *line = NULL;
char cmd_str[1024] = "";
char hfile[512] = "/tmp/fs_cli_history";
char cfile[512] = "/tmp/fs_cli_config";
@ -199,7 +208,7 @@ int main(int argc, char *argv[])
} else if (!strcasecmp(var, "port")) {
int pt = atoi(val);
if (pt > 0) {
profiles[cur].port = pt;
profiles[cur].port = (esl_port_t)pt;
}
}
}
@ -227,7 +236,8 @@ int main(int argc, char *argv[])
}
esl_thread_create_detached(msg_thread_run, &handle);
#ifdef HAVE_EDITLINE
el = el_init(__FILE__, stdout, stdout, stdout);
el_set(el, EL_PROMPT, &prompt);
el_set(el, EL_EDITOR, "emacs");
@ -241,7 +251,8 @@ int main(int argc, char *argv[])
history(myhistory, &ev, H_SETSIZE, 800);
el_set(el, EL_HIST, history, myhistory);
history(myhistory, &ev, H_LOAD, hfile);
#endif
snprintf(cmd_str, sizeof(cmd_str), "log info\n\n");
esl_send_recv(&handle, cmd_str);
@ -249,19 +260,28 @@ int main(int argc, char *argv[])
while (running) {
#ifdef HAVE_EDITLINE
line = el_gets(el, &count);
#endif
if (count > 1) {
if (!esl_strlen_zero(line)) {
char *cmd = strdup(line);
char *p;
#ifdef HAVE_EDITLINE
const LineInfo *lf = el_line(el);
char *foo = (char *) lf->buffer;
#endif
if ((p = strrchr(cmd, '\r')) || (p = strrchr(cmd, '\n'))) {
*p = '\0';
}
assert(cmd != NULL);
#ifdef HAVE_EDITLINE
history(myhistory, &ev, H_ENTER, line);
#endif
if (!strncasecmp(cmd, "...", 3)) {
goto done;
@ -277,8 +297,10 @@ int main(int argc, char *argv[])
}
}
#ifdef HAVE_EDITLINE
el_deletestr(el, strlen(foo) + 1);
memset(foo, 0, strlen(foo));
#endif
free(cmd);
}
}
@ -290,11 +312,13 @@ int main(int argc, char *argv[])
done:
#ifdef HAVE_EDITLINE
history(myhistory, &ev, H_SAVE, hfile);
/* Clean up our memory */
history_end(myhistory);
el_end(el);
#endif
esl_disconnect(&handle);

View File

@ -41,7 +41,7 @@
<Tool
Name="VCCLCompilerTool"
Optimization="0"
AdditionalIncludeDirectories="src/include"
AdditionalIncludeDirectories="include"
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;ESL_EXPORTS"
MinimalRebuild="true"
BasicRuntimeChecks="3"
@ -119,7 +119,7 @@
/>
<Tool
Name="VCCLCompilerTool"
AdditionalIncludeDirectories="src/include"
AdditionalIncludeDirectories="include"
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;_CRT_SECURE_NO_DEPRECATE;_CRT_NONSTDC_NO_DEPRECATE;ESL_EXPORTS"
RuntimeLibrary="2"
UsePrecompiledHeader="0"
@ -178,19 +178,19 @@
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\src\esl.c"
RelativePath=".\esl.c"
>
</File>
<File
RelativePath=".\src\esl_config.c"
RelativePath=".\esl_config.c"
>
</File>
<File
RelativePath=".\src\esl_event.c"
RelativePath=".\esl_event.c"
>
</File>
<File
RelativePath=".\src\esl_threadmutex.c"
RelativePath=".\esl_threadmutex.c"
>
</File>
</Filter>
@ -200,19 +200,19 @@
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
<File
RelativePath=".\src\include\esl.h"
RelativePath=".\include\esl.h"
>
</File>
<File
RelativePath=".\src\include\esl_config.h"
RelativePath=".\include\esl_config.h"
>
</File>
<File
RelativePath=".\src\include\esl_event.h"
RelativePath=".\include\esl_event.h"
>
</File>
<File
RelativePath=".\src\include\esl_threadmutex.h"
RelativePath=".\include\esl_threadmutex.h"
>
</File>
</Filter>

View File

@ -175,23 +175,23 @@ ESL_DECLARE(const char *)esl_stristr(const char *instr, const char *str)
return NULL;
}
#ifdef WIN32
#ifndef vsnprintf
#define vsnprintf _vsnprintf
#endif
#endif
ESL_DECLARE(int) esl_snprintf(char *buffer, size_t count, const char *fmt, ...)
{
va_list ap;
int ret;
va_start(ap, fmt);
ret = vsnprintf(buffer, count-1, fmt, ap);
if (ret < 0)
buffer[count-1] = '\0';
va_end(ap);
return ret;
#ifdef WIN32
#ifndef vsnprintf
#define vsnprintf _vsnprintf
#endif
#endif
ESL_DECLARE(int) esl_snprintf(char *buffer, size_t count, const char *fmt, ...)
{
va_list ap;
int ret;
va_start(ap, fmt);
ret = vsnprintf(buffer, count-1, fmt, ap);
if (ret < 0)
buffer[count-1] = '\0';
va_end(ap);
return ret;
}
static void null_logger(const char *file, const char *func, int line, int level, const char *fmt, ...)
@ -261,7 +261,7 @@ static void default_logger(const char *file, const char *func, int line, int lev
esl_logger_t esl_log = null_logger;
void esl_global_set_logger(esl_logger_t logger)
ESL_DECLARE(void) esl_global_set_logger(esl_logger_t logger)
{
if (logger) {
esl_log = logger;
@ -270,7 +270,7 @@ void esl_global_set_logger(esl_logger_t logger)
}
}
void esl_global_set_default_logger(int level)
ESL_DECLARE(void) esl_global_set_default_logger(int level)
{
if (level < 0 || level > 7) {
level = 7;
@ -410,7 +410,7 @@ ESL_DECLARE(esl_status_t) esl_execute(esl_handle_t *handle, const char *app, con
static int esl_socket_reuseaddr(esl_socket_t socket)
{
#ifdef WIN32
BOOL reuse_addr = TRUE;
BOOL reuse_addr = TRUE;
return setsockopt(socket, SOL_SOCKET, SO_REUSEADDR, (char *)&reuse_addr, sizeof(reuse_addr));
#else
int reuse_addr = 1;
@ -596,11 +596,11 @@ ESL_DECLARE(esl_status_t) esl_recv_event_timed(esl_handle_t *handle, uint32_t ms
FD_ZERO(&efds);
#ifdef WIN32
#pragma warning( push )
#pragma warning( push )
#pragma warning( disable : 4127 )
FD_SET(handle->sock, &rfds);
FD_SET(handle->sock, &efds);
#pragma warning( pop )
#pragma warning( pop )
#else
FD_SET(handle->sock, &rfds);
FD_SET(handle->sock, &efds);

View File

@ -163,10 +163,10 @@ typedef struct esl_event esl_event_t;
#include <strings.h>
#endif
#include <assert.h>
#if (_MSC_VER >= 1400) // VC8+
#define esl_assert(expr) assert(expr);__analysis_assume( expr )
#endif
#if (_MSC_VER >= 1400) // VC8+
#define esl_assert(expr) assert(expr);__analysis_assume( expr )
#endif
#ifndef esl_assert
#define esl_assert(_x) assert(_x)
@ -192,23 +192,23 @@ typedef intptr_t esl_ssize_t;
typedef int esl_filehandle_t;
#define ESL_SOCK_INVALID INVALID_SOCKET
#define strerror_r(num, buf, size) strerror_s(buf, size, num)
#if defined(ESL_DECLARE_STATIC)
#define ESL_DECLARE(type) type __stdcall
#define ESL_DECLARE_NONSTD(type) type __cdecl
#define ESL_DECLARE_DATA
#elif defined(ESL_EXPORTS)
#define ESL_DECLARE(type) __declspec(dllexport) type __stdcall
#define ESL_DECLARE_NONSTD(type) __declspec(dllexport) type __cdecl
#define ESL_DECLARE_DATA __declspec(dllexport)
#else
#define ESL_DECLARE(type) __declspec(dllimport) type __stdcall
#define ESL_DECLARE_NONSTD(type) __declspec(dllimport) type __cdecl
#define ESL_DECLARE_DATA __declspec(dllimport)
#endif
#if defined(ESL_DECLARE_STATIC)
#define ESL_DECLARE(type) type __stdcall
#define ESL_DECLARE_NONSTD(type) type __cdecl
#define ESL_DECLARE_DATA
#elif defined(ESL_EXPORTS)
#define ESL_DECLARE(type) __declspec(dllexport) type __stdcall
#define ESL_DECLARE_NONSTD(type) __declspec(dllexport) type __cdecl
#define ESL_DECLARE_DATA __declspec(dllexport)
#else
#define ESL_DECLARE(type) type
#define ESL_DECLARE_NONSTD(type) type
#define ESL_DECLARE_DATA
#define ESL_DECLARE(type) __declspec(dllimport) type __stdcall
#define ESL_DECLARE_NONSTD(type) __declspec(dllimport) type __cdecl
#define ESL_DECLARE_DATA __declspec(dllimport)
#endif
#else
#define ESL_DECLARE(type) type
#define ESL_DECLARE_NONSTD(type) type
#define ESL_DECLARE_DATA
#include <stdint.h>
#include <sys/types.h>
#include <sys/ioctl.h>
@ -281,10 +281,10 @@ typedef enum {
#define ESL_LOG_EMERG ESL_PRE, ESL_LOG_LEVEL_EMERG
typedef void (*esl_logger_t)(const char *file, const char *func, int line, int level, const char *fmt, ...);
extern esl_logger_t esl_log;
ESL_DECLARE_DATA extern esl_logger_t esl_log;
void esl_global_set_logger(esl_logger_t logger);
void esl_global_set_default_logger(int level);
ESL_DECLARE(void) esl_global_set_logger(esl_logger_t logger);
ESL_DECLARE(void) esl_global_set_default_logger(int level);
#include "esl_event.h"
#include "esl_threadmutex.h"
@ -295,7 +295,7 @@ ESL_DECLARE(char *)esl_url_decode(char *s);
ESL_DECLARE(const char *)esl_stristr(const char *instr, const char *str);
ESL_DECLARE(int) esl_toupper(int c);
ESL_DECLARE(int) esl_tolower(int c);
ESL_DECLARE(int) esl_snprintf(char *buffer, size_t count, const char *fmt, ...);
ESL_DECLARE(int) esl_snprintf(char *buffer, size_t count, const char *fmt, ...);
typedef void (*esl_listen_callback_t)(esl_socket_t server_sock, esl_socket_t client_sock, struct sockaddr_in addr);