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