Commit | Line | Data |
---|---|---|
86530b38 AT |
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 | * Copyright (c) 1998 by Scriptics Corporation. | |
11 | * | |
12 | * See the file "license.terms" for information on usage and redistribution | |
13 | * of this file, and for a DISCLAIMER OF ALL WARRANTIES. | |
14 | * | |
15 | * RCS: @(#) $Id: tkUnixPort.h,v 1.3 1998/09/30 19:01:22 rjohnson Exp $ | |
16 | */ | |
17 | ||
18 | #ifndef _UNIXPORT | |
19 | #define _UNIXPORT | |
20 | ||
21 | #define __UNIX__ 1 | |
22 | ||
23 | /* | |
24 | * Macro to use instead of "void" for arguments that must have | |
25 | * type "void *" in ANSI C; maps them to type "char *" in | |
26 | * non-ANSI systems. This macro may be used in some of the include | |
27 | * files below, which is why it is defined here. | |
28 | */ | |
29 | ||
30 | #ifndef VOID | |
31 | # ifdef __STDC__ | |
32 | # define VOID void | |
33 | # else | |
34 | # define VOID char | |
35 | # endif | |
36 | #endif | |
37 | ||
38 | #include <ctype.h> | |
39 | #include <fcntl.h> | |
40 | #ifdef HAVE_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 | #ifdef HAVE_SYS_TIME_H | |
60 | #include <sys/time.h> | |
61 | #endif | |
62 | #ifndef _LANG | |
63 | # include "Lang.h" | |
64 | #endif | |
65 | #if 0 /* Used in tk8 merge */ | |
66 | #if TIME_WITH_SYS_TIME | |
67 | # include <sys/time.h> | |
68 | # include <time.h> | |
69 | #else | |
70 | # if HAVE_SYS_TIME_H | |
71 | # include <sys/time.h> | |
72 | # else | |
73 | # include <time.h> | |
74 | # endif | |
75 | #endif | |
76 | #endif | |
77 | #if TIME_WITH_SYS_TIME | |
78 | # include <sys/time.h> | |
79 | # include <time.h> | |
80 | #else | |
81 | # if HAVE_SYS_TIME_H | |
82 | # include <sys/time.h> | |
83 | # else | |
84 | # include <time.h> | |
85 | # endif | |
86 | #endif | |
87 | #ifdef HAVE_UNISTD_H | |
88 | # include <unistd.h> | |
89 | #else | |
90 | # include "compat/unistd.h" | |
91 | #endif | |
92 | #include <X11/Xlib.h> | |
93 | #include <X11/cursorfont.h> | |
94 | #include <X11/keysym.h> | |
95 | #include <X11/Xatom.h> | |
96 | #include <X11/Xproto.h> | |
97 | #include <X11/Xresource.h> | |
98 | #include <X11/Xutil.h> | |
99 | ||
100 | /* | |
101 | * The following macro defines the type of the mask arguments to | |
102 | * select: | |
103 | */ | |
104 | ||
105 | #ifndef NO_FD_SET | |
106 | # define SELECT_MASK fd_set | |
107 | #else | |
108 | # ifndef _AIX | |
109 | typedef long fd_mask; | |
110 | # endif | |
111 | # if defined(_IBMR2) | |
112 | # define SELECT_MASK void | |
113 | # else | |
114 | # define SELECT_MASK int | |
115 | # endif | |
116 | #endif | |
117 | ||
118 | /* | |
119 | * The following macro defines the number of fd_masks in an fd_set: | |
120 | */ | |
121 | ||
122 | #ifndef FD_SETSIZE | |
123 | # ifdef OPEN_MAX | |
124 | # define FD_SETSIZE OPEN_MAX | |
125 | # else | |
126 | # define FD_SETSIZE 256 | |
127 | # endif | |
128 | #endif | |
129 | #if !defined(howmany) | |
130 | # define howmany(x, y) (((x)+((y)-1))/(y)) | |
131 | #endif | |
132 | #ifndef NFDBITS | |
133 | # define NFDBITS NBBY*sizeof(fd_mask) | |
134 | #endif | |
135 | #define MASK_SIZE howmany(FD_SETSIZE, NFDBITS) | |
136 | ||
137 | /* | |
138 | * Not all systems declare the errno variable in errno.h. so this | |
139 | * file does it explicitly. | |
140 | */ | |
141 | ||
142 | extern int errno; | |
143 | ||
144 | /* | |
145 | * Define "NBBY" (number of bits per byte) if it's not already defined. | |
146 | */ | |
147 | ||
148 | #ifndef NBBY | |
149 | # define NBBY 8 | |
150 | #endif | |
151 | ||
152 | /* | |
153 | * These macros are just wrappers for the equivalent X Region calls. | |
154 | */ | |
155 | ||
156 | #define TkClipBox(rgn, rect) XClipBox((Region) rgn, rect) | |
157 | #define TkCreateRegion() (TkRegion) XCreateRegion() | |
158 | #define TkDestroyRegion(rgn) XDestroyRegion((Region) rgn) | |
159 | #define TkIntersectRegion(a, b, r) XIntersectRegion((Region) a, \ | |
160 | (Region) b, (Region) r) | |
161 | /* #define TkRectInRegion(r, x, y, w, h) XRectInRegion((Region) r, x, y, w, h) */ | |
162 | #define TkSetRegion(d, gc, rgn) XSetRegion(d, gc, (Region) rgn) | |
163 | #define TkUnionRectWithRegion(rect, src, ret) XUnionRectWithRegion(rect, \ | |
164 | (Region) src, (Region) ret) | |
165 | ||
166 | /* | |
167 | * The TkPutImage macro strips off the color table information, which isn't | |
168 | * needed for X. | |
169 | */ | |
170 | ||
171 | #define TkPutImage(colors, ncolors, display, pixels, gc, image, destx, desty, srcx, srcy, width, height) \ | |
172 | XPutImage(display, pixels, gc, image, destx, desty, srcx, \ | |
173 | srcy, width, height); | |
174 | ||
175 | /* | |
176 | * Supply macros for seek offsets, if they're not already provided by | |
177 | * an include file. | |
178 | */ | |
179 | ||
180 | #ifndef SEEK_SET | |
181 | # define SEEK_SET 0 | |
182 | #endif | |
183 | ||
184 | #ifndef SEEK_CUR | |
185 | # define SEEK_CUR 1 | |
186 | #endif | |
187 | ||
188 | #ifndef SEEK_END | |
189 | # define SEEK_END 2 | |
190 | #endif | |
191 | ||
192 | /* | |
193 | * Declarations for various library procedures that may not be declared | |
194 | * in any other header file. | |
195 | */ | |
196 | ||
197 | #ifndef _LANG | |
198 | extern void panic _ANSI_ARGS_(TCL_VARARGS(char *, string)); | |
199 | #endif | |
200 | ||
201 | /* | |
202 | * These functions do nothing under Unix, so we just eliminate calls to them. | |
203 | */ | |
204 | ||
205 | #define TkpDestroyButton(butPtr) {} | |
206 | #define TkSelUpdateClipboard(a,b) {} | |
207 | #define TkSetPixmapColormap(p,c) {} | |
208 | ||
209 | /* | |
210 | * These calls implement native bitmaps which are not supported under | |
211 | * UNIX. The macros eliminate the calls. | |
212 | */ | |
213 | ||
214 | #define TkpDefineNativeBitmaps() | |
215 | #define TkpCreateNativeBitmap(display, source) None | |
216 | #define TkpGetNativeAppBitmap(display, name, w, h) None | |
217 | ||
218 | /* | |
219 | * This macro stores a representation of the window handle in a string. | |
220 | */ | |
221 | ||
222 | #define TkpPrintWindowId(buf,w) \ | |
223 | sprintf((buf), "0x%x", (unsigned int) (w)) | |
224 | ||
225 | /* | |
226 | * TkpScanWindowId is just an alias for Tcl_GetInt on Unix. | |
227 | */ | |
228 | ||
229 | #define TkpScanWindowId(i,s,wp) \ | |
230 | Tcl_GetInt((i),(s),(wp)) | |
231 | ||
232 | /* | |
233 | * This macro indicates that entry and text widgets should display | |
234 | * the selection highlight regardless of which window has the focus. | |
235 | */ | |
236 | ||
237 | #define ALWAYS_SHOW_SELECTION | |
238 | ||
239 | /* | |
240 | * The following declaration is used to get access to a private Tcl interface | |
241 | * that is needed for portability reasons. | |
242 | */ | |
243 | ||
244 | #ifndef TclpGetTime | |
245 | EXTERN void TclpGetTime _ANSI_ARGS_((Tcl_Time *time)); | |
246 | #endif | |
247 | ||
248 | #endif /* _UNIXPORT */ |