Browse Source
- Added additional DEFER macro.
- Added additional DEFER macro.
- First stab at porting the recode module. Still having problems with the _ex() functions, they core - why?PHP-4.0.5
6 changed files with 362 additions and 1 deletions
-
12acinclude.m4
-
10ext/recode/Makefile.in
-
65ext/recode/config.m4
-
89ext/recode/php_recode.h
-
184ext/recode/recode.c
-
3ext/recode/setup.stub
@ -0,0 +1,10 @@ |
|||
|
|||
DEPTH = ../.. |
|||
topsrcdir = @topsrcdir@ |
|||
srcdir = @srcdir@ |
|||
VPATH = @srcdir@ |
|||
|
|||
LTLIBRARY_NAME = librecode.la |
|||
LTLIBRARY_SOURCES = recode.c |
|||
|
|||
include $(topsrcdir)/build/ltlib.mk |
|||
@ -0,0 +1,65 @@ |
|||
dnl $Id$ |
|||
dnl config.m4 for extension recode |
|||
dnl don't forget to call PHP_EXTENSION(recode) |
|||
|
|||
|
|||
AC_MSG_CHECKING(for recode support) |
|||
AC_ARG_WITH(recode, |
|||
[ --with-recode[=DIR] Include recode support. DIR is the recode |
|||
install directory.], |
|||
[ |
|||
if test "$withval" != "no"; then |
|||
RECODE_LIST="$withval /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 |
|||
|
|||
AC_ADD_INCLUDE($RECODE_DIR/$RECODE_INC) |
|||
AC_ADD_LIBRARY_DEFER_WITH_PATH(recode, $RECODE_DIR/$RECODE_LIB) |
|||
|
|||
AC_MSG_RESULT(yes) |
|||
|
|||
AC_DEFINE(HAVE_LIBRECODE, 1, [Whether we have librecode 3.5 or higher]) |
|||
PHP_EXTENSION(recode) |
|||
else |
|||
AC_MSG_RESULT(no) |
|||
fi |
|||
],[ |
|||
AC_MSG_RESULT(no) |
|||
]) |
|||
@ -0,0 +1,89 @@ |
|||
/* |
|||
+----------------------------------------------------------------------+ |
|||
| PHP version 4.0 | |
|||
+----------------------------------------------------------------------+ |
|||
| Copyright (c) 1997, 1998, 1999, 2000 The PHP Group | |
|||
+----------------------------------------------------------------------+ |
|||
| This source file is subject to version 2.01 of the PHP license, | |
|||
| that is bundled with this package in the file LICENSE, and is | |
|||
| available at through the world-wide-web at | |
|||
| http://www.php.net/license/2_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 | |
|||
| license@php.net so we can mail you a copy immediately. | |
|||
+----------------------------------------------------------------------+ |
|||
| Authors: Kristian Koehntopp (kris@koehntopp.de) | |
|||
+----------------------------------------------------------------------+ |
|||
*/ |
|||
|
|||
|
|||
/* $Id$ */ |
|||
|
|||
#ifndef _PHP_RECODE_H |
|||
#define _PHP_RECODE_H |
|||
|
|||
#ifdef COMPILE_DL_RECODE |
|||
#undef HAVE_LIBRECODE |
|||
#define HAVE_LIBRECODE 1 |
|||
#endif |
|||
|
|||
#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 |
|||
|
|||
#include <stdbool.h> |
|||
#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 |
|||
|
|||
extern PHP_MINIT_FUNCTION(recode); |
|||
extern PHP_MSHUTDOWN_FUNCTION(recode); |
|||
extern PHP_MINFO_FUNCTION(recode); |
|||
|
|||
extern PHP_FUNCTION(recode_string); |
|||
extern PHP_FUNCTION(recode_file); |
|||
|
|||
typedef struct { |
|||
RECODE_OUTER outer; |
|||
} php_recode_globals; |
|||
|
|||
#ifdef ZTS |
|||
# define ReSLS_D php_recode_globals *recode_globals |
|||
# define ReSLS_DC , ReSLS_D |
|||
# define ReSLS_C recode_globals |
|||
# define ReSLS_CC , ReSLS_C |
|||
# define ReSG(v) (recode_globals->v) |
|||
# define ReSLS_FETCH() php_recode_globals *recode_globals = ts_resource(recode_globals_id) |
|||
#else |
|||
# define ReSLS_D |
|||
# define ReSLS_DC |
|||
# define ReSLS_C |
|||
# define ReSLS_CC |
|||
# define ReSG(v) (recode_globals.v) |
|||
# define ReSLS_FETCH() |
|||
extern PHP_MYSQL_API php_recode_globals recode_globals; |
|||
#endif |
|||
|
|||
#else |
|||
#define phpext_recode_ptr NULL |
|||
#endif |
|||
|
|||
#endif /* _PHP_RECODE_H */ |
|||
@ -0,0 +1,184 @@ |
|||
/* |
|||
+----------------------------------------------------------------------+ |
|||
| PHP version 4.0 | |
|||
+----------------------------------------------------------------------+ |
|||
| Copyright (c) 1997, 1998, 1999, 2000 The PHP Group | |
|||
+----------------------------------------------------------------------+ |
|||
| This source file is subject to version 2.01 of the PHP license, | |
|||
| that is bundled with this package in the file LICENSE, and is | |
|||
| available at through the world-wide-web at | |
|||
| http://www.php.net/license/2_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 | |
|||
| license@php.net so we can mail you a copy immediately. | |
|||
+----------------------------------------------------------------------+ |
|||
| Authors: Kristian Koehntopp (kris@koehntopp.de) | |
|||
+----------------------------------------------------------------------+ |
|||
*/ |
|||
|
|||
/* $Id$ */ |
|||
|
|||
/* {{{ includes & prototypes */ |
|||
|
|||
#include "php.h" |
|||
#include "php_recode.h" |
|||
|
|||
#if HAVE_LIBRECODE |
|||
#include "ext/standard/info.h" |
|||
#include "ext/standard/php_string.h" |
|||
#include "zend_list.h" |
|||
|
|||
#ifdef HAVE_BROKEN_RECODE |
|||
extern char *program_name; |
|||
char *program_name = "php"; |
|||
#endif |
|||
|
|||
/* }}} */ |
|||
|
|||
#define SAFE_STRING(s) ((s)?(s):"") |
|||
|
|||
php_recode_globals recode_globals; |
|||
extern int le_fp,le_pp; |
|||
|
|||
/* {{{ module stuff */ |
|||
static zend_function_entry php_recode_functions[] = { |
|||
PHP_FE(recode_string, NULL) |
|||
PHP_FE(recode_file, NULL) |
|||
PHP_FALIAS(recode, recode_string, NULL) |
|||
{NULL, NULL, NULL} |
|||
}; |
|||
|
|||
zend_module_entry recode_module_entry = { |
|||
"Recode", |
|||
php_recode_functions, |
|||
PHP_MINIT(recode), |
|||
PHP_MSHUTDOWN(recode), |
|||
NULL, |
|||
NULL, |
|||
PHP_MINFO(recode), |
|||
STANDARD_MODULE_PROPERTIES |
|||
}; |
|||
|
|||
#if APACHE |
|||
extern void timeout(int sig); |
|||
#endif |
|||
|
|||
PHP_MINIT_FUNCTION(recode) |
|||
{ |
|||
ReSLS_FETCH(); |
|||
ReSG(outer) = recode_new_outer(true); |
|||
if (ReSG(outer) == NULL) |
|||
return FAILURE; |
|||
|
|||
return SUCCESS; |
|||
} |
|||
|
|||
|
|||
PHP_MSHUTDOWN_FUNCTION(recode) |
|||
{ |
|||
ReSLS_FETCH(); |
|||
|
|||
if (ReSG(outer)) |
|||
recode_delete_outer(ReSG(outer)); |
|||
|
|||
return SUCCESS; |
|||
} |
|||
|
|||
|
|||
PHP_MINFO_FUNCTION(recode) |
|||
{ |
|||
ReSLS_FETCH(); |
|||
|
|||
php_printf("<table border=5 width=\"600\">"); |
|||
php_info_print_table_header(1, "Module Revision"); |
|||
php_info_print_table_row(1, "$Revision$"); |
|||
php_printf("</table>\n"); |
|||
} |
|||
|
|||
/* {{{ proto string recode_string(string request, string str) |
|||
Recode string str according to request string */ |
|||
|
|||
PHP_FUNCTION(recode_string) |
|||
{ |
|||
/* All of this cores in zend_get_parameters_ex()... |
|||
|
|||
RECODE_REQUEST request = NULL; |
|||
pval **str; |
|||
pval **req; |
|||
char *r; |
|||
bool success; |
|||
|
|||
ReSLS_FETCH(); |
|||
if (ARG_COUNT(ht) != 2 |
|||
|| zend_get_parameters_ex(ht, 2, &req, &str) == FAILURE) { |
|||
WRONG_PARAM_COUNT; |
|||
} |
|||
convert_to_string_ex(str); |
|||
convert_to_string_ex(req); |
|||
*/ |
|||
|
|||
RECODE_REQUEST request = NULL; |
|||
char *r = NULL; |
|||
pval *str; |
|||
pval *req; |
|||
bool success; |
|||
|
|||
ReSLS_FETCH(); |
|||
if (ARG_COUNT(ht) != 2 |
|||
|| zend_get_parameters(ht, 2, &req, &str) == FAILURE) { |
|||
WRONG_PARAM_COUNT; |
|||
} |
|||
convert_to_string(str); |
|||
convert_to_string(req); |
|||
|
|||
request = recode_new_request(ReSG(outer)); |
|||
if (request == NULL) { |
|||
php_error(E_WARNING, "Cannot allocate request structure"); |
|||
RETURN_FALSE; |
|||
} |
|||
|
|||
success = recode_scan_request(request, req->value.str.val); |
|||
if (!success) { |
|||
php_error(E_WARNING, "Illegal recode request '%s'", req->value.str.val); |
|||
goto error_exit; |
|||
} |
|||
|
|||
r = recode_string(request, str->value.str.val); |
|||
if (!r) { |
|||
php_error(E_WARNING, "Recoding failed."); |
|||
goto error_exit; |
|||
} |
|||
|
|||
RETVAL_STRING(r, 1); |
|||
free(r); |
|||
/* FALLTHROUGH */ |
|||
|
|||
error_exit: |
|||
if (request) |
|||
recode_delete_request(request); |
|||
|
|||
if (!r) |
|||
RETURN_FALSE; |
|||
|
|||
return; |
|||
} |
|||
/* }}} */ |
|||
|
|||
/* {{{ proto bool recode_file(string request, int input, int output) |
|||
Recode file input into file output according to request */ |
|||
PHP_FUNCTION(recode_file) |
|||
{ |
|||
php_error(E_WARNING, "This has not been ported, yet"); |
|||
RETURN_FALSE; |
|||
} |
|||
/* }}} */ |
|||
|
|||
|
|||
#endif |
|||
|
|||
/* |
|||
* Local variables: |
|||
* tab-width: 4 |
|||
* c-basic-offset: 4 |
|||
* End: |
|||
*/ |
|||
@ -0,0 +1,3 @@ |
|||
define_option with-recode 'GNU-Recode support?' yesnodir no \ |
|||
' Whether to build the recode extension.' |
|||
|
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue