2525#endif
2626
2727#include "php.h"
28- #include "php_recode.h"
2928#include "php_streams.h"
3029
3130#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"
3631
37-
38- #ifdef HAVE_BROKEN_RECODE
32+ /* For recode 3.5 */
3933extern char * program_name ;
4034char * program_name = "php" ;
35+
36+ #ifdef HAVE_STDBOOL_H
37+ # include <stdbool.h>
38+ #else
39+ typedef enum {false = 0 , true = 1 } bool ;
4140#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+
4252/* }}} */
4353
44- #define SAFE_STRING (s ) ((s)?(s):"")
54+ ZEND_BEGIN_MODULE_GLOBALS (recode )
55+ RECODE_OUTER outer ;
56+ ZEND_END_MODULE_GLOBALS (recode )
4557
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+
4664ZEND_DECLARE_MODULE_GLOBALS (recode );
47- extern int le_fp ,le_pp ;
4865
4966/* {{{ module stuff */
5067static zend_function_entry php_recode_functions [] = {
@@ -55,22 +72,18 @@ static zend_function_entry php_recode_functions[] = {
5572};
5673
5774zend_module_entry recode_module_entry = {
58- STANDARD_MODULE_HEADER ,
75+ STANDARD_MODULE_HEADER ,
5976 "recode" ,
60- php_recode_functions ,
77+ php_recode_functions ,
6178 PHP_MINIT (recode ),
6279 PHP_MSHUTDOWN (recode ),
6380 NULL ,
6481 NULL ,
6582 PHP_MINFO (recode ),
66- NO_VERSION_YET ,
83+ NO_VERSION_YET ,
6784 STANDARD_MODULE_PROPERTIES
6885};
6986
70- #if APACHE
71- extern void timeout (int sig );
72- #endif
73-
7487#ifdef COMPILE_DL_RECODE
7588ZEND_GET_MODULE (recode )
7689#endif
@@ -84,14 +97,14 @@ PHP_MINIT_FUNCTION(recode)
8497{
8598 ZEND_INIT_MODULE_GLOBALS (recode , php_recode_init_globals , NULL );
8699
87- ReSG (outer ) = recode_new_outer (true );
88- if (ReSG (outer ) == NULL )
100+ ReSG (outer ) = recode_new_outer (false );
101+ if (ReSG (outer ) == NULL ) {
89102 return FAILURE ;
90-
103+ }
104+
91105 return SUCCESS ;
92106}
93107
94-
95108PHP_MSHUTDOWN_FUNCTION (recode )
96109{
97110 if (ReSG (outer )) {
@@ -100,36 +113,33 @@ PHP_MSHUTDOWN_FUNCTION(recode)
100113 return SUCCESS ;
101114}
102115
103-
104116PHP_MINFO_FUNCTION (recode )
105117{
106118 php_info_print_table_start ();
107119 php_info_print_table_row (2 , "Recode Support" , "enabled" );
108120 php_info_print_table_row (2 , "Revision" , "$Revision$" );
109121 php_info_print_table_end ();
110-
111122}
112123
113124/* {{{ proto string recode_string(string request, string str)
114125 Recode string str according to request string */
115-
116126PHP_FUNCTION (recode_string )
117127{
118128 RECODE_REQUEST request = NULL ;
119129 char * r = NULL ;
120- pval * * str ;
121- pval * * req ;
130+ zval * * str ;
131+ zval * * req ;
122132 bool success ;
123133 int r_len = 0 , r_alen = 0 ;
124134
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 ;
128137 }
129138 convert_to_string_ex (str );
130139 convert_to_string_ex (req );
131140
132141 request = recode_new_request (ReSG (outer ));
142+
133143 if (request == NULL ) {
134144 php_error (E_WARNING , "Cannot allocate request structure" );
135145 RETURN_FALSE ;
@@ -168,20 +178,17 @@ PHP_FUNCTION(recode_file)
168178{
169179 RECODE_REQUEST request = NULL ;
170180 int success ;
171- pval * * req ;
172- pval * * input , * * output ;
181+ zval * * req ;
182+ zval * * input , * * output ;
173183 php_stream * instream , * outstream ;
174184 FILE * in_fp , * out_fp ;
175185 int in_type , out_type ;
176186
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 ) {
180188 WRONG_PARAM_COUNT ;
181189 }
182190
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 ());
185192
186193 if (!instream ) {
187194 php_error (E_WARNING ,"Unable to find input file identifier" );
@@ -192,8 +199,7 @@ PHP_FUNCTION(recode_file)
192199 RETURN_FALSE ;
193200 }
194201
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 ());
197203 if (!outstream ) {
198204 php_error (E_WARNING ,"Unable to find output file identifier" );
199205 RETURN_FALSE ;
0 commit comments