openpam_ctype.h revision 236099
1236099Sdes/*- 2236099Sdes * Copyright (c) 2012 Dag-Erling Sm��rgrav 3236099Sdes * All rights reserved. 4236099Sdes * 5236099Sdes * Redistribution and use in source and binary forms, with or without 6236099Sdes * modification, are permitted provided that the following conditions 7236099Sdes * are met: 8236099Sdes * 1. Redistributions of source code must retain the above copyright 9236099Sdes * notice, this list of conditions and the following disclaimer 10236099Sdes * in this position and unchanged. 11236099Sdes * 2. Redistributions in binary form must reproduce the above copyright 12236099Sdes * notice, this list of conditions and the following disclaimer in the 13236099Sdes * documentation and/or other materials provided with the distribution. 14236099Sdes * 3. The name of the author may not be used to endorse or promote 15236099Sdes * products derived from this software without specific prior written 16236099Sdes * permission. 17236099Sdes * 18236099Sdes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 19236099Sdes * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 20236099Sdes * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 21236099Sdes * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 22236099Sdes * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 23236099Sdes * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 24236099Sdes * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 25236099Sdes * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 26236099Sdes * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 27236099Sdes * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 28236099Sdes * SUCH DAMAGE. 29236099Sdes * 30236099Sdes * $Id: openpam_ctype.h 578 2012-04-06 00:45:59Z des $ 31236099Sdes */ 32236099Sdes 33236099Sdes#ifndef OPENPAM_CTYPE_H_INCLUDED 34236099Sdes#define OPENPAM_CTYPE_H_INCLUDED 35236099Sdes 36236099Sdes/* 37236099Sdes * Evaluates to non-zero if the argument is a linear whitespace character. 38236099Sdes * For the purposes of this macro, the definition of linear whitespace is 39236099Sdes * extended to include the form feed and carraige return characters. 40236099Sdes */ 41236099Sdes#define is_lws(ch) \ 42236099Sdes (ch == ' ' || ch == '\t' || ch == '\f' || ch == '\r') 43236099Sdes 44236099Sdes/* 45236099Sdes * Evaluates to non-zero if the argument is a whitespace character. 46236099Sdes */ 47236099Sdes#define is_ws(ch) \ 48236099Sdes (is_lws(ch) || ch == '\n') 49236099Sdes 50236099Sdes/* 51236099Sdes * Evaluates to non-zero if the argument is a printable ASCII character. 52236099Sdes * Assumes that the execution character set is a superset of ASCII. 53236099Sdes */ 54236099Sdes#define is_p(ch) \ 55236099Sdes (ch >= '!' && ch <= '~') 56236099Sdes 57236099Sdes/* 58236099Sdes * Returns non-zero if the argument belongs to the POSIX Portable Filename 59236099Sdes * Character Set. Assumes that the execution character set is a superset 60236099Sdes * of ASCII. 61236099Sdes */ 62236099Sdes#define is_pfcs(ch) \ 63236099Sdes ((ch >= '0' && ch <= '9') || \ 64236099Sdes (ch >= 'A' && ch <= 'Z') || \ 65236099Sdes (ch >= 'a' && ch <= 'z') || \ 66236099Sdes ch == '.' || ch == '_' || ch == '-') 67236099Sdes 68236099Sdes#endif 69