xincs.h

Go to the documentation of this file.
00001 /********************************************************************************
00002 *                                                                               *
00003 *              F O X   P r i v a t e   I n c l u d e   F i l e s                *
00004 *                                                                               *
00005 *********************************************************************************
00006 * Copyright (C) 1997,2006 by Jeroen van der Zijp.   All Rights Reserved.        *
00007 *********************************************************************************
00008 * This library is free software; you can redistribute it and/or                 *
00009 * modify it under the terms of the GNU Lesser General Public                    *
00010 * License as published by the Free Software Foundation; either                  *
00011 * version 2.1 of the License, or (at your option) any later version.            *
00012 *                                                                               *
00013 * This library is distributed in the hope that it will be useful,               *
00014 * but WITHOUT ANY WARRANTY; without even the implied warranty of                *
00015 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU             *
00016 * Lesser General Public License for more details.                               *
00017 *                                                                               *
00018 * You should have received a copy of the GNU Lesser General Public              *
00019 * License along with this library; if not, write to the Free Software           *
00020 * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA.    *
00021 *********************************************************************************
00022 * $Id: xincs.h,v 1.73 2006/01/22 17:58:14 fox Exp $                             *
00023 ********************************************************************************/
00024 #ifndef XINCS_H
00025 #define XINCS_H
00026 
00027 
00029 
00030 // Thread safe
00031 #ifndef _POSIX_PTHREAD_SEMANTICS
00032 #define _POSIX_PTHREAD_SEMANTICS
00033 #endif
00034 
00035 /************************  Platform  Dependent  Headers  ***********************/
00036 
00037 #ifndef __USE_LARGEFILE64
00038 #define __USE_LARGEFILE64 1
00039 #endif
00040 #ifndef __USE_FILE_OFFSET64
00041 #define __USE_FILE_OFFSET64 1       // for GNU lib
00042 #endif
00043 
00044 // GNU extras if we can get them
00045 #ifndef _GNU_SOURCE
00046 #define _GNU_SOURCE
00047 #endif
00048 
00049 // Use 64-bit files
00050 #ifndef WIN32
00051 #ifndef _FILE_OFFSET_BITS
00052 #define _FILE_OFFSET_BITS 64
00053 #endif
00054 #endif
00055 
00056 // Basic includes
00057 #include <stdio.h>
00058 #include <stdlib.h>
00059 #include <stdarg.h>
00060 #include <limits.h>
00061 #include <math.h>
00062 #include <float.h>
00063 #include <string.h>
00064 #include <errno.h>
00065 #include <signal.h>
00066 #include <time.h>
00067 #include <locale.h>
00068 #include <fcntl.h>
00069 #include <sys/types.h>
00070 #include <sys/stat.h>
00071 
00072 #ifndef WIN32
00073 
00074 #include <grp.h>
00075 #include <pwd.h>
00076 #include <sys/ioctl.h>
00077 #ifdef HAVE_SYS_FILIO_H         // Get FIONREAD on Solaris
00078 #include <sys/filio.h>
00079 #endif
00080 #else
00081 
00082 #include <io.h>                 // For _access()
00083 #if defined(_MSC_VER) || defined(__WATCOMC__)       // Microsoft Visual C++ or Watcom C++
00084 #include <direct.h>
00085 #include <fcntl.h>
00086 #define lseek _lseeki64
00087 #define stat _stati64
00088 #define lstat _stati64
00089 #define getcwd _getcwd
00090 #define mkdir _mkdir
00091 #define access _access
00092 #define vsnprintf _vsnprintf
00093 #define execl _execl
00094 #define execlp _execlp
00095 #define execle _execle
00096 #define execv _execv
00097 #define execve _execve
00098 #define execvp _execvp
00099 #define strdup _strdup
00100 #define alloca _alloca
00101 #endif
00102 #ifdef __BORLANDC__         // Borland C++ Builder
00103 #include <dir.h>
00104 #if __BORLANDC__ <= 0x0530      // C++ Builder 3.0
00105 #define vsnprintf(a, b, c, d) vsprintf(a, c, d)
00106 #endif
00107 #define lstat stat
00108 #endif
00109 #ifdef __MINGW32__              // GCC MingW32
00110 #include <direct.h>
00111 #define vsnprintf _vsnprintf
00112 #endif
00113 #ifdef __SC__                   // Digital Mars C++ Compiler
00114 #include <direct.h>
00115 #include <io.h>                 // For _access()
00116 #define vsnprintf _vsnprintf
00117 #endif
00118 
00119 #endif
00120 
00121 #ifdef HAVE_UNISTD_H
00122 #include <unistd.h>
00123 #endif
00124 #ifdef HAVE_SYS_WAIT_H
00125 #include <sys/wait.h>
00126 #endif
00127 #ifdef TIME_WITH_SYS_TIME
00128 #include <sys/time.h>
00129 #include <time.h>
00130 #else
00131 #ifdef HAVE_SYS_TIME_H
00132 #include <sys/time.h>
00133 #else
00134 #include <time.h>
00135 #endif
00136 #endif
00137 #ifdef HAVE_SYS_PARAM_H
00138 #include <sys/param.h>
00139 #endif
00140 #ifdef HAVE_SYS_SELECT_H
00141 #if (!defined(__MINGW32__)) && (!defined(hpux))
00142 #include <sys/select.h>
00143 #endif
00144 #endif
00145 #ifdef HAVE_DIRENT_H
00146 #include <dirent.h>
00147 #define NAMLEN(dirent) strlen((dirent)->d_name)
00148 #else
00149 #define dirent direct
00150 #define NAMLEN(dirent) (dirent)->d_namlen
00151 #ifdef HAVE_SYS_NDIR_H
00152 #include <sys/ndir.h>
00153 #endif
00154 #ifdef HAVE_SYS_DIR_H
00155 #include <sys/dir.h>
00156 #endif
00157 #ifdef HAVE_NDIR_H
00158 #include <ndir.h>
00159 #endif
00160 #endif
00161 #ifdef HAVE_XSHM_H
00162 #include <sys/ipc.h>
00163 #include <sys/shm.h>
00164 #endif
00165 #ifdef HAVE_MMAP
00166 #include <sys/mman.h>
00167 #endif
00168 
00169 
00170 // For thread-safe readdir_r, we sometimes need extra
00171 // space above and beyond the space for dirent itself
00172 #ifdef HAVE_DIRENT_H
00173 #ifndef WIN32
00174 struct fxdirent : public dirent {
00175   char buffer[256];
00176   };
00177 #endif
00178 #endif
00179 
00180 
00181 // MS-Windows
00182 #ifdef WIN32
00183 #ifndef STRICT
00184 #define STRICT
00185 #endif
00186 #ifndef WIN32_LEAN_AND_MEAN
00187 #define WIN32_LEAN_AND_MEAN
00188 #endif
00189 #ifndef _WIN32_WINNT
00190 #define _WIN32_WINNT 0x600
00191 #endif
00192 #include <windows.h>
00193 #ifndef __CYGWIN__
00194 #include <winsock2.h>
00195 #endif
00196 #include <commctrl.h>           // For _TrackMouseEvent
00197 #include <shellapi.h>
00198 
00199 // X windows includes
00200 #else
00201 
00202 #include <X11/X.h>
00203 #define XRegisterIMInstantiateCallback broken_XRegisterIMInstantiateCallback
00204 #define XUnregisterIMInstantiateCallback broken_XUnregisterIMInstantiateCallback
00205 #define XSetIMValues broken_XSetIMValues
00206 #include <X11/Xlib.h>
00207 #undef XRegisterIMInstantiateCallback
00208 #undef XUnregisterIMInstantiateCallback
00209 #undef XSetIMValues
00210 #include <X11/Xcms.h>
00211 #include <X11/Xutil.h>
00212 #include <X11/Xresource.h>
00213 #include <X11/Xatom.h>
00214 #include <X11/cursorfont.h>
00215 #ifdef HUMMINGBIRD
00216 #include <X11/XlibXtra.h>
00217 #endif
00218 #ifdef HAVE_XSHM_H
00219 #include <X11/extensions/XShm.h>
00220 #endif
00221 #ifdef HAVE_XCURSOR_H
00222 #include <X11/Xcursor/Xcursor.h>
00223 #endif
00224 #ifdef HAVE_XFT_H
00225 #include <X11/Xft/Xft.h>
00226 #endif
00227 #ifdef HAVE_XSHAPE_H
00228 #include <X11/extensions/shape.h>
00229 #endif
00230 #ifdef HAVE_XRANDR_H
00231 #include <X11/extensions/Xrandr.h>
00232 #endif
00233 
00234 #ifndef NO_XIM
00235 #ifndef XlibSpecificationRelease        // Not defined until X11R5
00236 #define NO_XIM
00237 #elif XlibSpecificationRelease < 6      // Need at least Xlib X11R6
00238 #define NO_XIM
00239 #endif
00240 #endif
00241 
00242 #ifndef NO_XIM
00243 extern "C" Bool XRegisterIMInstantiateCallback(Display*,struct _XrmHashBucketRec*,char*,char*,XIMProc,XPointer);
00244 extern "C" Bool XUnregisterIMInstantiateCallback(Display*,struct _XrmHashBucketRec*,char*,char*,XIMProc,XPointer);
00245 extern "C" char *XSetIMValues(XIM,...);
00246 #endif
00247 
00248 #endif
00249 
00250 
00251 
00252 
00253 // OpenGL includes
00254 #ifdef HAVE_GL_H
00255 #ifndef SUN_OGL_NO_VERTEX_MACROS
00256 #define SUN_OGL_NO_VERTEX_MACROS
00257 #endif
00258 #ifndef HPOGL_SUPPRESS_FAST_API
00259 #define HPOGL_SUPPRESS_FAST_API
00260 #endif
00261 #include <GL/gl.h>
00262 #ifndef WIN32
00263 #include <GL/glx.h>
00264 #endif
00265 #endif
00266 #ifndef GLAPIENTRY
00267 #define GLAPIENTRY
00268 #endif
00269 #ifndef GLAPI
00270 #define GLAPI
00271 #endif
00272 #ifdef HAVE_GLU_H
00273 #include <GL/glu.h>
00274 #endif
00275 
00276 // Maximum path length
00277 #ifndef MAXPATHLEN
00278 #if defined(PATH_MAX)
00279 #define MAXPATHLEN   PATH_MAX
00280 #elif defined(_MAX_PATH)
00281 #define MAXPATHLEN   _MAX_PATH
00282 #elif defined(MAX_PATH)
00283 #define MAXPATHLEN   MAX_PATH
00284 #else
00285 #define MAXPATHLEN   1024
00286 #endif
00287 #endif
00288 
00289 // Modes for access(filename,mode) on Windows
00290 #ifdef WIN32
00291 #ifndef R_OK
00292 #define R_OK 4
00293 #endif
00294 #ifndef W_OK
00295 #define W_OK 2
00296 #endif
00297 #ifndef X_OK
00298 #define X_OK 1
00299 #endif
00300 #ifndef F_OK
00301 #define F_OK 0
00302 #endif
00303 #endif
00304 
00305 // File open modes on Windows
00306 #ifdef WIN32
00307 #if defined(_MSC_VER)
00308 #define O_APPEND _O_APPEND
00309 #define O_CREAT  _O_CREAT
00310 #define O_EXCL   _O_EXCL
00311 #define O_RDONLY _O_RDONLY
00312 #define O_RDWR   _O_RDWR
00313 #define O_TRUNC  _O_TRUNC
00314 #define O_WRONLY _O_WRONLY
00315 #define O_BINARY _O_BINARY
00316 #endif
00317 #endif
00318 
00319 // Some systems don't have it
00320 #ifndef SEEK_SET
00321 #define SEEK_SET 0
00322 #endif
00323 #ifndef SEEK_CUR
00324 #define SEEK_CUR 1
00325 #endif
00326 #ifndef SEEK_END
00327 #define SEEK_END 2
00328 #endif
00329 
00330 // Printer stuff
00331 #ifdef WIN32
00332 #include <winspool.h>
00333 #endif
00334 
00335 
00336 // Wheel support (OS >= W98, OS>=NT4.0)
00337 #ifdef WIN32
00338 
00339 // Missing wheel message id's
00340 #ifndef SPI_GETWHEELSCROLLLINES
00341 #define SPI_GETWHEELSCROLLLINES   104
00342 #endif
00343 #ifndef WM_MOUSEWHEEL
00344 #define WM_MOUSEWHEEL             0x020A
00345 #endif
00346 
00347 // GetSystemMetrics parameters missing in header files
00348 #ifndef SM_XVIRTUALSCREEN
00349 #define SM_XVIRTUALSCREEN       76
00350 #endif
00351 #ifndef SM_YVIRTUALSCREEN
00352 #define SM_YVIRTUALSCREEN       77
00353 #endif
00354 #ifndef SM_CXVIRTUALSCREEN
00355 #define SM_CXVIRTUALSCREEN      78
00356 #endif
00357 #ifndef SM_CYVIRTUALSCREEN
00358 #define SM_CYVIRTUALSCREEN      79
00359 #endif
00360 #ifndef SM_CMONITORS
00361 #define SM_CMONITORS            80
00362 #endif
00363 #ifndef SM_SAMEDISPLAYFORMAT
00364 #define SM_SAMEDISPLAYFORMAT    81
00365 #endif
00366 
00367 // Missing in CYGWIN
00368 #ifndef IMAGE_SUBSYSTEM_NATIVE_WINDOWS
00369 #define IMAGE_SUBSYSTEM_NATIVE_WINDOWS 8
00370 #endif
00371 #ifndef IMAGE_SUBSYSTEM_WINDOWS_CE_GUI
00372 #define IMAGE_SUBSYSTEM_WINDOWS_CE_GUI 9
00373 #endif
00374 #endif
00375 
00376 
00377 // IBM VisualAge for C++ 3.5
00378 #if defined(__IBMCPP__) && defined(WIN32)
00379 #include <direct.h>
00380 #include <io.h>         // for _access()
00381 #define _mkdir(x) mkdir((char *)(x))
00382 #define _vsnprintf(a, b, c, d) vsprintf(a, c, d)
00383 #define ICON_SMALL      0
00384 #define ICON_BIG        1
00385 #define bool            int
00386 
00387 // This declarations come from Microsoft SDK
00388 #define TME_HOVER       0x00000001
00389 #define TME_LEAVE       0x00000002
00390 #define TME_QUERY       0x40000000
00391 #define TME_CANCEL      0x80000000
00392 #define HOVER_DEFAULT   0xFFFFFFFF
00393 #define WM_MOUSEHOVER   0x02A1
00394 #define WM_MOUSELEAVE   0x02A3
00395 
00396 typedef struct tagTRACKMOUSEEVENT {
00397     DWORD cbSize;
00398     DWORD dwFlags;
00399     HWND  hwndTrack;
00400     DWORD dwHoverTime;
00401 } TRACKMOUSEEVENT, *LPTRACKMOUSEEVENT;
00402 
00403 WINUSERAPI
00404 BOOL
00405 WINAPI
00406 TrackMouseEvent(
00407     IN OUT LPTRACKMOUSEEVENT lpEventTrack);
00408 
00409 #ifdef __GL_H__
00410 #define GL_COLOR_LOGIC_OP                 0x0BF2
00411 #define GL_POLYGON_OFFSET_POINT           0x2A01
00412 #define GL_POLYGON_OFFSET_LINE            0x2A02
00413 WINGDIAPI void APIENTRY glPolygonOffset (GLfloat factor,GLfloat units);
00414 #endif
00415 
00416 #endif
00417 
00418 #endif

(C) 2002-2009 Niall Douglas. Some parts (C) to assorted authors.
Generated on Fri Nov 20 18:31:26 2009 for TnFOX by doxygen v1.4.7