File: Xmt.h

package info (click to toggle)
gridengine 6.2-4
  • links: PTS, VCS
  • area: main
  • in suites: lenny
  • size: 51,532 kB
  • ctags: 51,172
  • sloc: ansic: 418,155; java: 37,080; sh: 22,593; jsp: 7,699; makefile: 5,292; csh: 4,244; xml: 2,901; cpp: 2,086; perl: 1,895; tcl: 1,188; lisp: 669; ruby: 642; yacc: 393; lex: 266
file content (359 lines) | stat: -rw-r--r-- 9,300 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
/* 
 * Motif Tools Library, Version 3.1
 * $Id$
 * 
 * Written by David Flanagan.
 * Copyright (c) 1992-2001 by David Flanagan.
 * All Rights Reserved.  See the file COPYRIGHT for details.
 * This is open source software.  See the file LICENSE for details.
 * There is no warranty for this software.  See NO_WARRANTY for details.
 *
 * $Log$
 * Revision 1.1.1.1  2001/07/18 11:06:03  root
 * Initial checkin.
 *
 * Revision 1.2  2001/06/12 16:25:28  andre
 * *** empty log message ***
 *
 *
 */

#ifndef _Xmt_h
#define _Xmt_h

/*
 * This header will contain whatever #ifdefs and #includes are needed to
 * make the Xmt library portable on as many platforms as possible
 */

#if !defined (XMT_HAS_STRERROR)
# if defined (XMT_HAS_SYS_ERRLIST)
extern char *sys_errlist[];
#   define strerror(err) sys_errlist[err]
# else
#   define strerror(err) "strerror is unsupported"
# endif /* XMT_HAS_SYS_ERRLIST */
#endif /* !XMT_HAS_STERROR */

/*
 * Standard X header files
 */
#include <X11/Intrinsic.h>
#include <X11/StringDefs.h>

/*
 * If the compiler can't handle prototypes, tell the Motif headers so
 */
#if NeedFunctionPrototypes == 0
#ifndef _NO_PROTO
#define _NO_PROTO
#endif
#endif

/*
 * The standard Motif header file
 */
#include <Xm/Xm.h>

/*
 * Specify what version of Xmt this is.
 */
#define XmtVERSION      3
#define XmtREVISION     1
#define XmtVersion      (XmtVERSION * 1000 + XmtREVISION)
#define XmtPatchlevel   0

/*
 * figure out what version of Xt we're using.
 */
#if defined(XtSpecificationRelease)
#  define X11R4
#else
#  undef X11R4
#endif
#if defined(XtSpecificationRelease) && XtSpecificationRelease >= 5
#  define X11R5
#else
#  undef X11R5
#endif

/* 
 * There were some useful Xrm functions, etc. added in R5.
 * Pre-R5, they can be approximated as follows:
 */
#ifndef X11R5
#  define XrmGetDatabase(dpy) ((dpy)->db)
#  define XrmSetDatabase(dpy, database) ((dpy)->db = (database))
#  define XtScreenDatabase(screen) XtDatabase(DisplayOfScreen(screen))
#  define XrmPermStringToQuark(str) XrmStringToQuark(str)
#  define XPointer caddr_t
#endif

/*
 * The MIT X11R5 implementation defines some useful C++
 * portability stuff.  We redefine it here in case we're using
 * X11R4 or some other implementation
 */
#ifndef _XFUNCPROTOBEGIN
#  ifdef __cplusplus	       	/* for C++ V2.0 */
#    define _XFUNCPROTOBEGIN extern "C" {
#    define _XFUNCPROTOEND }
#  else
#    define _XFUNCPROTOBEGIN
#    define _XFUNCPROTOEND
#  endif /* __cplusplus */
#endif /* _XFUNCPROTOBEGIN */

/*
 * const String s; is the same as char * const s; not const char *s;
 * The latter is really what we want.  As a workaround, we define
 * a new type StringConst which is a const char *.
 * Note that we can declare: const StringConst s;
 */
#if __STDC__ || defined(__cplusplus) || defined(c_plusplus)
typedef const char *StringConst;
#ifndef _Xconst
#define _Xconst const
#endif
#else
typedef char * StringConst;
#ifndef _Xconst
#define _Xconst /* as nothing */
#endif
#endif

/*
 * In R4 we get the database of a widget with XtDatabase(); in
 * R5 we use XtScreenDatabase().  So we define a macro that will
 * do the right thing for us.
 */
#ifndef X11R5
#define XmtDatabaseOfWidget(w) (XtDatabase(XtDisplayOfObject(w)))
#else
#define XmtDatabaseOfWidget(w) (XtScreenDatabase(XtScreenOfObject(w)))
#endif

/*
 * Standard C and K&R C handle varargs routines slightly differently.
 */
#if NeedVarargsPrototypes
# include <stdarg.h>
# define Va_start(a,b) va_start(a,b)
#else
# include <varargs.h>
# define Va_start(a,b) va_start(a)
#endif

/*
 * In K&R C, function arguments are all made at least as long as an int.
 * In ANSI-C, using prototypes, it is possible to pass function arguments
 * in their "narrow" form.  This library might be compiled with an ANSI
 * compiler, but linked with code compiled with K&R, so we have to be
 * careful not to use narrow arguments in this way, unless we are
 * explicitly told not to worry about it.
 *
 * Client code generally doesn't need to worry about being compiled with
 * mixed compilers, so you shouldn't have to use these.  If you do, only
 * use them in the prototypes for function definitions and declarations,
 * not as variables or structure fields.
 */
#if NeedWidePrototypes /* almost always defined to True */
#define XmtWideBoolean int
#define XmtWideDimension unsigned int
#define XmtWidePosition int
#else
#define XmtWideBoolean Boolean
#define XmtWideDimension Dimension
#define XmtWidePosition Position
#endif

/*
 * if compiling with gcc version 2, there are some cool type-checking and
 * optimizations things we can do, through gcc extensions to the C grammar.
 * use -Wformat (or -Wall) to get warnings about bad printf style args.
 */
#if defined(__GNUC__) && __GNUC__ >= 2 && !defined(__STRICT_ANSI__)
/*
 * these first two are superseded in gcc 2.5, and are no longer
 * used anywhere in Xmt.  They remain here in case someone else
 * started using them, though.
 */
#define gcc_const_func const
#define gcc_volatile_func volatile
#define gcc_printf_func(format_arg_num, first_vararg_num)\
   __attribute__((format (printf, format_arg_num, first_vararg_num)))
#if defined(__GNUC_MINOR__) && __GNUC_MINOR__ >= 5 && !defined(__STRICT_ANSI__)
/*
 * In gcc 2.5 and later, we can define these to help the compiler optimize.
 * They are actually used in Xmt, so compiling with gcc 2.5 gives a minor
 * optimization boost.
 */
#define gcc_const_attribute __attribute__((const))
#define gcc_volatile_attribute __attribute__((noreturn))
#else
/* if not gcc 2.5 or later, these two aren't defined */
#define gcc_const_attribute
#define gcc_volatile_attribute
#endif
#else
/* if not gcc 2.0 or later , none of these are defined */
#define gcc_const_func
#define gcc_volatile_func
#define gcc_printf_func(a,b)
#define gcc_const_attribute
#define gcc_volatile_attribute
#endif

/*
 * In X11R5, Intrinsic.h includes Xosdefs.h which defines the symbols
 * X_NOT_STDC_ENV and X_NOT_POSIX_ENV for systems without the standard
 * C and Posix header files.  These are useful to know when we can
 * to include <stdlib.h>, for example, and when we should just declare
 * the functions we want explicitly.
 *
 * X_NOT_STDC_ENV means does not have ANSI C header files.  Lack of this
 * symbol does NOT mean that the system has stdarg.h.
 *
 * X_NOT_POSIX means does not have POSIX header files.  Lack of this
 * symbol does NOT mean that the POSIX environment is the default.
 * You may still have to define _POSIX_SOURCE to get it.
 *
 * For X11R4, we just include the contents of the X11R5 file here
 * See the file COPYRIGHT for the applicable MIT copyright notice.
 */
#ifndef X11R5
#ifndef _XOSDEFS_H_
#define _XOSDEFS_H_

#ifdef NOSTDHDRS
#define X_NOT_POSIX
#define X_NOT_STDC_ENV
#endif

#ifdef sony
#ifndef SYSTYPE_SYSV
#define X_NOT_POSIX
#endif
#endif

#ifdef UTEK
#define X_NOT_POSIX
#define X_NOT_STDC_ENV
#endif

#ifdef CRAY
#define X_NOT_POSIX
#endif

#ifdef vax
#ifndef ultrix			/* assume vanilla BSD */
#define X_NOT_POSIX
#define X_NOT_STDC_ENV
#endif
#endif

#ifdef luna
#define X_NOT_POSIX
#define X_NOT_STDC_ENV
#endif

#ifdef Mips
#define X_NOT_POSIX
#define X_NOT_STDC_ENV
#endif
  
#ifdef USL
#ifdef SYSV /* (release 3.2) */
#define X_NOT_POSIX
#define X_NOT_STDC_ENV
#endif
#endif

#ifdef SYSV386
#ifdef SYSV
#define X_NOT_POSIX
#define X_NOT_STDC_ENV
#endif
#endif

#ifdef MOTOROLA
#ifdef SYSV
#define X_NOT_STDC_ENV
#endif
#endif
#endif /* _XOSDEFS_H_ */
#endif

/*
 * In Unix, app-defaults files have the suffix ".ad".  In VMS
 * they have the suffix ".dat".  We define a symbolic constant
 * to take care of this difference and use it in ContextHelp.c
 * and Include.c
 */
#ifndef APPDEFAULTSSUFFIX
#ifndef VMS
#define APPDEFAULTSSUFFIX ".ad"
#else
#define APPDEFAULTSSUFFIX ".dat"
#endif
#endif

/*
 * some special representation types used in the library
 */

/* A special type used in a number of places; different from XtRString */
#ifndef XmtRBuffer
#define XmtRBuffer "Buffer"
#endif

/* Xt doesn't define an XtRDouble */
#ifndef XmtRDouble
#define XmtRDouble "Double"
#endif

/*
 * This macro is an analog to XtOffsetOf.  Instead of returning the
 * offset of a field in a structure of the specified type, however,
 * it returns the size of that field.  It is particularly useful when
 * declaring resource lists with XmtRBuffer resources, because we can't
 * just use sizeof() with fields like "char name[40];"
 */
#define XmtSizeOf(type, field) sizeof(((type *)0)->field)

/*
 * DECWindows can't handle XtRemoveCallback, so we make these patches:
 */
#if DECWINDOWS_CALLBACK_HACK
#define XtAddCallback _XmtDECAddCallback
#define XtRemoveCallback _XmtDECRemoveCallback
#if NeedFunctionPrototypes
extern void _XmtDECAddCallback(Widget, String, XtCallbackProc, XtPointer);
extern void _XmtDECRemoveCallback(Widget, String, XtCallbackProc, XtPointer);
#else
extern void _XmtDECAddCallback();
extern void _XmtDECRemoveCallback();
#endif
#endif

/*
 * Here is some portability stuff for Motif 1.1
 */
#if XmVersion == 1001
#define XmGetPixmapByDepth(s,i,f,b,d) XmGetPixmap(s,i,f,b)
#endif

/*
 * Some systems (e.g. SunOS 4.1.3_U1) still don't have memmove()
 */
#ifdef NO_MEMMOVE
#undef memmove
#define memmove(a,b,n) bcopy(b,a,n)
#endif

/*
 * Some common Xmt functions
 */
#include <Xmt/Util.h>

#endif /* _Xmt_h */