mirror of
https://github.com/tesseract-ocr/tesseract.git
synced 2024-11-27 20:59:36 +08:00
Changes to cutil for 3.00
git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@292 d0cd1f9f-072b-0410-8dd7-cf729c803f20
This commit is contained in:
parent
694d3f2c20
commit
82071afb86
@ -1,14 +1,15 @@
|
||||
SUBDIRS =
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/ccutil
|
||||
|
||||
EXTRA_DIST = cutil.vcproj
|
||||
|
||||
include_HEADERS = \
|
||||
bitvec.h callcpp.h const.h cutil.h danerror.h debug.h efio.h \
|
||||
bitvec.h callcpp.h const.h cutil.h cutil_class.h danerror.h efio.h \
|
||||
emalloc.h freelist.h funcdefs.h general.h globals.h listio.h \
|
||||
minmax.h oldheap.h oldlist.h structures.h tessarray.h \
|
||||
tordvars.h variables.h
|
||||
oldheap.h oldlist.h structures.h tessarray.h
|
||||
|
||||
lib_LIBRARIES = libtesseract_cutil.a
|
||||
libtesseract_cutil_a_SOURCES = \
|
||||
tessarray.cpp bitvec.cpp cutil.cpp danerror.cpp debug.cpp efio.cpp \
|
||||
bitvec.cpp cutil.cpp cutil_class.cpp danerror.cpp efio.cpp \
|
||||
emalloc.cpp freelist.cpp globals.cpp listio.cpp oldheap.cpp \
|
||||
oldlist.cpp structures.cpp tordvars.cpp variables.cpp
|
||||
oldlist.cpp structures.cpp tessarray.cpp
|
||||
|
@ -57,12 +57,11 @@ AR = ar
|
||||
ARFLAGS = cru
|
||||
libtesseract_cutil_a_AR = $(AR) $(ARFLAGS)
|
||||
libtesseract_cutil_a_LIBADD =
|
||||
am_libtesseract_cutil_a_OBJECTS = tessarray.$(OBJEXT) bitvec.$(OBJEXT) \
|
||||
cutil.$(OBJEXT) danerror.$(OBJEXT) debug.$(OBJEXT) \
|
||||
efio.$(OBJEXT) emalloc.$(OBJEXT) freelist.$(OBJEXT) \
|
||||
globals.$(OBJEXT) listio.$(OBJEXT) oldheap.$(OBJEXT) \
|
||||
oldlist.$(OBJEXT) structures.$(OBJEXT) tordvars.$(OBJEXT) \
|
||||
variables.$(OBJEXT)
|
||||
am_libtesseract_cutil_a_OBJECTS = bitvec.$(OBJEXT) cutil.$(OBJEXT) \
|
||||
cutil_class.$(OBJEXT) danerror.$(OBJEXT) efio.$(OBJEXT) \
|
||||
emalloc.$(OBJEXT) freelist.$(OBJEXT) globals.$(OBJEXT) \
|
||||
listio.$(OBJEXT) oldheap.$(OBJEXT) oldlist.$(OBJEXT) \
|
||||
structures.$(OBJEXT) tessarray.$(OBJEXT)
|
||||
libtesseract_cutil_a_OBJECTS = $(am_libtesseract_cutil_a_OBJECTS)
|
||||
DEFAULT_INCLUDES = -I.@am__isrc@ -I$(top_builddir)
|
||||
depcomp = $(SHELL) $(top_srcdir)/config/depcomp
|
||||
@ -194,17 +193,17 @@ top_builddir = @top_builddir@
|
||||
top_srcdir = @top_srcdir@
|
||||
SUBDIRS =
|
||||
AM_CPPFLAGS = -I$(top_srcdir)/ccutil
|
||||
EXTRA_DIST = cutil.vcproj
|
||||
include_HEADERS = \
|
||||
bitvec.h callcpp.h const.h cutil.h danerror.h debug.h efio.h \
|
||||
bitvec.h callcpp.h const.h cutil.h cutil_class.h danerror.h efio.h \
|
||||
emalloc.h freelist.h funcdefs.h general.h globals.h listio.h \
|
||||
minmax.h oldheap.h oldlist.h structures.h tessarray.h \
|
||||
tordvars.h variables.h
|
||||
oldheap.h oldlist.h structures.h tessarray.h
|
||||
|
||||
lib_LIBRARIES = libtesseract_cutil.a
|
||||
libtesseract_cutil_a_SOURCES = \
|
||||
tessarray.cpp bitvec.cpp cutil.cpp danerror.cpp debug.cpp efio.cpp \
|
||||
bitvec.cpp cutil.cpp cutil_class.cpp danerror.cpp efio.cpp \
|
||||
emalloc.cpp freelist.cpp globals.cpp listio.cpp oldheap.cpp \
|
||||
oldlist.cpp structures.cpp tordvars.cpp variables.cpp
|
||||
oldlist.cpp structures.cpp tessarray.cpp
|
||||
|
||||
all: all-recursive
|
||||
|
||||
@ -281,8 +280,8 @@ distclean-compile:
|
||||
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bitvec.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cutil.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/cutil_class.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/danerror.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/debug.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/efio.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/emalloc.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/freelist.Po@am__quote@
|
||||
@ -292,8 +291,6 @@ distclean-compile:
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/oldlist.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/structures.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tessarray.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/tordvars.Po@am__quote@
|
||||
@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/variables.Po@am__quote@
|
||||
|
||||
.cpp.o:
|
||||
@am__fastdepCXX_TRUE@ $(CXXCOMPILE) -MT $@ -MD -MP -MF $(DEPDIR)/$*.Tpo -c -o $@ $<
|
||||
|
@ -20,15 +20,15 @@
|
||||
#ifndef CALLCPP_H
|
||||
#define CALLCPP_H
|
||||
|
||||
#ifndef __UNIX__
|
||||
#include <assert.h>
|
||||
#endif
|
||||
#include "host.h"
|
||||
#include "varable.h"
|
||||
#include "unichar.h"
|
||||
|
||||
class ScrollView;
|
||||
|
||||
#ifdef __cplusplus
|
||||
//extern "C" {
|
||||
#endif
|
||||
typedef enum {
|
||||
Black,
|
||||
White,
|
||||
@ -87,73 +87,23 @@ extern INT_VAR_H (tess_cp_mapping0, 0, "Mappings for class pruner distance");
|
||||
extern INT_VAR_H (tess_cp_mapping1, 1, "Mappings for class pruner distance");
|
||||
extern INT_VAR_H (tess_cp_mapping2, 2, "Mappings for class pruner distance");
|
||||
extern INT_VAR_H (tess_cp_mapping3, 3, "Mappings for class pruner distance");
|
||||
extern INT_VAR_H (stopper_numbers_on, 0,
|
||||
"Allow numbers to be acceptable choices");
|
||||
extern INT_VAR_H (config_pruner_enabled, 0, "Turn on config pruner");
|
||||
extern INT_VAR_H (feature_prune_percentile, 0, "Percent of features to use");
|
||||
extern INT_VAR_H (newcp_ratings_on, 0, "Use new class pruner normalisation");
|
||||
extern INT_VAR_H (record_matcher_output, 0, "Record detailed matcher info");
|
||||
extern INT_VAR_H (il1_adaption_test, 0,
|
||||
"Dont adapt to i/I at beginning of word");
|
||||
extern double_VAR_H (permuter_pending_threshold, 0.0,
|
||||
"Worst conf for using pending dictionary");
|
||||
extern double_VAR_H (newcp_duff_rating, 0.30,
|
||||
"Worst rating for calling real matcher");
|
||||
extern double_VAR_H (newcp_prune_threshold, 1.2, "Ratio of best to prune");
|
||||
extern double_VAR_H (tessedit_cp_ratio, 0.0, "Ratio from best to prune");
|
||||
|
||||
//Global matcher info from the class pruner.
|
||||
extern inT32 cp_classes;
|
||||
extern inT32 cp_bestindex;
|
||||
extern inT32 cp_bestrating;
|
||||
extern inT32 cp_bestconf;
|
||||
extern char cp_chars[2];
|
||||
extern inT32 cp_ratings[2];
|
||||
extern inT32 cp_confs[2];
|
||||
extern inT32 cp_maps[4];
|
||||
//Global info to control writes of matcher info
|
||||
extern inT32 blob_type; //write control
|
||||
extern char blob_answer[UNICHAR_LEN + 1]; //correct char
|
||||
extern char *word_answer; //correct word
|
||||
extern inT32 matcher_pass; //pass in chopper.c
|
||||
extern inT32 bits_in_states; //no of bits in states
|
||||
|
||||
#ifndef __UNIX__
|
||||
#include <assert.h>
|
||||
#endif
|
||||
void setup_cp_maps();
|
||||
void trace_stack(); //Trace current stack
|
||||
void cprintf ( //Trace printf
|
||||
const char *format, ... //special message
|
||||
);
|
||||
char *c_alloc_string( //allocate string
|
||||
inT32 count //no of chars required
|
||||
);
|
||||
void c_free_string( //free a string
|
||||
char *string //string to free
|
||||
);
|
||||
void *c_alloc_struct( //allocate memory
|
||||
inT32 count, //no of chars required
|
||||
const char *name //class name
|
||||
);
|
||||
void c_free_struct( //free a structure
|
||||
void *deadstruct, //structure to free
|
||||
inT32 count, //no of bytes
|
||||
const char *name //class name
|
||||
);
|
||||
void *c_alloc_mem_p( //allocate permanent space
|
||||
inT32 count //block size to allocate
|
||||
);
|
||||
void *c_alloc_mem( //get some memory
|
||||
inT32 count //no of bytes to get
|
||||
);
|
||||
void c_free_mem( //free mem from alloc_mem
|
||||
void *oldchunk //chunk to free
|
||||
);
|
||||
void c_check_mem( //check consistency
|
||||
const char *string, //context message
|
||||
inT8 level //level of check
|
||||
);
|
||||
ScrollView *c_create_window( /*create a window */
|
||||
const char *name, /*name/title of window */
|
||||
inT16 xpos, /*coords of window */
|
||||
@ -184,7 +134,4 @@ char window_wait(ScrollView* win);
|
||||
void reverse32(void *ptr);
|
||||
void reverse16(void *ptr);
|
||||
|
||||
#ifdef __cplusplus
|
||||
//};
|
||||
#endif
|
||||
#endif
|
||||
|
@ -46,9 +46,6 @@ Import original HP distribution
|
||||
|
||||
#define RESET_COUNT 2000
|
||||
|
||||
void_proc deallocate = (void_proc) c_free_string;
|
||||
char_proc allocate = (char_proc) c_alloc_string;
|
||||
|
||||
/**********************************************************************
|
||||
* long_rand
|
||||
*
|
||||
|
@ -64,7 +64,6 @@ Import original HP distribution
|
||||
|
||||
//typedef int (*int_proc) (void);
|
||||
typedef void (*void_proc) (...);
|
||||
typedef char *(*char_proc) _ARGS ((...));
|
||||
typedef void *(*void_star_proc) _ARGS ((...));
|
||||
|
||||
typedef int (*int_void) (void);
|
||||
@ -72,34 +71,9 @@ typedef void (*void_void) (void);
|
||||
typedef int (*int_compare) (void *, void *);
|
||||
typedef void (*void_dest) (void *);
|
||||
|
||||
extern void_proc deallocate;
|
||||
extern char_proc allocate;
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
M a c r o s
|
||||
----------------------------------------------------------------------*/
|
||||
/**********************************************************************
|
||||
* min
|
||||
*
|
||||
* Minimum of two values
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef min
|
||||
#define min(x,y) \
|
||||
((x) < (y) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
/**********************************************************************
|
||||
* max
|
||||
*
|
||||
* Maximum of two values
|
||||
**********************************************************************/
|
||||
|
||||
#ifndef max
|
||||
#define max(x,y) \
|
||||
((y) < (x) ? (x) : (y))
|
||||
#endif
|
||||
|
||||
/**********************************************************************
|
||||
* new_line
|
||||
*
|
||||
@ -125,7 +99,7 @@ extern char_proc allocate;
|
||||
* to it and return the result.
|
||||
**********************************************************************/
|
||||
|
||||
#define strfree(s) ((*deallocate) (s))
|
||||
#define strfree(s) (free_string(s))
|
||||
|
||||
/**********************************************************************
|
||||
* strsave
|
||||
@ -136,7 +110,7 @@ extern char_proc allocate;
|
||||
|
||||
#define strsave(s) \
|
||||
((s) != NULL ? \
|
||||
((char*) strcpy ((*allocate) (strlen(s)+1), s)) : \
|
||||
((char*) strcpy (alloc_string(strlen(s)+1), s)) : \
|
||||
(NULL))
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
@ -156,4 +130,5 @@ FILE *open_file
|
||||
|
||||
#undef _ARGS
|
||||
*/
|
||||
#include "cutil_class.h"
|
||||
#endif
|
||||
|
289
cutil/cutil.vcproj
Executable file
289
cutil/cutil.vcproj
Executable file
@ -0,0 +1,289 @@
|
||||
<?xml version="1.0" encoding="Windows-1252"?>
|
||||
<VisualStudioProject
|
||||
ProjectType="Visual C++"
|
||||
Version="9.00"
|
||||
Name="cutil"
|
||||
ProjectGUID="{0BDEFC56-679F-436E-A089-81FCAEBA50F3}"
|
||||
RootNamespace="cutil"
|
||||
Keyword="Win32Proj"
|
||||
TargetFrameworkVersion="196613"
|
||||
>
|
||||
<Platforms>
|
||||
<Platform
|
||||
Name="Win32"
|
||||
/>
|
||||
</Platforms>
|
||||
<ToolFiles>
|
||||
</ToolFiles>
|
||||
<Configurations>
|
||||
<Configuration
|
||||
Name="Debug|Win32"
|
||||
OutputDirectory="$(SolutionDir)$(ConfigurationName)"
|
||||
IntermediateDirectory="$(ConfigurationName)"
|
||||
ConfigurationType="4"
|
||||
CharacterSet="2"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="0"
|
||||
AdditionalIncludeDirectories="..\ccutil,..\viewer"
|
||||
PreprocessorDefinitions="WIN32;_DEBUG;_LIB;__MSW32__;_CRT_SECURE_NO_WARNINGS"
|
||||
MinimalRebuild="true"
|
||||
BasicRuntimeChecks="3"
|
||||
RuntimeLibrary="1"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
DebugInformationFormat="4"
|
||||
/>
|
||||
<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"
|
||||
CharacterSet="2"
|
||||
WholeProgramOptimization="1"
|
||||
>
|
||||
<Tool
|
||||
Name="VCPreBuildEventTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCustomBuildTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCXMLDataGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCWebServiceProxyGeneratorTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCMIDLTool"
|
||||
/>
|
||||
<Tool
|
||||
Name="VCCLCompilerTool"
|
||||
Optimization="2"
|
||||
EnableIntrinsicFunctions="true"
|
||||
AdditionalIncludeDirectories="..\ccutil,..\viewer"
|
||||
PreprocessorDefinitions="WIN32;NDEBUG;_LIB;__MSW32__;_CRT_SECURE_NO_WARNINGS"
|
||||
RuntimeLibrary="0"
|
||||
EnableFunctionLevelLinking="true"
|
||||
UsePrecompiledHeader="0"
|
||||
WarningLevel="3"
|
||||
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>
|
||||
</Configurations>
|
||||
<References>
|
||||
</References>
|
||||
<Files>
|
||||
<Filter
|
||||
Name="Source Files"
|
||||
Filter="cpp;c;cc;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\bitvec.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\cutil.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\cutil_class.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\danerror.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\efio.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\emalloc.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\freelist.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\globals.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\listio.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\oldheap.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\oldlist.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\structures.cpp"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\tessarray.cpp"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
Filter="h;hpp;hxx;hm;inl;inc;xsd"
|
||||
UniqueIdentifier="{93995380-89BD-4b04-88EB-625FBE52EBFB}"
|
||||
>
|
||||
<File
|
||||
RelativePath=".\bitvec.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\callcpp.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\const.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\cutil.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\cutil_class.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\danerror.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\efio.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\emalloc.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\freelist.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\funcdefs.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\general.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\globals.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\listio.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\oldheap.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\oldlist.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\structures.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath=".\tessarray.h"
|
||||
>
|
||||
</File>
|
||||
</Filter>
|
||||
<Filter
|
||||
Name="Resource Files"
|
||||
Filter="rc;ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe;resx;tiff;tif;png;wav"
|
||||
UniqueIdentifier="{67DA6AB6-F800-4c08-8B7A-83BB121AAD01}"
|
||||
>
|
||||
</Filter>
|
||||
</Files>
|
||||
<Globals>
|
||||
</Globals>
|
||||
</VisualStudioProject>
|
29
cutil/cutil_class.cpp
Normal file
29
cutil/cutil_class.cpp
Normal file
@ -0,0 +1,29 @@
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// File: cutil.cpp
|
||||
// Description: cutil class.
|
||||
// Author: Samuel Charron
|
||||
//
|
||||
// (C) Copyright 2006, Google Inc.
|
||||
// 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 "cutil_class.h"
|
||||
|
||||
namespace tesseract {
|
||||
|
||||
CUtil::CUtil() {
|
||||
}
|
||||
|
||||
CUtil::~CUtil() {
|
||||
}
|
||||
|
||||
} // namespace tesseract
|
61
cutil/cutil_class.h
Normal file
61
cutil/cutil_class.h
Normal file
@ -0,0 +1,61 @@
|
||||
///////////////////////////////////////////////////////////////////////
|
||||
// File: cutil.h
|
||||
// Description: cutil class.
|
||||
// Author: Samuel Charron
|
||||
//
|
||||
// (C) Copyright 2006, Google Inc.
|
||||
// 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 TESSERACT_CUTIL_CUTIL_CLASS_H__
|
||||
#define TESSERACT_CUTIL_CUTIL_CLASS_H__
|
||||
|
||||
#include "ccutil.h"
|
||||
#include "tessclas.h"
|
||||
#include "const.h"
|
||||
#include "strngs.h"
|
||||
|
||||
namespace tesseract {
|
||||
|
||||
class CUtil : public CCUtil {
|
||||
public:
|
||||
CUtil();
|
||||
~CUtil();
|
||||
void read_variables(const char *filename, bool global_only);
|
||||
public:
|
||||
TBLOB *pageblobs; /*first blob on page */
|
||||
TEXTBLOCK *pageblocks; /*first block on page */
|
||||
|
||||
int resolution; /*scanner res in dpi */
|
||||
int acts[MAXPROC]; /*action flags */
|
||||
int debugs[MAXPROC]; /*debug flags */
|
||||
int plots[MAXPROC]; /*plot flags */
|
||||
|
||||
int corners[4]; /*corners of scan window */
|
||||
|
||||
char *debugfile; /* debug file name */
|
||||
|
||||
int plots_fx;
|
||||
int plots_ocr;
|
||||
|
||||
int debugs_fx;
|
||||
int debugs_ocr;
|
||||
|
||||
int acts_fx;
|
||||
int acts_ocr;
|
||||
|
||||
char *demodir; /*demo home directory */
|
||||
};
|
||||
|
||||
} // namespace tesseract
|
||||
|
||||
#endif // TESSERACT_CUTIL_CUTIL_CLASS_H__
|
@ -1,97 +0,0 @@
|
||||
/* -*-C-*-
|
||||
********************************************************************************
|
||||
*
|
||||
* File: debug.c (Formerly debug.c)
|
||||
* Description: Combinatorial Splitter
|
||||
* Author: Mark Seaman, OCR Technology
|
||||
* Created: Thu Jul 27 08:59:01 1989
|
||||
* Modified: Tue Feb 19 10:34:36 1991 (Mark Seaman) marks@hpgrlt
|
||||
* Language: C
|
||||
* Package: N/A
|
||||
* Status: Experimental (Do Not Distribute)
|
||||
*
|
||||
* (c) Copyright 1989, Hewlett-Packard Company.
|
||||
** 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.
|
||||
*
|
||||
*********************************************************************************/
|
||||
/*----------------------------------------------------------------------
|
||||
I n c l u d e s
|
||||
----------------------------------------------------------------------*/
|
||||
#include <stdio.h>
|
||||
#include "debug.h"
|
||||
#include "callcpp.h"
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
V a r i a b l e s
|
||||
----------------------------------------------------------------------*/
|
||||
MENU_ITEM menu_table[NUM_MENUS][NUM_MENU_ITEMS];
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
F u n c t i o n s
|
||||
----------------------------------------------------------------------*/
|
||||
/**********************************************************************
|
||||
* set_float_value
|
||||
*
|
||||
* Set the value of a floating point variable from the break handler.
|
||||
**********************************************************************/
|
||||
int set_float_value(const char *message, float *variable) {
|
||||
char this_string[CHARS_PER_LINE];
|
||||
|
||||
cprintf ("%s (%7.5f) ? ", message, *variable);
|
||||
fflush(stdout);
|
||||
|
||||
if (fgets (this_string, CHARS_PER_LINE, stdin) == NULL)
|
||||
return (1);
|
||||
|
||||
if (fgets (this_string, CHARS_PER_LINE, stdin) != NULL) {
|
||||
sscanf (this_string, "%f", variable);
|
||||
cprintf ("%s = %7.5f\n", message, *variable);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* set_int_value
|
||||
*
|
||||
* Set the value of a floating point variable from the break handler.
|
||||
**********************************************************************/
|
||||
int set_int_value(const char *message, int *variable) {
|
||||
char this_string[CHARS_PER_LINE];
|
||||
|
||||
cprintf ("%s (%d) ? ", message, *variable);
|
||||
fflush(stdout);
|
||||
|
||||
if (fgets (this_string, CHARS_PER_LINE, stdin) == NULL)
|
||||
return (1);
|
||||
|
||||
if (fgets (this_string, CHARS_PER_LINE, stdin) != NULL) {
|
||||
sscanf (this_string, "%d", variable);
|
||||
cprintf ("%s = %d\n", message, *variable);
|
||||
}
|
||||
return (1);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* make_menu_item
|
||||
*
|
||||
* Create an entry in the menu handler table that will create a menu
|
||||
* entry. When this entry is selected it will invoke the requested
|
||||
* function.
|
||||
**********************************************************************/
|
||||
void make_menu_item(int menu,
|
||||
int menu_item,
|
||||
const char *menu_string,
|
||||
int_void menu_funct) {
|
||||
menu_table[menu][menu_item].menu_string = menu_string;
|
||||
menu_table[menu][menu_item].menu_function = (void_proc) menu_funct;
|
||||
}
|
348
cutil/debug.h
348
cutil/debug.h
@ -1,348 +0,0 @@
|
||||
/* -*-C-*-
|
||||
********************************************************************************
|
||||
*
|
||||
* File: debug.h (Formerly debug.h)
|
||||
* Description: Combinatorial Splitter
|
||||
* Author: Mark Seaman, OCR Technology
|
||||
* Created: Thu Jul 27 08:59:01 1989
|
||||
* Modified: Wed Feb 27 14:38:16 1991 (Mark Seaman) marks@hpgrlt
|
||||
* Language: C
|
||||
* Package: N/A
|
||||
* Status: Experimental (Do Not Distribute)
|
||||
*
|
||||
* (c) Copyright 1989, Hewlett-Packard Company.
|
||||
** 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.
|
||||
*
|
||||
*********************************************************************************/
|
||||
/* To hide variable names for relase to UNLV DONT put the variable names in
|
||||
the executable: Toggle be either defining or not defining SECURE_NAMES
|
||||
This stage prevents the menu construction*/
|
||||
/* #define SECURE_NAMES done in secnames.h when necessary */
|
||||
|
||||
#ifndef DEBUG_H
|
||||
#define DEBUG_H
|
||||
|
||||
#include "variables.h"
|
||||
#include "callcpp.h"
|
||||
#include <stdio.h>
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
T y p e s
|
||||
----------------------------------------------------------------------*/
|
||||
typedef struct
|
||||
{
|
||||
const char *menu_string;
|
||||
void_proc menu_function;
|
||||
} MENU_ITEM;
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
V a r i a b l e s
|
||||
----------------------------------------------------------------------*/
|
||||
#define NUM_MENUS 30
|
||||
#define NUM_MENU_ITEMS 30
|
||||
extern MENU_ITEM menu_table[NUM_MENUS][NUM_MENU_ITEMS];
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
M a c r o s
|
||||
----------------------------------------------------------------------*/
|
||||
/**********************************************************************
|
||||
* float_value
|
||||
*
|
||||
* Template procedures to set a floating point value of a variable.
|
||||
**********************************************************************/
|
||||
|
||||
#define float_value(proc,string,variable,default) \
|
||||
\
|
||||
float variable = default; \
|
||||
\
|
||||
int proc () \
|
||||
{ \
|
||||
return (set_float_value (string, &variable)); \
|
||||
} \
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* handle_menu_x
|
||||
*
|
||||
* Create a procedure to handle menu items.
|
||||
**********************************************************************/
|
||||
|
||||
#define handle_menu(menu,handle_menu_x) \
|
||||
\
|
||||
int handle_menu_x () \
|
||||
{ \
|
||||
int x; \
|
||||
cprintf ("\t 0. Continue\n"); \
|
||||
for (x = 0; x < NUM_MENU_ITEMS; x++) { \
|
||||
if (menu_table[menu][x].menu_string) \
|
||||
cprintf ("\t%2d. %s\n", x, menu_table[menu][x].menu_string); \
|
||||
} \
|
||||
\
|
||||
scanf ("%d", &x); \
|
||||
\
|
||||
if (x == 0) return (0); \
|
||||
if ((0 < x && x < NUM_MENU_ITEMS) && \
|
||||
(menu_table[menu][x].menu_function)) { \
|
||||
(*menu_table[menu][x].menu_function) (); \
|
||||
return (1); \
|
||||
} \
|
||||
else { \
|
||||
cprintf ("Bad menu selection"); \
|
||||
return (0); \
|
||||
} \
|
||||
} \
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* int_value
|
||||
*
|
||||
* Template procedures to set a floating point value of a variable.
|
||||
**********************************************************************/
|
||||
|
||||
#define int_value(proc,string,variable,default) \
|
||||
\
|
||||
int variable = default; \
|
||||
\
|
||||
int proc () \
|
||||
{ \
|
||||
return (set_int_value (string, &variable)); \
|
||||
} \
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* toggle_value
|
||||
*
|
||||
* Template procedures to toggle the value of a variable.
|
||||
**********************************************************************/
|
||||
|
||||
#ifdef SECURE_NAMES
|
||||
#define toggle_value(proc,string,variable,default) \
|
||||
\
|
||||
int variable = default; \
|
||||
\
|
||||
int proc () \
|
||||
{ \
|
||||
if (variable) { \
|
||||
variable = 0; \
|
||||
} \
|
||||
else { \
|
||||
variable = 1; \
|
||||
} \
|
||||
return (1); \
|
||||
} \
|
||||
|
||||
#else
|
||||
|
||||
#define toggle_value(proc,string,variable,default) \
|
||||
\
|
||||
int variable = default; \
|
||||
\
|
||||
int proc () \
|
||||
{ \
|
||||
if (variable) { \
|
||||
cprintf( "%s is OFF\n", string); \
|
||||
variable = 0; \
|
||||
} \
|
||||
else { \
|
||||
cprintf( "%s is ON\n", string); \
|
||||
variable = 1; \
|
||||
} \
|
||||
return (1); \
|
||||
} \
|
||||
|
||||
#endif
|
||||
|
||||
/**********************************************************************
|
||||
* make_float_const
|
||||
*
|
||||
* Create a constant with a config file reader
|
||||
**********************************************************************/
|
||||
|
||||
#define make_float_const(name,default,installer) \
|
||||
\
|
||||
float name = default; \
|
||||
\
|
||||
void installer () \
|
||||
{ \
|
||||
float_variable (name, #name, default); \
|
||||
} \
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* make_int_const
|
||||
*
|
||||
* Create a constant with a config file reader
|
||||
**********************************************************************/
|
||||
|
||||
#define make_int_const(name,default,installer) \
|
||||
\
|
||||
int name = default; \
|
||||
\
|
||||
void installer () \
|
||||
{ \
|
||||
int_variable (name, #name, default); \
|
||||
} \
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* make_toggle_const
|
||||
*
|
||||
* Create a constant with a config file reader
|
||||
**********************************************************************/
|
||||
|
||||
#define make_toggle_const(name,default,installer) \
|
||||
\
|
||||
int name = default; \
|
||||
\
|
||||
void installer () \
|
||||
{ \
|
||||
int_variable (name, #name, default); \
|
||||
} \
|
||||
|
||||
|
||||
#ifdef SECURE_NAMES
|
||||
/**********************************************************************
|
||||
* make_float_var
|
||||
*
|
||||
* Create a variable with a config file reader and a menu handler.
|
||||
**********************************************************************/
|
||||
|
||||
#define make_float_var(name,default,installer,menu,menuitem,menufunct,menustring) \
|
||||
\
|
||||
float_value (menufunct, "", name, default); \
|
||||
\
|
||||
void installer () \
|
||||
{ \
|
||||
float_variable (name, #name, default); \
|
||||
} \
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* make_int_var
|
||||
*
|
||||
* Create a variable with a config file reader and a menu handler.
|
||||
**********************************************************************/
|
||||
|
||||
#define make_int_var(name,default,installer,menu,menuitem,menufunct,menustring) \
|
||||
\
|
||||
int_value (menufunct, "", name, default); \
|
||||
\
|
||||
void installer () \
|
||||
{ \
|
||||
int_variable (name, #name, default); \
|
||||
} \
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* make_toggle_var
|
||||
*
|
||||
* Create a variable with a config file reader and a menu handler.
|
||||
**********************************************************************/
|
||||
|
||||
#define make_toggle_var(name,default,installer,menu,menuitem,menufunct,menustring) \
|
||||
\
|
||||
toggle_value (menufunct, "", name, default); \
|
||||
\
|
||||
void installer () \
|
||||
{ \
|
||||
int_variable (name, #name, default); \
|
||||
} \
|
||||
|
||||
#else
|
||||
|
||||
/**********************************************************************
|
||||
* make_float_var
|
||||
*
|
||||
* Create a variable with a config file reader and a menu handler.
|
||||
**********************************************************************/
|
||||
|
||||
#define make_float_var(name,default,installer,menu,menuitem,menufunct,menustring) \
|
||||
\
|
||||
float_value (menufunct, menustring, name, default); \
|
||||
\
|
||||
void installer () \
|
||||
{ \
|
||||
float_variable (name, #name, default); \
|
||||
make_menu_item (menu, menuitem, menustring, menufunct); \
|
||||
} \
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* make_int_var
|
||||
*
|
||||
* Create a variable with a config file reader and a menu handler.
|
||||
**********************************************************************/
|
||||
|
||||
#define make_int_var(name,default,installer,menu,menuitem,menufunct,menustring) \
|
||||
\
|
||||
int_value (menufunct, menustring, name, default); \
|
||||
\
|
||||
void installer () \
|
||||
{ \
|
||||
int_variable (name, #name, default); \
|
||||
make_menu_item (menu, menuitem, menustring, menufunct); \
|
||||
} \
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* make_toggle_var
|
||||
*
|
||||
* Create a variable with a config file reader and a menu handler.
|
||||
**********************************************************************/
|
||||
|
||||
#define make_toggle_var(name,default,installer,menu,menuitem,menufunct,menustring) \
|
||||
\
|
||||
toggle_value (menufunct, menustring, name, default); \
|
||||
\
|
||||
void installer () \
|
||||
{ \
|
||||
int_variable (name, #name, default); \
|
||||
make_menu_item (menu, menuitem, menustring, menufunct); \
|
||||
} \
|
||||
|
||||
#endif
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
F u n c t i o n s
|
||||
----------------------------------------------------------------------*/
|
||||
int set_float_value(const char *message, float *variable);
|
||||
|
||||
int set_int_value(const char *message, int *variable);
|
||||
|
||||
void make_menu_item(int menu,
|
||||
int menu_item,
|
||||
const char *menu_string,
|
||||
int_void menu_funct);
|
||||
|
||||
/*
|
||||
#if defined(__STDC__) || defined(__cplusplus)
|
||||
# define _ARGS(s) s
|
||||
#else
|
||||
# define _ARGS(s) ()
|
||||
#endif
|
||||
|
||||
int set_float_value
|
||||
_ARGS((char *message,
|
||||
float *variable));
|
||||
|
||||
int set_int_value
|
||||
_ARGS((char *message,
|
||||
int *variable));
|
||||
|
||||
void make_menu_item
|
||||
_ARGS((int menu,
|
||||
int menu_item,
|
||||
char *menu_string,
|
||||
int_proc menu_funct));
|
||||
|
||||
#undef _ARGS
|
||||
*/
|
||||
#endif
|
@ -29,41 +29,41 @@
|
||||
/* This file contains the global declarations used by all demonstrator files*/
|
||||
|
||||
//IMAGE info; /*image info record*/
|
||||
TBLOB *pageblobs; /*first blob on page */
|
||||
TEXTBLOCK *pageblocks; /*first block on page */
|
||||
//TBLOB *pageblobs; /*first blob on page */
|
||||
//TEXTBLOCK *pageblocks; /*first block on page */
|
||||
// char classes[CLASSIZE][CLASSLENGTH];
|
||||
/*class definitions */
|
||||
/*indices to to_classes */
|
||||
|
||||
int resolution; /*scanner res in dpi */
|
||||
int acts[MAXPROC]; /*action flags */
|
||||
int debugs[MAXPROC]; /*debug flags */
|
||||
int plots[MAXPROC]; /*plot flags */
|
||||
//int resolution; /*scanner res in dpi */
|
||||
//int acts[MAXPROC]; /*action flags */
|
||||
//int debugs[MAXPROC]; /*debug flags */
|
||||
//int plots[MAXPROC]; /*plot flags */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
V a r i a b l e s
|
||||
----------------------------------------------------------------------*/
|
||||
int corners[4]; /*corners of scan window */
|
||||
//int corners[4]; /*corners of scan window */
|
||||
|
||||
char imagefile[FILENAMESIZE]; /*image file name */
|
||||
char directory[FILENAMESIZE]; /* main directory */
|
||||
char *debugfile; /* debug file name */
|
||||
//char imagefile[FILENAMESIZE]; /*image file name */
|
||||
//char directory[FILENAMESIZE]; /* main directory */
|
||||
//char *debugfile; /* debug file name */
|
||||
|
||||
int plots_fx;
|
||||
int plots_ocr;
|
||||
//int plots_fx;
|
||||
//int plots_ocr;
|
||||
|
||||
int debugs_fx;
|
||||
int debugs_ocr;
|
||||
//int debugs_fx;
|
||||
//int debugs_ocr;
|
||||
|
||||
int acts_fx;
|
||||
int acts_ocr;
|
||||
//int acts_fx;
|
||||
//int acts_ocr;
|
||||
|
||||
char *demodir; /*demo home directory */
|
||||
//char *demodir; /*demo home directory */
|
||||
|
||||
int edgefd; /*edges window */
|
||||
int debugfd; /*debug window fd */
|
||||
FILE *debugfp; /*debug log file */
|
||||
//int edgefd; /*edges window */
|
||||
//int debugfd; /*debug window fd */
|
||||
//FILE *debugfp; /*debug log file */
|
||||
|
||||
UNICHARSET unicharset;
|
||||
//UNICHARSET unicharset;
|
||||
|
||||
STRING language_data_path_prefix;
|
||||
//STRING language_data_path_prefix;
|
||||
|
@ -36,35 +36,35 @@
|
||||
V a r i a b l e s
|
||||
----------------------------------------------------------------------*/
|
||||
//extern IMAGE info; /*image info record*/
|
||||
extern TBLOB *pageblobs; /*first blob on page */
|
||||
extern TEXTBLOCK *pageblocks; /*first block on page */
|
||||
/*class definitions */
|
||||
/* extern char classes[CLASSIZE][CLASSLENGTH]; */
|
||||
extern int resolution; /*scanner res in dpi */
|
||||
extern int acts[MAXPROC]; /*action flags */
|
||||
extern int debugs[MAXPROC]; /*debug flags */
|
||||
extern int plots[MAXPROC]; /*plot flags */
|
||||
extern int corners[4]; /*corners of scan window */
|
||||
/*image file name */
|
||||
extern char imagefile[FILENAMESIZE];
|
||||
/* main directory */
|
||||
extern char directory[FILENAMESIZE];
|
||||
extern char *debugfile; /* debug file name */
|
||||
//extern TBLOB *pageblobs; /*first blob on page */
|
||||
//extern TEXTBLOCK *pageblocks; /*first block on page */
|
||||
// /*class definitions */
|
||||
///* extern char classes[CLASSIZE][CLASSLENGTH]; */
|
||||
//extern int resolution; /*scanner res in dpi */
|
||||
//extern int acts[MAXPROC]; /*action flags */
|
||||
//extern int debugs[MAXPROC]; /*debug flags */
|
||||
//extern int plots[MAXPROC]; /*plot flags */
|
||||
//extern int corners[4]; /*corners of scan window */
|
||||
// /*image file name */
|
||||
//extern char imagefile[FILENAMESIZE];
|
||||
// /* main directory */
|
||||
//extern char directory[FILENAMESIZE];
|
||||
//extern char *debugfile; /* debug file name */
|
||||
|
||||
extern int plots_fx;
|
||||
extern int plots_ocr;
|
||||
//extern int plots_fx;
|
||||
//extern int plots_ocr;
|
||||
|
||||
extern int debugs_fx;
|
||||
extern int debugs_ocr;
|
||||
//extern int debugs_fx;
|
||||
//extern int debugs_ocr;
|
||||
|
||||
extern int acts_fx;
|
||||
extern int acts_ocr;
|
||||
//extern int acts_fx;
|
||||
//extern int acts_ocr;
|
||||
|
||||
extern char *demodir;
|
||||
extern FILE *debugfp; /*debug log file */
|
||||
//extern char *demodir;
|
||||
//extern FILE *debugfp; /*debug log file */
|
||||
|
||||
extern UNICHARSET unicharset; /* The UNICHARSET variable that Tesseract uses internally */
|
||||
//extern UNICHARSET unicharset; /* The UNICHARSET variable that Tesseract uses internally */
|
||||
|
||||
extern STRING language_data_path_prefix;
|
||||
//extern STRING language_data_path_prefix;
|
||||
|
||||
#endif
|
||||
|
@ -1,40 +0,0 @@
|
||||
/******************************************************************************
|
||||
** Filename: minmax.h
|
||||
** Purpose: Utility macros for min and max functions.
|
||||
** Author: Dan Johnson
|
||||
** History: Wed Oct 17 09:54:32 1990, DSJ, Created.
|
||||
**
|
||||
** (c) Copyright Hewlett-Packard Company, 1988.
|
||||
** 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 MINMAX_H
|
||||
#define MINMAX_H
|
||||
|
||||
/**----------------------------------------------------------------------------
|
||||
Include Files and Type Defines
|
||||
----------------------------------------------------------------------------**/
|
||||
|
||||
/**----------------------------------------------------------------------------
|
||||
Public Function Prototypes
|
||||
----------------------------------------------------------------------------**/
|
||||
|
||||
#ifndef MAX
|
||||
#define MAX(x,y) (((x)>=(y))?(x):(y))
|
||||
#endif
|
||||
|
||||
#ifndef MIN
|
||||
#define MIN(x,y) (((x)<=(y))?(x):(y))
|
||||
#endif
|
||||
|
||||
/**----------------------------------------------------------------------------
|
||||
Global Data Definitions and Declarations
|
||||
----------------------------------------------------------------------------**/
|
||||
#endif
|
@ -151,6 +151,33 @@ LIST delete_d(LIST list, void *key, int_compare is_equal) {
|
||||
return (result);
|
||||
}
|
||||
|
||||
LIST delete_d(LIST list, void *key,
|
||||
ResultCallback2<int, void*, void*>* is_equal) {
|
||||
LIST result = NIL;
|
||||
LIST last_one = NIL;
|
||||
|
||||
while (list != NIL) {
|
||||
if (!(*is_equal).Run (first_node (list), key)) {
|
||||
if (last_one == NIL) {
|
||||
last_one = list;
|
||||
list = rest (list);
|
||||
result = last_one;
|
||||
set_rest(last_one, NIL);
|
||||
}
|
||||
else {
|
||||
set_rest(last_one, list);
|
||||
last_one = list;
|
||||
list = rest (list);
|
||||
set_rest(last_one, NIL);
|
||||
}
|
||||
}
|
||||
else {
|
||||
list = pop (list);
|
||||
}
|
||||
}
|
||||
return (result);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* d e s t r o y
|
||||
@ -391,3 +418,9 @@ LIST search(LIST list, void *key, int_compare is_equal) {
|
||||
return (list);
|
||||
return (NIL);
|
||||
}
|
||||
|
||||
LIST search(LIST list, void *key, ResultCallback2<int, void*, void*>* is_equal) {
|
||||
iterate (list) if ((*is_equal).Run(first_node (list), key))
|
||||
return (list);
|
||||
return (NIL);
|
||||
}
|
||||
|
@ -118,17 +118,18 @@
|
||||
#define LIST_H
|
||||
|
||||
#include "cutil.h"
|
||||
#include "callback.h"
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
T y p e s
|
||||
----------------------------------------------------------------------*/
|
||||
#define NIL (LIST) 0
|
||||
typedef struct list_rec
|
||||
struct list_rec
|
||||
{
|
||||
struct list_rec *node;
|
||||
struct list_rec *next;
|
||||
} _LIST_;
|
||||
typedef _LIST_ *LIST;
|
||||
};
|
||||
typedef list_rec *LIST;
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
M a c r o s
|
||||
@ -239,6 +240,9 @@ int count(LIST var_list);
|
||||
|
||||
LIST delete_d(LIST list, void *key, int_compare is_equal);
|
||||
|
||||
LIST delete_d(LIST list, void *key,
|
||||
ResultCallback2<int, void*, void*>* is_equal);
|
||||
|
||||
LIST destroy(LIST list);
|
||||
|
||||
void destroy_nodes(LIST list, void_dest destructor);
|
||||
@ -269,6 +273,8 @@ LIST s_adjoin(LIST var_list, void *variable, int_compare compare);
|
||||
|
||||
LIST search(LIST list, void *key, int_compare is_equal);
|
||||
|
||||
LIST search(LIST list, void *key, ResultCallback2<int, void*, void*>*);
|
||||
|
||||
/*
|
||||
#if defined(__STDC__) || defined(__cplusplus)
|
||||
# define _ARGS(s) s
|
||||
|
@ -55,7 +55,7 @@ freeword, WERDBLOCK, "TWERD", wordcount)
|
||||
makestructure (newoutline, oldoutline, printol, TESSLINE,
|
||||
freeoutline, OUTLINEBLOCK, "TESSLINE", outlinecount);
|
||||
|
||||
makestructure (new_cell, free_cell, printcell, _LIST_,
|
||||
makestructure (new_cell, free_cell, printcell, list_rec,
|
||||
freelist, LISTBLOCK, "LIST", listcount);
|
||||
|
||||
newstructure (newblob, TBLOB, freeblob, BLOBBLOCK, "newblob", blobcount);
|
||||
|
@ -1,95 +0,0 @@
|
||||
/* -*-C-*-
|
||||
********************************************************************************
|
||||
*
|
||||
* File: tovars.c (Formerly to-vars.c)
|
||||
* Description: Text Ordering Control Variables
|
||||
* Author: Mark Seaman, OCR Technology
|
||||
* Created: Wed Jan 17 12:47:29 1990
|
||||
* Modified: Tue Jul 30 16:22:40 1991 (Mark Seaman) marks@hpgrlt
|
||||
* Language: C
|
||||
* Package: N/A
|
||||
* Status: Experimental (Do Not Distribute)
|
||||
*
|
||||
* (c) Copyright 1990, Hewlett-Packard Company.
|
||||
** 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.
|
||||
*
|
||||
*********************************************************************************/
|
||||
/*----------------------------------------------------------------------
|
||||
I n c l u d e s
|
||||
----------------------------------------------------------------------*/
|
||||
#include "mfcpch.h"
|
||||
#include "debug.h"
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
V a r i a b l e s
|
||||
----------------------------------------------------------------------*/
|
||||
FILE *rawfile; /* Text before dictionary */
|
||||
FILE *textfile; /* Text output file */
|
||||
FILE *matcher_fp; //matcher log
|
||||
FILE *correct_fp; //correct text
|
||||
|
||||
int write_output; /* Text file output */
|
||||
int write_raw_output; /* Text before context */
|
||||
|
||||
int similarity_enable = 0;
|
||||
int similarity_debug = 0;
|
||||
|
||||
make_float_var (certainty_threshold, -2.25, make_certainty_threshold,
|
||||
4, 5, set_certainty_value, "Certainty Value");
|
||||
|
||||
make_int_var (num_word_choices, 30, make_num_word_choices,
|
||||
4, 6, set_num_choices, "Number of choices");
|
||||
|
||||
make_toggle_var (blob_skip, 0, make_blob_skip,
|
||||
4, 7, toggle_skip, "Skip to Next selection");
|
||||
|
||||
make_float_var (overlap_threshold, 0.33, make_overlap_threshold,
|
||||
9, 7, set_overlap, "Overlap Threshold");
|
||||
|
||||
make_toggle_var (debug_3, 0, make_debug_3, 6, 3, toggle_debug_3, "Debug #3");
|
||||
|
||||
make_toggle_var (debug_5, 0, make_debug_5, 6, 5, toggle_debug_5, "Debug #5");
|
||||
|
||||
make_toggle_var (debug_8, 0, make_debug_8, 6, 8, toggle_debug_8, "Debug #8");
|
||||
|
||||
make_toggle_var (display_ratings, 0, make_display_ratings,
|
||||
6, 9, toggle_ratings, "Ratings display");
|
||||
|
||||
make_toggle_var (display_text, 0, make_display_text,
|
||||
6, 10, toggle_text, "Display Text");
|
||||
|
||||
make_toggle_var (show_bold, 1, make_show_bold,
|
||||
6, 17, set_show_bold, "Show Bold Text");
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
F u n c t i o n s
|
||||
----------------------------------------------------------------------*/
|
||||
/**********************************************************************
|
||||
* init_textord_vars
|
||||
*
|
||||
* Create variables to be used by the texord section of code.
|
||||
**********************************************************************/
|
||||
void init_textord_vars() {
|
||||
int_variable (write_output, "write_output", 0);
|
||||
int_variable (write_raw_output, "write_raw_output", 0);
|
||||
make_certainty_threshold();
|
||||
make_num_word_choices();
|
||||
make_blob_skip();
|
||||
make_overlap_threshold();
|
||||
make_show_bold();
|
||||
|
||||
make_debug_3();
|
||||
make_debug_5();
|
||||
make_debug_8();
|
||||
|
||||
make_display_ratings();
|
||||
make_display_text();
|
||||
}
|
@ -1,61 +0,0 @@
|
||||
/* -*-C-*-
|
||||
********************************************************************************
|
||||
*
|
||||
* File: tovars.h (Formerly to-vars.h)
|
||||
* Description: Do word classification
|
||||
* Author: Mark Seaman, OCR Technology
|
||||
* Created: Wed Oct 25 16:33:01 1989
|
||||
* Modified: Mon Jul 1 14:28:23 1991 (Mark Seaman) marks@hpgrlt
|
||||
* Language: C
|
||||
* Package: N/A
|
||||
* Status: Experimental (Do Not Distribute)
|
||||
*
|
||||
* (c) Copyright 1989, Hewlett-Packard Company.
|
||||
** 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 TOVARS_H
|
||||
#define TOVARS_H
|
||||
|
||||
#include <stdio.h>
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
V a r i a b l e s
|
||||
----------------------------------------------------------------------*/
|
||||
extern int debug_3;
|
||||
extern int debug_5;
|
||||
extern int debug_8;
|
||||
|
||||
extern FILE *rawfile; /* Text before dictionary */
|
||||
extern FILE *textfile; /* Text output file */
|
||||
extern FILE *correct_fp; //correct text
|
||||
extern FILE *matcher_fp;
|
||||
|
||||
extern int blob_skip; /* Skip to next selection */
|
||||
extern int num_word_choices; /* How many words to keep */
|
||||
extern int similarity_enable; /* Switch for Similarity */
|
||||
extern int similarity_debug; /* Level of debug output */
|
||||
extern int write_raw_output; /* Text before context */
|
||||
extern int write_output; /* Text file output */
|
||||
//extern "C" { extern int display_ratings; } /* Show the ratings */
|
||||
extern int display_ratings; /* Show the ratings */
|
||||
extern int show_bold; /* Use bold text */
|
||||
extern int display_text; /* Show word text */
|
||||
extern int display_blocks; /* Show word as boxes */
|
||||
|
||||
extern float overlap_threshold; /* Overlap Threshold */
|
||||
extern float certainty_threshold; /* When to quit looking */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
F u n c t i o n s
|
||||
----------------------------------------------------------------------*/
|
||||
void init_textord_vars();
|
||||
#endif
|
@ -1,317 +0,0 @@
|
||||
/* -*-C-*-
|
||||
********************************************************************************
|
||||
*
|
||||
* File: variables.c (Formerly variables.c)
|
||||
* Description: Variable handler for control flags
|
||||
* Author: Mark Seaman, OCR Technology
|
||||
* Created: Tue Dec 12 09:03:49 1989
|
||||
* Modified: Thu Apr 4 11:01:37 1991 (Mark Seaman) marks@hpgrlt
|
||||
* Language: C
|
||||
* Package: N/A
|
||||
* Status: Experimental (Do Not Distribute)
|
||||
*
|
||||
* (c) Copyright 1989, Hewlett-Packard Company.
|
||||
** 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.
|
||||
*
|
||||
*********************************************************************************/
|
||||
/*----------------------------------------------------------------------
|
||||
I n c l u d e s
|
||||
----------------------------------------------------------------------*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "variables.h"
|
||||
#include "tprintf.h"
|
||||
#include "listio.h"
|
||||
#include "globals.h"
|
||||
#include "scanutils.h"
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
V a r i a b l e s
|
||||
----------------------------------------------------------------------*/
|
||||
static LIST variable_list = NIL;
|
||||
//extern char *demodir;
|
||||
|
||||
VALUE dummy;
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
Macros
|
||||
----------------------------------------------------------------------*/
|
||||
/**********************************************************************
|
||||
* scan_int
|
||||
*
|
||||
* Scan in an integer value from a string. It might be in decimal or
|
||||
* hex. Read it into "integer".
|
||||
**********************************************************************/
|
||||
|
||||
#define scan_int(stripped,integer) \
|
||||
if (stripped [2] == 'x') \
|
||||
sscanf (&stripped[3], "%x", &integer); \
|
||||
else \
|
||||
sscanf (&stripped[1], "%d", &integer)
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
F u n c t i o n s
|
||||
----------------------------------------------------------------------*/
|
||||
|
||||
void free_variables() {
|
||||
destroy_nodes(variable_list, free);
|
||||
variable_list = NIL;
|
||||
}
|
||||
/**********************************************************************
|
||||
* add_ptr_variable
|
||||
*
|
||||
* Add a new ptr variable to the global variable list. Initalize its
|
||||
* value.
|
||||
**********************************************************************/
|
||||
void add_ptr_variable(void *address,
|
||||
const char *string,
|
||||
VALUE default_value,
|
||||
variables_io reader,
|
||||
variables_io writer) {
|
||||
VARIABLE *this_var;
|
||||
this_var = (VARIABLE *) malloc (sizeof (VARIABLE));
|
||||
|
||||
this_var->address = address;
|
||||
this_var->string = string;
|
||||
this_var->default_value = default_value;
|
||||
this_var->type_reader = reader;
|
||||
this_var->type_writer = writer;
|
||||
|
||||
*((void **) this_var->address) = default_value.ptr_part;
|
||||
variable_list = push (variable_list, this_var);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* add_32bit_variable
|
||||
*
|
||||
* Add a new 32bit variable to the global variable list. Initalize
|
||||
* its value.
|
||||
**********************************************************************/
|
||||
void add_32bit_variable(void *address,
|
||||
const char *string,
|
||||
VALUE default_value,
|
||||
variables_io reader,
|
||||
variables_io writer) {
|
||||
VARIABLE *this_var;
|
||||
this_var = (VARIABLE *) malloc (sizeof (VARIABLE));
|
||||
|
||||
this_var->address = address;
|
||||
this_var->string = string;
|
||||
this_var->default_value = default_value;
|
||||
this_var->type_reader = reader;
|
||||
this_var->type_writer = writer;
|
||||
|
||||
*((int *) this_var->address) = default_value.int_part;
|
||||
variable_list = push (variable_list, this_var);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* float_read
|
||||
*
|
||||
* Read an integer value and save it in a variable structure.
|
||||
**********************************************************************/
|
||||
void float_read(VARIABLE *variable, char *string) {
|
||||
float f;
|
||||
|
||||
#ifdef EMBEDDED
|
||||
// We have no sscanf with float functionality here
|
||||
*((float *) variable->address) = strtofloat(strip_line (string));
|
||||
#else
|
||||
sscanf (strip_line (string), "%f", &f);
|
||||
*((float *) variable->address) = f;
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* float_write
|
||||
*
|
||||
* Read an integer value and save it in a variable structure.
|
||||
**********************************************************************/
|
||||
void float_write(VARIABLE *variable, char *string) {
|
||||
float *f;
|
||||
f = (float *) variable->address;
|
||||
sprintf (string, "%s\t%4.2f", variable->string, *f);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* int_read
|
||||
*
|
||||
* Read an integer value and save it in a variable structure.
|
||||
**********************************************************************/
|
||||
void int_read(VARIABLE *variable, char *string) {
|
||||
char *stripped;
|
||||
int integer;
|
||||
|
||||
stripped = strip_line (string);
|
||||
/* Add the value */
|
||||
if (stripped[0] == '+') {
|
||||
scan_int(stripped, integer);
|
||||
*((int *) variable->address) += integer;
|
||||
}
|
||||
else if (stripped[0] == '|') {
|
||||
scan_int(stripped, integer);
|
||||
*((int *) variable->address) = integer | *((int *) variable->address);
|
||||
} /* Subtract the value */
|
||||
else if (stripped[0] == '_') {
|
||||
scan_int(stripped, integer);
|
||||
*((int *) variable->address) = (~integer) &
|
||||
*((int *) variable->address);
|
||||
}
|
||||
else {
|
||||
/* Set the value */
|
||||
if (stripped[1] == 'x') {
|
||||
sscanf (&stripped[2], "%x", &integer);
|
||||
}
|
||||
else {
|
||||
sscanf (stripped, "%d", &integer);
|
||||
}
|
||||
*((int *) variable->address) = integer;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* int_write
|
||||
*
|
||||
* Read an integer value and save it in a variable structure.
|
||||
**********************************************************************/
|
||||
void int_write(VARIABLE *variable, char *string) {
|
||||
sprintf (string, "%s\t%d", variable->string, *((int *) variable->address));
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* read_variables
|
||||
*
|
||||
* Read a file that contains assignments for all the desired variables.
|
||||
* This type of file can be written using the function write_variables.
|
||||
**********************************************************************/
|
||||
void read_variables(const char *filename) {
|
||||
int x = 0;
|
||||
char *this_string;
|
||||
LIST var_strings;
|
||||
char name[1024];
|
||||
FILE *fp;
|
||||
/* Read the strings */
|
||||
if (filename == NULL || filename[0] == '\0')
|
||||
return;
|
||||
|
||||
strcpy(name, demodir);
|
||||
strcat (name, "tessdata/tessconfigs/");
|
||||
strcat(name, filename);
|
||||
if ((fp = fopen (name, "r")) == NULL)
|
||||
strcpy(name, filename);
|
||||
else
|
||||
fclose(fp);
|
||||
var_strings = read_list (name);
|
||||
iterate(var_strings) {
|
||||
/* Get the name string */
|
||||
this_string = (char *) first_node (var_strings);
|
||||
if (this_string[0] != '#') {
|
||||
for (x = 0;
|
||||
x < strlen (this_string) && this_string[x] != ' '
|
||||
&& this_string[x] != '\t'; x++);
|
||||
this_string[x] = '\0';
|
||||
/* Find variable record */
|
||||
if (!set_old_style_variable(this_string, this_string + x + 1)) {
|
||||
tprintf("error: Could not find variable '%s'\n", this_string);
|
||||
exit(1); // ?err_exit ();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool set_old_style_variable(const char* variable, const char* value) {
|
||||
char* var_variable = strdup(variable);
|
||||
char* var_value = strdup(value);
|
||||
|
||||
VARIABLE *this_var;
|
||||
this_var = (VARIABLE *)first_node(search(variable_list, var_variable,
|
||||
same_var_name));
|
||||
if (this_var != NULL) {
|
||||
(*(this_var->type_reader)) (this_var, var_value);
|
||||
}
|
||||
free(var_variable);
|
||||
free(var_value);
|
||||
return this_var != NULL;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* same_var_name
|
||||
*
|
||||
* Return TRUE if the VARIABLE has the name string in it.
|
||||
**********************************************************************/
|
||||
int same_var_name(void *item1, //VARIABLE *variable,
|
||||
void *item2) { //char *string)
|
||||
VARIABLE *variable;
|
||||
char *string;
|
||||
|
||||
variable = (VARIABLE *) item1;
|
||||
string = (char *) item2;
|
||||
|
||||
if (strcmp (variable->string, string))
|
||||
return (FALSE);
|
||||
else
|
||||
return (TRUE);
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* string_read
|
||||
*
|
||||
* Read an integer value and save it in a variable structure.
|
||||
**********************************************************************/
|
||||
void string_read(VARIABLE *variable, char *string) {
|
||||
char *value;
|
||||
|
||||
value = strsave (strip_line (string));
|
||||
*((char **) variable->address) = value;
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* string_write
|
||||
*
|
||||
* Read an integer value and save it in a variable structure.
|
||||
**********************************************************************/
|
||||
void string_write(VARIABLE *variable, char *string) {
|
||||
sprintf (string, "%s\t%s", variable->string,
|
||||
*((char **) variable->address));
|
||||
}
|
||||
|
||||
|
||||
/**********************************************************************
|
||||
* strip_line
|
||||
*
|
||||
* Remove the name off the front of the line and strip the white space
|
||||
* before and after the value.
|
||||
**********************************************************************/
|
||||
char *strip_line(char *string) {
|
||||
int x;
|
||||
int y;
|
||||
|
||||
x = 0;
|
||||
/* Skip over whitespace */
|
||||
while (x < strlen (string) && (string[x] == '\t' || string[x] == ' '))
|
||||
x++;
|
||||
/* Strip trailing whitespace */
|
||||
for (y = strlen (string);
|
||||
y >= 0 && (string[y - 1] == '\t' || string[y - 1] == ' '); y--)
|
||||
string[y] = '\0';
|
||||
/* Return result */
|
||||
return (&string[x]);
|
||||
}
|
@ -1,170 +0,0 @@
|
||||
/* -*-C-*-
|
||||
********************************************************************************
|
||||
*
|
||||
* File: variables.h (Formerly variables.h)
|
||||
* Description: Variable handler for control flags
|
||||
* Author: Mark Seaman, OCR Technology
|
||||
* Created: Tue Dec 12 09:03:49 1989
|
||||
* Modified: Fri Jan 12 16:57:36 1990 (Mark Seaman) marks@hpgrlt
|
||||
* Language: C
|
||||
* Package: N/A
|
||||
* Status: Experimental (Do Not Distribute)
|
||||
*
|
||||
* (c) Copyright 1989, Hewlett-Packard Company.
|
||||
** 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 VARIABLES_H
|
||||
#define VARIABLES_H
|
||||
|
||||
#include "cutil.h"
|
||||
#include "oldlist.h"
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
T y p e s
|
||||
----------------------------------------------------------------------*/
|
||||
typedef union
|
||||
{
|
||||
float float_part;
|
||||
int int_part;
|
||||
void *ptr_part;
|
||||
const char *char_part;
|
||||
} VALUE;
|
||||
|
||||
class VARIABLE;
|
||||
|
||||
typedef void (*variables_io) (VARIABLE * variable, char *string);
|
||||
|
||||
class VARIABLE
|
||||
{
|
||||
public:
|
||||
void *address;
|
||||
const char *string;
|
||||
VALUE default_value;
|
||||
variables_io type_reader;
|
||||
variables_io type_writer;
|
||||
};
|
||||
|
||||
extern VALUE dummy; /* Needed for macros */
|
||||
|
||||
/*----------------------------------------------------------------------
|
||||
M a c r o s
|
||||
----------------------------------------------------------------------*/
|
||||
/* To hide variable names for relase to UNLV DONT put the variable names in
|
||||
the executable: Toggle be either defining or not defining SECURE_NAMES*/
|
||||
/* #define SECURE_NAMES defined in secnames.h when necessary */
|
||||
#ifdef SECURE_NAMES
|
||||
/**********************************************************************
|
||||
* float_variable
|
||||
*
|
||||
* Create a floating point variable that can be read and written from
|
||||
* a configuration file.
|
||||
**********************************************************************/
|
||||
|
||||
#define float_variable(name,string,default) \
|
||||
dummy.float_part = default; \
|
||||
add_32bit_variable (&name, "", dummy, float_read, float_write)
|
||||
|
||||
/**********************************************************************
|
||||
* string_variable
|
||||
*
|
||||
* Create a string point variable that can be read and written from
|
||||
* a configuration file.
|
||||
**********************************************************************/
|
||||
|
||||
#define string_variable(name,string,default) \
|
||||
dummy.char_part = default; \
|
||||
add_ptr_variable (&name, "", dummy, string_read, string_write)
|
||||
|
||||
/**********************************************************************
|
||||
* int_variable
|
||||
*
|
||||
* Create a int point variable that can be read and written from
|
||||
* a configuration file.
|
||||
**********************************************************************/
|
||||
|
||||
#define int_variable(name,string,default) \
|
||||
dummy.int_part = default; \
|
||||
add_32bit_variable (&name, "", dummy, int_read, int_write)
|
||||
|
||||
#else
|
||||
/**********************************************************************
|
||||
* float_variable
|
||||
*
|
||||
* Create a floating point variable that can be read and written from
|
||||
* a configuration file.
|
||||
**********************************************************************/
|
||||
|
||||
#define float_variable(name,string,default) \
|
||||
dummy.float_part = default; \
|
||||
add_32bit_variable (&name, string, dummy, float_read, float_write)
|
||||
|
||||
/**********************************************************************
|
||||
* string_variable
|
||||
*
|
||||
* Create a string point variable that can be read and written from
|
||||
* a configuration file.
|
||||
**********************************************************************/
|
||||
|
||||
#define string_variable(name,string,default) \
|
||||
dummy.char_part = default; \
|
||||
add_ptr_variable (&name, string, dummy, string_read, string_write)
|
||||
|
||||
/**********************************************************************
|
||||
* int_variable
|
||||
*
|
||||
* Create a int point variable that can be read and written from
|
||||
* a configuration file.
|
||||
**********************************************************************/
|
||||
|
||||
#define int_variable(name,string,default) \
|
||||
dummy.int_part = default; \
|
||||
add_32bit_variable (&name, string, dummy, int_read, int_write)
|
||||
#endif
|
||||
|
||||
/*--------------------------------------------------------------------------
|
||||
Public Function Prototoypes
|
||||
----------------------------------------------------------------------------*/
|
||||
void free_variables();
|
||||
|
||||
void add_ptr_variable(void *address,
|
||||
const char *string,
|
||||
VALUE default_value,
|
||||
variables_io reader,
|
||||
variables_io writer);
|
||||
|
||||
void add_32bit_variable(void *address,
|
||||
const char *string,
|
||||
VALUE default_value,
|
||||
variables_io reader,
|
||||
variables_io writer);
|
||||
|
||||
void float_read(VARIABLE *variable, char *string);
|
||||
|
||||
void float_write(VARIABLE *variable, char *string);
|
||||
|
||||
void int_read(VARIABLE *variable, char *string);
|
||||
|
||||
void int_write(VARIABLE *variable, char *string);
|
||||
|
||||
void read_variables(const char *filename);
|
||||
|
||||
bool set_old_style_variable(const char* variable, const char* value);
|
||||
|
||||
int same_var_name(void *item1, //VARIABLE *variable,
|
||||
void *item2); //char *string)
|
||||
|
||||
void string_read(VARIABLE *variable, char *string);
|
||||
|
||||
void string_write(VARIABLE *variable, char *string);
|
||||
|
||||
char *strip_line(char *string);
|
||||
#endif
|
Loading…
Reference in New Issue
Block a user