tesseract  3.03
/usr/local/google/home/jbreiden/tesseract-ocr-read-only/ccutil/host.h
Go to the documentation of this file.
00001 /******************************************************************************
00002  **  Filename:       Host.h
00003  **  Purpose:        This is the system independent typedefs and defines
00004  **  Author:         MN, JG, MD
00005  **  Version:        5.4.1
00006  **  History:        11/7/94 MCD received the modification that Lennart made
00007  **                  to port to 32 bit world and modify this file so that it
00008  **                  will be shared between platform.
00009  **                  11/9/94 MCD Make MSW32 subset of MSW. Now MSW means
00010  **                  MicroSoft Window and MSW32 means the 32 bit worlds
00011  **                  of MicroSoft Window. Therefore you want the environment
00012  **                  to be MicroSoft Window and in the 32 bit world -
00013  **                  _WIN32 must be defined by your compiler.
00014  **                  11/30/94 MCD Incorporated comments received for more
00015  **                  readability and the missing typedef for FLOAT.
00016  **                  12/1/94 MCD Added PFVOID typedef
00017  **                  5/1/95 MCD. Made many changes based on the inputs.
00018  **                  Changes:
00019  **                  1) Rearrange the #ifdef so that there're definitions for
00020  **                  particular platforms.
00021  **                  2) Took out the #define for computer and environment
00022  **                  that developer can uncomment
00023  **                  3) Added __OLDCODE__ where the defines will be
00024  **                  obsoleted in the next version and advise not to use.
00025  **                  4) Added the definitions for the following:
00026  **                  FILE_HANDLE, MEMORY_HANDLE, BOOL8,
00027  **                  MAX_INT8, MAX_INT16, MAX_INT32, MAX_UINT8
00028  **                  MAX_UINT16, MAX_UINT32, MAX_FLOAT32
00029  **                 06/19/96 MCD. Took out MAX_FLOAT32
00030  **                 07/15/96 MCD. Fixed the comments error
00031  **                 Add back BOOL8.
00032  **
00033  **  (c) Copyright Hewlett-Packard Company, 1988-1996.
00034  ** Licensed under the Apache License, Version 2.0 (the "License");
00035  ** you may not use this file except in compliance with the License.
00036  ** You may obtain a copy of the License at
00037  ** http://www.apache.org/licenses/LICENSE-2.0
00038  ** Unless required by applicable law or agreed to in writing, software
00039  ** distributed under the License is distributed on an "AS IS" BASIS,
00040  ** WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
00041  ** See the License for the specific language governing permissions and
00042  ** limitations under the License.
00043  */
00044 
00045 #ifndef   __HOST__
00046 #define   __HOST__
00047 
00048 /******************************************************************************
00049  **                                IMPORTANT!!!                                                                                                                 **
00050  **                                                                                                                                                                              **
00051  ** Defines either _WIN32, __MAC__, __UNIX__, __OS2__, __PM__ to
00052  ** use the specified definitions indicated below in the preprocessor settings.                                                        **
00053  **                                                                                                                                                                              **
00054  ** Also define either  __FarProc__ or  __FarData__  and __MOTO__ to use the
00055  ** specified definitions indicated below in the preprocessor settings.                                                                        **
00056  **                                                                                                                                                                             **
00057  ** If a preprocessor settings is not allow in the compiler that is being use,
00058  ** then it is recommended that a "platform.h" is created with the definition
00059  ** of the computer and/or operating system.
00060  ******************************************************************************/
00061 
00062 #include "platform.h"
00063 /* _WIN32 */
00064 #ifdef _WIN32
00065 #include <windows.h>
00066 #include <winbase.h>             // winbase.h contains windows.h
00067 #endif
00068 
00069 /********************************************************/
00070 /* __MAC__ */
00071 #ifdef __MAC__
00072 #include <Types.h>
00073 /*----------------------------*/
00074 /*----------------------------*/
00075 #endif
00076 /********************************************************/
00077 #if defined(__UNIX__) || defined( __DOS__ ) || defined(__OS2__) || defined(__PM__)
00078 /*----------------------------*/
00079 /* FarProc and FarData */
00080 /*----------------------------*/
00081 /*----------------------------*/
00082 #endif
00083 /*****************************************************************************
00084  **
00085  **                      Standard GHC Definitions
00086  **
00087  *****************************************************************************/
00088 
00089 #ifdef __MOTO__
00090 #define __NATIVE__   MOTO
00091 #else
00092 #define __NATIVE__   INTEL
00093 #endif
00094 
00095 //typedef HANDLE FD*  PHANDLE;
00096 
00097 // definitions of portable data types (numbers and characters)
00098 typedef SIGNED char inT8;
00099 typedef unsigned char uinT8;
00100 typedef short inT16;
00101 typedef unsigned short uinT16;
00102 typedef int inT32;
00103 typedef unsigned int uinT32;
00104 #if (_MSC_VER >= 1200)            //%%% vkr for VC 6.0
00105 typedef INT64 inT64;
00106 typedef UINT64 uinT64;
00107 #else
00108 typedef long long int inT64;
00109 typedef unsigned long long int uinT64;
00110 #endif                           //%%% vkr for VC 6.0
00111 typedef float FLOAT32;
00112 typedef double FLOAT64;
00113 typedef unsigned char BOOL8;
00114 
00115 #define INT32FORMAT "%d"
00116 #define INT64FORMAT "%lld"
00117 
00118 #define MAX_INT8  0x7f
00119 #define MAX_INT16 0x7fff
00120 #define MAX_INT32 0x7fffffff
00121 #define MAX_UINT8 0xff
00122 #define MAX_UINT16  0xffff
00123 #define MAX_UINT32  0xffffffff
00124 #define MAX_FLOAT32 ((float)3.40282347e+38)
00125 
00126 #define MIN_INT8  0x80
00127 #define MIN_INT16 0x8000
00128 #define MIN_INT32 static_cast<int>(0x80000000)
00129 #define MIN_UINT8 0x00
00130 #define MIN_UINT16  0x0000
00131 #define MIN_UINT32  0x00000000
00132 #define MIN_FLOAT32 ((float)1.17549435e-38)
00133 
00134 // Defines
00135 #ifndef TRUE
00136 #define TRUE            1
00137 #endif
00138 
00139 #ifndef FALSE
00140 #define FALSE           0
00141 #endif
00142 
00143 #ifndef NULL
00144 #define NULL            0L
00145 #endif
00146 
00147 // Return true if x is within tolerance of y
00148 template<class T> bool NearlyEqual(T x, T y, T tolerance) {
00149   T diff = x - y;
00150   return diff <= tolerance && -diff <= tolerance;
00151 }
00152 
00153 #endif
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines