2 * Copyright (c) 2014 Dag-Erling Smørgrav
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
8 * 1. Redistributions of source code must retain the above copyright
9 * notice, this list of conditions and the following disclaimer.
10 * 2. Redistributions in binary form must reproduce the above copyright
11 * notice, this list of conditions and the following disclaimer in the
12 * documentation and/or other materials provided with the distribution.
13 * 3. The name of the author may not be used to endorse or promote
14 * products derived from this software without specific prior written
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
18 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
19 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
20 * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
21 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
22 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
23 * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
24 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
25 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
26 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
39 #include "openpam_ctype.h"
43 #define OC_DIGIT "0123456789"
44 #define OC_XDIGIT OC_DIGIT "ABCDEFabcdef"
45 #define OC_UPPER "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
46 #define OC_LOWER "abcdefghijklmnopqrstuvwxyz"
47 #define OC_LETTER OC_UPPER OC_LOWER
48 #define OC_LWS " \t\f\r"
49 #define OC_WS OC_LWS "\n"
50 #define OC_P "!\"#$%&'()*+,-./" OC_DIGIT ":;<=>?@" OC_UPPER "[\\]^_`" OC_LOWER "{|}~"
51 #define OC_PFCS OC_DIGIT OC_LETTER "._-"
53 static const char oc_digit[] = OC_DIGIT;
54 static const char oc_xdigit[] = OC_XDIGIT;
55 static const char oc_upper[] = OC_UPPER;
56 static const char oc_lower[] = OC_LOWER;
57 static const char oc_letter[] = OC_LETTER;
58 static const char oc_lws[] = OC_LWS;
59 static const char oc_ws[] = OC_WS;
60 static const char oc_p[] = OC_P;
61 static const char oc_pfcs[] = OC_PFCS;
64 T_FUNC(t_oc_##set, "is_" #set) \
67 unsigned int i, ret; \
69 memset(crib, 0, sizeof crib); \
70 for (i = 0; oc_##set[i]; ++i) \
71 crib[(int)oc_##set[i]] = 1; \
72 for (i = ret = 0; i < sizeof crib; ++i) { \
73 if (is_##set(i) != crib[i]) { \
74 t_verbose("is_%s() incorrect " \
75 "for %#02x\n", #set, i); \
93 /***************************************************************************
97 const struct t_test *t_plan[] = {
110 const struct t_test **
111 t_prepare(int argc, char *argv[])