25
25
#endif
26
26
27
27
#include "php.h"
28
- #include "php_recode.h"
29
28
#include "php_streams.h"
30
29
31
30
#if HAVE_LIBRECODE
32
- #include "ext/standard/info.h"
33
- #include "ext/standard/file.h"
34
- #include "ext/standard/php_string.h"
35
- #include "zend_list.h"
36
31
37
-
38
- #ifdef HAVE_BROKEN_RECODE
32
+ /* For recode 3.5 */
39
33
extern char * program_name ;
40
34
char * program_name = "php" ;
35
+
36
+ #ifdef HAVE_STDBOOL_H
37
+ # include <stdbool.h>
38
+ #else
39
+ typedef enum {false = 0 , true = 1 } bool ;
41
40
#endif
41
+
42
+ #include <stdio.h>
43
+ #include <sys/types.h>
44
+ #include <unistd.h>
45
+ #include <recode.h>
46
+
47
+ #include "php_recode.h"
48
+ #include "ext/standard/info.h"
49
+ #include "ext/standard/file.h"
50
+ #include "ext/standard/php_string.h"
51
+
42
52
/* }}} */
43
53
44
- #define SAFE_STRING (s ) ((s)?(s):"")
54
+ ZEND_BEGIN_MODULE_GLOBALS (recode )
55
+ RECODE_OUTER outer ;
56
+ ZEND_END_MODULE_GLOBALS (recode )
45
57
58
+ #ifdef ZTS
59
+ # define ReSG (v ) TSRMG(recode_globals_id, zend_recode_globals *, v)
60
+ #else
61
+ # define ReSG (v ) (recode_globals.v)
62
+ #endif
63
+
46
64
ZEND_DECLARE_MODULE_GLOBALS (recode );
47
- extern int le_fp ,le_pp ;
48
65
49
66
/* {{{ module stuff */
50
67
static zend_function_entry php_recode_functions [] = {
@@ -55,22 +72,18 @@ static zend_function_entry php_recode_functions[] = {
55
72
};
56
73
57
74
zend_module_entry recode_module_entry = {
58
- STANDARD_MODULE_HEADER ,
75
+ STANDARD_MODULE_HEADER ,
59
76
"recode" ,
60
- php_recode_functions ,
77
+ php_recode_functions ,
61
78
PHP_MINIT (recode ),
62
79
PHP_MSHUTDOWN (recode ),
63
80
NULL ,
64
81
NULL ,
65
82
PHP_MINFO (recode ),
66
- NO_VERSION_YET ,
83
+ NO_VERSION_YET ,
67
84
STANDARD_MODULE_PROPERTIES
68
85
};
69
86
70
- #if APACHE
71
- extern void timeout (int sig );
72
- #endif
73
-
74
87
#ifdef COMPILE_DL_RECODE
75
88
ZEND_GET_MODULE (recode )
76
89
#endif
@@ -84,14 +97,14 @@ PHP_MINIT_FUNCTION(recode)
84
97
{
85
98
ZEND_INIT_MODULE_GLOBALS (recode , php_recode_init_globals , NULL );
86
99
87
- ReSG (outer ) = recode_new_outer (true );
88
- if (ReSG (outer ) == NULL )
100
+ ReSG (outer ) = recode_new_outer (false );
101
+ if (ReSG (outer ) == NULL ) {
89
102
return FAILURE ;
90
-
103
+ }
104
+
91
105
return SUCCESS ;
92
106
}
93
107
94
-
95
108
PHP_MSHUTDOWN_FUNCTION (recode )
96
109
{
97
110
if (ReSG (outer )) {
@@ -100,36 +113,33 @@ PHP_MSHUTDOWN_FUNCTION(recode)
100
113
return SUCCESS ;
101
114
}
102
115
103
-
104
116
PHP_MINFO_FUNCTION (recode )
105
117
{
106
118
php_info_print_table_start ();
107
119
php_info_print_table_row (2 , "Recode Support" , "enabled" );
108
120
php_info_print_table_row (2 , "Revision" , "$Revision$" );
109
121
php_info_print_table_end ();
110
-
111
122
}
112
123
113
124
/* {{{ proto string recode_string(string request, string str)
114
125
Recode string str according to request string */
115
-
116
126
PHP_FUNCTION (recode_string )
117
127
{
118
128
RECODE_REQUEST request = NULL ;
119
129
char * r = NULL ;
120
- pval * * str ;
121
- pval * * req ;
130
+ zval * * str ;
131
+ zval * * req ;
122
132
bool success ;
123
133
int r_len = 0 , r_alen = 0 ;
124
134
125
- if (ZEND_NUM_ARGS () != 2
126
- || zend_get_parameters_ex (2 , & req , & str ) == FAILURE ) {
127
- WRONG_PARAM_COUNT ;
135
+ if (ZEND_NUM_ARGS () != 2 || zend_get_parameters_ex (2 , & req , & str ) == FAILURE ) {
136
+ WRONG_PARAM_COUNT ;
128
137
}
129
138
convert_to_string_ex (str );
130
139
convert_to_string_ex (req );
131
140
132
141
request = recode_new_request (ReSG (outer ));
142
+
133
143
if (request == NULL ) {
134
144
php_error (E_WARNING , "Cannot allocate request structure" );
135
145
RETURN_FALSE ;
@@ -168,20 +178,17 @@ PHP_FUNCTION(recode_file)
168
178
{
169
179
RECODE_REQUEST request = NULL ;
170
180
int success ;
171
- pval * * req ;
172
- pval * * input , * * output ;
181
+ zval * * req ;
182
+ zval * * input , * * output ;
173
183
php_stream * instream , * outstream ;
174
184
FILE * in_fp , * out_fp ;
175
185
int in_type , out_type ;
176
186
177
-
178
- if (ZEND_NUM_ARGS () != 3
179
- || zend_get_parameters_ex (3 , & req , & input , & output ) == FAILURE ) {
187
+ if (ZEND_NUM_ARGS () != 3 || zend_get_parameters_ex (3 , & req , & input , & output ) == FAILURE ) {
180
188
WRONG_PARAM_COUNT ;
181
189
}
182
190
183
- instream = zend_fetch_resource (input TSRMLS_CC ,-1 , "File-Handle" , & in_type ,
184
- 1 , php_file_le_stream ());
191
+ instream = zend_fetch_resource (input TSRMLS_CC ,-1 , "File-Handle" , & in_type , 1 , php_file_le_stream ());
185
192
186
193
if (!instream ) {
187
194
php_error (E_WARNING ,"Unable to find input file identifier" );
@@ -192,8 +199,7 @@ PHP_FUNCTION(recode_file)
192
199
RETURN_FALSE ;
193
200
}
194
201
195
- outstream = zend_fetch_resource (output TSRMLS_CC ,-1 , "File-Handle" , & out_type ,
196
- 1 , php_file_le_stream ());
202
+ outstream = zend_fetch_resource (output TSRMLS_CC ,-1 , "File-Handle" , & out_type , 1 , php_file_le_stream ());
197
203
if (!outstream ) {
198
204
php_error (E_WARNING ,"Unable to find output file identifier" );
199
205
RETURN_FALSE ;
0 commit comments