Tesseract  3.02
tesseract-ocr/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  **                  __MSW__ and _WIN32 must be uncommented out.
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 __MSW__, _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 #else
00068 /********************************************************/
00069 /* __MSW__ */
00070 #ifdef __MSW__
00071 #include <windows.h>             // provides standard definitions (like HANDLE)
00072 #endif
00073 #endif
00074 
00075 /********************************************************/
00076 /* __MAC__ */
00077 #ifdef __MAC__
00078 #include <Types.h>
00079 /*----------------------------*/
00080 /*----------------------------*/
00081 #endif
00082 /********************************************************/
00083 #if defined(__UNIX__) || defined( __DOS__ ) || defined(__OS2__) || defined(__PM__)
00084 /*----------------------------*/
00085 /* FarProc and FarData */
00086 /*----------------------------*/
00087 /*----------------------------*/
00088 #endif
00089 /*****************************************************************************
00090  **
00091  **                      Standard GHC Definitions
00092  **
00093  *****************************************************************************/
00094 
00095 #ifdef __MOTO__
00096 #define __NATIVE__   MOTO
00097 #else
00098 #define __NATIVE__   INTEL
00099 #endif
00100 
00101 //typedef HANDLE FD*  PHANDLE;
00102 
00103 // definitions of portable data types (numbers and characters)
00104 typedef SIGNED char inT8;
00105 typedef unsigned char uinT8;
00106 typedef short inT16;
00107 typedef unsigned short uinT16;
00108 typedef int inT32;
00109 typedef unsigned int uinT32;
00110 #if (_MSC_VER >= 1200)            //%%% vkr for VC 6.0
00111 typedef INT64 inT64;
00112 typedef UINT64 uinT64;
00113 #else
00114 typedef long long int inT64;
00115 typedef unsigned long long int uinT64;
00116 #endif                           //%%% vkr for VC 6.0
00117 typedef float FLOAT32;
00118 typedef double FLOAT64;
00119 typedef unsigned char BOOL8;
00120 
00121 #define INT32FORMAT "%d"
00122 #define INT64FORMAT "%lld"
00123 
00124 #define MAX_INT8  0x7f
00125 #define MAX_INT16 0x7fff
00126 #define MAX_INT32 0x7fffffff
00127 #define MAX_UINT8 0xff
00128 #define MAX_UINT16  0xffff
00129 #define MAX_UINT32  0xffffffff
00130 #define MAX_FLOAT32 ((float)3.40282347e+38)
00131 
00132 #define MIN_INT8  0x80
00133 #define MIN_INT16 0x8000
00134 #define MIN_INT32 0x80000000
00135 #define MIN_UINT8 0x00
00136 #define MIN_UINT16  0x0000
00137 #define MIN_UINT32  0x00000000
00138 #define MIN_FLOAT32 ((float)1.17549435e-38)
00139 
00140 // Defines
00141 #ifndef TRUE
00142 #define TRUE            1
00143 #endif
00144 
00145 #ifndef FALSE
00146 #define FALSE           0
00147 #endif
00148 
00149 #ifndef NULL
00150 #define NULL            0L
00151 #endif
00152 
00153 // Return true if x is within tolerance of y
00154 template<class T> bool NearlyEqual(T x, T y, T tolerance) {
00155   T diff = x - y;
00156   return diff <= tolerance && -diff <= tolerance;
00157 }
00158 
00159 #endif