1 /* 2 * tkUnixPort.h -- 3 * 4 * This file is included by all of the Tk C files. It contains 5 * information that may be configuration-dependent, such as 6 * #includes for system include files and a few other things. 7 * 8 * Copyright (c) 1991-1993 The Regents of the University of California. 9 * Copyright (c) 1994-1996 Sun Microsystems, Inc. 10 * 11 * See the file "license.terms" for information on usage and redistribution 12 * of this file, and for a DISCLAIMER OF ALL WARRANTIES. 13 * 14 * RCS: @(#) Id 15 */ 16 17 #ifndef _UNIXPORT 18 #define _UNIXPORT 19 20 #define __UNIX__ 1 21 22 /* 23 * Macro to use instead of "void" for arguments that must have 24 * type "void *" in ANSI C; maps them to type "char *" in 25 * non-ANSI systems. This macro may be used in some of the include 26 * files below, which is why it is defined here. 27 */ 28 29 #ifndef VOID 30 # ifdef __STDC__ 31 # define VOID void 32 # else 33 # define VOID char 34 # endif 35 #endif 36 37 #include <stdio.h> 38 #include <ctype.h> 39 #include <fcntl.h> 40 #ifndef NO_LIMITS_H 41 # include <limits.h> 42 #else 43 # include "../compat/limits.h" 44 #endif 45 #include <math.h> 46 #include <pwd.h> 47 #ifdef NO_STDLIB_H 48 # include "../compat/stdlib.h" 49 #else 50 # include <stdlib.h> 51 #endif 52 #include <string.h> 53 #include <sys/types.h> 54 #include <sys/file.h> 55 #ifdef HAVE_SYS_SELECT_H 56 # include <sys/select.h> 57 #endif 58 #include <sys/stat.h> 59 #ifndef _TCL 60 # include <tcl.h> 61 #endif 62 #if TIME_WITH_SYS_TIME 63 # include <sys/time.h> 64 # include <time.h> 65 #else 66 # if HAVE_SYS_TIME_H 67 # include <sys/time.h> 68 # else 69 # include <time.h> 70 # endif 71 #endif 72 #if HAVE_INTTYPES_H 73 # include <inttypes.h> 74 #endif 75 #ifndef NO_UNISTD_H 76 # include <unistd.h> 77 #else 78 # include "../compat/unistd.h" 79 #endif 80 #include <X11/Xlib.h> 81 #include <X11/cursorfont.h> 82 #include <X11/keysym.h> 83 #include <X11/Xatom.h> 84 #include <X11/Xproto.h> 85 #include <X11/Xresource.h> 86 #include <X11/Xutil.h> 87 88 /* 89 * The following macro defines the type of the mask arguments to 90 * select: 91 */ 92 93 #ifndef NO_FD_SET 94 # define SELECT_MASK fd_set 95 #else 96 # ifndef _AIX 97 typedef long fd_mask; 98 # endif 99 # if defined(_IBMR2) 100 # define SELECT_MASK void 101 # else 102 # define SELECT_MASK int 103 # endif 104 #endif 105 106 /* 107 * The following macro defines the number of fd_masks in an fd_set: 108 */ 109 110 #ifndef FD_SETSIZE 111 # ifdef OPEN_MAX 112 # define FD_SETSIZE OPEN_MAX 113 # else 114 # define FD_SETSIZE 256 115 # endif 116 #endif 117 #if !defined(howmany) 118 # define howmany(x, y) (((x)+((y)-1))/(y)) 119 #endif 120 #ifndef NFDBITS 121 # define NFDBITS NBBY*sizeof(fd_mask) 122 #endif 123 #define MASK_SIZE howmany(FD_SETSIZE, NFDBITS) 124 125 /* 126 * Define "NBBY" (number of bits per byte) if it's not already defined. 127 */ 128 129 #ifndef NBBY 130 # define NBBY 8 131 #endif 132 133 /* 134 * These macros are just wrappers for the equivalent X Region calls. 135 */ 136 137 #define TkClipBox(rgn, rect) XClipBox((Region) rgn, rect) 138 #define TkCreateRegion() (TkRegion) XCreateRegion() 139 #define TkDestroyRegion(rgn) XDestroyRegion((Region) rgn) 140 #define TkIntersectRegion(a, b, r) XIntersectRegion((Region) a, \ 141 (Region) b, (Region) r) 142 #define TkRectInRegion(r, x, y, w, h) XRectInRegion((Region) r, x, y, w, h) 143 #define TkSetRegion(d, gc, rgn) XSetRegion(d, gc, (Region) rgn) 144 #define TkSubtractRegion(a, b, r) XSubtractRegion((Region) a, \ 145 (Region) b, (Region) r) 146 #define TkUnionRectWithRegion(rect, src, ret) XUnionRectWithRegion(rect, \ 147 (Region) src, (Region) ret) 148 149 /* 150 * The TkPutImage macro strips off the color table information, which isn't 151 * needed for X. 152 */ 153 154 #define TkPutImage(colors, ncolors, display, pixels, gc, image, srcx, srcy, destx, desty, width, height) \ 155 XPutImage(display, pixels, gc, image, srcx, srcy, destx, \ 156 desty, width, height); 157 158 /* 159 * Supply macros for seek offsets, if they're not already provided by 160 * an include file. 161 */ 162 163 #ifndef SEEK_SET 164 # define SEEK_SET 0 165 #endif 166 167 #ifndef SEEK_CUR 168 # define SEEK_CUR 1 169 #endif 170 171 #ifndef SEEK_END 172 # define SEEK_END 2 173 #endif 174 175 /* 176 * Declarations for various library procedures that may not be declared 177 * in any other header file. 178 */ 179 180 181 /* 182 * These functions do nothing under Unix, so we just eliminate calls to them. 183 */ 184 185 #define TkpButtonSetDefaults(specPtr) {} 186 #define TkpDestroyButton(butPtr) {} 187 #define TkSelUpdateClipboard(a,b) {} 188 #define TkSetPixmapColormap(p,c) {} 189 190 /* 191 * These calls implement native bitmaps which are not supported under 192 * UNIX. The macros eliminate the calls. 193 */ 194 195 #define TkpDefineNativeBitmaps() 196 #define TkpCreateNativeBitmap(display, source) None 197 #define TkpGetNativeAppBitmap(display, name, w, h) None 198 199 /* 200 * This macro stores a representation of the window handle in a string. 201 * This should perhaps use the real size of an XID. 202 */ 203 204 #define TkpPrintWindowId(buf,w) \ 205 sprintf((buf), "%#08lx", (unsigned long) (w)) 206 207 /* 208 * The following declaration is used to get access to a private Tcl interface 209 * that is needed for portability reasons. 210 * 211 * Disabled for now to determined whether we really still need this. 212 213 #ifndef _TCLINT 214 #include <tclInt.h> 215 #endif 216 */ 217 218 #endif /* _UNIXPORT */ 219