summaryrefslogtreecommitdiff
path: root/ext/recode
diff options
context:
space:
mode:
authorfoobar <sniper@php.net>2002-04-24 12:45:55 +0000
committerfoobar <sniper@php.net>2002-04-24 12:45:55 +0000
commit712c85eddc88fe05d4cd453c10fd19fdf692a451 (patch)
tree14dc1fda1a041f2bbfb5e19aa4fb8650d82782e4 /ext/recode
parent1259f0c24ab9cfffe2fe922c8052320cfb3a6353 (diff)
downloadphp-git-712c85eddc88fe05d4cd453c10fd19fdf692a451.tar.gz
One big mess is a bit less mess now.
Diffstat (limited to 'ext/recode')
-rw-r--r--ext/recode/config.m495
-rw-r--r--ext/recode/php_recode.h45
-rw-r--r--ext/recode/recode.c80
3 files changed, 84 insertions, 136 deletions
diff --git a/ext/recode/config.m4 b/ext/recode/config.m4
index 82741018cf..fc134ffc77 100644
--- a/ext/recode/config.m4
+++ b/ext/recode/config.m4
@@ -5,59 +5,42 @@ dnl
PHP_ARG_WITH(recode,for recode support,
[ --with-recode[=DIR] Include recode support.])
- if test "$PHP_RECODE" != "no"; then
- RECODE_LIST="$PHP_RECODE /usr /usr/local /opt"
-
- for i in $RECODE_LIST; do
- if test -f $i/include/recode.h; then
- RECODE_DIR=$i
- RECODE_INC=include
- RECODE_LIB=lib
- fi
- if test -f $i/include/recode/recode.h; then
- RECODE_DIR=$i
- RECODE_INC=include/recode
- RECODE_LIB=lib/recode
- fi
- if test -f $i/recode/include/recode.h; then
- RECODE_DIR=$i/recode
- RECODE_INC=include
- RECODE_LIB=lib
- fi
- done
- if test "$RECODE_DIR" = ""; then
- AC_MSG_ERROR(I cannot find recode.h anywhere below $RECODE_LIST. Is it installed?)
- fi
-
- old_LDFLAGS=$LDFLAGS
- old_LIBS=$LIBS
- LDFLAGS="$LDFLAGS -L$RECODE_DIR/$RECODE_LIB"
- LIBS="$LIBS -lrecode"
- AC_TRY_LINK([
-char *program_name;
-],[
-recode_format_table();
-],[],[
- AC_MSG_ERROR(I cannot link librecode (-L$RECODE_DIR/$RECODE_LIB -lrecode). Is it installed?)
-])
- LIBS=$old_LIBS
- LDFLAGS=$old_LDFLAGS
-
- if test "$RECODE_LIB" = ""; then
- AC_MSG_ERROR(Please reinstall recode - I cannot find librecode.a)
- fi
-
- PHP_ADD_INCLUDE($RECODE_DIR/$RECODE_INC)
- if test "$ext_shared" = "yes"; then
- PHP_ADD_LIBRARY_WITH_PATH(recode, $RECODE_DIR/$RECODE_LIB, RECODE_SHARED_LIBADD)
- PHP_SUBST(RECODE_SHARED_LIBADD)
- else
- PHP_ADD_LIBRARY_DEFER_WITH_PATH(recode, $RECODE_DIR/$RECODE_LIB)
- fi
-
- AC_DEFINE(HAVE_LIBRECODE, 1, [Whether we have librecode 3.5 or higher])
-
- AC_CHECK_HEADERS(stdbool.h)
-
- PHP_NEW_EXTENSION(recode, recode.c, $ext_shared)
- fi
+if test "$PHP_RECODE" != "no"; then
+ RECODE_LIST="$PHP_RECODE /usr /usr/local /opt"
+
+ for i in $RECODE_LIST; do
+ if test -f $i/include/recode.h; then
+ RECODE_DIR=$i
+ RECODE_INC=include
+ RECODE_LIB=lib
+ fi
+ if test -f $i/include/recode/recode.h; then
+ RECODE_DIR=$i
+ RECODE_INC=include/recode
+ RECODE_LIB=lib/recode
+ fi
+ if test -f $i/recode/include/recode.h; then
+ RECODE_DIR=$i/recode
+ RECODE_INC=include
+ RECODE_LIB=lib
+ fi
+ done
+
+ if test -z "$RECODE_DIR"; then
+ AC_MSG_ERROR([Can not find recode.h anywhere under $RECODE_LIST.])
+ fi
+
+ PHP_CHECK_LIBRARY(recode, recode_format_table, [
+ AC_DEFINE(HAVE_LIBRECODE, 1, [Whether we have librecode 3.5 or higher])
+ ], [
+ AC_MSG_ERROR(I cannot link librecode (-L$RECODE_DIR/$RECODE_LIB -lrecode). Is it installed?)
+ ], [
+ -L$RECODE_DIR/$RECODE_LIB
+ ])
+
+ PHP_ADD_INCLUDE($RECODE_DIR/$RECODE_INC)
+ PHP_ADD_LIBRARY_WITH_PATH(recode, $RECODE_DIR/$RECODE_LIB, RECODE_SHARED_LIBADD)
+ PHP_SUBST(RECODE_SHARED_LIBADD)
+ AC_CHECK_HEADERS(stdbool.h)
+ PHP_NEW_EXTENSION(recode, recode.c, $ext_shared)
+fi
diff --git a/ext/recode/php_recode.h b/ext/recode/php_recode.h
index dcdf4fd024..0fc86256e1 100644
--- a/ext/recode/php_recode.h
+++ b/ext/recode/php_recode.h
@@ -14,67 +14,26 @@
+----------------------------------------------------------------------+
| Author: Kristian Koehntopp <kris@koehntopp.de> |
+----------------------------------------------------------------------+
- */
-
+*/
/* $Id$ */
#ifndef PHP_RECODE_H
#define PHP_RECODE_H
-#ifdef PHP_WIN32
-#define PHP_MYSQL_API __declspec(dllexport)
-#else
-#define PHP_MYSQL_API
-#endif
-
#if HAVE_LIBRECODE
-/* Checking for thread safety and issue warning if necessary. */
-#ifdef ZTS
-#warning Recode module has not been tested for thread-safety.
-#endif
-
-/* Recode 3.5 is broken in the sense that it requires the definition
- * of a symbol "program_name" in order to link.
- */
-#define HAVE_BROKEN_RECODE
-
-#ifdef HAVE_STDBOOL_H
-# include <stdbool.h>
-#else
- typedef enum {false = 0, true = 1} bool;
-#endif
-
-#include <sys/types.h>
-#include <stdio.h>
-#include <recode.h>
-#include <unistd.h>
-
extern zend_module_entry recode_module_entry;
#define phpext_recode_ptr &recode_module_entry
PHP_MINIT_FUNCTION(recode);
PHP_MSHUTDOWN_FUNCTION(recode);
PHP_MINFO_FUNCTION(recode);
-
PHP_FUNCTION(recode_string);
PHP_FUNCTION(recode_file);
-#ifdef ZTS
-#include "TSRM.h"
-#endif
-
-ZEND_BEGIN_MODULE_GLOBALS(recode)
- RECODE_OUTER outer;
-ZEND_END_MODULE_GLOBALS(recode)
-
-#ifdef ZTS
-#define ReSG(v) TSRMG(recode_globals_id, zend_recode_globals *, v)
#else
-#define ReSG(v) (recode_globals.v)
-#endif
-
+#define phpext_recode_ptr NULL
#endif
#endif /* PHP_RECODE_H */
diff --git a/ext/recode/recode.c b/ext/recode/recode.c
index 8c17b5f76c..cb91166012 100644
--- a/ext/recode/recode.c
+++ b/ext/recode/recode.c
@@ -25,26 +25,43 @@
#endif
#include "php.h"
-#include "php_recode.h"
#include "php_streams.h"
#if HAVE_LIBRECODE
-#include "ext/standard/info.h"
-#include "ext/standard/file.h"
-#include "ext/standard/php_string.h"
-#include "zend_list.h"
-
-#ifdef HAVE_BROKEN_RECODE
+/* For recode 3.5 */
extern char *program_name;
char *program_name = "php";
+
+#ifdef HAVE_STDBOOL_H
+# include <stdbool.h>
+#else
+ typedef enum {false = 0, true = 1} bool;
#endif
+
+#include <stdio.h>
+#include <sys/types.h>
+#include <unistd.h>
+#include <recode.h>
+
+#include "php_recode.h"
+#include "ext/standard/info.h"
+#include "ext/standard/file.h"
+#include "ext/standard/php_string.h"
+
/* }}} */
-#define SAFE_STRING(s) ((s)?(s):"")
+ZEND_BEGIN_MODULE_GLOBALS(recode)
+ RECODE_OUTER outer;
+ZEND_END_MODULE_GLOBALS(recode)
+#ifdef ZTS
+# define ReSG(v) TSRMG(recode_globals_id, zend_recode_globals *, v)
+#else
+# define ReSG(v) (recode_globals.v)
+#endif
+
ZEND_DECLARE_MODULE_GLOBALS(recode);
-extern int le_fp,le_pp;
/* {{{ module stuff */
static zend_function_entry php_recode_functions[] = {
@@ -55,22 +72,18 @@ static zend_function_entry php_recode_functions[] = {
};
zend_module_entry recode_module_entry = {
- STANDARD_MODULE_HEADER,
+ STANDARD_MODULE_HEADER,
"recode",
- php_recode_functions,
+ php_recode_functions,
PHP_MINIT(recode),
PHP_MSHUTDOWN(recode),
NULL,
NULL,
PHP_MINFO(recode),
- NO_VERSION_YET,
+ NO_VERSION_YET,
STANDARD_MODULE_PROPERTIES
};
-#if APACHE
-extern void timeout(int sig);
-#endif
-
#ifdef COMPILE_DL_RECODE
ZEND_GET_MODULE(recode)
#endif
@@ -84,14 +97,14 @@ PHP_MINIT_FUNCTION(recode)
{
ZEND_INIT_MODULE_GLOBALS(recode, php_recode_init_globals, NULL);
- ReSG(outer) = recode_new_outer(true);
- if (ReSG(outer) == NULL)
+ ReSG(outer) = recode_new_outer(false);
+ if (ReSG(outer) == NULL) {
return FAILURE;
-
+ }
+
return SUCCESS;
}
-
PHP_MSHUTDOWN_FUNCTION(recode)
{
if (ReSG(outer)) {
@@ -100,36 +113,33 @@ PHP_MSHUTDOWN_FUNCTION(recode)
return SUCCESS;
}
-
PHP_MINFO_FUNCTION(recode)
{
php_info_print_table_start();
php_info_print_table_row(2, "Recode Support", "enabled");
php_info_print_table_row(2, "Revision", "$Revision$");
php_info_print_table_end();
-
}
/* {{{ proto string recode_string(string request, string str)
Recode string str according to request string */
-
PHP_FUNCTION(recode_string)
{
RECODE_REQUEST request = NULL;
char *r = NULL;
- pval **str;
- pval **req;
+ zval **str;
+ zval **req;
bool success;
int r_len=0, r_alen =0;
- if (ZEND_NUM_ARGS() != 2
- || zend_get_parameters_ex(2, &req, &str) == FAILURE) {
- WRONG_PARAM_COUNT;
+ if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &req, &str) == FAILURE) {
+ WRONG_PARAM_COUNT;
}
convert_to_string_ex(str);
convert_to_string_ex(req);
request = recode_new_request(ReSG(outer));
+
if (request == NULL) {
php_error(E_WARNING, "Cannot allocate request structure");
RETURN_FALSE;
@@ -168,20 +178,17 @@ PHP_FUNCTION(recode_file)
{
RECODE_REQUEST request = NULL;
int success;
- pval **req;
- pval **input, **output;
+ zval **req;
+ zval **input, **output;
php_stream *instream, *outstream;
FILE *in_fp, *out_fp;
int in_type, out_type;
-
- if (ZEND_NUM_ARGS() != 3
- || zend_get_parameters_ex(3, &req, &input, &output) == FAILURE) {
+ if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &req, &input, &output) == FAILURE) {
WRONG_PARAM_COUNT;
}
- instream = zend_fetch_resource(input TSRMLS_CC,-1, "File-Handle", &in_type,
- 1, php_file_le_stream());
+ instream = zend_fetch_resource(input TSRMLS_CC,-1, "File-Handle", &in_type, 1, php_file_le_stream());
if (!instream) {
php_error(E_WARNING,"Unable to find input file identifier");
@@ -192,8 +199,7 @@ PHP_FUNCTION(recode_file)
RETURN_FALSE;
}
- outstream = zend_fetch_resource(output TSRMLS_CC,-1, "File-Handle", &out_type,
- 1, php_file_le_stream());
+ outstream = zend_fetch_resource(output TSRMLS_CC,-1, "File-Handle", &out_type, 1, php_file_le_stream());
if (!outstream) {
php_error(E_WARNING,"Unable to find output file identifier");
RETURN_FALSE;