2 * CDE - Common Desktop Environment
4 * Copyright (c) 1993-2012, The Open Group. All rights reserved.
6 * These libraries and programs are free software; you can
7 * redistribute them and/or modify them under the terms of the GNU
8 * Lesser General Public License as published by the Free Software
9 * Foundation; either version 2 of the License, or (at your option)
12 * These libraries and programs are distributed in the hope that
13 * they will be useful, but WITHOUT ANY WARRANTY; without even the
14 * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
15 * PURPOSE. See the GNU Lesser General Public License for more
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with these librararies and programs; if not, write
20 * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
21 * Floor, Boston, MA 02110-1301 USA
23 /* $XConsortium: tools.h /main/3 1996/06/19 17:18:54 drk $ */
24 /* TOOLS.H: Definitions for type declarations, printing, bit handling, etc.
28 typedef unsigned char UNCH;
34 #define ustrcmp(s1, s2) strcmp((char *)(s1), (char *)(s2))
35 #define ustrcpy(s1, s2) strcpy((char *)(s1), (char *)(s2))
36 #define ustrchr(s, c) (UNCH *)strchr((char *)(s), c)
37 #define ustrncmp(s1, s2, n) strncmp((char *)(s1), (char *)(s2), n)
38 #define ustrncpy(s1, s2, n) strncpy((char *)(s1), (char *)(s2), n)
39 #define ustrlen(s1) strlen((char *)(s1))
41 #define ustrcmp strcmp
42 #define ustrcpy strcpy
43 #define ustrchr strchr
44 #define ustrncmp strncmp
45 #define ustrncpy strncpy
46 #define ustrlen strlen
50 int ustrcmp(UNCH *, UNCH *);
51 UNCH *ustrchr(UNCH *, int);
52 int ustrncmp(UNCH *, UNCH *, UNS);
53 int ustrncpy(UNCH *, UNCH *, UNS);
60 #define ISASCII(c) isascii(c)
62 #define ISASCII(c) (1)
66 #define MEMZERO(s, n) bzero(s, n)
67 #else /* not BSD_STRINGS */
68 #define MEMZERO(s, n) memset(s, '\0', n)
69 #endif /* not BSD_STRINGS */
71 /* Macros for bit manipulation.
73 #define SET(word, bits) ((word) |= (bits)) /* Turn bits on */
74 #define RESET(word, bits) ((word) &= ~(bits)) /* Turn bits off */
75 #define GET(word, bits) ((word) & (bits)) /* 1=any bit on */
76 #define BITOFF(word, bits) (GET(word, bits)==0) /* 1=no bits on */
77 #define BITON(word, bits) ((word) & (bits)) /* 1=any bit on */
79 #define ETDCDATA (dumetd) /* Dummy etd pointer for #PCDATA. */
80 #define ETDNULL (dumetd + 1) /* Dummy etd pointer for null tag. */
81 #define ETDNET (dumetd + 2) /* Dummy etd pointer for NET delimiter. */
83 ((p) == NULL || (p) == ETDCDATA || (p) == ETDNULL || (p) == ETDNET)
84 #define PTRNUM(p) ((p) == NULL ? 0 : ((p) - dumetd) + 1)
87 #define P(parms) parms
92 /* VP is used for prototypes of varargs functions. You can't have a
93 prototype if the function is defined using varargs.h rather than
98 #define VP(parms) P(parms)