Back to index

php5  5.3.10
filter_private.h
Go to the documentation of this file.
00001 /*
00002   +----------------------------------------------------------------------+
00003   | PHP Version 5                                                        |
00004   +----------------------------------------------------------------------+
00005   | Copyright (c) 1997-2012 The PHP Group                                |
00006   +----------------------------------------------------------------------+
00007   | This source file is subject to version 3.01 of the PHP license,      |
00008   | that is bundled with this package in the file LICENSE, and is        |
00009   | available through the world-wide-web at the following url:           |
00010   | http://www.php.net/license/3_01.txt                                  |
00011   | If you did not receive a copy of the PHP license and are unable to   |
00012   | obtain it through the world-wide-web, please send a note to          |
00013   | license@php.net so we can mail you a copy immediately.               |
00014   +----------------------------------------------------------------------+
00015   | Authors: Derick Rethans <derick@php.net>                             |
00016   +----------------------------------------------------------------------+
00017 */
00018 
00019 /* $Id: filter_private.h 321634 2012-01-01 13:15:04Z felipe $ */
00020 
00021 #ifndef FILTER_PRIVATE_H
00022 #define FILTER_PRIVATE_H
00023 
00024 #define FILTER_FLAG_NONE                    0x0000
00025 
00026 #define FILTER_REQUIRE_ARRAY                     0x1000000
00027 #define FILTER_REQUIRE_SCALAR                    0x2000000
00028 
00029 #define FILTER_FORCE_ARRAY                0x4000000
00030 #define FILTER_NULL_ON_FAILURE                   0x8000000
00031 
00032 #define FILTER_FLAG_ALLOW_OCTAL             0x0001
00033 #define FILTER_FLAG_ALLOW_HEX               0x0002
00034 
00035 #define FILTER_FLAG_STRIP_LOW               0x0004
00036 #define FILTER_FLAG_STRIP_HIGH              0x0008
00037 #define FILTER_FLAG_ENCODE_LOW              0x0010
00038 #define FILTER_FLAG_ENCODE_HIGH             0x0020
00039 #define FILTER_FLAG_ENCODE_AMP              0x0040
00040 #define FILTER_FLAG_NO_ENCODE_QUOTES        0x0080
00041 #define FILTER_FLAG_EMPTY_STRING_NULL       0x0100
00042 #define FILTER_FLAG_STRIP_BACKTICK          0x0200
00043 
00044 #define FILTER_FLAG_ALLOW_FRACTION          0x1000
00045 #define FILTER_FLAG_ALLOW_THOUSAND          0x2000
00046 #define FILTER_FLAG_ALLOW_SCIENTIFIC        0x4000
00047 
00048 #define FILTER_FLAG_SCHEME_REQUIRED         0x010000
00049 #define FILTER_FLAG_HOST_REQUIRED           0x020000
00050 #define FILTER_FLAG_PATH_REQUIRED           0x040000
00051 #define FILTER_FLAG_QUERY_REQUIRED          0x080000
00052 
00053 #define FILTER_FLAG_IPV4                    0x100000
00054 #define FILTER_FLAG_IPV6                    0x200000
00055 #define FILTER_FLAG_NO_RES_RANGE            0x400000
00056 #define FILTER_FLAG_NO_PRIV_RANGE           0x800000
00057 
00058 #define FILTER_VALIDATE_INT           0x0101
00059 #define FILTER_VALIDATE_BOOLEAN       0x0102
00060 #define FILTER_VALIDATE_FLOAT         0x0103
00061 
00062 #define FILTER_VALIDATE_REGEXP        0x0110
00063 #define FILTER_VALIDATE_URL           0x0111
00064 #define FILTER_VALIDATE_EMAIL         0x0112
00065 #define FILTER_VALIDATE_IP            0x0113
00066 #define FILTER_VALIDATE_LAST          0x0113
00067 
00068 #define FILTER_VALIDATE_ALL           0x0100
00069 
00070 #define FILTER_DEFAULT                0x0204
00071 #define FILTER_UNSAFE_RAW             0x0204
00072 
00073 #define FILTER_SANITIZE_STRING        0x0201
00074 #define FILTER_SANITIZE_ENCODED       0x0202
00075 #define FILTER_SANITIZE_SPECIAL_CHARS 0x0203
00076 #define FILTER_SANITIZE_EMAIL         0x0205
00077 #define FILTER_SANITIZE_URL           0x0206
00078 #define FILTER_SANITIZE_NUMBER_INT    0x0207
00079 #define FILTER_SANITIZE_NUMBER_FLOAT  0x0208
00080 #define FILTER_SANITIZE_MAGIC_QUOTES  0x0209
00081 #define FILTER_SANITIZE_FULL_SPECIAL_CHARS 0x020a
00082 #define FILTER_SANITIZE_LAST          0x020a
00083 
00084 #define FILTER_SANITIZE_ALL           0x0200
00085 
00086 #define FILTER_CALLBACK               0x0400
00087 
00088 #define PHP_FILTER_ID_EXISTS(id) \
00089 ((id >= FILTER_SANITIZE_ALL && id <= FILTER_SANITIZE_LAST) \
00090 || (id >= FILTER_VALIDATE_ALL && id <= FILTER_VALIDATE_LAST) \
00091 || id == FILTER_CALLBACK)
00092 
00093 #define RETURN_VALIDATION_FAILED   \
00094        zval_dtor(value);    \
00095        if (flags & FILTER_NULL_ON_FAILURE) {     \
00096               ZVAL_NULL(value);    \
00097        } else {      \
00098               ZVAL_FALSE(value);   \
00099        }      \
00100        return;       \
00101 
00102 #define PHP_FILTER_TRIM_DEFAULT(p, len) { \
00103        while ((len > 0)  && (*p == ' ' || *p == '\t' || *p == '\r' || *p == '\v' || *p == '\n')) { \
00104               p++; \
00105               len--; \
00106        } \
00107        if (len < 1) { \
00108               RETURN_VALIDATION_FAILED \
00109        } \
00110        while (p[len-1] == ' ' || p[len-1] == '\t' || p[len-1] == '\r' || p[len-1] == '\v' || p[len-1] == '\n') { \
00111               len--; \
00112        } \
00113 }
00114 
00115 #define PHP_FILTER_GET_LONG_OPT(zv, opt) { \
00116        if (Z_TYPE_PP(zv) != IS_LONG) {                                                                      \
00117               zval ___tmp = **zv;                                                                                 \
00118               zval_copy_ctor(&___tmp);                                                                                    \
00119               convert_to_long(&___tmp);                                                                                   \
00120               opt = Z_LVAL(___tmp);                                                                                  \
00121        } else {                                                                                                     \
00122               opt = Z_LVAL_PP(zv);                                                                        \
00123        }                                                                                                            \
00124 }
00125 
00126 #endif /* FILTER_PRIVATE_H */
00127 
00128 /*
00129  * Local variables:
00130  * tab-width: 4
00131  * c-basic-offset: 4
00132  * End:
00133  * vim600: noet sw=4 ts=4 fdm=marker
00134  * vim<600: noet sw=4 ts=4
00135  */