add mod_basic
This commit is contained in:
parent
d08116e762
commit
3a2736291e
|
@ -112,6 +112,7 @@ formats/mod_sndfile
|
|||
#formats/mod_ssml
|
||||
formats/mod_tone_stream
|
||||
#formats/mod_vlc
|
||||
#languages/mod_basic
|
||||
#languages/mod_java
|
||||
languages/mod_lua
|
||||
#languages/mod_managed
|
||||
|
|
|
@ -1484,6 +1484,7 @@ AC_CONFIG_FILES([Makefile
|
|||
src/mod/languages/mod_python/Makefile
|
||||
src/mod/languages/mod_v8/Makefile
|
||||
src/mod/languages/mod_yaml/Makefile
|
||||
src/mod/languages/mod_basic/Makefile
|
||||
src/mod/legacy/languages/mod_lua/Makefile
|
||||
src/mod/legacy/languages/mod_spidermonkey/Makefile
|
||||
src/mod/loggers/mod_console/Makefile
|
||||
|
|
|
@ -0,0 +1,8 @@
|
|||
include $(top_srcdir)/build/modmake.rulesam
|
||||
MODNAME=mod_basic
|
||||
|
||||
mod_LTLIBRARIES = mod_basic.la
|
||||
mod_basic_la_SOURCES = mod_basic.c my_basic.c
|
||||
mod_basic_la_CFLAGS = $(AM_CFLAGS)
|
||||
mod_basic_la_LIBADD = $(switch_builddir)/libfreeswitch.la
|
||||
mod_basic_la_LDFLAGS = -avoid-version -module -no-undefined -shared
|
|
@ -0,0 +1,291 @@
|
|||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="mod_basic"
|
||||
ProjectGUID="{11C9BC3D-45E9-46E3-BE84-B8CEE4685E39}"
|
||||
RootNamespace="mod_basic"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
<Platform
|
||||
Name="x64"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="..\..\..\..\w32\module_debug.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManifestTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCAppVerifierTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|x64"
|
||||
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="..\..\..\..\w32\module_debug.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TargetEnvironment="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(SolutionDir)$(PlatformName)\$(ConfigurationName)/mod/$(ProjectName).dll"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="17"
|
||||
/>
|
||||
<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"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="..\..\..\..\w32\module_release.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
/>
|
||||
<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|x64"
|
||||
OutputDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
ConfigurationType="2"
|
||||
InheritedPropertySheets="..\..\..\..\w32\module_release.vsprops"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TargetEnvironment="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
UsePrecompiledHeader="0"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
OutputFile="$(SolutionDir)$(PlatformName)\$(ConfigurationName)/mod/$(ProjectName).dll"
|
||||
RandomizedBaseAddress="1"
|
||||
DataExecutionPrevention="0"
|
||||
TargetMachine="17"
|
||||
/>
|
||||
<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>
|
||||
<File
|
||||
RelativePath=".\mod_basic.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\my_basic.c"
|
||||
>
|
||||
</File>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
|
@ -0,0 +1,132 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectName>mod_basic</ProjectName>
|
||||
<ProjectGuid>{11C9BC3D-45E9-46E3-BE84-B8CEE4685E39}</ProjectGuid>
|
||||
<RootNamespace>mod_basic</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\..\..\w32\module_release.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\..\..\w32\module_debug.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\..\..\w32\module_release.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\..\..\w32\module_debug.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Midl>
|
||||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Midl>
|
||||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="mod_basic.c" />
|
||||
<ClCompile Include="my_basic.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\..\w32\Library\FreeSwitchCore.2010.vcxproj">
|
||||
<Project>{202d7a4e-760d-4d0e-afa1-d7459ced30ff}</Project>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
|
@ -0,0 +1,136 @@
|
|||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup Label="ProjectConfigurations">
|
||||
<ProjectConfiguration Include="Debug|Win32">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Debug|x64">
|
||||
<Configuration>Debug</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|Win32">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>Win32</Platform>
|
||||
</ProjectConfiguration>
|
||||
<ProjectConfiguration Include="Release|x64">
|
||||
<Configuration>Release</Configuration>
|
||||
<Platform>x64</Platform>
|
||||
</ProjectConfiguration>
|
||||
</ItemGroup>
|
||||
<PropertyGroup Label="Globals">
|
||||
<ProjectName>mod_basic</ProjectName>
|
||||
<ProjectGuid>{11C9BC3D-45E9-46E3-BE84-B8CEE4685E39}</ProjectGuid>
|
||||
<RootNamespace>mod_basic</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>DynamicLibrary</ConfigurationType>
|
||||
<CharacterSet>MultiByte</CharacterSet>
|
||||
<PlatformToolset>v110</PlatformToolset>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
|
||||
<ImportGroup Label="ExtensionSettings">
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\..\..\w32\module_release.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\..\..\w32\module_debug.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\..\..\w32\module_release.props" />
|
||||
</ImportGroup>
|
||||
<ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
|
||||
<Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
|
||||
<Import Project="..\..\..\..\w32\module_debug.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Midl>
|
||||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Midl>
|
||||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<PrecompiledHeader>
|
||||
</PrecompiledHeader>
|
||||
</ClCompile>
|
||||
<Link>
|
||||
<RandomizedBaseAddress>false</RandomizedBaseAddress>
|
||||
<DataExecutionPrevention>
|
||||
</DataExecutionPrevention>
|
||||
<TargetMachine>MachineX64</TargetMachine>
|
||||
</Link>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="mod_basic.c" />
|
||||
<ClCompile Include="my_basic.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\..\w32\Library\FreeSwitchCore.2012.vcxproj">
|
||||
<Project>{202d7a4e-760d-4d0e-afa1-d7459ced30ff}</Project>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
|
@ -0,0 +1,418 @@
|
|||
/*
|
||||
* FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
* Copyright (C) 2005-2012, Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
* Version: MPL 1.1
|
||||
*
|
||||
* The contents of this file are subject to the Mozilla Public License Version
|
||||
* 1.1 (the "License"); you may not use this file except in compliance with
|
||||
* the License. You may obtain a copy of the License at
|
||||
* http://www.mozilla.org/MPL/
|
||||
*
|
||||
* Software distributed under the License is distributed on an "AS IS" basis,
|
||||
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
|
||||
* for the specific language governing rights and limitations under the
|
||||
* License.
|
||||
*
|
||||
* The Original Code is FreeSWITCH Modular Media Switching Software Library / Soft-Switch Application
|
||||
*
|
||||
* The Initial Developer of the Original Code is
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
* Portions created by the Initial Developer are Copyright (C)
|
||||
* the Initial Developer. All Rights Reserved.
|
||||
*
|
||||
* Contributor(s):
|
||||
*
|
||||
* Anthony Minessale II <anthm@freeswitch.org>
|
||||
*
|
||||
*
|
||||
* mod_basic.c -- BASIC Module
|
||||
*
|
||||
*/
|
||||
#include <switch.h>
|
||||
#include "my_basic.h"
|
||||
|
||||
/* Prototypes */
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_basic_shutdown);
|
||||
SWITCH_MODULE_RUNTIME_FUNCTION(mod_basic_runtime);
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_basic_load);
|
||||
|
||||
/* SWITCH_MODULE_DEFINITION(name, load, shutdown, runtime)
|
||||
* Defines a switch_loadable_module_function_table_t and a static const char[] modname
|
||||
*/
|
||||
SWITCH_MODULE_DEFINITION(mod_basic, mod_basic_load, mod_basic_shutdown, NULL);
|
||||
|
||||
static struct {
|
||||
int integer;
|
||||
} globals;
|
||||
|
||||
|
||||
|
||||
static switch_status_t do_config(switch_bool_t reload)
|
||||
{
|
||||
memset(&globals, 0, sizeof(globals));
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
static void _on_error(mb_interpreter_t* s, mb_error_e e, char* m, int p, unsigned short row, unsigned short col, int abort_code) {
|
||||
mb_unrefvar(s);
|
||||
if(SE_NO_ERR != e) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_WARNING,
|
||||
"Error:\n [POS] %d, [ROW] %d, [COL] %d,\n [CODE] %d, [MESSAGE] %s, [ABORT CODE] %d\n", p, row, col, e, m, abort_code);
|
||||
}
|
||||
}
|
||||
|
||||
typedef struct fs_data {
|
||||
switch_core_session_t *session;
|
||||
int argc;
|
||||
char *argv[128];
|
||||
switch_event_t *vars;
|
||||
} fs_data_t;
|
||||
|
||||
|
||||
static int fun_execute(mb_interpreter_t* s, void** l)
|
||||
{
|
||||
int result = MB_FUNC_OK;
|
||||
fs_data_t *fsdata = (fs_data_t *) mb_get_user_data(s);
|
||||
mb_value_t app;
|
||||
mb_value_t arg;
|
||||
|
||||
mb_assert(s && l);
|
||||
|
||||
mb_check(mb_attempt_func_begin(s, l));
|
||||
|
||||
if ((result = mb_pop_value(s, l, &app)) != MB_FUNC_OK) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
if ((result = mb_pop_value(s, l, &arg)) != MB_FUNC_OK) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (app.type == MB_DT_STRING && arg.type == MB_DT_STRING && fsdata->session) {
|
||||
switch_core_session_execute_application(fsdata->session, app.value.string, arg.value.string);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Bad args or no fsdata->session\n");
|
||||
result = MB_FUNC_WARNING;
|
||||
}
|
||||
|
||||
mb_check(mb_attempt_func_end(s, l));
|
||||
|
||||
end:
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static int fun_setvar(mb_interpreter_t* s, void** l)
|
||||
{
|
||||
int result = MB_FUNC_OK;
|
||||
fs_data_t *fsdata = (fs_data_t *) mb_get_user_data(s);
|
||||
mb_value_t var;
|
||||
mb_value_t val;
|
||||
|
||||
mb_assert(s && l);
|
||||
|
||||
mb_check(mb_attempt_func_begin(s, l));
|
||||
|
||||
if ((result = mb_pop_value(s, l, &var)) != MB_FUNC_OK) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
if ((result = mb_pop_value(s, l, &val)) != MB_FUNC_OK) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (var.type == MB_DT_STRING && val.type == MB_DT_STRING && fsdata->session) {
|
||||
switch_channel_t *channel = switch_core_session_get_channel(fsdata->session);
|
||||
switch_channel_set_variable(channel, var.value.string, val.value.string);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Bad args or no session\n");
|
||||
result = MB_FUNC_WARNING;
|
||||
}
|
||||
|
||||
mb_check(mb_attempt_func_end(s, l));
|
||||
|
||||
end:
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static int fun_getarg(mb_interpreter_t* s, void** l)
|
||||
{
|
||||
int result = MB_FUNC_OK;
|
||||
fs_data_t *fsdata = (fs_data_t *) mb_get_user_data(s);
|
||||
mb_value_t idx;
|
||||
|
||||
mb_assert(s && l);
|
||||
|
||||
mb_check(mb_attempt_func_begin(s, l));
|
||||
|
||||
if ((result = mb_pop_value(s, l, &idx)) != MB_FUNC_OK) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (idx.type == MB_DT_INT && fsdata->argc) {
|
||||
if (idx.value.integer < fsdata->argc) {
|
||||
mb_push_string(s, l, strdup(fsdata->argv[idx.value.integer]));
|
||||
}
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Bad args or no session\n");
|
||||
result = MB_FUNC_WARNING;
|
||||
}
|
||||
|
||||
mb_check(mb_attempt_func_end(s, l));
|
||||
|
||||
end:
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static int fun_getvar(mb_interpreter_t* s, void** l)
|
||||
{
|
||||
int result = MB_FUNC_OK;
|
||||
fs_data_t *fsdata = (fs_data_t *) mb_get_user_data(s);
|
||||
mb_value_t var;
|
||||
|
||||
mb_assert(s && l);
|
||||
|
||||
mb_check(mb_attempt_func_begin(s, l));
|
||||
|
||||
if ((result = mb_pop_value(s, l, &var)) != MB_FUNC_OK) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (var.type == MB_DT_STRING && fsdata->session) {
|
||||
switch_channel_t *channel = switch_core_session_get_channel(fsdata->session);
|
||||
const char *value = switch_channel_get_variable(channel, var.value.string);
|
||||
|
||||
mb_push_string(s, l, strdup(value));
|
||||
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Bad args or no session\n");
|
||||
result = MB_FUNC_WARNING;
|
||||
}
|
||||
|
||||
mb_check(mb_attempt_func_end(s, l));
|
||||
|
||||
end:
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
static int fun_api(mb_interpreter_t* s, void** l)
|
||||
{
|
||||
int result = MB_FUNC_OK;
|
||||
fs_data_t *fsdata = (fs_data_t *) mb_get_user_data(s);
|
||||
mb_value_t app;
|
||||
mb_value_t arg;
|
||||
|
||||
mb_assert(s && l);
|
||||
|
||||
mb_check(mb_attempt_func_begin(s, l));
|
||||
|
||||
if ((result = mb_pop_value(s, l, &app)) != MB_FUNC_OK) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
if ((result = mb_pop_value(s, l, &arg)) != MB_FUNC_OK) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (app.type == MB_DT_STRING && arg.type == MB_DT_STRING) {
|
||||
switch_stream_handle_t stream = { 0 };
|
||||
SWITCH_STANDARD_STREAM(stream);
|
||||
|
||||
switch_api_execute(app.value.string, arg.value.string, fsdata->session, &stream);
|
||||
mb_push_string(s, l, (char *) stream.data);
|
||||
//switch_safe_free(stream.data);
|
||||
} else {
|
||||
result = MB_FUNC_WARNING;
|
||||
}
|
||||
|
||||
mb_check(mb_attempt_func_end(s, l));
|
||||
|
||||
end:
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static int fun_log(mb_interpreter_t* s, void** l)
|
||||
{
|
||||
int result = MB_FUNC_OK;
|
||||
fs_data_t *fsdata = (fs_data_t *) mb_get_user_data(s);
|
||||
mb_value_t level;
|
||||
mb_value_t data;
|
||||
|
||||
mb_assert(s && l);
|
||||
|
||||
mb_check(mb_attempt_func_begin(s, l));
|
||||
|
||||
if ((result = mb_pop_value(s, l, &level)) != MB_FUNC_OK) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
if ((result = mb_pop_value(s, l, &data)) != MB_FUNC_OK) {
|
||||
goto end;
|
||||
}
|
||||
|
||||
if (level.type == MB_DT_STRING && data.type == MB_DT_STRING) {
|
||||
switch_log_level_t fslevel = SWITCH_LOG_DEBUG;
|
||||
|
||||
fslevel = switch_log_str2level(level.value.string);
|
||||
switch_log_printf(SWITCH_CHANNEL_SESSION_LOG(fsdata->session), fslevel, "%s\n", data.value.string);
|
||||
} else {
|
||||
result = MB_FUNC_WARNING;
|
||||
}
|
||||
|
||||
mb_check(mb_attempt_func_end(s, l));
|
||||
|
||||
end:
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
||||
static int bprint(const char *fmt, ...)
|
||||
{
|
||||
char *data = NULL;
|
||||
va_list ap;
|
||||
int ret = 0;
|
||||
|
||||
va_start(ap, fmt);
|
||||
ret = switch_vasprintf(&data, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
if (data) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG_CLEAN, SWITCH_LOG_CONSOLE, "%s\n", data);
|
||||
}
|
||||
|
||||
switch_safe_free(data);
|
||||
|
||||
return ret;
|
||||
|
||||
}
|
||||
|
||||
|
||||
SWITCH_STANDARD_APP(basic_function)
|
||||
{
|
||||
const char *file;
|
||||
char *fdup = NULL;
|
||||
mb_interpreter_t *bi = 0;
|
||||
fs_data_t fsdata = { 0 };
|
||||
char *mydata = NULL;
|
||||
|
||||
if (data) {
|
||||
mydata = strdup((char *) data);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "missing data\n");
|
||||
return;
|
||||
}
|
||||
|
||||
fsdata.argc = switch_split(mydata, ' ', fsdata.argv);
|
||||
|
||||
file = fsdata.argv[0];
|
||||
|
||||
if (zstr(file)) {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "missing file\n");
|
||||
}
|
||||
|
||||
if (!switch_is_file_path(file)) {
|
||||
fdup = switch_mprintf("%s/%s", SWITCH_GLOBAL_dirs.script_dir, file);
|
||||
switch_assert(fdup);
|
||||
file = fdup;
|
||||
}
|
||||
|
||||
mb_open(&bi);
|
||||
mb_set_error_handler(bi, _on_error);
|
||||
mb_set_printer(bi, bprint);
|
||||
fsdata.session = session;
|
||||
mb_set_user_data(bi, (void *) &fsdata);
|
||||
|
||||
mb_register_func(bi, "FS_EXECUTE", fun_execute);
|
||||
mb_register_func(bi, "FS_GETARG", fun_getarg);
|
||||
mb_register_func(bi, "FS_GETVAR", fun_getvar);
|
||||
mb_register_func(bi, "FS_SETVAR", fun_setvar);
|
||||
mb_register_func(bi, "FS_API", fun_api);
|
||||
mb_register_func(bi, "FS_LOG", fun_log);
|
||||
|
||||
if (mb_load_file(bi, file) == MB_FUNC_OK) {
|
||||
mb_run(bi);
|
||||
} else {
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_ERROR, "Error executing file\n");
|
||||
}
|
||||
|
||||
mb_close(&bi);
|
||||
|
||||
switch_safe_free(fdup);
|
||||
switch_safe_free(mydata);
|
||||
}
|
||||
|
||||
SWITCH_STANDARD_API(basic_api_function)
|
||||
{
|
||||
|
||||
basic_function(session, cmd);
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/* Macro expands to: switch_status_t mod_basic_load(switch_loadable_module_interface_t **module_interface, switch_memory_pool_t *pool) */
|
||||
SWITCH_MODULE_LOAD_FUNCTION(mod_basic_load)
|
||||
{
|
||||
switch_api_interface_t *api_interface;
|
||||
switch_application_interface_t *app_interface;
|
||||
|
||||
/* connect my internal structure to the blank pointer passed to me */
|
||||
*module_interface = switch_loadable_module_create_module_interface(pool, modname);
|
||||
|
||||
switch_log_printf(SWITCH_CHANNEL_LOG, SWITCH_LOG_NOTICE, "Hello World!\n");
|
||||
|
||||
do_config(SWITCH_FALSE);
|
||||
|
||||
SWITCH_ADD_API(api_interface, "basic", "Basic API", basic_api_function, "syntax");
|
||||
SWITCH_ADD_APP(app_interface, "basic", "", "", basic_function, "<file>", SAF_NONE);
|
||||
|
||||
mb_init();
|
||||
|
||||
/* indicate that the module should continue to be loaded */
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
/*
|
||||
Called when the system shuts down
|
||||
Macro expands to: switch_status_t mod_basic_shutdown() */
|
||||
SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_basic_shutdown)
|
||||
{
|
||||
/* Cleanup dynamically allocated config settings */
|
||||
mb_dispose();
|
||||
|
||||
return SWITCH_STATUS_SUCCESS;
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
If it exists, this is called in it's own thread when the module-load completes
|
||||
If it returns anything but SWITCH_STATUS_TERM it will be called again automatically
|
||||
Macro expands to: switch_status_t mod_basic_runtime()
|
||||
SWITCH_MODULE_RUNTIME_FUNCTION(mod_basic_runtime)
|
||||
{
|
||||
while(looping)
|
||||
{
|
||||
switch_cond_next();
|
||||
}
|
||||
return SWITCH_STATUS_TERM;
|
||||
}
|
||||
*/
|
||||
|
||||
/* For Emacs:
|
||||
* Local Variables:
|
||||
* mode:c
|
||||
* indent-tabs-mode:t
|
||||
* tab-width:4
|
||||
* c-basic-offset:4
|
||||
* End:
|
||||
* For VIM:
|
||||
* vim:set softtabstop=4 shiftwidth=4 tabstop=4 noet
|
||||
*/
|
File diff suppressed because it is too large
Load Diff
|
@ -0,0 +1,241 @@
|
|||
/*
|
||||
** This source file is part of MY-BASIC
|
||||
**
|
||||
** For the latest info, see http://code.google.com/p/my-basic/
|
||||
**
|
||||
** Copyright (c) 2011 - 2013 Tony & Tony's Toy Game Development Team
|
||||
**
|
||||
** Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
** this software and associated documentation files (the "Software"), to deal in
|
||||
** the Software without restriction, including without limitation the rights to
|
||||
** use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
** the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
** subject to the following conditions:
|
||||
**
|
||||
** The above copyright notice and this permission notice shall be included in all
|
||||
** copies or substantial portions of the Software.
|
||||
**
|
||||
** THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
** IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
** FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
** COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
** IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
** CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef __MY_BASIC_H__
|
||||
#define __MY_BASIC_H__
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#ifndef MBAPI
|
||||
# define MBAPI
|
||||
#endif /* MBAPI */
|
||||
|
||||
#ifndef MB_COMPACT_MODE
|
||||
# define MB_COMPACT_MODE
|
||||
#endif /* MB_COMPACT_MODE */
|
||||
|
||||
#ifdef MB_COMPACT_MODE
|
||||
# pragma pack(1)
|
||||
#endif /* MB_COMPACT_MODE */
|
||||
|
||||
#ifndef true
|
||||
# define true (!0)
|
||||
#endif
|
||||
#ifndef false
|
||||
# define false (0)
|
||||
#endif
|
||||
|
||||
#ifndef bool_t
|
||||
# define bool_t int
|
||||
#endif
|
||||
#ifndef byte_t
|
||||
# define byte_t unsigned char
|
||||
#endif
|
||||
#ifndef int_t
|
||||
# define int_t int
|
||||
#endif
|
||||
#ifndef real_t
|
||||
# define real_t float
|
||||
#endif
|
||||
|
||||
#ifndef _MSC_VER
|
||||
# ifndef _strcmpi
|
||||
# define _strcmpi strcasecmp
|
||||
# endif /* _strcmpi */
|
||||
#endif /* _MSC_VER */
|
||||
|
||||
#ifndef mb_assert
|
||||
# define mb_assert(__a) do { ((void)(__a)); assert(__a); } while(0)
|
||||
#endif /* mb_assert */
|
||||
|
||||
#ifndef mb_unrefvar
|
||||
# define mb_unrefvar(__v) ((void)(__v))
|
||||
#endif /* mb_unrefvar */
|
||||
|
||||
#ifndef MB_CODES
|
||||
# define MB_CODES
|
||||
# define MB_FUNC_OK 0
|
||||
# define MB_FUNC_BYE 1001
|
||||
# define MB_FUNC_WARNING 1002
|
||||
# define MB_FUNC_ERR 1003
|
||||
# define MB_FUNC_END 1004
|
||||
# define MB_FUNC_SUSPEND 1005
|
||||
# define MB_PARSING_ERR 3001
|
||||
# define MB_LOOP_BREAK 5001
|
||||
# define MB_LOOP_CONTINUE 5002
|
||||
# define MB_SUB_RETURN 5101
|
||||
# define MB_EXTENDED_ABORT 9001
|
||||
#endif /* MB_CODES */
|
||||
|
||||
#ifndef mb_check
|
||||
# define mb_check(__r) { int __hr = __r; if(__hr != MB_FUNC_OK) { return __hr; } }
|
||||
#endif /* mb_check */
|
||||
|
||||
#ifndef mb_reg_fun
|
||||
# define mb_reg_fun(__s, __f) mb_register_func(__s, #__f, __f)
|
||||
#endif /* mb_reg_fun */
|
||||
#ifndef mb_rem_fun
|
||||
# define mb_rem_fun(__s, __f) mb_remove_func(__s, #__f)
|
||||
#endif /* mb_rem_fun */
|
||||
|
||||
struct mb_interpreter_t;
|
||||
|
||||
typedef enum mb_error_e {
|
||||
SE_NO_ERR = 0,
|
||||
/** Common */
|
||||
SE_CM_MB_OPEN_FAILED,
|
||||
SE_CM_FUNC_EXISTS,
|
||||
SE_CM_FUNC_NOT_EXISTS,
|
||||
/** Parsing */
|
||||
SE_PS_FILE_OPEN_FAILED,
|
||||
SE_PS_SYMBOL_TOO_LONG,
|
||||
SE_PS_INVALID_CHAR,
|
||||
/** Running */
|
||||
SE_RN_NOT_SUPPORTED,
|
||||
SE_RN_EMPTY_PROGRAM,
|
||||
SE_RN_SYNTAX,
|
||||
SE_RN_INVALID_DATA_TYPE,
|
||||
SE_RN_TYPE_NOT_MATCH,
|
||||
SE_RN_ILLEGAL_BOUND,
|
||||
SE_RN_DIMENSION_TOO_MUCH,
|
||||
SE_RN_OPERATION_FAILED,
|
||||
SE_RN_DIMENSION_OUT_OF_BOUND,
|
||||
SE_RN_ARRAY_OUT_OF_BOUND,
|
||||
SE_RN_LABEL_NOT_EXISTS,
|
||||
SE_RN_NO_RETURN_POINT,
|
||||
SE_RN_COLON_EXPECTED,
|
||||
SE_RN_COMMA_OR_SEMICOLON_EXPECTED,
|
||||
SE_RN_ARRAY_IDENTIFIER_EXPECTED,
|
||||
SE_RN_OPEN_BRACKET_EXPECTED,
|
||||
SE_RN_CLOSE_BRACKET_EXPECTED,
|
||||
SE_RN_ARRAY_SUBSCRIPT_EXPECTED,
|
||||
SE_RN_STRUCTURE_NOT_COMPLETED,
|
||||
SE_RN_FUNCTION_EXPECTED,
|
||||
SE_RN_STRING_EXPECTED,
|
||||
SE_RN_VAR_OR_ARRAY_EXPECTED,
|
||||
SE_RN_ASSIGN_OPERATOR_EXPECTED,
|
||||
SE_RN_INTEGER_EXPECTED,
|
||||
SE_RN_ELSE_EXPECTED,
|
||||
SE_RN_TO_EXPECTED,
|
||||
SE_RN_UNTIL_EXPECTED,
|
||||
SE_RN_LOOP_VAR_EXPECTED,
|
||||
SE_RN_JUMP_LABEL_EXPECTED,
|
||||
SE_RN_INVALID_ID_USAGE,
|
||||
SE_RN_CALCULATION_ERROR,
|
||||
SE_RN_DIVIDE_BY_ZERO,
|
||||
SE_RN_INVALID_EXPRESSION,
|
||||
SE_RN_OUT_OF_MEMORY,
|
||||
/** Extended abort */
|
||||
SE_EA_EXTENDED_ABORT,
|
||||
} mb_error_e;
|
||||
|
||||
typedef enum mb_data_e {
|
||||
MB_DT_NIL = -1,
|
||||
MB_DT_INT = 0,
|
||||
MB_DT_REAL,
|
||||
MB_DT_STRING,
|
||||
} mb_data_e;
|
||||
|
||||
typedef union mb_value_u {
|
||||
int_t integer;
|
||||
real_t float_point;
|
||||
char* string;
|
||||
} mb_value_u;
|
||||
|
||||
typedef struct mb_value_t {
|
||||
mb_data_e type;
|
||||
mb_value_u value;
|
||||
} mb_value_t;
|
||||
|
||||
typedef void (* mb_error_handler_t)(struct mb_interpreter_t*, enum mb_error_e, char*, int, unsigned short, unsigned short, int);
|
||||
typedef int (* mb_func_t)(struct mb_interpreter_t*, void**);
|
||||
typedef int (* mb_print_func_t)(const char*, ...);
|
||||
|
||||
typedef struct mb_interpreter_t {
|
||||
void* local_func_dict;
|
||||
void* global_func_dict;
|
||||
void* global_var_dict;
|
||||
void* ast;
|
||||
void* parsing_context;
|
||||
void* running_context;
|
||||
mb_error_e last_error;
|
||||
int last_error_pos;
|
||||
unsigned short last_error_row;
|
||||
unsigned short last_error_col;
|
||||
mb_error_handler_t error_handler;
|
||||
mb_print_func_t printer;
|
||||
void* userdata;
|
||||
} mb_interpreter_t;
|
||||
|
||||
MBAPI unsigned int mb_ver(void);
|
||||
MBAPI const char* mb_ver_string(void);
|
||||
|
||||
MBAPI int mb_init(void);
|
||||
MBAPI int mb_dispose(void);
|
||||
MBAPI int mb_open(mb_interpreter_t** s);
|
||||
MBAPI int mb_close(mb_interpreter_t** s);
|
||||
MBAPI int mb_reset(mb_interpreter_t** s, bool_t clrf);
|
||||
|
||||
MBAPI int mb_register_func(mb_interpreter_t* s, const char* n, mb_func_t f);
|
||||
MBAPI int mb_remove_func(mb_interpreter_t* s, const char* n);
|
||||
|
||||
MBAPI int mb_attempt_func_begin(mb_interpreter_t* s, void** l);
|
||||
MBAPI int mb_attempt_func_end(mb_interpreter_t* s, void** l);
|
||||
MBAPI int mb_attempt_open_bracket(mb_interpreter_t* s, void** l);
|
||||
MBAPI int mb_attempt_close_bracket(mb_interpreter_t* s, void** l);
|
||||
MBAPI int mb_pop_int(mb_interpreter_t* s, void** l, int_t* val);
|
||||
MBAPI int mb_pop_real(mb_interpreter_t* s, void** l, real_t* val);
|
||||
MBAPI int mb_pop_string(mb_interpreter_t* s, void** l, char** val);
|
||||
MBAPI int mb_pop_value(mb_interpreter_t* s, void** l, mb_value_t* val);
|
||||
MBAPI int mb_push_int(mb_interpreter_t* s, void** l, int_t val);
|
||||
MBAPI int mb_push_real(mb_interpreter_t* s, void** l, real_t val);
|
||||
MBAPI int mb_push_string(mb_interpreter_t* s, void** l, char* val);
|
||||
MBAPI int mb_push_value(mb_interpreter_t* s, void** l, mb_value_t val);
|
||||
|
||||
MBAPI int mb_load_string(mb_interpreter_t* s, const char* l);
|
||||
MBAPI int mb_load_file(mb_interpreter_t* s, const char* f);
|
||||
MBAPI int mb_run(mb_interpreter_t* s);
|
||||
MBAPI int mb_suspend(mb_interpreter_t* s, void** l);
|
||||
|
||||
MBAPI mb_error_e mb_get_last_error(mb_interpreter_t* s);
|
||||
MBAPI const char* mb_get_error_desc(mb_error_e err);
|
||||
MBAPI int mb_set_error_handler(mb_interpreter_t* s, mb_error_handler_t h);
|
||||
MBAPI int mb_set_printer(mb_interpreter_t* s, mb_print_func_t p);
|
||||
|
||||
MBAPI void mb_set_user_data(mb_interpreter_t* s, void *ptr);
|
||||
MBAPI void *mb_get_user_data(mb_interpreter_t* s);
|
||||
|
||||
|
||||
#ifdef MB_COMPACT_MODE
|
||||
# pragma pack()
|
||||
#endif /* MB_COMPACT_MODE */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif /* __cplusplus */
|
||||
|
||||
#endif /* __MY_BASIC_H__ */
|
Loading…
Reference in New Issue