Annotation of embedaddon/php/ext/filter/filter_private.h, revision 1.1.1.4

1.1       misho       1: /*
                      2:   +----------------------------------------------------------------------+
                      3:   | PHP Version 5                                                        |
                      4:   +----------------------------------------------------------------------+
1.1.1.4 ! misho       5:   | Copyright (c) 1997-2014 The PHP Group                                |
1.1       misho       6:   +----------------------------------------------------------------------+
                      7:   | This source file is subject to version 3.01 of the PHP license,      |
                      8:   | that is bundled with this package in the file LICENSE, and is        |
                      9:   | available through the world-wide-web at the following url:           |
                     10:   | http://www.php.net/license/3_01.txt                                  |
                     11:   | If you did not receive a copy of the PHP license and are unable to   |
                     12:   | obtain it through the world-wide-web, please send a note to          |
                     13:   | license@php.net so we can mail you a copy immediately.               |
                     14:   +----------------------------------------------------------------------+
                     15:   | Authors: Derick Rethans <derick@php.net>                             |
                     16:   +----------------------------------------------------------------------+
                     17: */
                     18: 
1.1.1.2   misho      19: /* $Id$ */
1.1       misho      20: 
                     21: #ifndef FILTER_PRIVATE_H
                     22: #define FILTER_PRIVATE_H
                     23: 
                     24: #define FILTER_FLAG_NONE                    0x0000
                     25: 
                     26: #define FILTER_REQUIRE_ARRAY                   0x1000000
                     27: #define FILTER_REQUIRE_SCALAR                  0x2000000
                     28: 
                     29: #define FILTER_FORCE_ARRAY                     0x4000000
                     30: #define FILTER_NULL_ON_FAILURE                 0x8000000
                     31: 
                     32: #define FILTER_FLAG_ALLOW_OCTAL             0x0001
                     33: #define FILTER_FLAG_ALLOW_HEX               0x0002
                     34: 
                     35: #define FILTER_FLAG_STRIP_LOW               0x0004
                     36: #define FILTER_FLAG_STRIP_HIGH              0x0008
                     37: #define FILTER_FLAG_ENCODE_LOW              0x0010
                     38: #define FILTER_FLAG_ENCODE_HIGH             0x0020
                     39: #define FILTER_FLAG_ENCODE_AMP              0x0040
                     40: #define FILTER_FLAG_NO_ENCODE_QUOTES        0x0080
                     41: #define FILTER_FLAG_EMPTY_STRING_NULL       0x0100
                     42: #define FILTER_FLAG_STRIP_BACKTICK          0x0200
                     43: 
                     44: #define FILTER_FLAG_ALLOW_FRACTION          0x1000
                     45: #define FILTER_FLAG_ALLOW_THOUSAND          0x2000
                     46: #define FILTER_FLAG_ALLOW_SCIENTIFIC        0x4000
                     47: 
                     48: #define FILTER_FLAG_SCHEME_REQUIRED         0x010000
                     49: #define FILTER_FLAG_HOST_REQUIRED           0x020000
                     50: #define FILTER_FLAG_PATH_REQUIRED           0x040000
                     51: #define FILTER_FLAG_QUERY_REQUIRED          0x080000
                     52: 
                     53: #define FILTER_FLAG_IPV4                    0x100000
                     54: #define FILTER_FLAG_IPV6                    0x200000
                     55: #define FILTER_FLAG_NO_RES_RANGE            0x400000
                     56: #define FILTER_FLAG_NO_PRIV_RANGE           0x800000
                     57: 
                     58: #define FILTER_VALIDATE_INT           0x0101
                     59: #define FILTER_VALIDATE_BOOLEAN       0x0102
                     60: #define FILTER_VALIDATE_FLOAT         0x0103
                     61: 
                     62: #define FILTER_VALIDATE_REGEXP        0x0110
                     63: #define FILTER_VALIDATE_URL           0x0111
                     64: #define FILTER_VALIDATE_EMAIL         0x0112
                     65: #define FILTER_VALIDATE_IP            0x0113
                     66: #define FILTER_VALIDATE_LAST          0x0113
                     67: 
                     68: #define FILTER_VALIDATE_ALL           0x0100
                     69: 
                     70: #define FILTER_DEFAULT                0x0204
                     71: #define FILTER_UNSAFE_RAW             0x0204
                     72: 
                     73: #define FILTER_SANITIZE_STRING        0x0201
                     74: #define FILTER_SANITIZE_ENCODED       0x0202
                     75: #define FILTER_SANITIZE_SPECIAL_CHARS 0x0203
                     76: #define FILTER_SANITIZE_EMAIL         0x0205
                     77: #define FILTER_SANITIZE_URL           0x0206
                     78: #define FILTER_SANITIZE_NUMBER_INT    0x0207
                     79: #define FILTER_SANITIZE_NUMBER_FLOAT  0x0208
                     80: #define FILTER_SANITIZE_MAGIC_QUOTES  0x0209
                     81: #define FILTER_SANITIZE_FULL_SPECIAL_CHARS 0x020a
                     82: #define FILTER_SANITIZE_LAST          0x020a
                     83: 
                     84: #define FILTER_SANITIZE_ALL           0x0200
                     85: 
                     86: #define FILTER_CALLBACK               0x0400
                     87: 
                     88: #define PHP_FILTER_ID_EXISTS(id) \
                     89: ((id >= FILTER_SANITIZE_ALL && id <= FILTER_SANITIZE_LAST) \
                     90: || (id >= FILTER_VALIDATE_ALL && id <= FILTER_VALIDATE_LAST) \
                     91: || id == FILTER_CALLBACK)
                     92: 
                     93: #define RETURN_VALIDATION_FAILED       \
                     94:        zval_dtor(value);       \
                     95:        if (flags & FILTER_NULL_ON_FAILURE) {   \
                     96:                ZVAL_NULL(value);       \
                     97:        } else {        \
                     98:                ZVAL_FALSE(value);      \
                     99:        }       \
                    100:        return; \
                    101: 
1.1.1.3   misho     102: #define PHP_FILTER_TRIM_DEFAULT(p, len) PHP_FILTER_TRIM_DEFAULT_EX(p, len, 1);
                    103: 
                    104: #define PHP_FILTER_TRIM_DEFAULT_EX(p, len, return_if_empty) { \
1.1       misho     105:        while ((len > 0)  && (*p == ' ' || *p == '\t' || *p == '\r' || *p == '\v' || *p == '\n')) { \
                    106:                p++; \
                    107:                len--; \
                    108:        } \
1.1.1.3   misho     109:        if (len < 1 && return_if_empty) { \
1.1       misho     110:                RETURN_VALIDATION_FAILED \
                    111:        } \
1.1.1.3   misho     112:        if (len > 0) { \
                    113:                while (p[len-1] == ' ' || p[len-1] == '\t' || p[len-1] == '\r' || p[len-1] == '\v' || p[len-1] == '\n') { \
                    114:                        len--; \
                    115:                } \
1.1       misho     116:        } \
                    117: }
                    118: 
                    119: #define PHP_FILTER_GET_LONG_OPT(zv, opt) { \
                    120:        if (Z_TYPE_PP(zv) != IS_LONG) {                                                                      \
                    121:                zval ___tmp = **zv;                                                                                 \
                    122:                zval_copy_ctor(&___tmp);                                                                                    \
                    123:                convert_to_long(&___tmp);                                                                                   \
                    124:                opt = Z_LVAL(___tmp);                                                                                  \
                    125:        } else {                                                                                                     \
                    126:                opt = Z_LVAL_PP(zv);                                                                        \
                    127:        }                                                                                                            \
                    128: }
                    129: 
                    130: #endif /* FILTER_PRIVATE_H */
                    131: 
                    132: /*
                    133:  * Local variables:
                    134:  * tab-width: 4
                    135:  * c-basic-offset: 4
                    136:  * End:
                    137:  * vim600: noet sw=4 ts=4 fdm=marker
                    138:  * vim<600: noet sw=4 ts=4
                    139:  */

FreeBSD-CVSweb <freebsd-cvsweb@FreeBSD.org>