mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-11-15 22:08:33 +00:00
Update to latest UniMRCP version. MRCP requests can no timeout if there is no server response.
This commit is contained in:
1 parent
0555b702db
commit
17099473a3
441 files changed
+17430
-17071
No files matched your search
@@ -8,38 +8,43 @@ noinst_LTLIBRARIES = libaprtoolkit.la
|
||||
include_HEADERS = include/apt.h \
|
||||
include/apt_obj_list.h \
|
||||
include/apt_cyclic_queue.h \
|
||||
include/apt_dir_layout.h \
|
||||
include/apt_task.h \
|
||||
include/apt_task_msg.h \
|
||||
include/apt_consumer_task.h \
|
||||
include/apt_net_server_task.h \
|
||||
include/apt_net_client_task.h \
|
||||
include/apt_pollset.h \
|
||||
include/apt_poller_task.h \
|
||||
include/apt_pool.h \
|
||||
include/apt_log.h \
|
||||
include/apt_pair.h \
|
||||
include/apt_string.h \
|
||||
include/apt_string_table.h \
|
||||
include/apt_header_field.h \
|
||||
include/apt_text_stream.h \
|
||||
include/apt_text_message.h \
|
||||
include/apt_net.h \
|
||||
include/apt_nlsml_doc.h \
|
||||
include/apt_dir_layout.h \
|
||||
include/apt_multipart_content.h \
|
||||
include/apt_timer_queue.h \
|
||||
include/apt_test_suite.h
|
||||
|
||||
libaprtoolkit_la_SOURCES = src/apt_obj_list.c \
|
||||
src/apt_cyclic_queue.c \
|
||||
src/apt_dir_layout.c \
|
||||
src/apt_task.c \
|
||||
src/apt_task_msg.c \
|
||||
src/apt_consumer_task.c \
|
||||
src/apt_net_server_task.c \
|
||||
src/apt_net_client_task.c \
|
||||
src/apt_pollset.c \
|
||||
src/apt_poller_task.c \
|
||||
src/apt_pool.c \
|
||||
src/apt_log.c \
|
||||
src/apt_pair.c \
|
||||
src/apt_string_table.c \
|
||||
src/apt_header_field.c \
|
||||
src/apt_text_stream.c \
|
||||
src/apt_text_message.c \
|
||||
src/apt_net.c \
|
||||
src/apt_nlsml_doc.c \
|
||||
src/apt_dir_layout.c \
|
||||
src/apt_multipart_content.c \
|
||||
src/apt_timer_queue.c \
|
||||
src/apt_test_suite.c
|
||||
|
||||
@@ -1,409 +0,0 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="aprtoolkit"
|
||||
ProjectGUID="{13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2}"
|
||||
RootNamespace="aprtoolkit"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
<Platform
|
||||
Name="x64"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
InheritedPropertySheets="$(ProjectDir)..\..\build\vsprops\unidebug.vsprops;$(ProjectDir)..\..\build\vsprops\apt.vsprops"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions="APT_STATIC_LIB"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|x64"
|
||||
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
InheritedPropertySheets="$(ProjectDir)..\..\build\vsprops\unidebug.vsprops;$(ProjectDir)..\..\build\vsprops\apt.vsprops"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TargetEnvironment="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions="APT_STATIC_LIB"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
InheritedPropertySheets="$(ProjectDir)..\..\build\vsprops\unirelease.vsprops;$(ProjectDir)..\..\build\vsprops\apt.vsprops"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions="APT_STATIC_LIB"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|x64"
|
||||
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
InheritedPropertySheets="$(ProjectDir)..\..\build\vsprops\unirelease.vsprops;$(ProjectDir)..\..\build\vsprops\apt.vsprops"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TargetEnvironment="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
PreprocessorDefinitions="APT_STATIC_LIB"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="include"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\include\apt.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_consumer_task.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_cyclic_queue.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_dir_layout.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_log.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_net.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_net_client_task.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_net_server_task.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_nlsml_doc.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_obj_list.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_pair.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_pollset.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_pool.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_string.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_string_table.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_task.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_task_msg.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_test_suite.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_text_stream.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="src"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\apt_consumer_task.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\apt_cyclic_queue.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\apt_dir_layout.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\apt_log.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\apt_net.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\apt_net_client_task.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\apt_net_server_task.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\apt_nlsml_doc.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\apt_obj_list.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\apt_pair.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\apt_pollset.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\apt_pool.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\apt_string_table.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\apt_task.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\apt_task_msg.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\apt_test_suite.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\apt_text_stream.c"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
@@ -1,157 +0,0 @@
|
||||
<?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>aprtoolkit</ProjectName>
|
||||
<ProjectGuid>{13DEECA0-BDD4-4744-A1A2-8EB0A44DF3D2}</ProjectGuid>
|
||||
<RootNamespace>aprtoolkit</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</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="$(ProjectDir)..\..\build\vsprops\unirelease.props" />
|
||||
<Import Project="$(ProjectDir)..\..\build\vsprops\apt.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="$(ProjectDir)..\..\build\vsprops\unidebug.props" />
|
||||
<Import Project="$(ProjectDir)..\..\build\vsprops\apt.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="$(ProjectDir)..\..\build\vsprops\unirelease.props" />
|
||||
<Import Project="$(ProjectDir)..\..\build\vsprops\apt.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="$(ProjectDir)..\..\build\vsprops\unidebug.props" />
|
||||
<Import Project="$(ProjectDir)..\..\build\vsprops\apt.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(PlatformName)\$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(PlatformName)\$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(PlatformName)\$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(PlatformName)\$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(PlatformName)\$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(PlatformName)\$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(PlatformName)\$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(PlatformName)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>APT_STATIC_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Midl>
|
||||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>APT_STATIC_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>APT_STATIC_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Midl>
|
||||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<PreprocessorDefinitions>APT_STATIC_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\apt.h" />
|
||||
<ClInclude Include="include\apt_consumer_task.h" />
|
||||
<ClInclude Include="include\apt_cyclic_queue.h" />
|
||||
<ClInclude Include="include\apt_dir_layout.h" />
|
||||
<ClInclude Include="include\apt_log.h" />
|
||||
<ClInclude Include="include\apt_net.h" />
|
||||
<ClInclude Include="include\apt_net_client_task.h" />
|
||||
<ClInclude Include="include\apt_net_server_task.h" />
|
||||
<ClInclude Include="include\apt_nlsml_doc.h" />
|
||||
<ClInclude Include="include\apt_obj_list.h" />
|
||||
<ClInclude Include="include\apt_pair.h" />
|
||||
<ClInclude Include="include\apt_pollset.h" />
|
||||
<ClInclude Include="include\apt_pool.h" />
|
||||
<ClInclude Include="include\apt_string.h" />
|
||||
<ClInclude Include="include\apt_string_table.h" />
|
||||
<ClInclude Include="include\apt_task.h" />
|
||||
<ClInclude Include="include\apt_task_msg.h" />
|
||||
<ClInclude Include="include\apt_test_suite.h" />
|
||||
<ClInclude Include="include\apt_text_stream.h" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\apt_consumer_task.c" />
|
||||
<ClCompile Include="src\apt_cyclic_queue.c" />
|
||||
<ClCompile Include="src\apt_dir_layout.c" />
|
||||
<ClCompile Include="src\apt_log.c" />
|
||||
<ClCompile Include="src\apt_net.c" />
|
||||
<ClCompile Include="src\apt_net_client_task.c" />
|
||||
<ClCompile Include="src\apt_net_server_task.c" />
|
||||
<ClCompile Include="src\apt_nlsml_doc.c" />
|
||||
<ClCompile Include="src\apt_obj_list.c" />
|
||||
<ClCompile Include="src\apt_pair.c" />
|
||||
<ClCompile Include="src\apt_pollset.c" />
|
||||
<ClCompile Include="src\apt_pool.c" />
|
||||
<ClCompile Include="src\apt_string_table.c" />
|
||||
<ClCompile Include="src\apt_task.c" />
|
||||
<ClCompile Include="src\apt_task_msg.c" />
|
||||
<ClCompile Include="src\apt_test_suite.c" />
|
||||
<ClCompile Include="src\apt_text_stream.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\..\..\win32\apr-util\libaprutil.2010.vcxproj">
|
||||
<Project>{f057da7f-79e5-4b00-845c-ef446ef055e3}</Project>
|
||||
<ReferenceOutputAssembly>false</ReferenceOutputAssembly>
|
||||
</ProjectReference>
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -1,125 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="include">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="src">
|
||||
<UniqueIdentifier>{4c2fadb2-8996-43e3-9db1-e3fc3eccee30}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="include\apt.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\apt_consumer_task.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\apt_cyclic_queue.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\apt_dir_layout.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\apt_log.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\apt_net.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\apt_net_client_task.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\apt_net_server_task.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\apt_nlsml_doc.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\apt_obj_list.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\apt_pair.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\apt_pollset.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\apt_pool.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\apt_string.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\apt_string_table.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\apt_task.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\apt_task_msg.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\apt_test_suite.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\apt_text_stream.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="src\apt_consumer_task.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\apt_cyclic_queue.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\apt_dir_layout.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\apt_log.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\apt_net.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\apt_net_client_task.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\apt_net_server_task.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\apt_nlsml_doc.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\apt_obj_list.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\apt_pair.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\apt_pollset.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\apt_pool.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\apt_string_table.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\apt_task.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\apt_task_msg.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\apt_test_suite.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\apt_text_stream.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -253,22 +253,22 @@
|
||||
RelativePath=".\include\apt_dir_layout.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_header_field.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_log.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_multipart_content.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_net.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_net_client_task.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_net_server_task.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_nlsml_doc.h"
|
||||
>
|
||||
@@ -281,6 +281,10 @@
|
||||
RelativePath=".\include\apt_pair.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_poller_task.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_pollset.h"
|
||||
>
|
||||
@@ -309,10 +313,18 @@
|
||||
RelativePath=".\include\apt_test_suite.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_text_message.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_text_stream.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\apt_timer_queue.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="src"
|
||||
@@ -330,22 +342,22 @@
|
||||
RelativePath=".\src\apt_dir_layout.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\apt_header_field.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\apt_log.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\apt_multipart_content.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\apt_net.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\apt_net_client_task.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\apt_net_server_task.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\apt_nlsml_doc.c"
|
||||
>
|
||||
@@ -358,6 +370,10 @@
|
||||
RelativePath=".\src\apt_pair.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\apt_poller_task.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\apt_pollset.c"
|
||||
>
|
||||
@@ -382,10 +398,18 @@
|
||||
RelativePath=".\src\apt_test_suite.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\apt_text_message.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\apt_text_stream.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\apt_timer_queue.c"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __APT_H__
|
||||
#define __APT_H__
|
||||
#ifndef APT_H
|
||||
#define APT_H
|
||||
|
||||
/**
|
||||
* @file apt.h
|
||||
@@ -56,4 +58,4 @@
|
||||
/** Boolean value */
|
||||
typedef int apt_bool_t;
|
||||
|
||||
#endif /*__APT_H__*/
|
||||
#endif /* APT_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_consumer_task.h 1708 2010-05-24 17:03:25Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __APT_CONSUMER_TASK_H__
|
||||
#define __APT_CONSUMER_TASK_H__
|
||||
#ifndef APT_CONSUMER_TASK_H
|
||||
#define APT_CONSUMER_TASK_H
|
||||
|
||||
/**
|
||||
* @file apt_consumer_task.h
|
||||
@@ -44,7 +46,7 @@ APT_DECLARE(apt_consumer_task_t*) apt_consumer_task_create(
|
||||
* Get task base.
|
||||
* @param task the consumer task to get base for
|
||||
*/
|
||||
APT_DECLARE(apt_task_t*) apt_consumer_task_base_get(apt_consumer_task_t *task);
|
||||
APT_DECLARE(apt_task_t*) apt_consumer_task_base_get(const apt_consumer_task_t *task);
|
||||
|
||||
/**
|
||||
* Get task vtable.
|
||||
@@ -56,8 +58,8 @@ APT_DECLARE(apt_task_vtable_t*) apt_consumer_task_vtable_get(apt_consumer_task_t
|
||||
* Get consumer task object.
|
||||
* @param task the consumer task to get object from
|
||||
*/
|
||||
APT_DECLARE(void*) apt_consumer_task_object_get(apt_consumer_task_t *task);
|
||||
APT_DECLARE(void*) apt_consumer_task_object_get(const apt_consumer_task_t *task);
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__APT_CONSUMER_TASK_H__*/
|
||||
#endif /* APT_CONSUMER_TASK_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_cyclic_queue.h 1708 2010-05-24 17:03:25Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __APT_CYCLIC_QUEUE_H__
|
||||
#define __APT_CYCLIC_QUEUE_H__
|
||||
#ifndef APT_CYCLIC_QUEUE_H
|
||||
#define APT_CYCLIC_QUEUE_H
|
||||
|
||||
/**
|
||||
* @file apt_cyclic_queue.h
|
||||
@@ -69,9 +71,9 @@ APT_DECLARE(void) apt_cyclic_queue_clear(apt_cyclic_queue_t *queue);
|
||||
* @param queue the queue to query
|
||||
* @return TRUE if empty, otherwise FALSE
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_cyclic_queue_is_empty(apt_cyclic_queue_t *queue);
|
||||
APT_DECLARE(apt_bool_t) apt_cyclic_queue_is_empty(const apt_cyclic_queue_t *queue);
|
||||
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__APT_CYCLIC_QUEUE_H__*/
|
||||
#endif /* APT_CYCLIC_QUEUE_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_dir_layout.h 1524 2010-02-15 20:44:16Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __APT_DIR_LAYOUT_H__
|
||||
#define __APT_DIR_LAYOUT_H__
|
||||
#ifndef APT_DIR_LAYOUT_H
|
||||
#define APT_DIR_LAYOUT_H
|
||||
|
||||
/**
|
||||
* @file apt_dir_layout.h
|
||||
@@ -56,12 +58,13 @@ APT_DECLARE(apt_dir_layout_t*) apt_custom_dir_layout_create(
|
||||
const char *data_dir_path,
|
||||
apr_pool_t *pool);
|
||||
|
||||
/**
|
||||
* Construct file path with the given file name relative to data dir.
|
||||
*/
|
||||
/** Construct file path relative to data dir using the file name specified. */
|
||||
APT_DECLARE(char*) apt_datadir_filepath_get(const apt_dir_layout_t *dir_layout, const char *file_name, apr_pool_t *pool);
|
||||
|
||||
/** Construct file path relative to conf dir using the file name specified. */
|
||||
APT_DECLARE(char*) apt_confdir_filepath_get(const apt_dir_layout_t *dir_layout, const char *file_name, apr_pool_t *pool);
|
||||
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__APT_DIR_LAYOUT_H__*/
|
||||
#endif /* APT_DIR_LAYOUT_H */
|
||||
@@ -0,0 +1,178 @@
|
||||
/*
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_header_field.h 1719 2010-05-31 21:09:51Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef APT_HEADER_FIELD_H
|
||||
#define APT_HEADER_FIELD_H
|
||||
|
||||
/**
|
||||
* @file apt_header_field.h
|
||||
* @brief Header Field Declaration (RFC5322)
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma warning(disable: 4127)
|
||||
#endif
|
||||
#include <apr_ring.h>
|
||||
#include "apt_string.h"
|
||||
|
||||
APT_BEGIN_EXTERN_C
|
||||
|
||||
/** Header field declaration */
|
||||
typedef struct apt_header_field_t apt_header_field_t;
|
||||
/** Header section declaration */
|
||||
typedef struct apt_header_section_t apt_header_section_t;
|
||||
|
||||
/** Header field */
|
||||
struct apt_header_field_t {
|
||||
/** Ring entry */
|
||||
APR_RING_ENTRY(apt_header_field_t) link;
|
||||
|
||||
/** Name of the header field */
|
||||
apt_str_t name;
|
||||
/** Value of the header field */
|
||||
apt_str_t value;
|
||||
|
||||
/** Numeric identifier associated with name */
|
||||
apr_size_t id;
|
||||
};
|
||||
|
||||
/**
|
||||
* Header section
|
||||
* @remark The header section is a collection of header fields.
|
||||
* The header fields are stored in both a ring and an array.
|
||||
* The goal is to ensure efficient access and manipulation on the header fields.
|
||||
*/
|
||||
struct apt_header_section_t {
|
||||
/** List of header fields (name-value pairs) */
|
||||
APR_RING_HEAD(apt_head_t, apt_header_field_t) ring;
|
||||
/** Array of pointers to header fields */
|
||||
apt_header_field_t **arr;
|
||||
/** Max number of header fields */
|
||||
apr_size_t arr_size;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Allocate an empty header field.
|
||||
* @param pool the pool to allocate memory from
|
||||
*/
|
||||
APT_DECLARE(apt_header_field_t*) apt_header_field_alloc(apr_pool_t *pool);
|
||||
|
||||
/**
|
||||
* Create a header field using given name and value APT strings.
|
||||
* @param name the name of the header field
|
||||
* @param value the value of the header field
|
||||
* @param pool the pool to allocate memory from
|
||||
*/
|
||||
APT_DECLARE(apt_header_field_t*) apt_header_field_create(const apt_str_t *name, const apt_str_t *value, apr_pool_t *pool);
|
||||
|
||||
/**
|
||||
* Create a header field using given name and value C strings.
|
||||
* @param name the name of the header field
|
||||
* @param value the value of the header field
|
||||
* @param pool the pool to allocate memory from
|
||||
*/
|
||||
APT_DECLARE(apt_header_field_t*) apt_header_field_create_c(const char *name, const char *value, apr_pool_t *pool);
|
||||
|
||||
/**
|
||||
* Create a header field from entire text line consisting of a name and value pair.
|
||||
* @param line the text line, which consists of a name and value pair
|
||||
* @param separator the name and value separator
|
||||
* @param pool the pool to allocate memory from
|
||||
*/
|
||||
APT_DECLARE(apt_header_field_t*) apt_header_field_create_from_line(const apt_str_t *line, char separator, apr_pool_t *pool);
|
||||
|
||||
/**
|
||||
* Copy specified header field.
|
||||
* @param src_header_field the header field to copy
|
||||
* @param pool the pool to allocate memory from
|
||||
*/
|
||||
APT_DECLARE(apt_header_field_t*) apt_header_field_copy(const apt_header_field_t *src_header_field, apr_pool_t *pool);
|
||||
|
||||
/**
|
||||
* Initialize header section (collection of header fields).
|
||||
* @param header the header section to initialize
|
||||
*/
|
||||
APT_DECLARE(void) apt_header_section_init(apt_header_section_t *header);
|
||||
|
||||
/**
|
||||
* Allocate header section to set/get header fields by numeric identifiers.
|
||||
* @param header the header section to allocate
|
||||
* @param max_field_count the max number of header fields in the section (protocol dependent)
|
||||
* @param pool the pool to allocate memory from
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_header_section_array_alloc(apt_header_section_t *header, apr_size_t max_field_count, apr_pool_t *pool);
|
||||
|
||||
/**
|
||||
* Add (append) header field to header section.
|
||||
* @param header the header section to add field to
|
||||
* @param header_field the header field to add
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_header_section_field_add(apt_header_section_t *header, apt_header_field_t *header_field);
|
||||
|
||||
/**
|
||||
* Insert header field to header section based on numreic identifier if specified.
|
||||
* @param header the header section to insert field into
|
||||
* @param header_field the header field to insert
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_header_section_field_insert(apt_header_section_t *header, apt_header_field_t *header_field);
|
||||
|
||||
/**
|
||||
* Set header field in the array of header fields using associated numeric identifier.
|
||||
* @param header the header section to set field for
|
||||
* @param header_field the header field to set
|
||||
* @remark Typically, the header field should be already added to the header section using apt_header_section_field_add()
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_header_section_field_set(apt_header_section_t *header, apt_header_field_t *header_field);
|
||||
|
||||
/**
|
||||
* Remove header field from header section.
|
||||
* @param header the header section to remove field from
|
||||
* @param header_field the header field to remove
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_header_section_field_remove(apt_header_section_t *header, apt_header_field_t *header_field);
|
||||
|
||||
/**
|
||||
* Check whether specified header field is set.
|
||||
* @param header the header section to use
|
||||
* @param id the identifier associated with the header_field to check
|
||||
*/
|
||||
static APR_INLINE apt_bool_t apt_header_section_field_check(const apt_header_section_t *header, apr_size_t id)
|
||||
{
|
||||
if(id < header->arr_size) {
|
||||
return header->arr[id] ? TRUE : FALSE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get header field by specified identifier.
|
||||
* @param header the header section to use
|
||||
* @param id the identifier associated with the header_field
|
||||
*/
|
||||
static APR_INLINE apt_header_field_t* apt_header_section_field_get(const apt_header_section_t *header, apr_size_t id)
|
||||
{
|
||||
if(id < header->arr_size) {
|
||||
return header->arr[id];
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /* APT_HEADER_FIELD_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_log.h 1792 2011-01-10 21:08:52Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __APT_LOG_H__
|
||||
#define __APT_LOG_H__
|
||||
#ifndef APT_LOG_H
|
||||
#define APT_LOG_H
|
||||
|
||||
/**
|
||||
* @file apt_log.h
|
||||
@@ -44,8 +46,10 @@ APT_BEGIN_EXTERN_C
|
||||
#define APT_SIDRES_FMT "<%s@%s>"
|
||||
/** Format to log pointers and identifiers */
|
||||
#define APT_PTRSID_FMT APT_PTR_FMT" "APT_SID_FMT
|
||||
/** Format to log pointers, identifiers and resources */
|
||||
#define APT_PTRSIDRES_FMT APT_PTR_FMT" "APT_SIDRES_FMT
|
||||
/** Format to log pointers and identifiers */
|
||||
#define APT_NAMESID_FMT "%s "APT_SID_FMT
|
||||
/** Format to log names, identifiers and resources */
|
||||
#define APT_NAMESIDRES_FMT "%s "APT_SIDRES_FMT
|
||||
|
||||
|
||||
/** Priority of log messages ordered from highest priority to lowest (rfc3164) */
|
||||
@@ -69,22 +73,30 @@ typedef enum {
|
||||
APT_LOG_HEADER_TIME = 0x02, /**< enable time output */
|
||||
APT_LOG_HEADER_PRIORITY = 0x04, /**< enable priority name output */
|
||||
APT_LOG_HEADER_MARK = 0x08, /**< enable file:line mark output */
|
||||
APT_LOG_HEADER_THREAD = 0x10, /**< enable thread identifier output */
|
||||
|
||||
APT_LOG_HEADER_DEFAULT = APT_LOG_HEADER_DATE | APT_LOG_HEADER_TIME | APT_LOG_HEADER_PRIORITY
|
||||
} apt_log_header_e;
|
||||
|
||||
/** Log output modes */
|
||||
/** Mode of log output */
|
||||
typedef enum {
|
||||
APT_LOG_OUTPUT_NONE = 0x00, /**< disable logging */
|
||||
APT_LOG_OUTPUT_CONSOLE = 0x01, /**< enable console output */
|
||||
APT_LOG_OUTPUT_FILE = 0x02 /**< enable log file output */
|
||||
} apt_log_output_e;
|
||||
|
||||
/** Masking mode of private data */
|
||||
typedef enum {
|
||||
APT_LOG_MASKING_NONE, /**< log everything as is */
|
||||
APT_LOG_MASKING_COMPLETE, /**< mask private data completely */
|
||||
APT_LOG_MASKING_ENCRYPTED /**< encrypt private data */
|
||||
} apt_log_masking_e;
|
||||
|
||||
/** Opaque logger declaration */
|
||||
typedef struct apt_logger_t apt_logger_t;
|
||||
|
||||
/** Prototype of extended log handler function */
|
||||
typedef apt_bool_t (*apt_log_ext_handler_f)(const char *file, int line, const char *id,
|
||||
typedef apt_bool_t (*apt_log_ext_handler_f)(const char *file, int line, const char *obj,
|
||||
apt_log_priority_e priority, const char *format, va_list arg_ptr);
|
||||
|
||||
/**
|
||||
@@ -95,6 +107,13 @@ typedef apt_bool_t (*apt_log_ext_handler_f)(const char *file, int line, const ch
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_log_instance_create(apt_log_output_e mode, apt_log_priority_e priority, apr_pool_t *pool);
|
||||
|
||||
/**
|
||||
* Create and load the singleton instance of the logger.
|
||||
* @param config_file the path to configuration file to load settings from
|
||||
* @param pool the memory pool to use
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_log_instance_load(const char *config_file, apr_pool_t *pool);
|
||||
|
||||
/**
|
||||
* Destroy the singleton instance of the logger.
|
||||
*/
|
||||
@@ -116,13 +135,15 @@ APT_DECLARE(apt_bool_t) apt_log_instance_set(apt_logger_t *logger);
|
||||
* @param file_name the name of the log file
|
||||
* @param max_file_size the max size of the log file
|
||||
* @param max_file_count the max number of files used in log rotation
|
||||
* @param append whether to append or to truncate (start over) the log file
|
||||
* @param pool the memory pool to use
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_log_file_open(
|
||||
const char *dir_path,
|
||||
const char *file_name,
|
||||
apr_size_t max_file_size,
|
||||
apr_size_t max_file_count,
|
||||
const char *dir_path,
|
||||
const char *file_name,
|
||||
apr_size_t max_file_size,
|
||||
apr_size_t max_file_count,
|
||||
apt_bool_t append,
|
||||
apr_pool_t *pool);
|
||||
|
||||
/**
|
||||
@@ -131,23 +152,73 @@ APT_DECLARE(apt_bool_t) apt_log_file_open(
|
||||
APT_DECLARE(apt_bool_t) apt_log_file_close(void);
|
||||
|
||||
/**
|
||||
* Set the logging output.
|
||||
* Set the logging output mode.
|
||||
* @param mode the mode to set
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_log_output_mode_set(apt_log_output_e mode);
|
||||
|
||||
/**
|
||||
* Check the logging output mode to be enabled (set) or not.
|
||||
* @param mode the mode to check
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_log_output_mode_check(apt_log_output_e mode);
|
||||
|
||||
/**
|
||||
* Translate the output mode string to bitmask of apt_log_output_e values.
|
||||
* @param str the string to translate
|
||||
*/
|
||||
APT_DECLARE(int) apt_log_output_mode_translate(char *str);
|
||||
|
||||
/**
|
||||
* Set the logging priority (log level).
|
||||
* @param priority the priority to set
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_log_priority_set(apt_log_priority_e priority);
|
||||
|
||||
/**
|
||||
* Translate the priority (log level) string to enum.
|
||||
* @param str the string to translate
|
||||
*/
|
||||
APT_DECLARE(apt_log_priority_e) apt_log_priority_translate(const char *str);
|
||||
|
||||
/**
|
||||
* Set the header (format) for log messages.
|
||||
* @param header the header to set (used as bitmask)
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_log_header_set(int header);
|
||||
|
||||
/**
|
||||
* Translate the header string to bitmask of apt_log_header_e values.
|
||||
* @param str the string to translate
|
||||
*/
|
||||
APT_DECLARE(int) apt_log_header_translate(char *str);
|
||||
|
||||
/**
|
||||
* Set the masking mode of private data.
|
||||
* @param masking the masking mode to set
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_log_masking_set(apt_log_masking_e masking);
|
||||
|
||||
/**
|
||||
* Get the current masking mode of private data.
|
||||
*/
|
||||
APT_DECLARE(apt_log_masking_e) apt_log_masking_get();
|
||||
|
||||
/**
|
||||
* Translate the masking mode string to enum.
|
||||
* @param str the string to translate
|
||||
*/
|
||||
APT_DECLARE(apt_log_masking_e) apt_log_masking_translate(const char *str);
|
||||
|
||||
/**
|
||||
* Mask private data based on the masking mode
|
||||
* @param data_in the data to mask
|
||||
* @param length the length of the data to mask on input, the length of the masked data on output
|
||||
* @param pool the memory pool to use if needed
|
||||
* @return The masked data.
|
||||
*/
|
||||
APT_DECLARE(const char*) apt_log_data_mask(const char *data_in, apr_size_t *length, apr_pool_t *pool);
|
||||
|
||||
/**
|
||||
* Set the extended external log handler.
|
||||
* @param handler the handler to pass log events to
|
||||
@@ -165,6 +236,16 @@ APT_DECLARE(apt_bool_t) apt_log_ext_handler_set(apt_log_ext_handler_f handler);
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_log(const char *file, int line, apt_log_priority_e priority, const char *format, ...);
|
||||
|
||||
/**
|
||||
* Do logging.
|
||||
* @param file the file name log entry is generated from
|
||||
* @param line the line number log entry is generated from
|
||||
* @param priority the priority of the entire log entry
|
||||
* @param obj the associated object
|
||||
* @param format the format of the entire log entry
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_obj_log(const char *file, int line, apt_log_priority_e priority, void *obj, const char *format, ...);
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__APT_LOG_H__*/
|
||||
#endif /* APT_LOG_H */
|
||||
@@ -0,0 +1,108 @@
|
||||
/*
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_multipart_content.h 1722 2010-06-01 08:40:35Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef APT_MULTIPART_CONTENT_H
|
||||
#define APT_MULTIPART_CONTENT_H
|
||||
|
||||
/**
|
||||
* @file apt_multipart_content.h
|
||||
* @brief Multipart Content Routine
|
||||
*/
|
||||
|
||||
#include "apt_header_field.h"
|
||||
|
||||
APT_BEGIN_EXTERN_C
|
||||
|
||||
/** Opaque multipart content declaration */
|
||||
typedef struct apt_multipart_content_t apt_multipart_content_t;
|
||||
|
||||
/** Content part declaration */
|
||||
typedef struct apt_content_part_t apt_content_part_t;
|
||||
|
||||
/** Content part */
|
||||
struct apt_content_part_t {
|
||||
/** Header section */
|
||||
apt_header_section_t header;
|
||||
/** Body */
|
||||
apt_str_t body;
|
||||
|
||||
/** Pointer to parsed content-type header field */
|
||||
apt_str_t *type;
|
||||
/** Pointer to parsed content-id header field */
|
||||
apt_str_t *id;
|
||||
/** Pointer to parsed content-length header field */
|
||||
apt_str_t *length;
|
||||
};
|
||||
|
||||
/**
|
||||
* Create an empty multipart content
|
||||
* @param max_content_size the max size of the content (body)
|
||||
* @param boundary the boundary to separate content parts
|
||||
* @param pool the pool to allocate memory from
|
||||
* @return an empty multipart content
|
||||
*/
|
||||
APT_DECLARE(apt_multipart_content_t*) apt_multipart_content_create(apr_size_t max_content_size, const apt_str_t *boundary, apr_pool_t *pool);
|
||||
|
||||
/**
|
||||
* Add content part to multipart content
|
||||
* @param multipart_content the multipart content to add content part to
|
||||
* @param content_part the content part to add
|
||||
* @return TRUE on success
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_multipart_content_add(apt_multipart_content_t *multipart_content, const apt_content_part_t *content_part);
|
||||
|
||||
/**
|
||||
* Add content part to multipart content by specified header fields and body
|
||||
* @param multipart_content the multipart content to add content part to
|
||||
* @param content_type the type of content part
|
||||
* @param content_id the identifier of content part
|
||||
* @param body the body of content part
|
||||
* @return TRUE on success
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_multipart_content_add2(apt_multipart_content_t *multipart_content, const apt_str_t *content_type, const apt_str_t *content_id, const apt_str_t *body);
|
||||
|
||||
/**
|
||||
* Finalize multipart content generation
|
||||
* @param multipart_content the multipart content to finalize
|
||||
* @return generated multipart content
|
||||
*/
|
||||
APT_DECLARE(apt_str_t*) apt_multipart_content_finalize(apt_multipart_content_t *multipart_content);
|
||||
|
||||
|
||||
/**
|
||||
* Assign body to multipart content to get (parse) each content part from
|
||||
* @param body the body of multipart content to parse
|
||||
* @param boundary the boundary to separate content parts
|
||||
* @param pool the pool to allocate memory from
|
||||
* @return multipart content with assigned body
|
||||
*/
|
||||
APT_DECLARE(apt_multipart_content_t*) apt_multipart_content_assign(const apt_str_t *body, const apt_str_t *boundary, apr_pool_t *pool);
|
||||
|
||||
/**
|
||||
* Get the next content part
|
||||
* @param multipart_content the multipart content to get the next content part from
|
||||
* @param content_part the parsed content part
|
||||
* @param is_final indicates the final boundary is reached
|
||||
* @return TRUE on success
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_multipart_content_get(apt_multipart_content_t *multipart_content, apt_content_part_t *content_part, apt_bool_t *is_final);
|
||||
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /* APT_MULTIPART_CONTENT_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_net.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __APT_NET_H__
|
||||
#define __APT_NET_H__
|
||||
#ifndef APT_NET_H
|
||||
#define APT_NET_H
|
||||
|
||||
/**
|
||||
* @file apt_net.h
|
||||
@@ -43,4 +45,4 @@ void apt_ntp_time_get(apr_uint32_t *sec, apr_uint32_t *frac);
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__APT_NET_H__*/
|
||||
#endif /* APT_NET_H */
|
||||
@@ -1,127 +0,0 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __APT_NET_CLIENT_TASK_H__
|
||||
#define __APT_NET_CLIENT_TASK_H__
|
||||
|
||||
/**
|
||||
* @file apt_net_client_task.h
|
||||
* @brief Network Client Task Base
|
||||
*/
|
||||
|
||||
#include <apr_poll.h>
|
||||
#include "apt_task.h"
|
||||
|
||||
APT_BEGIN_EXTERN_C
|
||||
|
||||
/** Opaque network client task declaration */
|
||||
typedef struct apt_net_client_task_t apt_net_client_task_t;
|
||||
/** Network client connection declaration */
|
||||
typedef struct apt_net_client_connection_t apt_net_client_connection_t;
|
||||
/** Virtual table of network client events */
|
||||
typedef struct apt_net_client_vtable_t apt_net_client_vtable_t;
|
||||
|
||||
/** Network client connection */
|
||||
struct apt_net_client_connection_t {
|
||||
/** Memory pool */
|
||||
apr_pool_t *pool;
|
||||
/** External object */
|
||||
void *obj;
|
||||
/** Connected socket */
|
||||
apr_socket_t *sock;
|
||||
/** Socket poll descriptor */
|
||||
apr_pollfd_t sock_pfd;
|
||||
/** String identifier used for traces */
|
||||
const char *id;
|
||||
};
|
||||
|
||||
/** Virtual table of network client events */
|
||||
struct apt_net_client_vtable_t {
|
||||
/** Message receive handler */
|
||||
apt_bool_t (*on_receive)(apt_net_client_task_t *task, apt_net_client_connection_t *connection);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Create network client task.
|
||||
* @param max_connection_count the number of max connections
|
||||
* @param obj the external object
|
||||
* @param client_vtable the table of virtual methods of the net client task
|
||||
* @param msg_pool the pool of task messages
|
||||
* @param pool the pool to allocate memory from
|
||||
*/
|
||||
APT_DECLARE(apt_net_client_task_t*) apt_net_client_task_create(
|
||||
apr_size_t max_connection_count,
|
||||
void *obj,
|
||||
const apt_net_client_vtable_t *client_vtable,
|
||||
apt_task_msg_pool_t *msg_pool,
|
||||
apr_pool_t *pool);
|
||||
|
||||
/**
|
||||
* Destroy network client task.
|
||||
* @param task the task to destroy
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_net_client_task_destroy(apt_net_client_task_t *task);
|
||||
|
||||
/**
|
||||
* Start network client task and wait for incoming requests.
|
||||
* @param task the task to start
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_net_client_task_start(apt_net_client_task_t *task);
|
||||
|
||||
/**
|
||||
* Terminate connection task.
|
||||
* @param task the task to terminate
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_net_client_task_terminate(apt_net_client_task_t *task);
|
||||
|
||||
/**
|
||||
* Get task base.
|
||||
* @param task the network client task to get task base from
|
||||
*/
|
||||
APT_DECLARE(apt_task_t*) apt_net_client_task_base_get(apt_net_client_task_t *task);
|
||||
|
||||
/**
|
||||
* Get task vtable.
|
||||
* @param task the network client task to get vtable from
|
||||
*/
|
||||
APT_DECLARE(apt_task_vtable_t*) apt_net_client_task_vtable_get(apt_net_client_task_t *task);
|
||||
|
||||
/**
|
||||
* Get external object.
|
||||
* @param task the task to get object from
|
||||
*/
|
||||
APT_DECLARE(void*) apt_net_client_task_object_get(apt_net_client_task_t *task);
|
||||
|
||||
/**
|
||||
* Create connection.
|
||||
*/
|
||||
APT_DECLARE(apt_net_client_connection_t*) apt_net_client_connect(apt_net_client_task_t *task, const char *ip, apr_port_t port);
|
||||
|
||||
/**
|
||||
* Close connection.
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_net_client_connection_close(apt_net_client_task_t *task, apt_net_client_connection_t *connection);
|
||||
|
||||
/**
|
||||
* Close and destroy connection.
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_net_client_disconnect(apt_net_client_task_t *task, apt_net_client_connection_t *connection);
|
||||
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__APT_NET_CLIENT_TASK_H__*/
|
||||
@@ -1,132 +0,0 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __APT_NET_SERVER_TASK_H__
|
||||
#define __APT_NET_SERVER_TASK_H__
|
||||
|
||||
/**
|
||||
* @file apt_net_server_task.h
|
||||
* @brief Network Server Task Base
|
||||
*/
|
||||
|
||||
#include <apr_poll.h>
|
||||
#include "apt_task.h"
|
||||
|
||||
APT_BEGIN_EXTERN_C
|
||||
|
||||
/** Opaque network server task declaration */
|
||||
typedef struct apt_net_server_task_t apt_net_server_task_t;
|
||||
/** Network server connection declaration */
|
||||
typedef struct apt_net_server_connection_t apt_net_server_connection_t;
|
||||
/** Virtual table of network server events */
|
||||
typedef struct apt_net_server_vtable_t apt_net_server_vtable_t;
|
||||
|
||||
/** Network server connection */
|
||||
struct apt_net_server_connection_t {
|
||||
/** Memory pool */
|
||||
apr_pool_t *pool;
|
||||
/** External object */
|
||||
void *obj;
|
||||
/** Client IP address */
|
||||
char *client_ip;
|
||||
/** Accepted socket */
|
||||
apr_socket_t *sock;
|
||||
/** Socket poll descriptor */
|
||||
apr_pollfd_t sock_pfd;
|
||||
/** String identifier used for traces */
|
||||
const char *id;
|
||||
};
|
||||
|
||||
/** Virtual table of network server events */
|
||||
struct apt_net_server_vtable_t {
|
||||
/** Connect event handler */
|
||||
apt_bool_t (*on_connect)(apt_net_server_task_t *task, apt_net_server_connection_t *connection);
|
||||
/** Disconnect event handler */
|
||||
apt_bool_t (*on_disconnect)(apt_net_server_task_t *task, apt_net_server_connection_t *connection);
|
||||
/** Message receive handler */
|
||||
apt_bool_t (*on_receive)(apt_net_server_task_t *task, apt_net_server_connection_t *connection);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Create network server task.
|
||||
* @param listen_ip the listen IP address
|
||||
* @param listen_port the listen port
|
||||
* @param max_connection_count the number of max connections to accept
|
||||
* @param obj the external object
|
||||
* @param server_vtable the table of virtual methods of the net server task
|
||||
* @param msg_pool the pool of task messages
|
||||
* @param pool the pool to allocate memory from
|
||||
*/
|
||||
APT_DECLARE(apt_net_server_task_t*) apt_net_server_task_create(
|
||||
const char *listen_ip,
|
||||
apr_port_t listen_port,
|
||||
apr_size_t max_connection_count,
|
||||
void *obj,
|
||||
const apt_net_server_vtable_t *server_vtable,
|
||||
apt_task_msg_pool_t *msg_pool,
|
||||
apr_pool_t *pool);
|
||||
|
||||
/**
|
||||
* Destroy network server task.
|
||||
* @param task the task to destroy
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_net_server_task_destroy(apt_net_server_task_t *task);
|
||||
|
||||
/**
|
||||
* Start network server task and wait for incoming requests.
|
||||
* @param task the task to start
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_net_server_task_start(apt_net_server_task_t *task);
|
||||
|
||||
/**
|
||||
* Terminate connection task.
|
||||
* @param task the task to terminate
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_net_server_task_terminate(apt_net_server_task_t *task);
|
||||
|
||||
/**
|
||||
* Get task base.
|
||||
* @param task the network server task to get task base from
|
||||
*/
|
||||
APT_DECLARE(apt_task_t*) apt_net_server_task_base_get(apt_net_server_task_t *task);
|
||||
|
||||
/**
|
||||
* Get task vtable.
|
||||
* @param task the network server task to get vtable from
|
||||
*/
|
||||
APT_DECLARE(apt_task_vtable_t*) apt_net_server_task_vtable_get(apt_net_server_task_t *task);
|
||||
|
||||
/**
|
||||
* Get external object.
|
||||
* @param task the task to get object from
|
||||
*/
|
||||
APT_DECLARE(void*) apt_net_server_task_object_get(apt_net_server_task_t *task);
|
||||
|
||||
/**
|
||||
* Close connection.
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_net_server_connection_close(apt_net_server_task_t *task, apt_net_server_connection_t *connection);
|
||||
|
||||
/**
|
||||
* Destroy connection.
|
||||
*/
|
||||
APT_DECLARE(void) apt_net_server_connection_destroy(apt_net_server_connection_t *connection);
|
||||
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__APT_NET_SERVER_TASK_H__*/
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_nlsml_doc.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __APT_NLSML_DOC_H__
|
||||
#define __APT_NLSML_DOC_H__
|
||||
#ifndef APT_NLSML_DOC_H
|
||||
#define APT_NLSML_DOC_H
|
||||
|
||||
/**
|
||||
* @file apt_nlsml_doc.h
|
||||
@@ -45,4 +47,4 @@ APT_DECLARE(const char *) nlsml_input_attrib_get(const apr_xml_elem *input, cons
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__APT_NLSML_DOC_H__*/
|
||||
#endif /* APT_NLSML_DOC_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_obj_list.h 1708 2010-05-24 17:03:25Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __APT_OBJ_LIST_H__
|
||||
#define __APT_OBJ_LIST_H__
|
||||
#ifndef APT_OBJ_LIST_H
|
||||
#define APT_OBJ_LIST_H
|
||||
|
||||
/**
|
||||
* @file apt_obj_list.h
|
||||
@@ -65,40 +67,40 @@ APT_DECLARE(void*) apt_list_pop_front(apt_obj_list_t *list);
|
||||
* Retrieve object of the first element in the list.
|
||||
* @param list the list to retrieve from
|
||||
*/
|
||||
APT_DECLARE(void*) apt_list_head(apt_obj_list_t *list);
|
||||
APT_DECLARE(void*) apt_list_head(const apt_obj_list_t *list);
|
||||
|
||||
/**
|
||||
* Retrieve object of the last element in the list.
|
||||
* @param list the list to retrieve from
|
||||
*/
|
||||
APT_DECLARE(void*) apt_obj_list_tail(apt_obj_list_t *list);
|
||||
APT_DECLARE(void*) apt_obj_list_tail(const apt_obj_list_t *list);
|
||||
|
||||
|
||||
/**
|
||||
* Retrieve the first element of the list.
|
||||
* @param list the list to retrieve from
|
||||
*/
|
||||
APT_DECLARE(apt_list_elem_t*) apt_list_first_elem_get(apt_obj_list_t *list);
|
||||
APT_DECLARE(apt_list_elem_t*) apt_list_first_elem_get(const apt_obj_list_t *list);
|
||||
|
||||
/**
|
||||
* Retrieve the last element of the list.
|
||||
* @param list the list to retrieve from
|
||||
*/
|
||||
APT_DECLARE(apt_list_elem_t*) apt_list_last_elem_get(apt_obj_list_t *list);
|
||||
APT_DECLARE(apt_list_elem_t*) apt_list_last_elem_get(const apt_obj_list_t *list);
|
||||
|
||||
/**
|
||||
* Retrieve the next element of the list.
|
||||
* @param list the list to retrieve from
|
||||
* @param elem the element to retrieve next element from
|
||||
*/
|
||||
APT_DECLARE(apt_list_elem_t*) apt_list_next_elem_get(apt_obj_list_t *list, apt_list_elem_t *elem);
|
||||
APT_DECLARE(apt_list_elem_t*) apt_list_next_elem_get(const apt_obj_list_t *list, apt_list_elem_t *elem);
|
||||
|
||||
/**
|
||||
* Retrieve the prev element of the list.
|
||||
* @param list the list to retrieve from
|
||||
* @param elem the element to retrieve prev element from
|
||||
*/
|
||||
APT_DECLARE(apt_list_elem_t*) apt_list_prev_elem_get(apt_obj_list_t *list, apt_list_elem_t *elem);
|
||||
APT_DECLARE(apt_list_elem_t*) apt_list_prev_elem_get(const apt_obj_list_t *list, apt_list_elem_t *elem);
|
||||
|
||||
/**
|
||||
* Insert element to the list.
|
||||
@@ -123,15 +125,15 @@ APT_DECLARE(apt_list_elem_t*) apt_list_elem_remove(apt_obj_list_t *list, apt_lis
|
||||
* @param list the list to query
|
||||
* @return TRUE if empty, otherwise FALSE
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_list_is_empty(apt_obj_list_t *list);
|
||||
APT_DECLARE(apt_bool_t) apt_list_is_empty(const apt_obj_list_t *list);
|
||||
|
||||
/**
|
||||
* Retrieve the object associated with element.
|
||||
* @param elem the element to retrieve object from
|
||||
*/
|
||||
APT_DECLARE(void*) apt_list_elem_object_get(apt_list_elem_t *elem);
|
||||
APT_DECLARE(void*) apt_list_elem_object_get(const apt_list_elem_t *elem);
|
||||
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__APT_OBJ_LIST_H__*/
|
||||
#endif /* APT_OBJ_LIST_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_pair.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __APT_PAIR_H__
|
||||
#define __APT_PAIR_H__
|
||||
#ifndef APT_PAIR_H
|
||||
#define APT_PAIR_H
|
||||
|
||||
/**
|
||||
* @file apt_pair.h
|
||||
@@ -70,4 +72,4 @@ APT_DECLARE(const apt_pair_t*) apt_pair_array_get(const apt_pair_arr_t *arr, int
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__APT_PAIR_H__*/
|
||||
#endif /* APT_PAIR_H */
|
||||
@@ -0,0 +1,122 @@
|
||||
/*
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_poller_task.h 1708 2010-05-24 17:03:25Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef APT_POLLER_TASK_H
|
||||
#define APT_POLLER_TASK_H
|
||||
|
||||
/**
|
||||
* @file apt_poller_task.h
|
||||
* @brief Poller Task
|
||||
*/
|
||||
|
||||
#include "apt_pollset.h"
|
||||
#include "apt_task.h"
|
||||
#include "apt_timer_queue.h"
|
||||
|
||||
APT_BEGIN_EXTERN_C
|
||||
|
||||
/** Opaque poller task declaration */
|
||||
typedef struct apt_poller_task_t apt_poller_task_t;
|
||||
|
||||
/** Function prototype to handle signalled descripors */
|
||||
typedef apt_bool_t (*apt_poll_signal_f)(void *obj, const apr_pollfd_t *descriptor);
|
||||
|
||||
|
||||
/**
|
||||
* Create poller task.
|
||||
* @param max_pollset_size the maximum number of descriptors pollset can hold
|
||||
* @param signal_handler the handler of signalled descriptors
|
||||
* @param obj the external object to pass to callback
|
||||
* @param msg_pool the pool of task messages
|
||||
* @param pool the pool to allocate memory from
|
||||
*/
|
||||
APT_DECLARE(apt_poller_task_t*) apt_poller_task_create(
|
||||
apr_size_t max_pollset_size,
|
||||
apt_poll_signal_f signal_handler,
|
||||
void *obj,
|
||||
apt_task_msg_pool_t *msg_pool,
|
||||
apr_pool_t *pool);
|
||||
|
||||
/**
|
||||
* Destroy poller task.
|
||||
* @param task the task to destroy
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_poller_task_destroy(apt_poller_task_t *task);
|
||||
|
||||
/**
|
||||
* Cleanup poller task.
|
||||
* @param task the task to cleanup
|
||||
*
|
||||
* @remark This function should be considered in protected scope.
|
||||
* It will be called on task destroy unless you override the behavior.
|
||||
*/
|
||||
APT_DECLARE(void) apt_poller_task_cleanup(apt_poller_task_t *task);
|
||||
|
||||
/**
|
||||
* Start poller task and wait for incoming messages.
|
||||
* @param task the task to start
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_poller_task_start(apt_poller_task_t *task);
|
||||
|
||||
/**
|
||||
* Terminate poller task.
|
||||
* @param task the task to terminate
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_poller_task_terminate(apt_poller_task_t *task);
|
||||
|
||||
/**
|
||||
* Get task base.
|
||||
* @param task the poller task to get task base from
|
||||
*/
|
||||
APT_DECLARE(apt_task_t*) apt_poller_task_base_get(const apt_poller_task_t *task);
|
||||
|
||||
/**
|
||||
* Get task vtable.
|
||||
* @param task the poller task to get vtable from
|
||||
*/
|
||||
APT_DECLARE(apt_task_vtable_t*) apt_poller_task_vtable_get(apt_poller_task_t *task);
|
||||
|
||||
/**
|
||||
* Get external object.
|
||||
* @param task the poller task to get object from
|
||||
*/
|
||||
APT_DECLARE(void*) apt_poller_task_object_get(const apt_poller_task_t *task);
|
||||
|
||||
/**
|
||||
* Get pollset.
|
||||
* @param task the poller task to get pollset from
|
||||
*/
|
||||
APT_DECLARE(apt_pollset_t*) apt_poller_task_pollset_get(const apt_poller_task_t *task);
|
||||
|
||||
/**
|
||||
* Create timer.
|
||||
* @param task the poller task to create timer in the scope of
|
||||
* @param proc the timer callback
|
||||
* @param obj the object to pass to callback
|
||||
* @param pool the pool to allocate memory from
|
||||
*/
|
||||
APT_DECLARE(apt_timer_t*) apt_poller_task_timer_create(
|
||||
apt_poller_task_t *task,
|
||||
apt_timer_proc_f proc,
|
||||
void *obj,
|
||||
apr_pool_t *pool);
|
||||
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /* APT_POLLER_TASK_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_pollset.h 1565 2010-03-06 07:13:04Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __APT_POLLSET_H__
|
||||
#define __APT_POLLSET_H__
|
||||
#ifndef APT_POLLSET_H
|
||||
#define APT_POLLSET_H
|
||||
|
||||
/**
|
||||
* @file apt_pollset.h
|
||||
@@ -39,7 +41,7 @@ APT_BEGIN_EXTERN_C
|
||||
typedef struct apt_pollset_t apt_pollset_t;
|
||||
|
||||
/**
|
||||
* Create interruptable pollset on top of APR pollset
|
||||
* Create interruptable pollset on top of APR pollset.
|
||||
* @param size the maximum number of descriptors pollset can hold
|
||||
* @param pool the pool to allocate memory from
|
||||
*/
|
||||
@@ -69,7 +71,7 @@ APT_DECLARE(apt_bool_t) apt_pollset_remove(apt_pollset_t *pollset, const apr_pol
|
||||
* Block for activity on the descriptor(s) in a pollset.
|
||||
* @param pollset the pollset to use
|
||||
* @param timeout the timeout in microseconds
|
||||
* @param num nthe umber of signalled descriptors (output parameter)
|
||||
* @param num the number of signalled descriptors (output parameter)
|
||||
* @param descriptors the array of signalled descriptors (output parameter)
|
||||
*/
|
||||
APT_DECLARE(apr_status_t) apt_pollset_poll(
|
||||
@@ -93,4 +95,4 @@ APT_DECLARE(apt_bool_t) apt_pollset_is_wakeup(apt_pollset_t *pollset, const apr_
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__APT_POLLSET_H__*/
|
||||
#endif /* APT_POLLSET_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_pool.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __APT_POOL_H__
|
||||
#define __APT_POOL_H__
|
||||
#ifndef APT_POOL_H
|
||||
#define APT_POOL_H
|
||||
|
||||
/**
|
||||
* @file apt_pool.h
|
||||
@@ -44,4 +46,4 @@ APT_DECLARE(apr_pool_t*) apt_subpool_create(apr_pool_t *parent);
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__APT_POOL_H__*/
|
||||
#endif /* APT_POOL_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_string.h 1531 2010-02-20 14:19:53Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __APT_STRING_H__
|
||||
#define __APT_STRING_H__
|
||||
#ifndef APT_STRING_H
|
||||
#define APT_STRING_H
|
||||
|
||||
/**
|
||||
* @file apt_string.h
|
||||
@@ -65,7 +67,7 @@ static APR_INLINE apr_size_t apt_string_length_get(const apt_str_t *str)
|
||||
/** Check whether string is empty. */
|
||||
static APR_INLINE apr_size_t apt_string_is_empty(const apt_str_t *str)
|
||||
{
|
||||
return str->length ? TRUE : FALSE;
|
||||
return str->length ? FALSE : TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,4 +142,4 @@ static APR_INLINE apt_bool_t apt_string_compare(const apt_str_t *str1, const apt
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__APT_STRING_H__*/
|
||||
#endif /* APT_STRING_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_string_table.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __APT_STRING_TABLE_H__
|
||||
#define __APT_STRING_TABLE_H__
|
||||
#ifndef APT_STRING_TABLE_H
|
||||
#define APT_STRING_TABLE_H
|
||||
|
||||
/**
|
||||
* @file apt_string_table.h
|
||||
@@ -60,4 +62,4 @@ APT_DECLARE(apr_size_t) apt_string_table_id_find(const apt_str_table_item_t tabl
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__APT_STRING_TABLE_H__*/
|
||||
#endif /* APT_STRING_TABLE_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_task.h 1696 2010-05-20 15:44:16Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __APT_TASK_H__
|
||||
#define __APT_TASK_H__
|
||||
#ifndef APT_TASK_H
|
||||
#define APT_TASK_H
|
||||
|
||||
/**
|
||||
* @file apt_task.h
|
||||
@@ -124,19 +126,19 @@ APT_DECLARE(apt_bool_t) apt_task_msg_process(apt_task_t *task, apt_task_msg_t *m
|
||||
* Get parent (master) task.
|
||||
* @param task the task to get parent from
|
||||
*/
|
||||
APT_DECLARE(apt_task_t*) apt_task_parent_get(apt_task_t *task);
|
||||
APT_DECLARE(apt_task_t*) apt_task_parent_get(const apt_task_t *task);
|
||||
|
||||
/**
|
||||
* Get memory pool associated with task.
|
||||
* @param task the task to get pool from
|
||||
*/
|
||||
APT_DECLARE(apr_pool_t*) apt_task_pool_get(apt_task_t *task);
|
||||
APT_DECLARE(apr_pool_t*) apt_task_pool_get(const apt_task_t *task);
|
||||
|
||||
/**
|
||||
* Get external object associated with the task.
|
||||
* @param task the task to get object from
|
||||
*/
|
||||
APT_DECLARE(void*) apt_task_object_get(apt_task_t *task);
|
||||
APT_DECLARE(void*) apt_task_object_get(const apt_task_t *task);
|
||||
|
||||
/**
|
||||
* Get task vtable.
|
||||
@@ -155,7 +157,7 @@ APT_DECLARE(void) apt_task_name_set(apt_task_t *task, const char *name);
|
||||
* Get task name.
|
||||
* @param task the task to get name from
|
||||
*/
|
||||
APT_DECLARE(const char*) apt_task_name_get(apt_task_t *task);
|
||||
APT_DECLARE(const char*) apt_task_name_get(const apt_task_t *task);
|
||||
|
||||
/**
|
||||
* Enable/disable auto ready mode.
|
||||
@@ -170,6 +172,36 @@ APT_DECLARE(void) apt_task_auto_ready_set(apt_task_t *task, apt_bool_t auto_read
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_task_ready(apt_task_t *task);
|
||||
|
||||
/**
|
||||
* Get the running flag.
|
||||
* @param task the task
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t*) apt_task_running_flag_get(apt_task_t *task);
|
||||
|
||||
/**
|
||||
* Add start request.
|
||||
* @param task the task
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_task_start_request_add(apt_task_t *task);
|
||||
|
||||
/**
|
||||
* Remove start request.
|
||||
* @param task the task
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_task_start_request_remove(apt_task_t *task);
|
||||
|
||||
/**
|
||||
* Add termination request.
|
||||
* @param task the task
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_task_terminate_request_add(apt_task_t *task);
|
||||
|
||||
/**
|
||||
* Remove termination request.
|
||||
* @param task the task
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_task_terminate_request_remove(apt_task_t *task);
|
||||
|
||||
/**
|
||||
* Hold task execution.
|
||||
* @param msec the time to hold
|
||||
@@ -197,26 +229,16 @@ struct apt_task_vtable_t {
|
||||
apt_task_event_f on_pre_run;
|
||||
/** Virtual post-run event handler */
|
||||
apt_task_event_f on_post_run;
|
||||
/** Virtual start-request event handler */
|
||||
apt_task_event_f on_start_request;
|
||||
/** Virtual start-complete event handler */
|
||||
apt_task_event_f on_start_complete;
|
||||
/** Virtual terminate-request event handler */
|
||||
apt_task_event_f on_terminate_request;
|
||||
/** Virtual terminate-complete event handler */
|
||||
apt_task_event_f on_terminate_complete;
|
||||
};
|
||||
|
||||
static APR_INLINE void apt_task_vtable_reset(apt_task_vtable_t *vtable)
|
||||
{
|
||||
vtable->destroy = NULL;
|
||||
vtable->start = NULL;
|
||||
vtable->terminate = NULL;
|
||||
vtable->run = NULL;
|
||||
vtable->signal_msg = NULL;
|
||||
vtable->process_msg = NULL;
|
||||
vtable->on_pre_run = NULL;
|
||||
vtable->on_post_run = NULL;
|
||||
vtable->on_start_complete = NULL;
|
||||
vtable->on_terminate_complete = NULL;
|
||||
}
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__APT_TASK_H__*/
|
||||
#endif /* APT_TASK_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_task_msg.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __APT_TASK_MSG_H__
|
||||
#define __APT_TASK_MSG_H__
|
||||
#ifndef APT_TASK_MSG_H
|
||||
#define APT_TASK_MSG_H
|
||||
|
||||
/**
|
||||
* @file apt_task_msg.h
|
||||
@@ -77,4 +79,4 @@ APT_DECLARE(void) apt_task_msg_release(apt_task_msg_t *task_msg);
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__APT_TASK_MSG_H__*/
|
||||
#endif /* APT_TASK_MSG_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_test_suite.h 1708 2010-05-24 17:03:25Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __APT_TEST_SUITE_H__
|
||||
#define __APT_TEST_SUITE_H__
|
||||
#ifndef APT_TEST_SUITE_H
|
||||
#define APT_TEST_SUITE_H
|
||||
|
||||
/**
|
||||
* @file apt_test_suite.h
|
||||
@@ -92,8 +94,8 @@ APT_DECLARE(apt_bool_t) apt_test_framework_run(apt_test_framework_t *framework,
|
||||
* Retrieve the memory pool.
|
||||
* @param framework the test framework to retrieve memory pool from
|
||||
*/
|
||||
APT_DECLARE(apr_pool_t*) apt_test_framework_pool_get(apt_test_framework_t *framework);
|
||||
APT_DECLARE(apr_pool_t*) apt_test_framework_pool_get(const apt_test_framework_t *framework);
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__APT_TEST_SUITE_H__*/
|
||||
#endif /* APT_TEST_SUITE_H */
|
||||
@@ -0,0 +1,125 @@
|
||||
/*
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_text_message.h 1722 2010-06-01 08:40:35Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef APT_TEXT_MESSAGE_H
|
||||
#define APT_TEXT_MESSAGE_H
|
||||
|
||||
/**
|
||||
* @file apt_text_message.h
|
||||
* @brief Text Message Interface (RFC5322)
|
||||
*/
|
||||
|
||||
#include "apt_header_field.h"
|
||||
#include "apt_text_stream.h"
|
||||
|
||||
APT_BEGIN_EXTERN_C
|
||||
|
||||
/** Status of text message processing (parsing/generation) */
|
||||
typedef enum {
|
||||
APT_MESSAGE_STATUS_COMPLETE,
|
||||
APT_MESSAGE_STATUS_INCOMPLETE,
|
||||
APT_MESSAGE_STATUS_INVALID
|
||||
} apt_message_status_e;
|
||||
|
||||
|
||||
/** Opaque text message parser */
|
||||
typedef struct apt_message_parser_t apt_message_parser_t;
|
||||
/** Vtable of text message parser */
|
||||
typedef struct apt_message_parser_vtable_t apt_message_parser_vtable_t;
|
||||
|
||||
/** Opaque text message generator */
|
||||
typedef struct apt_message_generator_t apt_message_generator_t;
|
||||
/** Vtable of text message generator */
|
||||
typedef struct apt_message_generator_vtable_t apt_message_generator_vtable_t;
|
||||
|
||||
/** Temporary context associated with message and used for its parsing or generation */
|
||||
typedef struct apt_message_context_t apt_message_context_t;
|
||||
|
||||
/** Create message parser */
|
||||
APT_DECLARE(apt_message_parser_t*) apt_message_parser_create(void *obj, const apt_message_parser_vtable_t *vtable, apr_pool_t *pool);
|
||||
|
||||
/** Parse message by raising corresponding event handlers */
|
||||
APT_DECLARE(apt_message_status_e) apt_message_parser_run(apt_message_parser_t *parser, apt_text_stream_t *stream, void **message);
|
||||
|
||||
/** Get external object associated with parser */
|
||||
APT_DECLARE(void*) apt_message_parser_object_get(apt_message_parser_t *parser);
|
||||
|
||||
/** Set verbose mode for the parser */
|
||||
APT_DECLARE(void) apt_message_parser_verbose_set(apt_message_parser_t *parser, apt_bool_t verbose);
|
||||
|
||||
|
||||
/** Create message generator */
|
||||
APT_DECLARE(apt_message_generator_t*) apt_message_generator_create(void *obj, const apt_message_generator_vtable_t *vtable, apr_pool_t *pool);
|
||||
|
||||
/** Generate message */
|
||||
APT_DECLARE(apt_message_status_e) apt_message_generator_run(apt_message_generator_t *generator, void *message, apt_text_stream_t *stream);
|
||||
|
||||
/** Get external object associated with generator */
|
||||
APT_DECLARE(void*) apt_message_generator_object_get(apt_message_generator_t *generator);
|
||||
|
||||
/** Set verbose mode for the parser */
|
||||
APT_DECLARE(void) apt_message_generator_verbose_set(apt_message_generator_t *generator, apt_bool_t verbose);
|
||||
|
||||
|
||||
/** Parse individual header field (name-value pair) */
|
||||
APT_DECLARE(apt_header_field_t*) apt_header_field_parse(apt_text_stream_t *stream, apr_pool_t *pool);
|
||||
|
||||
/** Generate individual header field (name-value pair) */
|
||||
APT_DECLARE(apt_bool_t) apt_header_field_generate(const apt_header_field_t *header_field, apt_text_stream_t *stream);
|
||||
|
||||
/** Parse header section */
|
||||
APT_DECLARE(apt_bool_t) apt_header_section_parse(apt_header_section_t *header, apt_text_stream_t *stream, apr_pool_t *pool);
|
||||
|
||||
/** Generate header section */
|
||||
APT_DECLARE(apt_bool_t) apt_header_section_generate(const apt_header_section_t *header, apt_text_stream_t *stream);
|
||||
|
||||
|
||||
/** Temporary context associated with message and used for its parsing or generation */
|
||||
struct apt_message_context_t {
|
||||
/** Context or ptotocol specific message */
|
||||
void *message;
|
||||
/** Header section of the message */
|
||||
apt_header_section_t *header;
|
||||
/** Body or content of the message */
|
||||
apt_str_t *body;
|
||||
};
|
||||
|
||||
/** Vtable of text message parser */
|
||||
struct apt_message_parser_vtable_t {
|
||||
/** Start new message parsing by associating corresponding context and reading its start-line if applicable */
|
||||
apt_bool_t (*on_start)(apt_message_parser_t *parser, apt_message_context_t *context, apt_text_stream_t *stream, apr_pool_t *pool);
|
||||
/** Header section handler is invoked when entire header section has been read and parsed into header fields */
|
||||
apt_bool_t (*on_header_complete)(apt_message_parser_t *parser, apt_message_context_t *context);
|
||||
/** Body handler is invoked when entire body has been read */
|
||||
apt_bool_t (*on_body_complete)(apt_message_parser_t *parser, apt_message_context_t *context);
|
||||
};
|
||||
|
||||
/** Vtable of text message generator */
|
||||
struct apt_message_generator_vtable_t {
|
||||
/** Start message generation by associating corresponding context and generating message start-line if applicable */
|
||||
apt_bool_t (*on_start)(apt_message_generator_t *generator, apt_message_context_t *context, apt_text_stream_t *stream);
|
||||
/** Header section handler is invoked to notify header section has been generated */
|
||||
apt_bool_t (*on_header_complete)(apt_message_generator_t *generator, apt_message_context_t *context, apt_text_stream_t *stream);
|
||||
/** Body handler is invoked to notify body has been generated */
|
||||
apt_bool_t (*on_body_complete)(apt_message_generator_t *generator, apt_message_context_t *context, apt_text_stream_t *stream);
|
||||
};
|
||||
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /* APT_TEXT_MESSAGE_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,25 +12,27 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_text_stream.h 1672 2010-04-28 20:37:22Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __APT_TEXT_STREAM_H__
|
||||
#define __APT_TEXT_STREAM_H__
|
||||
#ifndef APT_TEXT_STREAM_H
|
||||
#define APT_TEXT_STREAM_H
|
||||
|
||||
/**
|
||||
* @file apt_text_stream.h
|
||||
* @brief Text Stream Parse/Generate Routine
|
||||
*/
|
||||
|
||||
#include "apt_string.h"
|
||||
#include "apt_string_table.h"
|
||||
#include "apt_pair.h"
|
||||
|
||||
APT_BEGIN_EXTERN_C
|
||||
|
||||
/** Named tokens */
|
||||
|
||||
/** Space */
|
||||
#define APT_TOKEN_SP ' '
|
||||
#define APT_TOKEN_SP 0x20
|
||||
/** Horizontal tab */
|
||||
#define APT_TOKEN_HTAB 0x09
|
||||
/** Carrige return */
|
||||
#define APT_TOKEN_CR 0x0D
|
||||
/** Line feed */
|
||||
@@ -52,73 +54,77 @@ struct apt_text_stream_t {
|
||||
apt_bool_t is_eos;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Navigate through the lines of the text stream (message).
|
||||
* @param stream the text stream to navigate
|
||||
* Read entire line of the text stream.
|
||||
* @param stream the text stream to navigate on
|
||||
* @param line the read line to return
|
||||
* @return TRUE if the line is successfully read, otherwise FALSE
|
||||
* @remark To be used to navigate through the lines of the text stream (message).
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_text_line_read(apt_text_stream_t *stream, apt_str_t *line);
|
||||
|
||||
/**
|
||||
* Navigate through the headers (name:value pairs) of the text stream (message).
|
||||
* Read header field (name-value pair) of the text stream by scanning entire line.
|
||||
* @param stream the text stream to navigate
|
||||
* @param pair the read pair to return
|
||||
* @return TRUE if the header is successfully read, otherwise FALSE
|
||||
* @remark To be used to navigate through the lines and read header fields
|
||||
* (name:value pairs) of the text stream (message).
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_text_header_read(apt_text_stream_t *stream, apt_pair_t *pair);
|
||||
|
||||
/**
|
||||
* Navigate through the fields of the line.
|
||||
* Read the field terminated with specified separator.
|
||||
* @param stream the text stream to navigate
|
||||
* @param separator the field separator
|
||||
* @param skip_spaces whether to skip spaces or not
|
||||
* @param field the read field to return
|
||||
* @return TRUE if the length of the field > 0, otherwise FALSE
|
||||
* @return TRUE if the read field isn't empty, otherwise FALSE
|
||||
* @remark To be used to navigate through the fields of the text stream (message).
|
||||
*/
|
||||
APT_DECLARE(apt_bool_t) apt_text_field_read(apt_text_stream_t *stream, char separator, apt_bool_t skip_spaces, apt_str_t *field);
|
||||
|
||||
/** Generate name-value pair line */
|
||||
APT_DECLARE(apt_bool_t) apt_text_name_value_insert(apt_text_stream_t *stream, const apt_str_t *name, const apt_str_t *value);
|
||||
|
||||
|
||||
/** Generate header */
|
||||
APT_DECLARE(apt_bool_t) apt_text_header_generate(const apt_pair_t *pair, apt_text_stream_t *text_stream);
|
||||
|
||||
/** Generate only the name ("name:") of the header */
|
||||
APT_DECLARE(apt_bool_t) apt_text_header_name_generate(const apt_str_t *name, apt_text_stream_t *text_stream);
|
||||
/** Generate only the name ("name:") of the header field */
|
||||
APT_DECLARE(apt_bool_t) apt_text_header_name_insert(apt_text_stream_t *stream, const apt_str_t *name);
|
||||
|
||||
/** Parse array of name-value pairs */
|
||||
APT_DECLARE(apt_bool_t) apt_pair_array_parse(apt_pair_arr_t *arr, const apt_str_t *value, apr_pool_t *pool);
|
||||
/** Generate array of name-value pairs */
|
||||
APT_DECLARE(apt_bool_t) apt_pair_array_generate(apt_pair_arr_t *arr, apt_text_stream_t *text_stream);
|
||||
APT_DECLARE(apt_bool_t) apt_pair_array_generate(const apt_pair_arr_t *arr, apt_str_t *str, apr_pool_t *pool);
|
||||
|
||||
/** Insert array of name-value pairs */
|
||||
APT_DECLARE(apt_bool_t) apt_text_pair_array_insert(apt_text_stream_t *stream, const apt_pair_arr_t *arr);
|
||||
|
||||
|
||||
/** Parse boolean-value */
|
||||
APT_DECLARE(apt_bool_t) apt_boolean_value_parse(const apt_str_t *str, apt_bool_t *value);
|
||||
/** Generate apr_size_t value from pool (buffer is allocated from pool) */
|
||||
APT_DECLARE(apt_bool_t) apt_boolean_value_generate(apt_bool_t value, apt_str_t *str, apr_pool_t *pool);
|
||||
|
||||
/** Generate boolean-value */
|
||||
APT_DECLARE(apt_bool_t) apt_boolean_value_generate(apt_bool_t value, apt_text_stream_t *str);
|
||||
/** Insert boolean-value */
|
||||
APT_DECLARE(apt_bool_t) apt_text_boolean_value_insert(apt_text_stream_t *stream, apt_bool_t value);
|
||||
|
||||
/** Parse size_t value */
|
||||
/** Parse apr_size_t value */
|
||||
APT_DECLARE(apr_size_t) apt_size_value_parse(const apt_str_t *str);
|
||||
/** Generate apr_size_t value from pool (buffer is allocated from pool) */
|
||||
APT_DECLARE(apt_bool_t) apt_size_value_generate(apr_size_t value, apt_str_t *str, apr_pool_t *pool);
|
||||
|
||||
/** Generate apr_size_t value */
|
||||
APT_DECLARE(apt_bool_t) apt_size_value_generate(apr_size_t value, apt_text_stream_t *stream);
|
||||
/** Insert apr_size_t value */
|
||||
APT_DECLARE(apt_bool_t) apt_text_size_value_insert(apt_text_stream_t *stream, apr_size_t value);
|
||||
|
||||
/** Parse float value */
|
||||
APT_DECLARE(float) apt_float_value_parse(const apt_str_t *str);
|
||||
/** Generate float value (buffer is allocated from pool) */
|
||||
APT_DECLARE(apt_bool_t) apt_float_value_generate(float value, apt_str_t *str, apr_pool_t *pool);
|
||||
|
||||
/** Generate float value */
|
||||
APT_DECLARE(apt_bool_t) apt_float_value_generate(float value, apt_text_stream_t *stream);
|
||||
|
||||
/** Generate string value */
|
||||
static APR_INLINE apt_bool_t apt_string_value_generate(const apt_str_t *str, apt_text_stream_t *stream)
|
||||
{
|
||||
if(str->length) {
|
||||
memcpy(stream->pos,str->buf,str->length);
|
||||
stream->pos += str->length;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
/** Insert float value */
|
||||
APT_DECLARE(apt_bool_t) apt_text_float_value_insert(apt_text_stream_t *stream, float value);
|
||||
/** Insert string value */
|
||||
APT_DECLARE(apt_bool_t) apt_text_string_insert(apt_text_stream_t *stream, const apt_str_t *str);
|
||||
|
||||
/** Reset navigation related data of the text stream */
|
||||
static APR_INLINE void apt_text_stream_reset(apt_text_stream_t *stream)
|
||||
@@ -137,36 +143,74 @@ static APR_INLINE void apt_text_stream_init(apt_text_stream_t *stream, char *buf
|
||||
}
|
||||
|
||||
/** Insert end of the line symbol(s) */
|
||||
static APR_INLINE void apt_text_eol_insert(apt_text_stream_t *stream)
|
||||
static APR_INLINE apt_bool_t apt_text_eol_insert(apt_text_stream_t *stream)
|
||||
{
|
||||
*stream->pos++ = APT_TOKEN_CR;
|
||||
*stream->pos++ = APT_TOKEN_LF;
|
||||
if(stream->pos + 2 < stream->end) {
|
||||
*stream->pos++ = APT_TOKEN_CR;
|
||||
*stream->pos++ = APT_TOKEN_LF;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/** Insert character */
|
||||
static APR_INLINE void apt_text_char_insert(apt_text_stream_t *stream, char ch)
|
||||
static APR_INLINE apt_bool_t apt_text_char_insert(apt_text_stream_t *stream, char ch)
|
||||
{
|
||||
*stream->pos++ = ch;
|
||||
if(stream->pos + 1 < stream->end) {
|
||||
*stream->pos++ = ch;
|
||||
return TRUE;
|
||||
}
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/** Insert space */
|
||||
static APR_INLINE void apt_text_space_insert(apt_text_stream_t *stream)
|
||||
static APR_INLINE apt_bool_t apt_text_space_insert(apt_text_stream_t *stream)
|
||||
{
|
||||
*stream->pos++ = APT_TOKEN_SP;
|
||||
return apt_text_char_insert(stream,APT_TOKEN_SP);
|
||||
}
|
||||
|
||||
/** Skip spaces */
|
||||
/** Insert space */
|
||||
static APR_INLINE apt_bool_t apt_text_htab_insert(apt_text_stream_t *stream)
|
||||
{
|
||||
return apt_text_char_insert(stream,APT_TOKEN_HTAB);
|
||||
}
|
||||
|
||||
/** Check whether specified character is a white space (WSP = SP / HTAB) */
|
||||
static APR_INLINE apt_bool_t apt_text_is_wsp(char ch)
|
||||
{
|
||||
return (ch == APT_TOKEN_SP || ch == APT_TOKEN_HTAB) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/** Skip sequence of spaces */
|
||||
static APR_INLINE void apt_text_spaces_skip(apt_text_stream_t *stream)
|
||||
{
|
||||
const char *end = stream->text.buf + stream->text.length;
|
||||
while(stream->pos < end && *stream->pos == APT_TOKEN_SP) stream->pos++;
|
||||
while(stream->pos < stream->end && *stream->pos == APT_TOKEN_SP)
|
||||
stream->pos++;
|
||||
}
|
||||
|
||||
/** Skip sequence of white spaces (WSP = SP / HTAB) */
|
||||
static APR_INLINE void apt_text_white_spaces_skip(apt_text_stream_t *stream)
|
||||
{
|
||||
while(stream->pos < stream->end && apt_text_is_wsp(*stream->pos) == TRUE)
|
||||
stream->pos++;
|
||||
}
|
||||
|
||||
/** Skip specified character */
|
||||
static APR_INLINE void apt_text_char_skip(apt_text_stream_t *stream, char ch)
|
||||
{
|
||||
const char *end = stream->text.buf + stream->text.length;
|
||||
if(stream->pos < end && *stream->pos == ch) stream->pos++;
|
||||
if(stream->pos < stream->end && *stream->pos == ch) stream->pos++;
|
||||
}
|
||||
|
||||
/** Skip sequence of specified characters */
|
||||
static APR_INLINE void apt_text_chars_skip(apt_text_stream_t *stream, char ch)
|
||||
{
|
||||
while(stream->pos < stream->end && *stream->pos == ch) stream->pos++;
|
||||
}
|
||||
|
||||
/** Skip to specified character */
|
||||
static APR_INLINE void apt_text_skip_to_char(apt_text_stream_t *stream, char ch)
|
||||
{
|
||||
while(stream->pos < stream->end && *stream->pos != ch) stream->pos++;
|
||||
}
|
||||
|
||||
/** Check whether end of stream is reached */
|
||||
@@ -180,13 +224,14 @@ APT_DECLARE(apt_bool_t) apt_text_stream_scroll(apt_text_stream_t *stream);
|
||||
|
||||
/** Parse id at resource string */
|
||||
APT_DECLARE(apt_bool_t) apt_id_resource_parse(const apt_str_t *str, char separator, apt_str_t *id, apt_str_t *resource, apr_pool_t *pool);
|
||||
|
||||
/** Generate id at resource string */
|
||||
APT_DECLARE(apt_bool_t) apt_id_resource_generate(const apt_str_t *id, const apt_str_t *resource, char separator, apt_str_t *str, apr_pool_t *pool);
|
||||
|
||||
/** Generate value plus the length (number of digits) of the value itself */
|
||||
APT_DECLARE(apt_bool_t) apt_var_length_value_generate(apr_size_t *value, apr_size_t max_count, apt_str_t *str);
|
||||
|
||||
/** Generate completion-cause */
|
||||
APT_DECLARE(apt_bool_t) apt_completion_cause_generate(const apt_str_table_item_t table[], apr_size_t size, apr_size_t cause, apt_str_t *str, apr_pool_t *pool);
|
||||
|
||||
/**
|
||||
* Generate unique identifier (hex string)
|
||||
@@ -199,4 +244,4 @@ APT_DECLARE(apt_bool_t) apt_unique_id_generate(apt_str_t *id, apr_size_t length,
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__APT_TEXT_STREAM_H__*/
|
||||
#endif /* APT_TEXT_STREAM_H */
|
||||
@@ -0,0 +1,68 @@
|
||||
/*
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_timer_queue.h 1642 2010-04-08 13:37:57Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef APT_TIMER_QUEUE_H
|
||||
#define APT_TIMER_QUEUE_H
|
||||
|
||||
/**
|
||||
* @file apt_timer_queue.h
|
||||
* @brief Timer Queue
|
||||
*/
|
||||
|
||||
#include "apt.h"
|
||||
|
||||
APT_BEGIN_EXTERN_C
|
||||
|
||||
/** Opaque timer declaration */
|
||||
typedef struct apt_timer_t apt_timer_t;
|
||||
/** Opaque timer queue declaration */
|
||||
typedef struct apt_timer_queue_t apt_timer_queue_t;
|
||||
|
||||
/** Prototype of timer callback */
|
||||
typedef void (*apt_timer_proc_f)(apt_timer_t *timer, void *obj);
|
||||
|
||||
|
||||
/** Create timer queue */
|
||||
APT_DECLARE(apt_timer_queue_t*) apt_timer_queue_create(apr_pool_t *pool);
|
||||
|
||||
/** Destroy timer queue */
|
||||
APT_DECLARE(void) apt_timer_queue_destroy(apt_timer_queue_t *timer_queue);
|
||||
|
||||
/** Advance scheduled timers */
|
||||
APT_DECLARE(void) apt_timer_queue_advance(apt_timer_queue_t *timer_queue, apr_uint32_t elapsed_time);
|
||||
|
||||
/** Is timer queue empty */
|
||||
APT_DECLARE(apt_bool_t) apt_timer_queue_is_empty(const apt_timer_queue_t *timer_queue);
|
||||
|
||||
/** Get current timeout */
|
||||
APT_DECLARE(apt_bool_t) apt_timer_queue_timeout_get(const apt_timer_queue_t *timer_queue, apr_uint32_t *timeout);
|
||||
|
||||
|
||||
/** Create timer */
|
||||
APT_DECLARE(apt_timer_t*) apt_timer_create(apt_timer_queue_t *timer_queue, apt_timer_proc_f proc, void *obj, apr_pool_t *pool);
|
||||
|
||||
/** Set one-shot timer */
|
||||
APT_DECLARE(apt_bool_t) apt_timer_set(apt_timer_t *timer, apr_uint32_t timeout);
|
||||
|
||||
/** Kill timer */
|
||||
APT_DECLARE(apt_bool_t) apt_timer_kill(apt_timer_t *timer);
|
||||
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /* APT_TIMER_QUEUE_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,6 +12,8 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_consumer_task.c 1708 2010-05-24 17:03:25Z achaloyan $
|
||||
*/
|
||||
|
||||
#include <apr_time.h>
|
||||
@@ -54,7 +56,7 @@ APT_DECLARE(apt_consumer_task_t*) apt_consumer_task_create(
|
||||
return consumer_task;
|
||||
}
|
||||
|
||||
APT_DECLARE(apt_task_t*) apt_consumer_task_base_get(apt_consumer_task_t *task)
|
||||
APT_DECLARE(apt_task_t*) apt_consumer_task_base_get(const apt_consumer_task_t *task)
|
||||
{
|
||||
return task->base;
|
||||
}
|
||||
@@ -64,7 +66,7 @@ APT_DECLARE(apt_task_vtable_t*) apt_consumer_task_vtable_get(apt_consumer_task_t
|
||||
return apt_task_vtable_get(task->base);
|
||||
}
|
||||
|
||||
APT_DECLARE(void*) apt_consumer_task_object_get(apt_consumer_task_t *task)
|
||||
APT_DECLARE(void*) apt_consumer_task_object_get(const apt_consumer_task_t *task)
|
||||
{
|
||||
return task->obj;
|
||||
}
|
||||
@@ -79,22 +81,25 @@ static apt_bool_t apt_consumer_task_run(apt_task_t *task)
|
||||
{
|
||||
apr_status_t rv;
|
||||
void *msg;
|
||||
apt_bool_t running = TRUE;
|
||||
apt_bool_t *running;
|
||||
apt_consumer_task_t *consumer_task;
|
||||
consumer_task = apt_task_object_get(task);
|
||||
if(!consumer_task) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
while(running) {
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Wait for Task Messages [%s]",apt_task_name_get(task));
|
||||
running = apt_task_running_flag_get(task);
|
||||
if(!running) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
while(*running) {
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Wait for Messages [%s]",apt_task_name_get(task));
|
||||
rv = apr_queue_pop(consumer_task->msg_queue,&msg);
|
||||
if(rv == APR_SUCCESS) {
|
||||
if(msg) {
|
||||
apt_task_msg_t *task_msg = msg;
|
||||
if(apt_task_msg_process(consumer_task->base,task_msg) == FALSE) {
|
||||
running = FALSE;
|
||||
}
|
||||
apt_task_msg_process(consumer_task->base,task_msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,6 +12,8 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_cyclic_queue.c 1708 2010-05-24 17:03:25Z achaloyan $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -78,7 +80,7 @@ APT_DECLARE(void) apt_cyclic_queue_clear(apt_cyclic_queue_t *queue)
|
||||
queue->head = queue->tail = 0;
|
||||
}
|
||||
|
||||
APT_DECLARE(apt_bool_t) apt_cyclic_queue_is_empty(apt_cyclic_queue_t *queue)
|
||||
APT_DECLARE(apt_bool_t) apt_cyclic_queue_is_empty(const apt_cyclic_queue_t *queue)
|
||||
{
|
||||
return queue->actual_size ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,6 +12,8 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_dir_layout.c 1524 2010-02-15 20:44:16Z achaloyan $
|
||||
*/
|
||||
|
||||
#include <apr_file_info.h>
|
||||
@@ -72,3 +74,14 @@ APT_DECLARE(char*) apt_datadir_filepath_get(const apt_dir_layout_t *dir_layout,
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
APT_DECLARE(char*) apt_confdir_filepath_get(const apt_dir_layout_t *dir_layout, const char *file_name, apr_pool_t *pool)
|
||||
{
|
||||
if(dir_layout && dir_layout->conf_dir_path && file_name) {
|
||||
char *file_path = NULL;
|
||||
if(apr_filepath_merge(&file_path,dir_layout->conf_dir_path,file_name,0,pool) == APR_SUCCESS) {
|
||||
return file_path;
|
||||
}
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
@@ -0,0 +1,183 @@
|
||||
/*
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_header_field.c 1685 2010-05-06 05:34:54Z achaloyan $
|
||||
*/
|
||||
|
||||
#include "apt_header_field.h"
|
||||
#include "apt_text_stream.h"
|
||||
|
||||
#define UNKNOWN_HEADER_FIELD_ID (apr_size_t)-1
|
||||
|
||||
/** Allocate an empty header field */
|
||||
APT_DECLARE(apt_header_field_t*) apt_header_field_alloc(apr_pool_t *pool)
|
||||
{
|
||||
apt_header_field_t *header_field = apr_palloc(pool,sizeof(apt_header_field_t));
|
||||
apt_string_reset(&header_field->name);
|
||||
apt_string_reset(&header_field->value);
|
||||
header_field->id = UNKNOWN_HEADER_FIELD_ID;
|
||||
APR_RING_ELEM_INIT(header_field,link);
|
||||
return header_field;
|
||||
}
|
||||
|
||||
/** Create a header field using given name and value APT strings */
|
||||
APT_DECLARE(apt_header_field_t*) apt_header_field_create(const apt_str_t *name, const apt_str_t *value, apr_pool_t *pool)
|
||||
{
|
||||
apt_header_field_t *header_field;
|
||||
if(!name || !value) {
|
||||
return NULL;
|
||||
}
|
||||
header_field = apr_palloc(pool,sizeof(apt_header_field_t));
|
||||
apt_string_copy(&header_field->name,name,pool);
|
||||
apt_string_copy(&header_field->value,value,pool);
|
||||
header_field->id = UNKNOWN_HEADER_FIELD_ID;
|
||||
APR_RING_ELEM_INIT(header_field,link);
|
||||
return header_field;
|
||||
}
|
||||
|
||||
/** Create a header field using given name and value C strings */
|
||||
APT_DECLARE(apt_header_field_t*) apt_header_field_create_c(const char *name, const char *value, apr_pool_t *pool)
|
||||
{
|
||||
apt_header_field_t *header_field;
|
||||
if(!name || !value) {
|
||||
return NULL;
|
||||
}
|
||||
header_field = apr_palloc(pool,sizeof(apt_header_field_t));
|
||||
apt_string_assign(&header_field->name,name,pool);
|
||||
apt_string_assign(&header_field->value,value,pool);
|
||||
header_field->id = UNKNOWN_HEADER_FIELD_ID;
|
||||
APR_RING_ELEM_INIT(header_field,link);
|
||||
return header_field;
|
||||
}
|
||||
|
||||
/* Create a header field from entire text line consisting of a name and value pair */
|
||||
APT_DECLARE(apt_header_field_t*) apt_header_field_create_from_line(const apt_str_t *line, char separator, apr_pool_t *pool)
|
||||
{
|
||||
apt_str_t item;
|
||||
apt_text_stream_t stream;
|
||||
apt_header_field_t *header_field;
|
||||
if(!line) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
header_field = apr_palloc(pool,sizeof(apt_header_field_t));
|
||||
stream.text = *line;
|
||||
apt_text_stream_reset(&stream);
|
||||
|
||||
/* read name */
|
||||
if(apt_text_field_read(&stream,separator,TRUE,&item) == FALSE) {
|
||||
return NULL;
|
||||
}
|
||||
apt_string_copy(&header_field->name,&item,pool);
|
||||
|
||||
/* read value */
|
||||
apt_text_field_read(&stream,0,TRUE,&item);
|
||||
apt_string_copy(&header_field->value,&item,pool);
|
||||
|
||||
header_field->id = UNKNOWN_HEADER_FIELD_ID;
|
||||
APR_RING_ELEM_INIT(header_field,link);
|
||||
return header_field;
|
||||
}
|
||||
|
||||
/** Copy specified header field */
|
||||
APT_DECLARE(apt_header_field_t*) apt_header_field_copy(const apt_header_field_t *src_header_field, apr_pool_t *pool)
|
||||
{
|
||||
apt_header_field_t *header_field = apr_palloc(pool,sizeof(apt_header_field_t));
|
||||
apt_string_copy(&header_field->name,&src_header_field->name,pool);
|
||||
apt_string_copy(&header_field->value,&src_header_field->value,pool);
|
||||
header_field->id = src_header_field->id;
|
||||
APR_RING_ELEM_INIT(header_field,link);
|
||||
return header_field;
|
||||
}
|
||||
|
||||
/** Initialize header section (collection of header fields) */
|
||||
APT_DECLARE(void) apt_header_section_init(apt_header_section_t *header)
|
||||
{
|
||||
APR_RING_INIT(&header->ring, apt_header_field_t, link);
|
||||
header->arr = NULL;
|
||||
header->arr_size = 0;
|
||||
}
|
||||
|
||||
/** Allocate header section to set/get header fields by numeric identifiers */
|
||||
APT_DECLARE(apt_bool_t) apt_header_section_array_alloc(apt_header_section_t *header, apr_size_t max_field_count, apr_pool_t *pool)
|
||||
{
|
||||
if(!max_field_count) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
header->arr = (apt_header_field_t**)apr_pcalloc(pool,sizeof(apt_header_field_t*) * max_field_count);
|
||||
header->arr_size = max_field_count;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/** Add (append) header field to header section */
|
||||
APT_DECLARE(apt_bool_t) apt_header_section_field_add(apt_header_section_t *header, apt_header_field_t *header_field)
|
||||
{
|
||||
if(header_field->id < header->arr_size) {
|
||||
if(header->arr[header_field->id]) {
|
||||
return FALSE;
|
||||
}
|
||||
header->arr[header_field->id] = header_field;
|
||||
}
|
||||
APR_RING_INSERT_TAIL(&header->ring,header_field,apt_header_field_t,link);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/** Insert header field to header section based on numreic identifier if specified */
|
||||
APT_DECLARE(apt_bool_t) apt_header_section_field_insert(apt_header_section_t *header, apt_header_field_t *header_field)
|
||||
{
|
||||
apt_header_field_t *it;
|
||||
if(header_field->id < header->arr_size) {
|
||||
if(header->arr[header_field->id]) {
|
||||
return FALSE;
|
||||
}
|
||||
header->arr[header_field->id] = header_field;
|
||||
|
||||
for(it = APR_RING_FIRST(&header->ring);
|
||||
it != APR_RING_SENTINEL(&header->ring, apt_header_field_t, link);
|
||||
it = APR_RING_NEXT(it, link)) {
|
||||
if(header_field->id < it->id) {
|
||||
APR_RING_INSERT_BEFORE(it,header_field,link);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
APR_RING_INSERT_TAIL(&header->ring,header_field,apt_header_field_t,link);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/** Set header field in the array of header fields using associated numeric identifier */
|
||||
APT_DECLARE(apt_bool_t) apt_header_section_field_set(apt_header_section_t *header, apt_header_field_t *header_field)
|
||||
{
|
||||
if(header_field->id >= header->arr_size) {
|
||||
return FALSE;
|
||||
}
|
||||
if(header->arr[header_field->id]) {
|
||||
return FALSE;
|
||||
}
|
||||
header->arr[header_field->id] = header_field;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/** Remove header field from header section */
|
||||
APT_DECLARE(apt_bool_t) apt_header_section_field_remove(apt_header_section_t *header, apt_header_field_t *header_field)
|
||||
{
|
||||
if(header_field->id < header->arr_size) {
|
||||
header->arr[header_field->id] = NULL;
|
||||
}
|
||||
APR_RING_REMOVE(header_field,link);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,14 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_log.c 1792 2011-01-10 21:08:52Z achaloyan $
|
||||
*/
|
||||
|
||||
#include <apr_time.h>
|
||||
#include <apr_file_io.h>
|
||||
#include <apr_portable.h>
|
||||
#include <apr_xml.h>
|
||||
#include "apt_log.h"
|
||||
|
||||
#define MAX_LOG_ENTRY_SIZE 4096
|
||||
@@ -43,6 +47,7 @@ struct apt_log_file_data_t {
|
||||
apr_size_t max_size;
|
||||
apr_size_t cur_file_index;
|
||||
apr_size_t max_file_count;
|
||||
apt_bool_t append;
|
||||
apr_thread_mutex_t *mutex;
|
||||
apr_pool_t *pool;
|
||||
};
|
||||
@@ -53,6 +58,7 @@ struct apt_logger_t {
|
||||
int header;
|
||||
apt_log_ext_handler_f ext_handler;
|
||||
apt_log_file_data_t *file_data;
|
||||
apt_log_masking_e masking;
|
||||
};
|
||||
|
||||
static apt_logger_t *apt_logger = NULL;
|
||||
@@ -61,19 +67,83 @@ static apt_bool_t apt_do_log(const char *file, int line, apt_log_priority_e prio
|
||||
|
||||
static const char* apt_log_file_path_make(apt_log_file_data_t *file_data);
|
||||
static apt_bool_t apt_log_file_dump(apt_log_file_data_t *file_data, const char *log_entry, apr_size_t size);
|
||||
static apr_xml_doc* apt_log_doc_parse(const char *file_path, apr_pool_t *pool);
|
||||
static apr_size_t apt_log_file_get_size(apt_log_file_data_t *file_data);
|
||||
static apr_byte_t apt_log_file_exist(apt_log_file_data_t *file_data);
|
||||
|
||||
static apt_logger_t* apt_log_instance_alloc(apr_pool_t *pool)
|
||||
{
|
||||
apt_logger_t *logger = apr_palloc(pool,sizeof(apt_logger_t));
|
||||
logger->mode = APT_LOG_OUTPUT_CONSOLE;
|
||||
logger->priority = APT_PRIO_INFO;
|
||||
logger->header = APT_LOG_HEADER_DEFAULT;
|
||||
logger->ext_handler = NULL;
|
||||
logger->file_data = NULL;
|
||||
logger->masking = APT_LOG_MASKING_NONE;
|
||||
return logger;
|
||||
}
|
||||
|
||||
APT_DECLARE(apt_bool_t) apt_log_instance_create(apt_log_output_e mode, apt_log_priority_e priority, apr_pool_t *pool)
|
||||
{
|
||||
if(apt_logger) {
|
||||
return FALSE;
|
||||
}
|
||||
apt_logger = apr_palloc(pool,sizeof(apt_logger_t));
|
||||
apt_logger = apt_log_instance_alloc(pool);
|
||||
apt_logger->mode = mode;
|
||||
apt_logger->priority = priority;
|
||||
apt_logger->header = APT_LOG_HEADER_DEFAULT;
|
||||
apt_logger->ext_handler = NULL;
|
||||
apt_logger->file_data = NULL;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
APT_DECLARE(apt_bool_t) apt_log_instance_load(const char *config_file, apr_pool_t *pool)
|
||||
{
|
||||
apr_xml_doc *doc;
|
||||
const apr_xml_elem *elem;
|
||||
const apr_xml_elem *root;
|
||||
char *text;
|
||||
|
||||
if(apt_logger) {
|
||||
return FALSE;
|
||||
}
|
||||
apt_logger = apt_log_instance_alloc(pool);
|
||||
|
||||
/* Parse XML document */
|
||||
doc = apt_log_doc_parse(config_file,pool);
|
||||
if(!doc) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
root = doc->root;
|
||||
|
||||
/* Match document name */
|
||||
if(!root || strcasecmp(root->name,"aptlogger") != 0) {
|
||||
/* Unknown document */
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* Navigate through document */
|
||||
for(elem = root->first_child; elem; elem = elem->next) {
|
||||
if(!elem->first_cdata.first || !elem->first_cdata.first->text)
|
||||
continue;
|
||||
|
||||
text = apr_pstrdup(pool,elem->first_cdata.first->text);
|
||||
apr_collapse_spaces(text,text);
|
||||
|
||||
if(strcasecmp(elem->name,"priority") == 0) {
|
||||
apt_logger->priority = apt_log_priority_translate(text);
|
||||
}
|
||||
else if(strcasecmp(elem->name,"output") == 0) {
|
||||
apt_logger->mode = apt_log_output_mode_translate(text);
|
||||
}
|
||||
else if(strcasecmp(elem->name,"headers") == 0) {
|
||||
apt_logger->header = apt_log_header_translate(text);
|
||||
}
|
||||
else if(strcasecmp(elem->name,"masking") == 0) {
|
||||
apt_logger->masking = apt_log_masking_translate(text);
|
||||
}
|
||||
else {
|
||||
/* Unknown element */
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
@@ -104,7 +174,13 @@ APT_DECLARE(apt_bool_t) apt_log_instance_set(apt_logger_t *logger)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
APT_DECLARE(apt_bool_t) apt_log_file_open(const char *dir_path, const char *file_name, apr_size_t max_file_size, apr_size_t max_file_count, apr_pool_t *pool)
|
||||
APT_DECLARE(apt_bool_t) apt_log_file_open(
|
||||
const char *dir_path,
|
||||
const char *file_name,
|
||||
apr_size_t max_file_size,
|
||||
apr_size_t max_file_count,
|
||||
apt_bool_t append,
|
||||
apr_pool_t *pool)
|
||||
{
|
||||
const char *log_file_path;
|
||||
apt_log_file_data_t *file_data;
|
||||
@@ -117,29 +193,55 @@ APT_DECLARE(apt_bool_t) apt_log_file_open(const char *dir_path, const char *file
|
||||
}
|
||||
|
||||
file_data = apr_palloc(pool,sizeof(apt_log_file_data_t));
|
||||
file_data->log_dir_path = dir_path;
|
||||
file_data->log_file_name = file_name;
|
||||
file_data->log_dir_path = apr_pstrdup(pool,dir_path);
|
||||
file_data->log_file_name = apr_pstrdup(pool,file_name);
|
||||
file_data->cur_file_index = 0;
|
||||
file_data->cur_size = 0;
|
||||
file_data->max_file_count = max_file_count;
|
||||
file_data->max_size = max_file_size;
|
||||
file_data->append = append;
|
||||
file_data->mutex = NULL;
|
||||
file_data->pool = pool;
|
||||
|
||||
if(!file_data->max_size) {
|
||||
file_data->max_file_count = MAX_LOG_FILE_SIZE;
|
||||
file_data->max_size = MAX_LOG_FILE_SIZE;
|
||||
}
|
||||
if(!file_data->max_file_count) {
|
||||
file_data->max_file_count = MAX_LOG_FILE_COUNT;
|
||||
}
|
||||
|
||||
if(file_data->append == TRUE) {
|
||||
/* iteratively find the last created file */
|
||||
while(file_data->cur_file_index<file_data->max_file_count)
|
||||
{
|
||||
if(apt_log_file_exist(file_data) == 0)
|
||||
{
|
||||
if(file_data->cur_file_index > 0)
|
||||
file_data->cur_file_index--;
|
||||
file_data->cur_size = apt_log_file_get_size(file_data);
|
||||
break;
|
||||
}
|
||||
file_data->cur_file_index++;
|
||||
}
|
||||
|
||||
/* if all the files have been created start rewriting from beginning */
|
||||
if(file_data->cur_file_index>=file_data->max_file_count)
|
||||
{
|
||||
file_data->cur_file_index=0;
|
||||
file_data->cur_size=0;
|
||||
log_file_path = apt_log_file_path_make(file_data);
|
||||
file_data->file = fopen(log_file_path,"wb"); /* truncate the first file to zero length */
|
||||
fclose(file_data->file);
|
||||
}
|
||||
}
|
||||
|
||||
/* create mutex */
|
||||
if(apr_thread_mutex_create(&file_data->mutex,APR_THREAD_MUTEX_DEFAULT,pool) != APR_SUCCESS) {
|
||||
return FALSE;
|
||||
}
|
||||
/* open log file */
|
||||
log_file_path = apt_log_file_path_make(file_data);
|
||||
file_data->file = fopen(log_file_path,"wb");
|
||||
file_data->file = fopen(log_file_path,file_data->append == TRUE ? "ab" : "wb");
|
||||
if(!file_data->file) {
|
||||
apr_thread_mutex_destroy(file_data->mutex);
|
||||
return FALSE;
|
||||
@@ -177,6 +279,31 @@ APT_DECLARE(apt_bool_t) apt_log_output_mode_set(apt_log_output_e mode)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
APT_DECLARE(apt_bool_t) apt_log_output_mode_check(apt_log_output_e mode)
|
||||
{
|
||||
if(!apt_logger) {
|
||||
return FALSE;
|
||||
}
|
||||
return (apt_logger->mode | mode) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
APT_DECLARE(int) apt_log_output_mode_translate(char *str)
|
||||
{
|
||||
int mode = APT_LOG_OUTPUT_NONE;
|
||||
char *name;
|
||||
char *last;
|
||||
name = apr_strtok(str, ",", &last);
|
||||
while(name) {
|
||||
if(strcasecmp(name, "CONSOLE") == 0)
|
||||
mode |= APT_LOG_OUTPUT_CONSOLE;
|
||||
else if(strcasecmp(name, "FILE") == 0)
|
||||
mode |= APT_LOG_OUTPUT_FILE;
|
||||
|
||||
name = apr_strtok(NULL, ",", &last);
|
||||
}
|
||||
return mode;
|
||||
}
|
||||
|
||||
APT_DECLARE(apt_bool_t) apt_log_priority_set(apt_log_priority_e priority)
|
||||
{
|
||||
if(!apt_logger || priority >= APT_PRIO_COUNT) {
|
||||
@@ -186,6 +313,28 @@ APT_DECLARE(apt_bool_t) apt_log_priority_set(apt_log_priority_e priority)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
APT_DECLARE(apt_log_priority_e) apt_log_priority_translate(const char *str)
|
||||
{
|
||||
if(strcasecmp(str, "EMERGENCY") == 0)
|
||||
return APT_PRIO_EMERGENCY;
|
||||
else if(strcasecmp(str, "ALERT") == 0)
|
||||
return APT_PRIO_ALERT;
|
||||
else if(strcasecmp(str, "CRITICAL") == 0)
|
||||
return APT_PRIO_CRITICAL;
|
||||
else if(strcasecmp(str, "ERROR") == 0)
|
||||
return APT_PRIO_ERROR;
|
||||
else if(strcasecmp(str, "WARNING") == 0)
|
||||
return APT_PRIO_WARNING;
|
||||
else if(strcasecmp(str, "NOTICE") == 0)
|
||||
return APT_PRIO_NOTICE;
|
||||
else if(strcasecmp(str, "INFO") == 0)
|
||||
return APT_PRIO_INFO;
|
||||
else if(strcasecmp(str, "DEBUG") == 0)
|
||||
return APT_PRIO_DEBUG;
|
||||
|
||||
return APT_PRIO_DEBUG;
|
||||
}
|
||||
|
||||
APT_DECLARE(apt_bool_t) apt_log_header_set(int header)
|
||||
{
|
||||
if(!apt_logger) {
|
||||
@@ -195,6 +344,69 @@ APT_DECLARE(apt_bool_t) apt_log_header_set(int header)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
APT_DECLARE(int) apt_log_header_translate(char *str)
|
||||
{
|
||||
int header = APT_LOG_OUTPUT_NONE;
|
||||
char *name;
|
||||
char *last;
|
||||
name = apr_strtok(str, ",", &last);
|
||||
while(name) {
|
||||
if(strcasecmp(name, "DATE") == 0)
|
||||
header |= APT_LOG_HEADER_DATE;
|
||||
else if(strcasecmp(name, "TIME") == 0)
|
||||
header |= APT_LOG_HEADER_TIME;
|
||||
else if(strcasecmp(name, "PRIORITY") == 0)
|
||||
header |= APT_LOG_HEADER_PRIORITY;
|
||||
else if(strcasecmp(name, "MARK") == 0)
|
||||
header |= APT_LOG_HEADER_MARK;
|
||||
else if(strcasecmp(name, "THREAD") == 0)
|
||||
header |= APT_LOG_HEADER_THREAD;
|
||||
|
||||
name = apr_strtok(NULL, ",", &last);
|
||||
}
|
||||
return header;
|
||||
}
|
||||
|
||||
APT_DECLARE(apt_bool_t) apt_log_masking_set(apt_log_masking_e masking)
|
||||
{
|
||||
if(!apt_logger) {
|
||||
return FALSE;
|
||||
}
|
||||
apt_logger->masking = masking;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
APT_DECLARE(apt_log_masking_e) apt_log_masking_get()
|
||||
{
|
||||
if(!apt_logger) {
|
||||
return APT_LOG_MASKING_NONE;
|
||||
}
|
||||
return apt_logger->masking;
|
||||
}
|
||||
|
||||
APT_DECLARE(apt_log_masking_e) apt_log_masking_translate(const char *str)
|
||||
{
|
||||
if(strcasecmp(str, "COMPLETE") == 0)
|
||||
return APT_LOG_MASKING_COMPLETE;
|
||||
else if(strcasecmp(str, "ENCRYPTED") == 0)
|
||||
return APT_LOG_MASKING_ENCRYPTED;
|
||||
return APT_LOG_MASKING_NONE;
|
||||
}
|
||||
|
||||
#define APT_MASKED_CONTENT "*** masked ***"
|
||||
|
||||
APT_DECLARE(const char*) apt_log_data_mask(const char *data_in, apr_size_t *length, apr_pool_t *pool)
|
||||
{
|
||||
if(!apt_logger) {
|
||||
return NULL;
|
||||
}
|
||||
if(apt_logger->masking == APT_LOG_MASKING_COMPLETE) {
|
||||
*length = sizeof(APT_MASKED_CONTENT) - 1;
|
||||
return APT_MASKED_CONTENT;
|
||||
}
|
||||
return data_in;
|
||||
}
|
||||
|
||||
APT_DECLARE(apt_bool_t) apt_log_ext_handler_set(apt_log_ext_handler_f handler)
|
||||
{
|
||||
if(!apt_logger) {
|
||||
@@ -224,6 +436,35 @@ APT_DECLARE(apt_bool_t) apt_log(const char *file, int line, apt_log_priority_e p
|
||||
return status;
|
||||
}
|
||||
|
||||
APT_DECLARE(apt_bool_t) apt_obj_log(const char *file, int line, apt_log_priority_e priority, void *obj, const char *format, ...)
|
||||
{
|
||||
apt_bool_t status = TRUE;
|
||||
if(!apt_logger) {
|
||||
return FALSE;
|
||||
}
|
||||
if(priority <= apt_logger->priority) {
|
||||
va_list arg_ptr;
|
||||
va_start(arg_ptr, format);
|
||||
if(apt_logger->ext_handler) {
|
||||
status = apt_logger->ext_handler(file,line,obj,priority,format,arg_ptr);
|
||||
}
|
||||
else {
|
||||
status = apt_do_log(file,line,priority,format,arg_ptr);
|
||||
}
|
||||
va_end(arg_ptr);
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
static APR_INLINE unsigned long apt_thread_id_get()
|
||||
{
|
||||
#ifdef WIN32
|
||||
return (unsigned long) GetCurrentThreadId();
|
||||
#else
|
||||
return (unsigned long) apr_os_thread_current();
|
||||
#endif
|
||||
}
|
||||
|
||||
static apt_bool_t apt_do_log(const char *file, int line, apt_log_priority_e priority, const char *format, va_list arg_ptr)
|
||||
{
|
||||
char log_entry[MAX_LOG_ENTRY_SIZE];
|
||||
@@ -249,6 +490,9 @@ static apt_bool_t apt_do_log(const char *file, int line, apt_log_priority_e prio
|
||||
if(apt_logger->header & APT_LOG_HEADER_MARK) {
|
||||
offset += apr_snprintf(log_entry+offset,max_size-offset,"%s:%03d ",file,line);
|
||||
}
|
||||
if(apt_logger->header & APT_LOG_HEADER_THREAD) {
|
||||
offset += apr_snprintf(log_entry+offset,max_size-offset,"%05lu ",apt_thread_id_get());
|
||||
}
|
||||
if(apt_logger->header & APT_LOG_HEADER_PRIORITY) {
|
||||
memcpy(log_entry+offset,priority_snames[priority],MAX_PRIORITY_NAME_LENGTH);
|
||||
offset += MAX_PRIORITY_NAME_LENGTH;
|
||||
@@ -275,6 +519,40 @@ static const char* apt_log_file_path_make(apt_log_file_data_t *file_data)
|
||||
return log_file_path;
|
||||
}
|
||||
|
||||
static apr_size_t apt_log_file_get_size(apt_log_file_data_t *file_data)
|
||||
{
|
||||
FILE* fp;
|
||||
const char *log_file_path;
|
||||
apr_size_t ret;
|
||||
|
||||
log_file_path = apt_log_file_path_make(file_data);
|
||||
fp = fopen(log_file_path,"rb");
|
||||
|
||||
if(!fp) return 0;
|
||||
|
||||
fseek(fp,0,SEEK_END);
|
||||
ret = ftell(fp);
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
static apr_byte_t apt_log_file_exist(apt_log_file_data_t *file_data)
|
||||
{
|
||||
FILE* fp;
|
||||
const char *log_file_path;
|
||||
|
||||
log_file_path = apt_log_file_path_make(file_data);
|
||||
fp = fopen(log_file_path,"rb");
|
||||
|
||||
if(!fp) return 0;
|
||||
|
||||
fclose(fp);
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static apt_bool_t apt_log_file_dump(apt_log_file_data_t *file_data, const char *log_entry, apr_size_t size)
|
||||
{
|
||||
apr_thread_mutex_lock(file_data->mutex);
|
||||
@@ -303,3 +581,24 @@ static apt_bool_t apt_log_file_dump(apt_log_file_data_t *file_data, const char *
|
||||
apr_thread_mutex_unlock(file_data->mutex);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static apr_xml_doc* apt_log_doc_parse(const char *file_path, apr_pool_t *pool)
|
||||
{
|
||||
apr_xml_parser *parser = NULL;
|
||||
apr_xml_doc *xml_doc = NULL;
|
||||
apr_file_t *fd = NULL;
|
||||
apr_status_t rv;
|
||||
|
||||
rv = apr_file_open(&fd,file_path,APR_READ|APR_BINARY,0,pool);
|
||||
if(rv != APR_SUCCESS) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
rv = apr_xml_parse_file(pool,&parser,&xml_doc,fd,2000);
|
||||
if(rv != APR_SUCCESS) {
|
||||
xml_doc = NULL;
|
||||
}
|
||||
|
||||
apr_file_close(fd);
|
||||
return xml_doc;
|
||||
}
|
||||
@@ -0,0 +1,312 @@
|
||||
/*
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_multipart_content.c 1673 2010-04-28 20:45:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "apt_multipart_content.h"
|
||||
#include "apt_text_stream.h"
|
||||
#include "apt_text_message.h"
|
||||
|
||||
#define CONTENT_LENGTH_HEADER "Content-Length"
|
||||
#define CONTENT_TYPE_HEADER "Content-Type"
|
||||
#define CONTENT_ID_HEADER "Content-Id"
|
||||
|
||||
#define DEFAULT_BOUNDARY "break"
|
||||
#define DEFAULT_HYPHENS "--"
|
||||
|
||||
#define DEFAULT_MULTIPART_CONTENT_SIZE 4096
|
||||
|
||||
/** Multipart content */
|
||||
struct apt_multipart_content_t {
|
||||
apr_pool_t *pool;
|
||||
apt_text_stream_t stream;
|
||||
|
||||
apt_str_t boundary;
|
||||
apt_str_t hyphens;
|
||||
};
|
||||
|
||||
/** Create an empty multipart content */
|
||||
APT_DECLARE(apt_multipart_content_t*) apt_multipart_content_create(apr_size_t max_content_size, const apt_str_t *boundary, apr_pool_t *pool)
|
||||
{
|
||||
char *buffer;
|
||||
apt_multipart_content_t *multipart_content = apr_palloc(pool,sizeof(apt_multipart_content_t));
|
||||
multipart_content->pool = pool;
|
||||
|
||||
if(max_content_size == 0) {
|
||||
max_content_size = DEFAULT_MULTIPART_CONTENT_SIZE;
|
||||
}
|
||||
|
||||
if(boundary) {
|
||||
multipart_content->boundary = *boundary;
|
||||
}
|
||||
else {
|
||||
multipart_content->boundary.buf = DEFAULT_BOUNDARY;
|
||||
multipart_content->boundary.length = sizeof(DEFAULT_BOUNDARY)-1;
|
||||
}
|
||||
|
||||
multipart_content->hyphens.buf = DEFAULT_HYPHENS;
|
||||
multipart_content->hyphens.length = sizeof(DEFAULT_HYPHENS)-1;
|
||||
|
||||
buffer = apr_palloc(pool,max_content_size+1);
|
||||
apt_text_stream_init(&multipart_content->stream,buffer,max_content_size);
|
||||
return multipart_content;
|
||||
}
|
||||
|
||||
/** Initialize content part generation */
|
||||
static apt_bool_t apt_multipart_content_initialize(apt_multipart_content_t *multipart_content)
|
||||
{
|
||||
/* insert preceding end-of-line */
|
||||
if(apt_text_eol_insert(&multipart_content->stream) == FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
/* insert hyphens */
|
||||
if(apt_text_string_insert(&multipart_content->stream,&multipart_content->hyphens) == FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
/* insert boundary */
|
||||
if(apt_text_string_insert(&multipart_content->stream,&multipart_content->boundary) == FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
return apt_text_eol_insert(&multipart_content->stream);
|
||||
}
|
||||
|
||||
/** Add content part to multipart content */
|
||||
APT_DECLARE(apt_bool_t) apt_multipart_content_add(apt_multipart_content_t *multipart_content, const apt_content_part_t *content_part)
|
||||
{
|
||||
if(!content_part) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* insert preceding eol, hyppens and boudnary */
|
||||
if(apt_multipart_content_initialize(multipart_content) == FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* insert header fields */
|
||||
if(apt_header_section_generate(&content_part->header,&multipart_content->stream) == FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* insert body */
|
||||
return apt_text_string_insert(&multipart_content->stream,&content_part->body);
|
||||
}
|
||||
|
||||
/** Add content part to multipart content by specified header fields and body */
|
||||
APT_DECLARE(apt_bool_t) apt_multipart_content_add2(apt_multipart_content_t *multipart_content, const apt_str_t *content_type, const apt_str_t *content_id, const apt_str_t *body)
|
||||
{
|
||||
/* insert preceding eol, hyppens and boudnary */
|
||||
if(apt_multipart_content_initialize(multipart_content) == FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* insert content-type */
|
||||
if(content_type) {
|
||||
apt_str_t name = {CONTENT_TYPE_HEADER,sizeof(CONTENT_TYPE_HEADER)-1};
|
||||
if(apt_text_name_value_insert(&multipart_content->stream,&name,content_type) == FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* insert content-id */
|
||||
if(content_id) {
|
||||
apt_str_t name = {CONTENT_ID_HEADER,sizeof(CONTENT_ID_HEADER)-1};
|
||||
if(apt_text_name_value_insert(&multipart_content->stream,&name,content_id) == FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* insert content-length */
|
||||
if(body) {
|
||||
apt_str_t name = {CONTENT_LENGTH_HEADER,sizeof(CONTENT_LENGTH_HEADER)-1};
|
||||
if(apt_text_header_name_insert(&multipart_content->stream,&name) == FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
if(apt_text_size_value_insert(&multipart_content->stream,body->length) == FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
if(apt_text_eol_insert(&multipart_content->stream) == FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
/* insert empty line */
|
||||
if(apt_text_eol_insert(&multipart_content->stream) == FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* insert body */
|
||||
if(body) {
|
||||
if(apt_text_string_insert(&multipart_content->stream,body) == FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/** Finalize multipart content generation */
|
||||
APT_DECLARE(apt_str_t*) apt_multipart_content_finalize(apt_multipart_content_t *multipart_content)
|
||||
{
|
||||
apt_text_stream_t *stream = &multipart_content->stream;
|
||||
/* insert preceding end-of-line */
|
||||
if(apt_text_eol_insert(&multipart_content->stream) == FALSE) {
|
||||
return NULL;
|
||||
}
|
||||
/* insert hyphens */
|
||||
if(apt_text_string_insert(&multipart_content->stream,&multipart_content->hyphens) == FALSE) {
|
||||
return NULL;
|
||||
}
|
||||
/* insert boundary */
|
||||
if(apt_text_string_insert(&multipart_content->stream,&multipart_content->boundary) == FALSE) {
|
||||
return NULL;
|
||||
}
|
||||
/* insert final hyphens */
|
||||
if(apt_text_string_insert(&multipart_content->stream,&multipart_content->hyphens) == FALSE) {
|
||||
return NULL;
|
||||
}
|
||||
if(apt_text_eol_insert(&multipart_content->stream) == FALSE) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
stream->text.length = stream->pos - stream->text.buf;
|
||||
stream->text.buf[stream->text.length] = '\0';
|
||||
return &stream->text;
|
||||
}
|
||||
|
||||
|
||||
/** Assign body to multipart content to get (parse) each content part from */
|
||||
APT_DECLARE(apt_multipart_content_t*) apt_multipart_content_assign(const apt_str_t *body, const apt_str_t *boundary, apr_pool_t *pool)
|
||||
{
|
||||
apt_multipart_content_t *multipart_content = apr_palloc(pool,sizeof(apt_multipart_content_t));
|
||||
multipart_content->pool = pool;
|
||||
|
||||
if(!body) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(boundary) {
|
||||
multipart_content->boundary = *boundary;
|
||||
}
|
||||
else {
|
||||
apt_string_reset(&multipart_content->boundary);
|
||||
}
|
||||
|
||||
apt_string_reset(&multipart_content->hyphens);
|
||||
apt_text_stream_init(&multipart_content->stream,body->buf,body->length);
|
||||
return multipart_content;
|
||||
}
|
||||
|
||||
static APR_INLINE void apt_content_part_reset(apt_content_part_t *content_part)
|
||||
{
|
||||
apt_header_section_init(&content_part->header);
|
||||
apt_string_reset(&content_part->body);
|
||||
content_part->type = NULL;
|
||||
content_part->id = NULL;
|
||||
content_part->length = NULL;
|
||||
}
|
||||
|
||||
/** Get the next content part */
|
||||
APT_DECLARE(apt_bool_t) apt_multipart_content_get(apt_multipart_content_t *multipart_content, apt_content_part_t *content_part, apt_bool_t *is_final)
|
||||
{
|
||||
apt_str_t boundary;
|
||||
apt_header_field_t *header_field;
|
||||
apt_text_stream_t *stream = &multipart_content->stream;
|
||||
|
||||
if(!content_part || !is_final) {
|
||||
return FALSE;
|
||||
}
|
||||
*is_final = FALSE;
|
||||
apt_content_part_reset(content_part);
|
||||
|
||||
/* skip preamble */
|
||||
apt_text_skip_to_char(stream,'-');
|
||||
if(apt_text_is_eos(stream) == TRUE) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* skip initial hyphens */
|
||||
apt_text_chars_skip(stream,'-');
|
||||
if(apt_text_is_eos(stream) == TRUE) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* read line and the boundary */
|
||||
if(apt_text_line_read(stream,&boundary) == FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* remove optional trailing spaces */
|
||||
while(boundary.length && boundary.buf[boundary.length-1] == APT_TOKEN_SP) boundary.length--;
|
||||
|
||||
/* check whether this is the final boundary */
|
||||
if(boundary.length >= 2) {
|
||||
if(boundary.buf[boundary.length-1] == '-' && boundary.buf[boundary.length-2] == '-') {
|
||||
/* final boundary */
|
||||
boundary.length -= 2;
|
||||
*is_final = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/* compare boundaries */
|
||||
if(apt_string_is_empty(&multipart_content->boundary) == TRUE) {
|
||||
/* no boundary was specified from user space,
|
||||
learn boundary from the content */
|
||||
multipart_content->boundary = boundary;
|
||||
}
|
||||
else {
|
||||
if(apt_string_compare(&multipart_content->boundary,&boundary) == FALSE) {
|
||||
/* invalid boundary */
|
||||
return FALSE;
|
||||
}
|
||||
}
|
||||
|
||||
if(*is_final == TRUE) {
|
||||
/* final boundary => return TRUE, content remains empty */
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* read header fields */
|
||||
if(apt_header_section_parse(&content_part->header,stream,multipart_content->pool) == FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
for(header_field = APR_RING_FIRST(&content_part->header.ring);
|
||||
header_field != APR_RING_SENTINEL(&content_part->header.ring, apt_header_field_t, link);
|
||||
header_field = APR_RING_NEXT(header_field, link)) {
|
||||
if(strncmp(header_field->name.buf,CONTENT_LENGTH_HEADER,header_field->name.length) == 0) {
|
||||
content_part->length = &header_field->value;
|
||||
}
|
||||
else if(strncmp(header_field->name.buf,CONTENT_TYPE_HEADER,header_field->name.length) == 0) {
|
||||
content_part->type = &header_field->value;
|
||||
}
|
||||
else if(strncmp(header_field->name.buf,CONTENT_ID_HEADER,header_field->name.length) == 0) {
|
||||
content_part->id = &header_field->value;
|
||||
}
|
||||
}
|
||||
|
||||
if(content_part->length && apt_string_is_empty(content_part->length) == FALSE) {
|
||||
apr_size_t length = atoi(content_part->length->buf);
|
||||
if(length + stream->pos > stream->end) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* read content */
|
||||
apt_string_assign_n(&content_part->body,stream->pos,length,multipart_content->pool);
|
||||
stream->pos += length;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,6 +12,8 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_net.c 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#include <apr_network_io.h>
|
||||
|
||||
@@ -1,322 +0,0 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "apt_net_client_task.h"
|
||||
#include "apt_task.h"
|
||||
#include "apt_pool.h"
|
||||
#include "apt_pollset.h"
|
||||
#include "apt_cyclic_queue.h"
|
||||
#include "apt_log.h"
|
||||
|
||||
|
||||
/** Network client task */
|
||||
struct apt_net_client_task_t {
|
||||
apr_pool_t *pool;
|
||||
apt_task_t *base;
|
||||
void *obj;
|
||||
|
||||
apr_size_t max_connection_count;
|
||||
|
||||
apr_thread_mutex_t *guard;
|
||||
apt_cyclic_queue_t *msg_queue;
|
||||
apt_pollset_t *pollset;
|
||||
|
||||
const apt_net_client_vtable_t *client_vtable;
|
||||
};
|
||||
|
||||
static apt_bool_t apt_net_client_task_msg_signal(apt_task_t *task, apt_task_msg_t *msg);
|
||||
static apt_bool_t apt_net_client_task_run(apt_task_t *task);
|
||||
static apt_bool_t apt_net_client_task_on_destroy(apt_task_t *task);
|
||||
|
||||
/** Create connection task */
|
||||
APT_DECLARE(apt_net_client_task_t*) apt_net_client_task_create(
|
||||
apr_size_t max_connection_count,
|
||||
void *obj,
|
||||
const apt_net_client_vtable_t *client_vtable,
|
||||
apt_task_msg_pool_t *msg_pool,
|
||||
apr_pool_t *pool)
|
||||
{
|
||||
apt_task_vtable_t *vtable;
|
||||
apt_net_client_task_t *task;
|
||||
|
||||
task = apr_palloc(pool,sizeof(apt_net_client_task_t));
|
||||
task->pool = pool;
|
||||
task->obj = obj;
|
||||
task->pollset = NULL;
|
||||
task->max_connection_count = max_connection_count;
|
||||
|
||||
if(!client_vtable || !client_vtable->on_receive) {
|
||||
return NULL;
|
||||
}
|
||||
task->client_vtable = client_vtable;
|
||||
|
||||
task->base = apt_task_create(task,msg_pool,pool);
|
||||
if(!task->base) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
vtable = apt_task_vtable_get(task->base);
|
||||
if(vtable) {
|
||||
vtable->run = apt_net_client_task_run;
|
||||
vtable->destroy = apt_net_client_task_on_destroy;
|
||||
vtable->signal_msg = apt_net_client_task_msg_signal;
|
||||
}
|
||||
apt_task_auto_ready_set(task->base,FALSE);
|
||||
|
||||
task->msg_queue = apt_cyclic_queue_create(CYCLIC_QUEUE_DEFAULT_SIZE);
|
||||
apr_thread_mutex_create(&task->guard,APR_THREAD_MUTEX_UNNESTED,pool);
|
||||
return task;
|
||||
}
|
||||
|
||||
/** Virtual destroy handler */
|
||||
static apt_bool_t apt_net_client_task_on_destroy(apt_task_t *base)
|
||||
{
|
||||
apt_net_client_task_t *task = apt_task_object_get(base);
|
||||
if(task->guard) {
|
||||
apr_thread_mutex_destroy(task->guard);
|
||||
task->guard = NULL;
|
||||
}
|
||||
if(task->msg_queue) {
|
||||
apt_cyclic_queue_destroy(task->msg_queue);
|
||||
task->msg_queue = NULL;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/** Destroy connection task. */
|
||||
APT_DECLARE(apt_bool_t) apt_net_client_task_destroy(apt_net_client_task_t *task)
|
||||
{
|
||||
return apt_task_destroy(task->base);
|
||||
}
|
||||
|
||||
/** Start connection task. */
|
||||
APT_DECLARE(apt_bool_t) apt_net_client_task_start(apt_net_client_task_t *task)
|
||||
{
|
||||
return apt_task_start(task->base);
|
||||
}
|
||||
|
||||
/** Terminate connection task. */
|
||||
APT_DECLARE(apt_bool_t) apt_net_client_task_terminate(apt_net_client_task_t *task)
|
||||
{
|
||||
return apt_task_terminate(task->base,TRUE);
|
||||
}
|
||||
|
||||
/** Get task */
|
||||
APT_DECLARE(apt_task_t*) apt_net_client_task_base_get(apt_net_client_task_t *task)
|
||||
{
|
||||
return task->base;
|
||||
}
|
||||
|
||||
/** Get task vtable */
|
||||
APT_DECLARE(apt_task_vtable_t*) apt_net_client_task_vtable_get(apt_net_client_task_t *task)
|
||||
{
|
||||
return apt_task_vtable_get(task->base);
|
||||
}
|
||||
|
||||
/** Get external object */
|
||||
APT_DECLARE(void*) apt_net_client_task_object_get(apt_net_client_task_t *task)
|
||||
{
|
||||
return task->obj;
|
||||
}
|
||||
|
||||
/** Create connection */
|
||||
APT_DECLARE(apt_net_client_connection_t*) apt_net_client_connect(apt_net_client_task_t *task, const char *ip, apr_port_t port)
|
||||
{
|
||||
char *local_ip = NULL;
|
||||
char *remote_ip = NULL;
|
||||
apr_sockaddr_t *l_sockaddr = NULL;
|
||||
apr_sockaddr_t *r_sockaddr = NULL;
|
||||
apt_net_client_connection_t *connection;
|
||||
apr_pool_t *pool = apt_pool_create();
|
||||
if(!pool) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
connection = apr_palloc(pool,sizeof(apt_net_client_connection_t));
|
||||
connection->pool = pool;
|
||||
connection->obj = NULL;
|
||||
connection->sock = NULL;
|
||||
|
||||
if(apr_sockaddr_info_get(&r_sockaddr,ip,APR_INET,port,0,connection->pool) != APR_SUCCESS) {
|
||||
apr_pool_destroy(pool);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(apr_socket_create(&connection->sock,r_sockaddr->family,SOCK_STREAM,APR_PROTO_TCP,connection->pool) != APR_SUCCESS) {
|
||||
apr_pool_destroy(pool);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
apr_socket_opt_set(connection->sock, APR_SO_NONBLOCK, 0);
|
||||
apr_socket_timeout_set(connection->sock, -1);
|
||||
apr_socket_opt_set(connection->sock, APR_SO_REUSEADDR, 1);
|
||||
|
||||
if(apr_socket_connect(connection->sock,r_sockaddr) != APR_SUCCESS) {
|
||||
apr_socket_close(connection->sock);
|
||||
apr_pool_destroy(pool);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(apr_socket_addr_get(&l_sockaddr,APR_LOCAL,connection->sock) != APR_SUCCESS) {
|
||||
apr_socket_close(connection->sock);
|
||||
apr_pool_destroy(pool);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
apr_sockaddr_ip_get(&local_ip,l_sockaddr);
|
||||
apr_sockaddr_ip_get(&remote_ip,r_sockaddr);
|
||||
connection->id = apr_psprintf(pool,"%s:%hu <-> %s:%hu",
|
||||
local_ip,l_sockaddr->port,
|
||||
remote_ip,r_sockaddr->port);
|
||||
|
||||
memset(&connection->sock_pfd,0,sizeof(apr_pollfd_t));
|
||||
connection->sock_pfd.desc_type = APR_POLL_SOCKET;
|
||||
connection->sock_pfd.reqevents = APR_POLLIN;
|
||||
connection->sock_pfd.desc.s = connection->sock;
|
||||
connection->sock_pfd.client_data = connection;
|
||||
if(apt_pollset_add(task->pollset,&connection->sock_pfd) != TRUE) {
|
||||
apr_socket_close(connection->sock);
|
||||
apr_pool_destroy(pool);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Established TCP Connection %s",connection->id);
|
||||
return connection;
|
||||
}
|
||||
|
||||
/** Close connection */
|
||||
APT_DECLARE(apt_bool_t) apt_net_client_connection_close(apt_net_client_task_t *task, apt_net_client_connection_t *connection)
|
||||
{
|
||||
if(connection->sock) {
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Close TCP Connection %s",connection->id);
|
||||
apt_pollset_remove(task->pollset,&connection->sock_pfd);
|
||||
apr_socket_close(connection->sock);
|
||||
connection->sock = NULL;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/** Close and destroy connection */
|
||||
APT_DECLARE(apt_bool_t) apt_net_client_disconnect(apt_net_client_task_t *task, apt_net_client_connection_t *connection)
|
||||
{
|
||||
apt_net_client_connection_close(task,connection);
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Destroy TCP Connection %s",connection->id);
|
||||
apr_pool_destroy(connection->pool);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/** Create the pollset */
|
||||
static apt_bool_t apt_net_client_task_pollset_create(apt_net_client_task_t *task)
|
||||
{
|
||||
/* create pollset */
|
||||
task->pollset = apt_pollset_create((apr_uint32_t)task->max_connection_count, task->pool);
|
||||
if(!task->pollset) {
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Create Pollset");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/** Destroy the pollset */
|
||||
static void apt_net_client_task_pollset_destroy(apt_net_client_task_t *task)
|
||||
{
|
||||
if(task->pollset) {
|
||||
apt_pollset_destroy(task->pollset);
|
||||
task->pollset = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static apt_bool_t apt_net_client_task_process(apt_net_client_task_t *task)
|
||||
{
|
||||
apt_bool_t status = TRUE;
|
||||
apt_bool_t running = TRUE;
|
||||
apt_task_msg_t *msg;
|
||||
|
||||
do {
|
||||
apr_thread_mutex_lock(task->guard);
|
||||
msg = apt_cyclic_queue_pop(task->msg_queue);
|
||||
apr_thread_mutex_unlock(task->guard);
|
||||
if(msg) {
|
||||
status = apt_task_msg_process(task->base,msg);
|
||||
}
|
||||
else {
|
||||
running = FALSE;
|
||||
}
|
||||
}
|
||||
while(running == TRUE);
|
||||
return status;
|
||||
}
|
||||
|
||||
static apt_bool_t apt_net_client_task_run(apt_task_t *base)
|
||||
{
|
||||
apt_net_client_task_t *task = apt_task_object_get(base);
|
||||
apt_bool_t running = TRUE;
|
||||
apr_status_t status;
|
||||
apr_int32_t num;
|
||||
const apr_pollfd_t *ret_pfd;
|
||||
int i;
|
||||
|
||||
if(!task) {
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Start Network Client Task");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(apt_net_client_task_pollset_create(task) == FALSE) {
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Create Pollset");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* explicitly indicate task is ready to process messages */
|
||||
apt_task_ready(task->base);
|
||||
|
||||
while(running) {
|
||||
status = apt_pollset_poll(task->pollset, -1, &num, &ret_pfd);
|
||||
if(status != APR_SUCCESS) {
|
||||
continue;
|
||||
}
|
||||
for(i = 0; i < num; i++) {
|
||||
if(apt_pollset_is_wakeup(task->pollset,&ret_pfd[i])) {
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Process Control Message");
|
||||
if(apt_net_client_task_process(task) == FALSE) {
|
||||
running = FALSE;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Process Message");
|
||||
task->client_vtable->on_receive(task,ret_pfd[i].client_data);
|
||||
}
|
||||
}
|
||||
|
||||
apt_net_client_task_pollset_destroy(task);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static apt_bool_t apt_net_client_task_msg_signal(apt_task_t *base, apt_task_msg_t *msg)
|
||||
{
|
||||
apt_bool_t status;
|
||||
apt_net_client_task_t *task = apt_task_object_get(base);
|
||||
apr_thread_mutex_lock(task->guard);
|
||||
status = apt_cyclic_queue_push(task->msg_queue,msg);
|
||||
apr_thread_mutex_unlock(task->guard);
|
||||
if(apt_pollset_wakeup(task->pollset) != TRUE) {
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Signal Control Message");
|
||||
status = FALSE;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
@@ -1,393 +0,0 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#include "apt_net_server_task.h"
|
||||
#include "apt_task.h"
|
||||
#include "apt_pool.h"
|
||||
#include "apt_pollset.h"
|
||||
#include "apt_cyclic_queue.h"
|
||||
#include "apt_log.h"
|
||||
|
||||
|
||||
/** Network server task */
|
||||
struct apt_net_server_task_t {
|
||||
apr_pool_t *pool;
|
||||
apt_task_t *base;
|
||||
void *obj;
|
||||
|
||||
apr_size_t max_connection_count;
|
||||
|
||||
apr_thread_mutex_t *guard;
|
||||
apt_cyclic_queue_t *msg_queue;
|
||||
apt_pollset_t *pollset;
|
||||
|
||||
/* Listening socket descriptor */
|
||||
apr_sockaddr_t *sockaddr;
|
||||
apr_socket_t *listen_sock;
|
||||
apr_pollfd_t listen_sock_pfd;
|
||||
|
||||
const apt_net_server_vtable_t *server_vtable;
|
||||
};
|
||||
|
||||
static apt_bool_t apt_net_server_task_msg_signal(apt_task_t *task, apt_task_msg_t *msg);
|
||||
static apt_bool_t apt_net_server_task_run(apt_task_t *task);
|
||||
static apt_bool_t apt_net_server_task_on_destroy(apt_task_t *task);
|
||||
|
||||
/** Create connection task */
|
||||
APT_DECLARE(apt_net_server_task_t*) apt_net_server_task_create(
|
||||
const char *listen_ip,
|
||||
apr_port_t listen_port,
|
||||
apr_size_t max_connection_count,
|
||||
void *obj,
|
||||
const apt_net_server_vtable_t *server_vtable,
|
||||
apt_task_msg_pool_t *msg_pool,
|
||||
apr_pool_t *pool)
|
||||
{
|
||||
apt_task_vtable_t *vtable;
|
||||
apt_net_server_task_t *task;
|
||||
|
||||
task = apr_palloc(pool,sizeof(apt_net_server_task_t));
|
||||
task->pool = pool;
|
||||
task->obj = obj;
|
||||
task->sockaddr = NULL;
|
||||
task->listen_sock = NULL;
|
||||
task->pollset = NULL;
|
||||
task->max_connection_count = max_connection_count;
|
||||
|
||||
apr_sockaddr_info_get(&task->sockaddr,listen_ip,APR_INET,listen_port,0,task->pool);
|
||||
if(!task->sockaddr) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!server_vtable || !server_vtable->on_connect ||
|
||||
!server_vtable->on_disconnect || !server_vtable->on_receive) {
|
||||
return NULL;
|
||||
}
|
||||
task->server_vtable = server_vtable;
|
||||
|
||||
task->base = apt_task_create(task,msg_pool,pool);
|
||||
if(!task->base) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
vtable = apt_task_vtable_get(task->base);
|
||||
if(vtable) {
|
||||
vtable->run = apt_net_server_task_run;
|
||||
vtable->destroy = apt_net_server_task_on_destroy;
|
||||
vtable->signal_msg = apt_net_server_task_msg_signal;
|
||||
}
|
||||
apt_task_auto_ready_set(task->base,FALSE);
|
||||
|
||||
task->msg_queue = apt_cyclic_queue_create(CYCLIC_QUEUE_DEFAULT_SIZE);
|
||||
apr_thread_mutex_create(&task->guard,APR_THREAD_MUTEX_UNNESTED,pool);
|
||||
return task;
|
||||
}
|
||||
|
||||
/** Virtual destroy handler */
|
||||
static apt_bool_t apt_net_server_task_on_destroy(apt_task_t *base)
|
||||
{
|
||||
apt_net_server_task_t *task = apt_task_object_get(base);
|
||||
if(task->guard) {
|
||||
apr_thread_mutex_destroy(task->guard);
|
||||
task->guard = NULL;
|
||||
}
|
||||
if(task->msg_queue) {
|
||||
apt_cyclic_queue_destroy(task->msg_queue);
|
||||
task->msg_queue = NULL;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/** Destroy connection task. */
|
||||
APT_DECLARE(apt_bool_t) apt_net_server_task_destroy(apt_net_server_task_t *task)
|
||||
{
|
||||
return apt_task_destroy(task->base);
|
||||
}
|
||||
|
||||
/** Start connection task. */
|
||||
APT_DECLARE(apt_bool_t) apt_net_server_task_start(apt_net_server_task_t *task)
|
||||
{
|
||||
return apt_task_start(task->base);
|
||||
}
|
||||
|
||||
/** Terminate connection task. */
|
||||
APT_DECLARE(apt_bool_t) apt_net_server_task_terminate(apt_net_server_task_t *task)
|
||||
{
|
||||
return apt_task_terminate(task->base,TRUE);
|
||||
}
|
||||
|
||||
/** Get task */
|
||||
APT_DECLARE(apt_task_t*) apt_net_server_task_base_get(apt_net_server_task_t *task)
|
||||
{
|
||||
return task->base;
|
||||
}
|
||||
|
||||
/** Get task vtable */
|
||||
APT_DECLARE(apt_task_vtable_t*) apt_net_server_task_vtable_get(apt_net_server_task_t *task)
|
||||
{
|
||||
return apt_task_vtable_get(task->base);
|
||||
}
|
||||
|
||||
/** Get external object */
|
||||
APT_DECLARE(void*) apt_net_server_task_object_get(apt_net_server_task_t *task)
|
||||
{
|
||||
return task->obj;
|
||||
}
|
||||
|
||||
|
||||
/** Create listening socket and add to pollset */
|
||||
static apt_bool_t apt_net_server_task_listen_socket_create(apt_net_server_task_t *task)
|
||||
{
|
||||
apr_status_t status;
|
||||
if(!task->sockaddr) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* create listening socket */
|
||||
status = apr_socket_create(&task->listen_sock, task->sockaddr->family, SOCK_STREAM, APR_PROTO_TCP, task->pool);
|
||||
if(status != APR_SUCCESS) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
apr_socket_opt_set(task->listen_sock, APR_SO_NONBLOCK, 0);
|
||||
apr_socket_timeout_set(task->listen_sock, -1);
|
||||
apr_socket_opt_set(task->listen_sock, APR_SO_REUSEADDR, 1);
|
||||
|
||||
status = apr_socket_bind(task->listen_sock, task->sockaddr);
|
||||
if(status != APR_SUCCESS) {
|
||||
apr_socket_close(task->listen_sock);
|
||||
task->listen_sock = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
status = apr_socket_listen(task->listen_sock, SOMAXCONN);
|
||||
if(status != APR_SUCCESS) {
|
||||
apr_socket_close(task->listen_sock);
|
||||
task->listen_sock = NULL;
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
memset(&task->listen_sock_pfd,0,sizeof(apr_pollfd_t));
|
||||
task->listen_sock_pfd.desc_type = APR_POLL_SOCKET;
|
||||
task->listen_sock_pfd.reqevents = APR_POLLIN;
|
||||
task->listen_sock_pfd.desc.s = task->listen_sock;
|
||||
task->listen_sock_pfd.client_data = task->listen_sock;
|
||||
if(apt_pollset_add(task->pollset, &task->listen_sock_pfd) != TRUE) {
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Add Listen Socket to Pollset");
|
||||
apr_socket_close(task->listen_sock);
|
||||
task->listen_sock = NULL;
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/** Remove from pollset and destroy listening socket */
|
||||
static void apt_net_server_task_listen_socket_destroy(apt_net_server_task_t *task)
|
||||
{
|
||||
apt_pollset_remove(task->pollset,&task->listen_sock_pfd);
|
||||
|
||||
if(task->listen_sock) {
|
||||
apr_socket_close(task->listen_sock);
|
||||
task->listen_sock = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/** Create the pollset */
|
||||
static apt_bool_t apt_net_server_task_pollset_create(apt_net_server_task_t *task)
|
||||
{
|
||||
/* create pollset */
|
||||
task->pollset = apt_pollset_create((apr_uint32_t)task->max_connection_count + 1, task->pool);
|
||||
if(!task->pollset) {
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Create Pollset");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* create listening socket */
|
||||
if(apt_net_server_task_listen_socket_create(task) != TRUE) {
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Create Listen Socket");
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/** Destroy the pollset */
|
||||
static void apt_net_server_task_pollset_destroy(apt_net_server_task_t *task)
|
||||
{
|
||||
apt_net_server_task_listen_socket_destroy(task);
|
||||
if(task->pollset) {
|
||||
apt_pollset_destroy(task->pollset);
|
||||
task->pollset = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
static apt_bool_t apt_net_server_task_process(apt_net_server_task_t *task)
|
||||
{
|
||||
apt_bool_t status = TRUE;
|
||||
apt_bool_t running = TRUE;
|
||||
apt_task_msg_t *msg;
|
||||
|
||||
do {
|
||||
apr_thread_mutex_lock(task->guard);
|
||||
msg = apt_cyclic_queue_pop(task->msg_queue);
|
||||
apr_thread_mutex_unlock(task->guard);
|
||||
if(msg) {
|
||||
status = apt_task_msg_process(task->base,msg);
|
||||
}
|
||||
else {
|
||||
running = FALSE;
|
||||
}
|
||||
}
|
||||
while(running == TRUE);
|
||||
return status;
|
||||
}
|
||||
|
||||
static apt_bool_t apt_net_server_task_accept(apt_net_server_task_t *task)
|
||||
{
|
||||
char *local_ip = NULL;
|
||||
char *remote_ip = NULL;
|
||||
apr_sockaddr_t *l_sockaddr = NULL;
|
||||
apr_sockaddr_t *r_sockaddr = NULL;
|
||||
apt_net_server_connection_t *connection;
|
||||
apr_pool_t *pool = apt_pool_create();
|
||||
if(!pool) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
connection = apr_palloc(pool,sizeof(apt_net_server_connection_t));
|
||||
connection->pool = pool;
|
||||
connection->obj = NULL;
|
||||
connection->sock = NULL;
|
||||
connection->client_ip = NULL;
|
||||
|
||||
if(apr_socket_accept(&connection->sock,task->listen_sock,connection->pool) != APR_SUCCESS) {
|
||||
apr_pool_destroy(pool);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(apr_socket_addr_get(&l_sockaddr,APR_LOCAL,connection->sock) != APR_SUCCESS ||
|
||||
apr_socket_addr_get(&r_sockaddr,APR_REMOTE,connection->sock) != APR_SUCCESS) {
|
||||
apr_pool_destroy(pool);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
apr_sockaddr_ip_get(&local_ip,l_sockaddr);
|
||||
apr_sockaddr_ip_get(&remote_ip,r_sockaddr);
|
||||
connection->client_ip = remote_ip;
|
||||
connection->id = apr_psprintf(pool,"%s:%hu <-> %s:%hu",
|
||||
local_ip,l_sockaddr->port,
|
||||
remote_ip,r_sockaddr->port);
|
||||
|
||||
memset(&connection->sock_pfd,0,sizeof(apr_pollfd_t));
|
||||
connection->sock_pfd.desc_type = APR_POLL_SOCKET;
|
||||
connection->sock_pfd.reqevents = APR_POLLIN;
|
||||
connection->sock_pfd.desc.s = connection->sock;
|
||||
connection->sock_pfd.client_data = connection;
|
||||
if(apt_pollset_add(task->pollset,&connection->sock_pfd) != TRUE) {
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Add to Pollset");
|
||||
apr_socket_close(connection->sock);
|
||||
apr_pool_destroy(pool);
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Accepted TCP Connection %s",connection->id);
|
||||
task->server_vtable->on_connect(task,connection);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static apt_bool_t apt_net_server_task_run(apt_task_t *base)
|
||||
{
|
||||
apt_net_server_task_t *task = apt_task_object_get(base);
|
||||
apt_bool_t running = TRUE;
|
||||
apr_status_t status;
|
||||
apr_int32_t num;
|
||||
const apr_pollfd_t *ret_pfd;
|
||||
int i;
|
||||
|
||||
if(!task) {
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Start Network Server Task");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
if(apt_net_server_task_pollset_create(task) == FALSE) {
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Create Pollset");
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* explicitly indicate task is ready to process messages */
|
||||
apt_task_ready(task->base);
|
||||
|
||||
while(running) {
|
||||
status = apt_pollset_poll(task->pollset, -1, &num, &ret_pfd);
|
||||
if(status != APR_SUCCESS) {
|
||||
continue;
|
||||
}
|
||||
for(i = 0; i < num; i++) {
|
||||
if(ret_pfd[i].desc.s == task->listen_sock) {
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Accept Connection");
|
||||
apt_net_server_task_accept(task);
|
||||
continue;
|
||||
}
|
||||
if(apt_pollset_is_wakeup(task->pollset,&ret_pfd[i])) {
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Process Control Message");
|
||||
if(apt_net_server_task_process(task) == FALSE) {
|
||||
running = FALSE;
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Process Message");
|
||||
task->server_vtable->on_receive(task,ret_pfd[i].client_data);
|
||||
}
|
||||
}
|
||||
|
||||
apt_net_server_task_pollset_destroy(task);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static apt_bool_t apt_net_server_task_msg_signal(apt_task_t *base, apt_task_msg_t *msg)
|
||||
{
|
||||
apt_bool_t status;
|
||||
apt_net_server_task_t *task = apt_task_object_get(base);
|
||||
apr_thread_mutex_lock(task->guard);
|
||||
status = apt_cyclic_queue_push(task->msg_queue,msg);
|
||||
apr_thread_mutex_unlock(task->guard);
|
||||
if(apt_pollset_wakeup(task->pollset) != TRUE) {
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Signal Control Message");
|
||||
status = FALSE;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/** Close connection */
|
||||
APT_DECLARE(apt_bool_t) apt_net_server_connection_close(apt_net_server_task_t *task, apt_net_server_connection_t *connection)
|
||||
{
|
||||
if(connection->sock) {
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Close TCP Connection %s",connection->id);
|
||||
apt_pollset_remove(task->pollset,&connection->sock_pfd);
|
||||
apr_socket_close(connection->sock);
|
||||
connection->sock = NULL;
|
||||
task->server_vtable->on_disconnect(task,connection);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/** Destroy connection */
|
||||
APT_DECLARE(void) apt_net_server_connection_destroy(apt_net_server_connection_t *connection)
|
||||
{
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_NOTICE,"Destroy TCP Connection %s",connection->id);
|
||||
apr_pool_destroy(connection->pool);
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,9 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_nlsml_doc.c 1655 2010-04-16 18:36:27Z achaloyan $
|
||||
*/
|
||||
|
||||
#include "apt_nlsml_doc.h"
|
||||
#include "apt_log.h"
|
||||
|
||||
/** Load NLSML document */
|
||||
APT_DECLARE(apr_xml_doc*) nlsml_doc_load(const apt_str_t *data, apr_pool_t *pool)
|
||||
@@ -26,21 +29,25 @@ APT_DECLARE(apr_xml_doc*) nlsml_doc_load(const apt_str_t *data, apr_pool_t *pool
|
||||
/* create XML parser */
|
||||
parser = apr_xml_parser_create(pool);
|
||||
if(apr_xml_parser_feed(parser,data->buf,data->length) != APR_SUCCESS) {
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to feed NLSML input to the parser");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* done with XML tree creation */
|
||||
if(apr_xml_parser_done(parser,&doc) != APR_SUCCESS) {
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to terminate NLSML parsing");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
if(!doc || !doc->root) {
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"No NLSML root element");
|
||||
return NULL;
|
||||
}
|
||||
root = doc->root;
|
||||
|
||||
/* NLSML validity check: root element must be <result> */
|
||||
if(strcmp(root->name,"result") != 0) {
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Unexpected NLSML root element <%s>",root->name);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,6 +12,8 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_obj_list.c 1708 2010-05-24 17:03:25Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
@@ -65,7 +67,7 @@ APT_DECLARE(void*) apt_list_pop_front(apt_obj_list_t *list)
|
||||
return elem->obj;
|
||||
}
|
||||
|
||||
APT_DECLARE(void*) apt_list_head(apt_obj_list_t *list)
|
||||
APT_DECLARE(void*) apt_list_head(const apt_obj_list_t *list)
|
||||
{
|
||||
apt_list_elem_t *elem;
|
||||
if(APR_RING_EMPTY(&list->head,apt_list_elem_t,link)) {
|
||||
@@ -75,7 +77,7 @@ APT_DECLARE(void*) apt_list_head(apt_obj_list_t *list)
|
||||
return elem->obj;
|
||||
}
|
||||
|
||||
APT_DECLARE(void*) apt_obj_list_tail(apt_obj_list_t *list)
|
||||
APT_DECLARE(void*) apt_obj_list_tail(const apt_obj_list_t *list)
|
||||
{
|
||||
apt_list_elem_t *elem;
|
||||
if(APR_RING_EMPTY(&list->head,apt_list_elem_t,link)) {
|
||||
@@ -85,7 +87,7 @@ APT_DECLARE(void*) apt_obj_list_tail(apt_obj_list_t *list)
|
||||
return elem->obj;
|
||||
}
|
||||
|
||||
APT_DECLARE(apt_list_elem_t*) apt_list_first_elem_get(apt_obj_list_t *list)
|
||||
APT_DECLARE(apt_list_elem_t*) apt_list_first_elem_get(const apt_obj_list_t *list)
|
||||
{
|
||||
if(APR_RING_EMPTY(&list->head,apt_list_elem_t,link)) {
|
||||
return NULL;
|
||||
@@ -93,7 +95,7 @@ APT_DECLARE(apt_list_elem_t*) apt_list_first_elem_get(apt_obj_list_t *list)
|
||||
return APR_RING_FIRST(&list->head);
|
||||
}
|
||||
|
||||
APT_DECLARE(apt_list_elem_t*) apt_list_last_elem_get(apt_obj_list_t *list)
|
||||
APT_DECLARE(apt_list_elem_t*) apt_list_last_elem_get(const apt_obj_list_t *list)
|
||||
{
|
||||
if(APR_RING_EMPTY(&list->head,apt_list_elem_t,link)) {
|
||||
return NULL;
|
||||
@@ -101,7 +103,7 @@ APT_DECLARE(apt_list_elem_t*) apt_list_last_elem_get(apt_obj_list_t *list)
|
||||
return APR_RING_LAST(&list->head);
|
||||
}
|
||||
|
||||
APT_DECLARE(apt_list_elem_t*) apt_list_next_elem_get(apt_obj_list_t *list, apt_list_elem_t *elem)
|
||||
APT_DECLARE(apt_list_elem_t*) apt_list_next_elem_get(const apt_obj_list_t *list, apt_list_elem_t *elem)
|
||||
{
|
||||
apt_list_elem_t *next_elem = APR_RING_NEXT(elem,link);
|
||||
if(next_elem == APR_RING_SENTINEL(&list->head,apt_list_elem_t,link)) {
|
||||
@@ -110,7 +112,7 @@ APT_DECLARE(apt_list_elem_t*) apt_list_next_elem_get(apt_obj_list_t *list, apt_l
|
||||
return next_elem;
|
||||
}
|
||||
|
||||
APT_DECLARE(apt_list_elem_t*) apt_list_prev_elem_get(apt_obj_list_t *list, apt_list_elem_t *elem)
|
||||
APT_DECLARE(apt_list_elem_t*) apt_list_prev_elem_get(const apt_obj_list_t *list, apt_list_elem_t *elem)
|
||||
{
|
||||
apt_list_elem_t *prev_elem = APR_RING_PREV(elem,link);
|
||||
if(prev_elem == APR_RING_SENTINEL(&list->head,apt_list_elem_t,link)) {
|
||||
@@ -137,7 +139,7 @@ APT_DECLARE(apt_list_elem_t*) apt_list_elem_remove(apt_obj_list_t *list, apt_lis
|
||||
return next_elem;
|
||||
}
|
||||
|
||||
APT_DECLARE(apt_bool_t) apt_list_is_empty(apt_obj_list_t *list)
|
||||
APT_DECLARE(apt_bool_t) apt_list_is_empty(const apt_obj_list_t *list)
|
||||
{
|
||||
if(APR_RING_EMPTY(&list->head,apt_list_elem_t,link)) {
|
||||
return TRUE;
|
||||
@@ -145,7 +147,7 @@ APT_DECLARE(apt_bool_t) apt_list_is_empty(apt_obj_list_t *list)
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
APT_DECLARE(void*) apt_list_elem_object_get(apt_list_elem_t *elem)
|
||||
APT_DECLARE(void*) apt_list_elem_object_get(const apt_list_elem_t *elem)
|
||||
{
|
||||
return elem->obj;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,6 +12,8 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_pair.c 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#include "apt_pair.h"
|
||||
|
||||
@@ -0,0 +1,271 @@
|
||||
/*
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_poller_task.c 1708 2010-05-24 17:03:25Z achaloyan $
|
||||
*/
|
||||
|
||||
#include "apt_poller_task.h"
|
||||
#include "apt_task.h"
|
||||
#include "apt_pool.h"
|
||||
#include "apt_cyclic_queue.h"
|
||||
#include "apt_log.h"
|
||||
|
||||
|
||||
/** Poller task */
|
||||
struct apt_poller_task_t {
|
||||
apr_pool_t *pool;
|
||||
apt_task_t *base;
|
||||
|
||||
void *obj;
|
||||
apt_poll_signal_f signal_handler;
|
||||
|
||||
apr_thread_mutex_t *guard;
|
||||
apt_cyclic_queue_t *msg_queue;
|
||||
apt_pollset_t *pollset;
|
||||
apt_timer_queue_t *timer_queue;
|
||||
};
|
||||
|
||||
static apt_bool_t apt_poller_task_msg_signal(apt_task_t *task, apt_task_msg_t *msg);
|
||||
static apt_bool_t apt_poller_task_run(apt_task_t *task);
|
||||
static apt_bool_t apt_poller_task_on_destroy(apt_task_t *task);
|
||||
|
||||
|
||||
/** Create poller task */
|
||||
APT_DECLARE(apt_poller_task_t*) apt_poller_task_create(
|
||||
apr_size_t max_pollset_size,
|
||||
apt_poll_signal_f signal_handler,
|
||||
void *obj,
|
||||
apt_task_msg_pool_t *msg_pool,
|
||||
apr_pool_t *pool)
|
||||
{
|
||||
apt_task_vtable_t *vtable;
|
||||
apt_poller_task_t *task;
|
||||
|
||||
if(!signal_handler) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
task = apr_palloc(pool,sizeof(apt_poller_task_t));
|
||||
task->pool = pool;
|
||||
task->obj = obj;
|
||||
task->pollset = NULL;
|
||||
task->signal_handler = signal_handler;
|
||||
|
||||
task->pollset = apt_pollset_create((apr_uint32_t)max_pollset_size,pool);
|
||||
if(!task->pollset) {
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Create Pollset");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
task->base = apt_task_create(task,msg_pool,pool);
|
||||
if(!task->base) {
|
||||
apt_pollset_destroy(task->pollset);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
vtable = apt_task_vtable_get(task->base);
|
||||
if(vtable) {
|
||||
vtable->run = apt_poller_task_run;
|
||||
vtable->destroy = apt_poller_task_on_destroy;
|
||||
vtable->signal_msg = apt_poller_task_msg_signal;
|
||||
}
|
||||
apt_task_auto_ready_set(task->base,FALSE);
|
||||
|
||||
task->msg_queue = apt_cyclic_queue_create(CYCLIC_QUEUE_DEFAULT_SIZE);
|
||||
apr_thread_mutex_create(&task->guard,APR_THREAD_MUTEX_UNNESTED,pool);
|
||||
|
||||
task->timer_queue = apt_timer_queue_create(pool);
|
||||
return task;
|
||||
}
|
||||
|
||||
/** Destroy poller task */
|
||||
APT_DECLARE(apt_bool_t) apt_poller_task_destroy(apt_poller_task_t *task)
|
||||
{
|
||||
return apt_task_destroy(task->base);
|
||||
}
|
||||
|
||||
/** Cleanup poller task */
|
||||
APT_DECLARE(void) apt_poller_task_cleanup(apt_poller_task_t *task)
|
||||
{
|
||||
if(task->pollset) {
|
||||
apt_pollset_destroy(task->pollset);
|
||||
task->pollset = NULL;
|
||||
}
|
||||
if(task->guard) {
|
||||
apr_thread_mutex_destroy(task->guard);
|
||||
task->guard = NULL;
|
||||
}
|
||||
if(task->msg_queue) {
|
||||
apt_cyclic_queue_destroy(task->msg_queue);
|
||||
task->msg_queue = NULL;
|
||||
}
|
||||
}
|
||||
|
||||
/** Virtual destroy handler */
|
||||
static apt_bool_t apt_poller_task_on_destroy(apt_task_t *base)
|
||||
{
|
||||
apt_poller_task_t *task = apt_task_object_get(base);
|
||||
apt_poller_task_cleanup(task);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/** Start poller task */
|
||||
APT_DECLARE(apt_bool_t) apt_poller_task_start(apt_poller_task_t *task)
|
||||
{
|
||||
return apt_task_start(task->base);
|
||||
}
|
||||
|
||||
/** Terminate poller task */
|
||||
APT_DECLARE(apt_bool_t) apt_poller_task_terminate(apt_poller_task_t *task)
|
||||
{
|
||||
return apt_task_terminate(task->base,TRUE);
|
||||
}
|
||||
|
||||
/** Get task */
|
||||
APT_DECLARE(apt_task_t*) apt_poller_task_base_get(const apt_poller_task_t *task)
|
||||
{
|
||||
return task->base;
|
||||
}
|
||||
|
||||
/** Get task vtable */
|
||||
APT_DECLARE(apt_task_vtable_t*) apt_poller_task_vtable_get(apt_poller_task_t *task)
|
||||
{
|
||||
return apt_task_vtable_get(task->base);
|
||||
}
|
||||
|
||||
/** Get external object */
|
||||
APT_DECLARE(void*) apt_poller_task_object_get(const apt_poller_task_t *task)
|
||||
{
|
||||
return task->obj;
|
||||
}
|
||||
|
||||
/** Get pollset */
|
||||
APT_DECLARE(apt_pollset_t*) apt_poller_task_pollset_get(const apt_poller_task_t *task)
|
||||
{
|
||||
return task->pollset;
|
||||
}
|
||||
|
||||
/** Create timer */
|
||||
APT_DECLARE(apt_timer_t*) apt_poller_task_timer_create(
|
||||
apt_poller_task_t *task,
|
||||
apt_timer_proc_f proc,
|
||||
void *obj,
|
||||
apr_pool_t *pool)
|
||||
{
|
||||
return apt_timer_create(task->timer_queue,proc,obj,pool);
|
||||
}
|
||||
|
||||
static apt_bool_t apt_poller_task_wakeup_process(apt_poller_task_t *task)
|
||||
{
|
||||
apt_bool_t running = TRUE;
|
||||
apt_task_msg_t *msg;
|
||||
|
||||
do {
|
||||
apr_thread_mutex_lock(task->guard);
|
||||
msg = apt_cyclic_queue_pop(task->msg_queue);
|
||||
apr_thread_mutex_unlock(task->guard);
|
||||
if(msg) {
|
||||
apt_task_msg_process(task->base,msg);
|
||||
}
|
||||
else {
|
||||
running = FALSE;
|
||||
}
|
||||
}
|
||||
while(running == TRUE);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static apt_bool_t apt_poller_task_run(apt_task_t *base)
|
||||
{
|
||||
apt_poller_task_t *task = apt_task_object_get(base);
|
||||
apt_bool_t *running;
|
||||
apr_status_t status;
|
||||
apr_int32_t num;
|
||||
const apr_pollfd_t *ret_pfd;
|
||||
apr_interval_time_t timeout;
|
||||
apr_uint32_t queue_timeout;
|
||||
apr_time_t time_now, time_last = 0;
|
||||
int i;
|
||||
const char *task_name;
|
||||
|
||||
if(!task) {
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Start Poller Task");
|
||||
return FALSE;
|
||||
}
|
||||
task_name = apt_task_name_get(task->base),
|
||||
|
||||
running = apt_task_running_flag_get(task->base);
|
||||
if(!running) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* explicitly indicate task is ready to process messages */
|
||||
apt_task_ready(task->base);
|
||||
|
||||
while(*running) {
|
||||
if(apt_timer_queue_timeout_get(task->timer_queue,&queue_timeout) == TRUE) {
|
||||
timeout = queue_timeout * 1000;
|
||||
time_last = apr_time_now();
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Wait for Messages [%s] timeout [%u]",
|
||||
task_name, queue_timeout);
|
||||
}
|
||||
else {
|
||||
timeout = -1;
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Wait for Messages [%s]",task_name);
|
||||
}
|
||||
status = apt_pollset_poll(task->pollset, timeout, &num, &ret_pfd);
|
||||
if(status != APR_SUCCESS && status != APR_TIMEUP) {
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Poll [%s] status: %d",task_name,status);
|
||||
continue;
|
||||
}
|
||||
for(i = 0; i < num; i++) {
|
||||
if(apt_pollset_is_wakeup(task->pollset,&ret_pfd[i])) {
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Process Poller Wakeup [%s]",task_name);
|
||||
apt_poller_task_wakeup_process(task);
|
||||
if(*running == FALSE) {
|
||||
break;
|
||||
}
|
||||
continue;
|
||||
}
|
||||
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Process Signalled Descriptor [%s]",task_name);
|
||||
task->signal_handler(task->obj,&ret_pfd[i]);
|
||||
}
|
||||
|
||||
if(timeout != -1) {
|
||||
time_now = apr_time_now();
|
||||
if(time_now > time_last) {
|
||||
apt_timer_queue_advance(task->timer_queue,(apr_uint32_t)((time_now - time_last)/1000));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static apt_bool_t apt_poller_task_msg_signal(apt_task_t *base, apt_task_msg_t *msg)
|
||||
{
|
||||
apt_bool_t status;
|
||||
apt_poller_task_t *task = apt_task_object_get(base);
|
||||
apr_thread_mutex_lock(task->guard);
|
||||
status = apt_cyclic_queue_push(task->msg_queue,msg);
|
||||
apr_thread_mutex_unlock(task->guard);
|
||||
if(apt_pollset_wakeup(task->pollset) != TRUE) {
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_WARNING,"Failed to Signal Control Message");
|
||||
status = FALSE;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,6 +12,8 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_pollset.c 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#include <apr_poll.h>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,6 +12,8 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_pool.c 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#include "apt_pool.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,6 +12,8 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_string_table.c 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#include <ctype.h>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,6 +12,8 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_task.c 1696 2010-05-20 15:44:16Z achaloyan $
|
||||
*/
|
||||
|
||||
#include <apr_thread_proc.h>
|
||||
@@ -23,10 +25,10 @@
|
||||
/** Internal states of the task */
|
||||
typedef enum {
|
||||
TASK_STATE_IDLE, /**< no task activity */
|
||||
TASK_STATE_START_REQUESTED, /**< task start is requested and is in progress */
|
||||
TASK_STATE_START_REQUESTED, /**< start of the task has been requested, but it's not running yet */
|
||||
TASK_STATE_RUNNING, /**< task is running */
|
||||
TASK_STATE_TERMINATE_REQUESTED /**< task termination is requested and is in progress */
|
||||
} apt_task_state_t;
|
||||
TASK_STATE_TERMINATE_REQUESTED /**< termination of the task has been requested, but it's still running */
|
||||
} apt_task_state_e;
|
||||
|
||||
struct apt_task_t {
|
||||
void *obj; /* external object associated with the task */
|
||||
@@ -34,18 +36,22 @@ struct apt_task_t {
|
||||
apt_task_msg_pool_t *msg_pool; /* message pool to allocate task messages from */
|
||||
apr_thread_mutex_t *data_guard; /* mutex to protect task data */
|
||||
apr_thread_t *thread_handle; /* thread handle */
|
||||
apt_task_state_t state; /* current task state */
|
||||
apt_task_state_e state; /* current task state */
|
||||
apt_task_vtable_t vtable; /* table of virtual methods */
|
||||
apt_task_t *parent_task; /* parent (master) task */
|
||||
apt_obj_list_t *child_tasks; /* list of the child (slave) tasks */
|
||||
apr_size_t pending_start; /* number of pending start requests */
|
||||
apr_size_t pending_term; /* number of pending terminate requests */
|
||||
apt_bool_t running; /* task is running (TRUE if even terminate has already been requested) */
|
||||
apt_bool_t auto_ready; /* if TRUE, task is implicitly ready to process messages */
|
||||
const char *name; /* name of the task */
|
||||
};
|
||||
|
||||
static void* APR_THREAD_FUNC apt_task_run(apr_thread_t *thread_handle, void *data);
|
||||
static APR_INLINE void apt_task_vtable_reset(apt_task_vtable_t *vtable);
|
||||
static apt_bool_t apt_task_terminate_request(apt_task_t *task);
|
||||
static void apt_task_start_complete_raise(apt_task_t *task);
|
||||
static void apt_task_terminate_complete_raise(apt_task_t *task);
|
||||
|
||||
|
||||
APT_DECLARE(apt_task_t*) apt_task_create(
|
||||
@@ -98,7 +104,7 @@ APT_DECLARE(apt_bool_t) apt_task_destroy(apt_task_t *task)
|
||||
apt_task_wait_till_complete(task);
|
||||
}
|
||||
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Destroy %s",task->name);
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Destroy Task [%s]",task->name);
|
||||
if(task->vtable.destroy) {
|
||||
task->vtable.destroy(task);
|
||||
}
|
||||
@@ -120,7 +126,7 @@ APT_DECLARE(apt_bool_t) apt_task_start(apt_task_t *task)
|
||||
if(task->state == TASK_STATE_IDLE) {
|
||||
apr_status_t rv;
|
||||
task->state = TASK_STATE_START_REQUESTED;
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Start %s",task->name);
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Start Task [%s]",task->name);
|
||||
if(task->vtable.start) {
|
||||
/* raise virtual start method */
|
||||
task->vtable.start(task);
|
||||
@@ -152,7 +158,7 @@ APT_DECLARE(apt_bool_t) apt_task_terminate(apt_task_t *task, apt_bool_t wait_til
|
||||
|
||||
if(task->state == TASK_STATE_TERMINATE_REQUESTED) {
|
||||
/* raise virtual terminate method */
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Terminate %s",task->name);
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Terminate Task [%s]",task->name);
|
||||
if(task->vtable.terminate) {
|
||||
status = task->vtable.terminate(task);
|
||||
}
|
||||
@@ -180,17 +186,17 @@ APT_DECLARE(void) apt_task_delay(apr_size_t msec)
|
||||
apr_sleep(1000*msec);
|
||||
}
|
||||
|
||||
APT_DECLARE(apt_task_t*) apt_task_parent_get(apt_task_t *task)
|
||||
APT_DECLARE(apt_task_t*) apt_task_parent_get(const apt_task_t *task)
|
||||
{
|
||||
return task->parent_task;
|
||||
}
|
||||
|
||||
APT_DECLARE(apr_pool_t*) apt_task_pool_get(apt_task_t *task)
|
||||
APT_DECLARE(apr_pool_t*) apt_task_pool_get(const apt_task_t *task)
|
||||
{
|
||||
return task->pool;
|
||||
}
|
||||
|
||||
APT_DECLARE(void*) apt_task_object_get(apt_task_t *task)
|
||||
APT_DECLARE(void*) apt_task_object_get(const apt_task_t *task)
|
||||
{
|
||||
return task->obj;
|
||||
}
|
||||
@@ -205,7 +211,7 @@ APT_DECLARE(void) apt_task_name_set(apt_task_t *task, const char *name)
|
||||
task->name = name;
|
||||
}
|
||||
|
||||
APT_DECLARE(const char*) apt_task_name_get(apt_task_t *task)
|
||||
APT_DECLARE(const char*) apt_task_name_get(const apt_task_t *task)
|
||||
{
|
||||
return task->name;
|
||||
}
|
||||
@@ -220,6 +226,8 @@ APT_DECLARE(apt_task_msg_t*) apt_task_msg_get(apt_task_t *task)
|
||||
|
||||
APT_DECLARE(apt_bool_t) apt_task_msg_signal(apt_task_t *task, apt_task_msg_t *msg)
|
||||
{
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Signal Message to [%s] [%d;%d]",
|
||||
task->name, msg->type, msg->sub_type);
|
||||
if(task->vtable.signal_msg) {
|
||||
return task->vtable.signal_msg(task,msg);
|
||||
}
|
||||
@@ -238,74 +246,48 @@ APT_DECLARE(apt_bool_t) apt_task_msg_parent_signal(apt_task_t *task, apt_task_ms
|
||||
}
|
||||
|
||||
|
||||
APT_DECLARE(apt_bool_t) apt_core_task_msg_process(apt_task_t *task, apt_task_msg_t *msg)
|
||||
static apt_bool_t apt_core_task_msg_process(apt_task_t *task, apt_task_msg_t *msg)
|
||||
{
|
||||
apt_bool_t running = TRUE;
|
||||
switch(msg->sub_type) {
|
||||
case CORE_TASK_MSG_START_COMPLETE:
|
||||
case CORE_TASK_MSG_START_COMPLETE:
|
||||
{
|
||||
if(!task->pending_start) {
|
||||
/* error case, no pending start */
|
||||
break;
|
||||
}
|
||||
task->pending_start--;
|
||||
if(!task->pending_start) {
|
||||
if(task->vtable.on_start_complete) {
|
||||
task->vtable.on_start_complete(task);
|
||||
}
|
||||
if(task->parent_task) {
|
||||
/* signal start-complete message */
|
||||
apt_task_msg_signal(task->parent_task,msg);
|
||||
}
|
||||
}
|
||||
apt_task_start_request_remove(task);
|
||||
break;
|
||||
}
|
||||
case CORE_TASK_MSG_TERMINATE_REQUEST:
|
||||
{
|
||||
apt_task_child_terminate(task);
|
||||
if(!task->pending_term) {
|
||||
running = FALSE;
|
||||
task->running = FALSE;
|
||||
}
|
||||
break;
|
||||
}
|
||||
case CORE_TASK_MSG_TERMINATE_COMPLETE:
|
||||
{
|
||||
if(!task->pending_term) {
|
||||
/* error case, no pending terminate */
|
||||
break;
|
||||
}
|
||||
task->pending_term--;
|
||||
if(!task->pending_term) {
|
||||
if(task->vtable.on_terminate_complete) {
|
||||
task->vtable.on_terminate_complete(task);
|
||||
}
|
||||
if(task->parent_task) {
|
||||
/* signal terminate-complete message */
|
||||
apt_task_msg_signal(task->parent_task,msg);
|
||||
}
|
||||
running = FALSE;
|
||||
}
|
||||
apt_task_terminate_request_remove(task);
|
||||
break;
|
||||
}
|
||||
default: break;
|
||||
}
|
||||
return running;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
APT_DECLARE(apt_bool_t) apt_task_msg_process(apt_task_t *task, apt_task_msg_t *msg)
|
||||
{
|
||||
apt_bool_t running = TRUE;
|
||||
apt_bool_t status = FALSE;
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Process Message [%s] [%d;%d]",
|
||||
task->name, msg->type, msg->sub_type);
|
||||
if(msg->type == TASK_MSG_CORE) {
|
||||
running = apt_core_task_msg_process(task,msg);
|
||||
status = apt_core_task_msg_process(task,msg);
|
||||
}
|
||||
else {
|
||||
if(task->vtable.process_msg) {
|
||||
task->vtable.process_msg(task,msg);
|
||||
status = task->vtable.process_msg(task,msg);
|
||||
}
|
||||
}
|
||||
|
||||
apt_task_msg_release(msg);
|
||||
return running;
|
||||
return status;
|
||||
}
|
||||
|
||||
static apt_bool_t apt_task_terminate_request(apt_task_t *task)
|
||||
@@ -325,6 +307,9 @@ APT_DECLARE(apt_bool_t) apt_task_child_start(apt_task_t *task)
|
||||
apt_task_t *child_task = NULL;
|
||||
apt_list_elem_t *elem = apt_list_first_elem_get(task->child_tasks);
|
||||
task->pending_start = 0;
|
||||
if(task->vtable.on_start_request) {
|
||||
task->vtable.on_start_request(task);
|
||||
}
|
||||
/* walk through the list of the child tasks and start them */
|
||||
while(elem) {
|
||||
child_task = apt_list_elem_object_get(elem);
|
||||
@@ -338,18 +323,7 @@ APT_DECLARE(apt_bool_t) apt_task_child_start(apt_task_t *task)
|
||||
|
||||
if(!task->pending_start) {
|
||||
/* no child task to start, just raise start-complete event */
|
||||
if(task->vtable.on_start_complete) {
|
||||
task->vtable.on_start_complete(task);
|
||||
}
|
||||
if(task->parent_task) {
|
||||
if(task->msg_pool) {
|
||||
apt_task_msg_t *msg = apt_task_msg_acquire(task->msg_pool);
|
||||
/* signal start-complete message */
|
||||
msg->type = TASK_MSG_CORE;
|
||||
msg->sub_type = CORE_TASK_MSG_START_COMPLETE;
|
||||
apt_task_msg_signal(task->parent_task,msg);
|
||||
}
|
||||
}
|
||||
apt_task_start_complete_raise(task);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@@ -359,6 +333,9 @@ APT_DECLARE(apt_bool_t) apt_task_child_terminate(apt_task_t *task)
|
||||
apt_task_t *child_task = NULL;
|
||||
apt_list_elem_t *elem = apt_list_first_elem_get(task->child_tasks);
|
||||
task->pending_term = 0;
|
||||
if(task->vtable.on_terminate_request) {
|
||||
task->vtable.on_terminate_request(task);
|
||||
}
|
||||
/* walk through the list of the child tasks and terminate them */
|
||||
while(elem) {
|
||||
child_task = apt_list_elem_object_get(elem);
|
||||
@@ -380,20 +357,7 @@ APT_DECLARE(apt_bool_t) apt_task_child_terminate(apt_task_t *task)
|
||||
|
||||
if(!task->pending_term) {
|
||||
/* no child task to terminate, just raise terminate-complete event */
|
||||
if(task->vtable.on_terminate_complete) {
|
||||
task->vtable.on_terminate_complete(task);
|
||||
}
|
||||
#ifdef ENABLE_SIMULT_TASK_TERMINATION
|
||||
if(task->parent_task) {
|
||||
if(task->msg_pool) {
|
||||
apt_task_msg_t *msg = apt_task_msg_acquire(task->msg_pool);
|
||||
/* signal terminate-complete message */
|
||||
msg->type = TASK_MSG_CORE;
|
||||
msg->sub_type = CORE_TASK_MSG_TERMINATE_COMPLETE;
|
||||
apt_task_msg_signal(task->parent_task,msg);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
apt_task_terminate_complete_raise(task);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
@@ -414,6 +378,85 @@ APT_DECLARE(apt_bool_t) apt_task_ready(apt_task_t *task)
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
APT_DECLARE(apt_bool_t*) apt_task_running_flag_get(apt_task_t *task)
|
||||
{
|
||||
return &task->running;
|
||||
}
|
||||
|
||||
APT_DECLARE(apt_bool_t) apt_task_start_request_add(apt_task_t *task)
|
||||
{
|
||||
task->pending_start++;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
APT_DECLARE(apt_bool_t) apt_task_start_request_remove(apt_task_t *task)
|
||||
{
|
||||
if(!task->pending_start) {
|
||||
/* error case, no pending start */
|
||||
return FALSE;
|
||||
}
|
||||
task->pending_start--;
|
||||
if(!task->pending_start) {
|
||||
apt_task_start_complete_raise(task);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
APT_DECLARE(apt_bool_t) apt_task_terminate_request_add(apt_task_t *task)
|
||||
{
|
||||
task->pending_term++;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
APT_DECLARE(apt_bool_t) apt_task_terminate_request_remove(apt_task_t *task)
|
||||
{
|
||||
if(!task->pending_term) {
|
||||
/* error case, no pending terminate */
|
||||
return FALSE;
|
||||
}
|
||||
task->pending_term--;
|
||||
if(!task->pending_term) {
|
||||
apt_task_terminate_complete_raise(task);
|
||||
task->running = FALSE;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void apt_task_start_complete_raise(apt_task_t *task)
|
||||
{
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Task Started [%s]",task->name);
|
||||
if(task->vtable.on_start_complete) {
|
||||
task->vtable.on_start_complete(task);
|
||||
}
|
||||
if(task->parent_task) {
|
||||
if(task->msg_pool) {
|
||||
apt_task_msg_t *msg = apt_task_msg_acquire(task->msg_pool);
|
||||
/* signal start-complete message */
|
||||
msg->type = TASK_MSG_CORE;
|
||||
msg->sub_type = CORE_TASK_MSG_START_COMPLETE;
|
||||
apt_task_msg_signal(task->parent_task,msg);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void apt_task_terminate_complete_raise(apt_task_t *task)
|
||||
{
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Task Terminated [%s]",task->name);
|
||||
if(task->vtable.on_terminate_complete) {
|
||||
task->vtable.on_terminate_complete(task);
|
||||
}
|
||||
#ifdef ENABLE_SIMULT_TASK_TERMINATION
|
||||
if(task->parent_task) {
|
||||
if(task->msg_pool) {
|
||||
apt_task_msg_t *msg = apt_task_msg_acquire(task->msg_pool);
|
||||
/* signal terminate-complete message */
|
||||
msg->type = TASK_MSG_CORE;
|
||||
msg->sub_type = CORE_TASK_MSG_TERMINATE_COMPLETE;
|
||||
apt_task_msg_signal(task->parent_task,msg);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
static void* APR_THREAD_FUNC apt_task_run(apr_thread_t *thread_handle, void *data)
|
||||
{
|
||||
@@ -425,6 +468,7 @@ static void* APR_THREAD_FUNC apt_task_run(apr_thread_t *thread_handle, void *dat
|
||||
}
|
||||
apr_thread_mutex_lock(task->data_guard);
|
||||
task->state = TASK_STATE_RUNNING;
|
||||
task->running = TRUE;
|
||||
apr_thread_mutex_unlock(task->data_guard);
|
||||
|
||||
if(task->auto_ready == TRUE) {
|
||||
@@ -439,6 +483,7 @@ static void* APR_THREAD_FUNC apt_task_run(apr_thread_t *thread_handle, void *dat
|
||||
|
||||
apr_thread_mutex_lock(task->data_guard);
|
||||
task->state = TASK_STATE_IDLE;
|
||||
task->running = FALSE;
|
||||
apr_thread_mutex_unlock(task->data_guard);
|
||||
/* raise post-run event */
|
||||
if(task->vtable.on_post_run) {
|
||||
@@ -448,3 +493,19 @@ static void* APR_THREAD_FUNC apt_task_run(apr_thread_t *thread_handle, void *dat
|
||||
apr_thread_exit(thread_handle,APR_SUCCESS);
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static APR_INLINE void apt_task_vtable_reset(apt_task_vtable_t *vtable)
|
||||
{
|
||||
vtable->destroy = NULL;
|
||||
vtable->start = NULL;
|
||||
vtable->terminate = NULL;
|
||||
vtable->run = NULL;
|
||||
vtable->signal_msg = NULL;
|
||||
vtable->process_msg = NULL;
|
||||
vtable->on_pre_run = NULL;
|
||||
vtable->on_post_run = NULL;
|
||||
vtable->on_start_request = NULL;
|
||||
vtable->on_start_complete = NULL;
|
||||
vtable->on_terminate_request = NULL;
|
||||
vtable->on_terminate_complete = NULL;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,6 +12,8 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_task_msg.c 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,6 +12,8 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_test_suite.c 1708 2010-05-24 17:03:25Z achaloyan $
|
||||
*/
|
||||
|
||||
#include "apt_pool.h"
|
||||
@@ -61,7 +63,7 @@ APT_DECLARE(apt_bool_t) apt_test_framework_suite_add(apt_test_framework_t *frame
|
||||
return (apt_list_push_back(framework->suites,suite,suite->pool) ? TRUE : FALSE);
|
||||
}
|
||||
|
||||
APT_DECLARE(apr_pool_t*) apt_test_framework_pool_get(apt_test_framework_t *framework)
|
||||
APT_DECLARE(apr_pool_t*) apt_test_framework_pool_get(const apt_test_framework_t *framework)
|
||||
{
|
||||
return framework->pool;
|
||||
}
|
||||
|
||||
@@ -0,0 +1,448 @@
|
||||
/*
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_text_message.c 1671 2010-04-28 19:50:29Z achaloyan $
|
||||
*/
|
||||
|
||||
#include "apt_text_message.h"
|
||||
#include "apt_log.h"
|
||||
|
||||
/** Stage of text message processing (parsing/generation) */
|
||||
typedef enum {
|
||||
APT_MESSAGE_STAGE_START_LINE,
|
||||
APT_MESSAGE_STAGE_HEADER,
|
||||
APT_MESSAGE_STAGE_BODY
|
||||
} apt_message_stage_e;
|
||||
|
||||
|
||||
/** Text message parser */
|
||||
struct apt_message_parser_t {
|
||||
const apt_message_parser_vtable_t *vtable;
|
||||
void *obj;
|
||||
apr_pool_t *pool;
|
||||
apt_message_context_t context;
|
||||
apr_size_t content_length;
|
||||
apt_message_stage_e stage;
|
||||
apt_bool_t skip_lf;
|
||||
apt_bool_t verbose;
|
||||
};
|
||||
|
||||
/** Text message generator */
|
||||
struct apt_message_generator_t {
|
||||
const apt_message_generator_vtable_t *vtable;
|
||||
void *obj;
|
||||
apr_pool_t *pool;
|
||||
apt_message_context_t context;
|
||||
apr_size_t content_length;
|
||||
apt_message_stage_e stage;
|
||||
apt_bool_t verbose;
|
||||
};
|
||||
|
||||
/** Parse individual header field (name-value pair) */
|
||||
APT_DECLARE(apt_header_field_t*) apt_header_field_parse(apt_text_stream_t *stream, apr_pool_t *pool)
|
||||
{
|
||||
apr_size_t folding_length = 0;
|
||||
apr_array_header_t *folded_lines = NULL;
|
||||
apt_header_field_t *header_field;
|
||||
apt_str_t *line;
|
||||
apt_pair_t pair;
|
||||
/* read name-value pair */
|
||||
if(apt_text_header_read(stream,&pair) == FALSE) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
/* check folding lines (value spanning multiple lines) */
|
||||
while(stream->pos < stream->end) {
|
||||
if(apt_text_is_wsp(*stream->pos) == FALSE) {
|
||||
break;
|
||||
}
|
||||
|
||||
stream->pos++;
|
||||
|
||||
/* skip further white spaces (if any) */
|
||||
apt_text_white_spaces_skip(stream);
|
||||
|
||||
if(!folded_lines) {
|
||||
folded_lines = apr_array_make(pool,1,sizeof(apt_str_t));
|
||||
}
|
||||
line = apr_array_push(folded_lines);
|
||||
apt_text_line_read(stream,line);
|
||||
folding_length += line->length;
|
||||
};
|
||||
|
||||
header_field = apt_header_field_alloc(pool);
|
||||
/* copy parsed name of the header field */
|
||||
header_field->name.length = pair.name.length;
|
||||
header_field->name.buf = apr_palloc(pool, pair.name.length + 1);
|
||||
if(pair.name.length) {
|
||||
memcpy(header_field->name.buf, pair.name.buf, pair.name.length);
|
||||
}
|
||||
header_field->name.buf[header_field->name.length] = '\0';
|
||||
|
||||
/* copy parsed value of the header field */
|
||||
header_field->value.length = pair.value.length + folding_length;
|
||||
header_field->value.buf = apr_palloc(pool, header_field->value.length + 1);
|
||||
if(pair.value.length) {
|
||||
memcpy(header_field->value.buf, pair.value.buf, pair.value.length);
|
||||
}
|
||||
|
||||
if(folding_length) {
|
||||
int i;
|
||||
char *pos = header_field->value.buf + pair.value.length;
|
||||
/* copy parsed folding lines */
|
||||
for(i=0; i<folded_lines->nelts; i++) {
|
||||
line = &APR_ARRAY_IDX(folded_lines,i,apt_str_t);
|
||||
|
||||
memcpy(pos,line->buf,line->length);
|
||||
pos += line->length;
|
||||
}
|
||||
}
|
||||
header_field->value.buf[header_field->value.length] = '\0';
|
||||
|
||||
return header_field;
|
||||
}
|
||||
|
||||
/** Generate individual header field (name-value pair) */
|
||||
APT_DECLARE(apt_bool_t) apt_header_field_generate(const apt_header_field_t *header_field, apt_text_stream_t *stream)
|
||||
{
|
||||
return apt_text_name_value_insert(stream,&header_field->name,&header_field->value);
|
||||
}
|
||||
|
||||
/** Parse header section */
|
||||
APT_DECLARE(apt_bool_t) apt_header_section_parse(apt_header_section_t *header, apt_text_stream_t *stream, apr_pool_t *pool)
|
||||
{
|
||||
apt_header_field_t *header_field;
|
||||
apt_bool_t result = FALSE;
|
||||
|
||||
do {
|
||||
header_field = apt_header_field_parse(stream,pool);
|
||||
if(header_field) {
|
||||
if(apt_string_is_empty(&header_field->name) == FALSE) {
|
||||
/* normal header */
|
||||
apt_header_section_field_add(header,header_field);
|
||||
}
|
||||
else {
|
||||
/* empty header => exit */
|
||||
result = TRUE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else {
|
||||
/* malformed header => skip to the next one */
|
||||
}
|
||||
}
|
||||
while(apt_text_is_eos(stream) == FALSE);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/** Generate header section */
|
||||
APT_DECLARE(apt_bool_t) apt_header_section_generate(const apt_header_section_t *header, apt_text_stream_t *stream)
|
||||
{
|
||||
apt_header_field_t *header_field;
|
||||
for(header_field = APR_RING_FIRST(&header->ring);
|
||||
header_field != APR_RING_SENTINEL(&header->ring, apt_header_field_t, link);
|
||||
header_field = APR_RING_NEXT(header_field, link)) {
|
||||
apt_header_field_generate(header_field,stream);
|
||||
}
|
||||
|
||||
return apt_text_eol_insert(stream);
|
||||
}
|
||||
|
||||
static apt_bool_t apt_message_body_read(apt_message_parser_t *parser, apt_text_stream_t *stream)
|
||||
{
|
||||
apt_bool_t status = TRUE;
|
||||
apt_str_t *body = parser->context.body;
|
||||
if(body->buf) {
|
||||
/* stream length available to read */
|
||||
apr_size_t stream_length = stream->text.length - (stream->pos - stream->text.buf);
|
||||
/* required/remaining length to read */
|
||||
apr_size_t required_length = parser->content_length - body->length;
|
||||
if(required_length > stream_length) {
|
||||
required_length = stream_length;
|
||||
/* incomplete */
|
||||
status = FALSE;
|
||||
}
|
||||
memcpy(body->buf + body->length, stream->pos, required_length);
|
||||
body->length += required_length;
|
||||
stream->pos += required_length;
|
||||
if(parser->verbose == TRUE) {
|
||||
apr_size_t length = required_length;
|
||||
const char *masked_data = apt_log_data_mask(stream->pos,&length,parser->pool);
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Parsed Message Body [%"APR_SIZE_T_FMT" bytes]\n%.*s",
|
||||
required_length, length, masked_data);
|
||||
}
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
static apt_bool_t apt_message_body_write(apt_message_generator_t *generator, apt_text_stream_t *stream)
|
||||
{
|
||||
apt_bool_t status = TRUE;
|
||||
apt_str_t *body = generator->context.body;
|
||||
if(body && body->length < generator->content_length) {
|
||||
/* stream length available to write */
|
||||
apr_size_t stream_length = stream->text.length - (stream->pos - stream->text.buf);
|
||||
/* required/remaining length to write */
|
||||
apr_size_t required_length = generator->content_length - body->length;
|
||||
if(required_length > stream_length) {
|
||||
required_length = stream_length;
|
||||
/* incomplete */
|
||||
status = FALSE;
|
||||
}
|
||||
|
||||
memcpy(stream->pos, body->buf + body->length, required_length);
|
||||
|
||||
if(generator->verbose == TRUE) {
|
||||
apr_size_t length = required_length;
|
||||
const char *masked_data = apt_log_data_mask(stream->pos,&length,generator->pool);
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Generated Message Body [%"APR_SIZE_T_FMT" bytes]\n%.*s",
|
||||
required_length, length, masked_data);
|
||||
}
|
||||
|
||||
body->length += required_length;
|
||||
stream->pos += required_length;
|
||||
}
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
|
||||
/** Create message parser */
|
||||
APT_DECLARE(apt_message_parser_t*) apt_message_parser_create(void *obj, const apt_message_parser_vtable_t *vtable, apr_pool_t *pool)
|
||||
{
|
||||
apt_message_parser_t *parser = apr_palloc(pool,sizeof(apt_message_parser_t));
|
||||
parser->obj = obj;
|
||||
parser->vtable = vtable;
|
||||
parser->pool = pool;
|
||||
parser->context.message = NULL;
|
||||
parser->context.body = NULL;
|
||||
parser->context.header = NULL;
|
||||
parser->content_length = 0;
|
||||
parser->stage = APT_MESSAGE_STAGE_START_LINE;
|
||||
parser->skip_lf = FALSE;
|
||||
parser->verbose = FALSE;
|
||||
return parser;
|
||||
}
|
||||
|
||||
static APR_INLINE void apt_crlf_segmentation_test(apt_message_parser_t *parser, apt_text_stream_t *stream)
|
||||
{
|
||||
/* in the worst case message segmentation may occur between <CR> and <LF> */
|
||||
if(stream->pos == stream->end && *(stream->pos-1)== APT_TOKEN_CR) {
|
||||
/* if this is the case be prepared to skip <LF> with the next attempt */
|
||||
parser->skip_lf = TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/** Parse message by raising corresponding event handlers */
|
||||
APT_DECLARE(apt_message_status_e) apt_message_parser_run(apt_message_parser_t *parser, apt_text_stream_t *stream, void **message)
|
||||
{
|
||||
const char *pos;
|
||||
apt_message_status_e status = APT_MESSAGE_STATUS_INCOMPLETE;
|
||||
if(parser->skip_lf == TRUE) {
|
||||
/* skip <LF> occurred as a result of message segmentation between <CR> and <LF> */
|
||||
apt_text_char_skip(stream,APT_TOKEN_LF);
|
||||
parser->skip_lf = FALSE;
|
||||
}
|
||||
if(message) {
|
||||
*message = NULL;
|
||||
}
|
||||
|
||||
do {
|
||||
pos = stream->pos;
|
||||
if(parser->stage == APT_MESSAGE_STAGE_START_LINE) {
|
||||
if(parser->vtable->on_start(parser,&parser->context,stream,parser->pool) == FALSE) {
|
||||
if(apt_text_is_eos(stream) == FALSE) {
|
||||
status = APT_MESSAGE_STATUS_INVALID;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
apt_crlf_segmentation_test(parser,stream);
|
||||
|
||||
parser->stage = APT_MESSAGE_STAGE_HEADER;
|
||||
}
|
||||
|
||||
if(parser->stage == APT_MESSAGE_STAGE_HEADER) {
|
||||
/* read header section */
|
||||
apt_bool_t res = apt_header_section_parse(parser->context.header,stream,parser->pool);
|
||||
if(parser->verbose == TRUE) {
|
||||
apr_size_t length = stream->pos - pos;
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Parsed Message Header [%"APR_SIZE_T_FMT" bytes]\n%.*s",
|
||||
length, length, pos);
|
||||
}
|
||||
|
||||
apt_crlf_segmentation_test(parser,stream);
|
||||
|
||||
if(res == FALSE) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(parser->vtable->on_header_complete) {
|
||||
if(parser->vtable->on_header_complete(parser,&parser->context) == FALSE) {
|
||||
status = APT_MESSAGE_STATUS_INVALID;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(parser->context.body && parser->context.body->length) {
|
||||
apt_str_t *body = parser->context.body;
|
||||
parser->content_length = body->length;
|
||||
body->buf = apr_palloc(parser->pool,parser->content_length+1);
|
||||
body->buf[parser->content_length] = '\0';
|
||||
body->length = 0;
|
||||
parser->stage = APT_MESSAGE_STAGE_BODY;
|
||||
}
|
||||
else {
|
||||
status = APT_MESSAGE_STATUS_COMPLETE;
|
||||
if(message) {
|
||||
*message = parser->context.message;
|
||||
}
|
||||
parser->stage = APT_MESSAGE_STAGE_START_LINE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if(parser->stage == APT_MESSAGE_STAGE_BODY) {
|
||||
if(apt_message_body_read(parser,stream) == FALSE) {
|
||||
break;
|
||||
}
|
||||
|
||||
if(parser->vtable->on_body_complete) {
|
||||
parser->vtable->on_body_complete(parser,&parser->context);
|
||||
}
|
||||
status = APT_MESSAGE_STATUS_COMPLETE;
|
||||
if(message) {
|
||||
*message = parser->context.message;
|
||||
}
|
||||
parser->stage = APT_MESSAGE_STAGE_START_LINE;
|
||||
break;
|
||||
}
|
||||
}
|
||||
while(apt_text_is_eos(stream) == FALSE);
|
||||
|
||||
return status;
|
||||
}
|
||||
|
||||
/** Get external object associated with parser */
|
||||
APT_DECLARE(void*) apt_message_parser_object_get(apt_message_parser_t *parser)
|
||||
{
|
||||
return parser->obj;
|
||||
}
|
||||
|
||||
/** Set verbose mode for the parser */
|
||||
APT_DECLARE(void) apt_message_parser_verbose_set(apt_message_parser_t *parser, apt_bool_t verbose)
|
||||
{
|
||||
parser->verbose = verbose;
|
||||
}
|
||||
|
||||
|
||||
/** Create message generator */
|
||||
APT_DECLARE(apt_message_generator_t*) apt_message_generator_create(void *obj, const apt_message_generator_vtable_t *vtable, apr_pool_t *pool)
|
||||
{
|
||||
apt_message_generator_t *generator = apr_palloc(pool,sizeof(apt_message_generator_t));
|
||||
generator->obj = obj;
|
||||
generator->vtable = vtable;
|
||||
generator->pool = pool;
|
||||
generator->context.message = NULL;
|
||||
generator->context.header = NULL;
|
||||
generator->context.body = NULL;
|
||||
generator->content_length = 0;
|
||||
generator->stage = APT_MESSAGE_STAGE_START_LINE;
|
||||
generator->verbose = FALSE;
|
||||
return generator;
|
||||
}
|
||||
|
||||
static apt_message_status_e apt_message_generator_break(apt_message_generator_t *generator, apt_text_stream_t *stream)
|
||||
{
|
||||
/* failed to generate message */
|
||||
if(apt_text_is_eos(stream) == TRUE) {
|
||||
/* end of stream reached */
|
||||
return APT_MESSAGE_STATUS_INCOMPLETE;
|
||||
}
|
||||
|
||||
/* error case */
|
||||
return APT_MESSAGE_STATUS_INVALID;
|
||||
}
|
||||
|
||||
/** Generate message */
|
||||
APT_DECLARE(apt_message_status_e) apt_message_generator_run(apt_message_generator_t *generator, void *message, apt_text_stream_t *stream)
|
||||
{
|
||||
if(!message) {
|
||||
return APT_MESSAGE_STATUS_INVALID;
|
||||
}
|
||||
|
||||
if(message != generator->context.message) {
|
||||
generator->stage = APT_MESSAGE_STAGE_START_LINE;
|
||||
generator->context.message = message;
|
||||
generator->context.header = NULL;
|
||||
generator->context.body = NULL;
|
||||
}
|
||||
|
||||
if(generator->stage == APT_MESSAGE_STAGE_START_LINE) {
|
||||
/* generate start-line */
|
||||
if(generator->vtable->on_start(generator,&generator->context,stream) == FALSE) {
|
||||
return apt_message_generator_break(generator,stream);
|
||||
}
|
||||
|
||||
if(!generator->context.header || !generator->context.body) {
|
||||
return APT_MESSAGE_STATUS_INVALID;
|
||||
}
|
||||
|
||||
/* generate header */
|
||||
if(apt_header_section_generate(generator->context.header,stream) == FALSE) {
|
||||
return apt_message_generator_break(generator,stream);
|
||||
}
|
||||
|
||||
if(generator->vtable->on_header_complete) {
|
||||
generator->vtable->on_header_complete(generator,&generator->context,stream);
|
||||
}
|
||||
if(generator->verbose == TRUE) {
|
||||
apr_size_t length = stream->pos - stream->text.buf;
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Generated Message Header [%"APR_SIZE_T_FMT" bytes]\n%.*s",
|
||||
length, length, stream->text.buf);
|
||||
}
|
||||
|
||||
generator->stage = APT_MESSAGE_STAGE_START_LINE;
|
||||
generator->content_length = generator->context.body->length;
|
||||
if(generator->content_length) {
|
||||
generator->context.body->length = 0;
|
||||
generator->stage = APT_MESSAGE_STAGE_BODY;
|
||||
}
|
||||
}
|
||||
|
||||
if(generator->stage == APT_MESSAGE_STAGE_BODY) {
|
||||
if(apt_message_body_write(generator,stream) == FALSE) {
|
||||
return apt_message_generator_break(generator,stream);
|
||||
}
|
||||
|
||||
generator->stage = APT_MESSAGE_STAGE_START_LINE;
|
||||
}
|
||||
|
||||
return APT_MESSAGE_STATUS_COMPLETE;
|
||||
}
|
||||
|
||||
/** Get external object associated with generator */
|
||||
APT_DECLARE(void*) apt_message_generator_object_get(apt_message_generator_t *generator)
|
||||
{
|
||||
return generator->obj;
|
||||
}
|
||||
|
||||
/** Set verbose mode for the parser */
|
||||
APT_DECLARE(void) apt_message_generator_verbose_set(apt_message_generator_t *generator, apt_bool_t verbose)
|
||||
{
|
||||
generator->verbose = verbose;
|
||||
}
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,6 +12,8 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_text_stream.c 1793 2011-01-10 21:46:14Z achaloyan $
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
@@ -61,19 +63,20 @@ APT_DECLARE(apt_bool_t) apt_text_line_read(apt_text_stream_t *stream, apt_str_t
|
||||
else {
|
||||
/* end of stream is reached, do not advance stream pos, but set is_eos flag */
|
||||
stream->is_eos = TRUE;
|
||||
line->length = pos - line->buf;
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/** Navigate through the headers (name:value pairs) of the text stream (message)
|
||||
Valid headers are:
|
||||
/** To be used to navigate through the header fields (name:value pairs) of the text stream (message)
|
||||
Valid header fields are:
|
||||
name:value<CRLF>
|
||||
name: value<CRLF>
|
||||
name: value<CRLF>
|
||||
name: value<LF>
|
||||
name:<CRLF> (only name, no value)
|
||||
<CRLF> (empty header)
|
||||
Malformed headers are:
|
||||
Malformed header fields are:
|
||||
name:value (missing end of line <CRLF>)
|
||||
name<CRLF> (missing separator ':')
|
||||
*/
|
||||
@@ -109,8 +112,8 @@ APT_DECLARE(apt_bool_t) apt_text_header_read(apt_text_stream_t *stream, apt_pair
|
||||
break;
|
||||
}
|
||||
else if(!pair->name.length) {
|
||||
/* skip initial spaces and read name */
|
||||
if(!pair->name.buf && *pos != APT_TOKEN_SP) {
|
||||
/* skip preceding white spaces (SHOULD NOT be any WSP, though) and read name */
|
||||
if(!pair->name.buf && apt_text_is_wsp(*pos) == FALSE) {
|
||||
pair->name.buf = pos;
|
||||
}
|
||||
if(*pos == ':') {
|
||||
@@ -119,8 +122,8 @@ APT_DECLARE(apt_bool_t) apt_text_header_read(apt_text_stream_t *stream, apt_pair
|
||||
}
|
||||
}
|
||||
else if(!pair->value.length) {
|
||||
/* skip initial spaces and read value */
|
||||
if(!pair->value.buf && *pos != APT_TOKEN_SP) {
|
||||
/* skip preceding white spaces and read value */
|
||||
if(!pair->value.buf && apt_text_is_wsp(*pos) == FALSE) {
|
||||
pair->value.buf = pos;
|
||||
}
|
||||
}
|
||||
@@ -170,14 +173,19 @@ APT_DECLARE(apt_bool_t) apt_text_field_read(apt_text_stream_t *stream, char sepa
|
||||
/** Scroll text stream */
|
||||
APT_DECLARE(apt_bool_t) apt_text_stream_scroll(apt_text_stream_t *stream)
|
||||
{
|
||||
apr_size_t remaining_length = stream->text.buf + stream->text.length - stream->pos;
|
||||
if(!remaining_length || remaining_length == stream->text.length) {
|
||||
if(stream->pos == stream->end) {
|
||||
stream->pos = stream->text.buf;
|
||||
}
|
||||
else {
|
||||
apr_size_t remaining_length = stream->text.buf + stream->text.length - stream->pos;
|
||||
if(!remaining_length || remaining_length == stream->text.length) {
|
||||
stream->pos = stream->text.buf + remaining_length;
|
||||
return FALSE;
|
||||
}
|
||||
memmove(stream->text.buf,stream->pos,remaining_length);
|
||||
stream->pos = stream->text.buf + remaining_length;
|
||||
return FALSE;
|
||||
stream->text.length = remaining_length;
|
||||
}
|
||||
memmove(stream->text.buf,stream->pos,remaining_length);
|
||||
stream->pos = stream->text.buf + remaining_length;
|
||||
stream->text.length = remaining_length;
|
||||
*stream->pos = '\0';
|
||||
return TRUE;
|
||||
}
|
||||
@@ -216,14 +224,36 @@ APT_DECLARE(apt_bool_t) apt_id_resource_generate(const apt_str_t *id, const apt_
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/** Generate only the name ("name":) of the header */
|
||||
APT_DECLARE(apt_bool_t) apt_text_header_name_generate(const apt_str_t *name, apt_text_stream_t *stream)
|
||||
/** Generate name-value pair line */
|
||||
APT_DECLARE(apt_bool_t) apt_text_name_value_insert(apt_text_stream_t *stream, const apt_str_t *name, const apt_str_t *value)
|
||||
{
|
||||
char *pos = stream->pos;
|
||||
if(pos + name->length + value->length + 2 >= stream->end) {
|
||||
return FALSE;
|
||||
}
|
||||
memcpy(pos,name->buf,name->length);
|
||||
pos += name->length;
|
||||
*pos++ = ':';
|
||||
*pos++ = ' ';
|
||||
*pos++ = APT_TOKEN_SP;
|
||||
if(apt_string_is_empty(value) == FALSE) {
|
||||
memcpy(pos,value->buf,value->length);
|
||||
pos += value->length;
|
||||
}
|
||||
stream->pos = pos;
|
||||
return apt_text_eol_insert(stream);
|
||||
}
|
||||
|
||||
/** Generate only the name ("name":) of the header field */
|
||||
APT_DECLARE(apt_bool_t) apt_text_header_name_insert(apt_text_stream_t *stream, const apt_str_t *name)
|
||||
{
|
||||
char *pos = stream->pos;
|
||||
if(pos + name->length + 2 >= stream->end) {
|
||||
return FALSE;
|
||||
}
|
||||
memcpy(pos,name->buf,name->length);
|
||||
pos += name->length;
|
||||
*pos++ = ':';
|
||||
*pos++ = APT_TOKEN_SP;
|
||||
stream->pos = pos;
|
||||
return TRUE;
|
||||
}
|
||||
@@ -269,7 +299,21 @@ APT_DECLARE(apt_bool_t) apt_pair_array_parse(apt_pair_arr_t *arr, const apt_str_
|
||||
}
|
||||
|
||||
/** Generate array of name-value pairs */
|
||||
APT_DECLARE(apt_bool_t) apt_pair_array_generate(apt_pair_arr_t *arr, apt_text_stream_t *stream)
|
||||
APT_DECLARE(apt_bool_t) apt_pair_array_generate(const apt_pair_arr_t *arr, apt_str_t *str, apr_pool_t *pool)
|
||||
{
|
||||
char buf[512];
|
||||
apt_text_stream_t stream;
|
||||
apt_text_stream_init(&stream,buf,sizeof(buf));
|
||||
if(apt_text_pair_array_insert(&stream,arr) == FALSE) {
|
||||
return FALSE;
|
||||
}
|
||||
apt_string_assign_n(str, stream.text.buf, stream.pos - stream.text.buf, pool);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/** Insert array of name-value pairs */
|
||||
APT_DECLARE(apt_bool_t) apt_text_pair_array_insert(apt_text_stream_t *stream, const apt_pair_arr_t *arr)
|
||||
{
|
||||
int i;
|
||||
apt_pair_t *pair;
|
||||
@@ -314,30 +358,61 @@ APT_DECLARE(apt_bool_t) apt_boolean_value_parse(const apt_str_t *str, apt_bool_t
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/** Generate boolean-value */
|
||||
APT_DECLARE(apt_bool_t) apt_boolean_value_generate(apt_bool_t value, apt_text_stream_t *stream)
|
||||
/** Generate apr_size_t value from pool (buffer is allocated from pool) */
|
||||
APT_DECLARE(apt_bool_t) apt_boolean_value_generate(apt_bool_t value, apt_str_t *str, apr_pool_t *pool)
|
||||
{
|
||||
if(value == TRUE) {
|
||||
str->length = TOKEN_TRUE_LENGTH;
|
||||
str->buf = apr_palloc(pool,str->length);
|
||||
memcpy(str->buf,TOKEN_TRUE,str->length);
|
||||
}
|
||||
else {
|
||||
str->length = TOKEN_FALSE_LENGTH;
|
||||
str->buf = apr_palloc(pool,str->length);
|
||||
memcpy(str->buf,TOKEN_FALSE,str->length);
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/** Generate boolean-value */
|
||||
APT_DECLARE(apt_bool_t) apt_boolean_value_insert(apt_text_stream_t *stream, apt_bool_t value)
|
||||
{
|
||||
if(value == TRUE) {
|
||||
if(stream->pos + TOKEN_TRUE_LENGTH >= stream->end) {
|
||||
return FALSE;
|
||||
}
|
||||
memcpy(stream->pos,TOKEN_TRUE,TOKEN_TRUE_LENGTH);
|
||||
stream->pos += TOKEN_TRUE_LENGTH;
|
||||
}
|
||||
else {
|
||||
if(stream->pos + TOKEN_FALSE_LENGTH >= stream->end) {
|
||||
return FALSE;
|
||||
}
|
||||
memcpy(stream->pos,TOKEN_FALSE,TOKEN_FALSE_LENGTH);
|
||||
stream->pos += TOKEN_FALSE_LENGTH;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/** Parse size_t value */
|
||||
APT_DECLARE(apr_size_t) apt_size_value_parse(const apt_str_t *str)
|
||||
{
|
||||
return str->buf ? atol(str->buf) : 0;
|
||||
}
|
||||
|
||||
/** Generate apr_size_t value */
|
||||
APT_DECLARE(apt_bool_t) apt_size_value_generate(apr_size_t value, apt_text_stream_t *stream)
|
||||
/** Generate apr_size_t value (buffer is allocated from pool) */
|
||||
APT_DECLARE(apt_bool_t) apt_size_value_generate(apr_size_t value, apt_str_t *str, apr_pool_t *pool)
|
||||
{
|
||||
int length = sprintf(stream->pos, "%"APR_SIZE_T_FMT, value);
|
||||
str->buf = apr_psprintf(pool, "%"APR_SIZE_T_FMT, value);
|
||||
str->length = strlen(str->buf);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/** Insert apr_size_t value */
|
||||
APT_DECLARE(apt_bool_t) apt_text_size_value_insert(apt_text_stream_t *stream, apr_size_t value)
|
||||
{
|
||||
int length = apr_snprintf(stream->pos, stream->end - stream->pos, "%"APR_SIZE_T_FMT, value);
|
||||
if(length <= 0) {
|
||||
return FALSE;
|
||||
}
|
||||
@@ -345,29 +420,58 @@ APT_DECLARE(apt_bool_t) apt_size_value_generate(apr_size_t value, apt_text_strea
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/** Parse float value */
|
||||
APT_DECLARE(float) apt_float_value_parse(const apt_str_t *str)
|
||||
{
|
||||
return str->buf ? (float)atof(str->buf) : 0;
|
||||
}
|
||||
|
||||
/** Generate float value */
|
||||
APT_DECLARE(apt_bool_t) apt_float_value_generate(float value, apt_text_stream_t *stream)
|
||||
/** Generate float value (buffer is allocated from pool) */
|
||||
APT_DECLARE(apt_bool_t) apt_float_value_generate(float value, apt_str_t *str, apr_pool_t *pool)
|
||||
{
|
||||
char *end;
|
||||
int length = sprintf(stream->pos,"%f",value);
|
||||
str->buf = apr_psprintf(pool,"%f",value);
|
||||
str->length = strlen(str->buf);
|
||||
|
||||
/* remove trailing 0s (if any) */
|
||||
end = str->buf + str->length - 1;
|
||||
while(*end == 0x30 && end != str->buf && *(end - 1) != '.') end--;
|
||||
|
||||
str->length = end - str->buf + 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/** Generate float value */
|
||||
APT_DECLARE(apt_bool_t) apt_text_float_value_insert(apt_text_stream_t *stream, float value)
|
||||
{
|
||||
char *end;
|
||||
int length = apr_snprintf(stream->pos, stream->end - stream->pos, "%f", value);
|
||||
if(length <= 0) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* remove trailing 0s (if any) */
|
||||
end = stream->pos + length - 1;
|
||||
while(*end == 0x30 && end != stream->pos) end--;
|
||||
while(*end == 0x30 && end != stream->pos && *(end - 1) != '.') end--;
|
||||
|
||||
stream->pos = end + 1;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/** Insert string value */
|
||||
APT_DECLARE(apt_bool_t) apt_text_string_insert(apt_text_stream_t *stream, const apt_str_t *str)
|
||||
{
|
||||
if(stream->pos + str->length >= stream->end) {
|
||||
return FALSE;
|
||||
}
|
||||
if(str->length) {
|
||||
memcpy(stream->pos,str->buf,str->length);
|
||||
stream->pos += str->length;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/** Generate value plus the length (number of digits) of the value itself. */
|
||||
APT_DECLARE(apt_bool_t) apt_var_length_value_generate(apr_size_t *value, apr_size_t max_count, apt_str_t *str)
|
||||
{
|
||||
@@ -405,6 +509,25 @@ APT_DECLARE(apt_bool_t) apt_var_length_value_generate(apr_size_t *value, apr_siz
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/** Generate completion-cause */
|
||||
APT_DECLARE(apt_bool_t) apt_completion_cause_generate(const apt_str_table_item_t table[], apr_size_t size, apr_size_t cause, apt_str_t *str, apr_pool_t *pool)
|
||||
{
|
||||
char buf[256];
|
||||
int length;
|
||||
const apt_str_t *name = apt_string_table_str_get(table,size,cause);
|
||||
if(!name) {
|
||||
return FALSE;
|
||||
}
|
||||
length = sprintf(buf,"%03"APR_SIZE_T_FMT" ",cause);
|
||||
if(length <= 0) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
memcpy(buf+length,name->buf,name->length);
|
||||
apt_string_assign_n(str,buf,name->length + length,pool);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/** Generate unique identifier (hex string) */
|
||||
APT_DECLARE(apt_bool_t) apt_unique_id_generate(apt_str_t *id, apr_size_t length, apr_pool_t *pool)
|
||||
|
||||
@@ -0,0 +1,211 @@
|
||||
/*
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: apt_timer_queue.c 1665 2010-04-25 05:03:26Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifdef WIN32
|
||||
#pragma warning(disable: 4127)
|
||||
#endif
|
||||
#include <apr_ring.h>
|
||||
#include "apt_timer_queue.h"
|
||||
#include "apt_log.h"
|
||||
|
||||
/** Timer queue */
|
||||
struct apt_timer_queue_t {
|
||||
/** Ring head */
|
||||
APR_RING_HEAD(apt_timer_head_t, apt_timer_t) head;
|
||||
|
||||
/** Elapsed time */
|
||||
apr_uint32_t elapsed_time;
|
||||
};
|
||||
|
||||
/** Timer */
|
||||
struct apt_timer_t {
|
||||
/** Ring entry */
|
||||
APR_RING_ENTRY(apt_timer_t) link;
|
||||
|
||||
/** Back pointer to queue */
|
||||
apt_timer_queue_t *queue;
|
||||
/** Time next report is scheduled at */
|
||||
apr_uint32_t scheduled_time;
|
||||
|
||||
/** Timer proc */
|
||||
apt_timer_proc_f proc;
|
||||
/** Timer object */
|
||||
void *obj;
|
||||
};
|
||||
|
||||
static void apt_timers_reschedule(apt_timer_queue_t *timer_queue);
|
||||
|
||||
/** Create timer queue */
|
||||
APT_DECLARE(apt_timer_queue_t*) apt_timer_queue_create(apr_pool_t *pool)
|
||||
{
|
||||
apt_timer_queue_t *timer_queue = apr_palloc(pool,sizeof(apt_timer_queue_t));
|
||||
APR_RING_INIT(&timer_queue->head, apt_timer_t, link);
|
||||
timer_queue->elapsed_time = 0;
|
||||
return timer_queue;
|
||||
}
|
||||
|
||||
/** Destroy timer queue */
|
||||
APT_DECLARE(void) apt_timer_queue_destroy(apt_timer_queue_t *timer_queue)
|
||||
{
|
||||
}
|
||||
|
||||
/** Advance scheduled timers */
|
||||
APT_DECLARE(void) apt_timer_queue_advance(apt_timer_queue_t *timer_queue, apr_uint32_t elapsed_time)
|
||||
{
|
||||
apt_timer_t *timer;
|
||||
|
||||
if(APR_RING_EMPTY(&timer_queue->head, apt_timer_t, link)) {
|
||||
/* just return, nothing to do */
|
||||
return;
|
||||
}
|
||||
|
||||
/* increment elapsed time */
|
||||
timer_queue->elapsed_time += elapsed_time;
|
||||
if(timer_queue->elapsed_time >= 0xFFFF) {
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Reschedule Timers [%u]",timer_queue->elapsed_time);
|
||||
apt_timers_reschedule(timer_queue);
|
||||
}
|
||||
|
||||
/* process timers */
|
||||
do {
|
||||
/* get first node (timer) */
|
||||
timer = APR_RING_FIRST(&timer_queue->head);
|
||||
|
||||
if(timer->scheduled_time > timer_queue->elapsed_time) {
|
||||
/* scheduled time is not elapsed yet */
|
||||
break;
|
||||
}
|
||||
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Timer Elapsed 0x%x [%u]",timer,timer->scheduled_time);
|
||||
/* remove the elapsed timer from the list */
|
||||
APR_RING_REMOVE(timer, link);
|
||||
timer->scheduled_time = 0;
|
||||
/* process the elapsed timer */
|
||||
timer->proc(timer,timer->obj);
|
||||
}
|
||||
while(!APR_RING_EMPTY(&timer_queue->head, apt_timer_t, link));
|
||||
}
|
||||
|
||||
/** Is timer queue empty */
|
||||
APT_DECLARE(apt_bool_t) apt_timer_queue_is_empty(const apt_timer_queue_t *timer_queue)
|
||||
{
|
||||
return APR_RING_EMPTY(&timer_queue->head, apt_timer_t, link) ? TRUE : FALSE;
|
||||
}
|
||||
|
||||
/** Get current timeout */
|
||||
APT_DECLARE(apt_bool_t) apt_timer_queue_timeout_get(const apt_timer_queue_t *timer_queue, apr_uint32_t *timeout)
|
||||
{
|
||||
apt_timer_t *timer;
|
||||
/* is queue empty */
|
||||
if(APR_RING_EMPTY(&timer_queue->head, apt_timer_t, link)) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* get first node (timer) */
|
||||
timer = APR_RING_FIRST(&timer_queue->head);
|
||||
if(!timer) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
*timeout = timer->scheduled_time - timer_queue->elapsed_time;
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
/** Create timer */
|
||||
APT_DECLARE(apt_timer_t*) apt_timer_create(apt_timer_queue_t *timer_queue, apt_timer_proc_f proc, void *obj, apr_pool_t *pool)
|
||||
{
|
||||
apt_timer_t *timer = apr_palloc(pool,sizeof(apt_timer_t));
|
||||
timer->queue = timer_queue;
|
||||
timer->scheduled_time = 0;
|
||||
timer->proc = proc;
|
||||
timer->obj = obj;
|
||||
return timer;
|
||||
}
|
||||
|
||||
static APR_INLINE apt_bool_t apt_timer_insert(apt_timer_queue_t *timer_queue, apt_timer_t *timer)
|
||||
{
|
||||
apt_timer_t *it;
|
||||
for(it = APR_RING_LAST(&timer_queue->head);
|
||||
it != APR_RING_SENTINEL(&timer_queue->head, apt_timer_t, link);
|
||||
it = APR_RING_PREV(it, link)) {
|
||||
|
||||
if(it->scheduled_time <= timer->scheduled_time) {
|
||||
APR_RING_INSERT_AFTER(it,timer,link);
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
APR_RING_INSERT_HEAD(&timer_queue->head,timer,apt_timer_t,link);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/** Set one-shot timer */
|
||||
APT_DECLARE(apt_bool_t) apt_timer_set(apt_timer_t *timer, apr_uint32_t timeout)
|
||||
|
||||
{
|
||||
apt_timer_queue_t *queue = timer->queue;
|
||||
|
||||
if(timeout <= 0 || !timer->proc) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
/* calculate time to elapse */
|
||||
timer->scheduled_time = queue->elapsed_time + timeout;
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Set Timer 0x%x [%u]",timer,timer->scheduled_time);
|
||||
|
||||
if(APR_RING_EMPTY(&queue->head, apt_timer_t, link)) {
|
||||
APR_RING_INSERT_TAIL(&queue->head,timer,apt_timer_t,link);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/* insert new node (timer) to sorted by scheduled time list */
|
||||
return apt_timer_insert(queue,timer);
|
||||
}
|
||||
|
||||
/** Kill timer */
|
||||
APT_DECLARE(apt_bool_t) apt_timer_kill(apt_timer_t *timer)
|
||||
{
|
||||
apt_timer_queue_t *queue = timer->queue;
|
||||
|
||||
if(!timer->scheduled_time) {
|
||||
return FALSE;
|
||||
}
|
||||
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Kill Timer 0x%x [%u]",timer,timer->scheduled_time);
|
||||
/* remove node (timer) from the list */
|
||||
APR_RING_REMOVE(timer,link);
|
||||
timer->scheduled_time = 0;
|
||||
|
||||
if(APR_RING_EMPTY(&queue->head, apt_timer_t, link)) {
|
||||
/* reset elapsed time if no timers set */
|
||||
queue->elapsed_time = 0;
|
||||
}
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static void apt_timers_reschedule(apt_timer_queue_t *queue)
|
||||
{
|
||||
apt_timer_t *it;
|
||||
for(it = APR_RING_LAST(&queue->head);
|
||||
it != APR_RING_SENTINEL(&queue->head, apt_timer_t, link);
|
||||
it = APR_RING_PREV(it, link)) {
|
||||
|
||||
it->scheduled_time -= queue->elapsed_time;
|
||||
}
|
||||
queue->elapsed_time = 0;
|
||||
}
|
||||
@@ -35,7 +35,6 @@ include_HEADERS = codecs/g711/g711.h \
|
||||
include/mpf_rtp_termination_factory.h \
|
||||
include/mpf_file_termination_factory.h \
|
||||
include/mpf_scheduler.h \
|
||||
include/mpf_timer_manager.h \
|
||||
include/mpf_types.h \
|
||||
include/mpf_encoder.h \
|
||||
include/mpf_decoder.h \
|
||||
@@ -72,7 +71,6 @@ libmpf_la_SOURCES = codecs/g711/g711.c \
|
||||
src/mpf_file_termination_factory.c \
|
||||
src/mpf_frame_buffer.c \
|
||||
src/mpf_scheduler.c \
|
||||
src/mpf_timer_manager.c \
|
||||
src/mpf_encoder.c \
|
||||
src/mpf_decoder.c \
|
||||
src/mpf_jitter_buffer.c \
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_H__
|
||||
#define __MPF_H__
|
||||
#ifndef MPF_H
|
||||
#define MPF_H
|
||||
|
||||
/**
|
||||
* @file mpf.h
|
||||
@@ -39,4 +41,4 @@
|
||||
#define MPF_DECLARE(type) type
|
||||
#endif
|
||||
|
||||
#endif /*__MPF_H__*/
|
||||
#endif /* MPF_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_activity_detector.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_ACTIVITY_DETECTOR_H__
|
||||
#define __MPF_ACTIVITY_DETECTOR_H__
|
||||
#ifndef MPF_ACTIVITY_DETECTOR_H
|
||||
#define MPF_ACTIVITY_DETECTOR_H
|
||||
|
||||
/**
|
||||
* @file mpf_activity_detector.h
|
||||
@@ -63,4 +65,4 @@ MPF_DECLARE(mpf_detector_event_e) mpf_activity_detector_process(mpf_activity_det
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_ACTIVITY_DETECTOR_H__*/
|
||||
#endif /* MPF_ACTIVITY_DETECTOR_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_audio_file_descriptor.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_AUDIO_FILE_DESCRIPTOR_H__
|
||||
#define __MPF_AUDIO_FILE_DESCRIPTOR_H__
|
||||
#ifndef MPF_AUDIO_FILE_DESCRIPTOR_H
|
||||
#define MPF_AUDIO_FILE_DESCRIPTOR_H
|
||||
|
||||
/**
|
||||
* @file mpf_audio_file_descriptor.h
|
||||
@@ -51,4 +53,4 @@ struct mpf_audio_file_descriptor_t {
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_AUDIO_FILE_DESCRIPTOR_H__*/
|
||||
#endif /* MPF_AUDIO_FILE_DESCRIPTOR_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_audio_file_stream.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_AUDIO_FILE_STREAM_H__
|
||||
#define __MPF_AUDIO_FILE_STREAM_H__
|
||||
#ifndef MPF_AUDIO_FILE_STREAM_H
|
||||
#define MPF_AUDIO_FILE_STREAM_H
|
||||
|
||||
/**
|
||||
* @file mpf_audio_file_stream.h
|
||||
@@ -43,4 +45,4 @@ MPF_DECLARE(apt_bool_t) mpf_file_stream_modify(mpf_audio_stream_t *stream, mpf_a
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_AUDIO_FILE_STREAM_H__*/
|
||||
#endif /* MPF_AUDIO_FILE_STREAM_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_bridge.h 1693 2010-05-16 18:33:07Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_BRIDGE_H__
|
||||
#define __MPF_BRIDGE_H__
|
||||
#ifndef MPF_BRIDGE_H
|
||||
#define MPF_BRIDGE_H
|
||||
|
||||
/**
|
||||
* @file mpf_bridge.h
|
||||
@@ -31,15 +33,17 @@ APT_BEGIN_EXTERN_C
|
||||
* @param source the source audio stream
|
||||
* @param sink the sink audio stream
|
||||
* @param codec_manager the codec manager
|
||||
* @param name the informative name used for debugging
|
||||
* @param pool the pool to allocate memory from
|
||||
*/
|
||||
MPF_DECLARE(mpf_object_t*) mpf_bridge_create(
|
||||
mpf_audio_stream_t *source,
|
||||
mpf_audio_stream_t *sink,
|
||||
const mpf_codec_manager_t *codec_manager,
|
||||
const char *name,
|
||||
apr_pool_t *pool);
|
||||
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_BRIDGE_H__*/
|
||||
#endif /* MPF_BRIDGE_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_buffer.h 1709 2010-05-24 17:12:11Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_BUFFER_H__
|
||||
#define __MPF_BUFFER_H__
|
||||
#ifndef MPF_BUFFER_H
|
||||
#define MPF_BUFFER_H
|
||||
|
||||
/**
|
||||
* @file mpf_buffer.h
|
||||
@@ -49,8 +51,8 @@ apt_bool_t mpf_buffer_event_write(mpf_buffer_t *buffer, mpf_frame_type_e event_t
|
||||
apt_bool_t mpf_buffer_frame_read(mpf_buffer_t *buffer, mpf_frame_t *media_frame);
|
||||
|
||||
/** Get size of buffer **/
|
||||
apr_size_t mpf_buffer_get_size(mpf_buffer_t *buffer);
|
||||
apr_size_t mpf_buffer_get_size(const mpf_buffer_t *buffer);
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_BUFFER_H__*/
|
||||
#endif /* MPF_BUFFER_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_codec.h 1686 2010-05-08 18:46:08Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_CODEC_H__
|
||||
#define __MPF_CODEC_H__
|
||||
#ifndef MPF_CODEC_H
|
||||
#define MPF_CODEC_H
|
||||
|
||||
/**
|
||||
* @file mpf_codec.h
|
||||
@@ -55,6 +57,9 @@ struct mpf_codec_vtable_t {
|
||||
|
||||
/** Virtual dissect method */
|
||||
apt_bool_t (*dissect)(mpf_codec_t *codec, void **buffer, apr_size_t *size, mpf_codec_frame_t *frame);
|
||||
|
||||
/** Virtual initialize method */
|
||||
apt_bool_t (*initialize)(mpf_codec_t *codec, mpf_codec_frame_t *frame_out);
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -154,6 +159,19 @@ static APR_INLINE apt_bool_t mpf_codec_dissect(mpf_codec_t *codec, void **buffer
|
||||
return rv;
|
||||
}
|
||||
|
||||
/** Initialize (fill) codec frame with silence */
|
||||
static APR_INLINE apt_bool_t mpf_codec_initialize(mpf_codec_t *codec, mpf_codec_frame_t *frame_out)
|
||||
{
|
||||
apt_bool_t rv = TRUE;
|
||||
if(codec->vtable->initialize) {
|
||||
rv = codec->vtable->initialize(codec,frame_out);
|
||||
}
|
||||
else {
|
||||
memset(frame_out->buffer,0,frame_out->size);
|
||||
}
|
||||
return rv;
|
||||
}
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_CODEC_H__*/
|
||||
#endif /* MPF_CODEC_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_codec_descriptor.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_CODEC_DESCRIPTOR_H__
|
||||
#define __MPF_CODEC_DESCRIPTOR_H__
|
||||
#ifndef MPF_CODEC_DESCRIPTOR_H
|
||||
#define MPF_CODEC_DESCRIPTOR_H
|
||||
|
||||
/**
|
||||
* @file mpf_codec_descriptor.h
|
||||
@@ -278,4 +280,4 @@ MPF_DECLARE(int) mpf_sample_rate_mask_get(apr_uint16_t sampling_rate);
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_CODEC_DESCRIPTOR_H__*/
|
||||
#endif /* MPF_CODEC_DESCRIPTOR_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_codec_manager.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_CODEC_MANAGER_H__
|
||||
#define __MPF_CODEC_MANAGER_H__
|
||||
#ifndef MPF_CODEC_MANAGER_H
|
||||
#define MPF_CODEC_MANAGER_H
|
||||
|
||||
/**
|
||||
* @file mpf_codec_manager.h
|
||||
@@ -50,4 +52,4 @@ MPF_DECLARE(const mpf_codec_t*) mpf_codec_manager_codec_find(const mpf_codec_man
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_CODEC_MANAGER_H__*/
|
||||
#endif /* MPF_CODEC_MANAGER_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_context.h 1709 2010-05-24 17:12:11Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_CONTEXT_H__
|
||||
#define __MPF_CONTEXT_H__
|
||||
#ifndef MPF_CONTEXT_H
|
||||
#define MPF_CONTEXT_H
|
||||
|
||||
/**
|
||||
* @file mpf_context.h
|
||||
@@ -47,12 +49,14 @@ MPF_DECLARE(apt_bool_t) mpf_context_factory_process(mpf_context_factory_t *facto
|
||||
/**
|
||||
* Create MPF context.
|
||||
* @param factory the factory context belongs to
|
||||
* @param name the informative name of the context
|
||||
* @param obj the external object associated with context
|
||||
* @param max_termination_count the max number of terminations in context
|
||||
* @param pool the pool to allocate memory from
|
||||
*/
|
||||
MPF_DECLARE(mpf_context_t*) mpf_context_create(
|
||||
mpf_context_factory_t *factory,
|
||||
const char *name,
|
||||
void *obj,
|
||||
apr_size_t max_termination_count,
|
||||
apr_pool_t *pool);
|
||||
@@ -67,7 +71,7 @@ MPF_DECLARE(apt_bool_t) mpf_context_destroy(mpf_context_t *context);
|
||||
* Get external object associated with MPF context.
|
||||
* @param context the context to get object from
|
||||
*/
|
||||
MPF_DECLARE(void*) mpf_context_object_get(mpf_context_t *context);
|
||||
MPF_DECLARE(void*) mpf_context_object_get(const mpf_context_t *context);
|
||||
|
||||
/**
|
||||
* Add termination to context.
|
||||
@@ -126,4 +130,4 @@ MPF_DECLARE(apt_bool_t) mpf_context_process(mpf_context_t *context);
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_CONTEXT_H__*/
|
||||
#endif /* MPF_CONTEXT_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_decoder.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_DECODER_H__
|
||||
#define __MPF_DECODER_H__
|
||||
#ifndef MPF_DECODER_H
|
||||
#define MPF_DECODER_H
|
||||
|
||||
/**
|
||||
* @file mpf_decoder.h
|
||||
@@ -37,4 +39,4 @@ MPF_DECLARE(mpf_audio_stream_t*) mpf_decoder_create(mpf_audio_stream_t *source,
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_ENCODER_H__*/
|
||||
#endif /* MPF_ENCODER_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2009 Tomas Valenta, Arsen Chaloyan
|
||||
* Copyright 2009-2010 Tomas Valenta, Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,12 +12,14 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_dtmf_detector.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_DTMF_DETECTOR_H__
|
||||
#define __MPF_DTMF_DETECTOR_H__
|
||||
#ifndef MPF_DTMF_DETECTOR_H
|
||||
#define MPF_DTMF_DETECTOR_H
|
||||
|
||||
/*
|
||||
/**
|
||||
* @file mpf_dtmf_detector.h
|
||||
* @brief DTMF detector
|
||||
*
|
||||
@@ -118,4 +120,4 @@ MPF_DECLARE(void) mpf_dtmf_detector_destroy(struct mpf_dtmf_detector_t *detector
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_DTMF_DETECTOR_H__*/
|
||||
#endif /* MPF_DTMF_DETECTOR_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2009 Tomas Valenta, Arsen Chaloyan
|
||||
* Copyright 2009-2010 Tomas Valenta, Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -14,11 +14,11 @@
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __MPF_DTMF_GENERATOR_H__
|
||||
#define __MPF_DTMF_GENERATOR_H__
|
||||
#ifndef MPF_DTMF_GENERATOR_H
|
||||
#define MPF_DTMF_GENERATOR_H
|
||||
|
||||
/*
|
||||
* @file mpf_named_event.h
|
||||
/**
|
||||
* @file mpf_dtmf_generator.h
|
||||
* @brief DTMF generator
|
||||
*
|
||||
* Generator used to send DTMF tones. Capable to send digits
|
||||
@@ -128,4 +128,4 @@ MPF_DECLARE(void) mpf_dtmf_generator_destroy(struct mpf_dtmf_generator_t *genera
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_DTMF_GENERATOR_H__*/
|
||||
#endif /* MPF_DTMF_GENERATOR_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_encoder.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_ENCODER_H__
|
||||
#define __MPF_ENCODER_H__
|
||||
#ifndef MPF_ENCODER_H
|
||||
#define MPF_ENCODER_H
|
||||
|
||||
/**
|
||||
* @file mpf_encoder.h
|
||||
@@ -37,4 +39,4 @@ MPF_DECLARE(mpf_audio_stream_t*) mpf_encoder_create(mpf_audio_stream_t *sink, mp
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_ENCODER_H__*/
|
||||
#endif /* MPF_ENCODER_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_engine.h 1709 2010-05-24 17:12:11Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_ENGINE_H__
|
||||
#define __MPF_ENGINE_H__
|
||||
#ifndef MPF_ENGINE_H
|
||||
#define MPF_ENGINE_H
|
||||
|
||||
/**
|
||||
* @file mpf_engine.h
|
||||
@@ -32,9 +34,10 @@ typedef apt_task_msg_t mpf_task_msg_t;
|
||||
|
||||
/**
|
||||
* Create MPF engine.
|
||||
* @param id the identifier of the engine
|
||||
* @param pool the pool to allocate memory from
|
||||
*/
|
||||
MPF_DECLARE(mpf_engine_t*) mpf_engine_create(apr_pool_t *pool);
|
||||
MPF_DECLARE(mpf_engine_t*) mpf_engine_create(const char *id, apr_pool_t *pool);
|
||||
|
||||
/**
|
||||
* Create MPF codec manager.
|
||||
@@ -52,12 +55,14 @@ MPF_DECLARE(apt_bool_t) mpf_engine_codec_manager_register(mpf_engine_t *engine,
|
||||
/**
|
||||
* Create MPF context.
|
||||
* @param engine the engine to create context for
|
||||
* @param name the informative name of the context
|
||||
* @param obj the external object associated with context
|
||||
* @param max_termination_count the max number of terminations in context
|
||||
* @param pool the pool to allocate memory from
|
||||
*/
|
||||
MPF_DECLARE(mpf_context_t*) mpf_engine_context_create(
|
||||
mpf_engine_t *engine,
|
||||
mpf_engine_t *engine,
|
||||
const char *name,
|
||||
void *obj,
|
||||
apr_size_t max_termination_count,
|
||||
apr_pool_t *pool);
|
||||
@@ -72,13 +77,13 @@ MPF_DECLARE(apt_bool_t) mpf_engine_context_destroy(mpf_context_t *context);
|
||||
* Get external object associated with MPF context.
|
||||
* @param context the context to get object from
|
||||
*/
|
||||
MPF_DECLARE(void*) mpf_engine_context_object_get(mpf_context_t *context);
|
||||
MPF_DECLARE(void*) mpf_engine_context_object_get(const mpf_context_t *context);
|
||||
|
||||
/**
|
||||
* Get task.
|
||||
* @param engine the engine to get task from
|
||||
*/
|
||||
MPF_DECLARE(apt_task_t*) mpf_task_get(mpf_engine_t *engine);
|
||||
MPF_DECLARE(apt_task_t*) mpf_task_get(const mpf_engine_t *engine);
|
||||
|
||||
/**
|
||||
* Set task msg type to send responses and events with.
|
||||
@@ -148,7 +153,13 @@ MPF_DECLARE(apt_bool_t) mpf_engine_message_send(mpf_engine_t *engine, mpf_task_m
|
||||
*/
|
||||
MPF_DECLARE(apt_bool_t) mpf_engine_scheduler_rate_set(mpf_engine_t *engine, unsigned long rate);
|
||||
|
||||
/**
|
||||
* Get the identifier of the engine .
|
||||
* @param engine the engine to get name of
|
||||
*/
|
||||
MPF_DECLARE(const char*) mpf_engine_id_get(const mpf_engine_t *engine);
|
||||
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_ENGINE_H__*/
|
||||
#endif /* MPF_ENGINE_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_file_termination_factory.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_FILE_TERMINATION_FACTORY_H__
|
||||
#define __MPF_FILE_TERMINATION_FACTORY_H__
|
||||
#ifndef MPF_FILE_TERMINATION_FACTORY_H
|
||||
#define MPF_FILE_TERMINATION_FACTORY_H
|
||||
|
||||
/**
|
||||
* @file mpf_file_termination_factory.h
|
||||
@@ -34,4 +36,4 @@ MPF_DECLARE(mpf_termination_factory_t*) mpf_file_termination_factory_create(apr_
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_RTP_TERMINATION_FACTORY_H__*/
|
||||
#endif /* MPF_RTP_TERMINATION_FACTORY_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_frame.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_FRAME_H__
|
||||
#define __MPF_FRAME_H__
|
||||
#ifndef MPF_FRAME_H
|
||||
#define MPF_FRAME_H
|
||||
|
||||
/**
|
||||
* @file mpf_frame.h
|
||||
@@ -61,4 +63,4 @@ struct mpf_frame_t {
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_FRAME_H__*/
|
||||
#endif /* MPF_FRAME_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_frame_buffer.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_FRAME_BUFFER_H__
|
||||
#define __MPF_FRAME_BUFFER_H__
|
||||
#ifndef MPF_FRAME_BUFFER_H
|
||||
#define MPF_FRAME_BUFFER_H
|
||||
|
||||
/**
|
||||
* @file mpf_frame_buffer.h
|
||||
@@ -47,4 +49,4 @@ apt_bool_t mpf_frame_buffer_read(mpf_frame_buffer_t *buffer, mpf_frame_t *frame)
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_FRAME_BUFFER_H__*/
|
||||
#endif /* MPF_FRAME_BUFFER_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_jitter_buffer.h 1802 2011-05-13 02:43:12Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_JITTER_BUFFER_H__
|
||||
#define __MPF_JITTER_BUFFER_H__
|
||||
#ifndef MPF_JITTER_BUFFER_H
|
||||
#define MPF_JITTER_BUFFER_H
|
||||
|
||||
/**
|
||||
* @file mpf_jitter_buffer.h
|
||||
@@ -50,7 +52,7 @@ void mpf_jitter_buffer_destroy(mpf_jitter_buffer_t *jb);
|
||||
apt_bool_t mpf_jitter_buffer_restart(mpf_jitter_buffer_t *jb);
|
||||
|
||||
/** Write audio data to jitter buffer */
|
||||
jb_result_t mpf_jitter_buffer_write(mpf_jitter_buffer_t *jb, void *buffer, apr_size_t size, apr_uint32_t ts);
|
||||
jb_result_t mpf_jitter_buffer_write(mpf_jitter_buffer_t *jb, void *buffer, apr_size_t size, apr_uint32_t ts, apr_byte_t marker);
|
||||
|
||||
/** Write named event to jitter buffer */
|
||||
jb_result_t mpf_jitter_buffer_event_write(mpf_jitter_buffer_t *jb, const mpf_named_event_frame_t *named_event, apr_uint32_t ts, apr_byte_t marker);
|
||||
@@ -60,4 +62,4 @@ apt_bool_t mpf_jitter_buffer_read(mpf_jitter_buffer_t *jb, mpf_frame_t *media_fr
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_JITTER_BUFFER_H__*/
|
||||
#endif /* MPF_JITTER_BUFFER_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_message.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_MESSAGE_H__
|
||||
#define __MPF_MESSAGE_H__
|
||||
#ifndef MPF_MESSAGE_H
|
||||
#define MPF_MESSAGE_H
|
||||
|
||||
/**
|
||||
* @file mpf_message.h
|
||||
@@ -89,4 +91,4 @@ struct mpf_message_container_t {
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_MESSAGE_H__*/
|
||||
#endif /* MPF_MESSAGE_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_mixer.h 1693 2010-05-16 18:33:07Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_MIXER_H__
|
||||
#define __MPF_MIXER_H__
|
||||
#ifndef MPF_MIXER_H
|
||||
#define MPF_MIXER_H
|
||||
|
||||
/**
|
||||
* @file mpf_mixer.h
|
||||
@@ -32,6 +34,7 @@ APT_BEGIN_EXTERN_C
|
||||
* @param source_count the number of audio sources
|
||||
* @param sink the audio sink
|
||||
* @param codec_manager the codec manager
|
||||
* @param name the informative name used for debugging
|
||||
* @param pool the pool to allocate memory from
|
||||
*/
|
||||
MPF_DECLARE(mpf_object_t*) mpf_mixer_create(
|
||||
@@ -39,9 +42,10 @@ MPF_DECLARE(mpf_object_t*) mpf_mixer_create(
|
||||
apr_size_t source_count,
|
||||
mpf_audio_stream_t *sink,
|
||||
const mpf_codec_manager_t *codec_manager,
|
||||
const char *name,
|
||||
apr_pool_t *pool);
|
||||
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_MIXER_H__*/
|
||||
#endif /* MPF_MIXER_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_multiplier.h 1693 2010-05-16 18:33:07Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_MULTIPLIER_H__
|
||||
#define __MPF_MULTIPLIER_H__
|
||||
#ifndef MPF_MULTIPLIER_H
|
||||
#define MPF_MULTIPLIER_H
|
||||
|
||||
/**
|
||||
* @file mpf_multiplier.h
|
||||
@@ -32,6 +34,7 @@ APT_BEGIN_EXTERN_C
|
||||
* @param sink_arr the array of audio sinks
|
||||
* @param sink_count the number of audio sinks
|
||||
* @param codec_manager the codec manager
|
||||
* @param name the informative name used for debugging
|
||||
* @param pool the pool to allocate memory from
|
||||
*/
|
||||
MPF_DECLARE(mpf_object_t*) mpf_multiplier_create(
|
||||
@@ -39,9 +42,10 @@ MPF_DECLARE(mpf_object_t*) mpf_multiplier_create(
|
||||
mpf_audio_stream_t **sink_arr,
|
||||
apr_size_t sink_count,
|
||||
const mpf_codec_manager_t *codec_manager,
|
||||
const char *name,
|
||||
apr_pool_t *pool);
|
||||
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_MULTIPLIER_H__*/
|
||||
#endif /* MPF_MULTIPLIER_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_named_event.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_NAMED_EVENT_H__
|
||||
#define __MPF_NAMED_EVENT_H__
|
||||
#ifndef MPF_NAMED_EVENT_H
|
||||
#define MPF_NAMED_EVENT_H
|
||||
|
||||
/**
|
||||
* @file mpf_named_event.h
|
||||
@@ -68,4 +70,4 @@ MPF_DECLARE(char) mpf_event_id_to_dtmf_char(const apr_uint32_t event_id);
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_NAMED_EVENT_H__*/
|
||||
#endif /* MPF_NAMED_EVENT_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_object.h 1693 2010-05-16 18:33:07Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_OBJECT_H__
|
||||
#define __MPF_OBJECT_H__
|
||||
#ifndef MPF_OBJECT_H
|
||||
#define MPF_OBJECT_H
|
||||
|
||||
/**
|
||||
* @file mpf_object.h
|
||||
@@ -31,6 +33,8 @@ typedef struct mpf_object_t mpf_object_t;
|
||||
|
||||
/** Media processing objects base */
|
||||
struct mpf_object_t {
|
||||
/** Informative name used for debugging */
|
||||
const char *name;
|
||||
/** Virtual destroy */
|
||||
apt_bool_t (*destroy)(mpf_object_t *object);
|
||||
/** Virtual process */
|
||||
@@ -40,8 +44,9 @@ struct mpf_object_t {
|
||||
};
|
||||
|
||||
/** Initialize object */
|
||||
static APR_INLINE void mpf_object_init(mpf_object_t *object)
|
||||
static APR_INLINE void mpf_object_init(mpf_object_t *object, const char *name)
|
||||
{
|
||||
object->name = name;
|
||||
object->destroy = NULL;
|
||||
object->process = NULL;
|
||||
object->trace = NULL;
|
||||
@@ -71,4 +76,4 @@ static APR_INLINE void mpf_object_trace(mpf_object_t *object)
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_OBJECT_H__*/
|
||||
#endif /* MPF_OBJECT_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_resampler.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_RESAMPLER_H__
|
||||
#define __MPF_RESAMPLER_H__
|
||||
#ifndef MPF_RESAMPLER_H
|
||||
#define MPF_RESAMPLER_H
|
||||
|
||||
/**
|
||||
* @file mpf_resampler.h
|
||||
@@ -37,4 +39,4 @@ MPF_DECLARE(mpf_audio_stream_t*) mpf_resampler_create(mpf_audio_stream_t *source
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_RESAMPLER_H__*/
|
||||
#endif /* MPF_RESAMPLER_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_rtcp_packet.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_RTCP_PACKET_H__
|
||||
#define __MPF_RTCP_PACKET_H__
|
||||
#ifndef MPF_RTCP_PACKET_H
|
||||
#define MPF_RTCP_PACKET_H
|
||||
|
||||
/**
|
||||
* @file mpf_rtcp_packet.h
|
||||
@@ -198,4 +200,4 @@ static APR_INLINE void rtcp_rr_ntoh(rtcp_rr_stat_t *rr_stat)
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_RTCP_PACKET_H__*/
|
||||
#endif /* MPF_RTCP_PACKET_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_rtp_attribs.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_RTP_ATTRIBS_H__
|
||||
#define __MPF_RTP_ATTRIBS_H__
|
||||
#ifndef MPF_RTP_ATTRIBS_H
|
||||
#define MPF_RTP_ATTRIBS_H
|
||||
|
||||
/**
|
||||
* @file mpf_rtp_attribs.h
|
||||
@@ -51,4 +53,4 @@ MPF_DECLARE(const apt_str_t*) mpf_rtp_direction_str_get(mpf_stream_direction_e d
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_RTP_ATTRIBS_H__*/
|
||||
#endif /* MPF_RTP_ATTRIBS_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_rtp_defs.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_RTP_DEFS_H__
|
||||
#define __MPF_RTP_DEFS_H__
|
||||
#ifndef MPF_RTP_DEFS_H
|
||||
#define MPF_RTP_DEFS_H
|
||||
|
||||
/**
|
||||
* @file mpf_rtp_defs.h
|
||||
@@ -178,4 +180,4 @@ static APR_INLINE void rtp_transmitter_init(rtp_transmitter_t *transmitter)
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_RTP_DEFS_H__*/
|
||||
#endif /* MPF_RTP_DEFS_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_rtp_descriptor.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_RTP_DESCRIPTOR_H__
|
||||
#define __MPF_RTP_DESCRIPTOR_H__
|
||||
#ifndef MPF_RTP_DESCRIPTOR_H
|
||||
#define MPF_RTP_DESCRIPTOR_H
|
||||
|
||||
/**
|
||||
* @file mpf_rtp_descriptor.h
|
||||
@@ -36,6 +38,8 @@ typedef struct mpf_rtp_stream_descriptor_t mpf_rtp_stream_descriptor_t;
|
||||
typedef struct mpf_rtp_termination_descriptor_t mpf_rtp_termination_descriptor_t;
|
||||
/** RTP configuration declaration */
|
||||
typedef struct mpf_rtp_config_t mpf_rtp_config_t;
|
||||
/** RTP settings declaration */
|
||||
typedef struct mpf_rtp_settings_t mpf_rtp_settings_t;
|
||||
/** Jitter buffer configuration declaration */
|
||||
typedef struct mpf_jb_config_t mpf_jb_config_t;
|
||||
|
||||
@@ -75,6 +79,8 @@ struct mpf_rtp_stream_descriptor_t {
|
||||
mpf_rtp_media_descriptor_t *local;
|
||||
/** Remote media descriptor */
|
||||
mpf_rtp_media_descriptor_t *remote;
|
||||
/** Settings loaded from config */
|
||||
mpf_rtp_settings_t *settings;
|
||||
};
|
||||
|
||||
/** RTP termination descriptor */
|
||||
@@ -104,7 +110,7 @@ typedef enum {
|
||||
RTCP_BYE_PER_TALKSPURT /**< transmit RTCP BYE at the end of each talkspurt (input) */
|
||||
} rtcp_bye_policy_e;
|
||||
|
||||
/** RTP config */
|
||||
/** RTP factory config */
|
||||
struct mpf_rtp_config_t {
|
||||
/** Local IP address to bind to */
|
||||
apt_str_t ip;
|
||||
@@ -116,6 +122,10 @@ struct mpf_rtp_config_t {
|
||||
apr_port_t rtp_port_max;
|
||||
/** Current RTP port */
|
||||
apr_port_t rtp_port_cur;
|
||||
};
|
||||
|
||||
/** RTP settings */
|
||||
struct mpf_rtp_settings_t {
|
||||
/** Packetization time */
|
||||
apr_uint16_t ptime;
|
||||
/** Codec list */
|
||||
@@ -172,8 +182,8 @@ static APR_INLINE void mpf_jb_config_init(mpf_jb_config_t *jb_config)
|
||||
jb_config->max_playout_delay = 0;
|
||||
}
|
||||
|
||||
/** Create/allocate RTP config */
|
||||
static APR_INLINE mpf_rtp_config_t* mpf_rtp_config_create(apr_pool_t *pool)
|
||||
/** Allocate RTP config */
|
||||
static APR_INLINE mpf_rtp_config_t* mpf_rtp_config_alloc(apr_pool_t *pool)
|
||||
{
|
||||
mpf_rtp_config_t *rtp_config = (mpf_rtp_config_t*)apr_palloc(pool,sizeof(mpf_rtp_config_t));
|
||||
apt_string_reset(&rtp_config->ip);
|
||||
@@ -181,18 +191,25 @@ static APR_INLINE mpf_rtp_config_t* mpf_rtp_config_create(apr_pool_t *pool)
|
||||
rtp_config->rtp_port_cur = 0;
|
||||
rtp_config->rtp_port_min = 0;
|
||||
rtp_config->rtp_port_max = 0;
|
||||
rtp_config->ptime = 0;
|
||||
mpf_codec_list_init(&rtp_config->codec_list,0,pool);
|
||||
rtp_config->own_preferrence = FALSE;
|
||||
rtp_config->rtcp = FALSE;
|
||||
rtp_config->rtcp_bye_policy = RTCP_BYE_DISABLE;
|
||||
rtp_config->rtcp_tx_interval = 0;
|
||||
rtp_config->rtcp_rx_resolution = 0;
|
||||
mpf_jb_config_init(&rtp_config->jb_config);
|
||||
|
||||
return rtp_config;
|
||||
}
|
||||
|
||||
/** Allocate RTP settings */
|
||||
static APR_INLINE mpf_rtp_settings_t* mpf_rtp_settings_alloc(apr_pool_t *pool)
|
||||
{
|
||||
mpf_rtp_settings_t *rtp_settings = (mpf_rtp_settings_t*)apr_palloc(pool,sizeof(mpf_rtp_settings_t));
|
||||
rtp_settings->ptime = 0;
|
||||
mpf_codec_list_init(&rtp_settings->codec_list,0,pool);
|
||||
rtp_settings->own_preferrence = FALSE;
|
||||
rtp_settings->rtcp = FALSE;
|
||||
rtp_settings->rtcp_bye_policy = RTCP_BYE_DISABLE;
|
||||
rtp_settings->rtcp_tx_interval = 0;
|
||||
rtp_settings->rtcp_rx_resolution = 0;
|
||||
mpf_jb_config_init(&rtp_settings->jb_config);
|
||||
return rtp_settings;
|
||||
}
|
||||
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_RTP_DESCRIPTOR_H__*/
|
||||
#endif /* MPF_RTP_DESCRIPTOR_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_rtp_header.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_RTP_HEADER_H__
|
||||
#define __MPF_RTP_HEADER_H__
|
||||
#ifndef MPF_RTP_HEADER_H
|
||||
#define MPF_RTP_HEADER_H
|
||||
|
||||
/**
|
||||
* @file mpf_rtp_header.h
|
||||
@@ -83,4 +85,4 @@ struct rtp_extension_header_t {
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_RTP_HEADER_H__*/
|
||||
#endif /* MPF_RTP_HEADER_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_rtp_pt.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_RTP_PT_H__
|
||||
#define __MPF_RTP_PT_H__
|
||||
#ifndef MPF_RTP_PT_H
|
||||
#define MPF_RTP_PT_H
|
||||
|
||||
/**
|
||||
* @file mpf_rtp_pt.h
|
||||
@@ -41,4 +43,4 @@ typedef enum {
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_RTP_PT_H__*/
|
||||
#endif /* MPF_RTP_PT_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_rtp_stat.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_RTP_STAT_H__
|
||||
#define __MPF_RTP_STAT_H__
|
||||
#ifndef MPF_RTP_STAT_H
|
||||
#define MPF_RTP_STAT_H
|
||||
|
||||
/**
|
||||
* @file mpf_rtp_stat.h
|
||||
@@ -110,4 +112,4 @@ static APR_INLINE void mpf_rtp_rx_stat_reset(rtp_rx_stat_t *rx_stat)
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_RTP_STAT_H__*/
|
||||
#endif /* MPF_RTP_STAT_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_rtp_stream.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_RTP_STREAM_H__
|
||||
#define __MPF_RTP_STREAM_H__
|
||||
#ifndef MPF_RTP_STREAM_H
|
||||
#define MPF_RTP_STREAM_H
|
||||
|
||||
/**
|
||||
* @file mpf_rtp_stream.h
|
||||
@@ -30,10 +32,11 @@ APT_BEGIN_EXTERN_C
|
||||
/**
|
||||
* Create RTP stream.
|
||||
* @param termination the back pointer to hold
|
||||
* @param config the configuration to use
|
||||
* @param config the configuration of RTP factory
|
||||
* @param settings the settings to use
|
||||
* @param pool the pool to allocate memory from
|
||||
*/
|
||||
MPF_DECLARE(mpf_audio_stream_t*) mpf_rtp_stream_create(mpf_termination_t *termination, mpf_rtp_config_t *config, apr_pool_t *pool);
|
||||
MPF_DECLARE(mpf_audio_stream_t*) mpf_rtp_stream_create(mpf_termination_t *termination, mpf_rtp_config_t *config, mpf_rtp_settings_t *settings, apr_pool_t *pool);
|
||||
|
||||
/**
|
||||
* Add/enable RTP stream.
|
||||
@@ -56,4 +59,4 @@ MPF_DECLARE(apt_bool_t) mpf_rtp_stream_modify(mpf_audio_stream_t *stream, mpf_rt
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_RTP_STREAM_H__*/
|
||||
#endif /* MPF_RTP_STREAM_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_rtp_termination_factory.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_RTP_TERMINATION_FACTORY_H__
|
||||
#define __MPF_RTP_TERMINATION_FACTORY_H__
|
||||
#ifndef MPF_RTP_TERMINATION_FACTORY_H
|
||||
#define MPF_RTP_TERMINATION_FACTORY_H
|
||||
|
||||
/**
|
||||
* @file mpf_rtp_termination_factory.h
|
||||
@@ -37,4 +39,4 @@ MPF_DECLARE(mpf_termination_factory_t*) mpf_rtp_termination_factory_create(
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_RTP_TERMINATION_FACTORY_H__*/
|
||||
#endif /* MPF_RTP_TERMINATION_FACTORY_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_scheduler.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_SCHEDULER_H__
|
||||
#define __MPF_SCHEDULER_H__
|
||||
#ifndef MPF_SCHEDULER_H
|
||||
#define MPF_SCHEDULER_H
|
||||
|
||||
/**
|
||||
* @file mpf_scheduler.h
|
||||
@@ -63,4 +65,4 @@ MPF_DECLARE(apt_bool_t) mpf_scheduler_stop(mpf_scheduler_t *scheduler);
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_SCHEDULER_H__*/
|
||||
#endif /* MPF_SCHEDULER_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_stream.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_STREAM_H__
|
||||
#define __MPF_STREAM_H__
|
||||
#ifndef MPF_STREAM_H
|
||||
#define MPF_STREAM_H
|
||||
|
||||
/**
|
||||
* @file mpf_stream.h
|
||||
@@ -166,4 +168,4 @@ MPF_DECLARE(void) mpf_audio_stream_trace(mpf_audio_stream_t *stream, mpf_stream_
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_STREAM_H__*/
|
||||
#endif /* MPF_STREAM_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_stream_descriptor.h 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_STREAM_DESCRIPTOR_H__
|
||||
#define __MPF_STREAM_DESCRIPTOR_H__
|
||||
#ifndef MPF_STREAM_DESCRIPTOR_H
|
||||
#define MPF_STREAM_DESCRIPTOR_H
|
||||
|
||||
/**
|
||||
* @file mpf_stream_descriptor.h
|
||||
@@ -85,4 +87,4 @@ static APR_INLINE mpf_stream_direction_e mpf_stream_reverse_direction_get(mpf_st
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_STREAM_DESCRIPTOR_H__*/
|
||||
#endif /* MPF_STREAM_DESCRIPTOR_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_termination.h 1693 2010-05-16 18:33:07Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_TERMINATION_H__
|
||||
#define __MPF_TERMINATION_H__
|
||||
#ifndef MPF_TERMINATION_H
|
||||
#define MPF_TERMINATION_H
|
||||
|
||||
/**
|
||||
* @file mpf_termination.h
|
||||
@@ -23,6 +25,7 @@
|
||||
*/
|
||||
|
||||
#include "mpf_types.h"
|
||||
#include "apt_timer_queue.h"
|
||||
|
||||
APT_BEGIN_EXTERN_C
|
||||
|
||||
@@ -50,6 +53,8 @@ struct mpf_termination_vtable_t {
|
||||
struct mpf_termination_t {
|
||||
/** Pool to allocate memory from */
|
||||
apr_pool_t *pool;
|
||||
/** Informative name used for debugging */
|
||||
const char *name;
|
||||
/** External object */
|
||||
void *obj;
|
||||
/** Object to send events to */
|
||||
@@ -58,8 +63,8 @@ struct mpf_termination_t {
|
||||
mpf_termination_event_handler_f event_handler;
|
||||
/** Codec manager */
|
||||
const mpf_codec_manager_t *codec_manager;
|
||||
/** Timer manager */
|
||||
mpf_timer_manager_t *timer_manager;
|
||||
/** Timer queue */
|
||||
apt_timer_queue_t *timer_queue;
|
||||
/** Termination factory entire termination created by */
|
||||
mpf_termination_factory_t *termination_factory;
|
||||
/** Table of virtual methods */
|
||||
@@ -113,4 +118,4 @@ MPF_DECLARE(apt_bool_t) mpf_termination_subtract(mpf_termination_t *termination)
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_TERMINATION_H__*/
|
||||
#endif /* MPF_TERMINATION_H */
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_termination_factory.h 1693 2010-05-16 18:33:07Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_TERMINATION_FACTORY_H__
|
||||
#define __MPF_TERMINATION_FACTORY_H__
|
||||
#ifndef MPF_TERMINATION_FACTORY_H
|
||||
#define MPF_TERMINATION_FACTORY_H
|
||||
|
||||
/**
|
||||
* @file mpf_termination_factory.h
|
||||
@@ -64,25 +66,31 @@ MPF_DECLARE(mpf_termination_t*) mpf_raw_termination_create(
|
||||
*/
|
||||
MPF_DECLARE(apt_bool_t) mpf_termination_destroy(mpf_termination_t *termination);
|
||||
|
||||
/**
|
||||
* Get termination name.
|
||||
* @param termination the termination to get name of
|
||||
*/
|
||||
MPF_DECLARE(const char*) mpf_termination_name_get(const mpf_termination_t *termination);
|
||||
|
||||
/**
|
||||
* Get associated object.
|
||||
* @param termination the termination to get object from
|
||||
*/
|
||||
MPF_DECLARE(void*) mpf_termination_object_get(mpf_termination_t *termination);
|
||||
MPF_DECLARE(void*) mpf_termination_object_get(const mpf_termination_t *termination);
|
||||
|
||||
/**
|
||||
* Get audio stream.
|
||||
* @param termination the termination to get audio stream from
|
||||
*/
|
||||
MPF_DECLARE(mpf_audio_stream_t*) mpf_termination_audio_stream_get(mpf_termination_t *termination);
|
||||
MPF_DECLARE(mpf_audio_stream_t*) mpf_termination_audio_stream_get(const mpf_termination_t *termination);
|
||||
|
||||
/**
|
||||
* Get video stream.
|
||||
* @param termination the termination to get video stream from
|
||||
*/
|
||||
MPF_DECLARE(mpf_video_stream_t*) mpf_termination_video_stream_get(mpf_termination_t *termination);
|
||||
MPF_DECLARE(mpf_video_stream_t*) mpf_termination_video_stream_get(const mpf_termination_t *termination);
|
||||
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_TERMINATION_FACTORY_H__*/
|
||||
#endif /* MPF_TERMINATION_FACTORY_H */
|
||||
@@ -1,53 +0,0 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (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.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
#ifndef __MPF_TIMER_MANAGER_H__
|
||||
#define __MPF_TIMER_MANAGER_H__
|
||||
|
||||
/**
|
||||
* @file mpf_timer_manager.h
|
||||
* @brief MPF Timer Management
|
||||
*/
|
||||
|
||||
#include "mpf_types.h"
|
||||
|
||||
APT_BEGIN_EXTERN_C
|
||||
|
||||
|
||||
/** Prototype of timer callback */
|
||||
typedef void (*mpf_timer_proc_f)(mpf_timer_t *timer, void *obj);
|
||||
|
||||
|
||||
/** Create timer manager */
|
||||
MPF_DECLARE(mpf_timer_manager_t*) mpf_timer_manager_create(mpf_scheduler_t *scheduler, apr_pool_t *pool);
|
||||
|
||||
/** Destroy timer manager */
|
||||
MPF_DECLARE(void) mpf_timer_manager_destroy(mpf_timer_manager_t *timer_manager);
|
||||
|
||||
|
||||
/** Create timer */
|
||||
MPF_DECLARE(mpf_timer_t*) mpf_timer_create(mpf_timer_manager_t *timer_manager, mpf_timer_proc_f proc, void *obj, apr_pool_t *pool);
|
||||
|
||||
/** Set one-shot timer */
|
||||
MPF_DECLARE(apt_bool_t) mpf_timer_set(mpf_timer_t *timer, apr_uint32_t timeout);
|
||||
|
||||
/** Kill timer */
|
||||
MPF_DECLARE(apt_bool_t) mpf_timer_kill(mpf_timer_t *timer);
|
||||
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_TIMER_MANAGER_H__*/
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,10 +12,12 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_types.h 1543 2010-02-24 21:46:24Z achaloyan $
|
||||
*/
|
||||
|
||||
#ifndef __MPF_TYPES_H__
|
||||
#define __MPF_TYPES_H__
|
||||
#ifndef MPF_TYPES_H
|
||||
#define MPF_TYPES_H
|
||||
|
||||
/**
|
||||
* @file mpf_types.h
|
||||
@@ -35,12 +37,6 @@ typedef struct mpf_scheduler_t mpf_scheduler_t;
|
||||
/** Opaque codec manager declaration */
|
||||
typedef struct mpf_codec_manager_t mpf_codec_manager_t;
|
||||
|
||||
/** Opaque MPF timer manager declaration */
|
||||
typedef struct mpf_timer_manager_t mpf_timer_manager_t;
|
||||
|
||||
/** Opaque MPF timer declaration */
|
||||
typedef struct mpf_timer_t mpf_timer_t;
|
||||
|
||||
/** Opaque MPF context declaration */
|
||||
typedef struct mpf_context_t mpf_context_t;
|
||||
|
||||
@@ -59,4 +55,4 @@ typedef struct mpf_video_stream_t mpf_video_stream_t;
|
||||
|
||||
APT_END_EXTERN_C
|
||||
|
||||
#endif /*__MPF_TYPES_H__*/
|
||||
#endif /* MPF_TYPES_H */
|
||||
@@ -1,567 +0,0 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="mpf"
|
||||
ProjectGUID="{B5A00BFA-6083-4FAE-A097-71642D6473B5}"
|
||||
RootNamespace="mpf"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="131072"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
<Platform
|
||||
Name="x64"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
InheritedPropertySheets="$(ProjectDir)..\..\build\vsprops\unidebug.vsprops;$(ProjectDir)..\..\build\vsprops\mpf.vsprops"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="codecs"
|
||||
PreprocessorDefinitions="APT_STATIC_LIB;MPF_STATIC_LIB"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Debug|x64"
|
||||
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
InheritedPropertySheets="$(ProjectDir)..\..\build\vsprops\unidebug.vsprops;$(ProjectDir)..\..\build\vsprops\mpf.vsprops"
|
||||
CharacterSet="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TargetEnvironment="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="codecs"
|
||||
PreprocessorDefinitions="APT_STATIC_LIB;MPF_STATIC_LIB"
|
||||
WarnAsError="false"
|
||||
DebugInformationFormat="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
InheritedPropertySheets="$(ProjectDir)..\..\build\vsprops\unirelease.vsprops;$(ProjectDir)..\..\build\vsprops\mpf.vsprops"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="codecs"
|
||||
PreprocessorDefinitions="APT_STATIC_LIB;MPF_STATIC_LIB"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
<Configuration
|
||||
Name="Release|x64"
|
||||
OutputDirectory="$(SolutionDir)$(PlatformName)\$(ConfigurationName)"
|
||||
IntermediateDirectory="$(PlatformName)\$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
InheritedPropertySheets="$(ProjectDir)..\..\build\vsprops\unirelease.vsprops;$(ProjectDir)..\..\build\vsprops\mpf.vsprops"
|
||||
CharacterSet="1"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
TargetEnvironment="3"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
AdditionalIncludeDirectories="codecs"
|
||||
PreprocessorDefinitions="APT_STATIC_LIB;MPF_STATIC_LIB"
|
||||
WarnAsError="false"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCManagedResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCResourceCompilerTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPreLinkEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLibrarianTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCALinkTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXDCMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCBscMakeTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCFxCopTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCPostBuildEventTool"
|
||||
/>
|
||||
</Configuration>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="codecs"
|
||||
>
|
||||
<Filter
|
||||
Name="g711"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\codecs\g711\g711.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\codecs\g711\g711.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="include"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\include\mpf.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_activity_detector.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_audio_file_descriptor.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_audio_file_stream.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_bridge.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_buffer.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_codec.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_codec_descriptor.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_codec_manager.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_context.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_decoder.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_dtmf_detector.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_dtmf_generator.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_encoder.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_engine.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_file_termination_factory.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_frame.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_frame_buffer.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_jitter_buffer.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_message.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_mixer.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_multiplier.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_named_event.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_object.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_resampler.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_rtcp_packet.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_rtp_attribs.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_rtp_defs.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_rtp_descriptor.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_rtp_header.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_rtp_pt.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_rtp_stat.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_rtp_stream.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_rtp_termination_factory.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_scheduler.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_stream.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_stream_descriptor.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_termination.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_termination_factory.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_timer_manager.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_types.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="src"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\src\mpf_activity_detector.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mpf_audio_file_stream.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mpf_bridge.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mpf_buffer.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mpf_codec_descriptor.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mpf_codec_g711.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mpf_codec_linear.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mpf_codec_manager.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mpf_context.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mpf_decoder.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mpf_dtmf_detector.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mpf_dtmf_generator.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mpf_encoder.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mpf_engine.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mpf_file_termination_factory.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mpf_frame_buffer.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mpf_jitter_buffer.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mpf_mixer.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mpf_multiplier.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mpf_named_event.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mpf_resampler.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mpf_rtp_attribs.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mpf_rtp_stream.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mpf_rtp_termination_factory.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mpf_scheduler.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mpf_stream.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mpf_termination.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mpf_termination_factory.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mpf_timer_manager.c"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
||||
@@ -1,193 +0,0 @@
|
||||
<?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>mpf</ProjectName>
|
||||
<ProjectGuid>{B5A00BFA-6083-4FAE-A097-71642D6473B5}</ProjectGuid>
|
||||
<RootNamespace>mpf</RootNamespace>
|
||||
<Keyword>Win32Proj</Keyword>
|
||||
</PropertyGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</CharacterSet>
|
||||
<WholeProgramOptimization>true</WholeProgramOptimization>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
|
||||
<ConfigurationType>StaticLibrary</ConfigurationType>
|
||||
<CharacterSet>Unicode</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="$(ProjectDir)..\..\build\vsprops\unirelease.props" />
|
||||
<Import Project="$(ProjectDir)..\..\build\vsprops\mpf.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="$(ProjectDir)..\..\build\vsprops\unidebug.props" />
|
||||
<Import Project="$(ProjectDir)..\..\build\vsprops\mpf.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="$(ProjectDir)..\..\build\vsprops\unirelease.props" />
|
||||
<Import Project="$(ProjectDir)..\..\build\vsprops\mpf.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="$(ProjectDir)..\..\build\vsprops\unidebug.props" />
|
||||
<Import Project="$(ProjectDir)..\..\build\vsprops\mpf.props" />
|
||||
</ImportGroup>
|
||||
<PropertyGroup Label="UserMacros" />
|
||||
<PropertyGroup>
|
||||
<_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(PlatformName)\$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(PlatformName)\$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(PlatformName)\$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(PlatformName)\$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(PlatformName)\$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(PlatformName)\$(Configuration)\</IntDir>
|
||||
<OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(PlatformName)\$(Configuration)\</OutDir>
|
||||
<IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(PlatformName)\$(Configuration)\</IntDir>
|
||||
</PropertyGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>codecs;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>APT_STATIC_LIB;MPF_STATIC_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
|
||||
<Midl>
|
||||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>codecs;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>APT_STATIC_LIB;MPF_STATIC_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
<DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>codecs;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>APT_STATIC_LIB;MPF_STATIC_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
|
||||
<Midl>
|
||||
<TargetEnvironment>X64</TargetEnvironment>
|
||||
</Midl>
|
||||
<ClCompile>
|
||||
<AdditionalIncludeDirectories>codecs;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
|
||||
<PreprocessorDefinitions>APT_STATIC_LIB;MPF_STATIC_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
|
||||
<TreatWarningAsError>false</TreatWarningAsError>
|
||||
</ClCompile>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="codecs\g711\g711.c" />
|
||||
<ClCompile Include="src\mpf_activity_detector.c" />
|
||||
<ClCompile Include="src\mpf_audio_file_stream.c" />
|
||||
<ClCompile Include="src\mpf_bridge.c" />
|
||||
<ClCompile Include="src\mpf_buffer.c" />
|
||||
<ClCompile Include="src\mpf_codec_descriptor.c" />
|
||||
<ClCompile Include="src\mpf_codec_g711.c" />
|
||||
<ClCompile Include="src\mpf_codec_linear.c" />
|
||||
<ClCompile Include="src\mpf_codec_manager.c" />
|
||||
<ClCompile Include="src\mpf_context.c" />
|
||||
<ClCompile Include="src\mpf_decoder.c" />
|
||||
<ClCompile Include="src\mpf_dtmf_detector.c" />
|
||||
<ClCompile Include="src\mpf_dtmf_generator.c" />
|
||||
<ClCompile Include="src\mpf_encoder.c" />
|
||||
<ClCompile Include="src\mpf_engine.c" />
|
||||
<ClCompile Include="src\mpf_file_termination_factory.c" />
|
||||
<ClCompile Include="src\mpf_frame_buffer.c" />
|
||||
<ClCompile Include="src\mpf_jitter_buffer.c" />
|
||||
<ClCompile Include="src\mpf_mixer.c" />
|
||||
<ClCompile Include="src\mpf_multiplier.c" />
|
||||
<ClCompile Include="src\mpf_named_event.c" />
|
||||
<ClCompile Include="src\mpf_resampler.c" />
|
||||
<ClCompile Include="src\mpf_rtp_attribs.c" />
|
||||
<ClCompile Include="src\mpf_rtp_stream.c" />
|
||||
<ClCompile Include="src\mpf_rtp_termination_factory.c" />
|
||||
<ClCompile Include="src\mpf_scheduler.c" />
|
||||
<ClCompile Include="src\mpf_stream.c" />
|
||||
<ClCompile Include="src\mpf_termination.c" />
|
||||
<ClCompile Include="src\mpf_termination_factory.c" />
|
||||
<ClCompile Include="src\mpf_timer_manager.c" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="codecs\g711\g711.h" />
|
||||
<ClInclude Include="include\mpf.h" />
|
||||
<ClInclude Include="include\mpf_activity_detector.h" />
|
||||
<ClInclude Include="include\mpf_audio_file_descriptor.h" />
|
||||
<ClInclude Include="include\mpf_audio_file_stream.h" />
|
||||
<ClInclude Include="include\mpf_bridge.h" />
|
||||
<ClInclude Include="include\mpf_buffer.h" />
|
||||
<ClInclude Include="include\mpf_codec.h" />
|
||||
<ClInclude Include="include\mpf_codec_descriptor.h" />
|
||||
<ClInclude Include="include\mpf_codec_manager.h" />
|
||||
<ClInclude Include="include\mpf_context.h" />
|
||||
<ClInclude Include="include\mpf_decoder.h" />
|
||||
<ClInclude Include="include\mpf_dtmf_detector.h" />
|
||||
<ClInclude Include="include\mpf_dtmf_generator.h" />
|
||||
<ClInclude Include="include\mpf_encoder.h" />
|
||||
<ClInclude Include="include\mpf_engine.h" />
|
||||
<ClInclude Include="include\mpf_file_termination_factory.h" />
|
||||
<ClInclude Include="include\mpf_frame.h" />
|
||||
<ClInclude Include="include\mpf_frame_buffer.h" />
|
||||
<ClInclude Include="include\mpf_jitter_buffer.h" />
|
||||
<ClInclude Include="include\mpf_message.h" />
|
||||
<ClInclude Include="include\mpf_mixer.h" />
|
||||
<ClInclude Include="include\mpf_multiplier.h" />
|
||||
<ClInclude Include="include\mpf_named_event.h" />
|
||||
<ClInclude Include="include\mpf_object.h" />
|
||||
<ClInclude Include="include\mpf_resampler.h" />
|
||||
<ClInclude Include="include\mpf_rtcp_packet.h" />
|
||||
<ClInclude Include="include\mpf_rtp_attribs.h" />
|
||||
<ClInclude Include="include\mpf_rtp_defs.h" />
|
||||
<ClInclude Include="include\mpf_rtp_descriptor.h" />
|
||||
<ClInclude Include="include\mpf_rtp_header.h" />
|
||||
<ClInclude Include="include\mpf_rtp_pt.h" />
|
||||
<ClInclude Include="include\mpf_rtp_stat.h" />
|
||||
<ClInclude Include="include\mpf_rtp_stream.h" />
|
||||
<ClInclude Include="include\mpf_rtp_termination_factory.h" />
|
||||
<ClInclude Include="include\mpf_scheduler.h" />
|
||||
<ClInclude Include="include\mpf_stream.h" />
|
||||
<ClInclude Include="include\mpf_stream_descriptor.h" />
|
||||
<ClInclude Include="include\mpf_termination.h" />
|
||||
<ClInclude Include="include\mpf_termination_factory.h" />
|
||||
<ClInclude Include="include\mpf_timer_manager.h" />
|
||||
<ClInclude Include="include\mpf_types.h" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
|
||||
<ImportGroup Label="ExtensionTargets">
|
||||
</ImportGroup>
|
||||
</Project>
|
||||
@@ -1,239 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<Project ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<ItemGroup>
|
||||
<Filter Include="codecs">
|
||||
<UniqueIdentifier>{3d69fc35-a195-4376-9508-ef77d7b27e71}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="codecs\g711">
|
||||
<UniqueIdentifier>{81e2eace-c57a-4135-92cd-cc3575dfb088}</UniqueIdentifier>
|
||||
</Filter>
|
||||
<Filter Include="include">
|
||||
<UniqueIdentifier>{93995380-89BD-4b04-88EB-625FBE52EBFB}</UniqueIdentifier>
|
||||
<Extensions>h;hpp;hxx;hm;inl;inc;xsd</Extensions>
|
||||
</Filter>
|
||||
<Filter Include="src">
|
||||
<UniqueIdentifier>{6fc3533a-b688-477d-914d-e0ffb15aa9a9}</UniqueIdentifier>
|
||||
<Extensions>cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx</Extensions>
|
||||
</Filter>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="codecs\g711\g711.c">
|
||||
<Filter>codecs\g711</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mpf_activity_detector.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mpf_audio_file_stream.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mpf_bridge.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mpf_buffer.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mpf_codec_descriptor.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mpf_codec_g711.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mpf_codec_linear.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mpf_codec_manager.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mpf_context.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mpf_decoder.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mpf_dtmf_detector.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mpf_dtmf_generator.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mpf_encoder.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mpf_engine.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mpf_file_termination_factory.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mpf_frame_buffer.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mpf_jitter_buffer.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mpf_mixer.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mpf_multiplier.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mpf_named_event.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mpf_resampler.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mpf_rtp_attribs.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mpf_rtp_stream.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mpf_rtp_termination_factory.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mpf_scheduler.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mpf_stream.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mpf_termination.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mpf_termination_factory.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="src\mpf_timer_manager.c">
|
||||
<Filter>src</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClInclude Include="codecs\g711\g711.h">
|
||||
<Filter>codecs\g711</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_activity_detector.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_audio_file_descriptor.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_audio_file_stream.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_bridge.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_buffer.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_codec.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_codec_descriptor.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_codec_manager.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_context.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_decoder.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_dtmf_detector.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_dtmf_generator.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_encoder.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_engine.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_file_termination_factory.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_frame.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_frame_buffer.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_jitter_buffer.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_message.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_mixer.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_multiplier.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_named_event.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_object.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_resampler.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_rtcp_packet.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_rtp_attribs.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_rtp_defs.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_rtp_descriptor.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_rtp_header.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_rtp_pt.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_rtp_stat.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_rtp_stream.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_rtp_termination_factory.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_scheduler.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_stream.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_stream_descriptor.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_termination.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_termination_factory.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_timer_manager.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="include\mpf_types.h">
|
||||
<Filter>include</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -416,10 +416,6 @@
|
||||
RelativePath=".\include\mpf_termination_factory.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_timer_manager.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\include\mpf_types.h"
|
||||
>
|
||||
@@ -541,10 +537,6 @@
|
||||
RelativePath=".\src\mpf_termination_factory.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\src\mpf_timer_manager.c"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,6 +12,8 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_activity_detector.c 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#include "mpf_activity_detector.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,6 +12,8 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_audio_file_stream.c 1474 2010-02-07 20:51:47Z achaloyan $
|
||||
*/
|
||||
|
||||
#include "mpf_audio_file_stream.h"
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2008 Arsen Chaloyan
|
||||
* Copyright 2008-2010 Arsen Chaloyan
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -12,6 +12,8 @@
|
||||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*
|
||||
* $Id: mpf_bridge.c 1693 2010-05-16 18:33:07Z achaloyan $
|
||||
*/
|
||||
|
||||
#include "mpf_bridge.h"
|
||||
@@ -31,7 +33,8 @@ struct mpf_bridge_t {
|
||||
mpf_audio_stream_t *source;
|
||||
/** Audio stream sink */
|
||||
mpf_audio_stream_t *sink;
|
||||
|
||||
/** Codec used in case of null bridge */
|
||||
mpf_codec_t *codec;
|
||||
/** Media frame used to read data from source and write it to sink */
|
||||
mpf_frame_t frame;
|
||||
};
|
||||
@@ -57,7 +60,14 @@ static apt_bool_t mpf_null_bridge_process(mpf_object_t *object)
|
||||
{
|
||||
mpf_bridge_t *bridge = (mpf_bridge_t*) object;
|
||||
bridge->frame.type = MEDIA_FRAME_TYPE_NONE;
|
||||
bridge->frame.marker = MPF_MARKER_NONE;
|
||||
bridge->source->vtable->read_frame(bridge->source,&bridge->frame);
|
||||
|
||||
if((bridge->frame.type & MEDIA_FRAME_TYPE_AUDIO) == 0) {
|
||||
/* generate silence frame */
|
||||
mpf_codec_initialize(bridge->codec,&bridge->frame.codec_frame);
|
||||
}
|
||||
|
||||
bridge->sink->vtable->write_frame(bridge->sink,&bridge->frame);
|
||||
return TRUE;
|
||||
}
|
||||
@@ -80,20 +90,20 @@ static void mpf_bridge_trace(mpf_object_t *object)
|
||||
mpf_audio_stream_trace(bridge->sink,STREAM_DIRECTION_SEND,&output);
|
||||
|
||||
*output.pos = '\0';
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_INFO,output.text.buf);
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_INFO,"Media Path %s %s",object->name,output.text.buf);
|
||||
}
|
||||
|
||||
|
||||
static apt_bool_t mpf_bridge_destroy(mpf_object_t *object)
|
||||
{
|
||||
mpf_bridge_t *bridge = (mpf_bridge_t*) object;
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Destroy Audio Bridge");
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Destroy Audio Bridge %s",object->name);
|
||||
mpf_audio_stream_rx_close(bridge->source);
|
||||
mpf_audio_stream_tx_close(bridge->sink);
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
static mpf_bridge_t* mpf_bridge_base_create(mpf_audio_stream_t *source, mpf_audio_stream_t *sink, apr_pool_t *pool)
|
||||
static mpf_bridge_t* mpf_bridge_base_create(mpf_audio_stream_t *source, mpf_audio_stream_t *sink, const char *name, apr_pool_t *pool)
|
||||
{
|
||||
mpf_bridge_t *bridge;
|
||||
if(!source || !sink) {
|
||||
@@ -103,20 +113,21 @@ static mpf_bridge_t* mpf_bridge_base_create(mpf_audio_stream_t *source, mpf_audi
|
||||
bridge = apr_palloc(pool,sizeof(mpf_bridge_t));
|
||||
bridge->source = source;
|
||||
bridge->sink = sink;
|
||||
mpf_object_init(&bridge->base);
|
||||
bridge->codec = NULL;
|
||||
mpf_object_init(&bridge->base,name);
|
||||
bridge->base.destroy = mpf_bridge_destroy;
|
||||
bridge->base.process = mpf_bridge_process;
|
||||
bridge->base.trace = mpf_bridge_trace;
|
||||
return bridge;
|
||||
}
|
||||
|
||||
static mpf_object_t* mpf_linear_bridge_create(mpf_audio_stream_t *source, mpf_audio_stream_t *sink, const mpf_codec_manager_t *codec_manager, apr_pool_t *pool)
|
||||
static mpf_object_t* mpf_linear_bridge_create(mpf_audio_stream_t *source, mpf_audio_stream_t *sink, const mpf_codec_manager_t *codec_manager, const char *name, apr_pool_t *pool)
|
||||
{
|
||||
mpf_codec_descriptor_t *descriptor;
|
||||
apr_size_t frame_size;
|
||||
mpf_bridge_t *bridge;
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Create Linear Audio Bridge");
|
||||
bridge = mpf_bridge_base_create(source,sink,pool);
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Create Linear Audio Bridge %s",name);
|
||||
bridge = mpf_bridge_base_create(source,sink,name,pool);
|
||||
if(!bridge) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -136,13 +147,13 @@ static mpf_object_t* mpf_linear_bridge_create(mpf_audio_stream_t *source, mpf_au
|
||||
return &bridge->base;
|
||||
}
|
||||
|
||||
static mpf_object_t* mpf_null_bridge_create(mpf_audio_stream_t *source, mpf_audio_stream_t *sink, const mpf_codec_manager_t *codec_manager, apr_pool_t *pool)
|
||||
static mpf_object_t* mpf_null_bridge_create(mpf_audio_stream_t *source, mpf_audio_stream_t *sink, const mpf_codec_manager_t *codec_manager, const char *name, apr_pool_t *pool)
|
||||
{
|
||||
mpf_codec_t *codec;
|
||||
apr_size_t frame_size;
|
||||
mpf_bridge_t *bridge;
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Create Null Audio Bridge");
|
||||
bridge = mpf_bridge_base_create(source,sink,pool);
|
||||
apt_log(APT_LOG_MARK,APT_PRIO_DEBUG,"Create Null Audio Bridge %s",name);
|
||||
bridge = mpf_bridge_base_create(source,sink,name,pool);
|
||||
if(!bridge) {
|
||||
return NULL;
|
||||
}
|
||||
@@ -154,6 +165,7 @@ static mpf_object_t* mpf_null_bridge_create(mpf_audio_stream_t *source, mpf_audi
|
||||
}
|
||||
|
||||
frame_size = mpf_codec_frame_size_calculate(source->rx_descriptor,codec->attribs);
|
||||
bridge->codec = codec;
|
||||
bridge->frame.codec_frame.size = frame_size;
|
||||
bridge->frame.codec_frame.buffer = apr_palloc(pool,frame_size);
|
||||
|
||||
@@ -167,7 +179,12 @@ static mpf_object_t* mpf_null_bridge_create(mpf_audio_stream_t *source, mpf_audi
|
||||
return &bridge->base;
|
||||
}
|
||||
|
||||
MPF_DECLARE(mpf_object_t*) mpf_bridge_create(mpf_audio_stream_t *source, mpf_audio_stream_t *sink, const mpf_codec_manager_t *codec_manager, apr_pool_t *pool)
|
||||
MPF_DECLARE(mpf_object_t*) mpf_bridge_create(
|
||||
mpf_audio_stream_t *source,
|
||||
mpf_audio_stream_t *sink,
|
||||
const mpf_codec_manager_t *codec_manager,
|
||||
const char *name,
|
||||
apr_pool_t *pool)
|
||||
{
|
||||
if(!source || !sink) {
|
||||
return NULL;
|
||||
@@ -179,7 +196,7 @@ MPF_DECLARE(mpf_object_t*) mpf_bridge_create(mpf_audio_stream_t *source, mpf_aud
|
||||
}
|
||||
|
||||
if(mpf_codec_descriptors_match(source->rx_descriptor,sink->tx_descriptor) == TRUE) {
|
||||
return mpf_null_bridge_create(source,sink,codec_manager,pool);
|
||||
return mpf_null_bridge_create(source,sink,codec_manager,name,pool);
|
||||
}
|
||||
|
||||
if(mpf_codec_lpcm_descriptor_match(source->rx_descriptor) == FALSE) {
|
||||
@@ -209,5 +226,5 @@ MPF_DECLARE(mpf_object_t*) mpf_bridge_create(mpf_audio_stream_t *source, mpf_aud
|
||||
source = resampler;
|
||||
}
|
||||
|
||||
return mpf_linear_bridge_create(source,sink,codec_manager,pool);
|
||||
return mpf_linear_bridge_create(source,sink,codec_manager,name,pool);
|
||||
}
|
||||
Loaded 100 of 441 files, more files were not shown because too many files have changed in this diff.
Show more
Reference in new issue
Block a user