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: tkUnixPort.h,v 1.8.2.2 2006/09/06 22:01:26 hobbs Exp $
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#ifndef NO_UNISTD_H
73#   include <unistd.h>
74#else
75#   include "../compat/unistd.h"
76#endif
77#include <X11/Xlib.h>
78#include <X11/cursorfont.h>
79#include <X11/keysym.h>
80#include <X11/Xatom.h>
81#include <X11/Xproto.h>
82#include <X11/Xresource.h>
83#include <X11/Xutil.h>
84
85/*
86 * The following macro defines the type of the mask arguments to
87 * select:
88 */
89
90#ifndef NO_FD_SET
91#   define SELECT_MASK fd_set
92#else
93#   ifndef _AIX
94	typedef long fd_mask;
95#   endif
96#   if defined(_IBMR2)
97#	define SELECT_MASK void
98#   else
99#	define SELECT_MASK int
100#   endif
101#endif
102
103/*
104 * The following macro defines the number of fd_masks in an fd_set:
105 */
106
107#ifndef FD_SETSIZE
108#   ifdef OPEN_MAX
109#	define FD_SETSIZE OPEN_MAX
110#   else
111#	define FD_SETSIZE 256
112#   endif
113#endif
114#if !defined(howmany)
115#   define howmany(x, y) (((x)+((y)-1))/(y))
116#endif
117#ifndef NFDBITS
118#   define NFDBITS NBBY*sizeof(fd_mask)
119#endif
120#define MASK_SIZE howmany(FD_SETSIZE, NFDBITS)
121
122/*
123 * Define "NBBY" (number of bits per byte) if it's not already defined.
124 */
125
126#ifndef NBBY
127#   define NBBY 8
128#endif
129
130/*
131 * These macros are just wrappers for the equivalent X Region calls.
132 */
133
134#define TkClipBox(rgn, rect) XClipBox((Region) rgn, rect)
135#define TkCreateRegion() (TkRegion) XCreateRegion()
136#define TkDestroyRegion(rgn) XDestroyRegion((Region) rgn)
137#define TkIntersectRegion(a, b, r) XIntersectRegion((Region) a, \
138	(Region) b, (Region) r)
139#define TkRectInRegion(r, x, y, w, h) XRectInRegion((Region) r, x, y, w, h)
140#define TkSetRegion(d, gc, rgn) XSetRegion(d, gc, (Region) rgn)
141#define TkSubtractRegion(a, b, r) XSubtractRegion((Region) a, \
142	(Region) b, (Region) r)
143#define TkUnionRectWithRegion(rect, src, ret) XUnionRectWithRegion(rect, \
144	(Region) src, (Region) ret)
145
146/*
147 * The TkPutImage macro strips off the color table information, which isn't
148 * needed for X.
149 */
150
151#define TkPutImage(colors, ncolors, display, pixels, gc, image, destx, desty, srcx, srcy, width, height) \
152	XPutImage(display, pixels, gc, image, destx, desty, srcx, \
153	srcy, width, height);
154
155/*
156 * Supply macros for seek offsets, if they're not already provided by
157 * an include file.
158 */
159
160#ifndef SEEK_SET
161#   define SEEK_SET 0
162#endif
163
164#ifndef SEEK_CUR
165#   define SEEK_CUR 1
166#endif
167
168#ifndef SEEK_END
169#   define SEEK_END 2
170#endif
171
172/*
173 * Declarations for various library procedures that may not be declared
174 * in any other header file.
175 */
176
177
178/*
179 * These functions do nothing under Unix, so we just eliminate calls to them.
180 */
181
182#define TkpButtonSetDefaults(specPtr) {}
183#define TkpDestroyButton(butPtr) {}
184#define TkSelUpdateClipboard(a,b) {}
185#define TkSetPixmapColormap(p,c) {}
186
187/*
188 * These calls implement native bitmaps which are not supported under
189 * UNIX.  The macros eliminate the calls.
190 */
191
192#define TkpDefineNativeBitmaps()
193#define TkpCreateNativeBitmap(display, source) None
194#define TkpGetNativeAppBitmap(display, name, w, h) None
195
196/*
197 * This macro stores a representation of the window handle in a string.
198 * This should perhaps use the real size of an XID.
199 */
200
201#define TkpPrintWindowId(buf,w) \
202	sprintf((buf), "%#08lx", (unsigned long) (w))
203
204/*
205 * The following declaration is used to get access to a private Tcl interface
206 * that is needed for portability reasons.
207 */
208
209#ifndef _TCLINT
210#include <tclInt.h>
211#endif
212
213#endif /* _UNIXPORT */
214