forked from laruence/yaf
-
Notifications
You must be signed in to change notification settings - Fork 0
/
yaf_request.h
103 lines (90 loc) · 4.04 KB
/
yaf_request.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
/*
+----------------------------------------------------------------------+
| Yet Another Framework |
+----------------------------------------------------------------------+
| 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: Xinchen Hui <[email protected]> |
+----------------------------------------------------------------------+
*/
#ifndef YAF_REQUEST_H
#define YAF_REQUEST_H
#define YAF_REQUEST_PROPERTY_NAME_MODULE "module"
#define YAF_REQUEST_PROPERTY_NAME_CONTROLLER "controller"
#define YAF_REQUEST_PROPERTY_NAME_ACTION "action"
#define YAF_REQUEST_PROPERTY_NAME_METHOD "method"
#define YAF_REQUEST_PROPERTY_NAME_PARAMS "params"
#define YAF_REQUEST_PROPERTY_NAME_URI "uri"
#define YAF_REQUEST_PROPERTY_NAME_STATE "dispatched"
#define YAF_REQUEST_PROPERTY_NAME_LANG "language"
#define YAF_REQUEST_PROPERTY_NAME_ROUTED "routed"
#define YAF_REQUEST_PROPERTY_NAME_BASE "_base_uri"
#define YAF_REQUEST_PROPERTY_NAME_EXCEPTION "_exception"
#define YAF_REQUEST_SERVER_URI "request_uri="
#define YAF_GLOBAL_VARS_TYPE unsigned int
#define YAF_GLOBAL_VARS_POST TRACK_VARS_POST
#define YAF_GLOBAL_VARS_GET TRACK_VARS_GET
#define YAF_GLOBAL_VARS_ENV TRACK_VARS_ENV
#define YAF_GLOBAL_VARS_FILES TRACK_VARS_FILES
#define YAF_GLOBAL_VARS_SERVER TRACK_VARS_SERVER
#define YAF_GLOBAL_VARS_REQUEST TRACK_VARS_REQUEST
#define YAF_GLOBAL_VARS_COOKIE TRACK_VARS_COOKIE
#define YAF_REQUEST_IS_METHOD(x) \
PHP_METHOD(yaf_request, is##x) {\
zval * method = zend_read_property(Z_OBJCE_P(getThis()), getThis(), ZEND_STRL(YAF_REQUEST_PROPERTY_NAME_METHOD), 0 TSRMLS_CC);\
if (strncasecmp(#x, Z_STRVAL_P(method), Z_STRLEN_P(method)) == 0) { \
RETURN_TRUE; \
} \
RETURN_FALSE; \
}
#define YAF_REQUEST_METHOD(ce, x, type) \
PHP_METHOD(ce, get##x) { \
char *name; \
int len; \
zval *ret; \
zval *def = NULL; \
if (ZEND_NUM_ARGS() == 0) { \
ret = yaf_request_query(type, NULL, 0 TSRMLS_CC); \
}else if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s|z", &name, &len, &def) == FAILURE) { \
return; \
} else { \
ret = yaf_request_query(type, name, len TSRMLS_CC); \
if (ZVAL_IS_NULL(ret)) { \
if (def != NULL) { \
zval_ptr_dtor(&ret); \
RETURN_ZVAL(def, 1, 0); \
} \
} \
} \
RETURN_ZVAL(ret, 1, 1); \
}
extern zend_class_entry * yaf_request_ce;
zval * yaf_request_query(uint type, char * name, uint len TSRMLS_DC);
yaf_request_t * yaf_request_instance(yaf_request_t *this_ptr, char *info TSRMLS_DC);
int yaf_request_set_base_uri(yaf_request_t *request, char *base_uri, char *request_uri TSRMLS_DC);
PHPAPI void php_session_start(TSRMLS_D);
zval * yaf_request_get_method(yaf_request_t *instance TSRMLS_DC);
zval * yaf_request_get_param(yaf_request_t *instance, char *key, int len TSRMLS_DC);
zval * yaf_request_get_language(yaf_request_t *instance TSRMLS_DC);
int yaf_request_is_routed(yaf_request_t *request TSRMLS_DC);
int yaf_request_is_dispatched(yaf_request_t *request TSRMLS_DC);
int yaf_request_set_dispatched(yaf_request_t *request, int flag TSRMLS_DC);
int yaf_request_set_routed(yaf_request_t *request, int flag TSRMLS_DC);
int yaf_request_set_params_single(yaf_request_t *instance, char *key, int len, zval *value TSRMLS_DC);
int yaf_request_set_params_multi(yaf_request_t *instance, zval *values TSRMLS_DC);
YAF_STARTUP_FUNCTION(request);
#endif
/*
* Local variables:
* tab-width: 4
* c-basic-offset: 4
* End:
* vim600: noet sw=4 ts=4 fdm=marker
* vim<600: noet sw=4 ts=4
*/