cvs: php4 /ext/standard basic_functions.c uniqid.c uniqid.h

From: Date: Fri, 20 Dec 2002 16:34:42 +0000
Subject: cvs: php4 /ext/standard basic_functions.c uniqid.c uniqid.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-17298@lists.php.net to get a copy of this message
helly Fri Dec 20 11:34:42 2002 EDT Modified files: /php4/ext/standard basic_functions.c uniqid.c uniqid.h Log: -disable uniqid() when required lib functions not available -emit an error when uniqid() will fail -make more_entropy parameter default to true for CYGWIN Index: php4/ext/standard/basic_functions.c diff -u php4/ext/standard/basic_functions.c:1.548 php4/ext/standard/basic_functions.c:1.549 --- php4/ext/standard/basic_functions.c:1.548 Thu Dec 12 13:50:26 2002 +++ php4/ext/standard/basic_functions.c Fri Dec 20 11:34:41 2002 @@ -17,7 +17,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: basic_functions.c,v 1.548 2002/12/12 18:50:26 msopacua Exp $ */ +/* $Id: basic_functions.c,v 1.549 2002/12/20 16:34:41 helly Exp $ */ #include "php.h" #include "php_streams.h" @@ -515,7 +515,10 @@ PHP_FE(getrusage, NULL) #endif +#ifdef HAVE_GETTIMEOFDAY PHP_FE(uniqid, NULL) +#endif + PHP_FE(quoted_printable_decode, NULL) PHP_FE(convert_cyr_string, NULL) PHP_FE(get_current_user, NULL) Index: php4/ext/standard/uniqid.c diff -u php4/ext/standard/uniqid.c:1.32 php4/ext/standard/uniqid.c:1.33 --- php4/ext/standard/uniqid.c:1.32 Thu Dec 5 15:59:49 2002 +++ php4/ext/standard/uniqid.c Fri Dec 20 11:34:41 2002 @@ -16,7 +16,7 @@ +----------------------------------------------------------------------+ */ -/* $Id: uniqid.c,v 1.32 2002/12/05 20:59:49 helly Exp $ */ +/* $Id: uniqid.c,v 1.33 2002/12/20 16:34:41 helly Exp $ */ #include "php.h" @@ -40,11 +40,15 @@ /* {{{ proto string uniqid(string prefix [, bool more_entropy]) Generates a unique ID */ +#ifdef HAVE_GETTIMEOFDAY PHP_FUNCTION(uniqid) { -#ifdef HAVE_GETTIMEOFDAY char *prefix; +#if defined(__CYGWIN__) + zend_bool more_entropy = 1; +#else zend_bool more_entropy = 0; +#endif char uniqid[138]; int sec, usec, argc, prefix_len; struct timeval tv; @@ -57,17 +61,21 @@ /* Do some bounds checking since we are using a char array. */ if (prefix_len > 114) { - php_error_docref(NULL TSRMLS_CC, E_WARNING, "The prefix to uniqid should not be more than 114 characters."); + php_error_docref(NULL TSRMLS_CC, E_ERROR, "The prefix to uniqid should not be more than 114 characters."); return; } #if HAVE_USLEEP && !defined(PHP_WIN32) if (!more_entropy) { +#if defined(__CYGWIN__) + php_error_docref(NULL TSRMLS_CC, E_ERROR, "You must use 'more entropy' under CYGWIN."); + return; +#endif usleep(1); } #endif gettimeofday((struct timeval *) &tv, (struct timezone *) NULL); sec = (int) tv.tv_sec; - usec = (int) (tv.tv_usec % 1000000); + usec = (int) (tv.tv_usec % 0x100000); /* The max value usec can have is 0xF423F, so we use only five hex * digits for usecs. @@ -79,15 +87,9 @@ } RETURN_STRING(uniqid, 1); -#endif } +#endif /* }}} */ - -function_entry uniqid_functions[] = { - PHP_FE(uniqid, NULL) - {NULL, NULL, NULL} -}; - /* * Local variables: Index: php4/ext/standard/uniqid.h diff -u php4/ext/standard/uniqid.h:1.7 php4/ext/standard/uniqid.h:1.8 --- php4/ext/standard/uniqid.h:1.7 Thu Feb 28 03:26:49 2002 +++ php4/ext/standard/uniqid.h Fri Dec 20 11:34:42 2002 @@ -16,11 +16,13 @@ +----------------------------------------------------------------------+ */ -/* $Id: uniqid.h,v 1.7 2002/02/28 08:26:49 sebastian Exp $ */ +/* $Id: uniqid.h,v 1.8 2002/12/20 16:34:42 helly Exp $ */ #ifndef UNIQID_H #define UNIQID_H +#ifdef HAVE_GETTIMEOFDAY PHP_FUNCTION(uniqid); +#endif #endif /* UNIQID_H */

« previous php.cvs (#17298) next »