moriyoshi               Sun Dec 22 14:03:15 2002 EDT

  Modified files:              (Branch: PHP_4_3)
    /php4/ext/ncurses   ncurses.c ncurses_functions.c php_ncurses.h 
  Log:
  MFH
  
  
Index: php4/ext/ncurses/ncurses.c
diff -u php4/ext/ncurses/ncurses.c:1.18 php4/ext/ncurses/ncurses.c:1.18.2.1
--- php4/ext/ncurses/ncurses.c:1.18     Fri Sep 27 18:33:14 2002
+++ php4/ext/ncurses/ncurses.c  Sun Dec 22 14:03:14 2002
@@ -84,11 +84,19 @@
 #define PHP_NCURSES_CONST(x)  REGISTER_LONG_CONSTANT("NCURSES_"#x, x, CONST_CS | 
CONST_PERSISTENT)
 #define PHP_NCURSES_FKEY_CONST(x)  REGISTER_LONG_CONSTANT("NCURSES_KEY_F"#x, KEY_F0 + 
x, CONST_CS | CONST_PERSISTENT)
 
+/* {{{ php_ncurses_globals_ctor */
+static void php_ncurses_globals_ctor(zend_ncurses_globals *pglobals)
+{
+       pglobals->registered_constants = 0;
+       pglobals->is_initialised = 0;
+}
+/* }}} */
 
 /* {{{ PHP_MINIT_FUNCTION
  */
 PHP_MINIT_FUNCTION(ncurses)
 {
+       ZEND_INIT_MODULE_GLOBALS(ncurses, php_ncurses_globals_ctor, NULL);
     /* color constants */
     PHP_NCURSES_CONST(COLOR_BLACK);
     PHP_NCURSES_CONST(COLOR_RED);
Index: php4/ext/ncurses/ncurses_functions.c
diff -u php4/ext/ncurses/ncurses_functions.c:1.26 
php4/ext/ncurses/ncurses_functions.c:1.26.2.1
--- php4/ext/ncurses/ncurses_functions.c:1.26   Tue Oct 29 21:54:48 2002
+++ php4/ext/ncurses/ncurses_functions.c        Sun Dec 22 14:03:14 2002
@@ -131,6 +131,8 @@
        (void) nonl();         /* tell curses not to do NL->CR/NL on output */
        (void) cbreak();       /* take input chars one at a time, no wait for \n */
 
+       NCURSES_G(is_initialised) = 1;
+
        if (!NCURSES_G(registered_constants)) {
                zend_constant c;
                
@@ -315,7 +317,12 @@
    Starts using colors */
 PHP_FUNCTION(ncurses_start_color)
 {
-       RETURN_LONG(start_color());
+       if (NCURSES_G(is_initialised)) {
+               RETURN_LONG(start_color());
+       } else {
+               php_error(E_WARNING, "ncurses library is not initialised by 
+ncurses_init().");
+               RETURN_FALSE;
+       }
 }
 /* }}} */
 
Index: php4/ext/ncurses/php_ncurses.h
diff -u php4/ext/ncurses/php_ncurses.h:1.8 php4/ext/ncurses/php_ncurses.h:1.8.2.1
--- php4/ext/ncurses/php_ncurses.h:1.8  Mon Oct 21 10:56:42 2002
+++ php4/ext/ncurses/php_ncurses.h      Sun Dec 22 14:03:14 2002
@@ -48,6 +48,7 @@
 PHP_MINFO_FUNCTION(ncurses);
 
 ZEND_BEGIN_MODULE_GLOBALS(ncurses)
+       int   is_initialised;
        int       registered_constants;
 ZEND_END_MODULE_GLOBALS(ncurses)
 



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

Reply via email to