xref: /PHP-7.1/Zend/zend_constants.h (revision ccd4716e)
1 /*
2    +----------------------------------------------------------------------+
3    | Zend Engine                                                          |
4    +----------------------------------------------------------------------+
5    | Copyright (c) 1998-2018 Zend Technologies Ltd. (http://www.zend.com) |
6    +----------------------------------------------------------------------+
7    | This source file is subject to version 2.00 of the Zend 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.zend.com/license/2_00.txt.                                |
11    | If you did not receive a copy of the Zend license and are unable to  |
12    | obtain it through the world-wide-web, please send a note to          |
13    | license@zend.com so we can mail you a copy immediately.              |
14    +----------------------------------------------------------------------+
15    | Authors: Andi Gutmans <andi@zend.com>                                |
16    |          Zeev Suraski <zeev@zend.com>                                |
17    +----------------------------------------------------------------------+
18 */
19 
20 /* $Id$ */
21 
22 #ifndef ZEND_CONSTANTS_H
23 #define ZEND_CONSTANTS_H
24 
25 #include "zend_globals.h"
26 
27 #define CONST_CS				(1<<0)				/* Case Sensitive */
28 #define CONST_PERSISTENT		(1<<1)				/* Persistent */
29 #define CONST_CT_SUBST			(1<<2)				/* Allow compile-time substitution */
30 
31 #define	PHP_USER_CONSTANT INT_MAX	/* a constant defined in user space */
32 
33 typedef struct _zend_constant {
34 	zval value;
35 	zend_string *name;
36 	int flags;
37 	int module_number;
38 } zend_constant;
39 
40 #define REGISTER_NULL_CONSTANT(name, flags)  zend_register_null_constant((name), sizeof(name)-1, (flags), module_number)
41 #define REGISTER_BOOL_CONSTANT(name, bval, flags)  zend_register_bool_constant((name), sizeof(name)-1, (bval), (flags), module_number)
42 #define REGISTER_LONG_CONSTANT(name, lval, flags)  zend_register_long_constant((name), sizeof(name)-1, (lval), (flags), module_number)
43 #define REGISTER_DOUBLE_CONSTANT(name, dval, flags)  zend_register_double_constant((name), sizeof(name)-1, (dval), (flags), module_number)
44 #define REGISTER_STRING_CONSTANT(name, str, flags)  zend_register_string_constant((name), sizeof(name)-1, (str), (flags), module_number)
45 #define REGISTER_STRINGL_CONSTANT(name, str, len, flags)  zend_register_stringl_constant((name), sizeof(name)-1, (str), (len), (flags), module_number)
46 
47 #define REGISTER_NS_NULL_CONSTANT(ns, name, flags)  zend_register_null_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (flags), module_number)
48 #define REGISTER_NS_BOOL_CONSTANT(ns, name, bval, flags)  zend_register_bool_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (bval), (flags), module_number)
49 #define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags)  zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (lval), (flags), module_number)
50 #define REGISTER_NS_DOUBLE_CONSTANT(ns, name, dval, flags)  zend_register_double_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (dval), (flags), module_number)
51 #define REGISTER_NS_STRING_CONSTANT(ns, name, str, flags)  zend_register_string_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (str), (flags), module_number)
52 #define REGISTER_NS_STRINGL_CONSTANT(ns, name, str, len, flags)  zend_register_stringl_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (str), (len), (flags), module_number)
53 
54 #define REGISTER_MAIN_NULL_CONSTANT(name, flags)  zend_register_null_constant((name), sizeof(name)-1, (flags), 0)
55 #define REGISTER_MAIN_BOOL_CONSTANT(name, bval, flags)  zend_register_bool_constant((name), sizeof(name)-1, (bval), (flags), 0)
56 #define REGISTER_MAIN_LONG_CONSTANT(name, lval, flags)  zend_register_long_constant((name), sizeof(name)-1, (lval), (flags), 0)
57 #define REGISTER_MAIN_DOUBLE_CONSTANT(name, dval, flags)  zend_register_double_constant((name), sizeof(name)-1, (dval), (flags), 0)
58 #define REGISTER_MAIN_STRING_CONSTANT(name, str, flags)  zend_register_string_constant((name), sizeof(name)-1, (str), (flags), 0)
59 #define REGISTER_MAIN_STRINGL_CONSTANT(name, str, len, flags)  zend_register_stringl_constant((name), sizeof(name)-1, (str), (len), (flags), 0)
60 
61 BEGIN_EXTERN_C()
62 void clean_module_constants(int module_number);
63 void free_zend_constant(zval *zv);
64 int zend_startup_constants(void);
65 int zend_shutdown_constants(void);
66 void zend_register_standard_constants(void);
67 void clean_non_persistent_constants(void);
68 ZEND_API int zend_verify_const_access(zend_class_constant *c, zend_class_entry *ce);
69 ZEND_API zval *zend_get_constant(zend_string *name);
70 ZEND_API zval *zend_get_constant_str(const char *name, size_t name_len);
71 ZEND_API zval *zend_get_constant_ex(zend_string *name, zend_class_entry *scope, uint32_t flags);
72 ZEND_API void zend_register_bool_constant(const char *name, size_t name_len, zend_bool bval, int flags, int module_number);
73 ZEND_API void zend_register_null_constant(const char *name, size_t name_len, int flags, int module_number);
74 ZEND_API void zend_register_long_constant(const char *name, size_t name_len, zend_long lval, int flags, int module_number);
75 ZEND_API void zend_register_double_constant(const char *name, size_t name_len, double dval, int flags, int module_number);
76 ZEND_API void zend_register_string_constant(const char *name, size_t name_len, char *strval, int flags, int module_number);
77 ZEND_API void zend_register_stringl_constant(const char *name, size_t name_len, char *strval, size_t strlen, int flags, int module_number);
78 ZEND_API int zend_register_constant(zend_constant *c);
79 void zend_copy_constants(HashTable *target, HashTable *sourc);
80 zend_constant *zend_quick_get_constant(const zval *key, uint32_t flags);
81 END_EXTERN_C()
82 
83 #define ZEND_CONSTANT_DTOR free_zend_constant
84 
85 #endif
86 
87 /*
88  * Local variables:
89  * tab-width: 4
90  * c-basic-offset: 4
91  * indent-tabs-mode: t
92  * End:
93  */
94