-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathphp_uri_template.h
90 lines (73 loc) · 2.72 KB
/
php_uri_template.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
/*
+----------------------------------------------------------------------+
| See LICENSE file for further copyright information |
+----------------------------------------------------------------------+
| Authors: Ioseb Dzmanashvili <[email protected]> |
+----------------------------------------------------------------------+
*/
#ifndef PHP_URI_TEMPLATE_H
#define PHP_URI_TEMPLATE_H
#define PHP_URI_TEMPLATE_EXTNAME "uri_template"
#define PHP_URI_TEMPLATE_VERSION "1.0"
#define URI_TEMPLATE_ERROR_NONE 0
#define URI_TEMPLATE_ERROR 1
#define URI_TEMPLATE_ERROR_SYNTAX 2
#define URI_TEMPLATE_ERROR_EXPRESSION 3
#define URI_TEMPLATE_ALLOW_UNRESERVED 0
#define URI_TEMPLATE_ALLOW_LITERALS 1
#define URI_TEMPLATE_ALLOW_RESERVED 2
#ifdef HAVE_CONFIG_H
#include "config.h"
#endif
#include "SAPI.h"
#include "zend_API.h"
#include "php.h"
#include "php_ini.h"
#include "ext/standard/info.h"
#include "ext/standard/php_string.h"
#include "ext/standard/php_smart_str.h"
#include "ext/standard/html.h"
#include "php_variables.h"
extern zend_module_entry uri_template_module_entry;
#define phpext_uri_template_ptr &uri_template_module_entry;
#ifdef ZTS
#include "TSRM.h"
#endif
PHP_FUNCTION(uri_template);
typedef struct uri_template_var {
struct uri_template_var *next;
char *name;
int length;
int explode;
} uri_template_var;
typedef struct uri_template_vars {
uri_template_var *first;
uri_template_var *last;
int count;
} uri_template_vars;
typedef struct uri_template_expr {
char op; /* operator */
char first; /* result prefix */
char sep; /* variable separator */
char ifemp; /* if value is empty */
int allow; /* allow reserved chars */
int named; /* var is named */
int error; /* expression is malformed */
uri_template_vars *vars; /* list of expression vars */
} uri_template_expr;
uri_template_vars *uri_template_vars_create();
uri_template_var *uri_template_var_create();
uri_template_expr *uri_template_expr_create(char operator);
void uri_template_vars_free(uri_template_vars *list);
void uri_template_var_free(uri_template_var *var);
void uri_template_expr_add_var(uri_template_expr *expr, uri_template_var *var);
void uri_template_expr_free(uri_template_expr *expr);
void uri_template_parse(char *tpl, zval *return_value, zval *vars, zval *capture);
void uri_template_process(uri_template_expr *expr, zval *vars, smart_str *result);
void uri_template_substr_copy(smart_str *dest, char *source, size_t num, int allowed_chars);
#ifdef ZTS
#define IF_G(v) TSRMG(filter_globals_id, zend_filter_globals *, v)
#else
#define IF_G(v) (filter_globals.v)
#endif
#endif