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