]> granicus.if.org Git - php/commitdiff
MFH
authorMarcus Boerger <helly@php.net>
Fri, 20 Dec 2002 16:37:44 +0000 (16:37 +0000)
committerMarcus Boerger <helly@php.net>
Fri, 20 Dec 2002 16:37:44 +0000 (16:37 +0000)
ext/standard/basic_functions.c
ext/standard/uniqid.c
ext/standard/uniqid.h

index 154af12f621afa71bfea342b5ac7da3a7551a23c..76d0e0279f1d97c2c7ca33f236ceeeec76eaf9b0 100644 (file)
@@ -523,7 +523,10 @@ function_entry basic_functions[] = {
        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 feff29949c2a73d9751414612fdf91c3e5a60173..7ab0ece36efd3ed9ef32515c1ba5e683e7911561 100644 (file)
 
 /* {{{ 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 @@ PHP_FUNCTION(uniqid)
 
        /* 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,16 +87,10 @@ PHP_FUNCTION(uniqid)
        }
 
        RETURN_STRING(uniqid, 1);
-#endif
 }
+#endif
 /* }}} */
 
-function_entry uniqid_functions[] = {
-       PHP_FE(uniqid, NULL)
-       {NULL, NULL, NULL}
-};
-
-
 /*
  * Local variables:
  * tab-width: 4
index 352a75ff82a46f1aff3a994008a4512c56ad7484..65e1f046c4fbbbc1e4c3955be029dc4788a50770 100644 (file)
@@ -21,6 +21,8 @@
 #ifndef UNIQID_H
 #define UNIQID_H
 
+#ifdef HAVE_GETTIMEOFDAY
 PHP_FUNCTION(uniqid);
+#endif
 
 #endif /* UNIQID_H */