cvs: /php4/ext/recode recode.c /php4/ext/standard file.c file.h
| From: | Kristian K�hntopp | Date: | Sun, 12 Mar 2000 19:42:29 +0000 |
| Subject: | cvs: /php4/ext/recode recode.c /php4/ext/standard file.c file.h | ||
| Groups: | php.version4 | ||
| Request: | Send a blank email to php-version4+get-11969@lists.php.net to get a copy of this message | ||
kk Sun Mar 12 11:42:29 2000 EDT
Modified files:
/php4/ext/recode recode.c
/php4/ext/standard file.c file.h
Log:
Finished porting recode module.
Index: php4/ext/recode/recode.c
diff -u php4/ext/recode/recode.c:1.2 php4/ext/recode/recode.c:1.3
--- php4/ext/recode/recode.c:1.2 Sun Mar 12 11:08:52 2000
+++ php4/ext/recode/recode.c Sun Mar 12 11:42:29 2000
@@ -16,7 +16,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: recode.c,v 1.2 2000/03/12 19:08:52 kk Exp $ */
+/* $Id: recode.c,v 1.3 2000/03/12 19:42:29 kk Exp $ */
/* {{{ includes & prototypes */
@@ -25,6 +25,7 @@
#if HAVE_LIBRECODE
#include "ext/standard/info.h"
+#include "ext/standard/file.h"
#include "ext/standard/php_string.h"
#include "zend_list.h"
@@ -91,7 +92,7 @@
php_printf("<table border=5 width=\"600\">");
php_info_print_table_header(1, "Module Revision");
- php_info_print_table_row(1, "$Revision: 1.2 $");
+ php_info_print_table_row(1, "$Revision: 1.3 $");
php_printf("</table>\n");
}
@@ -147,15 +148,68 @@
}
/* }}} */
-/* {{{ proto bool recode_file(string request, int input, int output)
+/* {{{ proto bool recode_file(string request, resource input, resource output)
Recode file input into file output according to request */
PHP_FUNCTION(recode_file)
{
- php_error(E_WARNING, "This has not been ported, yet");
+ RECODE_REQUEST request = NULL;
+ int success;
+ pval **req;
+ pval **input, **output;
+ FILE *in_fp, *out_fp;
+ int in_type, out_type;
+
+ ReSLS_FETCH();
+ if (ARG_COUNT(ht) != 3
+ || zend_get_parameters_ex(3, &req, &input, &output) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ in_fp = zend_fetch_resource(input,-1, "File-Handle", &in_type,
+ 2, php_file_le_fopen(), php_file_le_popen());
+ if (!in_fp) {
+ php_error(E_WARNING,"Unable to find input file identifier");
+ RETURN_FALSE;
+ }
+
+ out_fp = zend_fetch_resource(output,-1, "File-Handle", &out_type,
+ 2, php_file_le_fopen(), php_file_le_popen());
+ if (!out_fp) {
+ php_error(E_WARNING,"Unable to find output file identifier");
+ RETURN_FALSE;
+ }
+
+ convert_to_string_ex(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;
+ }
+
+ success = recode_file_to_file(request, in_fp, out_fp);
+ if (!success) {
+ php_error(E_WARNING, "Recoding failed.");
+ goto error_exit;
+ }
+
+ if (request)
+ recode_delete_request(request);
+ RETURN_TRUE;
+
+error_exit:
+ if (request)
+ recode_delete_request(request);
+
RETURN_FALSE;
}
/* }}} */
-
#endif
Index: php4/ext/standard/file.c
diff -u php4/ext/standard/file.c:1.70 php4/ext/standard/file.c:1.71
--- php4/ext/standard/file.c:1.70 Sun Mar 12 07:47:32 2000
+++ php4/ext/standard/file.c Sun Mar 12 11:42:29 2000
@@ -17,7 +17,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: file.c,v 1.70 2000/03/12 15:47:32 sas Exp $ */
+/* $Id: file.c,v 1.71 2000/03/12 19:42:29 kk Exp $ */
/* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
@@ -244,6 +244,11 @@
PHPAPI int php_file_le_fopen(void) /* XXX doe we really want this???? */
{
return le_fopen;
+}
+
+PHPAPI int php_file_le_popen(void) /* XXX you may not like this, but I need it. -- KK */
+{
+ return le_popen;
}
Index: php4/ext/standard/file.h
diff -u php4/ext/standard/file.h:1.19 php4/ext/standard/file.h:1.20
--- php4/ext/standard/file.h:1.19 Mon Mar 6 12:37:11 2000
+++ php4/ext/standard/file.h Sun Mar 12 11:42:29 2000
@@ -27,7 +27,7 @@
+----------------------------------------------------------------------+
*/
-/* $Id: file.h,v 1.19 2000/03/06 20:37:11 ssb Exp $ */
+/* $Id: file.h,v 1.20 2000/03/12 19:42:29 kk Exp $ */
/* Synced with php 3.0 revision 1.30 1999-06-16 [ssb] */
@@ -76,6 +76,7 @@
PHPAPI int php_set_sock_blocking(int socketd, int block);
PHPAPI int php_file_le_fopen(void);
+PHPAPI int php_file_le_popen(void);
PHPAPI int php_file_le_socket(void);
PHPAPI int php_file_le_uploads(void);