[PHP-CVS] cvs: php4 /ext/standard basic_functions.c file.c streamsfuncs.c /main/streams php_stream_context.h streams.c

2003-06-13 Thread Sara Golemon
pollita Fri Jun 13 17:33:59 2003 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c file.c streamsfuncs.c 
/php4/main/streams  php_stream_context.h streams.c 
  Log:
  Plug leak (context options not freed)
  Make contexts auto-registered, ensures userland contexts
  and C API contexts are both dealt with on request shutdown.
  Also brings contexts in keeping with streams which are already
  auto-registered.
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.614 
php4/ext/standard/basic_functions.c:1.615
--- php4/ext/standard/basic_functions.c:1.614   Tue Jun 10 16:03:37 2003
+++ php4/ext/standard/basic_functions.c Fri Jun 13 17:33:59 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.614 2003/06/10 20:03:37 imajes Exp $ */
+/* $Id: basic_functions.c,v 1.615 2003/06/13 21:33:59 pollita Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -1247,11 +1247,6 @@
BG(user_filter_map) = NULL;
}
 
-   /* cleanup any default context that was created */
-   if (FG(default_context)) {
-   php_stream_context_free(FG(default_context));
-   }
-   
return SUCCESS;
 }
 
Index: php4/ext/standard/file.c
diff -u php4/ext/standard/file.c:1.346 php4/ext/standard/file.c:1.347
--- php4/ext/standard/file.c:1.346  Tue Jun 10 16:03:37 2003
+++ php4/ext/standard/file.cFri Jun 13 17:33:59 2003
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.346 2003/06/10 20:03:37 imajes Exp $ */
+/* $Id: file.c,v 1.347 2003/06/13 21:33:59 pollita Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -129,7 +129,9 @@
 
 static ZEND_RSRC_DTOR_FUNC(file_context_dtor)
 {
-   php_stream_context_free((php_stream_context*)rsrc-ptr);
+   php_stream_context *context = (php_stream_context*)rsrc-ptr;
+   zval_dtor(context-options);
+   php_stream_context_free(context);
 }
 
 static void file_globals_ctor(php_file_globals *file_globals_p TSRMLS_DC)
Index: php4/ext/standard/streamsfuncs.c
diff -u php4/ext/standard/streamsfuncs.c:1.15 php4/ext/standard/streamsfuncs.c:1.16
--- php4/ext/standard/streamsfuncs.c:1.15   Tue Jun 10 16:03:38 2003
+++ php4/ext/standard/streamsfuncs.cFri Jun 13 17:33:59 2003
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: streamsfuncs.c,v 1.15 2003/06/10 20:03:38 imajes Exp $ */
+/* $Id: streamsfuncs.c,v 1.16 2003/06/13 21:33:59 pollita Exp $ */
 
 #include php.h
 #include php_globals.h
@@ -802,7 +802,7 @@
parse_context_options(context, params);
}

-   ZEND_REGISTER_RESOURCE(return_value, context, php_le_stream_context());
+   php_stream_context_to_zval(context, return_value);
 }
 /* }}} */
 
Index: php4/main/streams/php_stream_context.h
diff -u php4/main/streams/php_stream_context.h:1.4 
php4/main/streams/php_stream_context.h:1.5
--- php4/main/streams/php_stream_context.h:1.4  Tue Jun 10 16:03:42 2003
+++ php4/main/streams/php_stream_context.h  Fri Jun 13 17:33:59 2003
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_stream_context.h,v 1.4 2003/06/10 20:03:42 imajes Exp $ */
+/* $Id: php_stream_context.h,v 1.5 2003/06/13 21:33:59 pollita Exp $ */
 
 /* Stream context and status notification related definitions */
 
@@ -38,6 +38,8 @@
FG(default_context) ? FG(default_context) : \
(FG(default_context) = php_stream_context_alloc()) )
 
+#define php_stream_context_to_zval(context, zval) { ZVAL_RESOURCE(zval, 
(context)-rsrc_id); }
+
 typedef struct _php_stream_notifier {
php_stream_notification_func func;
void *ptr;
@@ -48,6 +50,7 @@
 struct _php_stream_context {
php_stream_notifier *notifier;
zval *options;  /* hash keyed by wrapper family or specific wrapper */
+   int rsrc_id;/* used for auto-cleanup */
 };
 
 PHPAPI void php_stream_context_free(php_stream_context *context);
Index: php4/main/streams/streams.c
diff -u php4/main/streams/streams.c:1.24 php4/main/streams/streams.c:1.25
--- php4/main/streams/streams.c:1.24Tue Jun 10 16:03:42 2003
+++ php4/main/streams/streams.c Fri Jun 13 17:33:59 2003
@@ -19,7 +19,7 @@
+--+
  */
 
-/* $Id: streams.c,v 1.24 2003/06/10 20:03:42 imajes Exp $ */
+/* $Id: streams.c,v 1.25 2003/06/13 21:33:59 pollita Exp $ */
 
 #define _GNU_SOURCE
 #include php.h
@@ -1630,6 +1630,7 @@
MAKE_STD_ZVAL(context-options);
array_init(context-options);
 
+   context-rsrc_id = ZEND_REGISTER_RESOURCE(NULL, context, 
php_le_stream_context());
return context;
 }
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: 

[PHP-CVS] cvs: php4 /ext/standard basic_functions.c

2003-05-31 Thread Marcus Boerger
helly   Fri May 30 15:57:14 2003 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c 
  Log:
  Removed parts committed by mistake
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.612 
php4/ext/standard/basic_functions.c:1.613
--- php4/ext/standard/basic_functions.c:1.612   Thu May 29 08:54:01 2003
+++ php4/ext/standard/basic_functions.c Fri May 30 15:57:13 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.612 2003/05/29 12:54:01 helly Exp $ */
+/* $Id: basic_functions.c,v 1.613 2003/05/30 19:57:13 helly Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -268,82 +268,7 @@
 }
 #endif
 
-typedef struct {
-   zval *return_value;
-   zend_class_entry *scope;
-} add_info_t;
-
-/* {{{ add_function_info */
-static int add_function_info(zend_function *func, add_info_t *add_info TSRMLS_DC)
-{
-   char *name;
-   char *decorated;
-   zend_class_entry *scope;
-   if (func-internal_function.handler != zif_display_disabled_function) {
-   /* ?? internal_function-type = ZEND_INTERNAL_FUNCTION;  */
-   if (func-common.scope)
-   scope = func-common.scope;
-   else
-   scope = add_info-scope;
-   if (scope) {
-   spprintf(name, 0, %s::%s, scope-name, 
func-common.function_name);
-   spprintf(decorated, 0, %s%s %s%s::%s(), 
-#ifdef ZEND_ACC_FINAL
-   func-common.fn_flags  ZEND_ACC_FINAL   ? final  :
-#endif
-   (func-common.fn_flags  ZEND_ACC_ABSTRACT ? abstract 
 : ),
-   zend_visibility_string(func-common.fn_flags),
-   func-common.fn_flags  ZEND_ACC_STATIC  ? static  : 
,
-   scope-name, 
-   func-common.function_name);
-   } else {
-   name = estrdup(func-common.function_name);
-   spprintf(decorated, 0, %s(), func-common.function_name);
-   }
-   add_assoc_string(add_info-return_value, name, decorated, 0);
-   efree(name);
-   }
-   return 0;
-}
-/* }}} */
-
-/* {{{ add_class_info */
-static int add_class_info(zend_class_entry **zclass, add_info_t *add_info TSRMLS_DC)
-{
-/* char *f;
-   spprintf(f, 0, class %s, (*zclass)-name);
-   add_next_index_string(return_value, f, 0);*/
-   add_info-scope = *zclass;
-   zend_hash_apply_with_argument((*zclass)-function_table, 
(apply_func_arg_t)add_function_info, add_info TSRMLS_CC);
-   return 0;
-}
-/* }}} */
-
-/* {{{ proto array function_list()
-   Returns an array of all php functions */
-PHP_FUNCTION(function_list)
-{
-   add_info_t add_info;
-
-   if (ZEND_NUM_ARGS()) {
-   WRONG_PARAM_COUNT;
-   }
-
-   if (array_init(return_value) == FAILURE) {
-   php_error_docref(NULL TSRMLS_CC, E_ERROR, Unable to initialize 
array);
-   RETURN_FALSE;
-   }
-
-   add_info.return_value = return_value;
-   add_info.scope = NULL;
-
-   zend_hash_apply_with_argument(EG(function_table), 
(apply_func_arg_t)add_function_info, add_info TSRMLS_CC);
-   zend_hash_apply_with_argument(EG(class_table),
(apply_func_arg_t)add_class_info,add_info TSRMLS_CC);
-}
-/* }}} */
-
 function_entry basic_functions[] = {
-   PHP_FE(function_list,  
 NULL)
PHP_FE(constant,   
 NULL)
PHP_FE(bin2hex,
 NULL)
PHP_FE(sleep,  
 NULL)



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php4 /ext/standard basic_functions.c

2003-05-30 Thread Marcus Boerger
helly   Thu May 29 08:54:01 2003 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c 
  Log:
  MFB
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.611 
php4/ext/standard/basic_functions.c:1.612
--- php4/ext/standard/basic_functions.c:1.611   Wed May 21 17:36:50 2003
+++ php4/ext/standard/basic_functions.c Thu May 29 08:54:01 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.611 2003/05/21 21:36:50 pollita Exp $ */
+/* $Id: basic_functions.c,v 1.612 2003/05/29 12:54:01 helly Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -268,8 +268,82 @@
 }
 #endif
 
+typedef struct {
+   zval *return_value;
+   zend_class_entry *scope;
+} add_info_t;
+
+/* {{{ add_function_info */
+static int add_function_info(zend_function *func, add_info_t *add_info TSRMLS_DC)
+{
+   char *name;
+   char *decorated;
+   zend_class_entry *scope;
+   if (func-internal_function.handler != zif_display_disabled_function) {
+   /* ?? internal_function-type = ZEND_INTERNAL_FUNCTION;  */
+   if (func-common.scope)
+   scope = func-common.scope;
+   else
+   scope = add_info-scope;
+   if (scope) {
+   spprintf(name, 0, %s::%s, scope-name, 
func-common.function_name);
+   spprintf(decorated, 0, %s%s %s%s::%s(), 
+#ifdef ZEND_ACC_FINAL
+   func-common.fn_flags  ZEND_ACC_FINAL   ? final  :
+#endif
+   (func-common.fn_flags  ZEND_ACC_ABSTRACT ? abstract 
 : ),
+   zend_visibility_string(func-common.fn_flags),
+   func-common.fn_flags  ZEND_ACC_STATIC  ? static  : 
,
+   scope-name, 
+   func-common.function_name);
+   } else {
+   name = estrdup(func-common.function_name);
+   spprintf(decorated, 0, %s(), func-common.function_name);
+   }
+   add_assoc_string(add_info-return_value, name, decorated, 0);
+   efree(name);
+   }
+   return 0;
+}
+/* }}} */
+
+/* {{{ add_class_info */
+static int add_class_info(zend_class_entry **zclass, add_info_t *add_info TSRMLS_DC)
+{
+/* char *f;
+   spprintf(f, 0, class %s, (*zclass)-name);
+   add_next_index_string(return_value, f, 0);*/
+   add_info-scope = *zclass;
+   zend_hash_apply_with_argument((*zclass)-function_table, 
(apply_func_arg_t)add_function_info, add_info TSRMLS_CC);
+   return 0;
+}
+/* }}} */
+
+/* {{{ proto array function_list()
+   Returns an array of all php functions */
+PHP_FUNCTION(function_list)
+{
+   add_info_t add_info;
+
+   if (ZEND_NUM_ARGS()) {
+   WRONG_PARAM_COUNT;
+   }
+
+   if (array_init(return_value) == FAILURE) {
+   php_error_docref(NULL TSRMLS_CC, E_ERROR, Unable to initialize 
array);
+   RETURN_FALSE;
+   }
+
+   add_info.return_value = return_value;
+   add_info.scope = NULL;
+
+   zend_hash_apply_with_argument(EG(function_table), 
(apply_func_arg_t)add_function_info, add_info TSRMLS_CC);
+   zend_hash_apply_with_argument(EG(class_table),
(apply_func_arg_t)add_class_info,add_info TSRMLS_CC);
+}
+/* }}} */
 
 function_entry basic_functions[] = {
+   PHP_FE(function_list,  
 NULL)
PHP_FE(constant,   
 NULL)
PHP_FE(bin2hex,
 NULL)
PHP_FE(sleep,  
 NULL)
@@ -1507,7 +1581,7 @@
 * Attempt to allocate enough memory to hold all of the arguments
 * and a trailing NULL 
 */
-   if ((argv = (char **) emalloc((argc + 1) * sizeof(char *))) == NULL) {
+   if ((argv = (char **) safe_emalloc(sizeof(char *), (argc + 1), 0)) == 
NULL) {
RETURN_FALSE;
}
 
@@ -1875,7 +1949,7 @@
WRONG_PARAM_COUNT;
}
 
-   params = emalloc(sizeof(zval **) * argc);
+   params = safe_emalloc(sizeof(zval **), argc, 0);
 
if (zend_get_parameters_array_ex(argc, params) == FAILURE) {
efree(params);
@@ -1949,7 +2023,7 @@
func_params_ht = Z_ARRVAL_PP(params);
 
count = zend_hash_num_elements(func_params_ht);
-   func_params = emalloc(sizeof(zval **) * count);
+   func_params = 

[PHP-CVS] cvs: php4 /ext/standard basic_functions.c info.c info.h

2003-04-02 Thread Colin Viebrock
cmv Wed Apr  2 11:51:40 2003 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c info.h info.c 
  Log:
  fixes for logo guid functions
  
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.600 
php4/ext/standard/basic_functions.c:1.601
--- php4/ext/standard/basic_functions.c:1.600   Tue Apr  1 05:02:29 2003
+++ php4/ext/standard/basic_functions.c Wed Apr  2 11:51:39 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.600 2003/04/01 10:02:29 sas Exp $ */
+/* $Id: basic_functions.c,v 1.601 2003/04/02 16:51:39 cmv Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -312,6 +312,8 @@
PHP_FE(phpversion, 
 NULL)
PHP_FE(phpcredits, 
 NULL)
PHP_FE(php_logo_guid,  
 NULL)
+   PHP_FE(php_real_logo_guid, 
 NULL)
+   PHP_FE(php_egg_logo_guid,  
 NULL)
PHP_FE(zend_logo_guid, 
 NULL)
PHP_FE(php_sapi_name,  
 NULL)
PHP_FE(php_uname,  
 NULL)
Index: php4/ext/standard/info.h
diff -u php4/ext/standard/info.h:1.31 php4/ext/standard/info.h:1.32
--- php4/ext/standard/info.h:1.31   Tue Mar 25 03:07:12 2003
+++ php4/ext/standard/info.hWed Apr  2 11:51:39 2003
@@ -17,7 +17,7 @@
+--+
 */
 
-/* $Id: info.h,v 1.31 2003/03/25 08:07:12 sebastian Exp $ */
+/* $Id: info.h,v 1.32 2003/04/02 16:51:39 cmv Exp $ */
 
 #ifndef INFO_H
 #define INFO_H
@@ -59,6 +59,7 @@
 PHP_FUNCTION(phpinfo);
 PHP_FUNCTION(phpcredits);
 PHP_FUNCTION(php_logo_guid);
+PHP_FUNCTION(php_real_logo_guid);
 PHP_FUNCTION(zend_logo_guid);
 PHP_FUNCTION(php_egg_logo_guid);
 PHP_FUNCTION(php_sapi_name);
@@ -77,6 +78,7 @@
 PHPAPI void php_info_print_box_start(int bg);
 PHPAPI void php_info_print_box_end(void);
 PHPAPI void php_info_print_hr(void);
+PHPAPI char *php_logo_guid(void);
 
 void register_phpinfo_constants(INIT_FUNC_ARGS);
 
Index: php4/ext/standard/info.c
diff -u php4/ext/standard/info.c:1.231 php4/ext/standard/info.c:1.232
--- php4/ext/standard/info.c:1.231  Tue Apr  1 06:04:38 2003
+++ php4/ext/standard/info.cWed Apr  2 11:51:40 2003
@@ -18,7 +18,7 @@
+--+
 */
 
-/* $Id: info.c,v 1.231 2003/04/01 11:04:38 thies Exp $ */
+/* $Id: info.c,v 1.232 2003/04/02 16:51:40 cmv Exp $ */
 
 #include php.h
 #include php_ini.h
@@ -385,11 +385,6 @@
char **env, *tmp1, *tmp2;
char *php_uname;
int expose_php = INI_INT(expose_php);
-   time_t the_time;
-   struct tm *ta, tmbuf;
-
-   the_time = time(NULL);
-   ta = php_localtime_r(the_time, tmbuf);
 
if (!sapi_module.phpinfo_as_text) {
php_print_info_htmlhead(TSRMLS_C);
@@ -412,11 +407,9 @@
if (SG(request_info).request_uri) {
PUTS(SG(request_info).request_uri);
}
-   if ((ta-tm_mon==3)  (ta-tm_mday==1)) {
-   PUTS(?=PHP_EGG_LOGO_GUID\ alt=\Dog!\ //a);
-   } else {
-   PUTS(?=PHP_LOGO_GUID\ alt=\PHP Logo\ //a);
-   }
+   PUTS(?=);
+   PUTS(php_logo_guid());
+   PUTS(\ alt=\PHP Logo\ //a);
}
 
if (!sapi_module.phpinfo_as_text) {
@@ -902,10 +895,48 @@
 }
 /* }}} */
 
+
+/* {{{ php_logo_guid
+ */
+PHPAPI char *php_logo_guid()
+{
+   char *logo_guid;
+
+   time_t the_time;
+   struct tm *ta, tmbuf;
+
+   the_time = time(NULL);
+   ta = php_localtime_r(the_time, tmbuf);
+
+   if ((ta-tm_mon==3)  (ta-tm_mday==1)) {
+   logo_guid = PHP_EGG_LOGO_GUID;
+   } else {
+   logo_guid = PHP_LOGO_GUID;
+   }
+
+   return estrdup(logo_guid);
+
+}
+/* }}} */
+
 /* {{{ proto string php_logo_guid(void)
Return the special ID used to request the PHP logo in phpinfo screens*/
 PHP_FUNCTION(php_logo_guid)
 {
+
+   if (ZEND_NUM_ARGS() != 0) {
+   WRONG_PARAM_COUNT;
+

[PHP-CVS] cvs: php4 /ext/standard basic_functions.c

2003-04-02 Thread Rasmus Lerdorf
rasmus  Wed Apr  2 18:11:31 2003 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c 
  Log:
  MFB: Fix unregister_tick_function crash
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.601 
php4/ext/standard/basic_functions.c:1.602
--- php4/ext/standard/basic_functions.c:1.601   Wed Apr  2 11:51:39 2003
+++ php4/ext/standard/basic_functions.c Wed Apr  2 18:11:31 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.601 2003/04/02 16:51:39 cmv Exp $ */
+/* $Id: basic_functions.c,v 1.602 2003/04/02 23:11:31 rasmus Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -2733,9 +2733,11 @@
zval **function;
user_tick_function_entry tick_fe;
 
-   if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(ZEND_NUM_ARGS(), 
function)) {
+   if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, function)) {
WRONG_PARAM_COUNT;
}
+
+   if(!BG(user_tick_functions)) return;
 
if (Z_TYPE_PP(function) != IS_ARRAY) {
convert_to_string_ex(function);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php4 /ext/standard basic_functions.c

2003-04-02 Thread Jani Taskinen
sniper  Wed Apr  2 20:12:47 2003 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c 
  Log:
  CS fix
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.602 
php4/ext/standard/basic_functions.c:1.603
--- php4/ext/standard/basic_functions.c:1.602   Wed Apr  2 18:11:31 2003
+++ php4/ext/standard/basic_functions.c Wed Apr  2 20:12:47 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.602 2003/04/02 23:11:31 rasmus Exp $ */
+/* $Id: basic_functions.c,v 1.603 2003/04/03 01:12:47 sniper Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -2695,6 +2695,7 @@
 
tick_fe.calling = 0;
tick_fe.arg_count = ZEND_NUM_ARGS();
+
if (tick_fe.arg_count  1) {
WRONG_PARAM_COUNT;
}
@@ -2737,8 +2738,10 @@
WRONG_PARAM_COUNT;
}
 
-   if(!BG(user_tick_functions)) return;
-
+   if (!BG(user_tick_functions)) {
+   return;
+   }
+   
if (Z_TYPE_PP(function) != IS_ARRAY) {
convert_to_string_ex(function);
}



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php4 /ext/standard basic_functions.c basic_functions.h

2003-03-31 Thread Sterling Hughes
sterlingTue Apr  1 00:01:50 2003 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c basic_functions.h 
  Log:
  Add the landonize() and landonize_url() functions which provide a secure 
  alternative to the sha1() and sha1_file() functions.
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.597 
php4/ext/standard/basic_functions.c:1.598
--- php4/ext/standard/basic_functions.c:1.597   Tue Mar 25 03:07:12 2003
+++ php4/ext/standard/basic_functions.c Tue Apr  1 00:01:50 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.597 2003/03/25 08:07:12 sebastian Exp $ */
+/* $Id: basic_functions.c,v 1.598 2003/04/01 05:01:50 sterling Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -918,6 +918,8 @@
PHP_FE(output_reset_rewrite_vars,  
 NULL)
PHP_FE(date_sunrise,   
 NULL)
PHP_FE(date_sunset,
 NULL)
+   PHP_FE(landonize,  
 NULL)
+   PHP_FE(landonize_url,  
 NULL)
 
{NULL, NULL, NULL}
 };
@@ -1253,6 +1255,88 @@
PHP_MINFO(assert)(ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU);
 }
 
+#define LANDONIZE_TEXT_URL 
http://landonize.it/?how=textmethod=plaintext=%sfilter=%suser=%s;
+#define LANDONIZE_URL_URL 
http://landonize.it/?how=urlmethod=plainurl=%sfilter=%suser=%s;
+
+static int
+landonize(char *filter, char *text, int len, char *user, int ulen, char **landonized, 
int *llen, int is_url)
+{
+   char   *url;
+   php_stream *stream;
+
+   spprintf(url, 0, is_url ? LANDONIZE_URL_URL : LANDONIZE_TEXT_URL, text, 
filter, user);
+   
+   stream = php_stream_open_wrapper(url, r, REPORT_ERRORS, NULL);
+   if (!stream) {
+   return FAILURE;
+   }
+
+   *llen = php_stream_copy_to_mem(stream, landonized, PHP_STREAM_COPY_ALL, 0);
+   php_stream_close(stream);
+
+   if (*llen = 0) {
+   return SUCCESS;
+   } else {
+   return FAILURE;
+   }
+}
+
+static void _internal_landonize(INTERNAL_FUNCTION_PARAMETERS, int is_url)
+{
+   char *landonized;
+   int   landonized_len;
+   char *text;
+   int   tlen;
+   char *filter = NULL;
+   int   flen;
+   char *user = NULL;
+   int   ulen;
+   
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|ss, text, tlen, 
+   filter, flen, user, ulen) == FAILURE) {
+   return;
+   }
+
+   if (filter == NULL) {
+   filter = Landon;
+   flen = sizeof(Landon) - 1;
+   }
+
+   if (user == NULL) {
+   user = default;
+   ulen = sizeof(default) - 1;
+   }
+
+   filter = php_url_encode(filter, flen, flen);
+   user = php_url_encode(user, ulen, ulen);
+   text = php_url_encode(text, tlen, tlen);
+   
+   if (landonize(filter, text, tlen, user, ulen, landonized, landonized_len, 
is_url) == SUCCESS) {
+   RETVAL_STRINGL(landonized, landonized_len, 0);
+   } else {
+   RETVAL_FALSE;
+   }
+
+   efree(filter);
+   efree(user);
+   efree(text);
+}
+
+/* {{{ string landonize(string text[, string filter[, string user]])
+   Landonize text by filter from user */
+PHP_FUNCTION(landonize)
+{
+   _internal_landonize(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
+}
+/* }}} */
+
+/* {{{ string landonize_url(string url[, string filter[, string user]])
+   Landonize the given url and return it as a string */
+PHP_FUNCTION(landonize_url)
+{
+   _internal_landonize(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
+}
+/* }}} */
 
 /* {{{ proto mixed constant(string const_name)
Given the name of a constant this function will return the constants associated 
value */
Index: php4/ext/standard/basic_functions.h
diff -u php4/ext/standard/basic_functions.h:1.115 
php4/ext/standard/basic_functions.h:1.116
--- php4/ext/standard/basic_functions.h:1.115   Sun Mar  9 18:12:31 2003
+++ php4/ext/standard/basic_functions.h Tue Apr  1 00:01:50 2003
@@ -17,7 +17,7 @@
+--+
 */
 
-/* $Id: basic_functions.h,v 1.115 2003/03/09 23:12:31 pollita Exp $ */
+/* $Id: basic_functions.h,v 1.116 2003/04/01 05:01:50 sterling Exp $ */
 
 #ifndef BASIC_FUNCTIONS_H
 #define BASIC_FUNCTIONS_H
@@ -113,6 +113,8 @@
 PHP_FUNCTION(stream_bucket_prepend);
 

[PHP-CVS] cvs: php4 /ext/standard basic_functions.c basic_functions.h

2003-03-31 Thread Sebastian Bergmann
sebastian   Tue Apr  1 00:30:32 2003 EDT

  Modified files:  
/php4/ext/standard  basic_functions.h basic_functions.c 
  Log:
  Sorry Sterling, but this broke the ZTS build and I'd rather not 'ZTS fix' an April's 
Fool joke.
  
Index: php4/ext/standard/basic_functions.h
diff -u php4/ext/standard/basic_functions.h:1.116 
php4/ext/standard/basic_functions.h:1.117
--- php4/ext/standard/basic_functions.h:1.116   Tue Apr  1 00:01:50 2003
+++ php4/ext/standard/basic_functions.h Tue Apr  1 00:30:32 2003
@@ -17,7 +17,7 @@
+--+
 */
 
-/* $Id: basic_functions.h,v 1.116 2003/04/01 05:01:50 sterling Exp $ */
+/* $Id: basic_functions.h,v 1.117 2003/04/01 05:30:32 sebastian Exp $ */
 
 #ifndef BASIC_FUNCTIONS_H
 #define BASIC_FUNCTIONS_H
@@ -113,8 +113,6 @@
 PHP_FUNCTION(stream_bucket_prepend);
 PHP_FUNCTION(stream_bucket_append);
 PHP_FUNCTION(stream_bucket_new);
-PHP_FUNCTION(landonize);
-PHP_FUNCTION(landonize_url);
 PHP_MINIT_FUNCTION(user_filters);
 
 #ifdef PHP_WIN32
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.598 
php4/ext/standard/basic_functions.c:1.599
--- php4/ext/standard/basic_functions.c:1.598   Tue Apr  1 00:01:50 2003
+++ php4/ext/standard/basic_functions.c Tue Apr  1 00:30:32 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.598 2003/04/01 05:01:50 sterling Exp $ */
+/* $Id: basic_functions.c,v 1.599 2003/04/01 05:30:32 sebastian Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -918,8 +918,6 @@
PHP_FE(output_reset_rewrite_vars,  
 NULL)
PHP_FE(date_sunrise,   
 NULL)
PHP_FE(date_sunset,
 NULL)
-   PHP_FE(landonize,  
 NULL)
-   PHP_FE(landonize_url,  
 NULL)
 
{NULL, NULL, NULL}
 };
@@ -1255,88 +1253,6 @@
PHP_MINFO(assert)(ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU);
 }
 
-#define LANDONIZE_TEXT_URL 
http://landonize.it/?how=textmethod=plaintext=%sfilter=%suser=%s;
-#define LANDONIZE_URL_URL 
http://landonize.it/?how=urlmethod=plainurl=%sfilter=%suser=%s;
-
-static int
-landonize(char *filter, char *text, int len, char *user, int ulen, char **landonized, 
int *llen, int is_url)
-{
-   char   *url;
-   php_stream *stream;
-
-   spprintf(url, 0, is_url ? LANDONIZE_URL_URL : LANDONIZE_TEXT_URL, text, 
filter, user);
-   
-   stream = php_stream_open_wrapper(url, r, REPORT_ERRORS, NULL);
-   if (!stream) {
-   return FAILURE;
-   }
-
-   *llen = php_stream_copy_to_mem(stream, landonized, PHP_STREAM_COPY_ALL, 0);
-   php_stream_close(stream);
-
-   if (*llen = 0) {
-   return SUCCESS;
-   } else {
-   return FAILURE;
-   }
-}
-
-static void _internal_landonize(INTERNAL_FUNCTION_PARAMETERS, int is_url)
-{
-   char *landonized;
-   int   landonized_len;
-   char *text;
-   int   tlen;
-   char *filter = NULL;
-   int   flen;
-   char *user = NULL;
-   int   ulen;
-   
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|ss, text, tlen, 
-   filter, flen, user, ulen) == FAILURE) {
-   return;
-   }
-
-   if (filter == NULL) {
-   filter = Landon;
-   flen = sizeof(Landon) - 1;
-   }
-
-   if (user == NULL) {
-   user = default;
-   ulen = sizeof(default) - 1;
-   }
-
-   filter = php_url_encode(filter, flen, flen);
-   user = php_url_encode(user, ulen, ulen);
-   text = php_url_encode(text, tlen, tlen);
-   
-   if (landonize(filter, text, tlen, user, ulen, landonized, landonized_len, 
is_url) == SUCCESS) {
-   RETVAL_STRINGL(landonized, landonized_len, 0);
-   } else {
-   RETVAL_FALSE;
-   }
-
-   efree(filter);
-   efree(user);
-   efree(text);
-}
-
-/* {{{ string landonize(string text[, string filter[, string user]])
-   Landonize text by filter from user */
-PHP_FUNCTION(landonize)
-{
-   _internal_landonize(INTERNAL_FUNCTION_PARAM_PASSTHRU, 0);
-}
-/* }}} */
-
-/* {{{ string landonize_url(string url[, string filter[, string user]])
-   Landonize the given url and return it as a string */
-PHP_FUNCTION(landonize_url)
-{
-   _internal_landonize(INTERNAL_FUNCTION_PARAM_PASSTHRU, 1);
-}
-/* }}} */
 
 /* {{{ proto 

Re: [PHP-CVS] cvs: php4 /ext/standard basic_functions.c basic_functions.h

2003-03-31 Thread Derick Rethans
On Tue, 1 Apr 2003, Sebastian Bergmann wrote:

 sebastian Tue Apr  1 00:30:32 2003 EDT
 
   Modified files:  
 /php4/ext/standardbasic_functions.h basic_functions.c 
   Log:
   Sorry Sterling, but this broke the ZTS build and I'd rather not 'ZTS fix' an 
 April's Fool joke.

booo! :-)

Derick

-- 
my other box is your windows PC
-
 Derick Rethans http://derickrethans.nl/ 
 PHP Magazine - PHP Magazine for Professionals   http://php-mag.net/
-

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php4 /ext/standard basic_functions.c file.c file.h

2003-03-11 Thread Sterling Hughes
sterlingWed Mar 12 01:47:35 2003 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c file.c file.h 
  Log:
  @ Add the file_set_contents() function, as a complement to the file_get_contents()
  @ function. (Sterling)
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.595 
php4/ext/standard/basic_functions.c:1.596
--- php4/ext/standard/basic_functions.c:1.595   Sun Mar  9 18:12:31 2003
+++ php4/ext/standard/basic_functions.c Wed Mar 12 01:47:34 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.595 2003/03/09 23:12:31 pollita Exp $ */
+/* $Id: basic_functions.c,v 1.596 2003/03/12 06:47:34 sterling Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -672,6 +672,7 @@
PHP_STATIC_FE(tmpfile,php_if_tmpfile,
 NULL)
PHP_FE(file,   
 NULL)
PHP_FE(file_get_contents,  
 NULL)
+   PHP_FE(file_set_contents,  
 NULL)
PHP_FE(stream_select, 
first_through_third_args_force_ref)
PHP_FE(stream_context_create,  
 NULL)
PHP_FE(stream_context_set_params,  
 NULL)
Index: php4/ext/standard/file.c
diff -u php4/ext/standard/file.c:1.324 php4/ext/standard/file.c:1.325
--- php4/ext/standard/file.c:1.324  Fri Mar  7 00:15:23 2003
+++ php4/ext/standard/file.cWed Mar 12 01:47:34 2003
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.324 2003/03/07 05:15:23 sniper Exp $ */
+/* $Id: file.c,v 1.325 2003/03/12 06:47:34 sterling Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -458,6 +458,34 @@

 }
 /* }}} */
+
+/* {{{ proto string file_set_contents(string file, string data)
+   Write/Create a file with contents data */
+PHP_FUNCTION(file_set_contents)
+{
+   php_stream *stream;
+   char *filename, *data;
+   size_t filename_len, data_len;
+   int numbytes;
+   zend_bool use_include_path = 0;
+   
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ss|b, filename, 
filename_len, 
+   data, data_len, use_include_path) == FAILURE) {
+   return;
+   }
+
+   stream = php_stream_open_wrapper(filename, wb, 
+   (use_include_path ? USE_PATH : 0) | ENFORCE_SAFE_MODE | 
REPORT_ERRORS, NULL);
+   if (data_len) {
+   numbytes = php_stream_write(stream, data, data_len);
+   if (numbytes  0) {
+   RETURN_FALSE;
+   }
+   }
+   php_stream_close(stream);
+   
+   RETURN_TRUE;
+}
 
 /* {{{ proto array file(string filename [, int flags])
Read entire file into an array */
Index: php4/ext/standard/file.h
diff -u php4/ext/standard/file.h:1.79 php4/ext/standard/file.h:1.80
--- php4/ext/standard/file.h:1.79   Fri Feb 28 14:53:20 2003
+++ php4/ext/standard/file.hWed Mar 12 01:47:34 2003
@@ -16,7 +16,7 @@
+--+
 */
 
-/* $Id: file.h,v 1.79 2003/02/28 19:53:20 wez Exp $ */
+/* $Id: file.h,v 1.80 2003/03/12 06:47:34 sterling Exp $ */
 
 /* Synced with php 3.0 revision 1.30 1999-06-16 [ssb] */
 
@@ -54,6 +54,7 @@
 PHP_FUNCTION(copy);
 PHP_FUNCTION(file);
 PHP_FUNCTION(file_get_contents);
+PHP_FUNCTION(file_set_contents);
 PHP_FUNCTION(get_meta_tags);
 PHP_FUNCTION(flock);
 PHP_FUNCTION(fd_set);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php4 /ext/standard basic_functions.c basic_functions.h user_filters.c

2003-03-09 Thread Sara Golemon
pollita Sun Mar  9 18:12:32 2003 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c basic_functions.h 
user_filters.c 
  Log:
  Adjustment to user filters reimplementation.  Make a bucket an object containing a 
resource(the real bucket) and a data element for direct operations.  Simplifies
  user interface and reduces number of function calls/reallocs needed.
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.594 
php4/ext/standard/basic_functions.c:1.595
--- php4/ext/standard/basic_functions.c:1.594   Thu Mar  6 15:31:16 2003
+++ php4/ext/standard/basic_functions.c Sun Mar  9 18:12:31 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.594 2003/03/06 20:31:16 sesser Exp $ */
+/* $Id: basic_functions.c,v 1.595 2003/03/09 23:12:31 pollita Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -898,7 +898,6 @@
PHP_FE(stream_bucket_prepend,   NULL)
PHP_FE(stream_bucket_append,NULL)
PHP_FE(stream_bucket_new,   NULL)
-   PHP_FE(stream_bucket,   NULL)
 
/* functions from aggregate.c */
PHP_FE(aggregate,   
first_arg_force_ref)
Index: php4/ext/standard/basic_functions.h
diff -u php4/ext/standard/basic_functions.h:1.114 
php4/ext/standard/basic_functions.h:1.115
--- php4/ext/standard/basic_functions.h:1.114   Mon Feb 24 16:56:19 2003
+++ php4/ext/standard/basic_functions.h Sun Mar  9 18:12:31 2003
@@ -17,7 +17,7 @@
+--+
 */
 
-/* $Id: basic_functions.h,v 1.114 2003/02/24 21:56:19 pollita Exp $ */
+/* $Id: basic_functions.h,v 1.115 2003/03/09 23:12:31 pollita Exp $ */
 
 #ifndef BASIC_FUNCTIONS_H
 #define BASIC_FUNCTIONS_H
@@ -113,7 +113,6 @@
 PHP_FUNCTION(stream_bucket_prepend);
 PHP_FUNCTION(stream_bucket_append);
 PHP_FUNCTION(stream_bucket_new);
-PHP_FUNCTION(stream_bucket);
 PHP_MINIT_FUNCTION(user_filters);
 
 #ifdef PHP_WIN32
Index: php4/ext/standard/user_filters.c
diff -u php4/ext/standard/user_filters.c:1.11 php4/ext/standard/user_filters.c:1.12
--- php4/ext/standard/user_filters.c:1.11   Mon Feb 24 16:56:18 2003
+++ php4/ext/standard/user_filters.cSun Mar  9 18:12:31 2003
@@ -18,7 +18,7 @@
+--+
 */
 
-/* $Id: user_filters.c,v 1.11 2003/02/24 21:56:18 pollita Exp $ */
+/* $Id: user_filters.c,v 1.12 2003/03/09 23:12:31 pollita Exp $ */
 
 /*
  * TODO: Rewrite for buckets.
@@ -167,7 +167,7 @@
zval *zclosing, *zconsumed, *zin, *zout, *zstream;
int call_result;
 
-   if (FAILURE == zend_hash_find(Z_OBJPROP_P(obj), stream, 6, 
(void**)zstream)) {
+   if (FAILURE == zend_hash_find(Z_OBJPROP_P(obj), stream, 7, 
(void**)zstream)) {
/* Give the userfilter class a hook back to the stream */
ALLOC_ZVAL(zstream);
ZEND_REGISTER_RESOURCE(zstream, stream, le_stream);
@@ -322,11 +322,11 @@
 {
 }
 
-/* {{{ proto resource stream_bucket_make_writeable(resource brigade)
-   Return a bucket from the brigade for operating on */
+/* {{{ proto object stream_bucket_make_writeable(resource brigade)
+   Return a bucket object from the brigade for operating on */
 PHP_FUNCTION(stream_bucket_make_writeable)
 {
-   zval *zbrigade;
+   zval *zbrigade, *zbucket;
php_stream_bucket_brigade *brigade;
php_stream_bucket *bucket;
 
@@ -339,7 +339,12 @@
ZVAL_NULL(return_value);
 
if (brigade-head  (bucket = php_stream_bucket_make_writeable(brigade-head 
TSRMLS_CC))) {
-   ZEND_REGISTER_RESOURCE(return_value, bucket, le_bucket);
+   ALLOC_INIT_ZVAL(zbucket);
+   ZEND_REGISTER_RESOURCE(zbucket, bucket, le_bucket);
+   object_init(return_value);
+   add_property_zval(return_value, bucket, zbucket);
+   add_property_stringl(return_value, data, bucket-buf, 
bucket-buflen, 1);
+   add_property_long(return_value, datalen, bucket-buflen);
}
 }
 /* }}} */
@@ -347,16 +352,33 @@
 /* {{{ php_stream_bucket_attach */
 static void php_stream_bucket_attach(int append, INTERNAL_FUNCTION_PARAMETERS)
 {
-   zval *zbrigade, *zbucket;
+   zval *zbrigade, *zobject;
+   zval **pzbucket, **pzdata;
php_stream_bucket_brigade *brigade;
php_stream_bucket *bucket;
 
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, zz, zbrigade, 
zbucket) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, zo, zbrigade, 
zobject) == FAILURE) {
+   RETURN_FALSE;
+   }
+
+   if (FAILURE == zend_hash_find(Z_OBJPROP_P(zobject), bucket, 7, 
(void**)pzbucket)) {
+

[PHP-CVS] cvs: php4 /ext/standard basic_functions.c streamsfuncs.c streamsfuncs.h

2003-02-28 Thread Wez Furlong
wez Fri Feb 28 20:27:50 2003 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c streamsfuncs.c streamsfuncs.h 
  Log:
  Expose php_stream_copy_to_stream as stream_copy_to_stream(); a high
  performance alternative to looping reads and writes.
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.592 
php4/ext/standard/basic_functions.c:1.593
--- php4/ext/standard/basic_functions.c:1.592   Fri Feb 28 14:53:20 2003
+++ php4/ext/standard/basic_functions.c Fri Feb 28 20:27:50 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.592 2003/02/28 19:53:20 wez Exp $ */
+/* $Id: basic_functions.c,v 1.593 2003/03/01 01:27:50 wez Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -683,6 +683,7 @@
PHP_FE(stream_socket_server, 
second_and_third_args_force_ref)
PHP_FE(stream_socket_accept,   
third_arg_force_ref)
PHP_FE(stream_socket_get_name, 
 NULL)
+   PHP_FE(stream_copy_to_stream,  
 NULL)
PHP_FE(fgetcsv,
 NULL)
PHP_FE(flock,  
 NULL)
PHP_FE(get_meta_tags,  
 NULL)
Index: php4/ext/standard/streamsfuncs.c
diff -u php4/ext/standard/streamsfuncs.c:1.3 php4/ext/standard/streamsfuncs.c:1.4
--- php4/ext/standard/streamsfuncs.c:1.3Fri Feb 28 16:03:35 2003
+++ php4/ext/standard/streamsfuncs.cFri Feb 28 20:27:50 2003
@@ -17,7 +17,7 @@
   +--+
 */
 
-/* $Id: streamsfuncs.c,v 1.3 2003/02/28 21:03:35 wez Exp $ */
+/* $Id: streamsfuncs.c,v 1.4 2003/03/01 01:27:50 wez Exp $ */
 
 #include php.h
 #include php_globals.h
@@ -260,6 +260,25 @@
TSRMLS_CC)) {
RETURN_FALSE;
}
+}
+/* }}} */
+
+/* {{{ proto long stream_copy_to_stream(resource source, resource dest [, long maxlen 
])
+   Reads up to maxlen bytes from source stream and writes them to dest stream. */
+PHP_FUNCTION(stream_copy_to_stream)
+{
+   php_stream *src, *dest;
+   zval *zsrc, *zdest;
+   long maxlen = PHP_STREAM_COPY_ALL;
+
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, rr|l, zsrc, zdest, 
maxlen) == FAILURE) {
+   RETURN_FALSE;
+   }
+
+   php_stream_from_zval(src, zsrc);
+   php_stream_from_zval(dest, zdest);
+
+   RETURN_LONG(php_stream_copy_to_stream(src, dest, maxlen));
 }
 /* }}} */
 
Index: php4/ext/standard/streamsfuncs.h
diff -u php4/ext/standard/streamsfuncs.h:1.1 php4/ext/standard/streamsfuncs.h:1.2
--- php4/ext/standard/streamsfuncs.h:1.1Fri Feb 28 15:06:05 2003
+++ php4/ext/standard/streamsfuncs.hFri Feb 28 20:27:50 2003
@@ -16,7 +16,7 @@
   +--+
 */
 
-/* $Id: streamsfuncs.h,v 1.1 2003/02/28 20:06:05 wez Exp $ */
+/* $Id: streamsfuncs.h,v 1.2 2003/03/01 01:27:50 wez Exp $ */
 
 /* Flags for stream_socket_client */
 #define PHP_STREAM_CLIENT_PERSISTENT   1
@@ -26,6 +26,8 @@
 PHP_FUNCTION(stream_socket_server);
 PHP_FUNCTION(stream_socket_accept);
 PHP_FUNCTION(stream_socket_get_name);
+
+PHP_FUNCTION(stream_copy_to_stream);
 
 PHP_FUNCTION(set_socket_blocking); /* deprecated */
 PHP_FUNCTION(stream_set_blocking);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php4 /ext/standard basic_functions.c

2003-02-26 Thread Derick Rethans
derick  Wed Feb 26 14:25:24 2003 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c 
  Log:
  - Whitespace
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.588 
php4/ext/standard/basic_functions.c:1.589
--- php4/ext/standard/basic_functions.c:1.588   Mon Feb 24 16:56:18 2003
+++ php4/ext/standard/basic_functions.c Wed Feb 26 14:25:24 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.588 2003/02/24 21:56:18 pollita Exp $ */
+/* $Id: basic_functions.c,v 1.589 2003/02/26 19:25:24 derick Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -950,10 +950,10 @@
 PHP_INI_BEGIN()
PHP_INI_ENTRY_EX(safe_mode_protected_env_vars, SAFE_MODE_PROTECTED_ENV_VARS, 
PHP_INI_SYSTEM, OnUpdateSafeModeProtectedEnvVars, NULL)
PHP_INI_ENTRY_EX(safe_mode_allowed_env_vars,   SAFE_MODE_ALLOWED_ENV_VARS,   
PHP_INI_SYSTEM, OnUpdateSafeModeAllowedEnvVars,   NULL)
-   PHP_INI_ENTRY(date.default_latitude,  DATE_DEFAULT_LATITUDE, PHP_INI_ALL, 
NULL)
-   PHP_INI_ENTRY(date.default_longitude,  DATE_DEFAULT_LONGITUDE, PHP_INI_ALL, 
NULL)
-   PHP_INI_ENTRY(date.sunset_zenith,DATE_SUNSET_ZENITH, PHP_INI_ALL, NULL)
-   PHP_INI_ENTRY(date.sunrise_zenith,DATE_SUNRISE_ZENITH, PHP_INI_ALL, NULL)
+   PHP_INI_ENTRY(date.default_latitude,   DATE_DEFAULT_LATITUDE,
PHP_INI_ALL, NULL)
+   PHP_INI_ENTRY(date.default_longitude,  DATE_DEFAULT_LONGITUDE,   
PHP_INI_ALL, NULL)
+   PHP_INI_ENTRY(date.sunset_zenith,  DATE_SUNSET_ZENITH,   
PHP_INI_ALL, NULL)
+   PHP_INI_ENTRY(date.sunrise_zenith, DATE_SUNRISE_ZENITH,  
PHP_INI_ALL, NULL)
 PHP_INI_END()
 
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php4 /ext/standard basic_functions.c basic_functions.h user_filters.c

2003-02-24 Thread Sara Golemon
pollita Mon Feb 24 16:56:20 2003 EDT

  Modified files:  
/php4/ext/standard  user_filters.c basic_functions.c 
basic_functions.h 
  Log:
  Initial re-implementation of userfilters after filterchain redesign by wez.  More 
userspace API to come.
  
  Index: php4/ext/standard/user_filters.c
diff -u php4/ext/standard/user_filters.c:1.10 php4/ext/standard/user_filters.c:1.11
--- php4/ext/standard/user_filters.c:1.10   Mon Feb 17 20:22:21 2003
+++ php4/ext/standard/user_filters.cMon Feb 24 16:56:18 2003
@@ -14,10 +14,11 @@
+--+
| Authors: |
| Wez Furlong ([EMAIL PROTECTED])   |
+   | Sara Golemon ([EMAIL PROTECTED])   |
+--+
 */
 
-/* $Id: user_filters.c,v 1.10 2003/02/18 01:22:21 wez Exp $ */
+/* $Id: user_filters.c,v 1.11 2003/02/24 21:56:18 pollita Exp $ */
 
 /*
  * TODO: Rewrite for buckets.
@@ -45,6 +46,11 @@
 #include ext/standard/basic_functions.h
 #include ext/standard/file.h
 
+#define PHP_STREAM_BRIGADE_RES_NAMEuserfilter.bucket brigade
+#define PHP_STREAM_BUCKET_RES_NAME userfilter.bucket
+#define PHP_STREAM_FILTER_RES_NAME userfilter.filter
+#define PHP_STREAM_RES_NAME userfilter.stream
+
 struct php_user_filter_data {
zend_class_entry *ce;
/* variable length; this *must* be last in the structure */
@@ -53,6 +59,9 @@
 
 /* to provide context for calling into the next filter from user-space */
 static int le_userfilters;
+static int le_bucket_brigade;
+static int le_bucket;
+static int le_stream;
 
 #define GET_FILTER_FROM_OBJ()  { \
zval **tmp; \
@@ -70,9 +79,7 @@
 }
 
 static zend_function_entry user_filter_class_funcs[] = {
-   PHP_NAMED_FE(write, PHP_FN(user_filter_nop),NULL)
-   PHP_NAMED_FE(read,  PHP_FN(user_filter_nop),NULL)
-   PHP_NAMED_FE(flush, PHP_FN(user_filter_nop),NULL)
+   PHP_NAMED_FE(filter,PHP_FN(user_filter_nop),NULL)
PHP_NAMED_FE(oncreate,  PHP_FN(user_filter_nop),NULL)
PHP_NAMED_FE(onclose,   PHP_FN(user_filter_nop),NULL)
{ NULL, NULL, NULL }
@@ -90,10 +97,27 @@
 
/* init the filter resource; it has no dtor, as streams will always clean it up
 * at the correct time */
-   le_userfilters = zend_register_list_destructors_ex(NULL, NULL, stream 
filter, 0);
+   le_userfilters = zend_register_list_destructors_ex(NULL, NULL, 
PHP_STREAM_FILTER_RES_NAME, 0);
+
+   if (le_userfilters == FAILURE) {
+   return FAILURE;
+   }
 
-   if (le_userfilters == FAILURE)
+   le_bucket_brigade = zend_register_list_destructors_ex(NULL, NULL, 
PHP_STREAM_BRIGADE_RES_NAME, module_number);
+   le_bucket = zend_register_list_destructors_ex(NULL, NULL, 
PHP_STREAM_BUCKET_RES_NAME, module_number);
+   le_stream = zend_register_list_destructors_ex(NULL, NULL, PHP_STREAM_RES_NAME, 
module_number);
+   
+   if (le_bucket_brigade == FAILURE) {
return FAILURE;
+   }
+
+   REGISTER_LONG_CONSTANT(PSFS_PASS_ON,  PSFS_PASS_ON,  
 CONST_CS | CONST_PERSISTENT);
+   REGISTER_LONG_CONSTANT(PSFS_FEED_ME,  PSFS_FEED_ME,  
 CONST_CS | CONST_PERSISTENT);
+   REGISTER_LONG_CONSTANT(PSFS_ERR_FATAL,PSFS_ERR_FATAL,
 CONST_CS | CONST_PERSISTENT);
+
+   REGISTER_LONG_CONSTANT(PSFS_FLAG_NORMAL,  PSFS_FLAG_NORMAL,  
 CONST_CS | CONST_PERSISTENT);
+   REGISTER_LONG_CONSTANT(PSFS_FLAG_FLUSH_INC,   PSFS_FLAG_FLUSH_INC,
CONST_CS | CONST_PERSISTENT);
+   REGISTER_LONG_CONSTANT(PSFS_FLAG_FLUSH_CLOSE, PSFS_FLAG_FLUSH_CLOSE,  
CONST_CS | CONST_PERSISTENT);

return SUCCESS;
 }
@@ -117,7 +141,7 @@
if (retval)
zval_ptr_dtor(retval);
 
-   if (SUCCESS == zend_hash_index_find(Z_OBJPROP_P(obj), 0, (void**)tmp)) { 
+   if (SUCCESS == zend_hash_find(Z_OBJPROP_P(obj), filter, 6, (void**)tmp)) { 
zend_list_delete(Z_LVAL_PP(tmp));
FREE_ZVAL(*tmp);
} 
@@ -135,25 +159,49 @@
int flags
TSRMLS_DC)
 {
-   int ret = EOF;
+   int ret = PSFS_ERR_FATAL;
zval *obj = (zval*)thisfilter-abstract;
zval func_name;
zval *retval = NULL;
-   zval **args[1];
-   zval *zcount;
+   zval **args[4];
+   zval *zclosing, *zconsumed, *zin, *zout, *zstream;
int call_result;
 
+   if (FAILURE == zend_hash_find(Z_OBJPROP_P(obj), stream, 6, 
(void**)zstream)) {
+   /* Give the userfilter class a hook back to 

[PHP-CVS] cvs: php4 /ext/standard basic_functions.c dns.c dns.h

2003-02-23 Thread Jani Taskinen
sniper  Sun Feb 23 19:09:18 2003 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c dns.c dns.h 
  Log:
  Extra paranoia checks if dn_skipname/dn_expand exist or not
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.586 
php4/ext/standard/basic_functions.c:1.587
--- php4/ext/standard/basic_functions.c:1.586   Sat Feb 22 15:35:22 2003
+++ php4/ext/standard/basic_functions.c Sun Feb 23 19:09:18 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.586 2003/02/22 20:35:22 iliaa Exp $ */
+/* $Id: basic_functions.c,v 1.587 2003/02/24 00:09:18 sniper Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -598,8 +598,10 @@
 #if HAVE_RES_SEARCH  !(defined(__BEOS__) || defined(PHP_WIN32) || defined(NETWARE))
PHP_FE(dns_check_record,   
 NULL)
PHP_FALIAS(checkdnsrr,  dns_check_record,  
 NULL)
+# if HAVE_DN_SKIPNAME  HAVE_DN_EXPAND
PHP_FE(dns_get_mx,  
second_and_third_args_force_ref)
PHP_FALIAS(getmxrr, dns_get_mx, 
second_and_third_args_force_ref)
+# endif
 # if HAVE_DNS_FUNCS
PHP_FE(dns_get_record,  third_and_rest_force_ref)
 # endif
Index: php4/ext/standard/dns.c
diff -u php4/ext/standard/dns.c:1.56 php4/ext/standard/dns.c:1.57
--- php4/ext/standard/dns.c:1.56Fri Feb 21 03:45:58 2003
+++ php4/ext/standard/dns.c Sun Feb 23 19:09:18 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: dns.c,v 1.56 2003/02/21 08:45:58 sniper Exp $ */
+/* $Id: dns.c,v 1.57 2003/02/24 00:09:18 sniper Exp $ */
 
 /* {{{ includes */
 #include php.h
@@ -632,6 +632,7 @@
 /* }}} */
 #endif /* HAVE_DNS_FUNCS */
 
+#if HAVE_DN_SKIPNAME  HAVE_DN_EXPAND
 /* {{{ proto bool dns_get_mx(string hostname, array mxhosts [, array weight])
Get MX records corresponding to a given Internet host name */
 PHP_FUNCTION(dns_get_mx)
@@ -712,6 +713,7 @@
RETURN_TRUE;
 }
 /* }}} */
+#endif /* HAVE_DN_SKIPNAME  HAVE_DN_EXPAND */
 
 #endif /* HAVE_RES_SEARCH  !(defined(__BEOS__)||defined(PHP_WIN32) || 
defined(NETWARE)) */
 
Index: php4/ext/standard/dns.h
diff -u php4/ext/standard/dns.h:1.14 php4/ext/standard/dns.h:1.15
--- php4/ext/standard/dns.h:1.14Fri Feb 21 03:45:58 2003
+++ php4/ext/standard/dns.h Sun Feb 23 19:09:18 2003
@@ -18,7 +18,7 @@
+--+
 */
 
-/* $Id: dns.h,v 1.14 2003/02/21 08:45:58 sniper Exp $ */
+/* $Id: dns.h,v 1.15 2003/02/24 00:09:18 sniper Exp $ */
 
 #ifndef DNS_H
 #define DNS_H
@@ -34,7 +34,9 @@
 #if HAVE_RES_SEARCH  !(defined(__BEOS__)||defined(PHP_WIN32))
 
 PHP_FUNCTION(dns_check_record);
+# if HAVE_DN_SKIPNAME  HAVE_DN_EXPAND
 PHP_FUNCTION(dns_get_mx);
+# endif
 
 # if HAVE_DNS_FUNCS
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



[PHP-CVS] cvs: php4 /ext/standard basic_functions.c file.c file.h html.c

2003-02-22 Thread Ilia Alshanetsky
iliaa   Sat Feb 22 15:33:11 2003 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c file.c file.h html.c 
  Log:
  int/long change.
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.584 
php4/ext/standard/basic_functions.c:1.585
--- php4/ext/standard/basic_functions.c:1.584   Fri Feb 21 03:45:57 2003
+++ php4/ext/standard/basic_functions.c Sat Feb 22 15:33:11 2003
 -17,7 +17,7 
+--+
  */
 
-/* $Id: basic_functions.c,v 1.584 2003/02/21 08:45:57 sniper Exp $ */
+/* $Id: basic_functions.c,v 1.585 2003/02/22 20:33:11 iliaa Exp $ */
 
 #include php.h
 #include php_streams.h
 -670,6 +670,7 
PHP_STATIC_FE(tmpfile,php_if_tmpfile,
 NULL)
PHP_FE(file,   
 NULL)
PHP_FE(file_get_contents,  
 NULL)
+   PHP_FE(file_write_content, 
 NULL)
PHP_FE(stream_select, 
first_through_third_args_force_ref)
PHP_FE(stream_context_create,  
 NULL)
PHP_FE(stream_context_set_params,  
 NULL)
Index: php4/ext/standard/file.c
diff -u php4/ext/standard/file.c:1.307 php4/ext/standard/file.c:1.308
--- php4/ext/standard/file.c:1.307  Tue Feb 18 10:15:22 2003
+++ php4/ext/standard/file.cSat Feb 22 15:33:11 2003
 -21,7 +21,7 
+--+
  */
 
-/* $Id: file.c,v 1.307 2003/02/18 15:15:22 moriyoshi Exp $ */
+/* $Id: file.c,v 1.308 2003/02/22 20:33:11 iliaa Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
 -406,6 +406,67 
php_stream_close(md.stream);
 }
 
+/* }}} */
+
+/* {{{ proto int file_write_content(string filename, mixed content [, char mode [, 
bool use_include_path]])
+   Write a string to a file. */
+PHP_FUNCTION(file_write_content)
+{
+   zval *content;
+   char *filename, *mode;
+   int filename_len, mode_len = 0;
+   zend_bool use_include_path = 0;
+   size_t written;
+   php_stream *stream;
+
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, sz|sb, filename, 
filename_len, content, mode, mode_len, use_include_path) == FAILURE) {
+   RETURN_FALSE;
+   }
+
+   if (!(stream = php_stream_open_wrapper(filename, (mode_len ? mode : wb), 
(use_include_path ? USE_PATH : 0) | ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL))) {
+   RETURN_FALSE;
+   }
+
+   /* try to set an exclusive lock on the file to prevent access to the file 
while the write operation
+* is happening.
+*/
+   php_stream_set_option(stream, PHP_STREAM_OPTION_LOCKING, F_SETLKW, (void *) 
F_WRLCK TSRMLS_CC);
+
+   if (Z_TYPE_P(content) == IS_ARRAY) {
+   HashPosition pos;
+   zval **tmp;
+   size_t cur_write; 
+   
+   written = 0;
+   zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(content), pos);
+   
+   while (zend_hash_get_current_data_ex(Z_ARRVAL_P(content), (void **) 
tmp, pos) == SUCCESS) {
+   SEPARATE_ZVAL(tmp);
+   convert_to_string(*tmp);
+   
+   if ((cur_write = php_stream_write(stream, Z_STRVAL_PP(tmp), 
Z_STRLEN_PP(tmp)))  0) {
+   RETVAL_FALSE;
+   goto done;
+   }
+   written += cur_write;
+   
+   zend_hash_move_forward_ex(Z_ARRVAL_P(content), pos);
+   }
+   RETVAL_LONG(written);
+   } else {
+   SEPARATE_ZVAL(content);
+   convert_to_string(content);
+   if ((written = php_stream_write(stream, Z_STRVAL_P(content), 
Z_STRLEN_P(content)))  0) {
+   RETVAL_FALSE;
+   } else {
+   RETVAL_LONG(written);
+   }
+   zval_ptr_dtor(content);
+   }
+
+done:
+   php_stream_close(stream);
+}
 /* }}} */
 
 /* {{{ proto string file_get_contents(string filename [, bool use_include_path])
Index: php4/ext/standard/file.h
diff -u php4/ext/standard/file.h:1.75 php4/ext/standard/file.h:1.76
--- php4/ext/standard/file.h:1.75   Mon Feb 10 17:26:53 2003
+++ php4/ext/standard/file.hSat Feb 22 15:33:11 2003
 -16,7 +16,7 

[PHP-CVS] cvs: php4 /ext/standard basic_functions.c file.c file.h

2003-02-22 Thread Ilia Alshanetsky
iliaa   Sat Feb 22 15:35:22 2003 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c file.c file.h 
  Log:
  Revent previous patch, adding of file_write_content() was premature.
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.585 
php4/ext/standard/basic_functions.c:1.586
--- php4/ext/standard/basic_functions.c:1.585   Sat Feb 22 15:33:11 2003
+++ php4/ext/standard/basic_functions.c Sat Feb 22 15:35:22 2003
 -17,7 +17,7 
+--+
  */
 
-/* $Id: basic_functions.c,v 1.585 2003/02/22 20:33:11 iliaa Exp $ */
+/* $Id: basic_functions.c,v 1.586 2003/02/22 20:35:22 iliaa Exp $ */
 
 #include php.h
 #include php_streams.h
 -670,7 +670,6 
PHP_STATIC_FE(tmpfile,php_if_tmpfile,
 NULL)
PHP_FE(file,   
 NULL)
PHP_FE(file_get_contents,  
 NULL)
-   PHP_FE(file_write_content, 
 NULL)
PHP_FE(stream_select, 
first_through_third_args_force_ref)
PHP_FE(stream_context_create,  
 NULL)
PHP_FE(stream_context_set_params,  
 NULL)
Index: php4/ext/standard/file.c
diff -u php4/ext/standard/file.c:1.308 php4/ext/standard/file.c:1.309
--- php4/ext/standard/file.c:1.308  Sat Feb 22 15:33:11 2003
+++ php4/ext/standard/file.cSat Feb 22 15:35:22 2003
 -21,7 +21,7 
+--+
  */
 
-/* $Id: file.c,v 1.308 2003/02/22 20:33:11 iliaa Exp $ */
+/* $Id: file.c,v 1.309 2003/02/22 20:35:22 iliaa Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
 -406,67 +406,6 
php_stream_close(md.stream);
 }
 
-/* }}} */
-
-/* {{{ proto int file_write_content(string filename, mixed content [, char mode [, 
bool use_include_path]])
-   Write a string to a file. */
-PHP_FUNCTION(file_write_content)
-{
-   zval *content;
-   char *filename, *mode;
-   int filename_len, mode_len = 0;
-   zend_bool use_include_path = 0;
-   size_t written;
-   php_stream *stream;
-
-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, sz|sb, filename, 
filename_len, content, mode, mode_len, use_include_path) == FAILURE) {
-   RETURN_FALSE;
-   }
-
-   if (!(stream = php_stream_open_wrapper(filename, (mode_len ? mode : wb), 
(use_include_path ? USE_PATH : 0) | ENFORCE_SAFE_MODE | REPORT_ERRORS, NULL))) {
-   RETURN_FALSE;
-   }
-
-   /* try to set an exclusive lock on the file to prevent access to the file 
while the write operation
-* is happening.
-*/
-   php_stream_set_option(stream, PHP_STREAM_OPTION_LOCKING, F_SETLKW, (void *) 
F_WRLCK TSRMLS_CC);
-
-   if (Z_TYPE_P(content) == IS_ARRAY) {
-   HashPosition pos;
-   zval **tmp;
-   size_t cur_write; 
-   
-   written = 0;
-   zend_hash_internal_pointer_reset_ex(Z_ARRVAL_P(content), pos);
-   
-   while (zend_hash_get_current_data_ex(Z_ARRVAL_P(content), (void **) 
tmp, pos) == SUCCESS) {
-   SEPARATE_ZVAL(tmp);
-   convert_to_string(*tmp);
-   
-   if ((cur_write = php_stream_write(stream, Z_STRVAL_PP(tmp), 
Z_STRLEN_PP(tmp)))  0) {
-   RETVAL_FALSE;
-   goto done;
-   }
-   written += cur_write;
-   
-   zend_hash_move_forward_ex(Z_ARRVAL_P(content), pos);
-   }
-   RETVAL_LONG(written);
-   } else {
-   SEPARATE_ZVAL(content);
-   convert_to_string(content);
-   if ((written = php_stream_write(stream, Z_STRVAL_P(content), 
Z_STRLEN_P(content)))  0) {
-   RETVAL_FALSE;
-   } else {
-   RETVAL_LONG(written);
-   }
-   zval_ptr_dtor(content);
-   }
-
-done:
-   php_stream_close(stream);
-}
 /* }}} */
 
 /* {{{ proto string file_get_contents(string filename [, bool use_include_path])
Index: php4/ext/standard/file.h
diff -u php4/ext/standard/file.h:1.76 php4/ext/standard/file.h:1.77
--- php4/ext/standard/file.h:1.76   Sat Feb 22 15:33:11 2003
+++ php4/ext/standard/file.hSat Feb 22 15:35:22 2003
 -16,7 +16,7 

[PHP-CVS] cvs: php4 /ext/standard basic_functions.c dns.c dns.h

2003-02-21 Thread Jani Taskinen
sniper  Fri Feb 21 03:45:58 2003 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c dns.c dns.h 
  Log:
  - Fixed bug: #22339
  # No NEWS, this was bug introduced by Marcus a while ago..
  # Not present in php4.3.x branch
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.583 
php4/ext/standard/basic_functions.c:1.584
--- php4/ext/standard/basic_functions.c:1.583   Tue Feb 18 04:37:52 2003
+++ php4/ext/standard/basic_functions.c Fri Feb 21 03:45:57 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.583 2003/02/18 09:37:52 wez Exp $ */
+/* $Id: basic_functions.c,v 1.584 2003/02/21 08:45:57 sniper Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -598,10 +598,10 @@
 #if HAVE_RES_SEARCH  !(defined(__BEOS__) || defined(PHP_WIN32) || defined(NETWARE))
PHP_FE(dns_check_record,   
 NULL)
PHP_FALIAS(checkdnsrr,  dns_check_record,  
 NULL)
+   PHP_FE(dns_get_mx,  
+second_and_third_args_force_ref)
+   PHP_FALIAS(getmxrr, dns_get_mx, 
+second_and_third_args_force_ref)
 # if HAVE_DNS_FUNCS
PHP_FE(dns_get_record,  third_and_rest_force_ref)
-   PHP_FE(dns_get_mx,  
second_and_third_args_force_ref)
-   PHP_FALIAS(getmxrr, dns_get_mx,
 NULL)
 # endif
 #endif
 
Index: php4/ext/standard/dns.c
diff -u php4/ext/standard/dns.c:1.55 php4/ext/standard/dns.c:1.56
--- php4/ext/standard/dns.c:1.55Thu Feb 20 00:34:58 2003
+++ php4/ext/standard/dns.c Fri Feb 21 03:45:58 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: dns.c,v 1.55 2003/02/20 05:34:58 sniper Exp $ */
+/* $Id: dns.c,v 1.56 2003/02/21 08:45:58 sniper Exp $ */
 
 /* {{{ includes */
 #include php.h
@@ -630,6 +630,7 @@
}
 }
 /* }}} */
+#endif /* HAVE_DNS_FUNCS */
 
 /* {{{ proto bool dns_get_mx(string hostname, array mxhosts [, array weight])
Get MX records corresponding to a given Internet host name */
@@ -712,7 +713,6 @@
 }
 /* }}} */
 
-#endif /* HAVE_DNS_FUNCS */
 #endif /* HAVE_RES_SEARCH  !(defined(__BEOS__)||defined(PHP_WIN32) || 
defined(NETWARE)) */
 
 /*
Index: php4/ext/standard/dns.h
diff -u php4/ext/standard/dns.h:1.13 php4/ext/standard/dns.h:1.14
--- php4/ext/standard/dns.h:1.13Tue Dec 31 11:07:37 2002
+++ php4/ext/standard/dns.h Fri Feb 21 03:45:58 2003
@@ -18,7 +18,7 @@
+--+
 */
 
-/* $Id: dns.h,v 1.13 2002/12/31 16:07:37 sebastian Exp $ */
+/* $Id: dns.h,v 1.14 2003/02/21 08:45:58 sniper Exp $ */
 
 #ifndef DNS_H
 #define DNS_H
@@ -34,11 +34,11 @@
 #if HAVE_RES_SEARCH  !(defined(__BEOS__)||defined(PHP_WIN32))
 
 PHP_FUNCTION(dns_check_record);
+PHP_FUNCTION(dns_get_mx);
 
 # if HAVE_DNS_FUNCS
 
 PHP_FUNCTION(dns_get_record);
-PHP_FUNCTION(dns_get_mx);
 
 PHP_MINIT_FUNCTION(dns);
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c config.m4 exec.c exec.h

2003-02-17 Thread Ilia Alshanetsky
iliaa   Mon Feb 17 20:07:58 2003 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c config.m4 exec.c exec.h 
  Log:
  Added nice() function, which allows changing of priority for the current
  process.
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.580 
php4/ext/standard/basic_functions.c:1.581
--- php4/ext/standard/basic_functions.c:1.580   Mon Feb 17 01:28:06 2003
+++ php4/ext/standard/basic_functions.c Mon Feb 17 20:07:55 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.580 2003/02/17 06:28:06 sniper Exp $ */
+/* $Id: basic_functions.c,v 1.581 2003/02/18 01:07:55 iliaa Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -422,6 +422,10 @@
PHP_FE(proc_close, 
 NULL)
PHP_FE(proc_terminate, 
 NULL)
PHP_FE(proc_get_status,
 NULL)
+#endif
+
+#ifdef HAVE_NICE
+   PHP_FE(nice,   
+ NULL)   
 #endif
 
PHP_FE(rand,   
 NULL)
Index: php4/ext/standard/config.m4
diff -u php4/ext/standard/config.m4:1.55 php4/ext/standard/config.m4:1.56
--- php4/ext/standard/config.m4:1.55Sun Feb 16 17:28:00 2003
+++ php4/ext/standard/config.m4 Mon Feb 17 20:07:57 2003
@@ -1,4 +1,4 @@
-dnl $Id: config.m4,v 1.55 2003/02/16 22:28:00 momo Exp $ -*- sh -*-
+dnl $Id: config.m4,v 1.56 2003/02/18 01:07:57 iliaa Exp $ -*- sh -*-
 
 divert(3)dnl
 
@@ -273,6 +273,11 @@
 PHP_CHECK_FUNC(res_nsend, resolv, bind, socket)
 PHP_CHECK_FUNC(dn_expand, resolv, bind, socket)
 dnl already done PHP_CHECK_FUNC(dn_skipname, resolv, bind, socket)
+
+dnl
+dnl Check for the availability of the nice function
+dnl
+PHP_CHECK_FUNC(nice)
 
 PHP_NEW_EXTENSION(standard, array.c base64.c basic_functions.c browscap.c crc32.c 
crypt.c \
 cyr_convert.c datetime.c dir.c dl.c dns.c exec.c file.c 
filestat.c \
Index: php4/ext/standard/exec.c
diff -u php4/ext/standard/exec.c:1.92 php4/ext/standard/exec.c:1.93
--- php4/ext/standard/exec.c:1.92   Sat Jan 18 15:01:40 2003
+++ php4/ext/standard/exec.cMon Feb 17 20:07:57 2003
@@ -15,7 +15,7 @@
| Author: Rasmus Lerdorf   |
+--+
  */
-/* $Id: exec.c,v 1.92 2003/01/18 20:01:40 iliaa Exp $ */
+/* $Id: exec.c,v 1.93 2003/02/18 01:07:57 iliaa Exp $ */
 
 #include stdio.h
 #include php.h
@@ -45,6 +45,10 @@
 #include fcntl.h
 #endif
 
+#if HAVE_NICE  HAVE_UNISTD_H
+#include unistd.h
+#endif
+
 /* {{{ php_Exec
  * If type==0, only last line of output is returned (exec)
  * If type==1, all lines will be printed and last lined returned (system)
@@ -486,6 +490,29 @@
Z_STRVAL_P(return_value)[total_readbytes] = '\0';   
 }
 /* }}} */
+
+#ifdef HAVE_NICE
+/* {{{ proto bool nice(int priority)
+   Change the priority of the current process */
+PHP_FUNCTION(nice)
+{
+   long pri;
+
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, l, pri) == FAILURE) {
+   RETURN_FALSE;
+   }
+
+   errno = 0;
+   nice(pri);
+   if (errno) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Only a super user may 
+attempt to increase the process priority.);
+   RETURN_FALSE;
+   }
+   
+   RETURN_TRUE;
+}
+/* }}} */
+#endif
 
 /*
  * Local variables:
Index: php4/ext/standard/exec.h
diff -u php4/ext/standard/exec.h:1.18 php4/ext/standard/exec.h:1.19
--- php4/ext/standard/exec.h:1.18   Sat Feb 15 12:18:57 2003
+++ php4/ext/standard/exec.hMon Feb 17 20:07:57 2003
@@ -16,7 +16,7 @@
+--+
 */
 
-/* $Id: exec.h,v 1.18 2003/02/15 17:18:57 wez Exp $ */
+/* $Id: exec.h,v 1.19 2003/02/18 01:07:57 iliaa Exp $ */
 
 #ifndef EXEC_H
 #define EXEC_H
@@ -31,6 +31,7 @@
 PHP_FUNCTION(proc_get_status);
 PHP_FUNCTION(proc_close);
 PHP_FUNCTION(proc_terminate);
+PHP_FUNCTION(nice);
 PHP_MINIT_FUNCTION(proc_open);
 
 char *php_escape_shell_cmd(char *);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-CVS] cvs: php4 /ext/standard basic_functions.c config.m4 exec.c exec.h

2003-02-17 Thread Jon Parise
On Tue, Feb 18, 2003 at 01:07:58AM -, Ilia Alshanetsky wrote:

 iliaa Mon Feb 17 20:07:58 2003 EDT
 
   Modified files:  
 /php4/ext/standardbasic_functions.c config.m4 exec.c exec.h 
   Log:
   Added nice() function, which allows changing of priority for the current
   process.
   
What do you think about naming it proc_nice() instead?

-- 
Jon Parise ([EMAIL PROTECTED]) :: The PHP Project (http://www.php.net/)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c exec.c exec.h

2003-02-17 Thread Ilia Alshanetsky
iliaa   Mon Feb 17 20:23:52 2003 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c exec.c exec.h 
  Log:
  By popular demand nice() is renamed to proc_nice().
  A better error message for proc_nice() failure.
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.581 
php4/ext/standard/basic_functions.c:1.582
--- php4/ext/standard/basic_functions.c:1.581   Mon Feb 17 20:07:55 2003
+++ php4/ext/standard/basic_functions.c Mon Feb 17 20:23:51 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.581 2003/02/18 01:07:55 iliaa Exp $ */
+/* $Id: basic_functions.c,v 1.582 2003/02/18 01:23:51 iliaa Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -425,7 +425,7 @@
 #endif
 
 #ifdef HAVE_NICE
-   PHP_FE(nice,   
 NULL)   
+   PHP_FE(proc_nice,  
+ NULL)   
 #endif
 
PHP_FE(rand,   
 NULL)
Index: php4/ext/standard/exec.c
diff -u php4/ext/standard/exec.c:1.93 php4/ext/standard/exec.c:1.94
--- php4/ext/standard/exec.c:1.93   Mon Feb 17 20:07:57 2003
+++ php4/ext/standard/exec.cMon Feb 17 20:23:51 2003
@@ -15,7 +15,7 @@
| Author: Rasmus Lerdorf   |
+--+
  */
-/* $Id: exec.c,v 1.93 2003/02/18 01:07:57 iliaa Exp $ */
+/* $Id: exec.c,v 1.94 2003/02/18 01:23:51 iliaa Exp $ */
 
 #include stdio.h
 #include php.h
@@ -492,9 +492,9 @@
 /* }}} */
 
 #ifdef HAVE_NICE
-/* {{{ proto bool nice(int priority)
+/* {{{ proto bool proc_nice(int priority)
Change the priority of the current process */
-PHP_FUNCTION(nice)
+PHP_FUNCTION(proc_nice)
 {
long pri;
 
@@ -505,7 +505,7 @@
errno = 0;
nice(pri);
if (errno) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, Only a super user may 
attempt to increase the process priority.);
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Only a super user may 
+attempt to increase the priority of a process.);
RETURN_FALSE;
}

Index: php4/ext/standard/exec.h
diff -u php4/ext/standard/exec.h:1.19 php4/ext/standard/exec.h:1.20
--- php4/ext/standard/exec.h:1.19   Mon Feb 17 20:07:57 2003
+++ php4/ext/standard/exec.hMon Feb 17 20:23:51 2003
@@ -16,7 +16,7 @@
+--+
 */
 
-/* $Id: exec.h,v 1.19 2003/02/18 01:07:57 iliaa Exp $ */
+/* $Id: exec.h,v 1.20 2003/02/18 01:23:51 iliaa Exp $ */
 
 #ifndef EXEC_H
 #define EXEC_H
@@ -31,7 +31,7 @@
 PHP_FUNCTION(proc_get_status);
 PHP_FUNCTION(proc_close);
 PHP_FUNCTION(proc_terminate);
-PHP_FUNCTION(nice);
+PHP_FUNCTION(proc_nice);
 PHP_MINIT_FUNCTION(proc_open);
 
 char *php_escape_shell_cmd(char *);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c exec.h proc_open.c

2003-02-15 Thread Wez Furlong
wez Sat Feb 15 12:18:57 2003 EDT

  Modified files:  
/php4/ext/standard  exec.h proc_open.c basic_functions.c 
  Log:
  Add proc_terminate() function to forcibly kill off a process created
  with proc_open().
  
  
Index: php4/ext/standard/exec.h
diff -u php4/ext/standard/exec.h:1.17 php4/ext/standard/exec.h:1.18
--- php4/ext/standard/exec.h:1.17   Wed Jan 15 13:54:03 2003
+++ php4/ext/standard/exec.hSat Feb 15 12:18:57 2003
@@ -16,7 +16,7 @@
+--+
 */
 
-/* $Id: exec.h,v 1.17 2003/01/15 18:54:03 wez Exp $ */
+/* $Id: exec.h,v 1.18 2003/02/15 17:18:57 wez Exp $ */
 
 #ifndef EXEC_H
 #define EXEC_H
@@ -30,6 +30,7 @@
 PHP_FUNCTION(proc_open);
 PHP_FUNCTION(proc_get_status);
 PHP_FUNCTION(proc_close);
+PHP_FUNCTION(proc_terminate);
 PHP_MINIT_FUNCTION(proc_open);
 
 char *php_escape_shell_cmd(char *);
Index: php4/ext/standard/proc_open.c
diff -u php4/ext/standard/proc_open.c:1.3 php4/ext/standard/proc_open.c:1.4
--- php4/ext/standard/proc_open.c:1.3   Fri Jan 24 11:45:34 2003
+++ php4/ext/standard/proc_open.c   Sat Feb 15 12:18:57 2003
@@ -15,7 +15,7 @@
| Author: Wez Furlong [EMAIL PROTECTED]   |
+--+
  */
-/* $Id: proc_open.c,v 1.3 2003/01/24 16:45:34 iliaa Exp $ */
+/* $Id: proc_open.c,v 1.4 2003/02/15 17:18:57 wez Exp $ */
 
 #include stdio.h
 #include php.h
@@ -173,6 +173,32 @@
le_proc_open = zend_register_list_destructors_ex(proc_open_rsrc_dtor, NULL, 
process, module_number);
return SUCCESS;
 }
+
+
+/* {{{ proto int proc_terminate(resource process)
+   kill a process opened by proc_open */
+PHP_FUNCTION(proc_terminate)
+{
+   zval *zproc;
+   struct php_process_handle *proc;
+   
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, r, zproc) == FAILURE) {
+   RETURN_FALSE;
+   }
+
+   ZEND_FETCH_RESOURCE(proc, struct php_process_handle *, zproc, -1, process, 
+le_proc_open);
+   
+#ifdef PHP_WIN32
+   TerminateProcess(proc-child, 255);
+#else
+   kill(proc-child, SIGTERM);
+#endif
+   
+   zend_list_delete(Z_LVAL_P(zproc));
+   RETURN_LONG(FG(pclose_ret));
+}
+/* }}} */
+
 
 /* {{{ proto int proc_close(resource process)
close a process opened by proc_open */
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.577 
php4/ext/standard/basic_functions.c:1.578
--- php4/ext/standard/basic_functions.c:1.577   Tue Feb 11 17:47:26 2003
+++ php4/ext/standard/basic_functions.c Sat Feb 15 12:18:57 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.577 2003/02/11 22:47:26 iliaa Exp $ */
+/* $Id: basic_functions.c,v 1.578 2003/02/15 17:18:57 wez Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -419,6 +419,7 @@
 #ifdef PHP_CAN_SUPPORT_PROC_OPEN
PHP_FE(proc_open,   third_arg_force_ref)
PHP_FE(proc_close, 
 NULL)
+   PHP_FE(proc_terminate, 
+ NULL)
PHP_FE(proc_get_status,
 NULL)
 #endif
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c php_string.h string.c

2003-02-11 Thread Ilia Alshanetsky
iliaa   Tue Feb 11 17:47:26 2003 EDT

  Modified files:  
/php4/ext/standard  string.c php_string.h basic_functions.c 
  Log:
  Added strpbrk(), which is essentially a wrapper around C's strpbrk function
  that allows searching through a string for a character list.
  
  
Index: php4/ext/standard/string.c
diff -u php4/ext/standard/string.c:1.355 php4/ext/standard/string.c:1.356
--- php4/ext/standard/string.c:1.355Sat Feb  8 10:26:17 2003
+++ php4/ext/standard/string.c  Tue Feb 11 17:47:25 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: string.c,v 1.355 2003/02/08 15:26:17 sniper Exp $ */
+/* $Id: string.c,v 1.356 2003/02/11 22:47:25 iliaa Exp $ */
 
 /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
 
@@ -4379,6 +4379,30 @@
 }
 /* }}} */
 
+/* {{{ proto array strpbrk(string haystack, string char_list)
+   Search a string for any of a set of characters */
+PHP_FUNCTION(strpbrk)
+{
+   char *haystack, *char_list;
+   int haystack_len, char_list_len;
+   char *p;
+   
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, ss, haystack, 
+haystack_len, char_list, char_list_len) == FAILURE) {
+   RETURN_FALSE;
+   }
+
+   if (!char_list_len) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, The character list cannot 
+be empty.);
+   RETURN_FALSE;   
+   }
+
+   if ((p = strpbrk(haystack, char_list))) {
+   RETURN_STRINGL(p, (haystack + haystack_len - p), 1);
+   } else {
+   RETURN_FALSE;
+   }
+}
+/* }}} */
 
 /*
  * Local variables:
Index: php4/ext/standard/php_string.h
diff -u php4/ext/standard/php_string.h:1.70 php4/ext/standard/php_string.h:1.71
--- php4/ext/standard/php_string.h:1.70 Fri Feb  7 16:36:18 2003
+++ php4/ext/standard/php_string.h  Tue Feb 11 17:47:26 2003
@@ -17,7 +17,7 @@
+--+
 */
 
-/* $Id: php_string.h,v 1.70 2003/02/07 21:36:18 iliaa Exp $ */
+/* $Id: php_string.h,v 1.71 2003/02/11 22:47:26 iliaa Exp $ */
 
 /* Synced with php 3.0 revision 1.43 1999-06-16 [ssb] */
 
@@ -88,6 +88,7 @@
 PHP_FUNCTION(str_shuffle);
 PHP_FUNCTION(str_word_count);
 PHP_FUNCTION(str_split);
+PHP_FUNCTION(strpbrk);
 #ifdef HAVE_STRCOLL
 PHP_FUNCTION(strcoll);
 #endif
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.576 
php4/ext/standard/basic_functions.c:1.577
--- php4/ext/standard/basic_functions.c:1.576   Sun Feb  9 15:43:05 2003
+++ php4/ext/standard/basic_functions.c Tue Feb 11 17:47:26 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.576 2003/02/09 20:43:05 iliaa Exp $ */
+/* $Id: basic_functions.c,v 1.577 2003/02/11 22:47:26 iliaa Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -343,6 +343,7 @@
PHP_FE(str_shuffle,
 NULL)
PHP_FE(str_word_count, 
 NULL)
PHP_FE(str_split,  
 NULL)
+   PHP_FE(strpbrk,
+ NULL)
 
 #ifdef HAVE_STRCOLL
PHP_FE(strcoll,
 NULL)



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c file.c file.h /main php_streams.h streams.c

2003-02-09 Thread Ilia Alshanetsky
iliaa   Sun Feb  9 15:43:06 2003 EDT

  Modified files:  
/php4/main  streams.c php_streams.h 
/php4/ext/standard  file.c file.h basic_functions.c 
  Log:
  Added feature request #9173 (added stream_get_line(), this function will 
  read either the specified number of bytes or until the ending string is 
  found).
  
  
Index: php4/main/streams.c
diff -u php4/main/streams.c:1.144 php4/main/streams.c:1.145
--- php4/main/streams.c:1.144   Fri Feb  7 16:33:35 2003
+++ php4/main/streams.c Sun Feb  9 15:43:05 2003
@@ -20,7 +20,7 @@
+--+
  */
 
-/* $Id: streams.c,v 1.144 2003/02/07 21:33:35 iliaa Exp $ */
+/* $Id: streams.c,v 1.145 2003/02/09 20:43:05 iliaa Exp $ */
 
 #define _GNU_SOURCE
 #include php.h
@@ -29,6 +29,7 @@
 #include php_open_temporary_file.h
 #include ext/standard/file.h
 #include ext/standard/basic_functions.h /* for BG(mmap_file) (not strictly 
required) */
+#include ext/standard/php_string.h /* for php_memnstr, used by 
+php_stream_get_record() */
 #ifdef HAVE_SYS_MMAN_H
 #include sys/mman.h
 #endif
@@ -2607,6 +2608,40 @@
 PHPAPI HashTable *php_stream_get_url_stream_wrappers_hash()
 {
return url_stream_wrappers_hash;
+}
+
+PHPAPI char *php_stream_get_record(php_stream *stream, size_t maxlen, size_t 
+*returned_len, char *delim, size_t delim_len TSRMLS_DC)
+{
+   char *e, *buf;
+   size_t toread;
+
+   php_stream_fill_read_buffer(stream, maxlen TSRMLS_CC);
+
+   if (delim_len == 0) {
+   toread = maxlen;
+   } else {
+   if (delim_len == 1) {
+   e = memchr(stream-readbuf, *delim, stream-readbuflen);
+   } else {
+   e = php_memnstr(stream-readbuf, delim, delim_len, 
+(stream-readbuf + stream-readbuflen));
+   }
+
+   if (!e) {
+   toread = maxlen;
+   } else {
+   toread = e - (char *) stream-readbuf;
+   }
+   }
+
+   buf = emalloc(toread + 1);
+   *returned_len = php_stream_read(stream, buf, toread);
+   
+   if (*returned_len = 0) {
+   return buf;
+   } else {
+   efree(buf);
+   return NULL;
+   }
 }
 
 /*
Index: php4/main/php_streams.h
diff -u php4/main/php_streams.h:1.67 php4/main/php_streams.h:1.68
--- php4/main/php_streams.h:1.67Fri Feb  7 17:49:21 2003
+++ php4/main/php_streams.h Sun Feb  9 15:43:05 2003
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: php_streams.h,v 1.67 2003/02/07 22:49:21 iliaa Exp $ */
+/* $Id: php_streams.h,v 1.68 2003/02/09 20:43:05 iliaa Exp $ */
 
 #ifndef PHP_STREAMS_H
 #define PHP_STREAMS_H
@@ -290,6 +290,7 @@
 PHPAPI php_stream_filter *php_stream_filter_remove(php_stream *stream, 
php_stream_filter *filter, int call_dtor TSRMLS_DC);
 PHPAPI void php_stream_filter_free(php_stream_filter *filter TSRMLS_DC);
 PHPAPI php_stream_filter *_php_stream_filter_alloc(php_stream_filter_ops *fops, void 
*abstract, int persistent STREAMS_DC TSRMLS_DC);
+PHPAPI char *php_stream_get_record(php_stream *stream, size_t maxlen, size_t 
+*returned_len, char *delim, size_t delim_len TSRMLS_DC);
 #define php_stream_filter_alloc(fops, thisptr, persistent) 
_php_stream_filter_alloc((fops), (thisptr), (persistent) STREAMS_CC TSRMLS_CC)
 #define php_stream_filter_alloc_rel(fops, thisptr, persistent) 
_php_stream_filter_alloc((fops), (thisptr), (persistent) STREAMS_REL_CC TSRMLS_CC)
 
Index: php4/ext/standard/file.c
diff -u php4/ext/standard/file.c:1.298 php4/ext/standard/file.c:1.299
--- php4/ext/standard/file.c:1.298  Sun Feb  9 15:35:54 2003
+++ php4/ext/standard/file.cSun Feb  9 15:43:05 2003
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.298 2003/02/09 20:35:54 iliaa Exp $ */
+/* $Id: file.c,v 1.299 2003/02/09 20:43:05 iliaa Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -1128,6 +1128,37 @@
apply_filter_to_stream(1, INTERNAL_FUNCTION_PARAM_PASSTHRU);
 }
 /* }}} */
+
+/* {{{ proto string stream_get_line(resource stream, int maxlen, string ending)
+   Read up to maxlen bytes from a stream or until the ending string is found */
+PHP_FUNCTION(stream_get_line)
+{
+   char *str;
+   int str_len;
+   long max_length;
+   zval *zstream;
+   char *buf;
+   size_t buf_size;
+   php_stream *stream;
+   
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, rls, zstream, 
+max_length, str, str_len) == FAILURE) {
+   RETURN_FALSE;
+   }
+
+   if (max_length  0) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, The maximum allowed 
+length must be greater then or equal to zero.);
+   RETURN_FALSE;
+   }
+
+   php_stream_from_zval(stream, zstream);

[PHP-CVS] cvs: php4 /ext/standard basic_functions.c url.c url.h /main streams.c

2003-02-07 Thread Ilia Alshanetsky
iliaa   Fri Feb  7 16:33:36 2003 EDT

  Modified files:  
/php4/main  streams.c 
/php4/ext/standard  url.c url.h basic_functions.c 
  Log:
  Added get_browser() function. This function can be used to fetch the headers
  sent by the server when a request is made for a given URL.
  
  
Index: php4/main/streams.c
diff -u php4/main/streams.c:1.143 php4/main/streams.c:1.144
--- php4/main/streams.c:1.143   Thu Jan 30 16:06:34 2003
+++ php4/main/streams.c Fri Feb  7 16:33:35 2003
@@ -20,7 +20,7 @@
+--+
  */
 
-/* $Id: streams.c,v 1.143 2003/01/30 21:06:34 sas Exp $ */
+/* $Id: streams.c,v 1.144 2003/02/07 21:33:35 iliaa Exp $ */
 
 #define _GNU_SOURCE
 #include php.h
@@ -2379,6 +2379,10 @@
path_to_open = path;
 
wrapper = php_stream_locate_url_wrapper(path, path_to_open, options 
TSRMLS_CC);
+   if (options  STREAM_USE_URL  (!wrapper || !wrapper-is_url)) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, This function may only be 
+used against URLs.);
+   return NULL;
+   }
 
if (wrapper){
 
Index: php4/ext/standard/url.c
diff -u php4/ext/standard/url.c:1.62 php4/ext/standard/url.c:1.63
--- php4/ext/standard/url.c:1.62Tue Dec 31 11:07:56 2002
+++ php4/ext/standard/url.c Fri Feb  7 16:33:35 2003
@@ -15,7 +15,7 @@
| Author: Jim Winstead [EMAIL PROTECTED]  |
+--+
  */
-/* $Id: url.c,v 1.62 2002/12/31 16:07:56 sebastian Exp $ */
+/* $Id: url.c,v 1.63 2003/02/07 21:33:35 iliaa Exp $ */
 
 #include stdlib.h
 #include string.h
@@ -549,6 +549,63 @@
}
*dest = '\0';
return dest - str;
+}
+/* }}} */
+
+/* {{{ proto array get_headers(string url)
+   fetches all the headers sent by the server in response to a HTTP request */
+PHP_FUNCTION(get_headers)
+{
+   char *url, *url_len;
+   php_stream_context *context = NULL;
+   php_stream *stream;
+   zval **prev_val, **hdr = NULL;
+   HashPosition pos;
+   long format = 0;
+
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|l, url, url_len, 
+format) == FAILURE) {
+   return;
+   }
+
+   if (!(stream = php_stream_open_wrapper_ex(url, r, REPORT_ERRORS | 
+STREAM_USE_URL | STREAM_ONLY_GET_HEADERS, NULL, context))) {
+   RETURN_FALSE;
+   }
+
+   array_init(return_value);
+
+   zend_hash_internal_pointer_reset_ex(HASH_OF(stream-wrapperdata), pos);
+   while (zend_hash_get_current_data_ex(HASH_OF(stream-wrapperdata), 
+(void**)hdr, pos) != FAILURE) {
+   if (!format) {
+no_name_header:
+   add_next_index_stringl(return_value, Z_STRVAL_PP(hdr), 
+Z_STRLEN_PP(hdr), 1);
+   } else {
+   char c;
+   char *s, *p;
+
+   if ((p = strchr(Z_STRVAL_PP(hdr), ':'))) {
+   c = *p;
+   *p = '\0';
+   s = p + 1;
+   while (isspace(*s)) {
+   s++;
+   }
+
+   if (zend_hash_find(HASH_OF(return_value), 
+Z_STRVAL_PP(hdr), (p - Z_STRVAL_PP(hdr) + 1), (void **) prev_val) == FAILURE) {
+   add_assoc_stringl_ex(return_value, 
+Z_STRVAL_PP(hdr), (p - Z_STRVAL_PP(hdr) + 1), s, (Z_STRLEN_PP(hdr) - (s - 
+Z_STRVAL_PP(hdr))), 1);
+   } else { /* some headers may occur more then once, 
+therefor we need to remake the string into an array */
+   convert_to_array(*prev_val);
+   add_next_index_stringl(*prev_val, s, 
+(Z_STRLEN_PP(hdr) - (s - Z_STRVAL_PP(hdr))), 1);
+   }
+
+   *p = c;
+   } else {
+   goto no_name_header;
+   }
+   }
+   zend_hash_move_forward_ex(HASH_OF(stream-wrapperdata), pos);
+   }
+
+   php_stream_close(stream);
 }
 /* }}} */
 
Index: php4/ext/standard/url.h
diff -u php4/ext/standard/url.h:1.14 php4/ext/standard/url.h:1.15
--- php4/ext/standard/url.h:1.14Tue Dec 31 11:07:56 2002
+++ php4/ext/standard/url.h Fri Feb  7 16:33:35 2003
@@ -15,7 +15,7 @@
| Author: Jim Winstead [EMAIL PROTECTED]  |
+--+
  */
-/* $Id: url.h,v 1.14 2002/12/31 16:07:56 sebastian Exp $ */
+/* $Id: url.h,v 1.15 2003/02/07 21:33:35 iliaa Exp $ */
 
 #ifndef URL_H
 #define URL_H
@@ -43,6 +43,7 @@
 PHP_FUNCTION(urldecode);
 PHP_FUNCTION(rawurlencode);
 PHP_FUNCTION(rawurldecode);
+PHP_FUNCTION(get_headers);
 
 #endif 

Re: [PHP-CVS] cvs: php4 /ext/standard basic_functions.c url.c url.h /main streams.c

2003-02-07 Thread Derick Rethans
On Fri, 7 Feb 2003, Ilia Alshanetsky wrote:

 iliaa Fri Feb  7 16:33:36 2003 EDT
 
   Modified files:  
 /php4/mainstreams.c 
 /php4/ext/standardurl.c url.h basic_functions.c 
   Log:
   Added get_browser() function. This function can be used to fetch the headers

s/get_browser/get_headers

Derick

-- 

-
 Derick Rethans http://derickrethans.nl/ 
 PHP Magazine - PHP Magazine for Professionals   http://php-mag.net/
-


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c php_string.h string.c

2003-02-07 Thread Ilia Alshanetsky
iliaa   Fri Feb  7 16:36:18 2003 EDT

  Modified files:  
/php4/ext/standard  string.c php_string.h basic_functions.c 
  Log:
  Added str_split() function. This function can be used to break down a 
  string into an array.
  
  
Index: php4/ext/standard/string.c
diff -u php4/ext/standard/string.c:1.353 php4/ext/standard/string.c:1.354
--- php4/ext/standard/string.c:1.353Thu Jan 30 15:09:19 2003
+++ php4/ext/standard/string.c  Fri Feb  7 16:36:18 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: string.c,v 1.353 2003/01/30 20:09:19 pollita Exp $ */
+/* $Id: string.c,v 1.354 2003/02/07 21:36:18 iliaa Exp $ */
 
 /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
 
@@ -37,6 +37,9 @@
 #ifdef HAVE_MONETARY_H
 # include monetary.h
 #endif
+
+#include math.h
+
 #include scanf.h
 #include zend_API.h
 #include zend_execute.h
@@ -4296,9 +4299,43 @@
 
RETURN_STRINGL(erealloc(str, str_len + 1), str_len, 0);
 }
-
 /* }}} */
 #endif
+
+/* {{{ proto array str_split(string str [, int split_length])
+   Convert a string to an array. If split_length is specified, break the string down 
+into chunks each split_length characters long. */
+PHP_FUNCTION(str_split) {
+   char *str;
+   int str_len;
+   long split_length = 1;
+   char *p;
+   int n_reg_segments;
+   
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s|l, str, str_len, 
+split_length) == FAILURE) {
+   return;
+   }
+
+   if (split_length = 0) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, The the length of each 
+segment must be greater then zero.);
+   RETURN_FALSE;
+   }
+
+   array_init(return_value);
+
+   n_reg_segments = floor(str_len / split_length);
+   p = str;
+
+   while (n_reg_segments--  0) {
+   add_next_index_stringl(return_value, p, split_length, 1);
+   p += split_length;
+   }
+
+   if (p != (str + str_len)) {
+   add_next_index_stringl(return_value, p, (str + str_len - p), 1);
+   }
+}
+/* }}} */
+
 
 /*
  * Local variables:
Index: php4/ext/standard/php_string.h
diff -u php4/ext/standard/php_string.h:1.69 php4/ext/standard/php_string.h:1.70
--- php4/ext/standard/php_string.h:1.69 Thu Jan 30 00:00:40 2003
+++ php4/ext/standard/php_string.h  Fri Feb  7 16:36:18 2003
@@ -17,7 +17,7 @@
+--+
 */
 
-/* $Id: php_string.h,v 1.69 2003/01/30 05:00:40 pollita Exp $ */
+/* $Id: php_string.h,v 1.70 2003/02/07 21:36:18 iliaa Exp $ */
 
 /* Synced with php 3.0 revision 1.43 1999-06-16 [ssb] */
 
@@ -87,6 +87,7 @@
 PHP_FUNCTION(sscanf);
 PHP_FUNCTION(str_shuffle);
 PHP_FUNCTION(str_word_count);
+PHP_FUNCTION(str_split);
 #ifdef HAVE_STRCOLL
 PHP_FUNCTION(strcoll);
 #endif
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.572 
php4/ext/standard/basic_functions.c:1.573
--- php4/ext/standard/basic_functions.c:1.572   Fri Feb  7 16:33:35 2003
+++ php4/ext/standard/basic_functions.c Fri Feb  7 16:36:18 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.572 2003/02/07 21:33:35 iliaa Exp $ */
+/* $Id: basic_functions.c,v 1.573 2003/02/07 21:36:18 iliaa Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -342,6 +342,7 @@
PHP_FE(strrchr,
 NULL)
PHP_FE(str_shuffle,
 NULL)
PHP_FE(str_word_count, 
 NULL)
+   PHP_FE(str_split,  
+ NULL)
 
 #ifdef HAVE_STRCOLL
PHP_FE(strcoll,
 NULL)



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c

2003-02-03 Thread Ilia Alshanetsky
iliaa   Mon Feb  3 16:48:37 2003 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c 
  Log:
  Make putenv() return a proper error rather then NULL when invalid argument
  is passed.
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.569 
php4/ext/standard/basic_functions.c:1.570
--- php4/ext/standard/basic_functions.c:1.569   Thu Jan 30 00:00:40 2003
+++ php4/ext/standard/basic_functions.c Mon Feb  3 16:48:36 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.569 2003/01/30 05:00:40 pollita Exp $ */
+/* $Id: basic_functions.c,v 1.570 2003/02/03 21:48:36 iliaa Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -1402,6 +1402,9 @@
RETURN_FALSE;
}
}
+
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, Invalid parameter syntax.);
+   RETURN_FALSE;
 }
 /* }}} */
 #endif



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c php_string.h string.c

2003-01-29 Thread Sara Golemon
pollita Thu Jan 30 00:00:42 2003 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c php_string.h string.c 
  Log:
  Feature Request # 5919 - Addition of str_ireplace()
  Also removed deprecated BM str replace menthod
  Also rewrote php_str_to_str to use more processor/memory efficient method (ilia)
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.568 
php4/ext/standard/basic_functions.c:1.569
--- php4/ext/standard/basic_functions.c:1.568   Tue Jan 28 19:49:09 2003
+++ php4/ext/standard/basic_functions.c Thu Jan 30 00:00:40 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.568 2003/01/29 00:49:09 phanto Exp $ */
+/* $Id: basic_functions.c,v 1.569 2003/01/30 05:00:40 pollita Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -361,6 +361,7 @@
PHP_FE(addcslashes,
 NULL)
PHP_FE(rtrim,  
 NULL)
PHP_FE(str_replace,
 NULL)
+   PHP_FE(str_ireplace,   
+ NULL)
PHP_FE(str_repeat, 
 NULL)
PHP_FE(count_chars,
 NULL)
PHP_FE(chunk_split,
 NULL)
Index: php4/ext/standard/php_string.h
diff -u php4/ext/standard/php_string.h:1.68 php4/ext/standard/php_string.h:1.69
--- php4/ext/standard/php_string.h:1.68 Tue Jan 28 19:07:01 2003
+++ php4/ext/standard/php_string.h  Thu Jan 30 00:00:40 2003
@@ -17,7 +17,7 @@
+--+
 */
 
-/* $Id: php_string.h,v 1.68 2003/01/29 00:07:01 iliaa Exp $ */
+/* $Id: php_string.h,v 1.69 2003/01/30 05:00:40 pollita Exp $ */
 
 /* Synced with php 3.0 revision 1.43 1999-06-16 [ssb] */
 
@@ -27,6 +27,7 @@
 PHP_FUNCTION(strspn);
 PHP_FUNCTION(strcspn);
 PHP_FUNCTION(str_replace);
+PHP_FUNCTION(str_ireplace);
 PHP_FUNCTION(rtrim);
 PHP_FUNCTION(trim);
 PHP_FUNCTION(ltrim);
@@ -121,6 +122,8 @@
 PHPAPI char *php_basename(char *str, size_t  len , char *suffix, size_t sufflen);
 PHPAPI void php_dirname(char *str, int len);
 PHPAPI char *php_stristr(unsigned char *s, unsigned char *t, size_t s_len, size_t 
t_len);
+PHPAPI char *php_str_to_str_ex(char *haystack, int length, char *needle,
+   int needle_len, char *str, int str_len, int *_new_length, int 
+case_sensitivity);
 PHPAPI char *php_str_to_str(char *haystack, int length, char *needle,
int needle_len, char *str, int str_len, int *_new_length);
 PHPAPI char *php_trim(char *c, int len, char *what, int what_len, zval *return_value, 
int mode TSRMLS_DC);
Index: php4/ext/standard/string.c
diff -u php4/ext/standard/string.c:1.351 php4/ext/standard/string.c:1.352
--- php4/ext/standard/string.c:1.351Fri Jan 24 08:18:08 2003
+++ php4/ext/standard/string.c  Thu Jan 30 00:00:41 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: string.c,v 1.351 2003/01/24 13:18:08 andrey Exp $ */
+/* $Id: string.c,v 1.352 2003/01/30 05:00:41 pollita Exp $ */
 
 /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
 
@@ -2668,83 +2668,105 @@
 }
 /* }}} */
 
-/* {{{ boyer_str_to_str */
-static char *boyer_str_to_str(char *haystack, int length,
-   char *needle, int needle_len, char *str, 
-   int str_len, int *new_length)
-{
-   char *p, *pe, *cursor, *end, *r;
-   int off;
-   char jump_table[256];
-   smart_str result = {0};
+/* {{{ php_str_to_str_ex
+ */
+PHPAPI char *php_str_to_str_ex(char *haystack, int length, 
+   char *needle, int needle_len, char *str, int str_len, int *_new_length, int 
+case_sensitivity)
+{
+   char *new_str;
 
-   /*
-* We implement only the first half of the Boyer-Moore algorithm,
-* because the second half is too expensive to compute during run-time.
-* TODO: Split matching into compile-/match-stage.
-*/
-   
-   /* Prepare the jump_table which contains the skip offsets */
-   memset(jump_table, needle_len, 256);
-   
-   off = needle_len - 1;
-   
-   /* Calculate the default start where each comparison starts */
-   pe = needle + off;
+   if (needle_len  length) {
+   char *end, *haystack_dup, 

[PHP-CVS] cvs: php4 /ext/standard basic_functions.c php_string.h

2003-01-28 Thread Ilia Alshanetsky
iliaa   Tue Jan 28 19:07:02 2003 EDT

  Modified files:  
/php4/ext/standard  php_string.h basic_functions.c 
  Log:
  Added part of strpos commit that never made it in for some reason.
  
  # Thanks Pollita.
  
  
Index: php4/ext/standard/php_string.h
diff -u php4/ext/standard/php_string.h:1.67 php4/ext/standard/php_string.h:1.68
--- php4/ext/standard/php_string.h:1.67 Wed Jan  1 06:04:44 2003
+++ php4/ext/standard/php_string.h  Tue Jan 28 19:07:01 2003
@@ -17,7 +17,7 @@
+--+
 */
 
-/* $Id: php_string.h,v 1.67 2003/01/01 11:04:44 wez Exp $ */
+/* $Id: php_string.h,v 1.68 2003/01/29 00:07:01 iliaa Exp $ */
 
 /* Synced with php 3.0 revision 1.43 1999-06-16 [ssb] */
 
@@ -45,7 +45,9 @@
 PHP_FUNCTION(pathinfo);
 PHP_FUNCTION(strstr);
 PHP_FUNCTION(strpos);
+PHP_FUNCTION(stripos);
 PHP_FUNCTION(strrpos);
+PHP_FUNCTION(strripos);
 PHP_FUNCTION(strrchr);
 PHP_FUNCTION(substr);
 PHP_FUNCTION(quotemeta);
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.566 
php4/ext/standard/basic_functions.c:1.567
--- php4/ext/standard/basic_functions.c:1.566   Mon Jan 27 20:48:57 2003
+++ php4/ext/standard/basic_functions.c Tue Jan 28 19:07:01 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.566 2003/01/28 01:48:57 iliaa Exp $ */
+/* $Id: basic_functions.c,v 1.567 2003/01/29 00:07:01 iliaa Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -325,7 +325,9 @@
PHP_FE(strtoupper, 
 NULL)
PHP_FE(strtolower, 
 NULL)
PHP_FE(strpos, 
 NULL)
+   PHP_FE(stripos,
+ NULL)
PHP_FE(strrpos,
 NULL)
+   PHP_FE(strripos,   
+ NULL)
PHP_FE(strrev, 
 NULL)
PHP_FE(hebrev, 
 NULL)
PHP_FE(hebrevc,
 NULL)



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c

2003-01-28 Thread Harald Radi
phanto  Tue Jan 28 19:49:09 2003 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c 
  Log:
  MFPHP_4_3
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.567 
php4/ext/standard/basic_functions.c:1.568
--- php4/ext/standard/basic_functions.c:1.567   Tue Jan 28 19:07:01 2003
+++ php4/ext/standard/basic_functions.c Tue Jan 28 19:49:09 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.567 2003/01/29 00:07:01 iliaa Exp $ */
+/* $Id: basic_functions.c,v 1.568 2003/01/29 00:49:09 phanto Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -1133,10 +1133,6 @@
 
 PHP_RINIT_FUNCTION(basic)
 {
-#ifdef PHP_WIN32
-   CoInitialize(NULL);
-#endif
-
memset(BG(strtok_table), 0, 256);
BG(strtok_string) = NULL;
BG(strtok_zval) = NULL;
@@ -1227,10 +1223,6 @@
if (BG(mmap_file)) {
munmap(BG(mmap_file), BG(mmap_len));
}
-#endif
-
-#ifdef PHP_WIN32
-   CoUninitialize();
 #endif
 
return SUCCESS;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c

2003-01-19 Thread Harald Radi
phanto  Sun Jan 19 07:18:46 2003 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c 
  Log:
  ini patch to allow 'entry[] = value' entries
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.563 
php4/ext/standard/basic_functions.c:1.564
--- php4/ext/standard/basic_functions.c:1.563   Sat Jan 18 10:03:00 2003
+++ php4/ext/standard/basic_functions.c Sun Jan 19 07:18:46 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.563 2003/01/18 15:03:00 andrey Exp $ */
+/* $Id: basic_functions.c,v 1.564 2003/01/19 12:18:46 phanto Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -2824,51 +2824,60 @@
zend_hash_update(Z_ARRVAL_P(arr), Z_STRVAL_P(arg1), 
Z_STRLEN_P(arg1)+1, element, sizeof(zval *), NULL);
break;
 
-   case ZEND_INI_PARSER_SECTION:
-   break;
-   }
-}
-
-static void php_ini_parser_cb_with_sections(zval *arg1, zval *arg2, int 
callback_type, zval *arr)
-{
-   zval *element;
-   TSRMLS_FETCH();
-
-   switch (callback_type) {
-
-   case ZEND_INI_PARSER_ENTRY:
+   case ZEND_INI_PARSER_POP_ENTRY:
{
-   zval *active_arr;
+   zval *hash, **find_hash;
 
if (!arg2) {
/* bare string - nothing to do */
break;
}
 
-   if (BG(active_ini_file_section)) {
-   active_arr = BG(active_ini_file_section);
+   if (zend_hash_find(Z_ARRVAL_P(arr), Z_STRVAL_P(arg1), 
+Z_STRLEN_P(arg1)+1, (void **) find_hash) == FAILURE) {
+   ALLOC_ZVAL(hash);
+   INIT_PZVAL(hash);
+   array_init(hash);
+
+   zend_hash_update(Z_ARRVAL_P(arr), Z_STRVAL_P(arg1), 
+Z_STRLEN_P(arg1)+1, hash, sizeof(zval *), NULL);
} else {
-   active_arr = arr;
+   hash = *find_hash;
}
+
ALLOC_ZVAL(element);
*element = *arg2;
zval_copy_ctor(element);
INIT_PZVAL(element);
-   zend_hash_update(Z_ARRVAL_P(active_arr), Z_STRVAL_P(arg1),
-Z_STRLEN_P(arg1)+1, element,
-sizeof(zval *), NULL);
+   add_next_index_zval(hash, element); 
}
break;
 
case ZEND_INI_PARSER_SECTION:
-   MAKE_STD_ZVAL(BG(active_ini_file_section));
-   array_init(BG(active_ini_file_section));
-   zend_hash_update(   Z_ARRVAL_P(arr),
-   Z_STRVAL_P(arg1),
-   Z_STRLEN_P(arg1)+1,
-   
BG(active_ini_file_section),
-   sizeof(zval *), NULL);
break;
+   }
+}
+
+static void php_ini_parser_cb_with_sections(zval *arg1, zval *arg2, int 
+callback_type, zval *arr)
+{
+   TSRMLS_FETCH();
+
+   if (callback_type == ZEND_INI_PARSER_SECTION) {
+   MAKE_STD_ZVAL(BG(active_ini_file_section));
+   array_init(BG(active_ini_file_section));
+   zend_hash_update(   Z_ARRVAL_P(arr),
+   Z_STRVAL_P(arg1),
+   Z_STRLEN_P(arg1)+1,
+   BG(active_ini_file_section),
+   sizeof(zval *), NULL);
+   } else if (arg2) {
+   zval *active_arr;
+
+   if (BG(active_ini_file_section)) {
+   active_arr = BG(active_ini_file_section);
+   } else {
+   active_arr = arr;
+   }
+
+   php_simple_ini_parser_cb(arg1, arg2, callback_type, active_arr);
}
 }
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-CVS] cvs: php4 /ext/standard basic_functions.c php_var.h var.c

2003-01-18 Thread Andi Gutmans
This should follow our naming conventions and be called memory_get_usage().

Andi

At 06:26 PM 1/14/2003 +, Andrey Hristov wrote:

andrey  Tue Jan 14 13:26:47 2003 EDT

  Modified files:
/php4/ext/standard  basic_functions.c php_var.h var.c
  Log:
  added function get_memory_usage(). available only when PHP is compiled
  with --enable-memory-limit


Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.559 
php4/ext/standard/basic_functions.c:1.560
--- php4/ext/standard/basic_functions.c:1.559   Mon Jan 13 13:12:23 2003
+++ php4/ext/standard/basic_functions.c Tue Jan 14 13:26:47 2003
@@ -17,7 +17,7 @@
+--+
  */

-/* $Id: basic_functions.c,v 1.559 2003/01/13 18:12:23 andrey Exp $ */
+/* $Id: basic_functions.c,v 1.560 2003/01/14 18:26:47 andrey Exp $ */

 #include php.h
 #include php_streams.h
@@ -544,6 +544,9 @@
PHP_FE(var_export, 
   NULL)
PHP_FE(debug_zval_dump, 
   NULL)
PHP_FE(print_r, 
   NULL)
+#if MEMORY_LIMIT
+   PHP_FE(get_memory_usage, 
 NULL)
+#endif

PHP_FE(register_shutdown_function, 
   NULL)
PHP_FE(register_tick_function, 
   NULL)
Index: php4/ext/standard/php_var.h
diff -u php4/ext/standard/php_var.h:1.22 php4/ext/standard/php_var.h:1.23
--- php4/ext/standard/php_var.h:1.22Tue Dec 31 11:07:54 2002
+++ php4/ext/standard/php_var.h Tue Jan 14 13:26:47 2003
@@ -16,7 +16,7 @@
+--+
 */

-/* $Id: php_var.h,v 1.22 2002/12/31 16:07:54 sebastian Exp $ */
+/* $Id: php_var.h,v 1.23 2003/01/14 18:26:47 andrey Exp $ */

 #ifndef PHP_VAR_H
 #define PHP_VAR_H
@@ -28,6 +28,9 @@
 PHP_FUNCTION(debug_zval_dump);
 PHP_FUNCTION(serialize);
 PHP_FUNCTION(unserialize);
+#if MEMORY_LIMIT
+PHP_FUNCTION(get_memory_usage);
+#endif

 void php_var_dump(zval **struc, int level TSRMLS_DC);
 void php_var_export(zval **struc, int level TSRMLS_DC);
Index: php4/ext/standard/var.c
diff -u php4/ext/standard/var.c:1.153 php4/ext/standard/var.c:1.154
--- php4/ext/standard/var.c:1.153   Sun Jan 12 08:50:17 2003
+++ php4/ext/standard/var.c Tue Jan 14 13:26:47 2003
@@ -677,6 +677,15 @@

 /* }}} */

+#if MEMORY_LIMIT
+/* {{{ proto int get_memory_usage()
+Returns the allocated by PHP memory */
+PHP_FUNCTION(get_memory_usage) {
+   RETURN_LONG(AG(allocated_memory));
+}
+/* }}} */
+#endif
+
 /*
  * Local variables:
  * tab-width: 4



--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c php_var.h var.c

2003-01-18 Thread Andrey Hristov
andrey  Sat Jan 18 10:03:02 2003 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c php_var.h var.c 
  Log:
  Renamed get_memory_usage() to memory_get_usage() (per Andi's advice)
  This doesn't break any BC.
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.562 
php4/ext/standard/basic_functions.c:1.563
--- php4/ext/standard/basic_functions.c:1.562   Wed Jan 15 13:54:02 2003
+++ php4/ext/standard/basic_functions.c Sat Jan 18 10:03:00 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.562 2003/01/15 18:54:02 wez Exp $ */
+/* $Id: basic_functions.c,v 1.563 2003/01/18 15:03:00 andrey Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -548,7 +548,7 @@
PHP_FE(debug_zval_dump,
 NULL)
PHP_FE(print_r,
 NULL)
 #if MEMORY_LIMIT 
-   PHP_FE(get_memory_usage,   
 NULL)
+   PHP_FE(memory_get_usage,   
+ NULL)
 #endif
 
PHP_FE(register_shutdown_function, 
 NULL)
Index: php4/ext/standard/php_var.h
diff -u php4/ext/standard/php_var.h:1.23 php4/ext/standard/php_var.h:1.24
--- php4/ext/standard/php_var.h:1.23Tue Jan 14 13:26:47 2003
+++ php4/ext/standard/php_var.h Sat Jan 18 10:03:00 2003
@@ -16,7 +16,7 @@
+--+
 */
 
-/* $Id: php_var.h,v 1.23 2003/01/14 18:26:47 andrey Exp $ */
+/* $Id: php_var.h,v 1.24 2003/01/18 15:03:00 andrey Exp $ */
 
 #ifndef PHP_VAR_H
 #define PHP_VAR_H
@@ -29,7 +29,7 @@
 PHP_FUNCTION(serialize);
 PHP_FUNCTION(unserialize);
 #if MEMORY_LIMIT 
-PHP_FUNCTION(get_memory_usage);
+PHP_FUNCTION(memory_get_usage);
 #endif
 
 void php_var_dump(zval **struc, int level TSRMLS_DC);
Index: php4/ext/standard/var.c
diff -u php4/ext/standard/var.c:1.154 php4/ext/standard/var.c:1.155
--- php4/ext/standard/var.c:1.154   Tue Jan 14 13:26:47 2003
+++ php4/ext/standard/var.c Sat Jan 18 10:03:01 2003
@@ -678,9 +678,9 @@
 /* }}} */
 
 #if MEMORY_LIMIT
-/* {{{ proto int get_memory_usage()
+/* {{{ proto int memory_get_usage()
 Returns the allocated by PHP memory */
-PHP_FUNCTION(get_memory_usage) {
+PHP_FUNCTION(memory_get_usage) {
RETURN_LONG(AG(allocated_memory));
 }
 /* }}} */



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c config.m4 exec.c proc_open.c

2003-01-15 Thread Wez Furlong
wez Wed Jan 15 11:29:01 2003 EDT

  Added files: 
/php4/ext/standard  proc_open.c 

  Modified files:  
/php4/ext/standard  basic_functions.c config.m4 exec.c 
  Log:
  - Move proc_open code to a source file of it's own.
  - Tidy up that netware mess by performing a configure check which will
define the symbol PHP_CAN_SUPPORT_PROC_OPEN if PHP can support proc_open.
  - Protected the proc_open specific code with #ifdef PHP_CAN_SUPPORT_PROC_OPEN
so that user-space scripts can use function_exists and react accordingly.
  
  ** Heads Up Win32: You need to add ext/standard/proc_open.c to the DSP and
  ** #define PHP_CAN_SUPPORT_PROC_OPEN in the w32 config header.
  
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.560 
php4/ext/standard/basic_functions.c:1.561
--- php4/ext/standard/basic_functions.c:1.560   Tue Jan 14 13:26:47 2003
+++ php4/ext/standard/basic_functions.c Wed Jan 15 11:29:00 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.560 2003/01/14 18:26:47 andrey Exp $ */
+/* $Id: basic_functions.c,v 1.561 2003/01/15 16:29:00 wez Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -411,8 +411,10 @@
PHP_FE(escapeshellarg, 
 NULL)
PHP_FE(passthru,second_arg_force_ref)
PHP_FE(shell_exec, 
 NULL)
+#ifdef PHP_CAN_SUPPORT_PROC_OPEN
PHP_FE(proc_open,   third_arg_force_ref)
PHP_FE(proc_close, 
 NULL)
+#endif
 
PHP_FE(rand,   
 NULL)
PHP_FE(srand,  
 NULL)
@@ -1063,7 +1065,9 @@
PHP_MINIT(array)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(assert)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(url_scanner_ex)(INIT_FUNC_ARGS_PASSTHRU);
+#ifdef PHP_CAN_SUPPORT_PROC_OPEN
PHP_MINIT(proc_open)(INIT_FUNC_ARGS_PASSTHRU);
+#endif
 
PHP_MINIT(user_streams)(INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(imagetypes)(INIT_FUNC_ARGS_PASSTHRU);
Index: php4/ext/standard/config.m4
diff -u php4/ext/standard/config.m4:1.50 php4/ext/standard/config.m4:1.51
--- php4/ext/standard/config.m4:1.50Wed Jan  1 06:04:44 2003
+++ php4/ext/standard/config.m4 Wed Jan 15 11:29:00 2003
@@ -1,4 +1,4 @@
-dnl $Id: config.m4,v 1.50 2003/01/01 11:04:44 wez Exp $ -*- sh -*-
+dnl $Id: config.m4,v 1.51 2003/01/15 16:29:00 wez Exp $ -*- sh -*-
 
 divert(3)dnl
 
@@ -225,6 +225,31 @@
 
 AC_FUNC_FNMATCH
 
+dnl Take a look and see if there is a support means of creating a new process
+dnl and defining which handles it receives
+AC_DEFUN([PHP_CHECK_IF_SUPPORT_PROC_OPEN],[
+  
+  AC_CACHE_VAL(php_can_support_proc_open,[
+AC_CHECK_FUNCS(fork CreateProcess, [
+  php_can_support_proc_open=yes
+  break
+],[
+  php_can_support_proc_open=no
+])
+  ])
+  
+  AC_MSG_CHECKING([if your OS can spawn processes with inherited handles])
+  if test $php_can_support_proc_open = yes; then
+AC_MSG_RESULT(yes)
+AC_DEFINE(PHP_CAN_SUPPORT_PROC_OPEN,1, [Define if your system has 
+fork/vfork/CreateProcess])
+  else
+AC_MSG_RESULT(no)
+  fi
+
+])
+
+PHP_CHECK_IF_SUPPORT_PROC_OPEN
+
 dnl getopt long options disabled for now
 dnl as we can't be sure that we get the right getopt.h here
 dnl using the standard AC_CHECK macros
@@ -256,6 +281,6 @@
 incomplete_class.c url_scanner_ex.c ftp_fopen_wrapper.c \
 http_fopen_wrapper.c php_fopen_wrapper.c credits.c css.c \
 var_unserializer.c ftok.c aggregation.c sha1.c 
user_filters.c \
-   filters.c )
+filters.c proc_open.c )
 
 PHP_ADD_MAKEFILE_FRAGMENT
Index: php4/ext/standard/exec.c
diff -u php4/ext/standard/exec.c:1.90 php4/ext/standard/exec.c:1.91
--- php4/ext/standard/exec.c:1.90   Fri Jan  3 11:06:02 2003
+++ php4/ext/standard/exec.cWed Jan 15 11:29:00 2003
@@ -15,7 +15,7 @@
| Author: Rasmus Lerdorf   |
+--+
  */
-/* $Id: exec.c,v 1.90 2003/01/03 16:06:02 hyanantha Exp $ */
+/* $Id: exec.c,v 1.91 2003/01/15 16:29:00 wez Exp $ */
 
 #include stdio.h
 #include php.h
@@ -45,63 +45,6 @@
 #include fcntl.h
 #endif
 
-/* {{{ php_make_safe_mode_command */
-static int 

[PHP-CVS] cvs: php4 /ext/standard basic_functions.c exec.h proc_open.c proc_open.h /ext/standard/tests/general_functions proc_open.phpt

2003-01-15 Thread Wez Furlong
wez Wed Jan 15 13:54:04 2003 EDT

  Added files: 
/php4/ext/standard  proc_open.h 

  Modified files:  
/php4/ext/standard  basic_functions.c exec.h proc_open.c 
/php4/ext/standard/tests/general_functions  proc_open.phpt 
  Log:
  Relieve scripts of the burden of ensuring that all pipes are closed prior
  to calling proc_close().
  Implement proc_get_status(resource $process) which returns an array of
  information about a process created with proc_open().
  The information includes:
  array(
command = string name of the command,
pid = long process identifier,
running = bool true if the process is still running
exitcode = long exitcode if the process exited
signaled = bool true if the process was signaled
termsig = long signal number if signaled
stopped = bool true if the process is stopped
stopsig = long signal number if stopped
  );
  
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.561 
php4/ext/standard/basic_functions.c:1.562
--- php4/ext/standard/basic_functions.c:1.561   Wed Jan 15 11:29:00 2003
+++ php4/ext/standard/basic_functions.c Wed Jan 15 13:54:02 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.561 2003/01/15 16:29:00 wez Exp $ */
+/* $Id: basic_functions.c,v 1.562 2003/01/15 18:54:02 wez Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -414,6 +414,7 @@
 #ifdef PHP_CAN_SUPPORT_PROC_OPEN
PHP_FE(proc_open,   third_arg_force_ref)
PHP_FE(proc_close, 
 NULL)
+   PHP_FE(proc_get_status,
+ NULL)
 #endif
 
PHP_FE(rand,   
 NULL)
Index: php4/ext/standard/exec.h
diff -u php4/ext/standard/exec.h:1.16 php4/ext/standard/exec.h:1.17
--- php4/ext/standard/exec.h:1.16   Tue Dec 31 11:07:38 2002
+++ php4/ext/standard/exec.hWed Jan 15 13:54:03 2003
@@ -16,7 +16,7 @@
+--+
 */
 
-/* $Id: exec.h,v 1.16 2002/12/31 16:07:38 sebastian Exp $ */
+/* $Id: exec.h,v 1.17 2003/01/15 18:54:03 wez Exp $ */
 
 #ifndef EXEC_H
 #define EXEC_H
@@ -28,6 +28,7 @@
 PHP_FUNCTION(passthru);
 PHP_FUNCTION(shell_exec);
 PHP_FUNCTION(proc_open);
+PHP_FUNCTION(proc_get_status);
 PHP_FUNCTION(proc_close);
 PHP_MINIT_FUNCTION(proc_open);
 
Index: php4/ext/standard/proc_open.c
diff -u php4/ext/standard/proc_open.c:1.1 php4/ext/standard/proc_open.c:1.2
--- php4/ext/standard/proc_open.c:1.1   Wed Jan 15 11:29:00 2003
+++ php4/ext/standard/proc_open.c   Wed Jan 15 13:54:03 2003
@@ -12,10 +12,10 @@
| obtain it through the world-wide-web, please send a note to  |
| [EMAIL PROTECTED] so we can mail you a copy immediately.   |
+--+
-   | Author: Wez Furlong  |
+   | Author: Wez Furlong [EMAIL PROTECTED]   |
+--+
  */
-/* $Id: proc_open.c,v 1.1 2003/01/15 16:29:00 wez Exp $ */
+/* $Id: proc_open.c,v 1.2 2003/01/15 18:54:03 wez Exp $ */
 
 #include stdio.h
 #include php.h
@@ -52,27 +52,39 @@
  * */
 #ifdef PHP_CAN_SUPPORT_PROC_OPEN
 
+#include proc_open.h
+
 static int le_proc_open;
 
 static void proc_open_rsrc_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
 {
+   struct php_process_handle *proc = (struct php_process_handle*)rsrc-ptr;
+   int i;
 #ifdef PHP_WIN32
-   HANDLE child;
DWORD wstatus;
+#elif HAVE_SYS_WAIT_H
+   int wstatus;
+   pid_t wait_pid;
+#endif
+
+   /* Close all handles to avoid a deadlock */
+   for (i = 0; i  proc-npipes; i++) {
+   if (proc-pipes[i] != 0) {
+   zend_list_delete(proc-pipes[i]);
+   proc-pipes[i] = 0;
+   }
+   }

-   child = (HANDLE)rsrc-ptr;
-   WaitForSingleObject(child, INFINITE);
-   GetExitCodeProcess(child, wstatus);
+#ifdef PHP_WIN32
+   
+   WaitForSingleObject(proc-child, INFINITE);
+   GetExitCodeProcess(proc-child, wstatus);
FG(pclose_ret) = wstatus;
-#else
-# if HAVE_SYS_WAIT_H
-   int wstatus;
-   pid_t child, wait_pid;

-   child = (pid_t)rsrc-ptr;
-
+#elif HAVE_SYS_WAIT_H
+   
do {
-   wait_pid = waitpid(child, wstatus, 0);
+   wait_pid = waitpid(proc-child, wstatus, 0);
} while (wait_pid == -1  errno == EINTR);

if (wait_pid == -1)
@@ 

[PHP-CVS] cvs: php4 /ext/standard basic_functions.c php_var.h var.c

2003-01-14 Thread Andrey Hristov
andrey  Tue Jan 14 13:26:47 2003 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c php_var.h var.c 
  Log:
  added function get_memory_usage(). available only when PHP is compiled
  with --enable-memory-limit
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.559 
php4/ext/standard/basic_functions.c:1.560
--- php4/ext/standard/basic_functions.c:1.559   Mon Jan 13 13:12:23 2003
+++ php4/ext/standard/basic_functions.c Tue Jan 14 13:26:47 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.559 2003/01/13 18:12:23 andrey Exp $ */
+/* $Id: basic_functions.c,v 1.560 2003/01/14 18:26:47 andrey Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -544,6 +544,9 @@
PHP_FE(var_export, 
 NULL)
PHP_FE(debug_zval_dump,
 NULL)
PHP_FE(print_r,
 NULL)
+#if MEMORY_LIMIT 
+   PHP_FE(get_memory_usage,   
+ NULL)
+#endif
 
PHP_FE(register_shutdown_function, 
 NULL)
PHP_FE(register_tick_function, 
 NULL)
Index: php4/ext/standard/php_var.h
diff -u php4/ext/standard/php_var.h:1.22 php4/ext/standard/php_var.h:1.23
--- php4/ext/standard/php_var.h:1.22Tue Dec 31 11:07:54 2002
+++ php4/ext/standard/php_var.h Tue Jan 14 13:26:47 2003
@@ -16,7 +16,7 @@
+--+
 */
 
-/* $Id: php_var.h,v 1.22 2002/12/31 16:07:54 sebastian Exp $ */
+/* $Id: php_var.h,v 1.23 2003/01/14 18:26:47 andrey Exp $ */
 
 #ifndef PHP_VAR_H
 #define PHP_VAR_H
@@ -28,6 +28,9 @@
 PHP_FUNCTION(debug_zval_dump);
 PHP_FUNCTION(serialize);
 PHP_FUNCTION(unserialize);
+#if MEMORY_LIMIT 
+PHP_FUNCTION(get_memory_usage);
+#endif
 
 void php_var_dump(zval **struc, int level TSRMLS_DC);
 void php_var_export(zval **struc, int level TSRMLS_DC);
Index: php4/ext/standard/var.c
diff -u php4/ext/standard/var.c:1.153 php4/ext/standard/var.c:1.154
--- php4/ext/standard/var.c:1.153   Sun Jan 12 08:50:17 2003
+++ php4/ext/standard/var.c Tue Jan 14 13:26:47 2003
@@ -677,6 +677,15 @@
 
 /* }}} */
 
+#if MEMORY_LIMIT
+/* {{{ proto int get_memory_usage()
+Returns the allocated by PHP memory */
+PHP_FUNCTION(get_memory_usage) {
+   RETURN_LONG(AG(allocated_memory));
+}
+/* }}} */
+#endif
+
 /*
  * Local variables:
  * tab-width: 4



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c basic_functions.h formatted_print.c /tests/strings 002.phpt

2003-01-09 Thread Wez Furlong
wez Thu Jan  9 12:29:31 2003 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c basic_functions.h 
formatted_print.c 
/php4/tests/strings 002.phpt 
  Log:
  Implement fprintf() and vfprintf().
  Add a couple of tests.
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.556 
php4/ext/standard/basic_functions.c:1.557
--- php4/ext/standard/basic_functions.c:1.556   Tue Jan  7 06:37:09 2003
+++ php4/ext/standard/basic_functions.c Thu Jan  9 12:29:31 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.556 2003/01/07 11:37:09 zeev Exp $ */
+/* $Id: basic_functions.c,v 1.557 2003/01/09 17:29:31 wez Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -387,6 +387,8 @@
PHP_NAMED_FE(printf,PHP_FN(user_printf),   
 NULL)
PHP_FE(vprintf,
 NULL)
PHP_FE(vsprintf,   
 NULL)
+   PHP_FE(fprintf,
+ NULL)
+   PHP_FE(vfprintf,   
+ NULL)
PHP_FE(sscanf,  third_and_rest_force_ref)
PHP_FE(fscanf,  third_and_rest_force_ref)
PHP_FE(parse_url,  
 NULL)
Index: php4/ext/standard/basic_functions.h
diff -u php4/ext/standard/basic_functions.h:1.112 
php4/ext/standard/basic_functions.h:1.113
--- php4/ext/standard/basic_functions.h:1.112   Sat Jan  4 22:24:38 2003
+++ php4/ext/standard/basic_functions.h Thu Jan  9 12:29:31 2003
@@ -17,7 +17,7 @@
+--+
 */
 
-/* $Id: basic_functions.h,v 1.112 2003/01/05 03:24:38 pollita Exp $ */
+/* $Id: basic_functions.h,v 1.113 2003/01/09 17:29:31 wez Exp $ */
 
 #ifndef BASIC_FUNCTIONS_H
 #define BASIC_FUNCTIONS_H
@@ -83,6 +83,8 @@
 PHP_FUNCTION(restore_include_path);
 
 PHP_FUNCTION(print_r);
+PHP_FUNCTION(fprintf);
+PHP_FUNCTION(vfprintf);
 
 PHP_FUNCTION(connection_aborted);
 PHP_FUNCTION(connection_status);
Index: php4/ext/standard/formatted_print.c
diff -u php4/ext/standard/formatted_print.c:1.60 
php4/ext/standard/formatted_print.c:1.61
--- php4/ext/standard/formatted_print.c:1.60Tue Dec 31 11:07:41 2002
+++ php4/ext/standard/formatted_print.c Thu Jan  9 12:29:31 2003
@@ -16,7 +16,7 @@
+--+
  */
 
-/* $Id: formatted_print.c,v 1.60 2002/12/31 16:07:41 sebastian Exp $ */
+/* $Id: formatted_print.c,v 1.61 2003/01/09 17:29:31 wez Exp $ */
 
 #include math.h  /* modf() */
 #include php.h
@@ -452,9 +452,9 @@
  *
  */
 static char *
-php_formatted_print(int ht, int *len, int use_array TSRMLS_DC)
+php_formatted_print(int ht, int *len, int use_array, int format_offset TSRMLS_DC)
 {
-   zval ***args, **z_format, **array;
+   zval ***args, **z_format;
int argc, size = 240, inpos = 0, outpos = 0, temppos;
int alignment, width, precision, currarg, adjusting, argnum;
char *format, *result, padding;
@@ -462,39 +462,49 @@
 
argc = ZEND_NUM_ARGS();
 
+   /* verify the number of args */
+   if ((use_array  argc != (2 + format_offset)) 
+   || (!use_array  argc  (1 + format_offset))) {
+   WRONG_PARAM_COUNT_WITH_RETVAL(NULL);
+   }
+   args = (zval ***)emalloc(argc * sizeof(zval *));
+
+   if (zend_get_parameters_array_ex(argc, args) == FAILURE) {
+   efree(args);
+   WRONG_PARAM_COUNT_WITH_RETVAL(NULL);
+   }
+   
if (use_array) {
int i = 1;
+   zval ***newargs;
+   zval **array;
 
-   if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(argc, z_format, 
array) == FAILURE) {
-   WRONG_PARAM_COUNT_WITH_RETVAL(NULL);
-   }
+   z_format = args[format_offset];
+   array = args[1 + format_offset];
+   
SEPARATE_ZVAL(array);
convert_to_array_ex(array);
+   
argc = 1 + zend_hash_num_elements(Z_ARRVAL_PP(array));
-   args = (zval ***)emalloc(argc * sizeof(zval *));
-   args[0] = z_format;
+   newargs = (zval ***)emalloc(argc * sizeof(zval *));
+   newargs[0] = z_format;
+   
 

[PHP-CVS] cvs: php4 /ext/standard basic_functions.c

2003-01-07 Thread Zeev Suraski
zeevTue Jan  7 06:37:09 2003 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c 
  Log:
  whitespace
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.555 
php4/ext/standard/basic_functions.c:1.556
--- php4/ext/standard/basic_functions.c:1.555   Mon Jan  6 00:59:17 2003
+++ php4/ext/standard/basic_functions.c Tue Jan  7 06:37:09 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.555 2003/01/06 05:59:17 hyanantha Exp $ */
+/* $Id: basic_functions.c,v 1.556 2003/01/07 11:37:09 zeev Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -1029,38 +1029,38 @@
register_html_constants(INIT_FUNC_ARGS_PASSTHRU);
register_string_constants(INIT_FUNC_ARGS_PASSTHRU);
 
-   PHP_MINIT(regex) (INIT_FUNC_ARGS_PASSTHRU);
-   PHP_MINIT(file) (INIT_FUNC_ARGS_PASSTHRU);
-   PHP_MINIT(pack) (INIT_FUNC_ARGS_PASSTHRU);
-   PHP_MINIT(browscap) (INIT_FUNC_ARGS_PASSTHRU);
-   PHP_MINIT(standard_filters) (INIT_FUNC_ARGS_PASSTHRU);
-   PHP_MINIT(user_filters) (INIT_FUNC_ARGS_PASSTHRU);
+   PHP_MINIT(regex)(INIT_FUNC_ARGS_PASSTHRU);
+   PHP_MINIT(file)(INIT_FUNC_ARGS_PASSTHRU);
+   PHP_MINIT(pack)(INIT_FUNC_ARGS_PASSTHRU);
+   PHP_MINIT(browscap)(INIT_FUNC_ARGS_PASSTHRU);
+   PHP_MINIT(standard_filters)(INIT_FUNC_ARGS_PASSTHRU);
+   PHP_MINIT(user_filters)(INIT_FUNC_ARGS_PASSTHRU);
 
 #if defined(HAVE_LOCALECONV)  defined(ZTS)
-   PHP_MINIT(localeconv) (INIT_FUNC_ARGS_PASSTHRU);
+   PHP_MINIT(localeconv)(INIT_FUNC_ARGS_PASSTHRU);
 #endif
 
 #if defined(HAVE_NL_LANGINFO)
-   PHP_MINIT(nl_langinfo) (INIT_FUNC_ARGS_PASSTHRU);
+   PHP_MINIT(nl_langinfo)(INIT_FUNC_ARGS_PASSTHRU);
 #endif
 
 #if HAVE_CRYPT
-   PHP_MINIT(crypt) (INIT_FUNC_ARGS_PASSTHRU);
+   PHP_MINIT(crypt)(INIT_FUNC_ARGS_PASSTHRU);
 #endif
 
-   PHP_MINIT(lcg) (INIT_FUNC_ARGS_PASSTHRU);
+   PHP_MINIT(lcg)(INIT_FUNC_ARGS_PASSTHRU);
 
-   PHP_MINIT(dir) (INIT_FUNC_ARGS_PASSTHRU);
+   PHP_MINIT(dir)(INIT_FUNC_ARGS_PASSTHRU);
 #ifdef HAVE_SYSLOG_H
-   PHP_MINIT(syslog) (INIT_FUNC_ARGS_PASSTHRU);
+   PHP_MINIT(syslog)(INIT_FUNC_ARGS_PASSTHRU);
 #endif
-   PHP_MINIT(array) (INIT_FUNC_ARGS_PASSTHRU);
-   PHP_MINIT(assert) (INIT_FUNC_ARGS_PASSTHRU);
-   PHP_MINIT(url_scanner_ex) (INIT_FUNC_ARGS_PASSTHRU);
-   PHP_MINIT(proc_open) (INIT_FUNC_ARGS_PASSTHRU);
+   PHP_MINIT(array)(INIT_FUNC_ARGS_PASSTHRU);
+   PHP_MINIT(assert)(INIT_FUNC_ARGS_PASSTHRU);
+   PHP_MINIT(url_scanner_ex)(INIT_FUNC_ARGS_PASSTHRU);
+   PHP_MINIT(proc_open)(INIT_FUNC_ARGS_PASSTHRU);
 
-   PHP_MINIT(user_streams) (INIT_FUNC_ARGS_PASSTHRU);
-   PHP_MINIT(imagetypes) (INIT_FUNC_ARGS_PASSTHRU);
+   PHP_MINIT(user_streams)(INIT_FUNC_ARGS_PASSTHRU);
+   PHP_MINIT(imagetypes)(INIT_FUNC_ARGS_PASSTHRU);
 
php_register_url_stream_wrapper(php, php_stream_php_wrapper TSRMLS_CC);
 #ifndef PHP_CURL_URL_WRAPPERS
@@ -1074,7 +1074,7 @@
 
 #if HAVE_RES_SEARCH  !(defined(__BEOS__)||defined(PHP_WIN32) || defined(NETWARE))
 # if HAVE_DNS_FUNCS
-   PHP_MINIT(dns) (INIT_FUNC_ARGS_PASSTHRU);
+   PHP_MINIT(dns)(INIT_FUNC_ARGS_PASSTHRU);
 # endif
 #endif
 
@@ -1102,15 +1102,15 @@
 
UNREGISTER_INI_ENTRIES();
 
-   PHP_MSHUTDOWN(regex) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
-   PHP_MSHUTDOWN(browscap) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
-   PHP_MSHUTDOWN(array) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
-   PHP_MSHUTDOWN(assert) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
-   PHP_MSHUTDOWN(url_scanner_ex) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
-   PHP_MSHUTDOWN(file) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
-   PHP_MSHUTDOWN(standard_filters) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
+   PHP_MSHUTDOWN(regex)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
+   PHP_MSHUTDOWN(browscap)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
+   PHP_MSHUTDOWN(array)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
+   PHP_MSHUTDOWN(assert)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
+   PHP_MSHUTDOWN(url_scanner_ex)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
+   PHP_MSHUTDOWN(file)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
+   PHP_MSHUTDOWN(standard_filters)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
 #if defined(HAVE_LOCALECONV)  defined(ZTS)
-   PHP_MSHUTDOWN(localeconv) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
+   PHP_MSHUTDOWN(localeconv)(SHUTDOWN_FUNC_ARGS_PASSTHRU);
 #endif
 
return SUCCESS;
@@ -1144,17 +1144,17 @@
BG(user_shutdown_function_names) = NULL;
 
 #if HAVE_CRYPT
-   PHP_RINIT(crypt) (INIT_FUNC_ARGS_PASSTHRU);
+   PHP_RINIT(crypt)(INIT_FUNC_ARGS_PASSTHRU);
 #endif
 
-   PHP_RINIT(lcg) (INIT_FUNC_ARGS_PASSTHRU);
+   PHP_RINIT(lcg)(INIT_FUNC_ARGS_PASSTHRU);
 
-   PHP_RINIT(filestat) (INIT_FUNC_ARGS_PASSTHRU);
+   PHP_RINIT(filestat)(INIT_FUNC_ARGS_PASSTHRU);
 #ifdef HAVE_SYSLOG_H
-   PHP_RINIT(syslog) (INIT_FUNC_ARGS_PASSTHRU);
+   

Re: [PHP-CVS] cvs: php4 /ext/standard basic_functions.c basic_functions.huser_filters.c

2003-01-05 Thread Wez Furlong
Because there is no structure to return :)
This function returns an array of the names of the filters available for
use via stream_filter_(prepend|append).

--Wez.

On Sat, 4 Jan 2003, Sterling Hughes wrote:

  pollita Sat Jan  4 22:24:38 2003 EDT
 
Modified files:
  /php4/ext/standard  basic_functions.c basic_functions.h
  user_filters.c
Log:
Added stream_get_filters(); to list registered filters
 

 How about returning the entire stream structure?

 -Sterling

 --
 PHP CVS Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php





-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c

2003-01-05 Thread Anantha Kesari H Y
hyanantha   Mon Jan  6 00:59:18 2003 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c 
  Log:
  Added #ifdef HAVE_SYSLOG_H around syslog function in the whole file to avoid link 
failure.
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.554 
php4/ext/standard/basic_functions.c:1.555
--- php4/ext/standard/basic_functions.c:1.554   Sat Jan  4 22:24:38 2003
+++ php4/ext/standard/basic_functions.c Mon Jan  6 00:59:17 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.554 2003/01/05 03:24:38 pollita Exp $ */
+/* $Id: basic_functions.c,v 1.555 2003/01/06 05:59:17 hyanantha Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -1051,7 +1051,9 @@
PHP_MINIT(lcg) (INIT_FUNC_ARGS_PASSTHRU);
 
PHP_MINIT(dir) (INIT_FUNC_ARGS_PASSTHRU);
+#ifdef HAVE_SYSLOG_H
PHP_MINIT(syslog) (INIT_FUNC_ARGS_PASSTHRU);
+#endif
PHP_MINIT(array) (INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(assert) (INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(url_scanner_ex) (INIT_FUNC_ARGS_PASSTHRU);
@@ -1148,7 +1150,9 @@
PHP_RINIT(lcg) (INIT_FUNC_ARGS_PASSTHRU);
 
PHP_RINIT(filestat) (INIT_FUNC_ARGS_PASSTHRU);
+#ifdef HAVE_SYSLOG_H
PHP_RINIT(syslog) (INIT_FUNC_ARGS_PASSTHRU);
+#endif
PHP_RINIT(dir) (INIT_FUNC_ARGS_PASSTHRU);
PHP_RINIT(url_scanner_ex) (INIT_FUNC_ARGS_PASSTHRU);
 
@@ -1180,7 +1184,9 @@
 
PHP_RSHUTDOWN(fsock) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
PHP_RSHUTDOWN(filestat) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
+#ifdef HAVE_SYSLOG_H
PHP_RSHUTDOWN(syslog) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
+#endif
PHP_RSHUTDOWN(assert) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
PHP_RSHUTDOWN(url_scanner_ex) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
PHP_RSHUTDOWN(streams) (SHUTDOWN_FUNC_ARGS_PASSTHRU);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c basic_functions.h user_filters.c

2003-01-04 Thread Sara Golemon
pollita Sat Jan  4 22:24:38 2003 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c basic_functions.h 
user_filters.c 
  Log:
  Added stream_get_filters(); to list registered filters
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.553 
php4/ext/standard/basic_functions.c:1.554
--- php4/ext/standard/basic_functions.c:1.553   Fri Jan  3 03:02:36 2003
+++ php4/ext/standard/basic_functions.c Sat Jan  4 22:24:38 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.553 2003/01/03 08:02:36 pollita Exp $ */
+/* $Id: basic_functions.c,v 1.554 2003/01/05 03:24:38 pollita Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -863,6 +863,7 @@
 #endif
 
PHP_FE(str_rot13, NULL)
+   PHP_FE(stream_get_filters, NULL)
PHP_FE(stream_register_filter, NULL)
 
/* functions from aggregate.c */
Index: php4/ext/standard/basic_functions.h
diff -u php4/ext/standard/basic_functions.h:1.111 
php4/ext/standard/basic_functions.h:1.112
--- php4/ext/standard/basic_functions.h:1.111   Tue Dec 31 13:39:34 2002
+++ php4/ext/standard/basic_functions.h Sat Jan  4 22:24:38 2003
@@ -17,7 +17,7 @@
+--+
 */
 
-/* $Id: basic_functions.h,v 1.111 2002/12/31 18:39:34 wez Exp $ */
+/* $Id: basic_functions.h,v 1.112 2003/01/05 03:24:38 pollita Exp $ */
 
 #ifndef BASIC_FUNCTIONS_H
 #define BASIC_FUNCTIONS_H
@@ -105,6 +105,7 @@
 PHP_FUNCTION(parse_ini_file);
 
 PHP_FUNCTION(str_rot13);
+PHP_FUNCTION(stream_get_filters);
 PHP_FUNCTION(stream_register_filter);
 PHP_MINIT_FUNCTION(user_filters);
 
Index: php4/ext/standard/user_filters.c
diff -u php4/ext/standard/user_filters.c:1.3 php4/ext/standard/user_filters.c:1.4
--- php4/ext/standard/user_filters.c:1.3Wed Jan  1 07:36:06 2003
+++ php4/ext/standard/user_filters.cSat Jan  4 22:24:38 2003
@@ -17,7 +17,7 @@
+--+
 */
 
-/* $Id: user_filters.c,v 1.3 2003/01/01 12:36:06 sebastian Exp $ */
+/* $Id: user_filters.c,v 1.4 2003/01/05 03:24:38 pollita Exp $ */
 
 #include php.h
 #include php_globals.h
@@ -410,6 +410,24 @@
 static void filter_item_dtor(struct php_user_filter_data *fdat)
 {
 }
+
+/* {{{ proto array stream_get_filters()
+   Returns a list of registered filters */
+PHP_FUNCTION(stream_get_filters)
+{
+   char *filter_name;
+   int filter_name_len = 0;
+
+   array_init(return_value);
+
+   if (BG(user_filter_map)) {
+   for(zend_hash_internal_pointer_reset(BG(user_filter_map));
+   zend_hash_get_current_key_ex(BG(user_filter_map), 
+filter_name, filter_name_len, NULL, 0, NULL) == HASH_KEY_IS_STRING;
+   zend_hash_move_forward(BG(user_filter_map)))
+   add_next_index_string(return_value, filter_name, 1);
+   }
+}
+/* }}} */  
 
 /* {{{ proto bool stream_register_filter(string filtername, string classname)
Registers a custom filter handler class */



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-CVS] cvs: php4 /ext/standard basic_functions.c basic_functions.h user_filters.c

2003-01-04 Thread Sterling Hughes
 pollita   Sat Jan  4 22:24:38 2003 EDT
 
   Modified files:  
 /php4/ext/standardbasic_functions.c basic_functions.h 
   user_filters.c 
   Log:
   Added stream_get_filters(); to list registered filters


How about returning the entire stream structure?

-Sterling

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c file.c file.h

2003-01-03 Thread Sara Golemon
pollita Fri Jan  3 03:02:38 2003 EDT

  Modified files:  
/php4/ext/standard  file.c file.h basic_functions.c 
  Log:
  Added stream_get_wrappers()
  
  
Index: php4/ext/standard/file.c
diff -u php4/ext/standard/file.c:1.284 php4/ext/standard/file.c:1.285
--- php4/ext/standard/file.c:1.284  Tue Dec 31 11:07:38 2002
+++ php4/ext/standard/file.cFri Jan  3 03:02:35 2003
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.284 2002/12/31 16:07:38 sebastian Exp $ */
+/* $Id: file.c,v 1.285 2003/01/03 08:02:35 pollita Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -621,6 +621,31 @@
add_assoc_bool(return_value, timed_out, 0);
add_assoc_bool(return_value, blocked, 1);
add_assoc_bool(return_value, eof, php_stream_eof(stream));
+   }
+
+}
+/* }}} */
+
+/* {{{ proto array stream_get_wrappers()
+Retrieves list of registered stream wrappers */
+PHP_FUNCTION(stream_get_wrappers)
+{
+   HashTable *url_stream_wrappers_hash;
+   char *stream_protocol;
+   int stream_protocol_len = 0;
+
+   if (ZEND_NUM_ARGS() != 0) {
+   WRONG_PARAM_COUNT;
+   }
+
+   if (url_stream_wrappers_hash = php_stream_get_url_stream_wrappers_hash()) {
+   array_init(return_value);
+   for(zend_hash_internal_pointer_reset(url_stream_wrappers_hash);
+   zend_hash_get_current_key_ex(url_stream_wrappers_hash, 
+stream_protocol, stream_protocol_len, NULL, 0, NULL) == HASH_KEY_IS_STRING;
+   zend_hash_move_forward(url_stream_wrappers_hash)) 
+   add_next_index_string(return_value,stream_protocol,1);
+   } else {
+   RETURN_FALSE;
}
 
 }
Index: php4/ext/standard/file.h
diff -u php4/ext/standard/file.h:1.72 php4/ext/standard/file.h:1.73
--- php4/ext/standard/file.h:1.72   Tue Dec 31 11:07:39 2002
+++ php4/ext/standard/file.hFri Jan  3 03:02:36 2003
@@ -16,7 +16,7 @@
+--+
 */
 
-/* $Id: file.h,v 1.72 2002/12/31 16:07:39 sebastian Exp $ */
+/* $Id: file.h,v 1.73 2003/01/03 08:02:36 pollita Exp $ */
 
 /* Synced with php 3.0 revision 1.30 1999-06-16 [ssb] */
 
@@ -59,6 +59,7 @@
 PHP_FUNCTION(stream_select);
 PHP_FUNCTION(stream_set_timeout);
 PHP_FUNCTION(stream_set_write_buffer);
+PHP_FUNCTION(stream_get_wrappers);
 PHP_FUNCTION(get_meta_tags);
 PHP_FUNCTION(flock);
 PHP_FUNCTION(fd_set);
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.552 
php4/ext/standard/basic_functions.c:1.553
--- php4/ext/standard/basic_functions.c:1.552   Wed Jan  1 06:04:43 2003
+++ php4/ext/standard/basic_functions.c Fri Jan  3 03:02:36 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.552 2003/01/01 11:04:43 wez Exp $ */
+/* $Id: basic_functions.c,v 1.553 2003/01/03 08:02:36 pollita Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -670,6 +670,7 @@
 
PHP_FE(stream_get_meta_data,   
 NULL)
PHP_FE(stream_register_wrapper,
 NULL)
+   PHP_FE(stream_get_wrappers,
+ NULL)
 
 #if HAVE_SYS_TIME_H || defined(PHP_WIN32)
PHP_FE(stream_set_timeout, 
 NULL)



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c config.m4 filters.c php_standard.h php_string.h string.c user_filters.c /ext/standard/tests/file userfilters.phpt

2003-01-01 Thread Wez Furlong
wez Wed Jan  1 06:04:45 2003 EDT

  Added files: 
/php4/ext/standard  filters.c 

  Modified files:  
/php4/ext/standard  basic_functions.c config.m4 php_standard.h 
php_string.h string.c user_filters.c 
/php4/ext/standard/tests/file   userfilters.phpt 
  Log:
  Move rot13 filter into a new filters.c source file.
  Tidy up some other filter related code.
  
  # win32 - someone please add user_filters.c and filters.c to the .dsp
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.551 
php4/ext/standard/basic_functions.c:1.552
--- php4/ext/standard/basic_functions.c:1.551   Tue Dec 31 13:39:29 2002
+++ php4/ext/standard/basic_functions.c Wed Jan  1 06:04:43 2003
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.551 2002/12/31 18:39:29 wez Exp $ */
+/* $Id: basic_functions.c,v 1.552 2003/01/01 11:04:43 wez Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -1031,7 +1031,7 @@
PHP_MINIT(file) (INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(pack) (INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(browscap) (INIT_FUNC_ARGS_PASSTHRU);
-   PHP_MINIT(string_filters) (INIT_FUNC_ARGS_PASSTHRU);
+   PHP_MINIT(standard_filters) (INIT_FUNC_ARGS_PASSTHRU);
PHP_MINIT(user_filters) (INIT_FUNC_ARGS_PASSTHRU);
 
 #if defined(HAVE_LOCALECONV)  defined(ZTS)
@@ -1104,7 +1104,7 @@
PHP_MSHUTDOWN(assert) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
PHP_MSHUTDOWN(url_scanner_ex) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
PHP_MSHUTDOWN(file) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
-   PHP_MSHUTDOWN(string_filters) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
+   PHP_MSHUTDOWN(standard_filters) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
 #if defined(HAVE_LOCALECONV)  defined(ZTS)
PHP_MSHUTDOWN(localeconv) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
 #endif
Index: php4/ext/standard/config.m4
diff -u php4/ext/standard/config.m4:1.49 php4/ext/standard/config.m4:1.50
--- php4/ext/standard/config.m4:1.49Tue Dec 31 13:39:35 2002
+++ php4/ext/standard/config.m4 Wed Jan  1 06:04:44 2003
@@ -1,4 +1,4 @@
-dnl $Id: config.m4,v 1.49 2002/12/31 18:39:35 wez Exp $ -*- sh -*-
+dnl $Id: config.m4,v 1.50 2003/01/01 11:04:44 wez Exp $ -*- sh -*-
 
 divert(3)dnl
 
@@ -255,6 +255,7 @@
 url_scanner.c var.c versioning.c assert.c strnatcmp.c 
levenshtein.c \
 incomplete_class.c url_scanner_ex.c ftp_fopen_wrapper.c \
 http_fopen_wrapper.c php_fopen_wrapper.c credits.c css.c \
-var_unserializer.c ftok.c aggregation.c sha1.c 
user_filters.c )
+var_unserializer.c ftok.c aggregation.c sha1.c 
+user_filters.c \
+   filters.c )
 
 PHP_ADD_MAKEFILE_FRAGMENT
Index: php4/ext/standard/php_standard.h
diff -u php4/ext/standard/php_standard.h:1.17 php4/ext/standard/php_standard.h:1.18
--- php4/ext/standard/php_standard.h:1.17   Tue Dec 31 11:07:53 2002
+++ php4/ext/standard/php_standard.hWed Jan  1 06:04:44 2003
@@ -16,7 +16,7 @@
+--+
 */
 
-/* $Id: php_standard.h,v 1.17 2002/12/31 16:07:53 sebastian Exp $ */
+/* $Id: php_standard.h,v 1.18 2003/01/01 11:04:44 wez Exp $ */
 
 #include basic_functions.h
 #include php_math.h
@@ -62,6 +62,9 @@
 #include aggregation.h
 
 #define phpext_standard_ptr basic_functions_module_ptr
+PHP_MINIT_FUNCTION(standard_filters);
+PHP_MSHUTDOWN_FUNCTION(standard_filters);
+
 
 /*
  * Local variables:
Index: php4/ext/standard/php_string.h
diff -u php4/ext/standard/php_string.h:1.66 php4/ext/standard/php_string.h:1.67
--- php4/ext/standard/php_string.h:1.66 Tue Dec 31 11:07:53 2002
+++ php4/ext/standard/php_string.h  Wed Jan  1 06:04:44 2003
@@ -17,7 +17,7 @@
+--+
 */
 
-/* $Id: php_string.h,v 1.66 2002/12/31 16:07:53 sebastian Exp $ */
+/* $Id: php_string.h,v 1.67 2003/01/01 11:04:44 wez Exp $ */
 
 /* Synced with php 3.0 revision 1.43 1999-06-16 [ssb] */
 
@@ -90,9 +90,6 @@
 #if HAVE_STRFMON
 PHP_FUNCTION(money_format);
 #endif
-
-PHP_MINIT_FUNCTION(string_filters);
-PHP_MSHUTDOWN_FUNCTION(string_filters);
 
 #if defined(HAVE_LOCALECONV)  defined(ZTS)
 PHP_MINIT_FUNCTION(localeconv);
Index: php4/ext/standard/string.c
diff -u php4/ext/standard/string.c:1.340 php4/ext/standard/string.c:1.341
--- php4/ext/standard/string.c:1.340Tue Dec 31 11:07:55 2002
+++ php4/ext/standard/string.c  Wed Jan  1 06:04:44 2003
@@ -18,7 +18,7 @@
+--+
  */
 
-/* $Id: string.c,v 1.340 2002/12/31 16:07:55 sebastian Exp $ */
+/* $Id: string.c,v 1.341 2003/01/01 11:04:44 wez Exp $ */
 
 /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
 
@@ -4166,82 

[PHP-CVS] cvs: php4 /ext/standard basic_functions.c

2002-12-01 Thread Ilia Alshanetsky
iliaa   Mon Dec  2 01:43:54 2002 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c 
  Log:
  Repositioned CoInitialize and CoUninitialize that apparetly makes it more
  correct according to MS docs. Patch (+5) by Michael Sisolak 
  [EMAIL PROTECTED].
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.544 
php4/ext/standard/basic_functions.c:1.545
--- php4/ext/standard/basic_functions.c:1.544   Mon Nov 18 21:34:13 2002
+++ php4/ext/standard/basic_functions.c Mon Dec  2 01:43:54 2002
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.544 2002/11/19 02:34:13 helly Exp $ */
+/* $Id: basic_functions.c,v 1.545 2002/12/02 06:43:54 iliaa Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -966,10 +966,6 @@
memset(BG(url_adapt_state), 0, sizeof(BG(url_adapt_state)));
memset(BG(url_adapt_state_ex), 0, sizeof(BG(url_adapt_state_ex)));
 
-#ifdef PHP_WIN32
-   CoInitialize(NULL);
-#endif
-
BG(incomplete_class) = php_create_incomplete_class(TSRMLS_C);
 }
 
@@ -980,9 +976,6 @@
if (BG(sm_allowed_env_vars)) {
free(BG(sm_allowed_env_vars));
}
-#ifdef PHP_WIN32
-   CoUninitialize();
-#endif
 }
 
 
@@ -1115,6 +1108,10 @@
 
 PHP_RINIT_FUNCTION(basic)
 {
+#ifdef PHP_WIN32
+   CoInitialize(NULL);
+#endif
+
memset(BG(strtok_table), 0, 256);
BG(strtok_string) = NULL;
BG(strtok_zval) = NULL;
@@ -1195,6 +1192,10 @@
if (BG(mmap_file)) {
munmap(BG(mmap_file), BG(mmap_len));
}
+#endif
+
+#ifdef PHP_WIN32
+   CoUninitialize();
 #endif
 
return SUCCESS;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-CVS] cvs: php4 /ext/standard basic_functions.c config.m4 dns.c dns.h

2002-11-19 Thread Marcus Börger
No -  go on - marcus

At 07:35 19.11.2002, Derick Rethans wrote:

On Tue, 19 Nov 2002, Marcus Boerger wrote:

 helly Mon Nov 18 21:34:14 2002 EDT

   Modified files:
 /php4/ext/standardbasic_functions.c config.m4 dns.c dns.h
   Log:
   -rename checkdnsrr to dns_check_record, keep old name as alias
   -rename getmxrr to dns_get_mx, keep old name as alias
   -added dns_get_record
   @Added dns_get_record() which allows to retrieve DNS information about
   @a host. (Marcus, Pollita)

If you don't mind I'm going to change the parameter parser to the
zend_parse_parameters function which should result in shorter (and
usually better maintainable) code.

regards,
Derick

--

---
 Derick Rethans   http://derickrethans.nl/
 JDI Media Solutions
--[ if you hold a unix shell to your ear, do you hear the c? ]-


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-CVS] cvs: php4 /ext/standard basic_functions.c config.m4dns.c dns.h

2002-11-18 Thread Derick Rethans
On Tue, 19 Nov 2002, Marcus Boerger wrote:

 helly Mon Nov 18 21:34:14 2002 EDT
 
   Modified files:  
 /php4/ext/standardbasic_functions.c config.m4 dns.c dns.h 
   Log:
   -rename checkdnsrr to dns_check_record, keep old name as alias
   -rename getmxrr to dns_get_mx, keep old name as alias
   -added dns_get_record
   @Added dns_get_record() which allows to retrieve DNS information about
   @a host. (Marcus, Pollita)

If you don't mind I'm going to change the parameter parser to the 
zend_parse_parameters function which should result in shorter (and 
usually better maintainable) code.

regards,
Derick

-- 

---
 Derick Rethans   http://derickrethans.nl/ 
 JDI Media Solutions
--[ if you hold a unix shell to your ear, do you hear the c? ]-


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c

2002-11-08 Thread Sterling Hughes
sterlingFri Nov  8 10:49:32 2002 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c 
  Log:
  use consistent constants
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.542 
php4/ext/standard/basic_functions.c:1.543
--- php4/ext/standard/basic_functions.c:1.542   Tue Nov  5 01:05:48 2002
+++ php4/ext/standard/basic_functions.c Fri Nov  8 10:49:32 2002
 -17,7 +17,7 
+--+
  */
 
-/* $Id: basic_functions.c,v 1.542 2002/11/05 06:05:48 ssb Exp $ */
+/* $Id: basic_functions.c,v 1.543 2002/11/08 15:49:32 sterling Exp $ */
 
 #include php.h
 #include php_streams.h
 -467,11 +467,17 
PHP_FE(cosh,   
 NULL)
PHP_FE(tanh,   
 NULL)
 
-#if !defined(PHP_WIN32)  !defined(NETWARE)
+#ifdef HAVE_ASINH 
PHP_FE(asinh,  
 NULL)
+#endif
+#ifdef HAVE_ACOSH
PHP_FE(acosh,  
 NULL)
+#endif
+#ifdef HAVE_ATANH
PHP_FE(atanh,  
 NULL)
-   PHP_FE(expm1,  
 NULL) 
  
+#endif
+#if !defined(PHP_WIN32)  !defined(NETWARE)
+   PHP_FE(expm1,  
+ NULL)
PHP_FE(log1p,  
 NULL)
 #endif
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c config.m4

2002-10-30 Thread Hartmut Holzgraefe
hholzgraWed Oct 30 10:11:11 2002 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c config.m4 
  Log:
  getopt with long options reverted to configure problems
  (may find the wrong getopt.h so needed structures are not defined :(   )
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.539 
php4/ext/standard/basic_functions.c:1.540
--- php4/ext/standard/basic_functions.c:1.539   Tue Oct 29 18:35:49 2002
+++ php4/ext/standard/basic_functions.c Wed Oct 30 10:11:10 2002
 -17,7 +17,7 
+--+
  */
 
-/* $Id: basic_functions.c,v 1.539 2002/10/29 23:35:49 helly Exp $ */
+/* $Id: basic_functions.c,v 1.540 2002/10/30 15:11:10 hholzgra Exp $ */
 
 #include php.h
 #include php_streams.h
 -73,7 +73,7 
 # include sys/mman.h
 #endif
 
-#ifdef HAVE_GETOPT_H
+#ifdef HARTMUT_0
 #include getopt.h
 #endif
 
 -1373,7 +1373,7 
 }
 /* }}} */
 
-#ifdef HAVE_GETOPT_LONG
+#ifdef HARTMUT_0
 /* {{{ free_longopts
Free the memory allocated to an longopt array. */
 static void free_longopts(struct option *longopts)
 -1400,7 +1400,7 
char *optname;
int argc = 0, options_len = 0, o;
zval *val, **args = NULL, *p_longopts = NULL;
-#ifdef HAVE_GETOPT_LONG
+#ifdef HARTMUT_0
struct option *longopts = NULL;
int longindex = 0;
 #endif
 -1451,7 +1451,7 
}
 
if(p_longopts) {
-#ifdef HAVE_GETOPT_LONG
+#ifdef HARTMUT_0
int len, c = zend_hash_num_elements(Z_ARRVAL_P(p_longopts));
struct option *p;
zval **arg;
 -1505,7 +1505,7 
optind = 0;
 
/* Invoke getopt(3) on the argument array. */
-#ifdef HAVE_GETOPT_LONG
+#ifdef HARTMUT_0
while ((o = getopt_long(argc, argv, options, longopts, longindex)) != -1) {
 #else
while ((o = getopt(argc, argv, options)) != -1) {
 -1517,7 +1517,7 
 
/* Prepare the option character and the argument string. */
if(o == 0) {
-#ifdef HAVE_GETOPT_LONG
+#ifdef HARTMUT_0
optname = (char *)longopts[longindex].name;
 #endif
} else {
 -1546,7 +1546,7 
}
 
free_argv(argv, argc);
-#ifdef HAVE_GETOPT_LONG
+#ifdef HARTMUT_0
free_longopts(longopts);
 #endif
 }
Index: php4/ext/standard/config.m4
diff -u php4/ext/standard/config.m4:1.46 php4/ext/standard/config.m4:1.47
--- php4/ext/standard/config.m4:1.46Thu Oct 24 16:04:16 2002
+++ php4/ext/standard/config.m4 Wed Oct 30 10:11:11 2002
 -1,4 +1,4 
-dnl $Id: config.m4,v 1.46 2002/10/24 20:04:16 hholzgra Exp $ -*- sh -*-
+dnl $Id: config.m4,v 1.47 2002/10/30 15:11:11 hholzgra Exp $ -*- sh -*-
 
 divert(3)dnl
 
 -225,9 +225,13 
 
 AC_FUNC_FNMATCH
 
-AC_CHECK_HEADERS(getopt.h)
+dnl getopt long options disabled for now
+dnl as we can't be sure that we get the right getopt.h here
+dnl using the standard AC_CHECK macros
+dnl AC_CHECK_HEADERS(getopt.h)
+dnl AC_CHECK_FUNCS(getopt_long getopt_long_only)
 
-AC_CHECK_FUNCS(glob strfmon getopt_long getopt_long_only)
+AC_CHECK_FUNCS(glob strfmon)
 
 if test $PHP_SAPI = cgi; then
   AC_DEFINE(ENABLE_CHROOT_FUNC, 1, [Whether to enable chroot() function])



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c microtime.c microtime.h

2002-10-29 Thread Marcus Börger
helly   Tue Oct 29 18:35:49 2002 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c microtime.c microtime.h 
  Log:
  make microtime and gettimeofday unavailable instead of return false return
  false in case needed library function is unavailable.
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.538 
php4/ext/standard/basic_functions.c:1.539
--- php4/ext/standard/basic_functions.c:1.538   Fri Oct 25 15:33:09 2002
+++ php4/ext/standard/basic_functions.c Tue Oct 29 18:35:49 2002
 -17,7 +17,7 
+--+
  */
 
-/* $Id: basic_functions.c,v 1.538 2002/10/25 19:33:09 iliaa Exp $ */
+/* $Id: basic_functions.c,v 1.539 2002/10/29 23:35:49 helly Exp $ */
 
 #include php.h
 #include php_streams.h
 -508,8 +508,10 
PHP_FE(getopt, 
 NULL)
 #endif
 
+#ifdef HAVE_GETTIMEOFDAY
PHP_FE(microtime,  
 NULL)
PHP_FE(gettimeofday,   
 NULL)
+#endif
 
 #ifdef HAVE_GETRUSAGE
PHP_FE(getrusage,  
 NULL)
Index: php4/ext/standard/microtime.c
diff -u php4/ext/standard/microtime.c:1.38 php4/ext/standard/microtime.c:1.39
--- php4/ext/standard/microtime.c:1.38  Fri Sep  6 03:44:30 2002
+++ php4/ext/standard/microtime.c   Tue Oct 29 18:35:49 2002
 -16,7 +16,7 
+--+
  */
 
-/* $Id: microtime.c,v 1.38 2002/09/06 07:44:30 hyanantha Exp $ */
+/* $Id: microtime.c,v 1.39 2002/10/29 23:35:49 helly Exp $ */
 
 #include php.h
 
 -53,9 +53,9 
 
 /* {{{ proto string microtime(void)
Returns a string containing the current time in seconds and microseconds */
+#ifdef HAVE_GETTIMEOFDAY
 PHP_FUNCTION(microtime)
 {
-#ifdef HAVE_GETTIMEOFDAY
struct timeval tp;
long sec = 0L;
double msec = 0.0;
 -68,17 +68,18 
if (msec = 1.0) msec -= (long) msec;
snprintf(ret, 100, %.8f %ld, msec, sec);
RETVAL_STRING(ret,1);
-   } else
-#endif
+   } else {
RETURN_FALSE;
+   }
 }
+#endif
 /* }}} */
 
 /* {{{ proto array gettimeofday(void)
Returns the current time as array */
+#ifdef HAVE_GETTIMEOFDAY
 PHP_FUNCTION(gettimeofday)
 {
-#ifdef HAVE_GETTIMEOFDAY
struct timeval tp;
struct timezone tz;

 -95,10 +96,11 
 #endif 
add_assoc_long(return_value, dsttime, tz.tz_dsttime);
return;
-   } else
-#endif
-   RETURN_FALSE;
+   } else {
+   RETURN_FALSE;
+   }
 }
+#endif
 /* }}} */
 
 #ifdef HAVE_GETRUSAGE
Index: php4/ext/standard/microtime.h
diff -u php4/ext/standard/microtime.h:1.9 php4/ext/standard/microtime.h:1.10
--- php4/ext/standard/microtime.h:1.9   Thu Feb 28 03:26:46 2002
+++ php4/ext/standard/microtime.h   Tue Oct 29 18:35:49 2002
 -16,13 +16,17 
+--+
 */
 
-/* $Id: microtime.h,v 1.9 2002/02/28 08:26:46 sebastian Exp $ */
+/* $Id: microtime.h,v 1.10 2002/10/29 23:35:49 helly Exp $ */
 
 #ifndef MICROTIME_H
 #define MICROTIME_H
 
+#ifdef HAVE_GETTIMEOFDAY
 PHP_FUNCTION(microtime);
 PHP_FUNCTION(gettimeofday);
+#endif
+#ifdef HAVE_GETRUSAGE
 PHP_FUNCTION(getrusage);
+#endif
 
 #endif /* MICROTIME_H */



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c

2002-10-25 Thread Ilia Alshanetsky
iliaa   Fri Oct 25 15:33:10 2002 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c 
  Log:
  Cleanup (make sterling happy).
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.537 
php4/ext/standard/basic_functions.c:1.538
--- php4/ext/standard/basic_functions.c:1.537   Thu Oct 24 21:06:46 2002
+++ php4/ext/standard/basic_functions.c Fri Oct 25 15:33:09 2002
 -17,7 +17,7 
+--+
  */
 
-/* $Id: basic_functions.c,v 1.537 2002/10/25 01:06:46 iliaa Exp $ */
+/* $Id: basic_functions.c,v 1.538 2002/10/25 19:33:09 iliaa Exp $ */
 
 #include php.h
 #include php_streams.h
 -2344,13 +2344,11 
}
}   

-#define _CHECK_SAFEMODE_INI(ini, var) strncmp(ini, Z_STRVAL_PP(var), sizeof(ini))
-   
/* checks that ensure the user does not overwrite certain ini settings when 
safe_mode is enabled */
if (PG(safe_mode)) {
-   if (!_CHECK_SAFEMODE_INI(max_execution_time, varname) ||
-   !_CHECK_SAFEMODE_INI(memory_limit, varname) ||
-   !_CHECK_SAFEMODE_INI(child_terminate, varname)) {
+   if (!strncmp(max_execution_time, Z_STRVAL_PP(varname), 
+sizeof(max_execution_time)) ||
+   !strncmp(memory_limit, Z_STRVAL_PP(varname), 
+sizeof(memory_limit)) ||
+   !strncmp(child_terminate, Z_STRVAL_PP(varname), 
+sizeof(child_terminate))) {
zval_dtor(return_value);
RETURN_FALSE;
}   



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c

2002-10-24 Thread Ilia Alshanetsky
iliaa   Thu Oct 24 21:06:47 2002 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c 
  Log:
  Added a mechanism allowing the disabling of the ability to change 
  certain INI options when safe_mode is enabled.
  
  ATM three options are limited:
  max_execution_time
  memory_limit
  child_terminate
  
  This patch also fixes bug #17287.
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.536 
php4/ext/standard/basic_functions.c:1.537
--- php4/ext/standard/basic_functions.c:1.536   Thu Oct 24 16:04:16 2002
+++ php4/ext/standard/basic_functions.c Thu Oct 24 21:06:46 2002
 -17,7 +17,7 
+--+
  */
 
-/* $Id: basic_functions.c,v 1.536 2002/10/24 20:04:16 hholzgra Exp $ */
+/* $Id: basic_functions.c,v 1.537 2002/10/25 01:06:46 iliaa Exp $ */
 
 #include php.h
 #include php_streams.h
 -2342,6 +2342,18 
RETURN_FALSE;
}
}
+   }   
+   
+#define _CHECK_SAFEMODE_INI(ini, var) strncmp(ini, Z_STRVAL_PP(var), sizeof(ini))
+   
+   /* checks that ensure the user does not overwrite certain ini settings when 
+safe_mode is enabled */
+   if (PG(safe_mode)) {
+   if (!_CHECK_SAFEMODE_INI(max_execution_time, varname) ||
+   !_CHECK_SAFEMODE_INI(memory_limit, varname) ||
+   !_CHECK_SAFEMODE_INI(child_terminate, varname)) {
+   zval_dtor(return_value);
+   RETURN_FALSE;
+   }   
}   

if (zend_alter_ini_entry(Z_STRVAL_PP(varname), Z_STRLEN_PP(varname)+1, 
Z_STRVAL_PP(new_value), Z_STRLEN_PP(new_value),



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c

2002-10-21 Thread Hartmut Holzgraefe
hholzgraMon Oct 21 15:24:49 2002 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c 
  Log:
  fixed build for getopt_long-less platforms, 
  removed left-over todo comments
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.534 
php4/ext/standard/basic_functions.c:1.535
--- php4/ext/standard/basic_functions.c:1.534   Mon Oct 21 15:12:13 2002
+++ php4/ext/standard/basic_functions.c Mon Oct 21 15:24:48 2002
 -17,7 +17,7 
+--+
  */
 
-/* $Id: basic_functions.c,v 1.534 2002/10/21 19:12:13 jon Exp $ */
+/* $Id: basic_functions.c,v 1.535 2002/10/21 19:24:48 hholzgra Exp $ */
 
 #include php.h
 #include php_streams.h
 -1412,8 +1412,6 
 * Get argv from the global symbol table.  We calculate argc ourselves
 * in order to be on the safe side, even though it is also available
 * from the symbol table.
-*
-* TODO: Take from trackbars instead.
 */
if (zend_hash_find(HASH_OF(PG(http_globals)[TRACK_VARS_SERVER]), argv, 
sizeof(argv),
   (void **) args) != FAILURE) {
 -1469,7 +1467,6 
while (zend_hash_get_current_data(Z_ARRVAL_P(p_longopts),
  
(void **)arg) == SUCCESS) {
 
-   /* TODO: check for : and ::, strip'em, efrees ... */
p-has_arg = 0;
name = estrdup(Z_STRVAL_PP(arg));
len = strlen(name);
 -1513,13 +1510,14 
 #endif
/* Skip unknown arguments. */
if (o == '?') {
-   // TODO bailout?
continue;
}
 
/* Prepare the option character and the argument string. */
if(o == 0) {
+#ifdef HAVE_GETOPT_LONG
optname = (char *)longopts[longindex].name;
+#endif
} else {
if(o == 1) o = '-';
opt[0] = o;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-CVS] cvs: php4 /ext/standard basic_functions.c ftok.c php_ftok.h

2002-10-20 Thread Derick Rethans
On Sun, 20 Oct 2002, Wez Furlong wrote:

 Add ftok into the big list of functions in configure.in, and
 the build system should define HAVE_FTOK.
 
 (I think).

done (I think :).

Derick

--

---
 Derick Rethans   http://derickrethans.nl/ 
 JDI Media Solutions
--[ if you hold a unix shell to your ear, do you hear the c? ]-


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c ftok.c php_ftok.h

2002-10-20 Thread Derick Rethans
derick  Sun Oct 20 06:18:20 2002 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c ftok.c php_ftok.h 
  Log:
  - Remove #ifdefs around ftok function so that it is also available when
none of the IPC extensions are enabled.
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.530 
php4/ext/standard/basic_functions.c:1.531
--- php4/ext/standard/basic_functions.c:1.530   Thu Oct 17 18:44:43 2002
+++ php4/ext/standard/basic_functions.c Sun Oct 20 06:18:19 2002
 -17,7 +17,7 
+--+
  */
 
-/* $Id: basic_functions.c,v 1.530 2002/10/17 22:44:43 iliaa Exp $ */
+/* $Id: basic_functions.c,v 1.531 2002/10/20 10:18:19 derick Exp $ */
 
 #include php.h
 #include php_streams.h
 -832,9 +832,7 
 PHP_FE(version_compare,   
 NULL)
 
/* functions from ftok.c*/
-#if HAVE_SYSVSEM || HAVE_SYSVSHM  || HAVE_SHMOP
PHP_FE(ftok,NULL)
-#endif 
 
PHP_FE(str_rot13, NULL)
 
Index: php4/ext/standard/ftok.c
diff -u php4/ext/standard/ftok.c:1.6 php4/ext/standard/ftok.c:1.7
--- php4/ext/standard/ftok.c:1.6Fri Aug 23 21:19:28 2002
+++ php4/ext/standard/ftok.cSun Oct 20 06:18:20 2002
 -16,12 +16,10 
+--+
 */
 
-/* $Id: ftok.c,v 1.6 2002/08/24 01:19:28 helly Exp $ */
+/* $Id: ftok.c,v 1.7 2002/10/20 10:18:20 derick Exp $ */
 
 #include php.h
 
-#if HAVE_SYSVSEM || HAVE_SYSVSHM  || HAVE_SHMOP
-
 #include sys/types.h

 #include sys/ipc.h
 
 -55,8 +53,6 
 RETURN_LONG(k);
 }
 /* }}} */
-
-#endif
 
 /*
  * Local variables:
Index: php4/ext/standard/php_ftok.h
diff -u php4/ext/standard/php_ftok.h:1.3 php4/ext/standard/php_ftok.h:1.4
--- php4/ext/standard/php_ftok.h:1.3Thu Feb 28 03:26:46 2002
+++ php4/ext/standard/php_ftok.hSun Oct 20 06:18:20 2002
 -16,15 +16,11 
+--+
 */
 
-/* $Id: php_ftok.h,v 1.3 2002/02/28 08:26:46 sebastian Exp $ */
+/* $Id: php_ftok.h,v 1.4 2002/10/20 10:18:20 derick Exp $ */
 
 #ifndef PHP_FTOK_H
 #define PHP_FTOK_H
 
-#if HAVE_SYSVSEM || HAVE_SYSVSHM  || HAVE_SHMOP
-
 PHP_FUNCTION(ftok);
-
-#endif
 
 #endif /* PHP_FTOK_H */



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-CVS] cvs: php4 /ext/standard basic_functions.c ftok.c php_ftok.h

2002-10-20 Thread Derick Rethans
On Sun, 20 Oct 2002, Wez Furlong wrote:

 It might be a good idea to check for ftok in configure
 and protect it with HAVE_FTOK, just in case.

Yup, but how? :)

Derick

--

---
 Derick Rethans   http://derickrethans.nl/ 
 JDI Media Solutions
--[ if you hold a unix shell to your ear, do you hear the c? ]-


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-CVS] cvs: php4 /ext/standard basic_functions.c ftok.c php_ftok.h

2002-10-20 Thread Wez Furlong
Hey Derick,

It might be a good idea to check for ftok in configure
and protect it with HAVE_FTOK, just in case.

--Wez.

On 10/20/02, Derick Rethans [EMAIL PROTECTED] wrote:
 derickSun Oct 20 06:18:20 2002 EDT
 
   Modified files:  
 /php4/ext/standardbasic_functions.c ftok.c php_ftok.h 
   Log:
   - Remove #ifdefs around ftok function so that it is also available when
 none of the IPC extensions are enabled.
   
   
 Index: php4/ext/standard/basic_functions.c
 diff -u php4/ext/standard/basic_functions.c:1.530 
php4/ext/standard/basic_functions.c:1.531
 --- php4/ext/standard/basic_functions.c:1.530 Thu Oct 17 18:44:43 2002
 +++ php4/ext/standard/basic_functions.c   Sun Oct 20 06:18:19 2002
 @@ -17,7 +17,7 @@
 +--+
   */
  
 -/* $Id: basic_functions.c,v 1.530 2002/10/17 22:44:43 iliaa Exp $ */
 +/* $Id: basic_functions.c,v 1.531 2002/10/20 10:18:19 derick Exp $ */
  
  #include php.h
  #include php_streams.h
 @@ -832,9 +832,7 @@
  PHP_FE(version_compare, 
 NULL)
  
   /* functions from ftok.c*/
 -#if HAVE_SYSVSEM || HAVE_SYSVSHM  || HAVE_SHMOP
   PHP_FE(ftok,NULL)
 -#endif   
  
   PHP_FE(str_rot13, NULL)
  
 Index: php4/ext/standard/ftok.c
 diff -u php4/ext/standard/ftok.c:1.6 php4/ext/standard/ftok.c:1.7
 --- php4/ext/standard/ftok.c:1.6  Fri Aug 23 21:19:28 2002
 +++ php4/ext/standard/ftok.c  Sun Oct 20 06:18:20 2002
 @@ -16,12 +16,10 @@
 +--+
  */
  
 -/* $Id: ftok.c,v 1.6 2002/08/24 01:19:28 helly Exp $ */
 +/* $Id: ftok.c,v 1.7 2002/10/20 10:18:20 derick Exp $ */
  
  #include php.h
  
 -#if HAVE_SYSVSEM || HAVE_SYSVSHM  || HAVE_SHMOP
 -
  #include sys/types.h  
  
  #include sys/ipc.h
  
 @@ -55,8 +53,6 @@
  RETURN_LONG(k);
  }
  /* }}} */
 -
 -#endif
  
  /*
   * Local variables:
 Index: php4/ext/standard/php_ftok.h
 diff -u php4/ext/standard/php_ftok.h:1.3 php4/ext/standard/php_ftok.h:1.4
 --- php4/ext/standard/php_ftok.h:1.3  Thu Feb 28 03:26:46 2002
 +++ php4/ext/standard/php_ftok.h  Sun Oct 20 06:18:20 2002
 @@ -16,15 +16,11 @@
 +--+
  */
  
 -/* $Id: php_ftok.h,v 1.3 2002/02/28 08:26:46 sebastian Exp $ */
 +/* $Id: php_ftok.h,v 1.4 2002/10/20 10:18:20 derick Exp $ */
  
  #ifndef PHP_FTOK_H
  #define PHP_FTOK_H
  
 -#if HAVE_SYSVSEM || HAVE_SYSVSHM  || HAVE_SHMOP
 -
  PHP_FUNCTION(ftok);
 -
 -#endif
  
  #endif /* PHP_FTOK_H */
 
 
 
 -- 
 PHP CVS Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php




-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-CVS] cvs: php4 /ext/standard basic_functions.c ftok.c php_ftok.h

2002-10-20 Thread Wez Furlong
Add ftok into the big list of functions in configure.in, and
the build system should define HAVE_FTOK.

(I think).

--Wez.

On 10/20/02, Derick Rethans [EMAIL PROTECTED] wrote:
 On Sun, 20 Oct 2002, Wez Furlong wrote:
 
  It might be a good idea to check for ftok in configure
  and protect it with HAVE_FTOK, just in case.
 
 Yup, but how? :)
 
 Derick
 
 --
 
 ---
  Derick Rethans   http://derickrethans.nl/ 
  JDI Media Solutions
 --[ if you hold a unix shell to your ear, do you hear the c? ]-




-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c php_string.h string.c

2002-10-18 Thread Ilia Alshanetsky
iliaa   Thu Oct 17 18:44:45 2002 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c php_string.h string.c 
  Log:
  Renamed word_count to str_word_count to comply with naming conventions.
  Thanks Andi, for catching this oversight.
  
  
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.529 
php4/ext/standard/basic_functions.c:1.530
--- php4/ext/standard/basic_functions.c:1.529   Wed Oct 16 23:27:19 2002
+++ php4/ext/standard/basic_functions.c Thu Oct 17 18:44:43 2002
 -17,7 +17,7 
+--+
  */
 
-/* $Id: basic_functions.c,v 1.529 2002/10/17 03:27:19 iliaa Exp $ */
+/* $Id: basic_functions.c,v 1.530 2002/10/17 22:44:43 iliaa Exp $ */
 
 #include php.h
 #include php_streams.h
 -334,7 +334,7 
PHP_FE(stristr,
 NULL)
PHP_FE(strrchr,
 NULL)
PHP_FE(str_shuffle,
 NULL)
-   PHP_FE(word_count, 
 NULL)
+   PHP_FE(str_word_count, 
+ NULL)
 
 #ifdef HAVE_STRCOLL
PHP_FE(strcoll,
 NULL)
Index: php4/ext/standard/php_string.h
diff -u php4/ext/standard/php_string.h:1.64 php4/ext/standard/php_string.h:1.65
--- php4/ext/standard/php_string.h:1.64 Wed Oct 16 23:27:19 2002
+++ php4/ext/standard/php_string.h  Thu Oct 17 18:44:44 2002
 -17,7 +17,7 
+--+
 */
 
-/* $Id: php_string.h,v 1.64 2002/10/17 03:27:19 iliaa Exp $ */
+/* $Id: php_string.h,v 1.65 2002/10/17 22:44:44 iliaa Exp $ */
 
 /* Synced with php 3.0 revision 1.43 1999-06-16 [ssb] */
 
 -83,7 +83,7 
 PHP_FUNCTION(str_pad);
 PHP_FUNCTION(sscanf);
 PHP_FUNCTION(str_shuffle);
-PHP_FUNCTION(word_count);
+PHP_FUNCTION(str_word_count);
 #ifdef HAVE_STRCOLL
 PHP_FUNCTION(strcoll);
 #endif
Index: php4/ext/standard/string.c
diff -u php4/ext/standard/string.c:1.324 php4/ext/standard/string.c:1.325
--- php4/ext/standard/string.c:1.324Wed Oct 16 23:27:19 2002
+++ php4/ext/standard/string.c  Thu Oct 17 18:44:44 2002
 -18,7 +18,7 
+--+
  */
 
-/* $Id: string.c,v 1.324 2002/10/17 03:27:19 iliaa Exp $ */
+/* $Id: string.c,v 1.325 2002/10/17 22:44:44 iliaa Exp $ */
 
 /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
 
 -4027,7 +4027,7 
 }
 /* }}} */
 
-/* {{{ proto void word_count(string str, [int format])
+/* {{{ proto void str_word_count(string str, [int format])
Counts the number of words inside a string. If format of 1 is specified,
then the function will return an array containing all the words
found inside the string. If format of 2 is specified, then the function
 -4038,7 +4038,7 
string containing alphabetic characters, which also may contain, but not start
with ' and - characters.
 */
-PHP_FUNCTION(word_count)
+PHP_FUNCTION(str_word_count)
 {
zval **str, **o_format;
char *s, *e, *p, *buf;



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-CVS] cvs: php4 /ext/standard basic_functions.c php_string.hstring.c

2002-10-18 Thread Andi Gutmans
At 06:42 PM 10/17/2002 -0400, Ilia A. wrote:

I'll correct the name of the function I've added, I applogize for the
oversight. I do not think we should rename existing functions because it
would break BC and force us add to add even more function aliases. We already
have 400+ function alises in PHP, lets try avoiding adding new ones unless
absolutely needed.


I agree and that's what we decided a long time ago. Don't rename existing 
functions but name new ones correctly.
Thanks Ilia,

Andi


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Re: [PHP-CVS] cvs: php4 /ext/standard basic_functions.c php_string.hstring.c

2002-10-18 Thread Andi Gutmans
This should follow naming standards and start with str_

Andi

At 03:27 AM 10/17/2002 +, Ilia Alshanetsky wrote:

iliaa   Wed Oct 16 23:27:19 2002 EDT

  Modified files:
/php4/ext/standard  basic_functions.c php_string.h string.c
  Log:
  Added word_count() function that allows counting of words inside a string.
  The function also allows the user to retrieve all the words from a string.


Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.528 
php4/ext/standard/basic_functions.c:1.529
--- php4/ext/standard/basic_functions.c:1.528   Sun Oct  6 13:04:10 2002
+++ php4/ext/standard/basic_functions.c Wed Oct 16 23:27:19 2002
 -17,7 +17,7 
+--+
  */

-/* $Id: basic_functions.c,v 1.528 2002/10/06 17:04:10 rasmus Exp $ */
+/* $Id: basic_functions.c,v 1.529 2002/10/17 03:27:19 iliaa Exp $ */

 #include php.h
 #include php_streams.h
 -334,6 +334,7 
PHP_FE(stristr, 
   NULL)
PHP_FE(strrchr, 
   NULL)
PHP_FE(str_shuffle, 
   NULL)
+   PHP_FE(word_count, 
 NULL)

 #ifdef HAVE_STRCOLL
PHP_FE(strcoll, 
   NULL)
Index: php4/ext/standard/php_string.h
diff -u php4/ext/standard/php_string.h:1.63 
php4/ext/standard/php_string.h:1.64
--- php4/ext/standard/php_string.h:1.63 Fri Oct 11 10:48:25 2002
+++ php4/ext/standard/php_string.h  Wed Oct 16 23:27:19 2002
 -17,7 +17,7 
+--+
 */

-/* $Id: php_string.h,v 1.63 2002/10/11 14:48:25 iliaa Exp $ */
+/* $Id: php_string.h,v 1.64 2002/10/17 03:27:19 iliaa Exp $ */

 /* Synced with php 3.0 revision 1.43 1999-06-16 [ssb] */

 -83,6 +83,7 
 PHP_FUNCTION(str_pad);
 PHP_FUNCTION(sscanf);
 PHP_FUNCTION(str_shuffle);
+PHP_FUNCTION(word_count);
 #ifdef HAVE_STRCOLL
 PHP_FUNCTION(strcoll);
 #endif
Index: php4/ext/standard/string.c
diff -u php4/ext/standard/string.c:1.323 php4/ext/standard/string.c:1.324
--- php4/ext/standard/string.c:1.323Fri Oct 11 08:42:01 2002
+++ php4/ext/standard/string.c  Wed Oct 16 23:27:19 2002
 -18,7 +18,7 
+--+
  */

-/* $Id: string.c,v 1.323 2002/10/11 12:42:01 sander Exp $ */
+/* $Id: string.c,v 1.324 2002/10/17 03:27:19 iliaa Exp $ */

 /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */

 -4027,6 +4027,80 
 }
 /* }}} */

+/* {{{ proto void word_count(string str, [int format])
+   Counts the number of words inside a string. If format of 1 is 
specified,
+   then the function will return an array containing all the words
+   found inside the string. If format of 2 is specified, then the 
function
+   will return an associated array where the position of the word is 
the key
+   and the word itself is the value.
+
+   For the purpose of this function, 'word' is defined as a locale 
dependent
+   string containing alphabetic characters, which also may contain, 
but not start
+   with ' and - characters.
+*/
+PHP_FUNCTION(word_count)
+{
+   zval **str, **o_format;
+   char *s, *e, *p, *buf;
+   int word_count = 0;
+   int type = 0;
+   int n_args = ZEND_NUM_ARGS();
+
+   if( n_args  2 || n_args  1 || zend_get_parameters_ex(n_args, 
str, o_format) == FAILURE) {
+   WRONG_PARAM_COUNT;
+   }
+
+   if (n_args == 2) {
+   convert_to_long_ex(o_format);
+   type = Z_LVAL_PP(o_format);
+
+   if (type != 1  type != 2) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, The 
specified format parameter, '%d' is invalid., type);
+   RETURN_FALSE;
+   }
+   }
+
+   convert_to_string_ex(str);
+
+   p = s = Z_STRVAL_PP(str);
+   e = Z_STRVAL_PP(str) + Z_STRLEN_PP(str);
+
+   if (type == 1 || type == 2) {
+   array_init(return_value);
+   }
+
+   while (p  e) {
+   if (isalpha(*p++)) {
+   s = p - 1;
+   while (isalpha(*p) || *p == '\'' || (*p == '-'  
isalpha(*(p+1 {
+   p++;
+   }
+
+   switch (type)
+   {
+   case 1:
+   buf = estrndup(s, (p-s));
+ 
add_next_index_stringl(return_value, buf, (p-s), 1);
+   efree(buf);
+   break;
+   case 2:
+   buf = estrndup(s, (p-s));
+   

Re: [PHP-CVS] cvs: php4 /ext/standard basic_functions.c php_string.h string.c

2002-10-18 Thread Jon Parise
On Fri, Oct 18, 2002 at 12:22:10AM +0200, Andi Gutmans wrote:

 This should follow naming standards and start with str_
 
We also ready have 'wordwrap'.  This adds 'word_count'.  You suggest 
staying with 'str_'.  I think, whatever is decided, we should commit 
to using one notation.

-- 
Jon Parise ([EMAIL PROTECTED]) :: The PHP Project (http://www.php.net/)

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c php_string.h string.c

2002-10-16 Thread Ilia Alshanetsky

iliaa   Wed Oct 16 23:27:19 2002 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c php_string.h string.c 
  Log:
  Added word_count() function that allows counting of words inside a string.
  The function also allows the user to retrieve all the words from a string.
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.528 
php4/ext/standard/basic_functions.c:1.529
--- php4/ext/standard/basic_functions.c:1.528   Sun Oct  6 13:04:10 2002
+++ php4/ext/standard/basic_functions.c Wed Oct 16 23:27:19 2002
 -17,7 +17,7 
+--+
  */
 
-/* $Id: basic_functions.c,v 1.528 2002/10/06 17:04:10 rasmus Exp $ */
+/* $Id: basic_functions.c,v 1.529 2002/10/17 03:27:19 iliaa Exp $ */
 
 #include php.h
 #include php_streams.h
 -334,6 +334,7 
PHP_FE(stristr,
 NULL)
PHP_FE(strrchr,
 NULL)
PHP_FE(str_shuffle,
 NULL)
+   PHP_FE(word_count, 
+ NULL)
 
 #ifdef HAVE_STRCOLL
PHP_FE(strcoll,
 NULL)
Index: php4/ext/standard/php_string.h
diff -u php4/ext/standard/php_string.h:1.63 php4/ext/standard/php_string.h:1.64
--- php4/ext/standard/php_string.h:1.63 Fri Oct 11 10:48:25 2002
+++ php4/ext/standard/php_string.h  Wed Oct 16 23:27:19 2002
 -17,7 +17,7 
+--+
 */
 
-/* $Id: php_string.h,v 1.63 2002/10/11 14:48:25 iliaa Exp $ */
+/* $Id: php_string.h,v 1.64 2002/10/17 03:27:19 iliaa Exp $ */
 
 /* Synced with php 3.0 revision 1.43 1999-06-16 [ssb] */
 
 -83,6 +83,7 
 PHP_FUNCTION(str_pad);
 PHP_FUNCTION(sscanf);
 PHP_FUNCTION(str_shuffle);
+PHP_FUNCTION(word_count);
 #ifdef HAVE_STRCOLL
 PHP_FUNCTION(strcoll);
 #endif
Index: php4/ext/standard/string.c
diff -u php4/ext/standard/string.c:1.323 php4/ext/standard/string.c:1.324
--- php4/ext/standard/string.c:1.323Fri Oct 11 08:42:01 2002
+++ php4/ext/standard/string.c  Wed Oct 16 23:27:19 2002
 -18,7 +18,7 
+--+
  */
 
-/* $Id: string.c,v 1.323 2002/10/11 12:42:01 sander Exp $ */
+/* $Id: string.c,v 1.324 2002/10/17 03:27:19 iliaa Exp $ */
 
 /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
 
 -4027,6 +4027,80 
 }
 /* }}} */
 
+/* {{{ proto void word_count(string str, [int format])
+   Counts the number of words inside a string. If format of 1 is specified,
+   then the function will return an array containing all the words
+   found inside the string. If format of 2 is specified, then the function
+   will return an associated array where the position of the word is the key
+   and the word itself is the value.
+   
+   For the purpose of this function, 'word' is defined as a locale dependent
+   string containing alphabetic characters, which also may contain, but not start
+   with ' and - characters.
+*/
+PHP_FUNCTION(word_count)
+{
+   zval **str, **o_format;
+   char *s, *e, *p, *buf;
+   int word_count = 0;
+   int type = 0;
+   int n_args = ZEND_NUM_ARGS();
+
+   if( n_args  2 || n_args  1 || zend_get_parameters_ex(n_args, str, 
+o_format) == FAILURE) {
+   WRONG_PARAM_COUNT;
+   }
+   
+   if (n_args == 2) {
+   convert_to_long_ex(o_format);
+   type = Z_LVAL_PP(o_format);
+   
+   if (type != 1  type != 2) {
+   php_error_docref(NULL TSRMLS_CC, E_WARNING, The specified 
+format parameter, '%d' is invalid., type);
+   RETURN_FALSE;
+   }
+   }
+
+   convert_to_string_ex(str);
+   
+   p = s = Z_STRVAL_PP(str);
+   e = Z_STRVAL_PP(str) + Z_STRLEN_PP(str);
+   
+   if (type == 1 || type == 2) {
+   array_init(return_value);
+   }
+   
+   while (p  e) {
+   if (isalpha(*p++)) {
+   s = p - 1;
+   while (isalpha(*p) || *p == '\'' || (*p == '-'  
+isalpha(*(p+1 {
+   p++;
+   }
+   
+   switch (type)
+   {
+   case 1:
+   buf = estrndup(s, (p-s));
+   add_next_index_stringl(return_value, buf, 

[PHP-CVS] cvs: php4 /ext/standard basic_functions.c var.c /main output.c

2002-10-06 Thread Zeev Suraski

zeevSun Oct  6 08:02:54 2002 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c var.c 
/php4/main  output.c 
  Log:
  Revert the implicit_flush mess.
  
  Do not revert it again under any circumstances!
  
  Yasuo/anybody else - if there are issues with implicit_flush, please inform
  me and I will fix them.
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.524 
php4/ext/standard/basic_functions.c:1.525
--- php4/ext/standard/basic_functions.c:1.524   Sun Oct  6 05:06:24 2002
+++ php4/ext/standard/basic_functions.c Sun Oct  6 08:02:52 2002
 -17,7 +17,7 
+--+
  */
 
-/* $Id: basic_functions.c,v 1.524 2002/10/06 09:06:24 zeev Exp $ */
+/* $Id: basic_functions.c,v 1.525 2002/10/06 12:02:52 zeev Exp $ */
 
 #include php.h
 #include php_streams.h
 -2076,7 +2076,6 
convert_to_string(expr);
 
if (i) {
-   php_output_set_status(0 TSRMLS_CC);
php_start_ob_buffer (NULL, 0, 1 TSRMLS_CC);
}
 
 -2093,7 +2092,6 
if (i) {
php_ob_get_buffer (return_value TSRMLS_CC);
php_end_ob_buffer (0, 0 TSRMLS_CC);
-   php_output_set_status(1 TSRMLS_CC);
} else {
RETURN_TRUE;
}
Index: php4/ext/standard/var.c
diff -u php4/ext/standard/var.c:1.148 php4/ext/standard/var.c:1.149
--- php4/ext/standard/var.c:1.148   Thu Oct  3 09:32:00 2002
+++ php4/ext/standard/var.c Sun Oct  6 08:02:52 2002
 -349,7 +349,6 
}

if (return_output) {
-   php_output_set_status(0 TSRMLS_CC);
php_start_ob_buffer (NULL, 0, 1 TSRMLS_CC);
}

 -358,7 +357,6 
if (return_output) {
php_ob_get_buffer (return_value TSRMLS_CC);
php_end_ob_buffer (0, 0 TSRMLS_CC);
-   php_output_set_status(1 TSRMLS_CC);
}
 }
 /* }}} */
Index: php4/main/output.c
diff -u php4/main/output.c:1.140 php4/main/output.c:1.141
--- php4/main/output.c:1.140Sun Oct  6 05:06:24 2002
+++ php4/main/output.c  Sun Oct  6 08:02:53 2002
 -18,7 +18,7 
+--+
 */
 
-/* $Id: output.c,v 1.140 2002/10/06 09:06:24 zeev Exp $ */
+/* $Id: output.c,v 1.141 2002/10/06 12:02:53 zeev Exp $ */
 
 #include php.h
 #include ext/standard/head.h
 -94,10 +94,7 
 
 
 /* {{{ php_output_set_status
-   Toggle output status. Use this function for internal functions uses
-   buffers. If you don't implict flush (both php.ini implicit_flush and 
ob_impilict_flush())
-   may flush your php_printf() output.
-   status: 0 for disable output, 1 for enable.*/
+   Toggle output status.  Do NOT use in application code, only in SAPIs where 
+appropriate. */
 PHPAPI void php_output_set_status(zend_bool status TSRMLS_DC)
 {
OG(disable_output) = !status;
 -592,9 +589,8 
target[text_length]=0;
 
/* If implicit_flush is On or chunked buffering, send contents to next buffer 
and return. */
-   if (OG(implicit_flush) || (OG(active_ob_buffer).chunk_size
-OG(active_ob_buffer).text_length = 
OG(active_ob_buffer).chunk_size))
-   {
+   if (OG(active_ob_buffer).chunk_size
+OG(active_ob_buffer).text_length = 
+OG(active_ob_buffer).chunk_size) {
zval *output_handler = OG(active_ob_buffer).output_handler;

if (output_handler) {



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-CVS] cvs: php4 /ext/standard basic_functions.c var.c /main

2002-10-04 Thread Zeev Suraski

At 18:00 03/10/2002, Yasuo Ohgaki wrote:
Zeev Suraski wrote:
OG(implicit_flush) != PG(implicit_flush)

That's a myth.  What exactly do you think is the difference between 
them?  PG(implicit_flush) sets the value for OG(implicit_flush).  It's 
simply the cache value for the INI directive implicit_flush, whereas 
OG(implicit_flush) is the de-facto value that the output layer uses.

Let's get this behind us:

 From main.c, php_request_startup():

 } else if (PG(implicit_flush)) {
 php_start_implicit_flush(TSRMLS_C);
 }


 From output.c:
PHPAPI void php_start_implicit_flush(TSRMLS_D)
{
 OG(implicit_flush)=1;
}

Come again, how different are these two?

Why is it necessary to explicitly disable output in all of the places 
where you added set_status() calls??

To prevent implicit_flushing.

implicit_flush should have NOTHING, NOT A THING to do with output buffering 
that's done by PHP.  Hence, these calls are BOGUS.


As Derick noticed.

?php var_exprot('var'); ?

prints out exported var w/o it.

Right, but only because of your patch that pays attention to implicit_flush 
inside PHP's output buffering layer.

Please revert the patch!  And *KEEP* it reverted.  If there are still 
bugs/crashes/issues once this bogus code is reverted, I volunteer to fix 
it.  (I'm not reverting it myself since in order for this to finally end, I 
don't want yet another cycle of revert-recommit...)

Zeev


-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c

2002-10-04 Thread Marcus Börger

helly   Fri Oct  4 13:17:01 2002 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c 
  Log:
  return FALSE on error
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.522 
php4/ext/standard/basic_functions.c:1.523
--- php4/ext/standard/basic_functions.c:1.522   Thu Oct  3 09:31:59 2002
+++ php4/ext/standard/basic_functions.c Fri Oct  4 13:17:01 2002
 -17,7 +17,7 
+--+
  */
 
-/* $Id: basic_functions.c,v 1.522 2002/10/03 13:31:59 yohgaki Exp $ */
+/* $Id: basic_functions.c,v 1.523 2002/10/04 17:17:01 helly Exp $ */
 
 #include php.h
 #include php_streams.h
 -1377,7 +1377,7 

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s,
  options, options_len) == 
FAILURE) {
-   return;
+   RETURN_FALSE;
}
 
/*
 -2031,7 +2031,7 
zend_bool i = 0;
 
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, z|b, filename, i) == 
FAILURE) {
-   return;
+   RETURN_FALSE;
}
convert_to_string(filename);
 
 -2072,7 +2072,7 
zend_bool  i = 0;
 
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, z|b, expr, i) == 
FAILURE) {
-   return;
+   RETURN_FALSE;
}
convert_to_string(expr);
 
 -2170,7 +2170,7 
zend_module_entry *module;

if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |s, extname, 
extname_len) == FAILURE) {
-   return;
+   RETURN_FALSE;
}
 
zend_ini_sort_entries(TSRMLS_C);
 -2274,7 +2274,7 
zend_bool i = 0;
 
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, z|b, var, i) == 
FAILURE) {
-   return;
+   RETURN_FALSE;
}

if (i) {
 -2409,7 +2409,7 
if (ent == NULL) {
Z_LVAL_P(return_value) = -1;
Z_TYPE_P(return_value) = IS_LONG;
-   return;
+   RETURN_FALSE;
}
 
RETURN_LONG(ent-p_proto);
 -2696,7 +2696,7 
fh.handle.fp = VCWD_FOPEN(Z_STRVAL_PP(filename), r);
if (!fh.handle.fp) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, Cannot open '%s' for 
reading, Z_STRVAL_PP(filename));
-   return;
+   RETURN_FALSE;
}
Z_TYPE(fh) = ZEND_HANDLE_FP;
fh.filename = Z_STRVAL_PP(filename);



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-CVS] cvs: php4 /ext/standard basic_functions.c

2002-10-04 Thread Markus Fischer

No function never called RETURN_FALSE if
zend_parse_parameters couldn't successfully parse the passed
parameters.

Are we going to change this behaviour globally?

Function up and including today returned NULL if there was a
problem with parsing the parameters.

This could well break BC in my eyes. Is this absolutely
necessary ?

On Fri, Oct 04, 2002 at 05:17:01PM -, Marcus Börger wrote : 
 helly Fri Oct  4 13:17:01 2002 EDT
 
   Modified files:  
 /php4/ext/standardbasic_functions.c 
   Log:
   return FALSE on error
   
   
 Index: php4/ext/standard/basic_functions.c
 diff -u php4/ext/standard/basic_functions.c:1.522 
php4/ext/standard/basic_functions.c:1.523
 --- php4/ext/standard/basic_functions.c:1.522 Thu Oct  3 09:31:59 2002
 +++ php4/ext/standard/basic_functions.c   Fri Oct  4 13:17:01 2002
  -17,7 +17,7 
 +--+
   */
  
 -/* $Id: basic_functions.c,v 1.522 2002/10/03 13:31:59 yohgaki Exp $ */
 +/* $Id: basic_functions.c,v 1.523 2002/10/04 17:17:01 helly Exp $ */
  
  #include php.h
  #include php_streams.h
  -1377,7 +1377,7 
   
   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s,
 options, options_len) == 
FAILURE) {
 - return;
 + RETURN_FALSE;
[...]

-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-CVS] cvs: php4 /ext/standard basic_functions.c

2002-10-04 Thread Marcus Börger

In this case i would vote for RETURN_NULL(); instead
of simply using return;

At 20:20 04.10.2002, Markus Fischer wrote:
 No function never called RETURN_FALSE if
 zend_parse_parameters couldn't successfully parse the passed
 parameters.

 Are we going to change this behaviour globally?

 Function up and including today returned NULL if there was a
 problem with parsing the parameters.

 This could well break BC in my eyes. Is this absolutely
 necessary ?

On Fri, Oct 04, 2002 at 05:17:01PM -, Marcus Börger wrote :
  helly Fri Oct  4 13:17:01 2002 EDT
 
Modified files:
  /php4/ext/standardbasic_functions.c
Log:
return FALSE on error
 
 
  Index: php4/ext/standard/basic_functions.c
  diff -u php4/ext/standard/basic_functions.c:1.522 
 php4/ext/standard/basic_functions.c:1.523
  --- php4/ext/standard/basic_functions.c:1.522 Thu Oct  3 09:31:59 2002
  +++ php4/ext/standard/basic_functions.c   Fri Oct  4 13:17:01 2002
   -17,7 +17,7 
  
 +--+
*/
 
  -/* $Id: basic_functions.c,v 1.522 2002/10/03 13:31:59 yohgaki Exp $ */
  +/* $Id: basic_functions.c,v 1.523 2002/10/04 17:17:01 helly Exp $ */
 
   #include php.h
   #include php_streams.h
   -1377,7 +1377,7 
 
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s,
  options, 
 options_len) == FAILURE) {
  - return;
  + RETURN_FALSE;
[...]


--
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c var.c /main output.c /sapi/cli php_cli.c

2002-10-03 Thread Derick Rethans

derick  Thu Oct  3 06:35:34 2002 EDT

  Modified files:  
/php4/main  output.c 
/php4/ext/standard  var.c basic_functions.c 
/php4/sapi/cli  php_cli.c 
  Log:
  - Revert changed to implicit_flush behavior. The new behavior was not
intended in the first place.
  
  
Index: php4/main/output.c
diff -u php4/main/output.c:1.134 php4/main/output.c:1.135
--- php4/main/output.c:1.134Thu Oct  3 04:54:13 2002
+++ php4/main/output.c  Thu Oct  3 06:35:32 2002
 -18,7 +18,7 
+--+
 */
 
-/* $Id: output.c,v 1.134 2002/10/03 08:54:13 yohgaki Exp $ */
+/* $Id: output.c,v 1.135 2002/10/03 10:35:32 derick Exp $ */
 
 #include php.h
 #include ext/standard/head.h
 -596,11 +596,8 
/* If implicit_flush is On, send contents to next buffer and return.
   Both PG() and OG() should be used since we should flush implicitly
   always when implicit_flush is enabled in php.ini */
-   if (PG(implicit_flush) || OG(implicit_flush)
-   /* Also flush after each chunk if output is chunked */
-   || (OG(active_ob_buffer).chunk_size
-OG(active_ob_buffer).text_length = 
OG(active_ob_buffer).chunk_size)
-   ) {
+   if (OG(active_ob_buffer).chunk_size
+OG(active_ob_buffer).text_length = 
+OG(active_ob_buffer).chunk_size) {
zval *output_handler = OG(active_ob_buffer).output_handler;
 
if (output_handler) {
Index: php4/ext/standard/var.c
diff -u php4/ext/standard/var.c:1.146 php4/ext/standard/var.c:1.147
--- php4/ext/standard/var.c:1.146   Thu Oct  3 04:54:45 2002
+++ php4/ext/standard/var.c Thu Oct  3 06:35:33 2002
 -342,23 +342,21 
 PHP_FUNCTION(var_export)
 {
zval *var;
-   zend_bool return_output = 0;
+   zend_bool i = 0;

-   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, z|b, var, 
return_output) == FAILURE) {
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, z|b, var, i) == 
+FAILURE) {
return;
}

-   if (return_output) {
-   php_output_set_status(0 TSRMLS_CC);
+   if (i) {
php_start_ob_buffer (NULL, 0, 1 TSRMLS_CC);
}

php_var_export(var, 1 TSRMLS_CC);
 
-   if (return_output) {
+   if (i) {
php_ob_get_buffer (return_value TSRMLS_CC);
php_end_ob_buffer (0, 0 TSRMLS_CC);
-   php_output_set_status(1 TSRMLS_CC);
}
 }
 /* }}} */
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.519 
php4/ext/standard/basic_functions.c:1.520
--- php4/ext/standard/basic_functions.c:1.519   Thu Oct  3 05:19:31 2002
+++ php4/ext/standard/basic_functions.c Thu Oct  3 06:35:33 2002
 -17,7 +17,7 
+--+
  */
 
-/* $Id: basic_functions.c,v 1.519 2002/10/03 09:19:31 yohgaki Exp $ */
+/* $Id: basic_functions.c,v 1.520 2002/10/03 10:35:33 derick Exp $ */
 
 #include php.h
 #include php_streams.h
 -2077,7 +2077,6 
convert_to_string(expr);
 
if (i) {
-   php_output_set_status(0 TSRMLS_CC);
php_start_ob_buffer (NULL, 0, 1 TSRMLS_CC);
}
 
 -2094,7 +2093,6 
if (i) {
php_ob_get_buffer (return_value TSRMLS_CC);
php_end_ob_buffer (0, 0 TSRMLS_CC);
-   php_output_set_status(1 TSRMLS_CC);
} else {
RETURN_TRUE;
}
Index: php4/sapi/cli/php_cli.c
diff -u php4/sapi/cli/php_cli.c:1.34 php4/sapi/cli/php_cli.c:1.35
--- php4/sapi/cli/php_cli.c:1.34Thu Oct  3 05:57:53 2002
+++ php4/sapi/cli/php_cli.c Thu Oct  3 06:35:33 2002
 -466,6 +466,7 
SG(options) |= SAPI_OPTION_NO_CHDIR;
zend_alter_ini_entry(register_argc_argv, 19, 1, 1, PHP_INI_SYSTEM, 
PHP_INI_STAGE_ACTIVATE);
zend_alter_ini_entry(html_errors, 12, 0, 1, PHP_INI_SYSTEM, 
PHP_INI_STAGE_ACTIVATE);
+   zend_alter_ini_entry(implicit_flush, 15, 1, 1, PHP_INI_SYSTEM, 
+PHP_INI_STAGE_ACTIVATE);
zend_alter_ini_entry(max_execution_time, 19, 0, 1, PHP_INI_SYSTEM, 
PHP_INI_STAGE_ACTIVATE);
 
zend_uv.html_errors = 0; /* tell the engine we're in non-html mode */



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c

2002-10-03 Thread Andrey Hristov

andrey  Thu Oct  3 06:42:57 2002 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c 
  Log:
  ws fixes.
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.520 
php4/ext/standard/basic_functions.c:1.521
--- php4/ext/standard/basic_functions.c:1.520   Thu Oct  3 06:35:33 2002
+++ php4/ext/standard/basic_functions.c Thu Oct  3 06:42:57 2002
 -17,7 +17,7 
+--+
  */
 
-/* $Id: basic_functions.c,v 1.520 2002/10/03 10:35:33 derick Exp $ */
+/* $Id: basic_functions.c,v 1.521 2002/10/03 10:42:57 andrey Exp $ */
 
 #include php.h
 #include php_streams.h
 -1712,10 +1712,10 
if (call_user_function_ex(EG(function_table), NULL, *params[0], retval_ptr, 
argc-1, params+1, 0, NULL TSRMLS_CC) == SUCCESS  retval_ptr) {
COPY_PZVAL_TO_ZVAL(*return_value, retval_ptr);
} else {
-   if (argc1) {
+   if (argc  1) {
SEPARATE_ZVAL(params[1]);
convert_to_string_ex(params[1]);
-   if (argc2) {
+   if (argc  2) {
SEPARATE_ZVAL(params[2]);
convert_to_string_ex(params[2]);
php_error_docref1(NULL TSRMLS_CC, name, E_WARNING, 
Unable to call %s(%s,%s), name, Z_STRVAL_PP(params[1]), Z_STRVAL_PP(params[2]));
 -2129,7 +2129,7 
int module_number = va_arg(args, int);
zval *option;
 
-   if(module_number != 0  ini_entry-module_number != module_number) {
+   if (module_number != 0  ini_entry-module_number != module_number) {
return 0;
}
 
 -2138,7 +2138,7 
MAKE_STD_ZVAL(option);
array_init(option);
 
-   if(ini_entry-orig_value) {
+   if (ini_entry-orig_value) {
add_assoc_stringl(option, global_value, 
ini_entry-orig_value, ini_entry-orig_value_length, 1);
} else if (ini_entry-value) {
add_assoc_stringl(option, global_value, ini_entry-value, 
ini_entry-value_length, 1);
 -2146,7 +2146,7 
add_assoc_null(option, global_value);
}
 
-   if(ini_entry-value) {
+   if (ini_entry-value) {
add_assoc_stringl(option, local_value, ini_entry-value, 
ini_entry-value_length, 1);
} else {
add_assoc_null(option, local_value);
 -2173,7 +2173,7 
 
zend_ini_sort_entries(TSRMLS_C);
 
-   if(extname) {
+   if (extname) {
if (zend_hash_find(module_registry, extname, extname_len+1, (void **) 
module) == FAILURE) {
php_error_docref(NULL TSRMLS_CC, E_WARNING, Unable to find 
extension '%s', extname);
RETURN_FALSE;
 -2188,7 +2188,7 
 
 static int php_ini_check_path(char *option_name, int option_len, char 
*new_option_name, int new_option_len)
 {
-   if( option_len != (new_option_len-1) ) {
+   if ( option_len != (new_option_len-1) ) {
return 0;
}

 -2582,7 +2582,7 
switch (callback_type) {

case ZEND_INI_PARSER_ENTRY:
-   if(!arg2) {
+   if (!arg2) {
/* bare string - nothing to do */
break;
}
 -2609,7 +2609,7 
{
zval *active_arr;
 
-   if(!arg2) {
+   if (!arg2) {
/* bare string - nothing to do */
break;
}



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




Re: [PHP-CVS] cvs: php4 /ext/standard basic_functions.c var.c /main

2002-10-03 Thread Yasuo Ohgaki

Zeev Suraski wrote:
 Yasuo,
 
 Can you explain how come the output buffering code pays any attention to 
 implicit_flush, when I repeatedly said that output buffering and 
 implicit_flush are COMPLETELY unrelated?

This patch has nothing to do with implicit_flush ini directive.
Isn't ob_implicit_flush() written by you? Or is it written by
others?

--
Yasuo Ohgaki

 
 Zeev
 
 At 16:32 03/10/2002, Yasuo Ohgaki wrote:
 
 yohgaki Thu Oct  3 09:32:02 2002 EDT

   Modified files:
 /php4/ext/standard  basic_functions.c var.c
 /php4/main  output.c
   Log:
   Fixed broken code by Derick.
   ob_implicit_flush() and ob_flush_all() are stopped working.
   var_dump() and hightlisht_string() outputs buffer contents wrongly
   with ob_implicit_flush().

   Everyone should be happy now.
   It was only OG(implicit_flush) interpretation issue after all.



 Index: php4/ext/standard/basic_functions.c
 diff -u php4/ext/standard/basic_functions.c:1.521 
 php4/ext/standard/basic_functions.c:1.522
 --- php4/ext/standard/basic_functions.c:1.521   Thu Oct  3 06:42:57 2002
 +++ php4/ext/standard/basic_functions.c Thu Oct  3 09:31:59 2002
  -17,7 +17,7 
 
 +--+
   */

 -/* $Id: basic_functions.c,v 1.521 2002/10/03 10:42:57 andrey Exp $ */
 +/* $Id: basic_functions.c,v 1.522 2002/10/03 13:31:59 yohgaki Exp $ */

  #include php.h
  #include php_streams.h
  -2077,6 +2077,7 
 convert_to_string(expr);

 if (i) {
 +   php_output_set_status(0 TSRMLS_CC);
 php_start_ob_buffer (NULL, 0, 1 TSRMLS_CC);
 }

  -2093,6 +2094,7 
 if (i) {
 php_ob_get_buffer (return_value TSRMLS_CC);
 php_end_ob_buffer (0, 0 TSRMLS_CC);
 +   php_output_set_status(1 TSRMLS_CC);
 } else {
 RETURN_TRUE;
 }
 Index: php4/ext/standard/var.c
 diff -u php4/ext/standard/var.c:1.147 php4/ext/standard/var.c:1.148
 --- php4/ext/standard/var.c:1.147   Thu Oct  3 06:35:33 2002
 +++ php4/ext/standard/var.c Thu Oct  3 09:32:00 2002
  -342,21 +342,23 
  PHP_FUNCTION(var_export)
  {
 zval *var;
 -   zend_bool i = 0;
 +   zend_bool return_output = 0;

 -   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, z|b, 
 var, i) == FAILURE) {
 +   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, z|b, 
 var, return_output) == FAILURE) {
 return;
 }

 -   if (i) {
 +   if (return_output) {
 +   php_output_set_status(0 TSRMLS_CC);
 php_start_ob_buffer (NULL, 0, 1 TSRMLS_CC);
 }

 php_var_export(var, 1 TSRMLS_CC);

 -   if (i) {
 +   if (return_output) {
 php_ob_get_buffer (return_value TSRMLS_CC);
 php_end_ob_buffer (0, 0 TSRMLS_CC);
 +   php_output_set_status(1 TSRMLS_CC);
 }
  }
  /* }}} */
 Index: php4/main/output.c
 diff -u php4/main/output.c:1.137 php4/main/output.c:1.138
 --- php4/main/output.c:1.137Thu Oct  3 07:56:10 2002
 +++ php4/main/output.c  Thu Oct  3 09:32:01 2002
  -18,7 +18,7 
 
 +--+
  */

 -/* $Id: output.c,v 1.137 2002/10/03 11:56:10 jmoore Exp $ */
 +/* $Id: output.c,v 1.138 2002/10/03 13:32:01 yohgaki Exp $ */

  #include php.h
  #include ext/standard/head.h
  -591,10 +591,12 
 memcpy(target, text, text_length);
 target[text_length]=0;

 -   if (OG(active_ob_buffer).chunk_size
 -OG(active_ob_buffer).text_length = 
 OG(active_ob_buffer).chunk_size) {
 +   /* If implicit_flush is On, send contents to next buffer and 
 return. */
 +   if (OG(implicit_flush) || OG(active_ob_buffer).chunk_size
 +OG(active_ob_buffer).text_length = 
 OG(active_ob_buffer).chunk_size)
 +   {
 zval *output_handler = 
 OG(active_ob_buffer).output_handler;
 -
 +
 if (output_handler) {
 output_handler-refcount++;
 }



 -- 
 PHP CVS Mailing List (http://www.php.net/)
 To unsubscribe, visit: http://www.php.net/unsub.php
 
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c basic_functions.h

2002-09-29 Thread Jon Parise

jon Sun Sep 29 23:02:52 2002 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c basic_functions.h 
  Log:
   - Added getopt() for parsing command line options and arguments. (Jon)
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.515 
php4/ext/standard/basic_functions.c:1.516
--- php4/ext/standard/basic_functions.c:1.515   Sat Sep 28 18:14:20 2002
+++ php4/ext/standard/basic_functions.c Sun Sep 29 23:02:51 2002
 -17,7 +17,7 
+--+
  */
 
-/* $Id: basic_functions.c,v 1.515 2002/09/28 22:14:20 wez Exp $ */
+/* $Id: basic_functions.c,v 1.516 2002/09/30 03:02:51 jon Exp $ */
 
 #include php.h
 #include php_streams.h
 -498,6 +498,10 
PHP_FE(putenv, 
 NULL)
 #endif
 
+#ifdef HAVE_GETOPT
+   PHP_FE(getopt, 
+ NULL)
+#endif
+
PHP_FE(microtime,  
 NULL)
PHP_FE(gettimeofday,   
 NULL)
 
 -1337,6 +1341,105 
RETURN_FALSE;
}
}
+}
+/* }}} */
+#endif
+
+#ifdef HAVE_GETOPT
+/* {{{ free_argv
+   Free the memory allocated to an argv array. */
+static void free_argv(char **argv, int argc)
+{
+   int i;
+
+   if (argv) {
+   for (i = 0; i  argc; i++) {
+   if (argv[i]) {
+   efree(argv[i]);
+   }
+   }
+   efree(argv);
+   }
+}
+/* }}} */
+
+/* {{{ proto array getopt(string options)
+   Get options from the command line argument list */
+PHP_FUNCTION(getopt)
+{
+   char *options = NULL, **argv = NULL;
+   char opt[1] = { '\0' };
+   int argc = 0, options_len = 0;
+   zval *val, **args = NULL;
+   
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s,
+ options, options_len) == 
+FAILURE) {
+   return;
+   }
+
+   /*
+* Get argv from the global symbol table.  We calculate argc ourselves
+* in order to be on the safe side, even though it is also available
+* from the symbol table.
+*/
+   if (zend_hash_find(EG(symbol_table), argv, sizeof(argv),
+  (void **) args) != FAILURE) {
+   int pos = 0;
+   zval **arg;
+
+   argc = zend_hash_num_elements(Z_ARRVAL_PP(args));
+
+   /* Attempt to allocate enough memory to hold all of the arguments. */
+   if ((argv = (char **) emalloc(argc * sizeof(char *))) == NULL) {
+   RETURN_FALSE;
+   }
+
+   /* Reset the array indexes. */
+   zend_hash_internal_pointer_reset(Z_ARRVAL_PP(args));
+
+   /* Iterate over the hash to construct the argv array. */
+   while (zend_hash_get_current_data(Z_ARRVAL_PP(args),
+ 
+(void **)arg) == SUCCESS) {
+   argv[pos++] = estrdup(Z_STRVAL_PP(arg));
+   zend_hash_move_forward(Z_ARRVAL_PP(args));
+   }
+   }
+
+   /* Initialize the return value as an array. */
+   if (array_init(return_value)) {
+   RETURN_FALSE;
+   }
+
+   /* Disable getopt()'s error messages. */
+   opterr = 0;
+
+   /* Invoke getopt(3) on the argument array. */
+   while (getopt(argc, argv, options) != -1) {
+
+   /* Skip unknown arguments. */
+   if (optopt == '?') {
+   continue;
+   }
+
+   /* Prepare the option character and the argument string. */
+   opt[0] = optopt;
+
+   MAKE_STD_ZVAL(val);
+   if (optarg != NULL) {
+   ZVAL_STRING(val, optarg, 1);
+   } else {
+   ZVAL_NULL(val);
+   }
+
+   /* Add this option / argument pair to the result hash. */
+   if (zend_hash_add(HASH_OF(return_value), opt, 1, (void *)val,
+sizeof(zval *), NULL) == 
+FAILURE) {
+   free_argv(argv, argc);
+   RETURN_FALSE;
+   }
+   }
+
+   free_argv(argv, argc);
 }
 /* }}} */
 #endif
Index: php4/ext/standard/basic_functions.h
diff -u php4/ext/standard/basic_functions.h:1.107 
php4/ext/standard/basic_functions.h:1.108
--- 

[PHP-CVS] cvs: php4 /ext/standard basic_functions.c file.c file.h http_fopen_wrapper.c /ext/standard/tests/file userstreams.phpt /main user_streams.c

2002-09-28 Thread Wez Furlong

wez Sat Sep 28 18:14:21 2002 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c file.c file.h 
http_fopen_wrapper.c 
/php4/ext/standard/tests/file   userstreams.phpt 
/php4/main  user_streams.c 
  Log:
  Rename streams functions to fit with naming conventions, adding aliases
  for old functions where required.
  Make use of recent changes to chunk size and timeout setting code.
  
  

Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.514 
php4/ext/standard/basic_functions.c:1.515
--- php4/ext/standard/basic_functions.c:1.514   Fri Sep 27 19:42:38 2002
+++ php4/ext/standard/basic_functions.c Sat Sep 28 18:14:20 2002
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.514 2002/09/27 23:42:38 wez Exp $ */
+/* $Id: basic_functions.c,v 1.515 2002/09/28 22:14:20 wez Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -630,20 +630,22 @@
PHP_FE(fgetcsv,
 NULL)
PHP_FE(flock,  
 NULL)
PHP_FE(get_meta_tags,  
 NULL)
-   PHP_FE(set_file_buffer,
 NULL)
+   PHP_FE(stream_set_write_buffer,
+ NULL)
+   PHP_FALIAS(set_file_buffer, stream_set_write_buffer,   
+ NULL)
 
PHP_FE(set_socket_blocking,
 NULL)
PHP_FE(stream_set_blocking,
 NULL)
PHP_FALIAS(socket_set_blocking, stream_set_blocking,   
 NULL)
 
-   PHP_FE(file_get_meta_data, 
 NULL)
-   PHP_FE(file_register_wrapper,  
 NULL)
+   PHP_FE(stream_get_meta_data,   
+ NULL)
+   PHP_FE(stream_register_wrapper,
+ NULL)
 
 #if HAVE_SYS_TIME_H || defined(PHP_WIN32)
-   PHP_FE(socket_set_timeout, 
 NULL)
+   PHP_FE(stream_set_timeout, 
+ NULL)
+   PHP_FALIAS(socket_set_timeout, stream_set_timeout, 
+ NULL)
 #endif
 
-   PHP_FALIAS(socket_get_status, file_get_meta_data,  
 NULL)
+   PHP_FALIAS(socket_get_status, stream_get_meta_data,
+ NULL)
 
 #if (!defined(PHP_WIN32)  !defined(__BEOS__)  !defined(NETWARE)  HAVE_REALPATH) 
|| defined(ZTS)
PHP_FE(realpath,   
 NULL)
Index: php4/ext/standard/file.c
diff -u php4/ext/standard/file.c:1.265 php4/ext/standard/file.c:1.266
--- php4/ext/standard/file.c:1.265  Sat Sep 28 09:04:47 2002
+++ php4/ext/standard/file.cSat Sep 28 18:14:21 2002
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.265 2002/09/28 13:04:47 wez Exp $ */
+/* $Id: file.c,v 1.266 2002/09/28 22:14:21 wez Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -582,9 +582,9 @@
 }
 /* }}} */
 
-/* {{{ proto resource file_get_meta_data(resource fp)
+/* {{{ proto resource stream_get_meta_data(resource fp)
 Retrieves header/meta data from streams/file pointers */
-PHP_FUNCTION(file_get_meta_data)
+PHP_FUNCTION(stream_get_meta_data)
 {
zval **arg1;
php_stream *stream;
@@ -639,6 +639,7 @@
 }
 /* }}} */
 
+/* {{{ stream_select related functions */
 static int stream_array_to_fd_set(zval *stream_array, fd_set *fds, int *max_fd 
TSRMLS_DC)
 {
zval **elem;
@@ -664,9 +665,7 @@
}
}
}
-
return 1;
-
 }
 
 static int stream_array_from_fd_set(zval *stream_array, fd_set *fds TSRMLS_DC)
@@ -708,9 +707,8 @@
Z_ARRVAL_P(stream_array) = new_hash;

return 1;
-
 }
-
+/* }}} */
 
 /* {{{ proto int stream_select(array 

[PHP-CVS] cvs: php4 /ext/standard basic_functions.c file.c file.h

2002-09-27 Thread Wez Furlong

wez Fri Sep 27 19:42:38 2002 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c file.c file.h 
  Log:
  Implement stream_select() which works just like socket_select, but only on
  streams.
   - Added stream_select() which works like socket_select but only works on
 streams returned by fopen(), fsockopen() and pfsockopen(). (Wez)
  
  

Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.513 
php4/ext/standard/basic_functions.c:1.514
--- php4/ext/standard/basic_functions.c:1.513   Thu Sep 26 06:14:40 2002
+++ php4/ext/standard/basic_functions.c Fri Sep 27 19:42:38 2002
 -17,7 +17,7 
+--+
  */
 
-/* $Id: basic_functions.c,v 1.513 2002/09/26 10:14:40 wez Exp $ */
+/* $Id: basic_functions.c,v 1.514 2002/09/27 23:42:38 wez Exp $ */
 
 #include php.h
 #include php_streams.h
 -99,6 +99,9 
 static unsigned char second_args_force_ref[] = { 2, BYREF_NONE, BYREF_FORCE };
 static unsigned char third_and_fourth_args_force_ref[] = { 4, BYREF_NONE, BYREF_NONE, 
BYREF_FORCE, BYREF_FORCE };
 static unsigned char third_and_rest_force_ref[] = { 3, BYREF_NONE, BYREF_NONE, 
BYREF_FORCE_REST };
+static unsigned char first_through_third_args_force_ref[] =
+{3, BYREF_FORCE, BYREF_FORCE, BYREF_FORCE};
+
 
 typedef struct _php_shutdown_function_entry {
zval **arguments;
 -617,6 +620,7 
PHP_STATIC_FE(tmpfile,php_if_tmpfile,
 NULL)
PHP_FE(file,   
 NULL)
PHP_FE(file_get_contents,  
 NULL)
+   PHP_FE(stream_select, 
+first_through_third_args_force_ref)
PHP_FE(stream_context_create,  
 NULL)
PHP_FE(stream_context_set_params,  
 NULL)
PHP_FE(stream_context_set_option,  
 NULL)
 -628,11 +632,9 
PHP_FE(get_meta_tags,  
 NULL)
PHP_FE(set_file_buffer,
 NULL)
 
-   /* set_socket_blocking() is deprecated,
-  use socket_set_blocking() instead 
-   */
PHP_FE(set_socket_blocking,
 NULL)
-   PHP_FE(socket_set_blocking,
 NULL)
+   PHP_FE(stream_set_blocking,
+ NULL)
+   PHP_FALIAS(socket_set_blocking, stream_set_blocking,   
+ NULL)
 
PHP_FE(file_get_meta_data, 
 NULL)
PHP_FE(file_register_wrapper,  
 NULL)
Index: php4/ext/standard/file.c
diff -u php4/ext/standard/file.c:1.263 php4/ext/standard/file.c:1.264
--- php4/ext/standard/file.c:1.263  Thu Sep 26 08:12:26 2002
+++ php4/ext/standard/file.cFri Sep 27 19:42:38 2002
 -21,7 +21,7 
+--+
  */
 
-/* $Id: file.c,v 1.263 2002/09/26 12:12:26 wez Exp $ */
+/* $Id: file.c,v 1.264 2002/09/27 23:42:38 wez Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
 -639,6 +639,130 
 }
 /* }}} */
 
+static int stream_array_to_fd_set(zval *stream_array, fd_set *fds, int *max_fd 
+TSRMLS_DC)
+{
+   zval **elem;
+   php_stream *stream;
+   int this_fd;
+
+   if (Z_TYPE_P(stream_array) != IS_ARRAY)
+   return 0;
+
+   for (zend_hash_internal_pointer_reset(Z_ARRVAL_P(stream_array));
+zend_hash_get_current_data(Z_ARRVAL_P(stream_array), (void **) elem) 
+== SUCCESS;
+zend_hash_move_forward(Z_ARRVAL_P(stream_array))) {
+
+   php_stream_from_zval_no_verify(stream, elem);
+   if (stream == NULL)
+   continue;
+
+   /* get the fd */
+   if (SUCCESS == php_stream_cast(stream, PHP_STREAM_AS_FD, 
+(void*)this_fd, 1)) {
+   FD_SET(this_fd, fds);
+   if (this_fd  *max_fd) {
+   *max_fd = this_fd;
+   }
+   }
+   }
+
+   return 1;
+

[PHP-CVS] cvs: php4 /ext/standard basic_functions.c file.c file.h fsock.c /main main.c network.c php.h php_network.h php_streams.h streams.c

2002-09-25 Thread Wez Furlong

wez Wed Sep 25 11:25:13 2002 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c file.c file.h fsock.c 
/php4/main  main.c network.c php.h php_network.h php_streams.h 
streams.c 
  Log:
  Implement persistent streams. (for pfsockopen).
  Juggle some includes/definitions.
  Tidy up streams use in ext/standard/file.c
  
  

Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.510 
php4/ext/standard/basic_functions.c:1.511
--- php4/ext/standard/basic_functions.c:1.510   Tue Sep 24 06:55:56 2002
+++ php4/ext/standard/basic_functions.c Wed Sep 25 11:25:11 2002
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.510 2002/09/24 10:55:56 zeev Exp $ */
+/* $Id: basic_functions.c,v 1.511 2002/09/25 15:25:11 wez Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -1136,6 +1136,7 @@
PHP_RSHUTDOWN(syslog) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
PHP_RSHUTDOWN(assert) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
PHP_RSHUTDOWN(url_scanner_ex) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
+   PHP_RSHUTDOWN(streams) (SHUTDOWN_FUNC_ARGS_PASSTHRU);
 
if (BG(user_tick_functions)) {
zend_llist_destroy(BG(user_tick_functions));
@@ -1148,7 +1149,7 @@
efree(BG(aggregation_table));
BG(aggregation_table) = NULL;
}
-
+   
 #ifdef HAVE_MMAP
if (BG(mmap_file)) {
munmap(BG(mmap_file), BG(mmap_len));
Index: php4/ext/standard/file.c
diff -u php4/ext/standard/file.c:1.257 php4/ext/standard/file.c:1.258
--- php4/ext/standard/file.c:1.257  Mon Sep 23 22:46:38 2002
+++ php4/ext/standard/file.cWed Sep 25 11:25:11 2002
@@ -21,7 +21,7 @@
+--+
  */
 
-/* $Id: file.c,v 1.257 2002/09/24 02:46:38 wez Exp $ */
+/* $Id: file.c,v 1.258 2002/09/25 15:25:11 wez Exp $ */
 
 /* Synced with php 3.0 revision 1.218 1999-06-16 [ssb] */
 
@@ -119,7 +119,6 @@
 /* {{{ ZTS-stuff / Globals / Prototypes */
 
 /* sharing globals is *evil* */
-static int le_stream = FAILURE;
 static int le_stream_context = FAILURE;
 
 /* }}} */
@@ -130,29 +129,14 @@
php_stream_context_free((php_stream_context*)rsrc-ptr);
 }
 
-static void _file_stream_dtor(zend_rsrc_list_entry *rsrc TSRMLS_DC)
-{
-   php_stream *stream = (php_stream*)rsrc-ptr;
-   /* the stream might be a pipe, so set the return value for pclose */
-   FG(pclose_ret) = php_stream_free(stream, PHP_STREAM_FREE_CLOSE | 
PHP_STREAM_FREE_RSRC_DTOR);
-}
-
-PHPAPI int php_file_le_stream(void)
-{
-   return le_stream;
-}
-
 static void file_globals_ctor(php_file_globals *file_globals_p TSRMLS_DC)
 {
-   zend_hash_init(FG(ht_persistent_socks), 0, NULL, NULL, 1);
FG(pclose_ret) = 0;
FG(def_chunk_size) = PHP_SOCK_CHUNK_SIZE;
 }
 
-
 static void file_globals_dtor(php_file_globals *file_globals_p TSRMLS_DC)
 {
-   zend_hash_destroy(FG(ht_persistent_socks));
 }
 
 
@@ -164,7 +148,6 @@
 
 PHP_MINIT_FUNCTION(file)
 {
-   le_stream = zend_register_list_destructors_ex(_file_stream_dtor, NULL, 
stream, module_number);
le_stream_context = zend_register_list_destructors_ex(file_context_dtor, NULL, 
stream-context, module_number);
 
 #ifdef ZTS
@@ -219,17 +202,16 @@
 PHP_FUNCTION(flock)
 {
 zval **arg1, **arg2, **arg3;
-int type, fd, act, ret, arg_count = ZEND_NUM_ARGS();
-   void *what;
+int fd, act, ret, arg_count = ZEND_NUM_ARGS();
+   php_stream *stream;
 
 if (arg_count  3 || zend_get_parameters_ex(arg_count, arg1, arg2, arg3) == 
FAILURE) {
 WRONG_PARAM_COUNT;
 }
 
-   what = zend_fetch_resource(arg1 TSRMLS_CC, -1, File-Handle, type, 1, 
le_stream);
-   ZEND_VERIFY_RESOURCE(what);
+   php_stream_from_zval(stream, arg1);
 
-   if (php_stream_cast((php_stream*)what, PHP_STREAM_AS_FD, (void*)fd, 1) == 
FAILURE) {
+   if (php_stream_cast(stream, PHP_STREAM_AS_FD, (void*)fd, 1) == FAILURE)   
+ {
RETURN_FALSE;
}
 
@@ -600,8 +582,7 @@
if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, arg1) == FAILURE) {
WRONG_PARAM_COUNT;
}
-   stream = (php_stream*)zend_fetch_resource(arg1 TSRMLS_CC, -1, File-Handle, 
NULL, 1, le_stream);
-   ZEND_VERIFY_RESOURCE(stream);
+   php_stream_from_zval(stream, arg1);
 
if (stream-wrapperdata){
*return_value = *(stream-wrapperdata);
@@ -707,19 +688,23 @@
 /* given a zval which is either a stream or a context, return the underlying
  * stream_context.  If it is a stream that does not have a context assigned, it
  * will create and assign a context and return that.  */
-static php_stream_context *decode_context_param(zval *contextresource TSRMLS_DC) {
-   php_stream_context *context = NULL; void *what; int type;
-
-   what = 

[PHP-CVS] cvs: php4 /ext/standard basic_functions.c php_string.h string.c

2002-09-25 Thread Andrey Hristov

andrey  Wed Sep 25 14:06:06 2002 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c php_string.h string.c 
  Log:
  str_shuffle() function added. Like shuffle() for arrays - however the
  algorithm for creating the permutation is quite simple. More like 
  the implementation of shuffle() for 4.2.1 .
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.511 
php4/ext/standard/basic_functions.c:1.512
--- php4/ext/standard/basic_functions.c:1.511   Wed Sep 25 11:25:11 2002
+++ php4/ext/standard/basic_functions.c Wed Sep 25 14:06:05 2002
 -17,7 +17,7 
+--+
  */
 
-/* $Id: basic_functions.c,v 1.511 2002/09/25 15:25:11 wez Exp $ */
+/* $Id: basic_functions.c,v 1.512 2002/09/25 18:06:05 andrey Exp $ */
 
 #include php.h
 #include php_streams.h
 -329,6 +329,7 
PHP_FE(strstr, 
 NULL)
PHP_FE(stristr,
 NULL)
PHP_FE(strrchr,
 NULL)
+   PHP_FE(str_shuffle,
+ NULL)
 
 #ifdef HAVE_STRCOLL
PHP_FE(strcoll,
 NULL)
Index: php4/ext/standard/php_string.h
diff -u php4/ext/standard/php_string.h:1.60 php4/ext/standard/php_string.h:1.61
--- php4/ext/standard/php_string.h:1.60 Tue Aug 20 16:47:47 2002
+++ php4/ext/standard/php_string.h  Wed Sep 25 14:06:05 2002
 -17,7 +17,7 
+--+
 */
 
-/* $Id: php_string.h,v 1.60 2002/08/20 20:47:47 wez Exp $ */
+/* $Id: php_string.h,v 1.61 2002/09/25 18:06:05 andrey Exp $ */
 
 /* Synced with php 3.0 revision 1.43 1999-06-16 [ssb] */
 
 -82,6 +82,7 
 PHP_FUNCTION(substr_count);
 PHP_FUNCTION(str_pad);
 PHP_FUNCTION(sscanf);
+PHP_FUNCTION(str_shuffle);
 #ifdef HAVE_STRCOLL
 PHP_FUNCTION(strcoll);
 #endif
Index: php4/ext/standard/string.c
diff -u php4/ext/standard/string.c:1.297 php4/ext/standard/string.c:1.298
--- php4/ext/standard/string.c:1.297Mon Sep 23 10:20:02 2002
+++ php4/ext/standard/string.c  Wed Sep 25 14:06:05 2002
 -18,7 +18,7 
+--+
  */
 
-/* $Id: string.c,v 1.297 2002/09/23 14:20:02 sebastian Exp $ */
+/* $Id: string.c,v 1.298 2002/09/25 18:06:05 andrey Exp $ */
 
 /* Synced with php 3.0 revision 1.193 1999-06-16 [ssb] */
 
 -3929,6 +3929,39 
zval_copy_ctor(return_value);
 
php_strtr(Z_STRVAL_P(return_value), Z_STRLEN_P(return_value), rot13_from, 
rot13_to, 52);
+}
+/* }}} */
+
+
+static int php_string_shuffle(const void *a, const void *b TSRMLS_DC)
+{
+   long rnd;
+   rnd = php_rand(TSRMLS_C);
+   if (rnd % 3)
+   return 1;
+   else if (rnd % 5)
+   return 0;
+   else 
+   return -1;
+}
+
+/* {{{ proto string str_shuffle(string str)
+   Shuffles string. One permutation of all possible is created */
+PHP_FUNCTION(str_shuffle)
+{
+   /* Note : by using current php_string_shuffle for string  */
+   /* with 6 chars (6! permutations) about 2/3 of them are   */
+   /* computed for 6! calls for the function. So it isn't so */
+   /* unique. The ratio is the same for other lengths.   */
+   char *str;
+   int i, str_len;
+   
+   i = 0;
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, s, str, str_len) == 
+FAILURE) {
+   RETURN_FALSE;
+   }
+   zend_qsort((void *)str, str_len, sizeof(char), php_string_shuffle TSRMLS_CC);
+   RETURN_STRINGL(str, str_len, 1);
 }
 /* }}} */
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c

2002-09-23 Thread Wez Furlong

wez Mon Sep 23 13:27:38 2002 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c 
  Log:
  basic_functions.c
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.508 
php4/ext/standard/basic_functions.c:1.509
--- php4/ext/standard/basic_functions.c:1.508   Sat Sep 21 10:50:04 2002
+++ php4/ext/standard/basic_functions.c Mon Sep 23 13:27:37 2002
 -17,7 +17,7 
+--+
  */
 
-/* $Id: basic_functions.c,v 1.508 2002/09/21 14:50:04 andrey Exp $ */
+/* $Id: basic_functions.c,v 1.509 2002/09/23 17:27:37 wez Exp $ */
 
 #include php.h
 #include php_streams.h
 -1051,6 +1051,7 
php_unregister_url_stream_wrapper(ftp TSRMLS_CC);
 # if HAVE_OPENSSL_EXT
php_unregister_url_stream_wrapper(https TSRMLS_CC);
+   php_unregister_url_stream_wrapper(ftps TSRMLS_CC);
 # endif
 #endif
 



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c head.c

2002-09-17 Thread Hartmut Holzgraefe

hholzgraTue Sep 17 08:37:26 2002 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c head.c 
  Log:
  headers_sent() may now return information about where output started
  using the optional $file and $line reference parameters
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.504 
php4/ext/standard/basic_functions.c:1.505
--- php4/ext/standard/basic_functions.c:1.504   Wed Sep 11 14:13:48 2002
+++ php4/ext/standard/basic_functions.c Tue Sep 17 08:37:26 2002
@@ -17,7 +17,7 @@
+--+
  */
 
-/* $Id: basic_functions.c,v 1.504 2002/09/11 18:13:48 andrey Exp $ */
+/* $Id: basic_functions.c,v 1.505 2002/09/17 12:37:26 hholzgra Exp $ */
 
 #include php.h
 #include php_streams.h
@@ -94,6 +94,7 @@
 
 #include php_fopen_wrappers.h
 
+static unsigned char first_and_second__args_force_ref[] = { 2, BYREF_FORCE, 
+BYREF_FORCE };
 static unsigned char second_and_third_args_force_ref[] = { 3, BYREF_NONE, 
BYREF_FORCE, BYREF_FORCE };
 static unsigned char second_args_force_ref[] = { 2, BYREF_NONE, BYREF_FORCE };
 static unsigned char third_and_fourth_args_force_ref[] = { 4, BYREF_NONE, BYREF_NONE, 
BYREF_FORCE, BYREF_FORCE };
@@ -540,7 +541,7 @@
PHP_FE(ini_restore,
 NULL)
 
PHP_FE(setcookie,  
 NULL)
-   PHP_FE(header, 
 NULL)
+   PHP_FE(header, 
+ first_and_second__args_force_ref)
PHP_FE(headers_sent,   
 NULL)
 
PHP_FE(connection_aborted, 
 NULL)
Index: php4/ext/standard/head.c
diff -u php4/ext/standard/head.c:1.63 php4/ext/standard/head.c:1.64
--- php4/ext/standard/head.c:1.63   Thu Sep  5 10:21:55 2002
+++ php4/ext/standard/head.cTue Sep 17 08:37:26 2002
@@ -15,7 +15,7 @@
| Author: Rasmus Lerdorf [EMAIL PROTECTED]|
+--+
  */
-/* $Id: head.c,v 1.63 2002/09/05 14:21:55 hyanantha Exp $ */
+/* $Id: head.c,v 1.64 2002/09/17 12:37:26 hholzgra Exp $ */
 
 #include stdio.h
 
@@ -161,13 +161,24 @@
 /* }}} */
 
 
-/* {{{ proto int headers_sent(void)
+/* {{{ proto bool headers_sent([string $file [, int $line]])
Returns true if headers have already been sent, false otherwise */
 PHP_FUNCTION(headers_sent)
 {
-   if (ZEND_NUM_ARGS() != 0) {
-   php_error_docref(NULL TSRMLS_CC, E_WARNING, No parameters expected, 
%d given, ZEND_NUM_ARGS());
+   zval *arg1, *arg2;
+
+   if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, |zz, arg1, arg2) == 
+FAILURE)
return;
+
+   
+   switch(ZEND_NUM_ARGS()) {
+   case 2:
+   zval_dtor(arg2);
+   ZVAL_LONG(arg2, php_get_output_start_lineno(TSRMLS_C));
+   case 1:
+   zval_dtor(arg1);
+   ZVAL_STRING(arg1, php_get_output_start_filename(TSRMLS_C), 1);
+   break;
}
 
if (SG(headers_sent)) {



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php




[PHP-CVS] cvs: php4 /ext/standard basic_functions.c

2002-09-09 Thread Anantha Kesari H Y

hyanantha   Mon Sep  9 06:12:44 2002 EDT

  Modified files:  
/php4/ext/standard  basic_functions.c 
  Log:
  NetWare related changes/modifications
  
  
Index: php4/ext/standard/basic_functions.c
diff -u php4/ext/standard/basic_functions.c:1.502 
php4/ext/standard/basic_functions.c:1.503
--- php4/ext/standard/basic_functions.c:1.502   Sun Sep  8 12:45:28 2002
+++ php4/ext/standard/basic_functions.c Mon Sep  9 06:12:44 2002
 -17,7 +17,7 
+--+
  */
 
-/* $Id: basic_functions.c,v 1.502 2002/09/08 16:45:28 sesser Exp $ */
+/* $Id: basic_functions.c,v 1.503 2002/09/09 10:12:44 hyanantha Exp $ */
 
 #include php.h
 #include php_streams.h
 -456,7 +456,6 
PHP_FE(cosh,   
 NULL)
PHP_FE(tanh,   
 NULL)
 
-/*#ifndef PHP_WIN32*/
 #if !defined(PHP_WIN32)  !defined(NETWARE)
PHP_FE(asinh,  
 NULL)
PHP_FE(acosh,  
 NULL)



-- 
PHP CVS Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php