]> www.wagner.pp.ru Git - oss/ck.git/blob - ckPort.h
Ck console graphics toolkit
[oss/ck.git] / ckPort.h
1 /*
2  * ckPort.h --
3  *
4  *      This file is included by all of the curses wish C files.
5  *      It contains information that may be configuration-dependent,
6  *      such as #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 Sun Microsystems, Inc.
10  * Copyright (c) 1995 Christian Werner
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  */
16
17 #ifndef _CKPORT
18 #define _CKPORT
19
20 #if defined(_WIN32) || defined(WIN32)
21 #   include <windows.h>
22 #endif
23
24 /*
25  * Macro to use instead of "void" for arguments that must have
26  * type "void *" in ANSI C;  maps them to type "char *" in
27  * non-ANSI systems.  This macro may be used in some of the include
28  * files below, which is why it is defined here.
29  */
30
31 #ifndef VOID
32 #   ifdef __STDC__
33 #       define VOID void
34 #   else
35 #       define VOID char
36 #   endif
37 #endif
38
39 #include <stdio.h>
40 #include <ctype.h>
41 #include <fcntl.h>
42 #include <errno.h>
43 #include <signal.h>
44 #if defined(_WIN32) || defined(WIN32)
45 #   include <limits.h>
46 #else
47 #   ifdef HAVE_LIMITS_H
48 #      include <limits.h>
49 #   else
50 #      include "compat/limits.h"
51 #   endif
52 #endif
53 #include <math.h>
54 #if !defined(_WIN32) && !defined(WIN32)
55 #   include <pwd.h>
56 #endif
57 #ifdef NO_STDLIB_H
58 #   include "compat/stdlib.h"
59 #else
60 #   include <stdlib.h>
61 #endif
62 #include <string.h>
63 #include <sys/types.h>
64 #if !defined(_WIN32) && !defined(WIN32)
65 #   include <sys/file.h>
66 #endif
67 #ifdef HAVE_SYS_SELECT_H
68 #   include <sys/select.h>
69 #endif
70 #include <sys/stat.h>
71 #if !defined(_WIN32) && !defined(WIN32)
72 #   include <sys/time.h>
73 #endif
74 #ifndef _TCL
75 #   include <tcl.h>
76 #endif
77 #if !defined(_WIN32) && !defined(WIN32)
78 #   ifdef HAVE_UNISTD_H
79 #      include <unistd.h>
80 #   else
81 #      include "compat/unistd.h"
82 #   endif
83 #endif
84
85 #if (TCL_MAJOR_VERSION < 7)
86 #error Tcl major version must be 7 or greater
87 #endif
88
89 /*
90  * Not all systems declare the errno variable in errno.h. so this
91  * file does it explicitly.
92  */
93
94 #if !defined(_WIN32) && !defined(WIN32)
95 extern int errno;
96 #endif
97
98 #if (TCL_MAJOR_VERSION == 7) && (TCL_MINOR_VERSION <= 4)
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  * Define "NBBY" (number of bits per byte) if it's not already defined.
120  */
121
122 #ifndef NBBY
123 #   define NBBY 8
124 #endif
125
126 /*
127  * The following macro defines the number of fd_masks in an fd_set:
128  */
129
130 #ifndef FD_SETSIZE
131 #   ifdef OPEN_MAX
132 #       define FD_SETSIZE OPEN_MAX
133 #   else
134 #       define FD_SETSIZE 256
135 #   endif
136 #endif
137 #if !defined(howmany)
138 #   define howmany(x, y) (((x)+((y)-1))/(y))
139 #endif
140 #ifndef NFDBITS
141 #   define NFDBITS NBBY*sizeof(fd_mask)
142 #endif
143 #define MASK_SIZE howmany(FD_SETSIZE, NFDBITS)
144
145 /*
146  * The following macro checks to see whether there is buffered
147  * input data available for a stdio FILE.  This has to be done
148  * in different ways on different systems.  TK_FILE_GPTR and
149  * TK_FILE_COUNT are #defined by autoconf.
150  */
151
152 #ifdef TK_FILE_COUNT
153 #   define TK_READ_DATA_PENDING(f) ((f)->TK_FILE_COUNT > 0)
154 #else
155 #   ifdef TK_FILE_GPTR
156 #       define TK_READ_DATA_PENDING(f) ((f)->_gptr < (f)->_egptr)
157 #   else
158 #       ifdef TK_FILE_READ_PTR
159 #           define TK_READ_DATA_PENDING(f) ((f)->_IO_read_ptr != (f)->_IO_read_end)
160 #       else
161             /*
162              * Don't know what to do for this system; whoever installs
163              * Tk will have to write a function TkReadDataPending to do
164              * the job.
165              */
166             EXTERN int TkReadDataPending _ANSI_ARGS_((FILE *f));
167 #           define TK_READ_DATA_PENDING(f) TkReadDataPending(f)
168 #       endif
169 #   endif
170 #endif
171
172 /*
173  * Substitute Tcl's own versions for several system calls.  The
174  * Tcl versions retry automatically if interrupted by signals.
175  */
176
177 #define open(a,b,c) TclOpen(a,b,c)
178 #define read(a,b,c) TclRead(a,b,c)
179 #define waitpid(a,b,c) TclWaitpid(a,b,c)
180 #define write(a,b,c) TclWrite(a,b,c)
181 EXTERN int      TclOpen _ANSI_ARGS_((char *path, int oflag, mode_t mode));
182 EXTERN int      TclRead _ANSI_ARGS_((int fd, VOID *buf,
183                     unsigned int numBytes));
184 EXTERN int      TclWaitpid _ANSI_ARGS_((pid_t pid, int *statPtr, int options));
185 EXTERN int      TclWrite _ANSI_ARGS_((int fd, VOID *buf,
186                     unsigned int numBytes));
187
188 /*
189  * If this system has a BSDgettimeofday function (e.g. IRIX) use it
190  * instead of gettimeofday; the gettimeofday function has a different
191  * interface than the BSD one that this code expects.
192  */
193
194 #ifdef HAVE_BSDGETTIMEOFDAY
195 #   define gettimeofday BSDgettimeofday
196 #endif
197 #ifdef GETTOD_NOT_DECLARED
198 EXTERN int              gettimeofday _ANSI_ARGS_((struct timeval *tp,
199                             struct timezone *tzp));
200 #endif
201
202 #else
203
204 /*
205  * Provide some defines to get some Tk functionality which was in
206  * tkEvent.c prior to Tcl version 7.5.
207  */
208
209 #define Tk_BackgroundError Tcl_BackgroundError
210 #define Tk_DoWhenIdle Tcl_DoWhenIdle
211 #define Tk_DoWhenIdle2 Tcl_DoWhenIdle
212 #define Tk_CancelIdleCall Tcl_CancelIdleCall
213 #define Tk_CreateTimerHandler Tcl_CreateTimerHandler
214 #define Tk_DeleteTimerHandler Tcl_DeleteTimerHandler
215 #define Tk_AfterCmd Tcl_AfterCmd
216 #define Tk_FileeventCmd Tcl_FileEventCmd
217 #define Tk_DoOneEvent Tcl_DoOneEvent
218
219 #endif
220
221 /*
222  * Declarations for various library procedures that may not be declared
223  * in any other header file.
224  */
225
226 #ifndef panic
227 extern void             panic();
228 #endif
229
230  /* Return type for signal(), this taken from TclX.
231  */
232
233 #ifndef RETSIGTYPE
234 #   define RETSIGTYPE void
235 #endif
236
237 typedef RETSIGTYPE (*Ck_SignalProc) _ANSI_ARGS_((int));
238
239
240 #endif /* _CKPORT */