cvs: php4 /ext/ncurses ncurses.c ncurses_fe.c ncurses_functions.c php_ncurses_fe.h

From: Date: Tue, 25 Dec 2001 23:30:55 +0000
Subject: cvs: php4 /ext/ncurses ncurses.c ncurses_fe.c ncurses_functions.c php_ncurses_fe.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-8818@lists.php.net to get a copy of this message
georg Tue Dec 25 18:30:55 2001 EDT Modified files: /php4/ext/ncurses ncurses_functions.c ncurses.c ncurses_fe.c php_ncurses_fe.h Log: activated ncurses_instr New functions: ncurses_longname, ncurses_termname, ncurses_mousemask

Index: php4/ext/ncurses/ncurses_functions.c diff -u php4/ext/ncurses/ncurses_functions.c:1.11 php4/ext/ncurses/ncurses_functions.c:1.12 --- php4/ext/ncurses/ncurses_functions.c:1.11 Tue Dec 25 08:34:06 2001 +++ php4/ext/ncurses/ncurses_functions.c Tue Dec 25 18:30:55 2001 @@ -13,7 +13,7 @@ | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Hartmut Holzgraefe <hartmut@six.de> | - | | + | Georg Richter <georg.richter@php-ev.de> | +----------------------------------------------------------------------+ */ @@ -193,7 +193,7 @@ /* }}} */ /* {{{ proto int ncurses_baudrate() - Return baudrate of terminal */ + Returns baudrate of terminal */ PHP_FUNCTION(ncurses_baudrate) { RETURN_LONG(baudrate()); @@ -305,7 +305,7 @@ /* }}} */ /* {{{ proto string ncurses_erasechar() - Return current erase character */ + Returns current erase character */ PHP_FUNCTION(ncurses_erasechar) { char temp[2]; @@ -379,7 +379,7 @@ /* }}} */ /* {{{ proto string ncurses_killchar() - Return current line kill character */ + Returns current line kill character */ PHP_FUNCTION(ncurses_killchar) { char temp[2]; @@ -456,7 +456,7 @@ /* }}} */ /* {{{ proto bool ncurses_termattrs() - Return a logical OR of all attribute flags supported by terminal */ + Returns a logical OR of all attribute flags supported by terminal */ PHP_FUNCTION(ncurses_termattrs) { RETURN_LONG(termattrs()); @@ -1170,7 +1170,7 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lls",&y,&x)==FAILURE) { return; } - + RETURN_LONG(mvinch(y,x)); } /* }}} */ @@ -1185,28 +1185,36 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",&str,&str_len)==FAILURE) { return; } - + RETURN_LONG(insstr(str)); } /* }}} */ -#if 0 -/* TODO return by reference */ + /* {{{ proto int ncurses_instr(string buffer) - Read string from terminal screen */ + Reads string from terminal screen */ PHP_FUNCTION(ncurses_instr) { + ulong retval; + zval **param; char *str; - int str_len; - if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s",&str,&str_len)==FAILURE) { - return; + if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &param) == FAILURE ){ + WRONG_PARAM_COUNT; } - - RETURN_LONG(instr(str)); + + convert_to_string_ex(param); + + str = (char *)emalloc(COLS + 1); + retval = instr(str); + + ZVAL_STRING(*param, str, strlen(str)); + efree(str); + + RETURN_LONG(retval); } /* }}} */ -#endif + /* {{{ proto int ncurses_mvhline(int y, int x, int attrchar, int n) Set new position and draw a horizontal line using an attributed character and max. n characters long */ @@ -1217,7 +1225,7 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll",&i1,&i2,&i3,&i4)==FAILURE) { return; } - + RETURN_LONG(mvhline(i1,i2,i3,i4)); } /* }}} */ @@ -1336,7 +1344,7 @@ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll",&i1,&i2)==FAILURE) { return; } - + RETURN_LONG(vline(i1,i2)); } /* }}} */ @@ -1391,6 +1399,51 @@ FETCH_WINRES(w,handle); RETURN_LONG(wrefresh(*w)); +} +/* }}} */ + +/* {{{ proto string ncurses_termname() + returns terminal name */ +PHP_FUNCTION(ncurses_termname) +{ + char temp[15]; + + strcpy (temp, termname()); + RETURN_STRINGL (temp, strlen(temp), 1); +} +/* }}} */ + +/* {{{ proto string ncurses_longname() + returns terminal description */ +PHP_FUNCTION(ncurses_longname) +{ + char temp[128]; + + strcpy (temp, longname()); + RETURN_STRINGL (temp, strlen(temp), 1); +} +/* }}} */ + +/* {{{ proto int ncurses_mousemask() + returns and sets mouse options */ +PHP_FUNCTION(ncurses_mousemask) +{ + ulong oldmask; + ulong retval; + zval **param, **newmask; + + if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &newmask, &param) == FAILURE ){ + WRONG_PARAM_COUNT; + } + + convert_to_long_ex(newmask); + + retval = mousemask(Z_LVAL_PP(newmask), &oldmask); + + Z_TYPE_PP(param) = IS_LONG; + Z_LVAL_PP(param) = oldmask; + + RETURN_LONG(retval); } /* }}} */ Index: php4/ext/ncurses/ncurses.c diff -u php4/ext/ncurses/ncurses.c:1.12 php4/ext/ncurses/ncurses.c:1.13 --- php4/ext/ncurses/ncurses.c:1.12 Sat Dec 15 09:20:41 2001 +++ php4/ext/ncurses/ncurses.c Tue Dec 25 18:30:55 2001 @@ -96,6 +96,34 @@ PHP_NCURSES_CONST(KEY_RIGHT); PHP_NCURSES_CONST(KEY_BACKSPACE); + /* mouse constants */ + PHP_NCURSES_CONST(BUTTON1_PRESSED); + PHP_NCURSES_CONST(BUTTON1_RELEASED); + PHP_NCURSES_CONST(BUTTON1_CLICKED); + PHP_NCURSES_CONST(BUTTON1_DOUBLE_CLICKED); + PHP_NCURSES_CONST(BUTTON1_TRIPLE_CLICKED); + PHP_NCURSES_CONST(BUTTON2_PRESSED); + PHP_NCURSES_CONST(BUTTON2_RELEASED); + PHP_NCURSES_CONST(BUTTON2_CLICKED); + PHP_NCURSES_CONST(BUTTON2_DOUBLE_CLICKED); + PHP_NCURSES_CONST(BUTTON2_TRIPLE_CLICKED); + PHP_NCURSES_CONST(BUTTON3_PRESSED); + PHP_NCURSES_CONST(BUTTON3_RELEASED); + PHP_NCURSES_CONST(BUTTON3_CLICKED); + PHP_NCURSES_CONST(BUTTON3_DOUBLE_CLICKED); + PHP_NCURSES_CONST(BUTTON3_TRIPLE_CLICKED); + PHP_NCURSES_CONST(BUTTON4_PRESSED); + PHP_NCURSES_CONST(BUTTON4_RELEASED); + PHP_NCURSES_CONST(BUTTON4_CLICKED); + PHP_NCURSES_CONST(BUTTON4_DOUBLE_CLICKED); + PHP_NCURSES_CONST(BUTTON4_TRIPLE_CLICKED); + PHP_NCURSES_CONST(BUTTON_SHIFT); + PHP_NCURSES_CONST(BUTTON_CTRL); + PHP_NCURSES_CONST(BUTTON_ALT); + PHP_NCURSES_CONST(ALL_MOUSE_EVENTS); + PHP_NCURSES_CONST(REPORT_MOUSE_POSITION); + + le_ncurses = zend_register_list_destructors_ex(ncurses_destruct, NULL, "ncurses_handle", module_number); return SUCCESS; Index: php4/ext/ncurses/ncurses_fe.c diff -u php4/ext/ncurses/ncurses_fe.c:1.9 php4/ext/ncurses/ncurses_fe.c:1.10 --- php4/ext/ncurses/ncurses_fe.c:1.9 Sat Dec 15 09:20:41 2001 +++ php4/ext/ncurses/ncurses_fe.c Tue Dec 25 18:30:55 2001 @@ -13,7 +13,7 @@ | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Hartmut Holzgraefe <hartmut@six.de> | - | | + | Georg Richter <georg.richter@php-ev.de | +----------------------------------------------------------------------+ */ @@ -25,6 +25,8 @@ #include "php_ini.h" #include "php_ncurses.h" +static unsigned char second_args_force_ref[] = {2, BYREF_NONE, BYREF_FORCE}; +static unsigned char first_args_force_ref[] = {1, BYREF_FORCE}; /* ncurses_functions[] * * Every user visible function must have an entry in ncurses_functions[]. @@ -132,11 +134,7 @@ PHP_FE(ncurses_mvinch, NULL) PHP_FE(ncurses_mvwaddstr, NULL) PHP_FE(ncurses_insstr, NULL) - -#if 0 - PHP_FE(ncurses_instr, NULL) -#endif - + PHP_FE(ncurses_instr, first_args_force_ref) PHP_FE(ncurses_mvhline, NULL) PHP_FE(ncurses_mvcur, NULL) PHP_FE(ncurses_init_color, NULL) @@ -146,6 +144,9 @@ PHP_FE(ncurses_hline, NULL) PHP_FE(ncurses_vline, NULL) PHP_FE(ncurses_keyok, NULL) + PHP_FE(ncurses_termname, NULL) + PHP_FE(ncurses_longname, NULL) + PHP_FE(ncurses_mousemask, second_args_force_ref) {NULL, NULL, NULL} /* Must be the last line in ncurses_functions[] */ }; Index: php4/ext/ncurses/php_ncurses_fe.h diff -u php4/ext/ncurses/php_ncurses_fe.h:1.9 php4/ext/ncurses/php_ncurses_fe.h:1.10 --- php4/ext/ncurses/php_ncurses_fe.h:1.9 Sat Dec 15 09:20:41 2001 +++ php4/ext/ncurses/php_ncurses_fe.h Tue Dec 25 18:30:55 2001 @@ -13,7 +13,7 @@ | license@php.net so we can mail you a copy immediately. | +----------------------------------------------------------------------+ | Authors: Hartmut Holzgraefe <hartmut@six.de> | - | | + | Georg Richter <georg.richter@php-ev.de> | +----------------------------------------------------------------------+ */ @@ -122,11 +122,7 @@ PHP_FUNCTION(ncurses_mvinch); PHP_FUNCTION(ncurses_mvwaddstr); PHP_FUNCTION(ncurses_insstr); - -#if 0 PHP_FUNCTION(ncurses_instr); -#endif - PHP_FUNCTION(ncurses_mvhline); PHP_FUNCTION(ncurses_mvcur); PHP_FUNCTION(ncurses_init_color); @@ -136,6 +132,9 @@ PHP_FUNCTION(ncurses_hline); PHP_FUNCTION(ncurses_vline); PHP_FUNCTION(ncurses_keyok); +PHP_FUNCTION(ncurses_termname); +PHP_FUNCTION(ncurses_longname); +PHP_FUNCTION(ncurses_mousemask); #endif /*
« previous php.cvs (#8818) next »