tkUnixPort.h 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  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. #ifndef _UNIXPORT
  15. #define _UNIXPORT
  16. #define __UNIX__ 1
  17. #include <stdio.h>
  18. #include <pwd.h>
  19. #include <assert.h>
  20. #include <errno.h>
  21. #include <fcntl.h>
  22. #include <ctype.h>
  23. #include <math.h>
  24. #include <string.h>
  25. #include <limits.h>
  26. #ifdef NO_STDLIB_H
  27. # include "../compat/stdlib.h"
  28. #else
  29. # include <stdlib.h>
  30. #endif
  31. #include <sys/types.h>
  32. #include <sys/file.h>
  33. #ifdef HAVE_SYS_SELECT_H
  34. # include <sys/select.h>
  35. #endif
  36. #include <sys/stat.h>
  37. #ifndef _TCL
  38. # include <tcl.h>
  39. #endif
  40. #if TIME_WITH_SYS_TIME
  41. # include <sys/time.h>
  42. # include <time.h>
  43. #else
  44. # if HAVE_SYS_TIME_H
  45. # include <sys/time.h>
  46. # else
  47. # include <time.h>
  48. # endif
  49. #endif
  50. #if HAVE_INTTYPES_H
  51. # include <inttypes.h>
  52. #endif
  53. #ifndef NO_UNISTD_H
  54. # include <unistd.h>
  55. #else
  56. # include "../compat/unistd.h"
  57. #endif
  58. #if defined(__GNUC__) && !defined(__cplusplus)
  59. # pragma GCC diagnostic ignored "-Wc++-compat"
  60. #endif
  61. #include <X11/Xlib.h>
  62. #include <X11/cursorfont.h>
  63. #include <X11/keysym.h>
  64. #include <X11/Xatom.h>
  65. #include <X11/Xproto.h>
  66. #include <X11/Xresource.h>
  67. #include <X11/Xutil.h>
  68. /*
  69. * The following macro defines the type of the mask arguments to
  70. * select:
  71. */
  72. #ifndef NO_FD_SET
  73. # define SELECT_MASK fd_set
  74. #else
  75. # ifndef _AIX
  76. typedef long fd_mask;
  77. # endif
  78. # if defined(_IBMR2)
  79. # define SELECT_MASK void
  80. # else
  81. # define SELECT_MASK int
  82. # endif
  83. #endif
  84. /*
  85. * The following macro defines the number of fd_masks in an fd_set:
  86. */
  87. #ifndef FD_SETSIZE
  88. # ifdef OPEN_MAX
  89. # define FD_SETSIZE OPEN_MAX
  90. # else
  91. # define FD_SETSIZE 256
  92. # endif
  93. #endif
  94. #if !defined(howmany)
  95. # define howmany(x, y) (((x)+((y)-1))/(y))
  96. #endif
  97. #ifndef NFDBITS
  98. # define NFDBITS NBBY*sizeof(fd_mask)
  99. #endif
  100. #define MASK_SIZE howmany(FD_SETSIZE, NFDBITS)
  101. /*
  102. * Define "NBBY" (number of bits per byte) if it's not already defined.
  103. */
  104. #ifndef NBBY
  105. # define NBBY 8
  106. #endif
  107. #ifdef __CYGWIN__
  108. # include "tkIntXlibDecls.h"
  109. # define UINT unsigned int
  110. # define HWND void *
  111. # define HDC void *
  112. # define HINSTANCE void *
  113. # define COLORREF void *
  114. # define HMENU void *
  115. # define TkWinDCState void
  116. # define HPALETTE void *
  117. # define WNDPROC void *
  118. # define WPARAM void *
  119. # define LPARAM void *
  120. # define LRESULT void *
  121. #else /* !__CYGWIN__ */
  122. /*
  123. * The TkPutImage macro strips off the color table information, which isn't
  124. * needed for X.
  125. */
  126. # define TkPutImage(colors, ncolors, display, pixels, gc, image, srcx, srcy, destx, desty, width, height) \
  127. XPutImage(display, pixels, gc, image, srcx, srcy, destx, \
  128. desty, width, height);
  129. #endif /* !__CYGWIN__ */
  130. /*
  131. * Supply macros for seek offsets, if they're not already provided by
  132. * an include file.
  133. */
  134. #ifndef SEEK_SET
  135. # define SEEK_SET 0
  136. #endif
  137. #ifndef SEEK_CUR
  138. # define SEEK_CUR 1
  139. #endif
  140. #ifndef SEEK_END
  141. # define SEEK_END 2
  142. #endif
  143. /*
  144. * Declarations for various library procedures that may not be declared
  145. * in any other header file.
  146. */
  147. /*
  148. * These functions do nothing under Unix, so we just eliminate calls to them.
  149. */
  150. #define TkpButtonSetDefaults() {}
  151. #define TkpDestroyButton(butPtr) {}
  152. #define TkSelUpdateClipboard(a,b) {}
  153. #ifndef __CYGWIN__
  154. #define TkSetPixmapColormap(p,c) {}
  155. #endif
  156. /*
  157. * These calls implement native bitmaps which are not supported under
  158. * UNIX. The macros eliminate the calls.
  159. */
  160. #define TkpDefineNativeBitmaps()
  161. #define TkpCreateNativeBitmap(display, source) None
  162. #define TkpGetNativeAppBitmap(display, name, w, h) None
  163. /*
  164. * This macro stores a representation of the window handle in a string.
  165. * This should perhaps use the real size of an XID.
  166. */
  167. #ifndef __CYGWIN__
  168. #define TkpPrintWindowId(buf,w) \
  169. sprintf((buf), "0x%08lx", (unsigned long) (w))
  170. #endif
  171. /*
  172. * Used by tkWindow.c
  173. */
  174. #define TkpHandleMapOrUnmap(tkwin, event) Tk_HandleEvent(event)
  175. #endif /* _UNIXPORT */