1 /**
2  * Copyright (C) 2002-2015 by
3  * Jeffrey Fulmer - <jeff@joedog.org>, et al.
4  * This file is distributed as part of Siege
5  *
6  * This program is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License along
17  * with this program; if not, write to the Free Software Foundation, Inc.
18  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
19  *--
20  */
21 #ifndef JOEDOG_DEFS_H
22 #define JOEDOG_DEFS_H
23 #define private static
24 #define public
25 
26 #define  ISALPHA(x)     ((x >= 'a' && x <= 'z') || (x >= 'A' && x <= 'Z'))
27 #define  ISSEPARATOR(x) (('='==(x))||(':'==(x)))
28 #define  ISUPPER(x)     ((unsigned)(x)-'A'<='Z'-'A')
29 #define  ISLOWER(x)     ((unsigned)(x)-'a'<='z'-'a')
30 #define  ISSPACE(x)     isspace((unsigned char)(x))
31 #define  ISOPERAND(x) ('<'==(x)||'>'==(x)||'='==(x))
32 #define  ISDIGIT(x)     isdigit ((unsigned char)(x))
33 #define  ISXDIGIT(c) (((((((((c) - 48U) & 255) * 18 / 17 * 52 / 51 * 58 / 114    \
34          * 13 / 11 * 14 / 13 * 35 + 35) / 36 * 35 / 33 * 34 / 33 * 35 / 170 ^ 4) \
35          - 3) & 255) ^ 1) <= 2U)
36 /**
37  * Lifted from wget: Convert a sequence of ASCII hex digits X and Y
38  * to a number between 0 and 255. Uses XDIGIT_TO_NUM for conversion
39  * of individual digits.
40  */
41 #define XDIGIT_TO_NUM(x) ((x) < 'A' ? (x) - '0' : TOUPPER (x) - 'A' + 10)
42 #define XNUM_TO_DIGIT(x) ("0123456789ABCDEF"[x])
43 #define XNUM_TO_digit(x) ("0123456789abcdef"[x])
44 #define X2DIGITS_TO_NUM(h1, h2) ((XDIGIT_TO_NUM (h1) << 4) + XDIGIT_TO_NUM (h2))
45 
46 #define  ISNUMBER(v)  (((v) > (char)0x2f) && ((v) < (char)0x3a))
47 #define  ISQUOTE(x)   (x == '"' || x == '\'')
48 #if STDC_HEADERS
49 # define TOLOWER(Ch) tolower (Ch)
50 # define TOUPPER(Ch) toupper (Ch)
51 #else
52 # define TOLOWER(Ch) (ISUPPER (Ch) ? tolower (Ch) : (Ch))
53 # define TOUPPER(Ch) (ISLOWER (Ch) ? toupper (Ch) : (Ch))
54 #endif
55 
56 typedef void (*method)(void *v);
57 
58 #ifndef  EXIT_SUCCESS
59 # define EXIT_SUCCESS   0
60 #endif /*EXIT_SUCESS*/
61 #ifndef  EXIT_FAILURE
62 # define EXIT_FAILURE   1
63 #endif /*EXIT_FAILURE*/
64 
65 #endif/*JOEDOG_DEFS_H*/
66