1#ifndef UTILS_H
2#define	UTILS_H 1
3
4  /*\
5   *                          COPYRIGHT 1990
6   *                    DIGITAL EQUIPMENT CORPORATION
7   *                       MAYNARD, MASSACHUSETTS
8   *                        ALL RIGHTS RESERVED.
9   *
10   * THE INFORMATION IN THIS SOFTWARE IS SUBJECT TO CHANGE WITHOUT NOTICE AND
11   * SHOULD NOT BE CONSTRUED AS A COMMITMENT BY DIGITAL EQUIPMENT CORPORATION.
12   * DIGITAL MAKES NO REPRESENTATIONS ABOUT THE SUITABILITY OF THIS SOFTWARE
13   * FOR ANY PURPOSE.  IT IS SUPPLIED "AS IS" WITHOUT EXPRESS OR IMPLIED
14   * WARRANTY.
15   *
16   * IF THE SOFTWARE IS MODIFIED IN A MANNER CREATING DERIVATIVE COPYRIGHT
17   * RIGHTS, APPROPRIATE LEGENDS MAY BE PLACED ON THE DERIVATIVE WORK IN
18   * ADDITION TO THAT SET FORTH ABOVE.
19   *
20   * Permission to use, copy, modify, and distribute this software and its
21   * documentation for any purpose and without fee is hereby granted, provided
22   * that the above copyright notice appear in all copies and that both that
23   * copyright notice and this permission notice appear in supporting
24   * documentation, and that the name of Digital Equipment Corporation not be
25   * used in advertising or publicity pertaining to distribution of the
26   * software without specific, written prior permission.
27  \*/
28
29/***====================================================================***/
30
31#include 	<stdio.h>
32#include	<X11/Xos.h>
33#include	<X11/Xfuncproto.h>
34#include	<X11/Xfuncs.h>
35#include 	<stdarg.h>
36#include	<stddef.h>
37
38_XFUNCPROTOBEGIN
39
40#ifndef NUL
41#define	NUL	'\0'
42#endif
43
44/***====================================================================***/
45
46#ifndef OPAQUE_DEFINED
47typedef void *Opaque;
48#endif
49#ifndef NullOpaque
50#define	NullOpaque	((Opaque)NULL)
51#endif
52
53#ifndef BOOLEAN_DEFINED
54typedef char Boolean;
55#endif
56
57#ifndef True
58#define	True	((Boolean)1)
59#define	False	((Boolean)0)
60#endif /* ndef True */
61#define	booleanText(b)	((b)?"True":"False")
62
63#ifndef COMPARISON_DEFINED
64typedef int Comparison;
65
66#define	Greater		((Comparison)1)
67#define	Equal		((Comparison)0)
68#define	Less		((Comparison)-1)
69#define	CannotCompare	((Comparison)-37)
70#define	comparisonText(c)	((c)?((c)<0?"Less":"Greater"):"Equal")
71#endif
72
73
74/***====================================================================***/
75
76extern Boolean uSetErrorFile(const char *name);
77extern void uInformation(const char *s, ...) _X_ATTRIBUTE_PRINTF(1, 2);
78extern void uAction(const char *s, ...) _X_ATTRIBUTE_PRINTF(1, 2);
79extern void uWarning(const char *s, ...) _X_ATTRIBUTE_PRINTF(1, 2);
80extern void uError(const char *s, ...) _X_ATTRIBUTE_PRINTF(1, 2);
81extern void uFatalError(const char *s, ...) _X_ATTRIBUTE_PRINTF(1, 2)
82    _X_NORETURN;
83extern void uInternalError(const char *s, ...) _X_ATTRIBUTE_PRINTF(1, 2);
84
85/***====================================================================***/
86
87#define	NullString	((char *)NULL)
88
89#define	uStringText(s)		((s)==NullString?"<NullString>":(s))
90#define	uStringEqual(s1,s2)	(uStringCompare(s1,s2)==Equal)
91#define	uStringPrefix(p,s)	(strncmp(p,s,strlen(p))==0)
92#define	uStringCompare(s1,s2)	(strcmp(s1,s2))
93#define	uStrCaseEqual(s1,s2)	(strcasecmp(s1,s2)==0)
94
95#ifndef HAVE_ASPRINTF
96extern _X_HIDDEN int _X_ATTRIBUTE_PRINTF(2,3)
97    uAsprintf(char ** ret, const char *format, ...);
98#define asprintf                uAsprintf
99#endif
100
101/***====================================================================***/
102
103_XFUNCPROTOEND
104
105#endif                          /* UTILS_H */
106