inital checkin of unimrcp svn revision 985 from http://unimrcp.googlecode.com/svn/trunk/

git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@13790 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
Michael Jerris committed 2009-06-16 22:31:19 +00:00
1 parent ec90221783
commit da925bddf8
349 files changed
+47866

No files matched your search

@@ -0,0 +1,9 @@
MAINTAINERCLEANFILES = Makefile.in
INCLUDES = -I$(top_srcdir)/libs/apr-toolkit/include \
$(UNIMRCP_APR_INCLUDES) $(UNIMRCP_APU_INCLUDES)
noinst_PROGRAMS = strtablegen
strtablegen_LDADD = $(top_builddir)/libs/apr-toolkit/libaprtoolkit.la \
$(UNIMRCP_APR_LIBS) $(UNIMRCP_APU_LIBS)
strtablegen_SOURCES = src/main.c
+143
View File
@@ -0,0 +1,143 @@
/*
* 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 <stdio.h>
#include "apt_pool.h"
#include "apt_string_table.h"
#include "apt_text_stream.h"
static apt_bool_t is_unique(const apt_str_table_item_t table[], apr_size_t count,
apr_size_t item_index, apr_size_t char_index, char value)
{
size_t i;
const char *buf;
for(i=0; i<count; i++) {
buf = table[i].value.buf;
if(i != item_index && char_index < table[i].value.length &&
tolower(value) == tolower(buf[char_index])) {
return FALSE;
}
}
return TRUE;
}
static apt_bool_t string_table_key_generate(apt_str_table_item_t table[], apr_size_t count)
{
size_t i,j;
size_t length;
for(i=0; i<count; i++) {
length = table[i].value.length;
table[i].key = length;
for(j=0; j<length; j++) {
if(is_unique(table,count,i,j,table[i].value.buf[j]) == TRUE) {
table[i].key = j;
break;
}
}
}
return TRUE;
}
#define TEST_BUFFER_SIZE 2048
static char parse_buffer[TEST_BUFFER_SIZE];
static size_t string_table_read(apt_str_table_item_t table[], apr_size_t max_count, FILE *file, apr_pool_t *pool)
{
apt_str_table_item_t *item;
size_t count = 0;
apt_str_t line;
apt_text_stream_t text_stream;
text_stream.text.length = fread(parse_buffer, 1, sizeof(parse_buffer)-1, file);
parse_buffer[text_stream.text.length] = '\0';
text_stream.text.buf = parse_buffer;
text_stream.pos = parse_buffer;
do {
if(apt_text_line_read(&text_stream,&line) == FALSE || !line.length) {
break;
}
item = &table[count];
apt_string_copy(&item->value,&line,pool);
item->key = 0;
count++;
}
while(count < max_count);
return count;
}
static apt_bool_t string_table_write(const apt_str_table_item_t table[], apr_size_t count, FILE *file)
{
size_t i;
const apt_str_table_item_t *item;
for(i=0; i<count; i++) {
item = &table[i];
fprintf(file,"{{\"%s\",%"APR_SIZE_T_FMT"},%"APR_SIZE_T_FMT"},\r\n",
item->value.buf, item->value.length, item->key);
}
return TRUE;
}
int main(int argc, char *argv[])
{
apr_pool_t *pool = NULL;
apt_str_table_item_t table[100];
size_t count;
FILE *file_in, *file_out;
/* one time apr global initialization */
if(apr_initialize() != APR_SUCCESS) {
return 0;
}
pool = apt_pool_create();
if(argc < 2) {
printf("usage: stringtablegen stringtable.in [stringtable.out]\n");
return 0;
}
file_in = fopen(argv[1], "rb");
if(file_in == NULL) {
printf("cannot open file %s\n", argv[1]);
return 0;
}
if(argc > 2) {
file_out = fopen(argv[2], "wb");
}
else {
file_out = stdout;
}
/* read items (strings) from the file */
count = string_table_read(table,100,file_in,pool);
/* generate string table */
string_table_key_generate(table,count);
/* dump string table to the file */
string_table_write(table,count,file_out);
fclose(file_in);
if(file_out != stdout) {
fclose(file_out);
}
apr_pool_destroy(pool);
/* final apr global termination */
apr_terminate();
return 0;
}
@@ -0,0 +1,12 @@
Channel-Identifier
Active-Request-Id-List
Proxy-Sync-Id
Accept-Charset
Content-Type
Content-Id
Content-Base
Content-Encoding
Content-Location
Content-Length
Cache-Control
Logging-Tag
@@ -0,0 +1,163 @@
<?xml version="1.0" encoding="windows-1251"?>
<VisualStudioProject
ProjectType="Visual C++"
Version="8.00"
Name="strtablegen"
ProjectGUID="{79EF9F1D-E211-4ED1-91D2-FC935AB3A872}"
RootNamespace="strtablegen"
>
<Platforms>
<Platform
Name="Win32"
/>
</Platforms>
<ToolFiles>
</ToolFiles>
<Configurations>
<Configuration
Name="Debug|Win32"
ConfigurationType="1"
InheritedPropertySheets="$(SolutionDir)build\vsprops\unidebug.vsprops;$(SolutionDir)build\vsprops\apt.vsprops"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="aprtoolkit.lib libaprutil-1.lib libapr-1.lib"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
<Configuration
Name="Release|Win32"
ConfigurationType="1"
InheritedPropertySheets="$(SolutionDir)build\vsprops\unirelease.vsprops;$(SolutionDir)build\vsprops\apt.vsprops"
>
<Tool
Name="VCPreBuildEventTool"
/>
<Tool
Name="VCCustomBuildTool"
/>
<Tool
Name="VCXMLDataGeneratorTool"
/>
<Tool
Name="VCWebServiceProxyGeneratorTool"
/>
<Tool
Name="VCMIDLTool"
/>
<Tool
Name="VCCLCompilerTool"
/>
<Tool
Name="VCManagedResourceCompilerTool"
/>
<Tool
Name="VCResourceCompilerTool"
/>
<Tool
Name="VCPreLinkEventTool"
/>
<Tool
Name="VCLinkerTool"
AdditionalDependencies="aprtoolkit.lib libaprutil-1.lib libapr-1.lib"
LinkTimeCodeGeneration="1"
/>
<Tool
Name="VCALinkTool"
/>
<Tool
Name="VCManifestTool"
/>
<Tool
Name="VCXDCMakeTool"
/>
<Tool
Name="VCBscMakeTool"
/>
<Tool
Name="VCFxCopTool"
/>
<Tool
Name="VCAppVerifierTool"
/>
<Tool
Name="VCWebDeploymentTool"
/>
<Tool
Name="VCPostBuildEventTool"
/>
</Configuration>
</Configurations>
<References>
</References>
<Files>
<Filter
Name="src"
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
>
<File
RelativePath=".\src\main.c"
>
</File>
</Filter>
<Filter
Name="include"
Filter="h;hpp;hxx;hm;inl;inc;xsd"
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
>
</Filter>
</Files>
<Globals>
</Globals>
</VisualStudioProject>