-
Notifications
You must be signed in to change notification settings - Fork 2
/
php_aware_storage.h
160 lines (133 loc) · 6.24 KB
/
php_aware_storage.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
/*
+----------------------------------------------------------------------+
| PHP Version 5 / aware |
+----------------------------------------------------------------------+
| Copyright (c) 2009 Mikko Koppanen |
+----------------------------------------------------------------------+
| This source file is subject to version 3.01 of the PHP license, |
| that is bundled with this package in the file LICENSE, and is |
| available through the world-wide-web at the following url: |
| http://www.php.net/license/3_01.txt |
| If you did not receive a copy of the PHP license and are unable to |
| obtain it through the world-wide-web, please send a note to |
| [email protected] so we can mail you a copy immediately. |
+----------------------------------------------------------------------+
| Author: Mikko Kopppanen <[email protected]> |
+----------------------------------------------------------------------+
*/
#ifndef _PHP_AWARE_STORAGE_H_
# define _PHP_AWARE_STORAGE_H_
#include "php_aware.h"
#include "ext/standard/php_smart_str.h"
/* {{{ define the string length of the uuid
*/
#define PHP_AWARE_UUID_LEN 36
/* }}} */
/*{{{ typedef enum _AwareOperationStatus
*/
typedef enum _AwareOperationStatus {
AwareOperationFailed,
AwareOperationSuccess,
AwareOperationNotSupported
} AwareOperationStatus;
/* }}} */
/* {{{ typedef enum _AwareModuleRegisterStatus
*/
typedef enum _AwareModuleRegisterStatus {
AwareModuleNotConfigured,
AwareModuleRegistered,
AwareModuleFailed
} AwareModuleRegisterStatus;
/* }}} */
/* {{{ Arguments passed to different stages
*/
#define PHP_AWARE_CONNECT_ARGS TSRMLS_D
#define PHP_AWARE_GET_ARGS const char *uuid, zval *event TSRMLS_DC
#define PHP_AWARE_STORE_ARGS const char *uuid, zval *event, const char *error_filename, long error_lineno TSRMLS_DC
#define PHP_AWARE_GET_LIST_ARGS long start, long limit, zval *events TSRMLS_DC
#define PHP_AWARE_DELETE_ARGS const char *uuid TSRMLS_DC
#define PHP_AWARE_DISCONNECT_ARGS TSRMLS_D
/* }}} */
/* {{{ typedef struct _php_aware_storage_module
*/
typedef struct _php_aware_storage_module {
char *name;
AwareOperationStatus (*connect)(PHP_AWARE_CONNECT_ARGS);
AwareOperationStatus (*get)(PHP_AWARE_GET_ARGS);
AwareOperationStatus (*store)(PHP_AWARE_STORE_ARGS);
AwareOperationStatus (*get_list)(PHP_AWARE_GET_LIST_ARGS);
AwareOperationStatus (*delete)(PHP_AWARE_DELETE_ARGS);
AwareOperationStatus (*disconnect)(PHP_AWARE_DISCONNECT_ARGS);
} php_aware_storage_module;
/* }}} */
/* {{{ php_aware_storage_module *php_aware_find_storage_module(const char *);
*/
php_aware_storage_module *php_aware_find_storage_module(const char *);
/* }}} */
/* {{{ void php_aware_storage_store(php_aware_storage_module *, const char *, zval *, long, const char *, long TSRMLS_DC);
*/
void php_aware_storage_store(php_aware_storage_module *, const char *, zval *, long, const char *, long TSRMLS_DC);
/* }}} */
/* {{{ void php_aware_storage_get(const char *, const char *, zval * TSRMLS_DC);
*/
void php_aware_storage_get(const char *, const char *, zval * TSRMLS_DC);
/* }}} */
/* {{{ void php_aware_storage_get_list(const char *, long , long , zval * TSRMLS_DC);
*/
void php_aware_storage_get_list(const char *, long , long , zval * TSRMLS_DC);
/* }}} */
/* {{{ void php_aware_storage_store_all(const char *, zval *, long, const char *, long TSRMLS_DC);
*/
void php_aware_storage_store_all(const char *, zval *, long, const char *, long TSRMLS_DC);
/* }}} */
/* {{{ zend_bool php_aware_storage_delete(const char *mod_name, const char *uuid TSRMLS_DC);
*/
zend_bool php_aware_storage_delete(const char *mod_name, const char *uuid TSRMLS_DC);
/* }}} */
/* {{{ void php_aware_storage_module_list(zval *return_value);
*/
void php_aware_storage_module_list(zval *return_value);
/* }}} */
/* {{{ MY_AWARE_EXPORTS void php_aware_storage_serialize(const char *uuid, zval *event, smart_str *data_var TSRMLS_DC);
*/
MY_AWARE_EXPORTS void php_aware_storage_serialize(const char *uuid, zval *event, smart_str *data_var TSRMLS_DC);
/* }}} */
/* {{{ MY_AWARE_EXPORTS zend_bool php_aware_storage_unserialize(const char *, int , zval * TSRMLS_DC);
*/
MY_AWARE_EXPORTS zend_bool php_aware_storage_unserialize(const char *, int , zval * TSRMLS_DC);
/* }}} */
/* {{{ MY_AWARE_EXPORTS AwareModuleRegisterStatus php_aware_register_storage_module(php_aware_storage_module * TSRMLS_DC);
*/
MY_AWARE_EXPORTS AwareModuleRegisterStatus php_aware_register_storage_module(php_aware_storage_module * TSRMLS_DC);
/* }}} */
/* {{{ Storage function signatures
*/
#define PHP_AWARE_CONNECT_FUNC(mod_name) AwareOperationStatus php_aware_storage_connect_##mod_name(PHP_AWARE_CONNECT_ARGS)
#define PHP_AWARE_GET_FUNC(mod_name) AwareOperationStatus php_aware_storage_get_##mod_name(PHP_AWARE_GET_ARGS)
#define PHP_AWARE_STORE_FUNC(mod_name) AwareOperationStatus php_aware_storage_store_##mod_name(PHP_AWARE_STORE_ARGS)
#define PHP_AWARE_GET_LIST_FUNC(mod_name) AwareOperationStatus php_aware_storage_get_list_##mod_name(PHP_AWARE_GET_LIST_ARGS)
#define PHP_AWARE_DELETE_FUNC(mod_name) AwareOperationStatus php_aware_storage_delete_##mod_name(PHP_AWARE_DELETE_ARGS)
#define PHP_AWARE_DISCONNECT_FUNC(mod_name) AwareOperationStatus php_aware_storage_disconnect_##mod_name(PHP_AWARE_DISCONNECT_ARGS)
/* }}} */
/* {{{ define storage functions
*/
#define PHP_AWARE_STORAGE_FUNCS(mod_name) \
PHP_AWARE_CONNECT_FUNC(mod_name); \
PHP_AWARE_GET_FUNC(mod_name); \
PHP_AWARE_STORE_FUNC(mod_name); \
PHP_AWARE_GET_LIST_FUNC(mod_name); \
PHP_AWARE_DELETE_FUNC(mod_name); \
PHP_AWARE_DISCONNECT_FUNC(mod_name);
/* }}} */
/* {{{ Define the func ptrs for the specific module
*/
#define PHP_AWARE_STORAGE_MOD(mod_name) \
#mod_name, php_aware_storage_connect_##mod_name, php_aware_storage_get_##mod_name, php_aware_storage_store_##mod_name, \
php_aware_storage_get_list_##mod_name, php_aware_storage_delete_##mod_name, php_aware_storage_disconnect_##mod_name
/* }}} */
/* {{{ Register the storage module. called from MINIT in module
*/
#define PHP_AWARE_STORAGE_REGISTER(mod_name) \
php_aware_register_storage_module(php_aware_storage_module_##mod_name##_ptr TSRMLS_CC)
/* }}} */
#endif