Fixed name collision with jpeg library

git-svn-id: https://tesseract-ocr.googlecode.com/svn/trunk@156 d0cd1f9f-072b-0410-8dd7-cf729c803f20
This commit is contained in:
theraysmith 2008-04-22 00:23:41 +00:00
parent 9cd87f0ec5
commit 4b5609238b
38 changed files with 839 additions and 820 deletions

View File

@ -36,13 +36,13 @@
* This enables data to be located relative to the code.
**********************************************************************/
DLLSYM INT8 getpath( //get dir name of code
DLLSYM inT8 getpath( //get dir name of code
const char *code, //executable to locate
STRING &path //output path name
) {
char directory[MAX_PATH]; //main directory
#ifdef __UNIX__
INT16 dirind; //index in directory
inT16 dirind; //index in directory
register char *pathlist; //$PATH
int fd; //file descriptor
@ -68,7 +68,7 @@ DLLSYM INT8 getpath( //get dir name of code
directory[dirind++] = '/'; //add ending slash
directory[dirind++] = '\0';
path = directory; //try this path
strcat(directory, code);
strcat(directory, code);
fd = open (directory, 0);
if (fd >= 0) {
close(fd); //found it
@ -77,10 +77,10 @@ DLLSYM INT8 getpath( //get dir name of code
}
strcpy (directory, "./");
path = directory; //in current?
strcat(directory, code);
strcat(directory, code);
fd = open (directory, 0);
if (fd >= 0) {
close(fd);
close(fd);
return 0; //in current after all
}
return -1;

View File

@ -25,7 +25,7 @@
#include "notdll.h" //must be last include
DLLSYM INT8 getpath( //get dir name of code
DLLSYM inT8 getpath( //get dir name of code
const char *code, //executable to locate
STRING &path //output path name
);

View File

@ -25,6 +25,6 @@
*
**********************************************************************/
BITS16::BITS16( // constructor
UINT16 init) { // initial val
uinT16 init) { // initial val
val = init;
}

View File

@ -25,27 +25,27 @@
class DLLSYM BITS16
{
public:
UINT16 val;
uinT16 val;
BITS16() {
BITS16() {
val = 0;
} // constructor
BITS16( // constructor
UINT16 init); // initial val
uinT16 init); // initial val
void turn_on_bit( // flip specified bit
UINT8 bit_num) { // bit to flip 0..7
uinT8 bit_num) { // bit to flip 0..7
val = val | 01 << bit_num;
};
void turn_off_bit( // flip specified bit
UINT8 bit_num) { // bit to flip 0..7
uinT8 bit_num) { // bit to flip 0..7
val = val & ~(01 << bit_num);
};
void set_bit( // flip specified bit
UINT8 bit_num, // bit to flip 0..7
uinT8 bit_num, // bit to flip 0..7
BOOL8 value) { // value to flip to
if (value)
val = val | 01 << bit_num;
@ -54,7 +54,7 @@ class DLLSYM BITS16
};
BOOL8 bit( // access bit
UINT8 bit_num) const { // bit to access
uinT8 bit_num) const { // bit to access
return (val >> bit_num) & 01;
};
};

View File

@ -160,9 +160,9 @@ void CLIST::assign_to_sublist( //to this list
* Return count of elements on list
**********************************************************************/
INT32 CLIST::length() { //count elements
inT32 CLIST::length() { //count elements
CLIST_ITERATOR it(this);
INT32 count = 0;
inT32 count = 0;
#ifdef _DEBUG
if (!this)
@ -186,10 +186,10 @@ CLIST::sort ( //sort elements
int comparator ( //comparison routine
const void *, const void *)) {
CLIST_ITERATOR it(this);
INT32 count;
inT32 count;
void **base; //ptr array to sort
void **current;
INT32 i;
inT32 i;
#ifdef _DEBUG
if (!this)
@ -231,7 +231,7 @@ const void *, const void *)) {
void CLIST::prep_serialise() {
CLIST_ITERATOR this_it(this);
INT32 count = 0;
inT32 count = 0;
#ifdef _DEBUG
if (!this)
@ -283,7 +283,7 @@ CLIST::internal_dump (FILE * f, void element_serialiser (FILE *, void *)) {
void
CLIST::internal_de_dump (FILE * f, void *element_de_serialiser (FILE *)) {
INT32 count = (ptrdiff_t) last;
inT32 count = (ptrdiff_t) last;
CLIST_ITERATOR this_it;
#ifdef _DEBUG
@ -353,7 +353,7 @@ void *CLIST_ITERATOR::forward() {
**********************************************************************/
void *CLIST_ITERATOR::data_relative( //get data + or - ...
INT8 offset) { //offset from current
inT8 offset) { //offset from current
CLIST_LINK *ptr;
#ifdef _DEBUG

View File

@ -117,7 +117,7 @@ class DLLSYM CLIST
CLIST_ITERATOR *start_it, //from list start
CLIST_ITERATOR *end_it); //from list end
INT32 length(); //# elements in list
inT32 length(); //# elements in list
void sort ( //sort elements
int comparator ( //comparison routine
@ -208,7 +208,7 @@ class DLLSYM CLIST_ITERATOR
}
void *data_relative( //get data + or - ...
INT8 offset); //offset from current
inT8 offset); //offset from current
void *forward(); //move to next element
@ -244,7 +244,7 @@ class DLLSYM CLIST_ITERATOR
void exchange( //positions of 2 links
CLIST_ITERATOR *other_it); //other iterator
INT32 length(); //# elements in list
inT32 length(); //# elements in list
void sort ( //sort elements
int comparator ( //comparison routine
@ -752,7 +752,7 @@ inline BOOL8 CLIST_ITERATOR::cycled_list() {
*
**********************************************************************/
inline INT32 CLIST_ITERATOR::length() {
inline inT32 CLIST_ITERATOR::length() {
#ifdef _DEBUG
if (!this)
NULL_OBJECT.error ("CLIST_ITERATOR::length", ABORT, NULL);
@ -948,7 +948,7 @@ public: \
{ return (CLASSNAME*) CLIST_ITERATOR::data(); } \
\
CLASSNAME* data_relative( \
INT8 offset) \
inT8 offset) \
{ return (CLASSNAME*) CLIST_ITERATOR::data_relative( offset ); } \
\
CLASSNAME* forward() \

View File

@ -50,11 +50,11 @@ static LCommander *pCommander = NULL;
DEBUG_WIN::DEBUG_WIN( //constructor
const char *title, //of window
INT32 xpos, //initial position
INT32 ypos, //in pixels
INT32 xsize, //initial size
INT32 ysize, //in pixels
INT32 buflines //default scroll size
inT32 xpos, //initial position
inT32 ypos, //in pixels
inT32 xsize, //initial size
inT32 ysize, //in pixels
inT32 buflines //default scroll size
) {
char cmd[1024];
int parm; //output from scrolrwin
@ -94,8 +94,8 @@ DEBUG_WIN::DEBUG_WIN( //constructor
do
Sleep (100);
while (shm_mem[5] == 0); //wait for handle
parm = ((((UINT8) shm_mem[4] << 8) + (UINT8) shm_mem[3] << 8)
+ (UINT8) shm_mem[2] << 8) + (UINT8) shm_mem[1];
parm = ((((uinT8) shm_mem[4] << 8) + (uinT8) shm_mem[3] << 8)
+ (uinT8) shm_mem[2] << 8) + (uinT8) shm_mem[1];
handle = (HWND) parm;
if (handle != NULL) {
//setup window
@ -118,13 +118,13 @@ DEBUG_WIN::~DEBUG_WIN (
if (IsWindow (handle))
::SendMessage (handle, WM_COMMAND, IDOK, 0);
if (shm_mem != NULL)
UnmapViewOfFile(shm_mem);
UnmapViewOfFile(shm_mem);
if (shm_hand != NULL)
CloseHandle(shm_hand);
CloseHandle(shm_hand);
if (dbg_thread != NULL)
CloseHandle(dbg_thread);
CloseHandle(dbg_thread);
if (dbg_process == NULL)
CloseHandle(dbg_process);
CloseHandle(dbg_process);
}
@ -150,8 +150,8 @@ const char *format, ... //special message
msg_end = shm_mem + 1;
va_start(args, format); //variable list
//Format into msg
vsprintf(msg_end, format, args);
va_end(args);
vsprintf(msg_end, format, args);
va_end(args);
if (*msg_end == '\0')
return;
msg_start = shm_mem + 1;
@ -208,14 +208,14 @@ void DEBUG_WIN::await_destruction() { //wait for user to close
DEBUG_WIN::DEBUG_WIN( //constructor
const char *title, //of window
INT32 xpos, //initial position
INT32 ypos, //in pixels
INT32 xsize, //initial size
INT32 ysize, //in pixels
INT32 buflines //default scroll size
inT32 xpos, //initial position
inT32 ypos, //in pixels
inT32 xsize, //initial size
inT32 ysize, //in pixels
inT32 buflines //default scroll size
) {
#ifdef __UNIX__
INT32 length; /*length of name */
inT32 length; /*length of name */
char command[MAX_PATH]; /*pipe command */
pid_t pid; /*process id */
char host[MAX_PATH]; //remote host
@ -266,7 +266,7 @@ DEBUG_WIN::DEBUG_WIN( //constructor
if (fp != NULL) {
/*set no buffering */
if (setvbuf (fp, NULL, _IONBF, BUFSIZ)) {
pclose(fp);
pclose(fp);
fp = NULL;
}
}
@ -284,7 +284,7 @@ DEBUG_WIN::~DEBUG_WIN (
//destructor
) {
#ifdef __UNIX__
pclose(fp);
pclose(fp);
#endif
}
@ -308,9 +308,9 @@ const char *format, ... //special message
vfprintf(fp, format, args); //Format into msg
#else
//Format into msg
vfprintf(stderr, format, args);
vfprintf(stderr, format, args);
#endif
va_end(args);
va_end(args);
}
@ -322,7 +322,7 @@ const char *format, ... //special message
void DEBUG_WIN::await_destruction() { //wait for user to close
#ifdef __UNIX__
signal(SIGPIPE, SIG_IGN);
signal(SIGPIPE, SIG_IGN);
while (!ferror (fp)) {
sleep (1);
fputc (0, fp); //send nulls until error
@ -345,7 +345,7 @@ void DEBUG_WIN::await_destruction() { //wait for user to close
*
* Mac-specific function to set the commander for the next debug window
**********************************************************************/
void DEBUG_WIN::SetCommander(LCommander *pNew) {
void DEBUG_WIN::SetCommander(LCommander *pNew) {
pCommander = pNew;
}
@ -359,13 +359,13 @@ void DEBUG_WIN::SetCommander(LCommander *pNew) {
DEBUG_WIN::DEBUG_WIN( //constructor
const char *title, //of window
INT32 xpos, //initial position
INT32 ypos, //in pixels
INT32 xsize, //initial size
INT32 ysize, //in pixels
INT32 buflines //default scroll size
inT32 xpos, //initial position
inT32 ypos, //in pixels
inT32 xsize, //initial size
inT32 ysize, //in pixels
inT32 buflines //default scroll size
) {
INT32 length; /*length of name */
inT32 length; /*length of name */
// don't replace this DebugStr() with a call to DEBUG_WIN!
@ -406,14 +406,14 @@ const char *format, ... //special message
va_list args; //variable args
static char msg[1024];
INT32 i;
INT32 OriginalLength;
INT32 NewLength;
inT32 i;
inT32 OriginalLength;
inT32 NewLength;
TEHandle hTextEdit;
char *pTempBuffer;
CharsHandle hChar;
char *pOriginalText;
INT32 StringLength;
inT32 StringLength;
pTextEdit = (LTextEdit *) pWindow->FindPaneByID (text_FLOWED);
if (pTextEdit == NULL)
@ -423,7 +423,7 @@ const char *format, ... //special message
va_start(args, format); //variable list
vsprintf(msg, format, args); //Format into msg
va_end(args);
va_end(args);
StringLength = strlen (msg);
@ -468,18 +468,18 @@ const char *format, ... //special message
// put the new text into the text edit item
TESetText(pTempBuffer, NewLength, hTextEdit);
TESetText(pTempBuffer, NewLength, hTextEdit);
// clean up
DisposePtr(pTempBuffer);
DisposePtr(pTempBuffer);
#endif
}
#endif //Mac Implmentation
#else // Non graphical debugger
DEBUG_WIN::DEBUG_WIN( const char*, INT32, INT32, INT32, INT32, INT32 ) {
DEBUG_WIN::DEBUG_WIN( const char*, inT32, inT32, inT32, inT32, inT32 ) {
}
DEBUG_WIN::~DEBUG_WIN () {

View File

@ -62,14 +62,14 @@ class DLLSYM DEBUG_WIN
//the constructor creates the window, the destructor kills it
DEBUG_WIN ( //constructor
const char *title, //of window
INT32 xpos = DEBUG_WIN_XPOS,//initial position
INT32 ypos = DEBUG_WIN_YPOS,//in pixels
inT32 xpos = DEBUG_WIN_XPOS,//initial position
inT32 ypos = DEBUG_WIN_YPOS,//in pixels
//initial size
INT32 xsize = DEBUG_WIN_XSIZE,
inT32 xsize = DEBUG_WIN_XSIZE,
//in pixels
INT32 ysize = DEBUG_WIN_YSIZE,
inT32 ysize = DEBUG_WIN_YSIZE,
//default scroll size (textlines)
INT32 buflines = debug_lines);
inT32 buflines = debug_lines);
~DEBUG_WIN (); //destructor
@ -79,7 +79,7 @@ class DLLSYM DEBUG_WIN
void await_destruction(); //wait for user to close
#ifdef __MAC__
static void SetCommander(LCommander *pCommander);
static void SetCommander(LCommander *pCommander);
#endif
private:

View File

@ -154,9 +154,9 @@ void ELIST::assign_to_sublist( //to this list
* Return count of elements on list
**********************************************************************/
INT32 ELIST::length() { //count elements
inT32 ELIST::length() { //count elements
ELIST_ITERATOR it(this);
INT32 count = 0;
inT32 count = 0;
#ifdef _DEBUG
if (!this)
@ -182,10 +182,10 @@ ELIST::sort ( //sort elements
int comparator ( //comparison routine
const void *, const void *)) {
ELIST_ITERATOR it(this);
INT32 count;
inT32 count;
ELIST_LINK **base; //ptr array to sort
ELIST_LINK **current;
INT32 i;
inT32 i;
#ifdef _DEBUG
if (!this)
@ -227,7 +227,7 @@ const void *, const void *)) {
void ELIST::prep_serialise() {
ELIST_ITERATOR this_it(this);
INT32 count = 0;
inT32 count = 0;
#ifdef _DEBUG
if (!this)
@ -281,7 +281,7 @@ void element_serialiser (FILE *, ELIST_LINK *)) {
void
ELIST::internal_de_dump (FILE * f,
ELIST_LINK * element_de_serialiser (FILE *)) {
INT32 count = (ptrdiff_t) last;
inT32 count = (ptrdiff_t) last;
ELIST_ITERATOR this_it;
ELIST_LINK *de_serialised_element;
@ -356,7 +356,7 @@ ELIST_LINK *ELIST_ITERATOR::forward() {
**********************************************************************/
ELIST_LINK *ELIST_ITERATOR::data_relative( //get data + or - ...
INT8 offset) { //offset from current
inT8 offset) { //offset from current
ELIST_LINK *ptr;
#ifdef _DEBUG

View File

@ -32,24 +32,24 @@ This module implements list classes and iterators.
The following list types and iterators are provided:
List type List Class Iterator Class Element Class
--------- ---------- -------------- -------------
--------- ---------- -------------- -------------
Embedded list ELIST
Embedded list ELIST
ELIST_ITERATOR
ELIST_LINK
(Single linked)
Embedded list ELIST2
Embedded list ELIST2
ELIST2_ITERATOR
ELIST2_LINK
(Double linked)
Cons List CLIST
Cons List CLIST
CLIST_ITERATOR
CLIST_LINK
(Single linked)
Cons List CLIST2
Cons List CLIST2
CLIST2_ITERATOR
CLIST2_LINK
(Double linked)
@ -72,9 +72,9 @@ lists.
**********************************************************************/
/**********************************************************************
* CLASS - ELIST_LINK
* CLASS - ELIST_LINK
*
* Generic link class for singly linked lists with embedded links
* Generic link class for singly linked lists with embedded links
*
* Note: No destructor - elements are assumed to be destroyed EITHER after
* they have been extracted from a list OR by the ELIST destructor which
@ -162,7 +162,7 @@ class DLLSYM ELIST
ELIST_ITERATOR *start_it, //from list start
ELIST_ITERATOR *end_it); //from list end
INT32 length(); //# elements in list
inT32 length(); //# elements in list
void sort ( //sort elements
int comparator ( //comparison routine
@ -189,9 +189,9 @@ class DLLSYM ELIST
};
/***********************************************************************
* CLASS - ELIST_ITERATOR
* CLASS - ELIST_ITERATOR
*
* Generic iterator class for singly linked lists with embedded links
* Generic iterator class for singly linked lists with embedded links
**********************************************************************/
class DLLSYM ELIST_ITERATOR
@ -254,7 +254,7 @@ class DLLSYM ELIST_ITERATOR
}
ELIST_LINK *data_relative( //get data + or - ...
INT8 offset); //offset from current
inT8 offset); //offset from current
ELIST_LINK *forward(); //move to next element
@ -290,7 +290,7 @@ class DLLSYM ELIST_ITERATOR
void exchange( //positions of 2 links
ELIST_ITERATOR *other_it); //other iterator
INT32 length(); //# elements in list
inT32 length(); //# elements in list
void sort ( //sort elements
int comparator ( //comparison routine
@ -299,7 +299,7 @@ class DLLSYM ELIST_ITERATOR
};
/***********************************************************************
* ELIST_ITERATOR::set_to_list
* ELIST_ITERATOR::set_to_list
*
* (Re-)initialise the iterator to point to the start of the list_to_iterate
* over.
@ -327,7 +327,7 @@ inline void ELIST_ITERATOR::set_to_list( //change list
/***********************************************************************
* ELIST_ITERATOR::ELIST_ITERATOR
* ELIST_ITERATOR::ELIST_ITERATOR
*
* CONSTRUCTOR - set iterator to specified list;
**********************************************************************/
@ -338,7 +338,7 @@ inline ELIST_ITERATOR::ELIST_ITERATOR(ELIST *list_to_iterate) {
/***********************************************************************
* ELIST_ITERATOR::add_after_then_move
* ELIST_ITERATOR::add_after_then_move
*
* Add a new element to the list after the current element and move the
* iterator to the new element.
@ -385,7 +385,7 @@ inline void ELIST_ITERATOR::add_after_then_move( // element to add
/***********************************************************************
* ELIST_ITERATOR::add_after_stay_put
* ELIST_ITERATOR::add_after_stay_put
*
* Add a new element to the list after the current element but do not move
* the iterator to the new element.
@ -435,7 +435,7 @@ inline void ELIST_ITERATOR::add_after_stay_put( // element to add
/***********************************************************************
* ELIST_ITERATOR::add_before_then_move
* ELIST_ITERATOR::add_before_then_move
*
* Add a new element to the list before the current element and move the
* iterator to the new element.
@ -479,7 +479,7 @@ inline void ELIST_ITERATOR::add_before_then_move( // element to add
/***********************************************************************
* ELIST_ITERATOR::add_before_stay_put
* ELIST_ITERATOR::add_before_stay_put
*
* Add a new element to the list before the current element but dont move the
* iterator to the new element.
@ -524,7 +524,7 @@ inline void ELIST_ITERATOR::add_before_stay_put( // element to add
/***********************************************************************
* ELIST_ITERATOR::add_list_after
* ELIST_ITERATOR::add_list_after
*
* Insert another list to this list after the current element but dont move the
* iterator.
@ -573,7 +573,7 @@ inline void ELIST_ITERATOR::add_list_after(ELIST *list_to_add) {
/***********************************************************************
* ELIST_ITERATOR::add_list_before
* ELIST_ITERATOR::add_list_before
*
* Insert another list to this list before the current element. Move the
* iterator to the start of the inserted elements
@ -620,7 +620,7 @@ inline void ELIST_ITERATOR::add_list_before(ELIST *list_to_add) {
/***********************************************************************
* ELIST_ITERATOR::extract
* ELIST_ITERATOR::extract
*
* Do extraction by removing current from the list, returning it to the
* caller, but NOT updating the iterator. (So that any calling loop can do
@ -667,7 +667,7 @@ inline ELIST_LINK *ELIST_ITERATOR::extract() {
/***********************************************************************
* ELIST_ITERATOR::move_to_first()
* ELIST_ITERATOR::move_to_first()
*
* Move current so that it is set to the start of the list.
* Return data just in case anyone wants it.
@ -689,7 +689,7 @@ inline ELIST_LINK *ELIST_ITERATOR::move_to_first() {
/***********************************************************************
* ELIST_ITERATOR::mark_cycle_pt()
* ELIST_ITERATOR::mark_cycle_pt()
*
* Remember the current location so that we can tell whether we've returned
* to this point later.
@ -716,7 +716,7 @@ inline void ELIST_ITERATOR::mark_cycle_pt() {
/***********************************************************************
* ELIST_ITERATOR::at_first()
* ELIST_ITERATOR::at_first()
*
* Are we at the start of the list?
*
@ -738,7 +738,7 @@ inline BOOL8 ELIST_ITERATOR::at_first() {
/***********************************************************************
* ELIST_ITERATOR::at_last()
* ELIST_ITERATOR::at_last()
*
* Are we at the end of the list?
*
@ -760,7 +760,7 @@ inline BOOL8 ELIST_ITERATOR::at_last() {
/***********************************************************************
* ELIST_ITERATOR::cycled_list()
* ELIST_ITERATOR::cycled_list()
*
* Have we returned to the cycle_pt since it was set?
*
@ -780,13 +780,13 @@ inline BOOL8 ELIST_ITERATOR::cycled_list() {
/***********************************************************************
* ELIST_ITERATOR::length()
* ELIST_ITERATOR::length()
*
* Return the length of the list
*
**********************************************************************/
inline INT32 ELIST_ITERATOR::length() {
inline inT32 ELIST_ITERATOR::length() {
#ifdef _DEBUG
if (!this)
NULL_OBJECT.error ("ELIST_ITERATOR::length", ABORT, NULL);
@ -799,7 +799,7 @@ inline INT32 ELIST_ITERATOR::length() {
/***********************************************************************
* ELIST_ITERATOR::sort()
* ELIST_ITERATOR::sort()
*
* Sort the elements of the list, then reposition at the start.
*
@ -822,7 +822,7 @@ const void *, const void *)) {
/***********************************************************************
* ELIST_ITERATOR::add_to_end
* ELIST_ITERATOR::add_to_end
*
* Add a new element to the end of the list without moving the iterator.
* This is provided because a single linked list cannot move to the last as
@ -889,7 +889,7 @@ The macros generate:
- An element copier function: CLASSNAME##_copier
- An element serialiser function" CLASSNAME##_serialiser
- An element de-serialiser function" CLASSNAME##_de_serialiser
- An E_LIST subclass: CLASSNAME##_LIST
- An E_LIST subclass: CLASSNAME##_LIST
- An E_LIST_ITERATOR subclass: CLASSNAME##_IT
NOTE: Generated names are DELIBERATELY designed to clash with those for
@ -912,129 +912,129 @@ ELISTIZEH_C. ELISTIZEH is simply a concatenation of these parts.
ELISTIZEH_S has some additional bits thrown in the gaps.
***********************************************************************/
#define ELISTIZEH_A( CLASSNAME ) \
\
extern DLLSYM void CLASSNAME##_zapper( /*delete a link*/ \
ELIST_LINK* link); /*link to delete*/ \
\
extern DLLSYM ELIST_LINK* CLASSNAME##_copier( /*deep copy a link*/ \
ELIST_LINK* old_element); /*source link */
#define ELISTIZEH_A( CLASSNAME ) \
\
extern DLLSYM void CLASSNAME##_zapper( /*delete a link*/ \
ELIST_LINK* link); /*link to delete*/ \
\
extern DLLSYM ELIST_LINK* CLASSNAME##_copier( /*deep copy a link*/ \
ELIST_LINK* old_element); /*source link */
#define ELISTIZEH_B( CLASSNAME ) \
\
/*********************************************************************** \
* CLASS - CLASSNAME##_LIST \
* \
* List class for class CLASSNAME \
* \
**********************************************************************/ \
\
class DLLSYM CLASSNAME##_LIST : public ELIST \
{ \
public: \
CLASSNAME##_LIST():ELIST() {}\
/* constructor */ \
\
CLASSNAME##_LIST( /* dont construct */ \
const CLASSNAME##_LIST&) /*by initial assign*/\
{ DONT_CONSTRUCT_LIST_BY_COPY.error( QUOTE_IT( CLASSNAME##_LIST ), \
ABORT, NULL ); } \
\
void clear() /* delete elements */\
{ ELIST::internal_clear( &CLASSNAME##_zapper ); } \
\
~CLASSNAME##_LIST() /* destructor */ \
{ clear(); } \
\
void deep_copy( /* become a deep */ \
const CLASSNAME##_LIST* list) /* copy of src list*/\
{ ELIST::internal_deep_copy( &CLASSNAME##_copier, list ); } \
\
void operator=( /* prevent assign */ \
const CLASSNAME##_LIST&) \
{ DONT_ASSIGN_LISTS.error( QUOTE_IT( CLASSNAME##_LIST ), \
ABORT, NULL ); }
#define ELISTIZEH_B( CLASSNAME ) \
\
/*********************************************************************** \
* CLASS - CLASSNAME##_LIST \
* \
* List class for class CLASSNAME \
* \
**********************************************************************/ \
\
class DLLSYM CLASSNAME##_LIST : public ELIST \
{ \
public: \
CLASSNAME##_LIST():ELIST() {}\
/* constructor */ \
\
CLASSNAME##_LIST( /* dont construct */ \
const CLASSNAME##_LIST&) /*by initial assign*/\
{ DONT_CONSTRUCT_LIST_BY_COPY.error( QUOTE_IT( CLASSNAME##_LIST ), \
ABORT, NULL ); } \
\
void clear() /* delete elements */\
{ ELIST::internal_clear( &CLASSNAME##_zapper ); } \
\
~CLASSNAME##_LIST() /* destructor */ \
{ clear(); } \
\
void deep_copy( /* become a deep */ \
const CLASSNAME##_LIST* list) /* copy of src list*/\
{ ELIST::internal_deep_copy( &CLASSNAME##_copier, list ); } \
\
void operator=( /* prevent assign */ \
const CLASSNAME##_LIST&) \
{ DONT_ASSIGN_LISTS.error( QUOTE_IT( CLASSNAME##_LIST ), \
ABORT, NULL ); }
#define ELISTIZEH_C( CLASSNAME ) \
}; \
\
\
\
/*********************************************************************** \
* CLASS - CLASSNAME##_IT \
* \
* Iterator class for class CLASSNAME##_LIST \
* \
* Note: We don't need to coerce pointers to member functions input \
* parameters as these are automatically converted to the type of the base \
* type. ("A ptr to a class may be converted to a pointer to a public base \
* class of that class") \
**********************************************************************/ \
\
class DLLSYM CLASSNAME##_IT : public ELIST_ITERATOR \
{ \
public: \
CLASSNAME##_IT():ELIST_ITERATOR(){} \
\
CLASSNAME##_IT( \
CLASSNAME##_LIST* list):ELIST_ITERATOR(list){} \
\
CLASSNAME* data() \
{ return (CLASSNAME*) ELIST_ITERATOR::data(); } \
\
CLASSNAME* data_relative( \
INT8 offset) \
{ return (CLASSNAME*) ELIST_ITERATOR::data_relative( offset ); } \
\
CLASSNAME* forward() \
{ return (CLASSNAME*) ELIST_ITERATOR::forward(); } \
\
CLASSNAME* extract() \
{ return (CLASSNAME*) ELIST_ITERATOR::extract(); } \
\
CLASSNAME* move_to_first() \
{ return (CLASSNAME*) ELIST_ITERATOR::move_to_first(); } \
\
CLASSNAME* move_to_last() \
{ return (CLASSNAME*) ELIST_ITERATOR::move_to_last(); } \
#define ELISTIZEH_C( CLASSNAME ) \
}; \
\
\
\
/*********************************************************************** \
* CLASS - CLASSNAME##_IT \
* \
* Iterator class for class CLASSNAME##_LIST \
* \
* Note: We don't need to coerce pointers to member functions input \
* parameters as these are automatically converted to the type of the base \
* type. ("A ptr to a class may be converted to a pointer to a public base \
* class of that class") \
**********************************************************************/ \
\
class DLLSYM CLASSNAME##_IT : public ELIST_ITERATOR \
{ \
public: \
CLASSNAME##_IT():ELIST_ITERATOR(){} \
\
CLASSNAME##_IT( \
CLASSNAME##_LIST* list):ELIST_ITERATOR(list){} \
\
CLASSNAME* data() \
{ return (CLASSNAME*) ELIST_ITERATOR::data(); } \
\
CLASSNAME* data_relative( \
inT8 offset) \
{ return (CLASSNAME*) ELIST_ITERATOR::data_relative( offset ); } \
\
CLASSNAME* forward() \
{ return (CLASSNAME*) ELIST_ITERATOR::forward(); } \
\
CLASSNAME* extract() \
{ return (CLASSNAME*) ELIST_ITERATOR::extract(); } \
\
CLASSNAME* move_to_first() \
{ return (CLASSNAME*) ELIST_ITERATOR::move_to_first(); } \
\
CLASSNAME* move_to_last() \
{ return (CLASSNAME*) ELIST_ITERATOR::move_to_last(); } \
};
#define ELISTIZEH( CLASSNAME ) \
\
ELISTIZEH_A( CLASSNAME ) \
\
ELISTIZEH_B( CLASSNAME ) \
\
#define ELISTIZEH( CLASSNAME ) \
\
ELISTIZEH_A( CLASSNAME ) \
\
ELISTIZEH_B( CLASSNAME ) \
\
ELISTIZEH_C( CLASSNAME )
#define ELISTIZEH_S( CLASSNAME ) \
\
ELISTIZEH_A( CLASSNAME ) \
\
extern DLLSYM void CLASSNAME##_serialiser( \
FILE* f, \
ELIST_LINK* element); \
\
extern DLLSYM ELIST_LINK* CLASSNAME##_de_serialiser( \
FILE* f); \
\
ELISTIZEH_B( CLASSNAME ) \
\
void dump( /* dump to file */ \
FILE* f) \
{ ELIST::internal_dump( f, &CLASSNAME##_serialiser );} \
\
void de_dump( /* get from file */ \
FILE* f) \
{ ELIST::internal_de_dump( f, &CLASSNAME##_de_serialiser );} \
\
void serialise_asc( /*dump to ascii*/ \
FILE* f); \
void de_serialise_asc( /*de-dump from ascii*/\
FILE* f); \
\
make_serialise( CLASSNAME##_LIST ) \
\
#define ELISTIZEH_S( CLASSNAME ) \
\
ELISTIZEH_A( CLASSNAME ) \
\
extern DLLSYM void CLASSNAME##_serialiser( \
FILE* f, \
ELIST_LINK* element); \
\
extern DLLSYM ELIST_LINK* CLASSNAME##_de_serialiser( \
FILE* f); \
\
ELISTIZEH_B( CLASSNAME ) \
\
void dump( /* dump to file */ \
FILE* f) \
{ ELIST::internal_dump( f, &CLASSNAME##_serialiser );} \
\
void de_dump( /* get from file */ \
FILE* f) \
{ ELIST::internal_de_dump( f, &CLASSNAME##_de_serialiser );} \
\
void serialise_asc( /*dump to ascii*/ \
FILE* f); \
void de_serialise_asc( /*de-dump from ascii*/\
FILE* f); \
\
make_serialise( CLASSNAME##_LIST ) \
\
ELISTIZEH_C( CLASSNAME )
/***********************************************************************
@ -1043,104 +1043,103 @@ ELISTIZE_S is a simple extension to ELISTIZE
***********************************************************************/
#define ELISTIZE( CLASSNAME ) \
\
/*********************************************************************** \
* CLASSNAME##_zapper \
* \
* A function which can delete a CLASSNAME element. This is passed to the \
* generic clear list member function so that when a list is cleared the \
* elements on the list are properly destroyed from the base class, even \
* though we dont use a virtual destructor function. \
**********************************************************************/ \
\
DLLSYM void CLASSNAME##_zapper( /*delete a link*/ \
ELIST_LINK* link) /*link to delete*/ \
{ \
delete (CLASSNAME *) link; \
} \
\
/*********************************************************************** \
* CLASSNAME##_copier \
* \
* A function which can generate a new, deep copy of a CLASSNAME element. \
\
/*********************************************************************** \
* CLASSNAME##_zapper \
* \
* A function which can delete a CLASSNAME element. This is passed to the \
* generic clear list member function so that when a list is cleared the \
* elements on the list are properly destroyed from the base class, even \
* though we dont use a virtual destructor function. \
**********************************************************************/ \
\
DLLSYM void CLASSNAME##_zapper( /*delete a link*/ \
ELIST_LINK* link) /*link to delete*/ \
{ \
delete (CLASSNAME *) link; \
} \
\
/*********************************************************************** \
* CLASSNAME##_copier \
* \
* A function which can generate a new, deep copy of a CLASSNAME element. \
* This is passed to the generic deep copy list member function so that when \
* a list is copied the elements on the list are properly copied from the \
* base class, even though we dont use a virtual function. \
**********************************************************************/ \
\
DLLSYM ELIST_LINK* CLASSNAME##_copier( /*deep copy a link*/ \
ELIST_LINK* old_element) /*source link*/ \
{ \
CLASSNAME* new_element; \
\
new_element = new CLASSNAME; \
*new_element = *((CLASSNAME*) old_element); \
return (ELIST_LINK*) new_element; \
* a list is copied the elements on the list are properly copied from the \
* base class, even though we dont use a virtual function. \
**********************************************************************/ \
\
DLLSYM ELIST_LINK* CLASSNAME##_copier( /*deep copy a link*/ \
ELIST_LINK* old_element) /*source link*/ \
{ \
CLASSNAME* new_element; \
\
new_element = new CLASSNAME(*reinterpret_cast<CLASSNAME*>(old_element)); \
return (ELIST_LINK*) new_element; \
}
#define ELISTIZE_S( CLASSNAME ) \
\
ELISTIZE( CLASSNAME ) \
\
void CLASSNAME##_LIST::serialise_asc( \
/*dump to ascii*/ \
FILE* f) \
{ \
CLASSNAME##_IT it(this); \
\
serialise_INT32(f,length()); \
for (it.mark_cycle_pt();!it.cycled_list();it.forward()) \
it.data()->serialise_asc(f); /*serialise the list*/\
} \
\
void CLASSNAME##_LIST::de_serialise_asc( \
/*de-dump from ascii*/\
FILE* f) \
{ \
INT32 len; /*length to retrive*/\
CLASSNAME##_IT it; \
CLASSNAME* new_elt=NULL; /*list element*/ \
\
len=de_serialise_INT32(f); \
it.set_to_list(this); \
for (;len>0;len--) \
{ \
new_elt=new CLASSNAME; \
new_elt->de_serialise_asc(f); \
it.add_to_end(new_elt); /*put on the list*/ \
} \
return; \
} \
\
\
/*********************************************************************** \
* CLASSNAME##_serialiser \
* \
* A function which can serialise an element \
#define ELISTIZE_S( CLASSNAME ) \
\
ELISTIZE( CLASSNAME ) \
\
void CLASSNAME##_LIST::serialise_asc( \
/*dump to ascii*/ \
FILE* f) \
{ \
CLASSNAME##_IT it(this); \
\
serialise_INT32(f,length()); \
for (it.mark_cycle_pt();!it.cycled_list();it.forward()) \
it.data()->serialise_asc(f); /*serialise the list*/\
} \
\
void CLASSNAME##_LIST::de_serialise_asc( \
/*de-dump from ascii*/\
FILE* f) \
{ \
inT32 len; /*length to retrive*/\
CLASSNAME##_IT it; \
CLASSNAME* new_elt=NULL; /*list element*/ \
\
len=de_serialise_INT32(f); \
it.set_to_list(this); \
for (;len>0;len--) \
{ \
new_elt=new CLASSNAME; \
new_elt->de_serialise_asc(f); \
it.add_to_end(new_elt); /*put on the list*/ \
} \
return; \
} \
\
\
/*********************************************************************** \
* CLASSNAME##_serialiser \
* \
* A function which can serialise an element \
* This is passed to the generic dump member function so that when a list is \
* serialised the elements on the list are properly serialised. \
**********************************************************************/ \
\
DLLSYM void CLASSNAME##_serialiser( \
FILE* f, \
ELIST_LINK* element) \
{ \
((CLASSNAME*) element)->serialise( f ); \
} \
\
\
\
/*********************************************************************** \
* CLASSNAME##_de_serialiser \
* \
* A function which can de-serialise an element \
* serialised the elements on the list are properly serialised. \
**********************************************************************/ \
\
DLLSYM void CLASSNAME##_serialiser( \
FILE* f, \
ELIST_LINK* element) \
{ \
((CLASSNAME*) element)->serialise( f ); \
} \
\
\
\
/*********************************************************************** \
* CLASSNAME##_de_serialiser \
* \
* A function which can de-serialise an element \
* This is passed to the generic de-dump member function so that when a list \
* is de-serialised the elements on the list are properly de-serialised. \
**********************************************************************/ \
\
DLLSYM ELIST_LINK* CLASSNAME##_de_serialiser( \
FILE* f) \
{ \
return (ELIST_LINK*) CLASSNAME::de_serialise( f ); \
* is de-serialised the elements on the list are properly de-serialised. \
**********************************************************************/ \
\
DLLSYM ELIST_LINK* CLASSNAME##_de_serialiser( \
FILE* f) \
{ \
return (ELIST_LINK*) CLASSNAME::de_serialise( f ); \
}
#endif

View File

@ -130,9 +130,9 @@ void ELIST2::assign_to_sublist( //to this list
* Return count of elements on list
**********************************************************************/
INT32 ELIST2::length() { //count elements
inT32 ELIST2::length() { //count elements
ELIST2_ITERATOR it(this);
INT32 count = 0;
inT32 count = 0;
#ifdef _DEBUG
if (!this)
@ -158,10 +158,10 @@ ELIST2::sort ( //sort elements
int comparator ( //comparison routine
const void *, const void *)) {
ELIST2_ITERATOR it(this);
INT32 count;
inT32 count;
ELIST2_LINK **base; //ptr array to sort
ELIST2_LINK **current;
INT32 i;
inT32 i;
#ifdef _DEBUG
if (!this)
@ -203,7 +203,7 @@ const void *, const void *)) {
void ELIST2::prep_serialise() {
ELIST2_ITERATOR this_it(this);
INT32 count = 0;
inT32 count = 0;
#ifdef _DEBUG
if (!this)
@ -257,7 +257,7 @@ void element_serialiser (FILE *, ELIST2_LINK *)) {
void
ELIST2::internal_de_dump (FILE * f,
ELIST2_LINK * element_de_serialiser (FILE *)) {
INT32 count = (ptrdiff_t) last;
inT32 count = (ptrdiff_t) last;
ELIST2_ITERATOR this_it;
ELIST2_LINK *de_serialised_element;
@ -374,7 +374,7 @@ ELIST2_LINK *ELIST2_ITERATOR::backward() {
**********************************************************************/
ELIST2_LINK *ELIST2_ITERATOR::data_relative( //get data + or - ..
INT8 offset) { //offset from current
inT8 offset) { //offset from current
ELIST2_LINK *ptr;
#ifdef _DEBUG

View File

@ -131,7 +131,7 @@ class DLLSYM ELIST2
ELIST2_ITERATOR *start_it, //from list start
ELIST2_ITERATOR *end_it); //from list end
INT32 length(); //# elements in list
inT32 length(); //# elements in list
void sort ( //sort elements
int comparator ( //comparison routine
@ -223,7 +223,7 @@ class DLLSYM ELIST2_ITERATOR
}
ELIST2_LINK *data_relative( //get data + or - ...
INT8 offset); //offset from current
inT8 offset); //offset from current
ELIST2_LINK *forward(); //move to next element
@ -262,7 +262,7 @@ class DLLSYM ELIST2_ITERATOR
void exchange( //positions of 2 links
ELIST2_ITERATOR *other_it); //other iterator
INT32 length(); //# elements in list
inT32 length(); //# elements in list
void sort ( //sort elements
int comparator ( //comparison routine
@ -808,7 +808,7 @@ inline BOOL8 ELIST2_ITERATOR::cycled_list() {
*
**********************************************************************/
inline INT32 ELIST2_ITERATOR::length() {
inline inT32 ELIST2_ITERATOR::length() {
#ifdef _DEBUG
if (!this)
NULL_OBJECT.error ("ELIST2_ITERATOR::length", ABORT, NULL);
@ -1005,7 +1005,7 @@ CLASSNAME##_LIST* list):ELIST2_ITERATOR(list){} \
{ return (CLASSNAME*) ELIST2_ITERATOR::data(); } \
\
CLASSNAME* data_relative( \
INT8 offset) \
inT8 offset) \
{ return (CLASSNAME*) ELIST2_ITERATOR::data_relative( offset ); } \
\
CLASSNAME* forward() \

View File

@ -31,7 +31,7 @@
const ERRCODE BADERRACTION = "Illegal error action";
#define MAX_MSG 1024
extern INT16 global_abort_code;
extern inT16 global_abort_code;
/**********************************************************************
* error
@ -43,7 +43,7 @@ extern INT16 global_abort_code;
void
ERRCODE::error ( //handle error
const char *caller, //name of caller
INT8 action, //action to take
inT8 action, //action to take
const char *format, ... //special message
) const
{

View File

@ -70,7 +70,7 @@ class DLLSYM ERRCODE //error handler class
public:
void error ( //error print function
const char *caller, //function location
INT8 action, //action to take
inT8 action, //action to take
const char *format, ... //fprintf format
) const;
ERRCODE(const char *string) {

View File

@ -22,12 +22,12 @@
#include "errcode.h"
#include "tprintf.h"
INT16 global_loc_code = LOC_INIT;//location code
INT16 global_subloc_code = SUBLOC_NORM;
inT16 global_loc_code = LOC_INIT;//location code
inT16 global_subloc_code = SUBLOC_NORM;
//pass2 subloc code
INT16 global_subsubloc_code = SUBSUBLOC_OTHER;
inT16 global_subsubloc_code = SUBSUBLOC_OTHER;
//location code
INT16 global_abort_code = NO_ABORT_CODE;
inT16 global_abort_code = NO_ABORT_CODE;
//Prog abort code
void signal_exit( //
@ -49,7 +49,7 @@ void signal_exit( //
exit_status, global_loc_code, signal_code);
}
exit(exit_status);
exit(exit_status);
}
@ -69,7 +69,7 @@ void signal_exit( //
//extern "C" {
void err_exit() {
void err_exit() {
signal_exit (-1);
}
@ -95,19 +95,19 @@ void signal_termination_handler( //The real signal
//}; //end extern "C"
void set_global_loc_code(int loc_code) {
void set_global_loc_code(int loc_code) {
global_loc_code = loc_code;
}
void set_global_subloc_code(int loc_code) {
void set_global_subloc_code(int loc_code) {
global_subloc_code = loc_code;
}
void set_global_subsubloc_code(int loc_code) {
void set_global_subsubloc_code(int loc_code) {
global_subsubloc_code = loc_code;
}

View File

@ -27,15 +27,15 @@
* Uses xor function. Needs linear rehash.
**********************************************************************/
INT32 hash( //hash function
INT32 bits, //bits in hash function
inT32 hash( //hash function
inT32 bits, //bits in hash function
void *key, //key to hash
INT32 keysize //size of key
inT32 keysize //size of key
) {
INT32 bitindex; //current bit count
UINT32 keybits; //bit buffer
UINT32 hcode; //current hash code
UINT32 mask; //bit mask
inT32 bitindex; //current bit count
uinT32 keybits; //bit buffer
uinT32 hcode; //current hash code
uinT32 mask; //bit mask
mask = (1 << bits) - 1;
keysize *= 8; //in bits
@ -44,8 +44,8 @@ INT32 hash( //hash function
hcode = 0;
do {
while (keysize > 0 && bitindex <= 24) {
keybits |= *((UINT8 *) key) << bitindex;
key = (UINT8 *) key + 1;
keybits |= *((uinT8 *) key) << bitindex;
key = (uinT8 *) key + 1;
bitindex += 8;
keysize -= 8;
}

View File

@ -22,9 +22,9 @@
#include "host.h"
INT32 hash( //hash function
INT32 bits, //bits in hash function
inT32 hash( //hash function
inT32 bits, //bits in hash function
void *key, //key to hash
INT32 keysize //size of key
inT32 keysize //size of key
);
#endif

View File

@ -26,9 +26,9 @@
** FILE_HANDLE, MEMORY_HANDLE, BOOL8,
** MAX_INT8, MAX_INT16, MAX_INT32, MAX_UINT8
** MAX_UINT16, MAX_UINT32, MAX_FLOAT32
** 06/19/96 MCD. Took out MAX_FLOAT32
** 07/15/96 MCD. Fixed the comments error
** Add back BOOL8.
** 06/19/96 MCD. Took out MAX_FLOAT32
** 07/15/96 MCD. Fixed the comments error
** Add back BOOL8.
**
** (c) Copyright Hewlett-Packard Company, 1988-1996.
** Licensed under the Apache License, Version 2.0 (the "License");
@ -68,9 +68,6 @@
#define DLLIMPORT __declspec( dllimport)
#define DLLEXPORT __declspec( dllexport)
typedef HANDLE FILE_HANDLE;
typedef HANDLE MEMORY_HANDLE;
#else
/********************************************************/
/* __MSW__ */
@ -79,14 +76,6 @@ typedef HANDLE MEMORY_HANDLE;
#define DLLIMPORT __import
#define DLLEXPORT __export
/*----------------------------*/
/*----------------------------*/
typedef HANDLE FILE_HANDLE;
typedef HANDLE MEMORY_HANDLE;
/*----------------------------*/
#ifndef BOOLEAN
typedef UINT16 BOOLEAN;
#endif // BOOLEAN
#endif
#endif
@ -99,15 +88,6 @@ typedef UINT16 BOOLEAN;
#define DLLIMPORT
#define DLLEXPORT
// definitions of handles to relocatable blocks
typedef Handle HANDLE; // a handle to a relocatable memory block
typedef short FILE_HANDLE;
typedef Handle MEMORY_HANDLE;
/*----------------------------*/
#ifndef BOOLEAN
#define BOOLEAN Boolean
#endif
#endif
/********************************************************/
#if defined(__UNIX__) || defined( __DOS__ ) || defined(__OS2__) || defined(__PM__)
@ -116,13 +96,7 @@ typedef Handle MEMORY_HANDLE;
/*----------------------------*/
#define DLLIMPORT
#define DLLEXPORT
typedef void *HANDLE;
typedef HANDLE FILE_HANDLE;
typedef HANDLE MEMORY_HANDLE;
/*----------------------------*/
#ifndef BOOLEAN
typedef unsigned short BOOLEAN;
#endif // BOOLEAN
#endif
/*****************************************************************************
**
@ -139,49 +113,23 @@ typedef unsigned short BOOLEAN;
//typedef HANDLE FD* PHANDLE;
// definitions of portable data types (numbers and characters)
#if (_MSC_VER < 1400) // For VC 8.0.
typedef SIGNED char INT8;
#endif
typedef unsigned char UINT8;
typedef short INT16;
typedef unsigned short UINT16;
#if (_MSC_VER < 1200) //%%% vkr for VC 6.0
typedef int INT32;
typedef unsigned int UINT32;
typedef long long int INT64;
typedef unsigned long long int UINT64;
typedef SIGNED char inT8;
typedef unsigned char uinT8;
typedef short inT16;
typedef unsigned short uinT16;
typedef int inT32;
typedef unsigned int uinT32;
#if (_MSC_VER >= 1200) //%%% vkr for VC 6.0
typedef INT64 inT64;
typedef UINT64 uinT64;
#else
typedef long long int inT64;
typedef unsigned long long int uinT64;
#endif //%%% vkr for VC 6.0
typedef float FLOAT32;
typedef double FLOAT64;
typedef unsigned char BOOL8;
// definitions of pointers to portable data types
#if (_MSC_VER < 1400) // For VC 8.0.
typedef SIGNED char *PINT8;
#endif
typedef unsigned char *PUINT8;
typedef short *PINT16;
typedef unsigned short *PUINT16;
#if (_MSC_VER < 1200) //%%% vkr for VC 6.0
typedef int *PINT32;
typedef unsigned int *PUINT32;
#endif //%%% vkr for VC 6.0
typedef float *PFLOAT32;
typedef double *PFLOAT64;
// these are pointers to constant values (not constant pointers)
typedef const SIGNED char *PCINT8;
typedef const unsigned char *PCUINT8;
typedef const short *PCINT16;
typedef const unsigned short *PCUINT16;
typedef const int *PCINT32;
typedef const unsigned int *PCUINT32;
typedef const float *PCFLOAT32;
typedef const double *PCFLOAT64;
typedef void *PVOID;
#define INT32FORMAT "%d"
#define INT64FORMAT "%lld"
@ -222,57 +170,5 @@ typedef void *PVOID;
#ifndef NULL
#define NULL 0L
#endif
/******************************************************************************
** WARNING!! **
** Below are definition that will be obsoleted in the next version. Please **
** do not continue to use the definition under __OLDCODE__. **
*****************************************************************************/
#ifdef __OLDCODE__
#ifdef __MSW32__
#ifdef ERROR // Use HPERR
#undef ERROR
#define ERROR -1
#endif
typedef double FLOATHP;
#else
#ifdef __MSW__
#ifdef ERROR // Use HPERR
#undef ERROR
#define ERROR -1
#endif
typedef double FLOAT;
typedef double FLOATHP;
typedef FLOAT FD *PFLOAT;
#endif
#endif
#ifdef __MAC__
typedef float FLOAT;
typedef float FLOATHP;
typedef FLOAT FD *PFLOAT;
#endif
#ifdef __UNIX__
typedef float FLOAT;
typedef float FLOATHP;
typedef FLOAT FD *PFLOAT;
#endif
#ifdef __DOS__
typedef float FLOAT;
typedef float FLOATHP;
typedef FLOAT FD *PFLOAT;
#endif
// definitions of pointers to functions that take no parameters
// specific definitions should be provided for functions that take parameters
typedef void (far * PFVOID) (); /* pointer to function */
typedef INT16 (*PFINT16) (void);
typedef INT32 (*PFINT32) (void);
typedef BOOLEAN *PBOOLEAN; // a pointer to a Boolean
#endif
#endif

View File

@ -57,8 +57,8 @@ void main_setup( /*main demo program */
int argc, /*argument count */
const char *const *argv /*arguments */
) {
INT32 arg; /*argument */
INT32 offset; //for flag
inT32 arg; /*argument */
inT32 offset; //for flag
FILE *fp; /*variables file */
char flag[2]; //+/-
STRING varfile; /*name of file */

View File

@ -55,16 +55,16 @@ EXTERN MEM_ALLOCATOR main_mem;
//heads of freelists
EXTERN MEMUNION *free_structs[MAX_STRUCTS];
//number issued
EXTERN INT32 structs_in_use[MAX_STRUCTS];
EXTERN inT32 structs_in_use[MAX_STRUCTS];
//number issued
EXTERN INT32 blocks_in_use[MAX_STRUCTS];
EXTERN inT32 blocks_in_use[MAX_STRUCTS];
//head of block lists
EXTERN MEMUNION *struct_blocks[MAX_STRUCTS];
EXTERN const char *owner_names[MAX_STRUCTS][MAX_CLASSES];
EXTERN INT32 owner_counts[MAX_STRUCTS][MAX_CLASSES];
EXTERN inT32 owner_counts[MAX_STRUCTS][MAX_CLASSES];
//no of names
EXTERN INT16 name_counts[MAX_STRUCTS];
EXTERN INT32 free_struct_blocks; //no of free blocks
EXTERN inT16 name_counts[MAX_STRUCTS];
EXTERN inT32 free_struct_blocks; //no of free blocks
EXTERN INT_VAR (mem_mallocdepth, 0, "Malloc stack depth to trace");
EXTERN INT_VAR (mem_mallocbits, 8, "Log 2 of hash table size");
@ -81,11 +81,11 @@ EXTERN INT_VAR (mem_checkfreq, 0, "Calls to alloc_mem between owner counts");
void
MEM_ALLOCATOR::init ( //initialize
void *(*ext_malloc) (INT32), //external source
void *(*ext_malloc) (inT32), //external source
void (*ext_free) (void *), //external free
INT32 firstsize, //size of first block
INT32 lastsize, //size of last block
INT32 maxchunk //biggest request
inT32 firstsize, //size of first block
inT32 lastsize, //size of last block
inT32 maxchunk //biggest request
) {
blockcount = 0;
malloc_serial = 0;
@ -112,11 +112,11 @@ INT32 maxchunk //biggest request
* Generate a hash code for a caller, setup the tables if necessary.
**********************************************************************/
UINT16 MEM_ALLOCATOR::hash_caller( //get hash code
uinT16 MEM_ALLOCATOR::hash_caller( //get hash code
void *addr //return address
) {
INT32 index; //index to table
INT32 initial_hash; //initial index
inT32 index; //index to table
inT32 initial_hash; //initial index
if (callers == NULL)
init_callers(); //setup table
@ -143,7 +143,7 @@ UINT16 MEM_ALLOCATOR::hash_caller( //get hash code
//setup free table
callers[index].init_freeers ();
}
return (UINT16) index;
return (uinT16) index;
}
@ -157,9 +157,9 @@ UINT16 MEM_ALLOCATOR::hash_caller( //get hash code
void MALLOC_CALL::count_freeer( //count calls to free
void *addr //return address
) {
INT32 entries; //entries in table
INT32 index; //index to table
INT32 initial_hash; //initial index
inT32 entries; //entries in table
inT32 index; //index to table
inT32 initial_hash; //initial index
if (free_list == NULL)
init_freeers(); //setup table
@ -194,7 +194,7 @@ void MALLOC_CALL::count_freeer( //count calls to free
**********************************************************************/
void MEM_ALLOCATOR::init_callers() { //setup hash table
INT32 depth = mem_mallocdepth;
inT32 depth = mem_mallocdepth;
mem_mallocdepth.set_value (0); //can't register it
call_bits = mem_mallocbits;
@ -212,8 +212,8 @@ void MEM_ALLOCATOR::init_callers() { //setup hash table
**********************************************************************/
void MALLOC_CALL::init_freeers() { //setup hash table
INT32 entries; //entries in table
INT32 depth = mem_mallocdepth;
inT32 entries; //entries in table
inT32 depth = mem_mallocdepth;
mem_mallocdepth.set_value (0); //can't register it
free_bits = mem_freebits;
@ -233,8 +233,8 @@ void MALLOC_CALL::init_freeers() { //setup hash table
void MEM_ALLOCATOR::reduce_counts() { //divide by 2
MEMBLOCK *block; //current block
MEMUNION *chunk; //current chunk
INT32 chunksize; //size of chunk
INT32 blockindex; //index of block
inT32 chunksize; //size of chunk
inT32 blockindex; //index of block
check_mem ("Reducing counts", JUSTCHECKS);
for (blockindex = 0; blockindex < blockcount; blockindex++) {
@ -260,18 +260,18 @@ void MEM_ALLOCATOR::reduce_counts() { //divide by 2
void MEM_ALLOCATOR::display_counts() { //count up
MEMBLOCK *block; //current block
MEMUNION *chunk; //current chunk
INT32 chunksize; //size of chunk
INT32 blockindex; //index of block
INT32 buckets; //required buckets
INT32 bucketsize; //no in each bucket
INT32 callindex; //index to callers
INT32 freeindex; //index to freeers
INT32 freeentries; //table size
INT32 totalchunks; //total chunk counts
INT32 totalspace; //total mem space
INT32 totalpchunks; //permanent chunks
INT32 totalpspace; //permanent space
INT32 totalfrees; //total free calls
inT32 chunksize; //size of chunk
inT32 blockindex; //index of block
inT32 buckets; //required buckets
inT32 bucketsize; //no in each bucket
inT32 callindex; //index to callers
inT32 freeindex; //index to freeers
inT32 freeentries; //table size
inT32 totalchunks; //total chunk counts
inT32 totalspace; //total mem space
inT32 totalpchunks; //permanent chunks
inT32 totalpspace; //permanent space
inT32 totalfrees; //total free calls
if (callers == NULL)
return; //can't do anything
@ -283,9 +283,9 @@ void MEM_ALLOCATOR::display_counts() { //count up
for (callindex = 0; callindex < entries; callindex++) {
if (callers[callindex].free_list != NULL) {
callers[callindex].counts =
(INT32 *) malloc (buckets * 4 * sizeof (INT32));
(inT32 *) malloc (buckets * 4 * sizeof (inT32));
memset (callers[callindex].counts, 0,
(size_t) (buckets * 4 * sizeof (INT32)));
(size_t) (buckets * 4 * sizeof (inT32)));
}
}
for (blockindex = 0; blockindex < blockcount; blockindex++) {
@ -385,25 +385,25 @@ void MEM_ALLOCATOR::display_counts() { //count up
void MEM_ALLOCATOR::check( //check consistency
const char *string, //context message
INT8 level //level of check
inT8 level //level of check
) {
MEMBLOCK *block; //current block
MEMUNION *chunk; //current chunk
MEMUNION *prevchunk; //previous chunk
INT32 chunksize; //size of chunk
INT32 usedcount; //no of used chunks
INT32 usedsize; //size of used chunks
INT32 freecount; //no of free chunks
INT32 freesize; //size of free chunks
INT32 biggest; //biggest free chunk
INT32 totusedcount; //no of used chunks
INT32 totusedsize; //size of used chunks
INT32 totfreecount; //no of free chunks
INT32 totfreesize; //size of free chunks
INT32 totbiggest; //biggest free chunk
INT32 totblocksize; //total size of blocks
INT32 chunkindex; //index of chunk
INT32 blockindex; //index of block
inT32 chunksize; //size of chunk
inT32 usedcount; //no of used chunks
inT32 usedsize; //size of used chunks
inT32 freecount; //no of free chunks
inT32 freesize; //size of free chunks
inT32 biggest; //biggest free chunk
inT32 totusedcount; //no of used chunks
inT32 totusedsize; //size of used chunks
inT32 totfreecount; //no of free chunks
inT32 totfreesize; //size of free chunks
inT32 totbiggest; //biggest free chunk
inT32 totblocksize; //total size of blocks
inT32 chunkindex; //index of chunk
inT32 blockindex; //index of block
if (level >= MEMCHECKS)
tprintf ("\nMEM_ALLOCATOR::check:at '%s'\n", string);
@ -500,7 +500,7 @@ void MEM_ALLOCATOR::check( //check consistency
**********************************************************************/
void *MEM_ALLOCATOR::alloc_p( //permanent space
INT32 count, //block size to allocate
inT32 count, //block size to allocate
void *caller //ptr to caller
) {
MEMBLOCK *block; //current block
@ -561,12 +561,12 @@ void *MEM_ALLOCATOR::alloc_p( //permanent space
**********************************************************************/
void *MEM_ALLOCATOR::alloc( //get memory
INT32 count, //no of bytes to get
inT32 count, //no of bytes to get
void *caller //ptr to caller
) {
MEMBLOCK *block; //current block
MEMUNION *chunk; //current chunk
INT32 chunksize; //size of free chunk
inT32 chunksize; //size of free chunk
MEMUNION *chunkstart; //start of free chunk
if (count < 1 || count > biggestblock)
@ -653,7 +653,7 @@ void MEM_ALLOCATOR::set_owner( //get memory
MEMUNION *chunkstart, //chunk to set
void *caller //ptr to caller
) {
UINT16 callindex; //hash code
uinT16 callindex; //hash code
callindex = hash_caller (caller);
chunkstart->owner = callindex;
@ -672,7 +672,7 @@ void MEM_ALLOCATOR::set_owner( //get memory
}
}
malloc_auto_count++;
if (mem_checkfreq > 0 && malloc_auto_count >= (UINT32) mem_checkfreq) {
if (mem_checkfreq > 0 && malloc_auto_count >= (uinT32) mem_checkfreq) {
malloc_auto_count = 0;
check_mem ("Auto check", MEMCHECKS);
}
@ -740,7 +740,7 @@ void MEM_ALLOCATOR::dealloc( //free memory
**********************************************************************/
MEMBLOCK *MEM_ALLOCATOR::new_block( //get new big block
INT32 minsize //minimum size
inT32 minsize //minimum size
) {
MEMBLOCK *newblock; //new block
@ -807,12 +807,12 @@ MEMBLOCK *MEM_ALLOCATOR::new_block( //get new big block
**********************************************************************/
MEMUNION *MEMBLOCK::find_chunk( //find free chunk
INT32 count //size required
inT32 count //size required
) {
MEMUNION *chunk; //current chunk
INT32 chunksize; //size of free chunk
inT32 chunksize; //size of free chunk
MEMUNION *chunkstart; //start of free chunk
INT32 spaceshift; //shift in lowerspace
inT32 spaceshift; //shift in lowerspace
if (upperspace <= lowerspace) {
freechunk = blockstart; //restart chunklist
@ -891,7 +891,7 @@ MEMUNION *MEMBLOCK::find_chunk( //find free chunk
//#pragma OPTIMIZE OFF /*force link*/
void *trace_caller( //trace stack
INT32 depth //depth to trace
inT32 depth //depth to trace
) {
#ifdef hp9000s800
@ -938,7 +938,7 @@ void *trace_caller( //trace stack
// Fake procedure for non-UNIX
void *trace_caller( //trace stack
INT32 depth //depth to trace
inT32 depth //depth to trace
) {
return NULL;
}
@ -951,11 +951,11 @@ void *trace_caller( //trace stack
* Implemented very inefficiently, but only a debug tool!
**********************************************************************/
INT32 identify_struct_owner( //get table index
INT32 struct_count, //cell size
inT32 identify_struct_owner( //get table index
inT32 struct_count, //cell size
const char *name //name of type
) {
INT32 index; //index to structure
inT32 index; //index to structure
for (index = 0; index < name_counts[struct_count]
&& strcmp (name, owner_names[struct_count][index]); index++);
@ -977,16 +977,16 @@ INT32 identify_struct_owner( //get table index
**********************************************************************/
void check_struct( //check a structure
INT8 level, //print control
INT32 count //no of bytes
inT8 level, //print control
inT32 count //no of bytes
) {
MEMUNION *element; //current element
MEMUNION *block; //current block
INT32 struct_count; //no of required structs
INT32 block_count; //no of structure blocks
INT32 free_count; //size of freelist*/
INT32 name_index; //named holder
INT32 named_total; //total held by names
inT32 struct_count; //no of required structs
inT32 block_count; //no of structure blocks
inT32 free_count; //size of freelist*/
inT32 name_index; //named holder
inT32 named_total; //total held by names
//no of MEMUNIONS-1
struct_count = (count - 1) / sizeof (MEMUNION);
@ -1035,9 +1035,9 @@ void check_struct( //check a structure
**********************************************************************/
void check_structs( //count in use on structs
INT8 level //print control
inT8 level //print control
) {
INT8 index; //index to structs
inT8 index; //index to structs
for (index = 1; index <= MAX_STRUCTS; index++)
//check number allocated

View File

@ -42,10 +42,10 @@ class MEMUNION
union
{
MEMUNION *ptr; //next chunk
INT32 size; //chunk size
inT32 size; //chunk size
};
UINT16 owner; //owner of chunk
UINT16 age; //age of chunk
uinT16 owner; //owner of chunk
uinT16 age; //age of chunk
};
class MEMBLOCK
@ -56,18 +56,18 @@ class MEMBLOCK
MEMUNION *freechunk; /*next free chunk */
MEMUNION *topchunk; /*top free chunk */
MEMBLOCK *next; /*next block in chain */
INT32 upperspace; /*space above freechunk */
INT32 lowerspace; /*space below freechunk */
inT32 upperspace; /*space above freechunk */
inT32 lowerspace; /*space below freechunk */
MEMUNION *find_chunk( //find free chunk
INT32 count); //size required
inT32 count); //size required
};
class FREE_CALL
{
public:
void *freeer; //return addr
INT32 count; //no of frees
inT32 count; //no of frees
FREE_CALL() { //constructor
freeer = NULL;
count = 0;
@ -78,8 +78,8 @@ class MALLOC_CALL
public:
void *caller; //return addr
FREE_CALL *free_list; //freeer counts
INT32 *counts; //no of blocks
INT32 free_bits; //bits in free table
inT32 *counts; //no of blocks
inT32 free_bits; //bits in free table
MALLOC_CALL() { //constructor
caller = NULL;
@ -96,50 +96,50 @@ class MALLOC_CALL
class MEM_ALLOCATOR
{
public:
INT16 blockcount; //blocks in use
UINT16 malloc_serial; //serial allocation
inT16 blockcount; //blocks in use
uinT16 malloc_serial; //serial allocation
MEMBLOCK *topblock; //block for permanents
MEMBLOCK *currblock; //current block
MALLOC_CALL *callers; //hash table of callers
void *(*malloc) (INT32); //external allocator
void *(*malloc) (inT32); //external allocator
void (*free) (void *); //external free
INT32 maxsize; //biggest block
INT32 biggestblock; //biggest chunk
INT32 totalmem; //total free memory
INT32 memsize; //current block size
UINT32 malloc_div_ratio; //scaling of malloc_serial
UINT32 malloc_minor_serial; //scaling counter
UINT32 malloc_auto_count; //counts auto checks
INT32 call_bits; //size of table
INT32 entries; //size of table
inT32 maxsize; //biggest block
inT32 biggestblock; //biggest chunk
inT32 totalmem; //total free memory
inT32 memsize; //current block size
uinT32 malloc_div_ratio; //scaling of malloc_serial
uinT32 malloc_minor_serial; //scaling counter
uinT32 malloc_auto_count; //counts auto checks
inT32 call_bits; //size of table
inT32 entries; //size of table
//all memory blocks
MEMBLOCK memblocks[MAXBLOCKS];
void init ( //initialize
void *(*ext_malloc) (INT32),//external source
void *(*ext_malloc) (inT32),//external source
void (*ext_free) (void *), //external free
INT32 firstsize, //size of first block
INT32 lastsize, //size of last block
INT32 maxchunk); //biggest request
inT32 firstsize, //size of first block
inT32 lastsize, //size of last block
inT32 maxchunk); //biggest request
void *alloc( //allocator
INT32 size, //size of chunk
inT32 size, //size of chunk
void *caller); //ptr to caller
void *alloc_p( //allocator
INT32 size, //size of chunk
inT32 size, //size of chunk
void *caller); //ptr to caller
void dealloc( //deallocator
void *ptr, //mem to free
void *caller); //ptr to caller
void check( //check chunks
const char *string, //message
INT8 level); //amount of checks
inT8 level); //amount of checks
void reduce_counts(); //divide by 2
void display_counts(); //count up
MEMBLOCK *new_block( //get new big block
INT32 minsize); //minimum size
UINT16 hash_caller( //check a structure
inT32 minsize); //minimum size
uinT16 hash_caller( //check a structure
void *addr); //return address
private:
@ -153,12 +153,12 @@ extern MEM_ALLOCATOR main_mem;
//heads of freelists
extern MEMUNION *free_structs[MAX_STRUCTS];
//number issued
extern INT32 structs_in_use[MAX_STRUCTS];
extern inT32 structs_in_use[MAX_STRUCTS];
//number issued
extern INT32 blocks_in_use[MAX_STRUCTS];
extern inT32 blocks_in_use[MAX_STRUCTS];
//head of block lists
extern MEMUNION *struct_blocks[MAX_STRUCTS];
extern INT32 owner_counts[MAX_STRUCTS][MAX_CLASSES];
extern inT32 owner_counts[MAX_STRUCTS][MAX_CLASSES];
extern INT_VAR_H (mem_mallocdepth, 0, "Malloc stack depth to trace");
extern INT_VAR_H (mem_mallocbits, 8, "Log 2 of hash table size");
@ -169,18 +169,18 @@ extern INT_VAR_H (mem_checkfreq, 0,
"Calls to alloc_mem between owner counts");
void *trace_caller( //trace stack
INT32 depth //depth to trace
inT32 depth //depth to trace
);
INT32 identify_struct_owner( //get table index
INT32 struct_count, //cell size
inT32 identify_struct_owner( //get table index
inT32 struct_count, //cell size
const char *name //name of type
);
void check_struct( //check a structure
INT8 level, //print control
INT32 count //no of bytes
inT8 level, //print control
inT32 count //no of bytes
);
void check_structs( //count in use on structs
INT8 level //print control
inT8 level //print control
);
void *new_struct_block(); //allocate memory
void old_struct_block( //free a structure block

View File

@ -64,7 +64,7 @@ void* addr //mem to free
DLLSYM void check_mem( //check consistency
const char *string, //context message
INT8 level //level of check
inT8 level //level of check
) {
big_mem.check (string, level);
main_mem.check (string, level);
@ -83,7 +83,7 @@ DLLSYM void check_mem( //check consistency
**********************************************************************/
DLLSYM char *alloc_string( //allocate string
INT32 count //no of chars required
inT32 count //no of chars required
) {
#ifdef RAYS_MALLOC
char *string; //allocated string
@ -101,7 +101,7 @@ DLLSYM char *alloc_string( //allocate string
tprintf ("No memory for alloc_string");
return NULL;
}
string[0] = (INT8) count; //save its length
string[0] = (inT8) count; //save its length
}
else {
//get a big block
@ -162,7 +162,7 @@ DLLSYM void free_string( //free a string
DLLSYM void *
alloc_struct ( //allocate memory
INT32 count, //no of chars required
inT32 count, //no of chars required
#if defined COUNTING_CLASS_STRUCTURES
const char *name //name of type
#else
@ -172,9 +172,9 @@ const char * //name of type
#ifdef RAYS_MALLOC
MEMUNION *element; //current element
MEMUNION *returnelement; //return value
INT32 struct_count; //no of required structs
INT32 blocksize; //no of structs in block
INT32 index; //index to structure
inT32 struct_count; //no of required structs
inT32 blocksize; //no of structs in block
inT32 index; //index to structure
if (count < 1 || count > MAX_CHUNK) {
tprintf ("Invalid size %d requested of alloc_struct", count);
@ -247,7 +247,7 @@ const char * //name of type
DLLSYM void
free_struct ( //free a structure
void *deadstruct, //structure to free
INT32 count, //no of bytes
inT32 count, //no of bytes
#if defined COUNTING_CLASS_STRUCTURES
const char *name //name of type
#else
@ -261,8 +261,8 @@ const char * //name of type
MEMUNION *prev_block; //previous element
MEMUNION *nextblock; //next block in list
MEMUNION *block; //next block in list
INT32 struct_count; //no of required structs
INT32 index; //to structure counts
inT32 struct_count; //no of required structs
inT32 index; //to structure counts
if (count < 1 || count > MAX_CHUNK) {
tprintf ("Invalid size %d requested of free_struct", count);
@ -386,7 +386,7 @@ const char * //name of type
//#pragma OPT_LEVEL 0
//#endif
DLLSYM void *alloc_mem_p( //allocate permanent space
INT32 count //block size to allocate
inT32 count //block size to allocate
) {
#ifdef RAYS_MALLOC
#ifdef TESTING_BIGSTUFF
@ -395,7 +395,7 @@ DLLSYM void *alloc_mem_p( //allocate permanent space
FIRSTSIZE, LASTSIZE, MAX_CHUNK);
#else
if (main_mem.biggestblock == 0)
main_mem.init ((void *(*)(INT32)) malloc, free,
main_mem.init ((void *(*)(inT32)) malloc, free,
FIRSTSIZE, LASTSIZE, MAX_CHUNK);
#endif
if (mem_mallocdepth > 0)
@ -415,7 +415,7 @@ DLLSYM void *alloc_mem_p( //allocate permanent space
**********************************************************************/
DLLSYM void *alloc_mem( //get some memory
INT32 count //no of bytes to get
inT32 count //no of bytes to get
) {
#ifdef RAYS_MALLOC
#ifdef TESTING_BIGSTUFF
@ -424,7 +424,7 @@ DLLSYM void *alloc_mem( //get some memory
FIRSTSIZE, LASTSIZE, MAX_CHUNK);
#else
if (main_mem.biggestblock == 0)
main_mem.init ((void *(*)(INT32)) malloc, free,
main_mem.init ((void *(*)(inT32)) malloc, free,
FIRSTSIZE, LASTSIZE, MAX_CHUNK);
#endif
if (mem_mallocdepth > 0)
@ -444,11 +444,11 @@ DLLSYM void *alloc_mem( //get some memory
**********************************************************************/
DLLSYM void *alloc_big_mem( //get some memory
INT32 count //no of bytes to get
inT32 count //no of bytes to get
) {
#ifdef TESTING_BIGSTUFF
if (big_mem.biggestblock == 0)
big_mem.init ((void *(*)(INT32)) malloc, free,
big_mem.init ((void *(*)(inT32)) malloc, free,
BIGSIZE, BIGSIZE, MAX_BIGCHUNK);
if (mem_mallocdepth > 0)
return big_mem.alloc (count, trace_caller (mem_mallocdepth));
@ -467,11 +467,11 @@ DLLSYM void *alloc_big_mem( //get some memory
**********************************************************************/
DLLSYM void *alloc_big_zeros( //get some memory
INT32 count //no of bytes to get
inT32 count //no of bytes to get
) {
#ifdef TESTING_BIGSTUFF
if (big_mem.biggestblock == 0)
big_mem.init ((void *(*)(INT32)) malloc, free,
big_mem.init ((void *(*)(inT32)) malloc, free,
BIGSIZE, BIGSIZE, MAX_BIGCHUNK);
void *buf; //return value

View File

@ -32,7 +32,7 @@
void *operator new( /*fast allocator*/\
size_t size, /*size of object*/\
const char* file=NULL, /*filename*/\
INT32 line=0) /*line number*/\
inT32 line=0) /*line number*/\
{\
return alloc_struct(size); /*simple to do*/\
}\
@ -48,7 +48,7 @@
void *operator new( /*fast allocator*/\
size_t size, /*size of object*/\
const char* file=NULL, /*filename*/\
INT32 line=0) /*line number*/\
inT32 line=0) /*line number*/\
{\
return alloc_struct(size,#name); /*simple to do*/\
}\
@ -104,7 +104,7 @@
#define ALLOC_2D_ARRAY(x,y,mem,ptrs,type) /*make 2d array*/\
{ \
INT32 TMP_i; \
inT32 TMP_i; \
mem=(type*)alloc_mem((x)*(y)*sizeof(type)); /*get memory*/\
ptrs=(type**)alloc_mem((x)*sizeof(type*)); /*get ptrs*/\
for (TMP_i=0;TMP_i<(x);TMP_i++)\
@ -132,7 +132,7 @@
#define ALLOC_BIG_2D_ARRAY(x,y,mem,ptrs,type) /*make 2d array*/\
{ \
INT32 TMP_i; \
inT32 TMP_i; \
mem=(type*)alloc_big_mem((x)*(y)*sizeof(type)); /*get memory*/\
ptrs=(type**)alloc_big_mem((x)*sizeof(type*)); /*get ptrs*/\
for (TMP_i=0;TMP_i<(x);TMP_i++)\
@ -153,35 +153,35 @@
extern DLLSYM void check_mem( //check consistency
const char *string, //context message
INT8 level //level of check
inT8 level //level of check
);
//allocate string
extern DLLSYM char *alloc_string(INT32 count //no of chars required
extern DLLSYM char *alloc_string(inT32 count //no of chars required
);
extern DLLSYM void free_string( //free a string
char *string //string to free
);
//allocate memory
extern DLLSYM void *alloc_struct (
INT32 count, //no of chars required
inT32 count, //no of chars required
const char *name = NULL //class name
);
extern DLLSYM void free_struct ( //free a structure
void *deadstruct, //structure to free
INT32 count, //no of bytes
inT32 count, //no of bytes
const char *name = NULL //class name
);
extern DLLSYM void *alloc_mem_p( //allocate permanent space
INT32 count //block size to allocate
inT32 count //block size to allocate
);
extern DLLSYM void *alloc_mem( //get some memory
INT32 count //no of bytes to get
inT32 count //no of bytes to get
);
//get some memory
extern DLLSYM void *alloc_big_mem(INT32 count //no of bytes to get
extern DLLSYM void *alloc_big_mem(inT32 count //no of bytes to get
);
//get some memory
extern DLLSYM void *alloc_big_zeros(INT32 count //no of bytes to get
extern DLLSYM void *alloc_big_zeros(inT32 count //no of bytes to get
);
extern DLLSYM void free_mem( //free mem from alloc_mem
void *oldchunk //chunk to free

View File

@ -43,15 +43,15 @@ REALLY_DECLARE_MAIN(ARGC,ARGV)
* whitespace spaced string being an arg.\
**********************************************************************/\
\
INT32 parse_args( /*refine arg list*/\
INT32 argc, /*no of input args*/\
inT32 parse_args( /*refine arg list*/\
inT32 argc, /*no of input args*/\
char *argv[], /*input args*/\
char *arglist[] /*output args*/\
)\
{\
INT32 argcount; /*converted argc*/\
inT32 argcount; /*converted argc*/\
char *testchar; /*char in option string*/\
INT32 arg; /*current argument*/\
inT32 arg; /*current argument*/\
\
argcount=0; /*no of options*/\
for (arg=0;arg<argc;arg++)\
@ -81,17 +81,17 @@ char *arglist[] /*output args*/\
return argcount; /*new number of args*/\
}\
\
INT32 global_exit_code;\
INT32 real_main(INT32,const char**);\
inT32 global_exit_code;\
inT32 real_main(inT32,const char**);\
\
INT32 run_main( /*the main thread*/\
inT32 run_main( /*the main thread*/\
CWinApp* theapp /*arguments*/\
)\
{\
char **argv;\
char *argsin[2];\
INT32 argc;\
INT32 exit_code;\
inT32 argc;\
inT32 exit_code;\
\
argsin[0]=strdup(theapp->m_pszExeName);\
argsin[1]=strdup(theapp->m_lpCmdLine);\
@ -116,7 +116,7 @@ CWinApp* theapp /*arguments*/\
return exit_code;\
}\
\
INT32 real_main(INT32 ARGC,const char* ARGV[])\
inT32 real_main(inT32 ARGC,const char* ARGV[])\
#else
@ -129,15 +129,15 @@ INT32 real_main(INT32 ARGC,const char* ARGV[])\
* whitespace spaced string being an arg.\
**********************************************************************/\
\
INT32 parse_args( /*refine arg list*/\
INT32 argc, /*no of input args*/\
inT32 parse_args( /*refine arg list*/\
inT32 argc, /*no of input args*/\
char *argv[], /*input args*/\
char *arglist[] /*output args*/\
)\
{\
INT32 argcount; /*converted argc*/\
inT32 argcount; /*converted argc*/\
char *testchar; /*char in option string*/\
INT32 arg; /*current argument*/\
inT32 arg; /*current argument*/\
\
argcount=0; /*no of options*/\
for (arg=0;arg<argc;arg++)\
@ -167,7 +167,7 @@ char *arglist[] /*output args*/\
return argcount; /*new number of args*/\
}\
\
INT32 main(INT32 ARGC,const char* ARGV[])\
inT32 main(inT32 ARGC,const char* ARGV[])\
#endif

View File

@ -186,11 +186,11 @@ enum OCR_ERR_CODE
typedef struct /*font description */
{
UINT16 language; /*default language */
UINT8 font_family; /*serif/not, fixed/not */
UINT8 char_set; /*character set standard */
UINT8 pitch; /*fixed or prop */
INT8 name[MAX_FONT_NAME + 1]; /*plain ascii name */
uinT16 language; /*default language */
uinT8 font_family; /*serif/not, fixed/not */
uinT8 char_set; /*character set standard */
uinT8 pitch; /*fixed or prop */
inT8 name[MAX_FONT_NAME + 1]; /*plain ascii name */
} EFONT_DESC; /*font description */
/**********************************************************************
@ -203,12 +203,12 @@ typedef struct /*font description */
typedef struct /*startup info */
{
INT32 protocol; /*interface version */
UINT32 font_count; /*number of fonts */
UINT16 language; /*default language */
UINT16 name[MAX_OCR_NAME + 1]; /*name of engine */
inT32 protocol; /*interface version */
uinT32 font_count; /*number of fonts */
uinT16 language; /*default language */
uinT16 name[MAX_OCR_NAME + 1]; /*name of engine */
/*version of engine */
UINT16 version[MAX_OCR_VERSION + 1];
uinT16 version[MAX_OCR_VERSION + 1];
EFONT_DESC fonts[1]; /*array of fonts */
} EOCR_DESC; /*startup info */
@ -224,11 +224,11 @@ typedef struct /*startup info */
typedef struct /*bitmap strip */
{
INT16 x_size; /*width in pixels */
INT16 y_size; /*of full image */
INT16 strip_size; /*of this strip */
INT16 resolution; /*pixels per inch */
UINT8 data[8]; /*image data */
inT16 x_size; /*width in pixels */
inT16 y_size; /*of full image */
inT16 strip_size; /*of this strip */
inT16 resolution; /*pixels per inch */
uinT8 data[8]; /*image data */
} ESTRIP_DESC; /*bitmap strip */
/**********************************************************************
@ -264,16 +264,16 @@ typedef struct /*single character */
// Programs which want to handle languagues with different characters sets will need to
// handle extended characters appropriately, but *all* code needs to be prepared to
// receive UTF8 coded characters for characters such as bullet and fancy quotes.
UINT16 char_code; /*character itself */
INT16 left; /*of char (-1) */
INT16 right; /*of char (-1) */
INT16 top; /*of char (-1) */
INT16 bottom; /*of char (-1) */
INT16 font_index; /*what font (0) */
UINT8 confidence; /*0=perfect, 100=reject (0/100) */
UINT8 point_size; /*of char, 72=i inch, (10) */
INT8 blanks; /*no of spaces before this char (1) */
UINT8 formatting; /*char formatting (0) */
uinT16 char_code; /*character itself */
inT16 left; /*of char (-1) */
inT16 right; /*of char (-1) */
inT16 top; /*of char (-1) */
inT16 bottom; /*of char (-1) */
inT16 font_index; /*what font (0) */
uinT8 confidence; /*0=perfect, 100=reject (0/100) */
uinT8 point_size; /*of char, 72=i inch, (10) */
inT8 blanks; /*no of spaces before this char (1) */
uinT8 formatting; /*char formatting (0) */
} EANYCODE_CHAR; /*single character */
/**********************************************************************
@ -294,11 +294,11 @@ typedef bool (*CANCEL_FUNC)(void* cancel_this, int words);
typedef struct ETEXT_STRUCT /*output header */
{
INT16 count; /*chars in this buffer(0) */
INT16 progress; /*percent complete increasing (0-100) */
INT8 more_to_come; /*true if not last */
INT8 ocr_alive; /*ocr sets to 1, HP 0 */
INT8 err_code; /*for errcode use */
inT16 count; /*chars in this buffer(0) */
inT16 progress; /*percent complete increasing (0-100) */
inT8 more_to_come; /*true if not last */
inT8 ocr_alive; /*ocr sets to 1, HP 0 */
inT8 err_code; /*for errcode use */
CANCEL_FUNC cancel; /*returns true to cancel */
void* cancel_this; /*this or other data for cancel*/
clock_t end_time; /*time to stop if not 0*/
@ -319,7 +319,7 @@ typedef struct /*shared mem info */
HANDLE ocr_sem; /*ocr semaphore */
HANDLE hp_sem; /*hp semaphore */
void *shm_mem; /*shared memory */
INT32 shm_size; /*size of shm */
inT32 shm_size; /*size of shm */
} ESHM_INFO; /*shared mem info */
#elif defined (__MAC__)
typedef struct /*shared mem info */
@ -328,8 +328,8 @@ typedef struct /*shared mem info */
Boolean ocr_sem; /*ocr semaphore */
Boolean hp_sem; /*hp semaphore */
void *shm_mem; /*shared memory */
INT32 shm_size; /*size of shm */
INT16 language;
inT32 shm_size; /*size of shm */
inT16 language;
// Process management information follows:
ProcessSerialNumber IPEProcess;
@ -339,7 +339,7 @@ typedef struct /*shared mem info */
typedef struct /*shared mem info */
{
void *shm_mem; /*shared memory */
INT32 shm_size; /*size of shm */
inT32 shm_size; /*size of shm */
} ESHM_INFO;
#endif
#endif

View File

@ -71,16 +71,16 @@ typedef enum {
} OCR_STATE;
/* forward declarations - not in .h file as not needed outside this file*/
INT16 ocr_internal_shutdown(); /*closedown */
INT16 wait_for_mutex(); /*wait for HP to be ready */
INT16 wait_for_hp( /*wait for semaphore */
INT32 timeout /*in seconds */
inT16 ocr_internal_shutdown(); /*closedown */
inT16 wait_for_mutex(); /*wait for HP to be ready */
inT16 wait_for_hp( /*wait for semaphore */
inT32 timeout /*in seconds */
);
INT16 release_mutex(); /*release mutex */
INT16 release_ocr(); /*release semaphore */
inT16 release_mutex(); /*release mutex */
inT16 release_ocr(); /*release semaphore */
static INT32 font_count = 0; /*number of fonts */
static INT16 lines_read = 0; /*no read in this image */
static inT32 font_count = 0; /*number of fonts */
static inT16 lines_read = 0; /*no read in this image */
/*current state */
static OCR_STATE ocr_state = OCS_UNINIT;
@ -102,10 +102,10 @@ pascal short TerminateOCR(AppleEvent *theEvent,
* The parameters are the command line arguments in order.
**********************************************************************/
#ifdef __MAC__
INT16
ocr_open_shm (UINT16 * lang)
inT16
ocr_open_shm (uinT16 * lang)
#else
INT16
inT16
ocr_open_shm ( /*open the shm */
const char *shm_h, /*handle of shm */
const char *shm_size, /*size of shm segment */
@ -113,7 +113,7 @@ const char *mutex_h, /*hp mutex */
const char *ocr_h, /*ocr semaphore */
const char *hp_h, /*hp semaphore */
const char *lang_str, /*language */
UINT16 * lang /*required language */
uinT16 * lang /*required language */
)
#endif
{
@ -130,7 +130,7 @@ UINT16 * lang /*required language */
#else
if (lang != NULL)
/*get language */
*lang = (UINT16) strtol (lang_str, NULL, 10);
*lang = (uinT16) strtol (lang_str, NULL, 10);
#endif
if (ocr_state != OCS_UNINIT) {
ocr_error(OCR_ERR_BAD_STATE);
@ -216,16 +216,16 @@ void ocr_error( /*send an error code */
* Initialize one of the font descriptors.
**********************************************************************/
INT16 ocr_append_fontinfo( /*put info into shm */
UINT16 language, /*default language */
UINT8 font_family, /*serif/not, fixed/not */
UINT8 char_set, /*character set standard */
UINT8 pitch, /*fixed or prop */
inT16 ocr_append_fontinfo( /*put info into shm */
uinT16 language, /*default language */
uinT8 font_family, /*serif/not, fixed/not */
uinT8 char_set, /*character set standard */
uinT8 pitch, /*fixed or prop */
const char *name /*plain ascii name */
) {
EOCR_DESC *desc; /*ocr engine info */
int index; /*char index */
INT32 font_index; /*which font */
inT32 font_index; /*which font */
if (ocr_state != OCS_SETUP_SHM) {
ocr_error(OCR_ERR_BAD_STATE);
@ -235,7 +235,7 @@ INT16 ocr_append_fontinfo( /*put info into shm */
/*turn to right type */
desc = (EOCR_DESC *) shm.shm_mem;
if (font_count >
(INT32) ((shm.shm_size - sizeof (EOCR_DESC)) / sizeof (EFONT_DESC)))
(inT32) ((shm.shm_size - sizeof (EOCR_DESC)) / sizeof (EFONT_DESC)))
return OCR_API_NO_MEM; /*insufficient space */
font_index = font_count++; /*add a font */
/*setup structure */
@ -264,15 +264,15 @@ INT16 ocr_append_fontinfo( /*put info into shm */
* engine.
**********************************************************************/
INT16 ocr_setup_startinfo( /*put info into shm */
INT32 protocol, /*interface version */
UINT16 language, /*default language */
const UINT16 *name, /*name of engine */
const UINT16 *version /*version of engine */
inT16 ocr_setup_startinfo( /*put info into shm */
inT32 protocol, /*interface version */
uinT16 language, /*default language */
const uinT16 *name, /*name of engine */
const uinT16 *version /*version of engine */
) {
EOCR_DESC *desc; /*ocr engine info */
int index; /*char index */
INT16 result; /*from open */
inT16 result; /*from open */
if (ocr_state != OCS_SETUP_SHM || font_count < 1) {
ocr_error(OCR_ERR_BAD_STATE);
@ -306,15 +306,15 @@ INT16 ocr_setup_startinfo( /*put info into shm */
* engine.
**********************************************************************/
INT16 ocr_setup_startinfo_ansi( /*put info into shm */
UINT32 protocol, /*interface version */
UINT16 language, /*default language */
inT16 ocr_setup_startinfo_ansi( /*put info into shm */
uinT32 protocol, /*interface version */
uinT16 language, /*default language */
const char *name, /*name of engine */
const char *version /*version of engine */
) {
EOCR_DESC *desc; /*ocr engine info */
int index; /*char index */
INT16 result; /*from open */
inT16 result; /*from open */
if (ocr_state != OCS_SETUP_SHM || font_count < 1) {
ocr_error(OCR_ERR_BAD_STATE);
@ -350,7 +350,7 @@ INT16 ocr_setup_startinfo_ansi( /*put info into shm */
ESTRIP_DESC *ocr_get_first_image_strip() { /*get image strip */
ESTRIP_DESC *strip; /*strip info */
INT16 result; /*of wait/release */
inT16 result; /*of wait/release */
if (ocr_state != OCS_SETUP_INFO) {
tprintf ("Bad state reading strip");
@ -399,7 +399,7 @@ ESTRIP_DESC *ocr_get_first_image_strip() { /*get image strip */
ESTRIP_DESC *ocr_get_next_image_strip() { /*get image strip */
ESTRIP_DESC *strip; /*strip info */
INT16 result; /*of wait/release */
inT16 result; /*of wait/release */
if (ocr_state != OCS_READING_STRIPS) {
ocr_error(OCR_ERR_BAD_STATE);
@ -461,7 +461,7 @@ ETEXT_DESC *ocr_setup_monitor() { /*setup monitor */
* Return the number of chars that can be fitted into the buffer.
**********************************************************************/
INT32 ocr_char_space() { /*put char into shm */
inT32 ocr_char_space() { /*put char into shm */
ETEXT_DESC *buf; /*text buffer */
int result;
@ -488,24 +488,24 @@ INT32 ocr_char_space() { /*put char into shm */
* if there was insufficient room in the buffer.
**********************************************************************/
INT16 ocr_append_char( /*put char into shm */
UINT16 char_code, /*character itself */
INT16 left, /*of char (-1) */
INT16 right, /*of char (-1) */
INT16 top, /*of char (-1) */
INT16 bottom, /*of char (-1) */
INT16 font_index, /*what font (-1) */
UINT8 confidence, /*0=perfect, 100=reject (0/100) */
UINT8 point_size, /*of char, 72=i inch, (10) */
INT8 blanks, /*no of spaces before this char (1) */
UINT8 enhancement, /*char enhancement (0) */
inT16 ocr_append_char( /*put char into shm */
uinT16 char_code, /*character itself */
inT16 left, /*of char (-1) */
inT16 right, /*of char (-1) */
inT16 top, /*of char (-1) */
inT16 bottom, /*of char (-1) */
inT16 font_index, /*what font (-1) */
uinT8 confidence, /*0=perfect, 100=reject (0/100) */
uinT8 point_size, /*of char, 72=i inch, (10) */
inT8 blanks, /*no of spaces before this char (1) */
uinT8 enhancement, /*char enhancement (0) */
OCR_CHAR_DIRECTION text_dir, /*rendering direction (OCR_CDIR_RIGHT_LEFT) */
OCR_LINE_DIRECTION line_dir, /*line rendering direction (OCR_LDIR_DOWN_RIGHT) */
OCR_NEWLINE_TYPE nl_type /*type of newline (if any) (OCR_NL_NONE) */
) {
ETEXT_DESC *buf; /*text buffer */
int index; /*char index */
INT16 result; /*of callback */
inT16 result; /*of callback */
if (ocr_state != OCS_RECOGNIZING && ocr_state != OCS_SENDING_TEXT) {
ocr_error(OCR_ERR_BAD_STATE);
@ -568,7 +568,7 @@ INT16 ocr_append_char( /*put char into shm */
* if the OCR engine is now ready to receive another image.
**********************************************************************/
INT16 ocr_send_text( /*send shm */
inT16 ocr_send_text( /*send shm */
BOOL8 more_to_come /*any text left */
) {
ETEXT_DESC *buf; /*text buffer */
@ -624,7 +624,7 @@ INT16 ocr_send_text( /*send shm */
* Closedown communications with the HP side and free up handles.
**********************************************************************/
INT16 ocr_shutdown() { /*closedown */
inT16 ocr_shutdown() { /*closedown */
#ifdef __MAC__
shm.OCRProcess.lowLongOfPSN = kNoProcess;
shm.OCRProcess.highLongOfPSN = 0;
@ -641,7 +641,7 @@ INT16 ocr_shutdown() { /*closedown */
* Free up handles or whatever to clean up without attempting to communicate.
**********************************************************************/
INT16 ocr_internal_shutdown() { /*closedown */
inT16 ocr_internal_shutdown() { /*closedown */
ocr_state = OCS_DEAD; /*record state */
#ifdef __MSW32__
if (shm.shm_mem != NULL) {
@ -667,8 +667,8 @@ INT16 ocr_internal_shutdown() { /*closedown */
* The return value is HPERR if the HP side has terminated.
**********************************************************************/
INT16 wait_for_mutex() { /*wait for HP to be ready */
INT16 result = HPERR; /*return code */
inT16 wait_for_mutex() { /*wait for HP to be ready */
inT16 result = HPERR; /*return code */
#if defined (__MSW32__) || defined (__MAC__)
result = WaitForSingleObject (shm.mutex, (unsigned long) -1)
/*wait for thread to move */
@ -688,10 +688,10 @@ INT16 wait_for_mutex() { /*wait for HP to be ready */
* The return value is HPERR if the timeout (in seconds) elapsed.
**********************************************************************/
INT16 wait_for_hp( /*wait for semaphore */
INT32 timeout /*in seconds */
inT16 wait_for_hp( /*wait for semaphore */
inT32 timeout /*in seconds */
) {
INT16 result = HPERR; /*return code */
inT16 result = HPERR; /*return code */
#if defined (__MSW32__) || defined (__MAC__)
/*wait for thread to move */
result = WaitForSingleObject (shm.hp_sem, timeout * TICKS)
@ -711,8 +711,8 @@ INT16 wait_for_hp( /*wait for semaphore */
* The return value is OKAY if the call succeeds.
**********************************************************************/
INT16 release_mutex() { /*release mutex */
INT16 result = HPERR; /*return code */
inT16 release_mutex() { /*release mutex */
inT16 result = HPERR; /*return code */
#ifdef __MSW32__
/*release it */
result = ReleaseMutex (shm.mutex) ? OKAY : HPERR;
@ -733,8 +733,8 @@ INT16 release_mutex() { /*release mutex */
* The return value is OKAY if the call succeeds.
**********************************************************************/
INT16 release_ocr() { /*release semaphore */
INT32 timeout; //time allowed
inT16 release_ocr() { /*release semaphore */
inT32 timeout; //time allowed
timeout = RELEASE_TIMEOUT * TICKS;
#ifdef __MSW32__
@ -759,7 +759,7 @@ INT16 release_ocr() { /*release semaphore */
ocr_internal_shutdown();
return OKAY;
#elif defined (__MAC__)
INT16 result = HPERR; /*return code */
inT16 result = HPERR; /*return code */
/*release it */
result = ReleaseSemaphore (shm.ocr_sem) ? OKAY : HPERR;

View File

@ -41,16 +41,16 @@
* the default.
**********************************************************************/
#ifdef __MAC__
INT16 ocr_open_shm(UINT16 *lang);
inT16 ocr_open_shm(uinT16 *lang);
#else
INT16 ocr_open_shm( /*open the shm */
inT16 ocr_open_shm( /*open the shm */
const char *shm_h, /*handle of shm */
const char *shm_size, /*size of shm segment */
const char *mutex_h, /*hp mutex */
const char *ocr_h, /*ocr semaphore */
const char *hp_h, /*hp semaphore */
const char *lang_str, /*language */
UINT16 *lang /*required language */
uinT16 *lang /*required language */
);
#endif
@ -60,11 +60,11 @@ INT16 ocr_open_shm( /*open the shm */
* Initialize one of the font descriptors.
**********************************************************************/
INT16 ocr_append_fontinfo( /*put info into shm */
UINT16 language, /*default language */
UINT8 font_family, /*serif/not, fixed/not */
UINT8 char_set, /*character set standard */
UINT8 pitch, /*fixed or prop */
inT16 ocr_append_fontinfo( /*put info into shm */
uinT16 language, /*default language */
uinT8 font_family, /*serif/not, fixed/not */
uinT8 char_set, /*character set standard */
uinT8 pitch, /*fixed or prop */
const char *name /*plain ascii name */
);
@ -75,11 +75,11 @@ INT16 ocr_append_fontinfo( /*put info into shm */
* engine.
**********************************************************************/
INT16 ocr_setup_startinfo( /*put info into shm */
UINT32 protocol, /*interface version */
UINT16 language, /*default language */
const UINT16 *name, /*name of engine */
const UINT16 *version /*version of engine */
inT16 ocr_setup_startinfo( /*put info into shm */
uinT32 protocol, /*interface version */
uinT16 language, /*default language */
const uinT16 *name, /*name of engine */
const uinT16 *version /*version of engine */
);
/**********************************************************************
@ -89,9 +89,9 @@ INT16 ocr_setup_startinfo( /*put info into shm */
* engine.
**********************************************************************/
INT16 ocr_setup_startinfo_ansi( /*put info into shm */
UINT32 protocol, /*interface version */
UINT16 language, /*default language */
inT16 ocr_setup_startinfo_ansi( /*put info into shm */
uinT32 protocol, /*interface version */
uinT16 language, /*default language */
const char *name, /*name of engine */
const char *version /*version of engine */
);
@ -104,7 +104,7 @@ INT16 ocr_setup_startinfo_ansi( /*put info into shm */
**********************************************************************/
/*get image strip */
ESTRIP_DESC *ocr_get_first_image_strip();
ESTRIP_DESC *ocr_get_first_image_strip();
/**********************************************************************
* ocr_get_next_image_strip
@ -114,7 +114,7 @@ ESTRIP_DESC *ocr_get_first_image_strip();
**********************************************************************/
/*get image strip */
ESTRIP_DESC *ocr_get_next_image_strip();
ESTRIP_DESC *ocr_get_next_image_strip();
/**********************************************************************
* ocr_setup_monitor
@ -130,7 +130,7 @@ ETEXT_DESC *ocr_setup_monitor(); /*setup monitor */
* Return the number of chars that can be fitted into the buffer.
**********************************************************************/
INT32 ocr_char_space(); /*put char into shm */
inT32 ocr_char_space(); /*put char into shm */
/**********************************************************************
* ocr_append_char
@ -139,17 +139,17 @@ INT32 ocr_char_space(); /*put char into shm */
* if there was insufficient room in the buffer.
**********************************************************************/
INT16 ocr_append_char( /*put char into shm */
UINT16 char_code, /*character itself */
INT16 left, /*of char (-1) */
INT16 right, /*of char (-1) */
INT16 top, /*of char (-1) */
INT16 bottom, /*of char (-1) */
INT16 font_index, /*what font (-1) */
UINT8 confidence, /*0=perfect, 100=reject (0/100) */
UINT8 point_size, /*of char, 72=i inch, (10) */
INT8 blanks, /*no of spaces before this char (1) */
UINT8 enhancement, /*char enhancement (0) */
inT16 ocr_append_char( /*put char into shm */
uinT16 char_code, /*character itself */
inT16 left, /*of char (-1) */
inT16 right, /*of char (-1) */
inT16 top, /*of char (-1) */
inT16 bottom, /*of char (-1) */
inT16 font_index, /*what font (-1) */
uinT8 confidence, /*0=perfect, 100=reject (0/100) */
uinT8 point_size, /*of char, 72=i inch, (10) */
inT8 blanks, /*no of spaces before this char (1) */
uinT8 enhancement, /*char enhancement (0) */
OCR_CHAR_DIRECTION text_dir, /*rendering direction (OCR_CDIR_RIGHT_LEFT) */
OCR_LINE_DIRECTION line_dir, /*line rendering direction (OCR_LDIR_DOWN_RIGHT) */
OCR_NEWLINE_TYPE nl_type /*type of newline (if any) (OCR_NL_NONE) */
@ -165,7 +165,7 @@ INT16 ocr_append_char( /*put char into shm */
* if the OCR engine is now ready to receive another image.
**********************************************************************/
INT16 ocr_send_text( /*send shm */
inT16 ocr_send_text( /*send shm */
BOOL8 more_to_come /*any text left */
);
@ -175,7 +175,7 @@ INT16 ocr_send_text( /*send shm */
* Closedown communications with the HP side and free up handles.
**********************************************************************/
INT16 ocr_shutdown(); /*closedown */
inT16 ocr_shutdown(); /*closedown */
/**********************************************************************
* ocr_error

View File

@ -31,7 +31,7 @@ member functions for the class name specified in the macro parameter.
************************************************************************** */
DLLSYM void *de_serialise_bytes(FILE *f, int size) {
DLLSYM void *de_serialise_bytes(FILE *f, int size) {
void *ptr;
ptr = alloc_mem (size);
@ -45,7 +45,7 @@ DLLSYM void *de_serialise_bytes(FILE *f, int size) {
}
DLLSYM void serialise_bytes(FILE *f, void *ptr, int size) {
DLLSYM void serialise_bytes(FILE *f, void *ptr, int size) {
/*
printf( "Serialising bytes\n" );
printf( " Addr: %d Size: %d\n", int(ptr), size );
@ -55,14 +55,14 @@ DLLSYM void serialise_bytes(FILE *f, void *ptr, int size) {
}
DLLSYM void serialise_INT32(FILE *f, INT32 the_int) {
DLLSYM void serialise_INT32(FILE *f, inT32 the_int) {
if (fprintf (f, INT32FORMAT "\n", the_int) < 0)
WRITEFAILED.error ("serialise_INT32", ABORT, NULL);
}
DLLSYM INT32 de_serialise_INT32(FILE *f) {
INT32 the_int;
DLLSYM inT32 de_serialise_INT32(FILE *f) {
inT32 the_int;
if (fscanf (f, INT32FORMAT, &the_int) != 1)
READFAILED.error ("de_serialise_INT32", ABORT, NULL);
@ -70,15 +70,15 @@ DLLSYM INT32 de_serialise_INT32(FILE *f) {
}
DLLSYM void serialise_FLOAT64(FILE *f, double the_float) {
DLLSYM void serialise_FLOAT64(FILE *f, double the_float) {
if (fprintf (f, "%g\n", the_float) < 0)
WRITEFAILED.error ("serialise_FLOAT64", ABORT, NULL);
}
DLLSYM double de_serialise_FLOAT64(FILE *f) {
DLLSYM double de_serialise_FLOAT64(FILE *f) {
double the_float;
if (fscanf (f, "%lg", &the_float) != 1)
READFAILED.error ("de_serialise_FLOAT64", ABORT, NULL);
return the_float;
@ -88,25 +88,25 @@ DLLSYM double de_serialise_FLOAT64(FILE *f) {
/**********************************************************************
* reverse32
*
* Byte swap an INT32 or UINT32.
* Byte swap an inT32 or uinT32.
**********************************************************************/
DLLSYM UINT32 reverse32( //switch endian
UINT32 num //number to fix
DLLSYM uinT32 reverse32( //switch endian
uinT32 num //number to fix
) {
return (reverse16 ((UINT16) (num & 0xffff)) << 16)
| reverse16 ((UINT16) ((num >> 16) & 0xffff));
return (reverse16 ((uinT16) (num & 0xffff)) << 16)
| reverse16 ((uinT16) ((num >> 16) & 0xffff));
}
/**********************************************************************
* reverse16
*
* Byte swap an INT16 or UINT16.
* Byte swap an inT16 or uinT16.
**********************************************************************/
DLLSYM UINT16 reverse16( //switch endian
UINT16 num //number to fix
DLLSYM uinT16 reverse16( //switch endian
uinT16 num //number to fix
) {
return ((num & 0xff) << 8) | ((num >> 8) & 0xff);
}

View File

@ -37,17 +37,17 @@ member functions for the class name specified in the macro parameter.
************************************************************************** */
extern DLLSYM void *de_serialise_bytes(FILE *f, int size);
extern DLLSYM void serialise_bytes(FILE *f, void *ptr, int size);
extern DLLSYM void serialise_INT32(FILE *f, INT32 the_int);
extern DLLSYM INT32 de_serialise_INT32(FILE *f);
extern DLLSYM void serialise_FLOAT64(FILE *f, double the_float);
extern DLLSYM double de_serialise_FLOAT64(FILE *f);
extern DLLSYM UINT32 reverse32( //switch endian
UINT32 num //number to fix
extern DLLSYM void *de_serialise_bytes(FILE *f, int size);
extern DLLSYM void serialise_bytes(FILE *f, void *ptr, int size);
extern DLLSYM void serialise_INT32(FILE *f, inT32 the_int);
extern DLLSYM inT32 de_serialise_INT32(FILE *f);
extern DLLSYM void serialise_FLOAT64(FILE *f, double the_float);
extern DLLSYM double de_serialise_FLOAT64(FILE *f);
extern DLLSYM uinT32 reverse32( //switch endian
uinT32 num //number to fix
);
extern DLLSYM UINT16 reverse16( //switch endian
UINT16 num //number to fix
extern DLLSYM uinT16 reverse16( //switch endian
uinT16 num //number to fix
);
/***********************************************************************

View File

@ -135,7 +135,7 @@ void STRING::DiscardData() {
// This is a private method; ensure FixHeader is called (or used_ is well defined)
// beforehand
char* STRING::ensure_cstr(INT32 min_capacity) {
char* STRING::ensure_cstr(inT32 min_capacity) {
STRING_HEADER* orig_header = GetHeader();
if (min_capacity <= orig_header->capacity_)
return ((char *)this->data_) + sizeof(STRING_HEADER);
@ -203,7 +203,7 @@ BOOL8 STRING::contains(const char c) const {
return (c != '\0') && (strchr (GetCStr(), c) != NULL);
}
INT32 STRING::length() const {
inT32 STRING::length() const {
FixHeader();
return GetHeader()->used_ - 1;
}
@ -227,11 +227,11 @@ const char* STRING::string() const {
* Also makes the [] operator return a const so it is immutable
*/
#if STRING_IS_PROTECTED
const char& STRING::operator[](INT32 index) const {
const char& STRING::operator[](inT32 index) const {
return GetCStr()[index];
}
void STRING::insert_range(INT32 index, const char* str, int len) {
void STRING::insert_range(inT32 index, const char* str, int len) {
// if index is outside current range, then also grow size of string
// to accmodate the requested range.
STRING_HEADER* this_header = GetHeader();
@ -264,7 +264,7 @@ void STRING::insert_range(INT32 index, const char* str, int len) {
CHECK_INVARIANT(this);
}
void STRING::erase_range(INT32 index, int len) {
void STRING::erase_range(inT32 index, int len) {
char* this_cstr = GetCStr();
STRING_HEADER* this_header = GetHeader();
@ -274,7 +274,7 @@ void STRING::erase_range(INT32 index, int len) {
CHECK_INVARIANT(this);
}
void STRING::truncate_at(INT32 index) {
void STRING::truncate_at(inT32 index) {
char* this_cstr = ensure_cstr(index);
this_cstr[index] = '\0';
GetHeader()->used_ = index;
@ -282,7 +282,7 @@ void STRING::truncate_at(INT32 index) {
}
#else
char& STRING::operator[](INT32 index) const {
char& STRING::operator[](inT32 index) const {
// Code is casting away this const and mutating the string,
// so mark used_ as -1 to flag it unreliable.
GetHeader()->used_ = -1;
@ -321,7 +321,7 @@ BOOL8 STRING::operator!=(const char* cstr) const {
if (cstr == NULL)
return this_header->used_ > 1; // either '\0' or NULL
else {
INT32 length = strlen(cstr) + 1;
inT32 length = strlen(cstr) + 1;
return (this_header->used_ != length)
|| (memcmp(GetCStr(), cstr, length) != 0);
}

View File

@ -43,17 +43,17 @@ class DLLSYM STRING
~STRING ();
BOOL8 contains(const char c) const;
INT32 length() const;
inT32 length() const;
const char *string() const;
#if STRING_IS_PROTECTED
const char &operator[] (INT32 index) const;
const char &operator[] (inT32 index) const;
// len is number of chars in s to insert starting at index in this string
void insert_range(INT32 index, const char*s, int len);
void erase_range(INT32 index, int len);
void truncate_at(INT32 index);
void insert_range(inT32 index, const char*s, int len);
void erase_range(inT32 index, int len);
void truncate_at(inT32 index);
#else
char &operator[] (INT32 index) const;
char &operator[] (inT32 index) const;
#endif
BOOL8 operator== (const STRING & string) const;
@ -81,7 +81,7 @@ class DLLSYM STRING
make_serialise (STRING)
// ensure capcaity but keep pointer encapsulated
inline void ensure(INT32 min_capacity) { ensure_cstr(min_capacity); }
inline void ensure(inT32 min_capacity) { ensure_cstr(min_capacity); }
private:
typedef struct STRING_HEADER {
@ -128,7 +128,7 @@ class DLLSYM STRING
// Ensure string has requested capacity as optimization
// to avoid unnecessary reallocations.
// The return value is a cstr buffer with at least requested capacity
char* ensure_cstr(INT32 min_capacity);
char* ensure_cstr(inT32 min_capacity);
void FixHeader() const; // make used_ non-negative, even if const

View File

@ -33,7 +33,7 @@ char *tessoptarg;
**********************************************************************/
int tessopt ( //parse args
INT32 argc, //arg count
inT32 argc, //arg count
char *argv[], //args
const char *arglist //string of arg chars
) {

View File

@ -24,7 +24,7 @@ extern int tessoptind;
extern char *tessoptarg;
int tessopt ( //parse args
INT32 argc, //arg count
inT32 argc, //arg count
char *argv[], //args
const char *arglist //string of arg chars
);

View File

@ -44,7 +44,7 @@ const char *format, ... //special message
static FILE *debugfp = NULL; //debug file
//debug window
static DEBUG_WIN *debugwin = NULL;
INT32 offset = 0; //into message
inT32 offset = 0; //into message
static char msg[MAX_MSG_LEN + 1];
va_start(args, format); //variable list

View File

@ -34,13 +34,21 @@ UNICHARSET::UNICHARSET() :
unichars(NULL),
ids(),
size_used(0),
size_reserved(0)
size_reserved(0),
script_table(0),
script_table_size_used(0),
script_table_size_reserved(0),
null_script("NULL")
{
}
UNICHARSET::~UNICHARSET() {
if (size_reserved > 0)
if (size_reserved > 0) {
for (int i = 0; i < script_table_size_used; ++i)
delete[] script_table[i];
delete[] script_table;
delete[] unichars;
}
}
void UNICHARSET::reserve(int unichars_number) {
@ -48,6 +56,8 @@ void UNICHARSET::reserve(int unichars_number) {
UNICHAR_SLOT* unichars_new = new UNICHAR_SLOT[unichars_number];
for (int i = 0; i < size_used; ++i)
memcpy(&unichars_new[i], &unichars[i], sizeof(UNICHAR_SLOT));
for (int j = size_used; j < unichars_number; ++j)
unichars_new[j].properties.script = add_script(null_script);
delete[] unichars;
unichars = unichars_new;
size_reserved = unichars_number;
@ -96,6 +106,44 @@ const char* const UNICHARSET::id_to_unichar(UNICHAR_ID id) const {
return unichars[id].representation;
}
// Return a STRING containing debug information on the unichar, including
// the id_to_unichar, its hex unicodes and the properties.
STRING UNICHARSET::debug_str(UNICHAR_ID id) const {
const char* str = id_to_unichar(id);
STRING result = str;
result += " [";
int step = 1;
// Chop into unicodes and code each as hex.
for (int i = 0; str[i] != '\0'; i += step) {
char hex[sizeof(int) * 2 + 1];
step = UNICHAR::utf8_step(str + i);
if (step == 0) {
step = 1;
sprintf(hex, "%x", str[i]);
} else {
UNICHAR ch(str + i, step);
sprintf(hex, "%x", ch.first_uni());
}
result += hex;
result += " ";
}
result += "]";
// Append a for lower alpha, A for upper alpha, and x if alpha but neither.
if (get_isalpha(id)) {
if (get_islower(id))
result += "a";
else if (get_isupper(id))
result += "A";
else
result += "x";
}
// Append 0 if a digit.
if (get_isdigit(id)) {
result += "0";
}
return result;
}
void UNICHARSET::unichar_insert(const char* const unichar_repr) {
if (!ids.contains(unichar_repr)) {
if (size_used == size_reserved) {
@ -110,6 +158,7 @@ void UNICHARSET::unichar_insert(const char* const unichar_repr) {
this->set_islower(size_used, false);
this->set_isupper(size_used, false);
this->set_isdigit(size_used, false);
this->set_script(size_used, add_script(null_script));
this->unichars[size_used].properties.enabled = true;
ids.insert(unichar_repr, size_used);
++size_used;
@ -148,9 +197,10 @@ bool UNICHARSET::save_to_file(const char* filename) const {
properties |= ISDIGIT_MASK;
if (strcmp(this->id_to_unichar(id), " ") == 0)
fprintf(file, "%s %x\n", "NULL", properties);
fprintf(file, "%s %x %s\n", "NULL", properties, this->get_script(id));
else
fprintf(file, "%s %x\n", this->id_to_unichar(id), properties);
fprintf(file, "%s %x %s\n", this->id_to_unichar(id), properties,
this->get_script(id));
}
fclose(file);
return true;
@ -174,9 +224,12 @@ bool UNICHARSET::load_from_file(const char* filename) {
for (UNICHAR_ID id = 0; id < unicharset_size; ++id) {
char unichar[256];
unsigned int properties;
char script[64];
if (fgets(buffer, sizeof (buffer), file) == NULL ||
sscanf(buffer, "%s %x", unichar, &properties) != 2) {
(sscanf(buffer, "%s %x %63s", unichar, &properties, script) != 3 &&
!(sscanf(buffer, "%s %x", unichar, &properties) == 2 &&
strcpy(script, null_script)))) {
fclose(file);
return false;
}
@ -189,6 +242,7 @@ bool UNICHARSET::load_from_file(const char* filename) {
this->set_islower(id, properties & ISLOWER_MASK);
this->set_isupper(id, properties & ISUPPER_MASK);
this->set_isdigit(id, properties & ISDIGIT_MASK);
this->set_script(id, add_script(script));
this->unichars[id].properties.enabled = true;
}
fclose(file);
@ -231,3 +285,23 @@ void UNICHARSET::set_black_and_whitelist(const char* blacklist,
}
}
char* UNICHARSET::add_script(const char* script) {
for (int i = 0; i < script_table_size_used; ++i) {
if (strcmp(script, script_table[i]) == 0)
return script_table[i];
}
if (script_table_size_reserved == 0) {
script_table_size_reserved = 8;
script_table = new char*[script_table_size_reserved];
}
if (script_table_size_used + 1 >= script_table_size_reserved) {
char** new_script_table = new char*[script_table_size_reserved * 2];
memcpy(new_script_table, script_table, script_table_size_reserved * sizeof(char*));
delete[] script_table;
script_table = new_script_table;
script_table_size_reserved = 2 * script_table_size_reserved;
}
script_table[script_table_size_used] = new char[strlen(script) + 1];
strcpy(script_table[script_table_size_used], script);
return script_table[script_table_size_used++];
}

View File

@ -20,6 +20,7 @@
#ifndef THIRD_PARTY_TESSERACT_CCUTIL_UNICHARSET_H__
#define THIRD_PARTY_TESSERACT_CCUTIL_UNICHARSET_H__
#include "strngs.h"
#include "unichar.h"
#include "unicharmap.h"
@ -53,6 +54,10 @@ class UNICHARSET {
// within the UNICHARSET.
const char* const id_to_unichar(UNICHAR_ID id) const;
// Return a STRING containing debug information on the unichar, including
// the id_to_unichar, its hex unicodes and the properties.
STRING debug_str(UNICHAR_ID id) const;
// Add a unichar representation to the set.
void unichar_insert(const char* const unichar_repr);
@ -67,6 +72,12 @@ class UNICHARSET {
// Clear the UNICHARSET (all the previous data is lost).
void clear() {
if (size_reserved > 0) {
for (int i = 0; i < script_table_size_used; ++i)
delete[] script_table[i];
delete[] script_table;
script_table = 0;
script_table_size_reserved = 0;
script_table_size_used = 0;
delete[] unichars;
unichars = 0;
size_reserved = 0;
@ -120,6 +131,12 @@ class UNICHARSET {
unichars[unichar_id].properties.isdigit = value;
}
// Set the script name of the given unichar to the given value.
// Value is copied and thus can be a temporary;
void set_script(UNICHAR_ID unichar_id, const char* value) {
unichars[unichar_id].properties.script = add_script(value);
}
// Return the isalpha property of the given unichar.
bool get_isalpha(UNICHAR_ID unichar_id) const {
return unichars[unichar_id].properties.isalpha;
@ -140,6 +157,13 @@ class UNICHARSET {
return unichars[unichar_id].properties.isdigit;
}
// Return the script name of the given unichar.
// The returned pointer will always be the same for the same script, it's
// managed by unicharset and thus MUST NOT be deleted
const char* get_script(UNICHAR_ID unichar_id) const {
return unichars[unichar_id].properties.script;
}
// Return the isalpha property of the given unichar representation.
bool get_isalpha(const char* const unichar_repr) const {
return get_isalpha(unichar_to_id(unichar_repr));
@ -160,6 +184,13 @@ class UNICHARSET {
return get_isdigit(unichar_to_id(unichar_repr));
}
// Return the script name of the given unichar representation.
// The returned pointer will always be the same for the same script, it's
// managed by unicharset and thus MUST NOT be deleted
const char* get_script(const char* const unichar_repr) const {
return get_script(unichar_to_id(unichar_repr));
}
// Return the isalpha property of the given unichar representation.
// Only the first length characters from unichar_repr are used.
bool get_isalpha(const char* const unichar_repr,
@ -188,6 +219,15 @@ class UNICHARSET {
return get_isdigit(unichar_to_id(unichar_repr, length));
}
// Return the script name of the given unichar representation.
// Only the first length characters from unichar_repr are used.
// The returned pointer will always be the same for the same script, it's
// managed by unicharset and thus MUST NOT be deleted
const char* get_script(const char* const unichar_repr,
int length) const {
return get_script(unichar_to_id(unichar_repr, length));
}
// Return the enabled property of the given unichar.
bool get_enabled(UNICHAR_ID unichar_id) const {
return unichars[unichar_id].properties.enabled;
@ -195,12 +235,18 @@ class UNICHARSET {
private:
// Uniquify the given script. For two scripts a and b, if strcmp(a, b) == 0,
// then the returned pointer will be the same.
// The script parameter is copied and thus can be a temporary.
char* add_script(const char* script);
struct UNICHAR_PROPERTIES {
bool isalpha;
bool islower;
bool isupper;
bool isdigit;
bool enabled;
bool isalpha;
bool islower;
bool isupper;
bool isdigit;
bool enabled;
char* script;
};
struct UNICHAR_SLOT {
@ -212,6 +258,10 @@ class UNICHARSET {
UNICHARMAP ids;
int size_used;
int size_reserved;
char** script_table;
int script_table_size_used;
int script_table_size_reserved;
const char* null_script;
};
#endif // THIRD_PARTY_TESSERACT_CCUTIL_UNICHARSET_H__

View File

@ -102,7 +102,7 @@ INT_VAR_TO::INT_VAR_TO() { //constructor
**********************************************************************/
INT_VARIABLE::INT_VARIABLE( //constructor
INT32 v, //the variable
inT32 v, //the variable
const char *vname, //of variable
const char *comment //info on variable
) {
@ -524,8 +524,8 @@ DLLSYM BOOL8 read_variables_file(const char *file // name to read
BOOL8 anyerr; // true if any error
char flag; // file flag
BOOL8 foundit; // found variable
INT16 length; // length of line
INT16 nameoffset; // offset for real name
inT16 length; // length of line
inT16 nameoffset; // offset for real name
char *valptr; // value field
char *stringend; // end of string value
FILE *fp; // file pointer

View File

@ -60,7 +60,7 @@ class DLLSYM INT_VARIABLE
friend bool set_new_style_variable(const char *variable, const char* value);
public:
INT_VARIABLE(INT32 v, // initial value
INT_VARIABLE(inT32 v, // initial value
const char *vname, // name of variable
const char *comment); // info on variable
@ -71,11 +71,11 @@ class DLLSYM INT_VARIABLE
}
~INT_VARIABLE(); // for elist only
operator INT32() { // conversion
operator inT32() { // conversion
return value; // access as int
}
void set_value(INT32 v) { // value to set
void set_value(inT32 v) { // value to set
value = v;
}
@ -93,7 +93,7 @@ class DLLSYM INT_VARIABLE
static void print(FILE *fp); // file to print on
private:
INT32 value; // the variable
inT32 value; // the variable
const char *name; // name of variable
const char *info; // for menus
static INT_VAR_FROM copy; // pre constructor