2
* Motif Tools Library, Version 3.1
5
* Written by David Flanagan.
6
* Copyright (c) 1992-2001 by David Flanagan.
7
* All Rights Reserved. See the file COPYRIGHT for details.
8
* This is open source software. See the file LICENSE for details.
9
* There is no warranty for this software. See NO_WARRANTY for details.
12
* Revision 1.1.1.1 2001/07/18 11:06:03 root
15
* Revision 1.2 2001/06/12 16:25:28 andre
16
* *** empty log message ***
25
* This header will contain whatever #ifdefs and #includes are needed to
26
* make the Xmt library portable on as many platforms as possible
29
#if !defined (XMT_HAS_STRERROR)
30
# if defined (XMT_HAS_SYS_ERRLIST)
31
extern char *sys_errlist[];
32
# define strerror(err) sys_errlist[err]
34
# define strerror(err) "strerror is unsupported"
35
# endif /* XMT_HAS_SYS_ERRLIST */
36
#endif /* !XMT_HAS_STERROR */
39
* Standard X header files
41
#include <X11/Intrinsic.h>
42
#include <X11/StringDefs.h>
45
* If the compiler can't handle prototypes, tell the Motif headers so
47
#if NeedFunctionPrototypes == 0
54
* The standard Motif header file
59
* Specify what version of Xmt this is.
63
#define XmtVersion (XmtVERSION * 1000 + XmtREVISION)
64
#define XmtPatchlevel 0
67
* figure out what version of Xt we're using.
69
#if defined(XtSpecificationRelease)
74
#if defined(XtSpecificationRelease) && XtSpecificationRelease >= 5
81
* There were some useful Xrm functions, etc. added in R5.
82
* Pre-R5, they can be approximated as follows:
85
# define XrmGetDatabase(dpy) ((dpy)->db)
86
# define XrmSetDatabase(dpy, database) ((dpy)->db = (database))
87
# define XtScreenDatabase(screen) XtDatabase(DisplayOfScreen(screen))
88
# define XrmPermStringToQuark(str) XrmStringToQuark(str)
89
# define XPointer caddr_t
93
* The MIT X11R5 implementation defines some useful C++
94
* portability stuff. We redefine it here in case we're using
95
* X11R4 or some other implementation
97
#ifndef _XFUNCPROTOBEGIN
98
# ifdef __cplusplus /* for C++ V2.0 */
99
# define _XFUNCPROTOBEGIN extern "C" {
100
# define _XFUNCPROTOEND }
102
# define _XFUNCPROTOBEGIN
103
# define _XFUNCPROTOEND
104
# endif /* __cplusplus */
105
#endif /* _XFUNCPROTOBEGIN */
108
* const String s; is the same as char * const s; not const char *s;
109
* The latter is really what we want. As a workaround, we define
110
* a new type StringConst which is a const char *.
111
* Note that we can declare: const StringConst s;
113
#if __STDC__ || defined(__cplusplus) || defined(c_plusplus)
114
typedef const char *StringConst;
116
#define _Xconst const
119
typedef char * StringConst;
121
#define _Xconst /* as nothing */
126
* In R4 we get the database of a widget with XtDatabase(); in
127
* R5 we use XtScreenDatabase(). So we define a macro that will
128
* do the right thing for us.
131
#define XmtDatabaseOfWidget(w) (XtDatabase(XtDisplayOfObject(w)))
133
#define XmtDatabaseOfWidget(w) (XtScreenDatabase(XtScreenOfObject(w)))
137
* Standard C and K&R C handle varargs routines slightly differently.
139
#if NeedVarargsPrototypes
141
# define Va_start(a,b) va_start(a,b)
143
# include <varargs.h>
144
# define Va_start(a,b) va_start(a)
148
* In K&R C, function arguments are all made at least as long as an int.
149
* In ANSI-C, using prototypes, it is possible to pass function arguments
150
* in their "narrow" form. This library might be compiled with an ANSI
151
* compiler, but linked with code compiled with K&R, so we have to be
152
* careful not to use narrow arguments in this way, unless we are
153
* explicitly told not to worry about it.
155
* Client code generally doesn't need to worry about being compiled with
156
* mixed compilers, so you shouldn't have to use these. If you do, only
157
* use them in the prototypes for function definitions and declarations,
158
* not as variables or structure fields.
160
#if NeedWidePrototypes /* almost always defined to True */
161
#define XmtWideBoolean int
162
#define XmtWideDimension unsigned int
163
#define XmtWidePosition int
165
#define XmtWideBoolean Boolean
166
#define XmtWideDimension Dimension
167
#define XmtWidePosition Position
171
* if compiling with gcc version 2, there are some cool type-checking and
172
* optimizations things we can do, through gcc extensions to the C grammar.
173
* use -Wformat (or -Wall) to get warnings about bad printf style args.
175
#if defined(__GNUC__) && __GNUC__ >= 2 && !defined(__STRICT_ANSI__)
177
* these first two are superseded in gcc 2.5, and are no longer
178
* used anywhere in Xmt. They remain here in case someone else
179
* started using them, though.
181
#define gcc_const_func const
182
#define gcc_volatile_func volatile
183
#define gcc_printf_func(format_arg_num, first_vararg_num)\
184
__attribute__((format (printf, format_arg_num, first_vararg_num)))
185
#if defined(__GNUC_MINOR__) && __GNUC_MINOR__ >= 5 && !defined(__STRICT_ANSI__)
187
* In gcc 2.5 and later, we can define these to help the compiler optimize.
188
* They are actually used in Xmt, so compiling with gcc 2.5 gives a minor
189
* optimization boost.
191
#define gcc_const_attribute __attribute__((const))
192
#define gcc_volatile_attribute __attribute__((noreturn))
194
/* if not gcc 2.5 or later, these two aren't defined */
195
#define gcc_const_attribute
196
#define gcc_volatile_attribute
199
/* if not gcc 2.0 or later , none of these are defined */
200
#define gcc_const_func
201
#define gcc_volatile_func
202
#define gcc_printf_func(a,b)
203
#define gcc_const_attribute
204
#define gcc_volatile_attribute
208
* In X11R5, Intrinsic.h includes Xosdefs.h which defines the symbols
209
* X_NOT_STDC_ENV and X_NOT_POSIX_ENV for systems without the standard
210
* C and Posix header files. These are useful to know when we can
211
* to include <stdlib.h>, for example, and when we should just declare
212
* the functions we want explicitly.
214
* X_NOT_STDC_ENV means does not have ANSI C header files. Lack of this
215
* symbol does NOT mean that the system has stdarg.h.
217
* X_NOT_POSIX means does not have POSIX header files. Lack of this
218
* symbol does NOT mean that the POSIX environment is the default.
219
* You may still have to define _POSIX_SOURCE to get it.
221
* For X11R4, we just include the contents of the X11R5 file here
222
* See the file COPYRIGHT for the applicable MIT copyright notice.
230
#define X_NOT_STDC_ENV
241
#define X_NOT_STDC_ENV
249
#ifndef ultrix /* assume vanilla BSD */
251
#define X_NOT_STDC_ENV
257
#define X_NOT_STDC_ENV
262
#define X_NOT_STDC_ENV
266
#ifdef SYSV /* (release 3.2) */
268
#define X_NOT_STDC_ENV
275
#define X_NOT_STDC_ENV
281
#define X_NOT_STDC_ENV
284
#endif /* _XOSDEFS_H_ */
288
* In Unix, app-defaults files have the suffix ".ad". In VMS
289
* they have the suffix ".dat". We define a symbolic constant
290
* to take care of this difference and use it in ContextHelp.c
293
#ifndef APPDEFAULTSSUFFIX
295
#define APPDEFAULTSSUFFIX ".ad"
297
#define APPDEFAULTSSUFFIX ".dat"
302
* some special representation types used in the library
305
/* A special type used in a number of places; different from XtRString */
307
#define XmtRBuffer "Buffer"
310
/* Xt doesn't define an XtRDouble */
312
#define XmtRDouble "Double"
316
* This macro is an analog to XtOffsetOf. Instead of returning the
317
* offset of a field in a structure of the specified type, however,
318
* it returns the size of that field. It is particularly useful when
319
* declaring resource lists with XmtRBuffer resources, because we can't
320
* just use sizeof() with fields like "char name[40];"
322
#define XmtSizeOf(type, field) sizeof(((type *)0)->field)
325
* DECWindows can't handle XtRemoveCallback, so we make these patches:
327
#if DECWINDOWS_CALLBACK_HACK
328
#define XtAddCallback _XmtDECAddCallback
329
#define XtRemoveCallback _XmtDECRemoveCallback
330
#if NeedFunctionPrototypes
331
extern void _XmtDECAddCallback(Widget, String, XtCallbackProc, XtPointer);
332
extern void _XmtDECRemoveCallback(Widget, String, XtCallbackProc, XtPointer);
334
extern void _XmtDECAddCallback();
335
extern void _XmtDECRemoveCallback();
340
* Here is some portability stuff for Motif 1.1
342
#if XmVersion == 1001
343
#define XmGetPixmapByDepth(s,i,f,b,d) XmGetPixmap(s,i,f,b)
347
* Some systems (e.g. SunOS 4.1.3_U1) still don't have memmove()
351
#define memmove(a,b,n) bcopy(b,a,n)
355
* Some common Xmt functions
357
#include <Xmt/Util.h>