summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorMoriyoshi Koizumi <moriyoshi@php.net>2002-12-22 19:03:14 +0000
committerMoriyoshi Koizumi <moriyoshi@php.net>2002-12-22 19:03:14 +0000
commitc16bb3d7c93bcfd50eb05356f472453f7931dfb0 (patch)
tree8d9cbe77b0840c8f21de39c02de8b4bffbe0dd47
parentaaba243f4101cddd0194ec2abad314f4eef9b2a0 (diff)
downloadphp-git-c16bb3d7c93bcfd50eb05356f472453f7931dfb0.tar.gz
MFH
-rw-r--r--ext/ncurses/ncurses.c8
-rw-r--r--ext/ncurses/ncurses_functions.c9
-rw-r--r--ext/ncurses/php_ncurses.h1
3 files changed, 17 insertions, 1 deletions
diff --git a/ext/ncurses/ncurses.c b/ext/ncurses/ncurses.c
index 59309da5cf..31c992c550 100644
--- a/ext/ncurses/ncurses.c
+++ b/ext/ncurses/ncurses.c
@@ -84,11 +84,19 @@ PHP_INI_END()
#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);
diff --git a/ext/ncurses/ncurses_functions.c b/ext/ncurses/ncurses_functions.c
index 5c3e7f60c4..37c485ea76 100644
--- a/ext/ncurses/ncurses_functions.c
+++ b/ext/ncurses/ncurses_functions.c
@@ -131,6 +131,8 @@ PHP_FUNCTION(ncurses_init)
(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 @@ PHP_FUNCTION(ncurses_refresh)
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;
+ }
}
/* }}} */
diff --git a/ext/ncurses/php_ncurses.h b/ext/ncurses/php_ncurses.h
index 3cf60cf72e..d29ebc4f90 100644
--- a/ext/ncurses/php_ncurses.h
+++ b/ext/ncurses/php_ncurses.h
@@ -48,6 +48,7 @@ PHP_RSHUTDOWN_FUNCTION(ncurses);
PHP_MINFO_FUNCTION(ncurses);
ZEND_BEGIN_MODULE_GLOBALS(ncurses)
+ int is_initialised;
int registered_constants;
ZEND_END_MODULE_GLOBALS(ncurses)