-
Notifications
You must be signed in to change notification settings - Fork 205
/
php_phongo.h
99 lines (84 loc) · 3.59 KB
/
php_phongo.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
/*
* Copyright 2014-present MongoDB, Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
#ifndef PHONGO_H
#define PHONGO_H
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
/* Include headers for getpid(), which is used by PHONGO_SET_CREATED_BY_PID.
* This is based on PHP's ext/standard/pageinfo.c includes for getmypid. */
#if HAVE_UNISTD_H
#include <unistd.h>
#endif
#ifdef PHP_WIN32
#include <process.h>
#endif
#include "phongo_version.h"
#include "phongo_compat.h"
#include "phongo_classes.h"
#include "phongo_structs.h"
/* Define a common logging domain for the extension. Individual files may
* override the domain after including this header (e.g. phongo_bson.c). */
#undef MONGOC_LOG_DOMAIN
#define MONGOC_LOG_DOMAIN "PHONGO"
#define phpext_mongodb_ptr &mongodb_module_entry
extern zend_module_entry mongodb_module_entry;
ZEND_BEGIN_MODULE_GLOBALS(mongodb)
char* debug;
FILE* debug_fd;
HashTable persistent_clients;
HashTable* request_clients;
HashTable* subscribers;
HashTable* managers;
HashTable* loggers;
ZEND_END_MODULE_GLOBALS(mongodb)
#define MONGODB_G(v) ZEND_MODULE_GLOBALS_ACCESSOR(mongodb, v)
#if defined(ZTS) && defined(COMPILE_DL_MONGODB)
ZEND_TSRMLS_CACHE_EXTERN()
#endif
zend_object_handlers* phongo_get_std_object_handlers(void);
#define PHONGO_GET_PROPERTY_HASH_INIT_PROPS(is_temp, intern, props, size) \
do { \
if (is_temp) { \
ALLOC_HASHTABLE(props); \
zend_hash_init((props), (size), NULL, ZVAL_PTR_DTOR, 0); \
} else if ((intern)->properties) { \
(props) = (intern)->properties; \
} else { \
ALLOC_HASHTABLE(props); \
zend_hash_init((props), (size), NULL, ZVAL_PTR_DTOR, 0); \
(intern)->properties = (props); \
} \
} while (0)
#define PHONGO_GET_PROPERTY_HASH_FREE_PROPS(is_temp, props) \
do { \
if (is_temp) { \
zend_hash_destroy((props)); \
FREE_HASHTABLE(props); \
} \
} while (0)
#define PHONGO_ZVAL_EXCEPTION_NAME(e) (ZSTR_VAL(e->ce->name))
#define PHONGO_SET_CREATED_BY_PID(intern) \
do { \
(intern)->created_by_pid = (int) getpid(); \
} while (0)
#define PHONGO_DISABLED_CONSTRUCTOR(classname) \
static PHP_METHOD(classname, __construct) \
{ \
PHONGO_PARSE_PARAMETERS_NONE(); \
phongo_throw_exception(PHONGO_ERROR_RUNTIME, "Accessing private constructor"); \
}
#endif /* PHONGO_H */