PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LTP GCOV extension - code coverage report
Current view: directory - ncurses - ncurses_functions.c
Test: PHP Code Coverage
Date: 2009-11-19 Instrumented lines: 839
Code covered: 0.0 % Executed lines: 0
Legend: not executed executed

       1                 : /*
       2                 :    +----------------------------------------------------------------------+
       3                 :    | PHP Version 5                                                        |
       4                 :    +----------------------------------------------------------------------+
       5                 :    | Copyright (c) 1997-2009 The PHP Group                                |
       6                 :    +----------------------------------------------------------------------+
       7                 :    | This source file is subject to version 3.01 of the PHP license,      |
       8                 :    | that is bundled with this package in the file LICENSE, and is        |
       9                 :    | available through the world-wide-web at the following url:           |
      10                 :    | http://www.php.net/license/3_01.txt                                  |
      11                 :    | If you did not receive a copy of the PHP license and are unable to   |
      12                 :    | obtain it through the world-wide-web, please send a note to          |
      13                 :    | license@php.net so we can mail you a copy immediately.               |
      14                 :    +----------------------------------------------------------------------+
      15                 :    | Authors: Hartmut Holzgraefe <hholzgra@php.net>                       |
      16                 :    |          Georg Richter <georg.richter@php-ev.de>                     |
      17                 :    +----------------------------------------------------------------------+
      18                 : */
      19                 : 
      20                 : #ifdef HAVE_CONFIG_H
      21                 : #include "config.h"
      22                 : #endif
      23                 : 
      24                 : #include "php.h"
      25                 : #include "php_ini.h"
      26                 : #include "php_ncurses.h"
      27                 : 
      28                 : #define FETCH_WINRES(r, z)  ZEND_FETCH_RESOURCE(r, WINDOW **, z, -1, "ncurses_window", le_ncurses_windows)
      29                 : #if HAVE_NCURSES_PANEL
      30                 : # define FETCH_PANEL(r, z)  ZEND_FETCH_RESOURCE(r, PANEL **, z, -1, "ncurses_panel", le_ncurses_panels)
      31                 : #endif
      32                 : 
      33                 : #define IS_NCURSES_INITIALIZED() \
      34                 :                 if (!NCURSES_G(registered_constants)) { \
      35                 :                         php_error_docref(NULL TSRMLS_CC, E_WARNING, "You must initialize ncruses via ncurses_init(), before calling any ncurses functions."); \
      36                 :                         RETURN_FALSE; \
      37                 :                 }
      38                 : 
      39                 : /* {{{ proto int ncurses_addch(int ch)
      40                 :    Adds character at current position and advance cursor */
      41                 : PHP_FUNCTION(ncurses_addch)
      42               0 : {
      43                 :         long ch;
      44                 : 
      45               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &ch) == FAILURE) {
      46               0 :                 return;
      47                 :         }
      48                 : 
      49               0 :         IS_NCURSES_INITIALIZED();
      50               0 :         RETURN_LONG(addch(ch));
      51                 : }
      52                 : /* }}} */
      53                 : 
      54                 : /* {{{ proto int ncurses_waddch(resource window, int ch)
      55                 :    Adds character at current position in a window and advance cursor */
      56                 : PHP_FUNCTION(ncurses_waddch)
      57               0 : {
      58                 :         long ch;
      59                 :         zval *handle;
      60                 :         WINDOW **win;
      61                 : 
      62               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &handle, &ch) == FAILURE) {
      63               0 :                 return;
      64                 :         }
      65                 : 
      66               0 :         FETCH_WINRES(win, &handle);
      67                 : 
      68               0 :         RETURN_LONG(waddch(*win, ch));
      69                 : }
      70                 : /* }}} */
      71                 : 
      72                 : #ifdef HAVE_NCURSES_COLOR_SET
      73                 : /* {{{ proto int ncurses_color_set(int pair)
      74                 :    Sets fore- and background color */
      75                 : PHP_FUNCTION(ncurses_color_set)
      76               0 : {
      77                 :         long pair;
      78               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &pair) == FAILURE) {
      79               0 :                 return;
      80                 :         }
      81               0 :         IS_NCURSES_INITIALIZED();
      82               0 :         RETURN_LONG(color_set(pair,NULL));
      83                 : }
      84                 : /* }}} */
      85                 : #endif
      86                 : 
      87                 : /* {{{ proto bool ncurses_delwin(resource window)
      88                 :    Deletes a ncurses window */
      89                 : PHP_FUNCTION(ncurses_delwin)
      90               0 : {
      91                 :         zval *handle;
      92                 :         WINDOW **w;
      93                 : 
      94               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &handle) == FAILURE) {
      95               0 :                 return;
      96                 :         }
      97                 : 
      98               0 :         FETCH_WINRES(w, &handle);
      99                 : 
     100               0 :         zend_list_delete(Z_LVAL_P(handle));
     101               0 :         RETURN_TRUE;
     102                 : }
     103                 : /* }}} */
     104                 : 
     105                 : /* {{{ proto int ncurses_end(void)
     106                 :    Stops using ncurses, clean up the screen */
     107                 : PHP_FUNCTION(ncurses_end)
     108               0 : {
     109               0 :         IS_NCURSES_INITIALIZED();
     110               0 :         RETURN_LONG(endwin());             /* endialize the curses library */
     111                 : }
     112                 : /* }}} */
     113                 : 
     114                 : /* {{{ proto int ncurses_getch(void)
     115                 :    Reads a character from keyboard */
     116                 : PHP_FUNCTION(ncurses_getch)
     117               0 : {
     118               0 :         IS_NCURSES_INITIALIZED();
     119               0 :         RETURN_LONG(getch());
     120                 : }
     121                 : /* }}} */
     122                 : 
     123                 : /* {{{ proto bool ncurses_has_colors(void)
     124                 :    Checks if terminal has colors */
     125                 : PHP_FUNCTION(ncurses_has_colors)
     126               0 : {
     127               0 :         IS_NCURSES_INITIALIZED();
     128               0 :         RETURN_BOOL(has_colors());
     129                 : }
     130                 : /* }}} */
     131                 : 
     132                 : /* {{{ proto int ncurses_init(void)
     133                 :    Initializes ncurses */
     134                 : PHP_FUNCTION(ncurses_init)
     135               0 : {
     136               0 :         initscr();             /* initialize the curses library */
     137               0 :         keypad(stdscr, TRUE);  /* enable keyboard mapping */
     138               0 :         (void) nonl();         /* tell curses not to do NL->CR/NL on output */
     139               0 :         (void) cbreak();       /* take input chars one at a time, no wait for \n */
     140                 : 
     141               0 :         if (!NCURSES_G(registered_constants)) {
     142                 :                 zend_constant c;
     143                 :                 
     144               0 :                 WINDOW **pscr = (WINDOW**)emalloc(sizeof(WINDOW *));
     145                 :                 zval *zscr;
     146                 : 
     147               0 :                 *pscr = stdscr;
     148               0 :                 MAKE_STD_ZVAL(zscr);
     149               0 :                 ZEND_REGISTER_RESOURCE(zscr, pscr, le_ncurses_windows);
     150               0 :                 c.value = *zscr;
     151               0 :                 zval_copy_ctor(&c.value);
     152               0 :                 c.flags = CONST_CS;
     153               0 :                 c.name = zend_strndup(ZEND_STRL("STDSCR"));
     154               0 :                 c.name_len = sizeof("STDSCR");
     155               0 :                 zend_register_constant(&c TSRMLS_CC);
     156                 : 
     157                 :                 /* we need this "interesting" arrangement because the
     158                 :                  * underlying values of the ACS_XXX defines are not
     159                 :                  * initialized until after ncurses has been initialized */
     160                 :                 
     161                 : #define PHP_NCURSES_DEF_CONST(x)    \
     162                 :                 ZVAL_LONG(zscr, x);         \
     163                 :                 c.value = *zscr;            \
     164                 :                 zval_copy_ctor(&c.value);   \
     165                 :                 c.flags = CONST_CS;         \
     166                 :                 c.name = zend_strndup(ZEND_STRL("NCURSES_" #x)); \
     167                 :                 c.name_len = sizeof("NCURSES_" #x);                           \
     168                 :                 zend_register_constant(&c TSRMLS_CC)
     169                 :                 
     170               0 :                 PHP_NCURSES_DEF_CONST(ACS_ULCORNER);
     171               0 :                 PHP_NCURSES_DEF_CONST(ACS_LLCORNER);
     172               0 :                 PHP_NCURSES_DEF_CONST(ACS_URCORNER);
     173               0 :                 PHP_NCURSES_DEF_CONST(ACS_LRCORNER);
     174               0 :                 PHP_NCURSES_DEF_CONST(ACS_LTEE);
     175               0 :                 PHP_NCURSES_DEF_CONST(ACS_RTEE);
     176               0 :                 PHP_NCURSES_DEF_CONST(ACS_BTEE);
     177               0 :                 PHP_NCURSES_DEF_CONST(ACS_TTEE);
     178               0 :                 PHP_NCURSES_DEF_CONST(ACS_HLINE);
     179               0 :                 PHP_NCURSES_DEF_CONST(ACS_VLINE);
     180               0 :                 PHP_NCURSES_DEF_CONST(ACS_PLUS);
     181               0 :                 PHP_NCURSES_DEF_CONST(ACS_S1);
     182               0 :                 PHP_NCURSES_DEF_CONST(ACS_S9);
     183               0 :                 PHP_NCURSES_DEF_CONST(ACS_DIAMOND);
     184               0 :                 PHP_NCURSES_DEF_CONST(ACS_CKBOARD);
     185               0 :                 PHP_NCURSES_DEF_CONST(ACS_DEGREE);
     186               0 :                 PHP_NCURSES_DEF_CONST(ACS_PLMINUS);
     187               0 :                 PHP_NCURSES_DEF_CONST(ACS_BULLET);
     188               0 :                 PHP_NCURSES_DEF_CONST(ACS_LARROW);
     189               0 :                 PHP_NCURSES_DEF_CONST(ACS_RARROW);
     190               0 :                 PHP_NCURSES_DEF_CONST(ACS_DARROW);
     191               0 :                 PHP_NCURSES_DEF_CONST(ACS_UARROW);
     192               0 :                 PHP_NCURSES_DEF_CONST(ACS_BOARD);
     193               0 :                 PHP_NCURSES_DEF_CONST(ACS_LANTERN);
     194               0 :                 PHP_NCURSES_DEF_CONST(ACS_BLOCK);
     195                 :                 
     196               0 :                 FREE_ZVAL(zscr);
     197               0 :                 NCURSES_G(registered_constants) = 1;
     198                 :         }
     199               0 : }
     200                 : /* }}} */
     201                 : 
     202                 : /* {{{ proto int ncurses_init_pair(int pair, int fg, int bg)
     203                 :    Allocates a color pair */
     204                 : PHP_FUNCTION(ncurses_init_pair)
     205               0 : {
     206                 :         long pair, fg, bg;
     207                 : 
     208               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &pair, &fg, &bg) == FAILURE) {
     209               0 :                 return;
     210                 :         }
     211               0 :         IS_NCURSES_INITIALIZED();
     212               0 :         RETURN_LONG(init_pair(pair,fg,bg));
     213                 : }
     214                 : /* }}} */
     215                 : 
     216                 : /* {{{ proto int ncurses_move(int y, int x)
     217                 :    Moves output position */
     218                 : PHP_FUNCTION(ncurses_move)
     219               0 : {
     220                 :         long x, y;
     221               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &y, &x) == FAILURE) {
     222               0 :                 return;
     223                 :         }
     224               0 :         IS_NCURSES_INITIALIZED();
     225               0 :         RETURN_LONG(move(y,x));
     226                 : }
     227                 : /* }}} */
     228                 : 
     229                 : /* {{{ proto resource ncurses_newpad(int rows, int cols)
     230                 :    Creates a new pad (window) */
     231                 : PHP_FUNCTION(ncurses_newpad)
     232               0 : {
     233                 :         long rows,cols;
     234                 :         WINDOW **pwin;
     235                 : 
     236               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &rows, &cols) == FAILURE) {
     237               0 :                 return;
     238                 :         }
     239               0 :         IS_NCURSES_INITIALIZED();
     240                 :         
     241               0 :         pwin = (WINDOW **)emalloc(sizeof(WINDOW *));
     242               0 :         *pwin = newpad(rows,cols);
     243                 : 
     244               0 :         if(!*pwin) {
     245               0 :                 efree(pwin);
     246               0 :                 RETURN_FALSE;
     247                 :         }
     248                 : 
     249               0 :         ZEND_REGISTER_RESOURCE(return_value, pwin, le_ncurses_windows);
     250                 : 
     251                 : }
     252                 : /* }}} */
     253                 : 
     254                 : /* {{{ proto int ncurses_prefresh(resource pad, int pminrow, int pmincol, int sminrow, int smincol, int smaxrow, int smaxcol)
     255                 :    Copys a region from a pad into the virtual screen */
     256                 : PHP_FUNCTION(ncurses_prefresh)
     257               0 : {
     258                 :         WINDOW **pwin;
     259                 :         zval *phandle;
     260                 :         long pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol;
     261                 : 
     262               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rllllll", &phandle, &pminrow,
     263                 :                                 &pmincol, &sminrow, &smincol, &smaxrow, &smaxcol) == FAILURE) {
     264               0 :                 return;
     265                 :         }
     266                 : 
     267               0 :         FETCH_WINRES(pwin, &phandle);
     268                 : 
     269               0 :         RETURN_LONG(prefresh(*pwin, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol));
     270                 : }
     271                 : /* }}} */
     272                 : 
     273                 : /* {{{ proto int ncurses_pnoutrefresh(resource pad, int pminrow, int pmincol, int sminrow, int smincol, int smaxrow, int smaxcol)
     274                 :    Copys a region from a pad into the virtual screen */
     275                 : PHP_FUNCTION(ncurses_pnoutrefresh)
     276               0 : {
     277                 :         WINDOW **pwin;
     278                 :         zval *phandle;
     279                 :         long pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol;
     280                 : 
     281               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rllllll", &phandle, &pminrow,
     282                 :                                 &pmincol, &sminrow, &smincol, &smaxrow, &smaxcol) == FAILURE) {
     283               0 :                 return;
     284                 :         }
     285                 : 
     286               0 :         FETCH_WINRES(pwin, &phandle);
     287                 : 
     288               0 :         RETURN_LONG(pnoutrefresh(*pwin, pminrow, pmincol, sminrow, smincol, smaxrow, smaxcol));
     289                 : }
     290                 : /* }}} */
     291                 : 
     292                 : 
     293                 : 
     294                 : /* {{{ proto int ncurses_newwin(int rows, int cols, int y, int x)
     295                 :    Creates a new window */
     296                 : PHP_FUNCTION(ncurses_newwin)
     297               0 : {
     298                 :         long rows,cols,y,x;
     299                 :         WINDOW **pwin; 
     300                 : 
     301               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll", &rows, &cols, &y, &x) == FAILURE) {
     302               0 :                 return;
     303                 :         }
     304                 : 
     305               0 :         IS_NCURSES_INITIALIZED();
     306               0 :         pwin = (WINDOW **)emalloc(sizeof(WINDOW *));
     307               0 :         *pwin=newwin(rows,cols,y,x);
     308                 : 
     309               0 :         if(!*pwin) {
     310               0 :                 efree(pwin);
     311               0 :                 RETURN_FALSE;
     312                 :         }
     313                 : 
     314               0 :         ZEND_REGISTER_RESOURCE(return_value, pwin, le_ncurses_windows);
     315                 : }
     316                 : /* }}} */
     317                 : 
     318                 : /* {{{ proto int ncurses_refresh(int ch)
     319                 :    Refresh screen */
     320                 : PHP_FUNCTION(ncurses_refresh)
     321               0 : {
     322               0 :         IS_NCURSES_INITIALIZED();
     323               0 :         RETURN_LONG(refresh());
     324                 : }
     325                 : /* }}} */
     326                 : 
     327                 : /* {{{ proto int ncurses_start_color(void)
     328                 :    Starts using colors */
     329                 : PHP_FUNCTION(ncurses_start_color)
     330               0 : {
     331               0 :         IS_NCURSES_INITIALIZED();
     332               0 :         RETURN_LONG(start_color());
     333                 : }
     334                 : /* }}} */
     335                 : 
     336                 : /* {{{ proto int ncurses_standout(void)
     337                 :    Starts using 'standout' attribute */
     338                 : PHP_FUNCTION(ncurses_standout)
     339               0 : {
     340               0 :         IS_NCURSES_INITIALIZED();
     341               0 :         RETURN_LONG(standout());
     342                 : }
     343                 : /* }}} */
     344                 : 
     345                 : /* {{{ proto int ncurses_standend(void)
     346                 :    Stops using 'standout' attribute */
     347                 : PHP_FUNCTION(ncurses_standend)
     348               0 : {
     349               0 :         IS_NCURSES_INITIALIZED();
     350               0 :         RETURN_LONG(standend());
     351                 : }
     352                 : /* }}} */
     353                 : 
     354                 : /* {{{ proto int ncurses_baudrate(void)
     355                 :    Returns baudrate of terminal */
     356                 : PHP_FUNCTION(ncurses_baudrate)
     357               0 : {
     358               0 :         IS_NCURSES_INITIALIZED();
     359               0 :         RETURN_LONG(baudrate());
     360                 : }
     361                 : /* }}} */
     362                 : 
     363                 : /* {{{ proto int ncurses_beep(void)
     364                 :    Let the terminal beep */
     365                 : PHP_FUNCTION(ncurses_beep)
     366               0 : {
     367               0 :         IS_NCURSES_INITIALIZED();
     368               0 :         RETURN_LONG(beep());
     369                 : }
     370                 : /* }}} */
     371                 : 
     372                 : /* {{{ proto bool ncurses_can_change_color(void)
     373                 :    Checks if we can change terminals colors */
     374                 : PHP_FUNCTION(ncurses_can_change_color)
     375               0 : {
     376               0 :         IS_NCURSES_INITIALIZED();
     377               0 :         RETURN_LONG(can_change_color());
     378                 : }
     379                 : /* }}} */
     380                 : 
     381                 : /* {{{ proto bool ncurses_cbreak(void)
     382                 :    Switches of input buffering */
     383                 : PHP_FUNCTION(ncurses_cbreak)
     384               0 : {
     385               0 :         IS_NCURSES_INITIALIZED();
     386               0 :         RETURN_LONG(cbreak());
     387                 : }
     388                 : /* }}} */
     389                 : 
     390                 : /* {{{ proto bool ncurses_clear(void)
     391                 :    Clears screen */
     392                 : PHP_FUNCTION(ncurses_clear)
     393               0 : {
     394               0 :         IS_NCURSES_INITIALIZED();
     395               0 :         RETURN_LONG(clear());
     396                 : }
     397                 : /* }}} */
     398                 : 
     399                 : /* {{{ proto bool ncurses_clrtobot(void)
     400                 :    Clears screen from current position to bottom */
     401                 : PHP_FUNCTION(ncurses_clrtobot)
     402               0 : {
     403               0 :         IS_NCURSES_INITIALIZED();
     404               0 :         RETURN_LONG(clrtobot());
     405                 : }
     406                 : /* }}} */
     407                 : 
     408                 : /* {{{ proto bool ncurses_clrtoeol(void)
     409                 :    Clears screen from current position to end of line */
     410                 : PHP_FUNCTION(ncurses_clrtoeol)
     411               0 : {
     412               0 :         IS_NCURSES_INITIALIZED();
     413               0 :         RETURN_LONG(clrtoeol());
     414                 : }
     415                 : /* }}} */
     416                 : 
     417                 : /* {{{ proto int ncurses_reset_prog_mode(void)
     418                 :    Resets the prog mode saved by def_prog_mode */
     419                 : PHP_FUNCTION(ncurses_reset_prog_mode)
     420               0 : {
     421               0 :         IS_NCURSES_INITIALIZED();
     422               0 :         RETURN_LONG(reset_prog_mode());
     423                 : }
     424                 : /* }}} */
     425                 : 
     426                 : /* {{{ proto int ncurses_reset_shell_mode(void)
     427                 :    Resets the shell mode saved by def_shell_mode */
     428                 : PHP_FUNCTION(ncurses_reset_shell_mode)
     429               0 : {
     430               0 :         IS_NCURSES_INITIALIZED();
     431               0 :         RETURN_LONG(reset_shell_mode());
     432                 : }
     433                 : /* }}} */
     434                 : 
     435                 : /* {{{ proto int ncurses_def_prog_mode(void)
     436                 :    Saves terminals (program) mode */
     437                 : PHP_FUNCTION(ncurses_def_prog_mode)
     438               0 : {
     439               0 :         IS_NCURSES_INITIALIZED();
     440               0 :         RETURN_LONG(def_prog_mode());
     441                 : }
     442                 : /* }}} */
     443                 : 
     444                 : /* {{{ proto int ncurses_def_shell_mode(void)
     445                 :    Saves terminal (shell) mode*/
     446                 : PHP_FUNCTION(ncurses_def_shell_mode)
     447               0 : {
     448               0 :         IS_NCURSES_INITIALIZED();
     449               0 :         RETURN_LONG(def_shell_mode());
     450                 : }
     451                 : /* }}} */
     452                 : 
     453                 : /* {{{ proto int ncurses_delch(void)
     454                 :    Deletes character at current position, move rest of line left */
     455                 : PHP_FUNCTION(ncurses_delch)
     456               0 : {
     457               0 :         IS_NCURSES_INITIALIZED();
     458               0 :         RETURN_LONG(delch());
     459                 : }
     460                 : /* }}} */
     461                 : 
     462                 : /* {{{ proto int ncurses_deleteln(void)
     463                 :    Deletes line at current position, move rest of screen up */
     464                 : PHP_FUNCTION(ncurses_deleteln)
     465               0 : {
     466               0 :         IS_NCURSES_INITIALIZED();
     467               0 :         RETURN_LONG(deleteln());
     468                 : }
     469                 : /* }}} */
     470                 : 
     471                 : /* {{{ proto int ncurses_doupdate(void)
     472                 :    Writes all prepared refreshes to terminal */
     473                 : PHP_FUNCTION(ncurses_doupdate)
     474               0 : {
     475               0 :         IS_NCURSES_INITIALIZED();
     476               0 :         RETURN_LONG(doupdate());
     477                 : }
     478                 : /* }}} */
     479                 : 
     480                 : /* {{{ proto int ncurses_echo(void)
     481                 :    Activates keyboard input echo */
     482                 : PHP_FUNCTION(ncurses_echo)
     483               0 : {
     484               0 :         IS_NCURSES_INITIALIZED();
     485               0 :         RETURN_LONG(echo());
     486                 : }
     487                 : /* }}} */
     488                 : 
     489                 : /* {{{ proto int ncurses_erase(void)
     490                 :    Erases terminal screen */
     491                 : PHP_FUNCTION(ncurses_erase)
     492               0 : {
     493               0 :         IS_NCURSES_INITIALIZED();
     494               0 :         RETURN_LONG(erase());
     495                 : }
     496                 : /* }}} */
     497                 : 
     498                 : /* {{{ proto string ncurses_erasechar(void)
     499                 :    Returns current erase character */
     500                 : PHP_FUNCTION(ncurses_erasechar)
     501               0 : {
     502                 :         char temp[2];
     503                 : 
     504               0 :         IS_NCURSES_INITIALIZED();
     505               0 :         temp[0] = erasechar();
     506               0 :         temp[1] = '\0';
     507                 : 
     508               0 :         RETURN_STRINGL (temp, 1, 1);
     509                 : }
     510                 : /* }}} */
     511                 : 
     512                 : /* {{{ proto int ncurses_flash(void)
     513                 :    Flashes terminal screen (visual bell) */
     514                 : PHP_FUNCTION(ncurses_flash)
     515               0 : {
     516               0 :         IS_NCURSES_INITIALIZED();
     517               0 :         RETURN_LONG(flash());
     518                 : }
     519                 : /* }}} */
     520                 : 
     521                 : /* {{{ proto int ncurses_flushinp(void)
     522                 :    Flushes keyboard input buffer */
     523                 : PHP_FUNCTION(ncurses_flushinp)
     524               0 : {
     525               0 :         IS_NCURSES_INITIALIZED();
     526               0 :         RETURN_LONG(flushinp());
     527                 : }
     528                 : /* }}} */
     529                 : 
     530                 : /* {{{ proto int ncurses_has_ic(void)
     531                 :    Checks for insert- and delete-capabilities */
     532                 : PHP_FUNCTION(ncurses_has_ic)
     533               0 : {
     534               0 :         IS_NCURSES_INITIALIZED();
     535               0 :         RETURN_LONG(has_ic());
     536                 : }
     537                 : /* }}} */
     538                 : 
     539                 : 
     540                 : /* {{{ proto int ncurses_has_il(void)
     541                 :    Checks for line insert- and delete-capabilities */
     542                 : PHP_FUNCTION(ncurses_has_il)
     543               0 : {
     544               0 :         IS_NCURSES_INITIALIZED();
     545               0 :         RETURN_LONG(has_il());
     546                 : }
     547                 : /* }}} */
     548                 : 
     549                 : /* {{{ proto string ncurses_inch(void)
     550                 :    Gets character and attribute at current position */
     551                 : PHP_FUNCTION(ncurses_inch)
     552               0 : {
     553                 :         char temp[2];
     554                 : 
     555               0 :         IS_NCURSES_INITIALIZED();
     556               0 :         temp[0] = inch();
     557               0 :         temp[1] = '\0';
     558                 : 
     559               0 :         RETURN_STRINGL (temp, 1, 1);
     560                 : }
     561                 : /* }}} */
     562                 : 
     563                 : /* {{{ proto int ncurses_insertln(void)
     564                 :    Inserts a line, move rest of screen down */
     565                 : PHP_FUNCTION(ncurses_insertln)
     566               0 : {
     567               0 :         IS_NCURSES_INITIALIZED();
     568               0 :         RETURN_LONG(insertln());
     569                 : }
     570                 : /* }}} */
     571                 : 
     572                 : /* {{{ proto int ncurses_isendwin(void)
     573                 :    Ncurses is in endwin mode, normal screen output may be performed */
     574                 : PHP_FUNCTION(ncurses_isendwin)
     575               0 : {
     576               0 :         IS_NCURSES_INITIALIZED();
     577               0 :         RETURN_LONG(isendwin());
     578                 : }
     579                 : /* }}} */
     580                 : 
     581                 : /* {{{ proto string ncurses_killchar(void)
     582                 :    Returns current line kill character */
     583                 : PHP_FUNCTION(ncurses_killchar)
     584               0 : {
     585                 :         char temp[2];
     586                 : 
     587               0 :         IS_NCURSES_INITIALIZED();
     588               0 :         temp[0] = killchar();
     589               0 :         temp[1] = '\0';
     590                 : 
     591               0 :         RETURN_STRINGL (temp, 1, 1);
     592                 : }
     593                 : /* }}} */
     594                 : 
     595                 : /* {{{ proto int ncurses_nl(void)
     596                 :    Translates newline and carriage return / line feed */
     597                 : PHP_FUNCTION(ncurses_nl)
     598               0 : {
     599               0 :         IS_NCURSES_INITIALIZED();
     600               0 :         RETURN_LONG(nl());
     601                 : }
     602                 : /* }}} */
     603                 : 
     604                 : /* {{{ proto int ncurses_nocbreak(void)
     605                 :    Switches terminal to cooked mode */
     606                 : PHP_FUNCTION(ncurses_nocbreak)
     607               0 : {
     608               0 :         IS_NCURSES_INITIALIZED();
     609               0 :         RETURN_LONG(nocbreak());
     610                 : }
     611                 : /* }}} */
     612                 : 
     613                 : /* {{{ proto int ncurses_noecho(void)
     614                 :    Switches off keyboard input echo */
     615                 : PHP_FUNCTION(ncurses_noecho)
     616               0 : {
     617               0 :         IS_NCURSES_INITIALIZED();
     618               0 :         RETURN_LONG(noecho());
     619                 : }
     620                 : /* }}} */
     621                 : 
     622                 : /* {{{ proto int ncurses_nonl(void)
     623                 :    Do not ranslate newline and carriage return / line feed */
     624                 : PHP_FUNCTION(ncurses_nonl)
     625               0 : {
     626               0 :         RETURN_LONG(nonl());
     627                 : }
     628                 : /* }}} */
     629                 : 
     630                 : /* {{{ proto bool ncurses_noraw(void)
     631                 :    Switches terminal out of raw mode */
     632                 : PHP_FUNCTION(ncurses_noraw)
     633               0 : {
     634               0 :         IS_NCURSES_INITIALIZED();
     635               0 :         RETURN_LONG(noraw());
     636                 : }
     637                 : /* }}} */
     638                 : 
     639                 : /* {{{ proto int ncurses_raw(void)
     640                 :    Switches terminal into raw mode */
     641                 : PHP_FUNCTION(ncurses_raw)
     642               0 : {
     643               0 :         IS_NCURSES_INITIALIZED();
     644               0 :         RETURN_LONG(raw());
     645                 : }
     646                 : /* }}} */
     647                 : 
     648                 : /* {{{ proto int ncurses_meta(resource window, bool 8bit)
     649                 :    Enables/Disable 8-bit meta key information */
     650                 : PHP_FUNCTION(ncurses_meta)
     651               0 : {
     652                 :         zend_bool enable;
     653                 :         zval *handle;
     654                 :         WINDOW **win;
     655                 : 
     656               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rb", &handle, &enable) == FAILURE) {
     657               0 :                 return;
     658                 :         }
     659                 : 
     660               0 :         FETCH_WINRES(win, &handle);
     661                 : 
     662               0 :         RETURN_LONG(meta(*win, enable));
     663                 : }
     664                 : /* }}} */
     665                 : 
     666                 : /* {{{ proto int ncurses_werase(resource window)
     667                 :    Erase window contents */
     668                 : PHP_FUNCTION(ncurses_werase)
     669               0 : {
     670                 :         zval *handle;
     671                 :         WINDOW **win;
     672                 : 
     673               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &handle) == FAILURE) {
     674               0 :                 return;
     675                 :         }
     676                 : 
     677               0 :         FETCH_WINRES(win, &handle);
     678                 : 
     679               0 :         RETURN_LONG(werase(*win));
     680                 : }
     681                 : /* }}} */
     682                 : 
     683                 : 
     684                 : /* {{{ proto int ncurses_resetty(void)
     685                 :    Restores saved terminal state */
     686                 : PHP_FUNCTION(ncurses_resetty)
     687               0 : {
     688               0 :         IS_NCURSES_INITIALIZED();
     689               0 :         RETURN_LONG(resetty());
     690                 : }
     691                 : /* }}} */
     692                 : 
     693                 : /* {{{ proto int ncurses_savetty(void)
     694                 :    Saves terminal state */
     695                 : PHP_FUNCTION(ncurses_savetty)
     696               0 : {
     697               0 :         IS_NCURSES_INITIALIZED();
     698               0 :         RETURN_LONG(savetty());
     699                 : }
     700                 : /* }}} */
     701                 : 
     702                 : /* {{{ proto int ncurses_termattrs(void)
     703                 :    Returns a logical OR of all attribute flags supported by terminal */
     704                 : PHP_FUNCTION(ncurses_termattrs)
     705               0 : {
     706               0 :         IS_NCURSES_INITIALIZED();
     707               0 :         RETURN_LONG(termattrs());
     708                 : }
     709                 : /* }}} */
     710                 : 
     711                 : /* {{{ proto int ncurses_use_default_colors(void)
     712                 :    Assigns terminal default colors to color id -1 */
     713                 : PHP_FUNCTION(ncurses_use_default_colors)
     714               0 : {
     715               0 :         IS_NCURSES_INITIALIZED();
     716               0 :         RETURN_LONG(use_default_colors());
     717                 : }
     718                 : /* }}} */
     719                 : 
     720                 : /* {{{ proto int ncurses_slk_attr(void)
     721                 :    Returns current soft label keys attribute */
     722                 : PHP_FUNCTION(ncurses_slk_attr)
     723               0 : {
     724               0 :         IS_NCURSES_INITIALIZED();
     725               0 :         RETURN_LONG(slk_attr());
     726                 : }
     727                 : /* }}} */
     728                 : 
     729                 : /* {{{ proto int ncurses_slk_clear(void)
     730                 :    Clears soft label keys from screen */
     731                 : PHP_FUNCTION(ncurses_slk_clear)
     732               0 : {
     733               0 :         IS_NCURSES_INITIALIZED();
     734               0 :         RETURN_LONG(slk_clear());
     735                 : }
     736                 : /* }}} */
     737                 : 
     738                 : /* {{{ proto int ncurses_slk_noutrefresh(void)
     739                 :    Copies soft label keys to virtual screen */
     740                 : PHP_FUNCTION(ncurses_slk_noutrefresh)
     741               0 : {
     742               0 :         IS_NCURSES_INITIALIZED();
     743               0 :         RETURN_LONG(slk_noutrefresh());
     744                 : }
     745                 : /* }}} */
     746                 : 
     747                 : /* {{{ proto int ncurses_slk_refresh(void)
     748                 :    Copies soft label keys to screen */
     749                 : PHP_FUNCTION(ncurses_slk_refresh)
     750               0 : {
     751               0 :         IS_NCURSES_INITIALIZED();
     752               0 :         RETURN_LONG(slk_refresh());
     753                 : }
     754                 : /* }}} */
     755                 : 
     756                 : /* {{{ proto int ncurses_slk_restore(void)
     757                 :    Restores soft label keys */
     758                 : PHP_FUNCTION(ncurses_slk_restore)
     759               0 : {
     760               0 :         IS_NCURSES_INITIALIZED();
     761               0 :         RETURN_LONG(slk_restore());
     762                 : }
     763                 : /* }}} */
     764                 : 
     765                 : /* {{{ proto int ncurses_slk_touch(void)
     766                 :    Forces output when ncurses_slk_noutrefresh is performed */
     767                 : PHP_FUNCTION(ncurses_slk_touch)
     768               0 : {
     769               0 :         IS_NCURSES_INITIALIZED();
     770               0 :         RETURN_LONG(slk_touch());
     771                 : }
     772                 : /* }}} */
     773                 : 
     774                 : /* {{{ proto bool ncurses_slk_set(int labelnr, string label, int format)
     775                 :    Sets function key labels */
     776                 : PHP_FUNCTION(ncurses_slk_set)
     777               0 : {
     778                 :         char *str;
     779                 :         int  len;
     780                 :         long labelnr;
     781                 :         long format;
     782                 : 
     783               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lsl", &labelnr, &str, &len, &format) == FAILURE) {
     784               0 :                 return;
     785                 :         }
     786               0 :         IS_NCURSES_INITIALIZED();
     787               0 :         RETURN_BOOL(slk_set(labelnr, str, format));
     788                 : }
     789                 : /* }}} */
     790                 : 
     791                 : 
     792                 : /* {{{ proto int ncurses_attroff(int attributes)
     793                 :    Turns off the given attributes */
     794                 : PHP_FUNCTION(ncurses_attroff)
     795               0 : {
     796                 :         long intarg;
     797                 : 
     798               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &intarg) == FAILURE) {
     799               0 :                 return;
     800                 :         }
     801               0 :         IS_NCURSES_INITIALIZED();
     802               0 :         RETURN_LONG(attroff(intarg));
     803                 : }
     804                 : /* }}} */
     805                 : 
     806                 : /* {{{ proto int ncurses_attron(int attributes)
     807                 :    Turns on the given attributes */
     808                 : PHP_FUNCTION(ncurses_attron)
     809               0 : {
     810                 :         long intarg;
     811                 : 
     812               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &intarg) == FAILURE) {
     813               0 :                 return;
     814                 :         }
     815               0 :         IS_NCURSES_INITIALIZED();
     816               0 :         RETURN_LONG(attron(intarg));
     817                 : }
     818                 : /* }}} */
     819                 : 
     820                 : /* {{{ proto int ncurses_attrset(int attributes)
     821                 :    Sets given attributes */
     822                 : PHP_FUNCTION(ncurses_attrset)
     823               0 : {
     824                 :         long intarg;
     825                 : 
     826               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &intarg) == FAILURE) {
     827               0 :                 return;
     828                 :         }
     829               0 :         IS_NCURSES_INITIALIZED();
     830               0 :         RETURN_LONG(attrset(intarg));
     831                 : }
     832                 : /* }}} */
     833                 : 
     834                 : /* {{{ proto int ncurses_bkgd(int attrchar)
     835                 :    Sets background property for terminal screen */
     836                 : PHP_FUNCTION(ncurses_bkgd)
     837               0 : {
     838                 :         long intarg;
     839                 : 
     840               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &intarg) == FAILURE) {
     841               0 :                 return;
     842                 :         }
     843               0 :         IS_NCURSES_INITIALIZED();
     844               0 :         RETURN_LONG(bkgd(intarg));
     845                 : }
     846                 : /* }}} */
     847                 : 
     848                 : /* {{{ proto int ncurses_curs_set(int visibility)
     849                 :    Sets cursor state */
     850                 : PHP_FUNCTION(ncurses_curs_set)
     851               0 : {
     852                 :         long intarg;
     853                 : 
     854               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &intarg) == FAILURE) {
     855               0 :                 return;
     856                 :         }
     857               0 :         IS_NCURSES_INITIALIZED();
     858               0 :         RETURN_LONG(curs_set(intarg));
     859                 : }
     860                 : /* }}} */
     861                 : 
     862                 : /* {{{ proto int ncurses_delay_output(int milliseconds)
     863                 :    Delays output on terminal using padding characters */
     864                 : PHP_FUNCTION(ncurses_delay_output)
     865               0 : {
     866                 :         long intarg;
     867                 : 
     868               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &intarg) == FAILURE) {
     869               0 :                 return;
     870                 :         }
     871               0 :         IS_NCURSES_INITIALIZED();
     872               0 :         RETURN_LONG(delay_output(intarg));
     873                 : }
     874                 : /* }}} */
     875                 : 
     876                 : /* {{{ proto int ncurses_echochar(int character)
     877                 :    Single character output including refresh */
     878                 : PHP_FUNCTION(ncurses_echochar)
     879               0 : {
     880                 :         long intarg;
     881                 :         
     882               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &intarg) == FAILURE) {
     883               0 :                 return;
     884                 :         }
     885               0 :         IS_NCURSES_INITIALIZED();       
     886               0 :         RETURN_LONG(echochar(intarg));
     887                 : }
     888                 : /* }}} */
     889                 : 
     890                 : /* {{{ proto int ncurses_halfdelay(int tenth)
     891                 :    Puts terminal into halfdelay mode */
     892                 : PHP_FUNCTION(ncurses_halfdelay)
     893               0 : {
     894                 :         long intarg;
     895                 :         
     896               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &intarg) == FAILURE) {
     897               0 :                 return;
     898                 :         }
     899               0 :         IS_NCURSES_INITIALIZED();
     900               0 :         RETURN_LONG(halfdelay(intarg));
     901                 : }
     902                 : /* }}} */
     903                 : 
     904                 : /* {{{ proto int ncurses_has_key(int keycode)
     905                 :    Checks for presence of a function key on terminal keyboard */
     906                 : PHP_FUNCTION(ncurses_has_key)
     907               0 : {
     908                 :         long intarg;
     909                 :         
     910               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &intarg) == FAILURE) {
     911               0 :                 return;
     912                 :         }
     913               0 :         IS_NCURSES_INITIALIZED();       
     914               0 :         RETURN_LONG(has_key(intarg));
     915                 : }
     916                 : /* }}} */
     917                 : 
     918                 : /* {{{ proto int ncurses_insch(int character)
     919                 :    Inserts character moving rest of line including character at current position */
     920                 : PHP_FUNCTION(ncurses_insch)
     921               0 : {
     922                 :         long intarg;
     923                 :         
     924               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &intarg) == FAILURE) {
     925               0 :                 return;
     926                 :         }
     927               0 :         IS_NCURSES_INITIALIZED();       
     928               0 :         RETURN_LONG(insch(intarg));
     929                 : }
     930                 : /* }}} */
     931                 : 
     932                 : /* {{{ proto int ncurses_insdelln(int count)
     933                 :    Inserts lines before current line scrolling down (negative numbers delete and scroll up) */
     934                 : PHP_FUNCTION(ncurses_insdelln)
     935               0 : {
     936                 :         long intarg;
     937                 :         
     938               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &intarg) == FAILURE) {
     939               0 :                 return;
     940                 :         }
     941               0 :         IS_NCURSES_INITIALIZED();       
     942               0 :         RETURN_LONG(insdelln(intarg));
     943                 : }
     944                 : /* }}} */
     945                 : 
     946                 : /* {{{ proto int ncurses_mouseinterval(int milliseconds)
     947                 :    Sets timeout for mouse button clicks */
     948                 : PHP_FUNCTION(ncurses_mouseinterval)
     949               0 : {
     950                 :         long intarg;
     951                 : 
     952               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &intarg) == FAILURE) {
     953               0 :                 return;
     954                 :         }
     955               0 :         IS_NCURSES_INITIALIZED();
     956               0 :         RETURN_LONG(mouseinterval(intarg));
     957                 : }
     958                 : /* }}} */
     959                 : 
     960                 : /* {{{ proto int ncurses_napms(int milliseconds)
     961                 :    Sleep */
     962                 : PHP_FUNCTION(ncurses_napms)
     963               0 : {
     964                 :         long intarg;
     965                 :         
     966               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &intarg) == FAILURE) {
     967               0 :                 return;
     968                 :         }
     969               0 :         IS_NCURSES_INITIALIZED();       
     970               0 :         RETURN_LONG(napms(intarg));
     971                 : }
     972                 : /* }}} */
     973                 : 
     974                 : /* {{{ proto int ncurses_scrl(int count)
     975                 :    Scrolls window content up or down without changing current position */
     976                 : PHP_FUNCTION(ncurses_scrl)
     977               0 : {
     978                 :         long intarg;
     979                 :         
     980               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &intarg) == FAILURE) {
     981               0 :                 return;
     982                 :         }
     983               0 :         IS_NCURSES_INITIALIZED();       
     984               0 :         RETURN_LONG(scrl(intarg));
     985                 : }
     986                 : /* }}} */
     987                 : 
     988                 : /* {{{ proto int ncurses_slk_attroff(int intarg)
     989                 :    ??? */
     990                 : PHP_FUNCTION(ncurses_slk_attroff)
     991               0 : {
     992                 :         long intarg;
     993                 :         
     994               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &intarg) == FAILURE) {
     995               0 :                 return;
     996                 :         }
     997               0 :         IS_NCURSES_INITIALIZED();       
     998               0 :         RETURN_LONG(slk_attroff(intarg));
     999                 : }
    1000                 : /* }}} */
    1001                 : 
    1002                 : /* {{{ proto int ncurses_slk_attron(int intarg)
    1003                 :    ??? */
    1004                 : PHP_FUNCTION(ncurses_slk_attron)
    1005               0 : {
    1006                 :         long intarg;
    1007                 : 
    1008               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &intarg) == FAILURE) {
    1009               0 :                 return;
    1010                 :         }
    1011               0 :         IS_NCURSES_INITIALIZED();
    1012               0 :         RETURN_LONG(slk_attron(intarg));
    1013                 : }
    1014                 : /* }}} */
    1015                 : 
    1016                 : /* {{{ proto int ncurses_slk_attrset(int intarg)
    1017                 :    ??? */
    1018                 : PHP_FUNCTION(ncurses_slk_attrset)
    1019               0 : {
    1020                 :         long intarg;
    1021                 : 
    1022               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &intarg) == FAILURE) {
    1023               0 :                 return;
    1024                 :         }
    1025               0 :         IS_NCURSES_INITIALIZED();
    1026               0 :         RETURN_LONG(slk_attrset(intarg));
    1027                 : }
    1028                 : /* }}} */
    1029                 : 
    1030                 : #ifdef HAVE_NCURSES_SLK_COLOR
    1031                 : /* {{{ proto int ncurses_slk_color(int intarg)
    1032                 :    Sets color for soft label keys*/
    1033                 : PHP_FUNCTION(ncurses_slk_color)
    1034               0 : {
    1035                 :         long intarg;
    1036                 : 
    1037               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &intarg) == FAILURE) {
    1038               0 :                 return;
    1039                 :         }
    1040               0 :         IS_NCURSES_INITIALIZED();
    1041               0 :         RETURN_LONG(slk_color(intarg));
    1042                 : }
    1043                 : /* }}} */
    1044                 : #endif
    1045                 : 
    1046                 : /* {{{ proto int ncurses_slk_init(int intarg)
    1047                 :    Inits soft label keys */
    1048                 : PHP_FUNCTION(ncurses_slk_init)
    1049               0 : {
    1050                 :         long intarg;
    1051                 : 
    1052               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &intarg) == FAILURE) {
    1053               0 :                 return;
    1054                 :         }
    1055               0 :         IS_NCURSES_INITIALIZED();
    1056               0 :         RETURN_LONG(slk_init(intarg));
    1057                 : }
    1058                 : /* }}} */
    1059                 : 
    1060                 : /* {{{ proto int ncurses_typeahead(int fd)
    1061                 :    Specifys different filedescriptor for typeahead checking */
    1062                 : PHP_FUNCTION(ncurses_typeahead)
    1063               0 : {
    1064                 :         long intarg;
    1065                 : 
    1066               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &intarg) == FAILURE) {
    1067               0 :                 return;
    1068                 :         }
    1069               0 :         IS_NCURSES_INITIALIZED();
    1070               0 :         RETURN_LONG(typeahead(intarg));
    1071                 : }
    1072                 : /* }}} */
    1073                 : 
    1074                 : /* {{{ proto int ncurses_ungetch(int keycode)
    1075                 :    Puts a character back into the input stream */
    1076                 : PHP_FUNCTION(ncurses_ungetch)
    1077               0 : {
    1078                 :         long intarg;
    1079                 : 
    1080               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &intarg) == FAILURE) {
    1081               0 :                 return;
    1082                 :         }
    1083               0 :         IS_NCURSES_INITIALIZED();
    1084               0 :         RETURN_LONG(ungetch(intarg));
    1085                 : }
    1086                 : /* }}} */
    1087                 : 
    1088                 : /* {{{ proto int ncurses_vidattr(int intarg)
    1089                 :    ??? */
    1090                 : PHP_FUNCTION(ncurses_vidattr)
    1091               0 : {
    1092                 :         long intarg;
    1093                 :         
    1094               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &intarg) == FAILURE) {
    1095               0 :                 return;
    1096                 :         }
    1097               0 :         IS_NCURSES_INITIALIZED();
    1098               0 :         RETURN_LONG(vidattr(intarg));
    1099                 : }
    1100                 : /* }}} */
    1101                 : 
    1102                 : #ifdef HAVE_NCURSES_USE_EXTENDED_NAMES
    1103                 : /* {{{ proto int ncurses_use_extended_names(bool flag)
    1104                 :    Controls use of extended names in terminfo descriptions */
    1105                 : PHP_FUNCTION(ncurses_use_extended_names)
    1106               0 : {
    1107                 :         long intarg;
    1108                 :         
    1109               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &intarg) == FAILURE) {
    1110               0 :                 return;
    1111                 :         }
    1112               0 :         IS_NCURSES_INITIALIZED();
    1113               0 :         RETURN_LONG(use_extended_names(intarg));
    1114                 : }
    1115                 : /* }}} */
    1116                 : #endif  
    1117                 : 
    1118                 : /* {{{ proto void ncurses_bkgdset(int attrchar)
    1119                 :    Controls screen background */
    1120                 : PHP_FUNCTION(ncurses_bkgdset)
    1121               0 : {
    1122                 :         long intarg;
    1123                 :         
    1124               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &intarg) == FAILURE) {
    1125               0 :                 return;
    1126                 :         }
    1127               0 :         IS_NCURSES_INITIALIZED();
    1128               0 :         bkgdset(intarg);
    1129                 : }
    1130                 : /* }}} */
    1131                 : 
    1132                 : /* {{{ proto void ncurses_filter(void)
    1133                 :  */
    1134                 : PHP_FUNCTION(ncurses_filter)
    1135               0 : {
    1136               0 :         IS_NCURSES_INITIALIZED();
    1137               0 :         filter();
    1138                 : }
    1139                 : /* }}} */
    1140                 : 
    1141                 : /* {{{ proto int ncurses_noqiflush(void)
    1142                 :    Do not flush on signal characters*/
    1143                 : PHP_FUNCTION(ncurses_noqiflush)
    1144               0 : {
    1145               0 :         IS_NCURSES_INITIALIZED();
    1146               0 :         noqiflush();
    1147                 : }
    1148                 : /* }}} */
    1149                 : 
    1150                 : /* {{{ proto void ncurses_qiflush(void)
    1151                 :    Flushes on signal characters */
    1152                 : PHP_FUNCTION(ncurses_qiflush)
    1153               0 : {
    1154               0 :         IS_NCURSES_INITIALIZED();
    1155               0 :         qiflush();
    1156                 : }
    1157                 : /* }}} */
    1158                 : 
    1159                 : /* {{{ proto void ncurses_timeout(int millisec)
    1160                 :    Sets timeout for special key sequences */
    1161                 : PHP_FUNCTION(ncurses_timeout)
    1162               0 : {
    1163                 :         long intarg;
    1164                 :         
    1165               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &intarg) == FAILURE) {
    1166               0 :                 return;
    1167                 :         }
    1168               0 :         IS_NCURSES_INITIALIZED();
    1169               0 :         timeout(intarg);
    1170                 : }
    1171                 : /* }}} */
    1172                 : 
    1173                 : /* {{{ proto void ncurses_use_env(int flag)
    1174                 :    Controls use of environment information about terminal size */
    1175                 : PHP_FUNCTION(ncurses_use_env)
    1176               0 : {
    1177                 :         long intarg;
    1178                 : 
    1179               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "l", &intarg) == FAILURE) {
    1180               0 :                 return;
    1181                 :         }
    1182               0 :         IS_NCURSES_INITIALIZED();
    1183               0 :         use_env(intarg);
    1184                 : }
    1185                 : /* }}} */
    1186                 : 
    1187                 : /* {{{ proto int ncurses_addstr(string text)
    1188                 :    Outputs text at current position */
    1189                 : PHP_FUNCTION(ncurses_addstr)
    1190               0 : {
    1191                 :         char *str;
    1192                 :         int str_len;
    1193                 : 
    1194               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
    1195               0 :                 return;
    1196                 :         }
    1197               0 :         IS_NCURSES_INITIALIZED();
    1198               0 :         RETURN_LONG(addstr(str));
    1199                 : }
    1200                 : /* }}} */
    1201                 : 
    1202                 : /* {{{ proto int ncurses_putp(string text)
    1203                 :    ??? */
    1204                 : PHP_FUNCTION(ncurses_putp)
    1205               0 : {
    1206                 :         char *str;
    1207                 :         int str_len;
    1208                 : 
    1209               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
    1210               0 :                 return;
    1211                 :         }
    1212               0 :         IS_NCURSES_INITIALIZED();
    1213               0 :         RETURN_LONG(putp(str));
    1214                 : }
    1215                 : /* }}} */
    1216                 : 
    1217                 : /* {{{ proto int ncurses_scr_dump(string filename)
    1218                 :    Dumps screen content to file */
    1219                 : PHP_FUNCTION(ncurses_scr_dump)
    1220               0 : {
    1221                 :         char *str;
    1222                 :         int str_len;
    1223                 : 
    1224               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
    1225               0 :                 return;
    1226                 :         }
    1227               0 :         IS_NCURSES_INITIALIZED();
    1228               0 :         RETURN_LONG(scr_dump(str));
    1229                 : }
    1230                 : /* }}} */
    1231                 : 
    1232                 : /* {{{ proto int ncurses_scr_init(string filename)
    1233                 :    Initializes screen from file dump */
    1234                 : PHP_FUNCTION(ncurses_scr_init)
    1235               0 : {
    1236                 :         char *str;
    1237                 :         int str_len;
    1238                 : 
    1239               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
    1240               0 :                 return;
    1241                 :         }
    1242               0 :         IS_NCURSES_INITIALIZED();
    1243               0 :         RETURN_LONG(scr_init(str));
    1244                 : }
    1245                 : /* }}} */
    1246                 : 
    1247                 : /* {{{ proto int ncurses_scr_restore(string filename)
    1248                 :    Restores screen from file dump */
    1249                 : PHP_FUNCTION(ncurses_scr_restore)
    1250               0 : {
    1251                 :         char *str;
    1252                 :         int str_len;
    1253                 : 
    1254               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
    1255               0 :                 return;
    1256                 :         }
    1257               0 :         IS_NCURSES_INITIALIZED();
    1258               0 :         RETURN_LONG(scr_restore(str));
    1259                 : }
    1260                 : /* }}} */
    1261                 : 
    1262                 : /* {{{ proto int ncurses_scr_set(string filename)
    1263                 :    Inherits screen from file dump */
    1264                 : PHP_FUNCTION(ncurses_scr_set)
    1265               0 : {
    1266                 :         char *str;
    1267                 :         int str_len;
    1268                 : 
    1269               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
    1270               0 :                 return;
    1271                 :         }
    1272               0 :         IS_NCURSES_INITIALIZED();
    1273               0 :         RETURN_LONG(scr_set(str));
    1274                 : }
    1275                 : /* }}} */
    1276                 : 
    1277                 : /* {{{ proto int ncurses_mvaddch(int y, int x, int c)
    1278                 :    Moves current position and add character */
    1279                 : PHP_FUNCTION(ncurses_mvaddch)
    1280               0 : {
    1281                 :         long y,x,c;
    1282                 :         
    1283               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lll", &y, &x, &c) == FAILURE) {
    1284               0 :                 return;
    1285                 :         }
    1286               0 :         IS_NCURSES_INITIALIZED();       
    1287               0 :         RETURN_LONG(mvaddch(y,x,c));
    1288                 : }
    1289                 : /* }}} */
    1290                 : 
    1291                 : /* {{{ proto int ncurses_mvaddchnstr(int y, int x, string s, int n)
    1292                 :    Moves position and add attrributed string with specified length */
    1293                 : PHP_FUNCTION(ncurses_mvaddchnstr)
    1294               0 : {
    1295                 :         long y,x,n;
    1296                 :         char *str;
    1297                 :         int str_len;
    1298                 : 
    1299               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llsl", &y, &x, &str, &str_len, &n) == FAILURE) {
    1300               0 :                 return;
    1301                 :         }
    1302               0 :         IS_NCURSES_INITIALIZED();       
    1303               0 :         RETURN_LONG(mvaddchnstr(y,x,(chtype *)str,n));
    1304                 : }
    1305                 : /* }}} */
    1306                 : 
    1307                 : /* {{{ proto int ncurses_addchnstr(string s, int n)
    1308                 :    Adds attributed string with specified length at current position */
    1309                 : PHP_FUNCTION(ncurses_addchnstr)
    1310               0 : {
    1311                 :         long n;
    1312                 :         char *str;
    1313                 :         int str_len;
    1314                 : 
    1315               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &str, &str_len, &n) == FAILURE) {
    1316               0 :                 return;
    1317                 :         }
    1318               0 :         IS_NCURSES_INITIALIZED();       
    1319               0 :         RETURN_LONG(addchnstr((chtype *)str,n));
    1320                 : }
    1321                 : /* }}} */
    1322                 : 
    1323                 : /* {{{ proto int ncurses_mvaddchstr(int y, int x, string s)
    1324                 :    Moves position and add attributed string */
    1325                 : PHP_FUNCTION(ncurses_mvaddchstr)
    1326               0 : {
    1327                 :         long y,x;
    1328                 :         char *str;
    1329                 :         int str_len;
    1330                 : 
    1331               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lls", &y, &x, &str, &str_len) == FAILURE) {
    1332               0 :                 return;
    1333                 :         }
    1334               0 :         IS_NCURSES_INITIALIZED();       
    1335               0 :         RETURN_LONG(mvaddchstr(y,x,(chtype *)str));
    1336                 : }
    1337                 : /* }}} */
    1338                 : 
    1339                 : /* {{{ proto int ncurses_addchstr(string s)
    1340                 :    Adds attributed string at current position */
    1341                 : PHP_FUNCTION(ncurses_addchstr)
    1342               0 : {
    1343                 :         char *str;
    1344                 :         int str_len;
    1345                 : 
    1346               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
    1347               0 :                 return;
    1348                 :         }
    1349               0 :         IS_NCURSES_INITIALIZED();       
    1350               0 :         RETURN_LONG(addchstr((chtype *)str));
    1351                 : }
    1352                 : /* }}} */
    1353                 : 
    1354                 : /* {{{ proto int ncurses_mvaddnstr(int y, int x, string s, int n)
    1355                 :    Moves position and add string with specified length */
    1356                 : PHP_FUNCTION(ncurses_mvaddnstr)
    1357               0 : {
    1358                 :         long y,x,n;
    1359                 :         char *str;
    1360                 :         int str_len;
    1361                 : 
    1362               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llsl", &y, &x, &str, &str_len, &n) == FAILURE) {
    1363               0 :                 return;
    1364                 :         }
    1365               0 :         IS_NCURSES_INITIALIZED();       
    1366               0 :         RETURN_LONG(mvaddnstr(y,x,str,n));
    1367                 : }
    1368                 : /* }}} */
    1369                 : 
    1370                 : /* {{{ proto int ncurses_addnstr(string s, int n)
    1371                 :    Adds string with specified length at current position */
    1372                 : PHP_FUNCTION(ncurses_addnstr)
    1373               0 : {
    1374                 :         long n;
    1375                 :         char *str;
    1376                 :         int str_len;
    1377                 : 
    1378               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &str, &str_len, &n) == FAILURE) {
    1379               0 :                 return;
    1380                 :         }
    1381               0 :         IS_NCURSES_INITIALIZED();       
    1382               0 :         RETURN_LONG(addnstr(str,n));
    1383                 : }
    1384                 : /* }}} */
    1385                 : 
    1386                 : /* {{{ proto int ncurses_mvaddstr(int y, int x, string s)
    1387                 :    Moves position and add string */
    1388                 : PHP_FUNCTION(ncurses_mvaddstr)
    1389               0 : {
    1390                 :         long y,x;
    1391                 :         char *str;
    1392                 :         int str_len;
    1393                 : 
    1394               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lls", &y, &x, &str, &str_len) == FAILURE) {
    1395               0 :                 return;
    1396                 :         }
    1397               0 :         IS_NCURSES_INITIALIZED();
    1398               0 :         RETURN_LONG(mvaddstr(y,x,str));
    1399                 : }
    1400                 : /* }}} */
    1401                 : 
    1402                 : /* {{{ proto int ncurses_mvdelch(int y, int x)
    1403                 :    Moves position and delete character, shift rest of line left */
    1404                 : PHP_FUNCTION(ncurses_mvdelch)
    1405               0 : {
    1406                 :         long y,x;
    1407                 : 
    1408               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &y, &x) == FAILURE) {
    1409               0 :                 return;
    1410                 :         }
    1411               0 :         IS_NCURSES_INITIALIZED();       
    1412               0 :         RETURN_LONG(mvdelch(y,x));
    1413                 : }
    1414                 : /* }}} */
    1415                 : 
    1416                 : 
    1417                 : /* {{{ proto int ncurses_mvgetch(int y, int x)
    1418                 :    Moves position and get character at new position */
    1419                 : PHP_FUNCTION(ncurses_mvgetch)
    1420               0 : {
    1421                 :         long y,x;
    1422                 : 
    1423               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &y, &x) == FAILURE) {
    1424               0 :                 return;
    1425                 :         }
    1426               0 :         IS_NCURSES_INITIALIZED();       
    1427               0 :         RETURN_LONG(mvgetch(y,x));
    1428                 : }
    1429                 : /* }}} */
    1430                 : 
    1431                 : /* {{{ proto int ncurses_mvinch(int y, int x)
    1432                 :    Moves position and get attributed character at new position */
    1433                 : PHP_FUNCTION(ncurses_mvinch)
    1434               0 : {
    1435                 :         long y,x;
    1436                 : 
    1437               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &y, &x) == FAILURE) {
    1438               0 :                 return;
    1439                 :         }
    1440               0 :         IS_NCURSES_INITIALIZED();
    1441               0 :         RETURN_LONG(mvinch(y,x));
    1442                 : }
    1443                 : /* }}} */
    1444                 : 
    1445                 : /* {{{ proto int ncurses_insstr(string text)
    1446                 :    Inserts string at current position, moving rest of line right */
    1447                 : PHP_FUNCTION(ncurses_insstr)
    1448               0 : {
    1449                 :         char *str;
    1450                 :         int str_len;
    1451                 : 
    1452               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &str, &str_len) == FAILURE) {
    1453               0 :                 return;
    1454                 :         }
    1455               0 :         IS_NCURSES_INITIALIZED();
    1456               0 :         RETURN_LONG(insstr(str));
    1457                 : }
    1458                 : /* }}} */
    1459                 : 
    1460                 : /* {{{ proto int ncurses_instr(string &buffer)
    1461                 :    Reads string from terminal screen */
    1462                 : PHP_FUNCTION(ncurses_instr)
    1463               0 : {
    1464                 :         ulong retval;
    1465                 :         zval *param;
    1466                 :         char *str;
    1467                 : 
    1468               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &param) == FAILURE ) {
    1469               0 :                 return;
    1470                 :         }
    1471               0 :         IS_NCURSES_INITIALIZED();
    1472                 : 
    1473               0 :         str = (char *)emalloc(COLS + 1);
    1474               0 :         retval = instr(str);
    1475                 : 
    1476               0 :         ZVAL_STRING(param, str, 1);
    1477               0 :         efree(str);
    1478                 : 
    1479               0 :         RETURN_LONG(retval);
    1480                 : }
    1481                 : /* }}} */
    1482                 : 
    1483                 : /* {{{ proto int ncurses_mvhline(int y, int x, int attrchar, int n)
    1484                 :    Sets new position and draw a horizontal line using an attributed character and max. n characters long */
    1485                 : PHP_FUNCTION(ncurses_mvhline)
    1486               0 : {
    1487                 :         long i1,i2,i3,i4;
    1488                 : 
    1489               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll", &i1, &i2, &i3, &i4) == FAILURE) {
    1490               0 :                 return;
    1491                 :         }
    1492               0 :         IS_NCURSES_INITIALIZED();
    1493               0 :         RETURN_LONG(mvhline(i1,i2,i3,i4));
    1494                 : }
    1495                 : /* }}} */
    1496                 : 
    1497                 : /* {{{ proto int ncurses_mvvline(int y, int x, int attrchar, int n)
    1498                 :    Sets new position and draw a vertical line using an attributed character and max. n characters long */
    1499                 : PHP_FUNCTION(ncurses_mvvline)
    1500               0 : {
    1501                 :         long i1,i2,i3,i4;
    1502                 : 
    1503               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll", &i1, &i2, &i3, &i4) == FAILURE) {
    1504               0 :                 return;
    1505                 :         }
    1506               0 :         IS_NCURSES_INITIALIZED();       
    1507               0 :         RETURN_LONG(mvvline(i1,i2,i3,i4));
    1508                 : }
    1509                 : /* }}} */
    1510                 : 
    1511                 : /* {{{ proto int ncurses_mvcur(int old_y,int old_x, int new_y, int new_x)
    1512                 :    Moves cursor immediately */
    1513                 : PHP_FUNCTION(ncurses_mvcur)
    1514               0 : {
    1515                 :         long i1,i2,i3,i4;
    1516                 : 
    1517               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll", &i1, &i2, &i3, &i4) == FAILURE) {
    1518               0 :                 return;
    1519                 :         }
    1520               0 :         IS_NCURSES_INITIALIZED();       
    1521               0 :         RETURN_LONG(mvcur(i1,i2,i3,i4));
    1522                 : }
    1523                 : /* }}} */
    1524                 : 
    1525                 : /* {{{ proto int ncurses_init_color(int color, int r, int g, int b)
    1526                 :    Sets new RGB value for color */
    1527                 : PHP_FUNCTION(ncurses_init_color)
    1528               0 : {
    1529                 :         long i1,i2,i3,i4;
    1530                 : 
    1531               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llll", &i1, &i2, &i3, &i4) == FAILURE) {
    1532               0 :                 return;
    1533                 :         }
    1534               0 :         IS_NCURSES_INITIALIZED();       
    1535               0 :         RETURN_LONG(init_color(i1,i2,i3,i4));
    1536                 : }
    1537                 : /* }}} */
    1538                 : 
    1539                 : /* {{{ proto int ncurses_color_content(int color, int &r, int &g, int &b)
    1540                 :    Gets the RGB value for color */
    1541                 : PHP_FUNCTION(ncurses_color_content)
    1542               0 : {
    1543                 :         zval *r, *g, *b;
    1544                 :         short rv, gv, bv;
    1545                 :         int retval;
    1546                 :         long c;
    1547                 : 
    1548               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lzzz", &c, &r, &g, &b) == FAILURE) {
    1549               0 :                 return;
    1550                 :         }
    1551               0 :         IS_NCURSES_INITIALIZED();
    1552                 :         
    1553               0 :         retval = color_content(c, &rv, &gv, &bv);
    1554                 : 
    1555               0 :         ZVAL_LONG(r, rv);
    1556               0 :         ZVAL_LONG(g, gv);
    1557               0 :         ZVAL_LONG(b, bv);
    1558                 : 
    1559               0 :         RETURN_LONG(retval);
    1560                 : }
    1561                 : /* }}} */
    1562                 : 
    1563                 : /* {{{ proto int ncurses_pair_content(int pair, int &f, int &b)
    1564                 :    Gets the RGB value for color */
    1565                 : PHP_FUNCTION(ncurses_pair_content)
    1566               0 : {
    1567                 :         zval *f, *b;
    1568                 :         short fv, bv;
    1569                 :         int retval;
    1570                 :         long p;
    1571                 : 
    1572               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lzz", &p, &f, &b) == FAILURE) {
    1573               0 :                 return;
    1574                 :         }
    1575               0 :         IS_NCURSES_INITIALIZED();
    1576                 : 
    1577               0 :         retval = pair_content(p, &fv, &bv);
    1578                 : 
    1579               0 :         ZVAL_LONG(f, fv);
    1580               0 :         ZVAL_LONG(b, bv);
    1581                 : 
    1582               0 :         RETURN_LONG(retval);
    1583                 : }
    1584                 : /* }}} */
    1585                 : 
    1586                 : /* {{{ proto int ncurses_border(int left, int right, int top, int bottom, int tl_corner, int tr_corner, int bl_corner, int br_corner)
    1587                 :    Draws a border around the screen using attributed characters */
    1588                 : PHP_FUNCTION(ncurses_border)
    1589               0 : {
    1590                 :         long i1,i2,i3,i4,i5,i6,i7,i8;
    1591                 : 
    1592               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "llllllll", &i1, &i2, &i3, &i4, &i5, &i6, &i7, &i8) == FAILURE) {
    1593               0 :                 return;
    1594                 :         }
    1595               0 :         IS_NCURSES_INITIALIZED();       
    1596               0 :         RETURN_LONG(border(i1,i2,i3,i4,i5,i6,i7,i8));
    1597                 : }
    1598                 : /* }}} */
    1599                 : 
    1600                 : /* {{{ proto int ncurses_wborder(resource window, int left, int right, int top, int bottom, int tl_corner, int tr_corner, int bl_corner, int br_corner)
    1601                 :    Draws a border around the window using attributed characters */
    1602                 : PHP_FUNCTION(ncurses_wborder)
    1603               0 : {
    1604                 :         long i1,i2,i3,i4,i5,i6,i7,i8;
    1605                 :         zval *handle;
    1606                 :         WINDOW **win;
    1607                 : 
    1608               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rllllllll", &handle, &i1, &i2, &i3, &i4, &i5, &i6, &i7, &i8) == FAILURE) {
    1609               0 :                 return;
    1610                 :         }
    1611                 : 
    1612               0 :         FETCH_WINRES(win, &handle);
    1613                 :         
    1614               0 :         RETURN_LONG(wborder(*win,i1,i2,i3,i4,i5,i6,i7,i8));
    1615                 : }
    1616                 : /* }}} */
    1617                 : 
    1618                 : #ifdef HAVE_NCURSES_ASSUME_DEFAULT_COLORS
    1619                 : /* {{{ proto int ncurses_assume_default_colors(int fg, int bg)
    1620                 :    Defines default colors for color 0 */
    1621                 : PHP_FUNCTION(ncurses_assume_default_colors)
    1622               0 : {
    1623                 :         long i1,i2;
    1624                 : 
    1625               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &i1, &i2) == FAILURE) {
    1626               0 :                 return;
    1627                 :         }
    1628               0 :         IS_NCURSES_INITIALIZED();
    1629               0 :         RETURN_LONG(assume_default_colors(i1,i2));
    1630                 : }
    1631                 : /* }}} */
    1632                 : #endif  
    1633                 : 
    1634                 : /* {{{ proto int ncurses_define_key(string definition, int keycode)
    1635                 :    Defines a keycode */
    1636                 : PHP_FUNCTION(ncurses_define_key)
    1637               0 : {
    1638                 :         long n;
    1639                 :         char *str;
    1640                 :         int str_len;
    1641                 : 
    1642               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "sl", &str, &str_len, &n) == FAILURE) {
    1643               0 :                 return;
    1644                 :         }
    1645               0 :         IS_NCURSES_INITIALIZED();       
    1646               0 :         RETURN_LONG(define_key(str,n));
    1647                 : }
    1648                 : /* }}} */
    1649                 : 
    1650                 : /* {{{ proto int ncurses_hline(int charattr, int n)
    1651                 :    Draws a horizontal line at current position using an attributed character and max. n characters long */
    1652                 : PHP_FUNCTION(ncurses_hline)
    1653               0 : {
    1654                 :         long i1,i2;
    1655                 : 
    1656               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &i1, &i2) == FAILURE) {
    1657               0 :                 return;
    1658                 :         }
    1659               0 :         IS_NCURSES_INITIALIZED();       
    1660               0 :         RETURN_LONG(hline(i1,i2));
    1661                 : }
    1662                 : /* }}} */
    1663                 : 
    1664                 : /* {{{ proto int ncurses_vline(int charattr, int n)
    1665                 :    Draws a vertical line at current position using an attributed character and max. n characters long */
    1666                 : PHP_FUNCTION(ncurses_vline)
    1667               0 : {
    1668                 :         long i1,i2;
    1669                 : 
    1670               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &i1, &i2) == FAILURE) {
    1671               0 :                 return;
    1672                 :         }
    1673               0 :         IS_NCURSES_INITIALIZED();
    1674               0 :         RETURN_LONG(vline(i1,i2));
    1675                 : }
    1676                 : /* }}} */
    1677                 : 
    1678                 : /* {{{ proto int ncurses_whline(resource window, int charattr, int n)
    1679                 :    Draws a horizontal line in a window at current position using an attributed character and max. n characters long */
    1680                 : PHP_FUNCTION(ncurses_whline)
    1681               0 : {
    1682                 :         long i1,i2;
    1683                 :         zval *handle;
    1684                 :         WINDOW **win;
    1685                 : 
    1686               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rll", &handle, &i1, &i2) == FAILURE) {
    1687               0 :                 return;
    1688                 :         }
    1689                 : 
    1690               0 :         FETCH_WINRES(win, &handle);
    1691                 :         
    1692               0 :         RETURN_LONG(whline(*win,i1,i2));
    1693                 : }
    1694                 : /* }}} */
    1695                 : 
    1696                 : /* {{{ proto int ncurses_wvline(resource window, int charattr, int n)
    1697                 :    Draws a vertical line in a window at current position using an attributed character and max. n characters long */
    1698                 : PHP_FUNCTION(ncurses_wvline)
    1699               0 : {
    1700                 :         long i1,i2;
    1701                 :         zval *handle;
    1702                 :         WINDOW **win;
    1703                 : 
    1704               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rll", &handle, &i1, &i2) == FAILURE) {
    1705               0 :                 return;
    1706                 :         }
    1707               0 :         FETCH_WINRES(win, &handle);
    1708                 : 
    1709               0 :         RETURN_LONG(wvline(*win,i1,i2));
    1710                 : }
    1711                 : /* }}} */
    1712                 : 
    1713                 : /* {{{ proto int ncurses_keyok(int keycode, int enable)
    1714                 :    Enables or disable a keycode */
    1715                 : PHP_FUNCTION(ncurses_keyok)
    1716               0 : {
    1717                 :         long i,b;
    1718                 : 
    1719               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "ll", &i, &b) == FAILURE) {
    1720               0 :                 return;
    1721                 :         }
    1722               0 :         IS_NCURSES_INITIALIZED();       
    1723               0 :         RETURN_LONG(hline(i,b));
    1724                 : }
    1725                 : /* }}} */
    1726                 : 
    1727                 : /* {{{ proto int ncurses_mvwaddstr(resource window, int y, int x, string text)
    1728                 :    Adds string at new position in window */
    1729                 : PHP_FUNCTION(ncurses_mvwaddstr)
    1730               0 : {
    1731                 :         zval *handle;
    1732                 :         long y, x;
    1733                 :         int text_len;
    1734                 :         char *text;
    1735                 :         WINDOW **w;
    1736                 : 
    1737               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rlls", &handle, &y, &x, &text, &text_len) == FAILURE) {
    1738               0 :                 return;
    1739                 :         }
    1740                 :         
    1741               0 :         FETCH_WINRES(w, &handle);
    1742                 : 
    1743               0 :         RETURN_LONG(mvwaddstr(*w,y,x,text));
    1744                 : }
    1745                 : /* }}} */
    1746                 : 
    1747                 : /* {{{ proto int ncurses_wrefresh(resource window)
    1748                 :    Refreshes window on terminal screen */
    1749                 : PHP_FUNCTION(ncurses_wrefresh)
    1750               0 : {
    1751                 :         zval *handle;
    1752                 :         WINDOW **w;
    1753                 : 
    1754               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &handle) == FAILURE) {
    1755               0 :                 return;
    1756                 :         }
    1757                 : 
    1758               0 :         FETCH_WINRES(w, &handle);
    1759                 : 
    1760               0 :         RETURN_LONG(wrefresh(*w));
    1761                 : }
    1762                 : /* }}} */
    1763                 : 
    1764                 : /* {{{ proto string ncurses_termname(void)
    1765                 :    Returns terminal name */
    1766                 : PHP_FUNCTION(ncurses_termname)
    1767               0 : {
    1768                 :         char temp[15];
    1769                 :         
    1770               0 :         IS_NCURSES_INITIALIZED();
    1771                 : 
    1772               0 :         strlcpy(temp, termname(), sizeof(temp));
    1773                 : 
    1774               0 :         RETURN_STRINGL (temp, strlen(temp), 1);
    1775                 : }
    1776                 : /* }}} */
    1777                 : 
    1778                 : /* {{{ proto string ncurses_longname(void)
    1779                 :    Returns terminal description */
    1780                 : PHP_FUNCTION(ncurses_longname)
    1781               0 : {
    1782                 :         char temp[128];
    1783                 : 
    1784               0 :         IS_NCURSES_INITIALIZED();
    1785                 : 
    1786               0 :         strlcpy(temp, longname(), sizeof(temp));
    1787                 : 
    1788               0 :         RETURN_STRINGL (temp, strlen(temp), 1);
    1789                 : }
    1790                 : /* }}} */
    1791                 : 
    1792                 : /* {{{ proto int ncurses_mousemask(int newmask, int &oldmask)
    1793                 :    Returns and sets mouse options */
    1794                 : PHP_FUNCTION(ncurses_mousemask)
    1795               0 : {
    1796                 :         ulong oldmask;
    1797                 :         ulong retval;
    1798                 :         zval *param;
    1799                 :         long newmask;
    1800                 : 
    1801               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "lz", &newmask, &param) == FAILURE) {
    1802               0 :                 return;
    1803                 :         }
    1804               0 :         IS_NCURSES_INITIALIZED();
    1805                 : 
    1806               0 :         retval = mousemask(newmask, &oldmask);
    1807                 : 
    1808               0 :         ZVAL_LONG(param, oldmask);
    1809                 : 
    1810               0 :         RETURN_LONG(retval);
    1811                 : }
    1812                 : /* }}} */
    1813                 : 
    1814                 : /* {{{ proto bool ncurses_getmouse(array &mevent)
    1815                 :    Reads mouse event from queue. The content of mevent is cleared before new data is added. */
    1816                 : PHP_FUNCTION(ncurses_getmouse)
    1817               0 : {
    1818                 :         zval *arg;
    1819                 :         MEVENT mevent;
    1820                 :         ulong retval;
    1821                 : 
    1822               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "z", &arg) == FAILURE) {
    1823               0 :                 return;
    1824                 :         }
    1825               0 :         IS_NCURSES_INITIALIZED();
    1826                 : 
    1827               0 :         zval_dtor(arg);
    1828               0 :         array_init(arg);
    1829                 : 
    1830               0 :         retval = getmouse(&mevent);
    1831                 : 
    1832               0 :         add_assoc_long(arg, "id", mevent.id);
    1833               0 :         add_assoc_long(arg, "x", mevent.x);
    1834               0 :         add_assoc_long(arg, "y", mevent.y);
    1835               0 :         add_assoc_long(arg, "z", mevent.z);
    1836               0 :         add_assoc_long(arg, "mmask", mevent.bstate);
    1837                 : 
    1838               0 :         RETURN_BOOL(retval == 0);
    1839                 : }
    1840                 : /* }}} */
    1841                 : 
    1842                 : /* {{{ proto int ncurses_ungetmouse(array mevent)
    1843                 :    Pushes mouse event to queue */
    1844                 : PHP_FUNCTION(ncurses_ungetmouse)
    1845               0 : {
    1846                 :         zval *arg, **zvalue;
    1847                 :         MEVENT mevent;
    1848                 :         ulong retval;
    1849                 : 
    1850               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "a", &arg) == FAILURE) {
    1851               0 :                 return;
    1852                 :         }
    1853               0 :         IS_NCURSES_INITIALIZED();
    1854                 : 
    1855               0 :         if (zend_hash_find(Z_ARRVAL_P(arg), "id", sizeof("id"), (void **) &zvalue) == SUCCESS) {
    1856               0 :                 convert_to_long_ex(zvalue);
    1857               0 :                 mevent.id = Z_LVAL_PP(zvalue);
    1858                 :         }
    1859                 : 
    1860               0 :         if (zend_hash_find(Z_ARRVAL_P(arg), "x", sizeof("x"), (void **) &zvalue) == SUCCESS) {
    1861               0 :                 convert_to_long_ex(zvalue);
    1862               0 :                 mevent.x = Z_LVAL_PP(zvalue);
    1863                 :         }
    1864                 : 
    1865               0 :         if (zend_hash_find(Z_ARRVAL_P(arg), "y", sizeof("y"), (void **) &zvalue) == SUCCESS) {
    1866               0 :                 convert_to_long_ex(zvalue);
    1867               0 :                 mevent.y = Z_LVAL_PP(zvalue);
    1868                 :         }
    1869                 : 
    1870               0 :         if (zend_hash_find(Z_ARRVAL_P(arg), "z", sizeof("z"), (void **) &zvalue) == SUCCESS) {
    1871               0 :                 convert_to_long_ex(zvalue);
    1872               0 :                 mevent.z = Z_LVAL_PP(zvalue);
    1873                 :         }
    1874                 : 
    1875               0 :         if (zend_hash_find(Z_ARRVAL_P(arg), "mmask", sizeof("mmask"), (void **) &zvalue) == SUCCESS) {
    1876               0 :                 convert_to_long_ex(zvalue);
    1877               0 :                 mevent.bstate = Z_LVAL_PP(zvalue);
    1878                 :         }
    1879                 : 
    1880               0 :         retval = ungetmouse(&mevent);
    1881                 : 
    1882               0 :         RETURN_LONG(retval);
    1883                 : }
    1884                 : /* }}} */
    1885                 : 
    1886                 : /* {{{ proto bool ncurses_mouse_trafo(int &y, int &x, bool toscreen)
    1887                 :    Transforms coordinates */
    1888                 : PHP_FUNCTION(ncurses_mouse_trafo)
    1889               0 : {
    1890                 :         zval *x, *y;
    1891                 :         zend_bool toscreen;
    1892                 :         int nx, ny, retval;
    1893                 : 
    1894               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "zzb", &y, &x, &toscreen) == FAILURE) {
    1895               0 :                 return;
    1896                 :         }
    1897               0 :         IS_NCURSES_INITIALIZED();
    1898                 : 
    1899               0 :         convert_to_long(y);
    1900               0 :         convert_to_long(x);
    1901                 : 
    1902               0 :         nx = Z_LVAL_P(x);
    1903               0 :         ny = Z_LVAL_P(y);
    1904                 : 
    1905               0 :         retval = mouse_trafo(&ny, &nx, toscreen);
    1906                 : 
    1907               0 :         ZVAL_LONG(x, nx);
    1908               0 :         ZVAL_LONG(y, ny);
    1909                 : 
    1910               0 :         RETURN_BOOL(retval);
    1911                 : }
    1912                 : /* }}} */
    1913                 : 
    1914                 : /* {{{ proto bool ncurses_wmouse_trafo(resource window, int &y, int &x, bool toscreen)
    1915                 :    Transforms window/stdscr coordinates */
    1916                 : PHP_FUNCTION(ncurses_wmouse_trafo)
    1917               0 : {
    1918                 :         zval *handle, *x, *y;
    1919                 :         int nx, ny, retval;
    1920                 :         WINDOW **win;
    1921                 :         zend_bool toscreen;
    1922                 : 
    1923               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rzzb", &handle, &y, &x, &toscreen) == FAILURE) {
    1924               0 :                 return;
    1925                 :         }
    1926                 : 
    1927               0 :         FETCH_WINRES(win, &handle);
    1928                 : 
    1929               0 :         convert_to_long(x);
    1930               0 :         convert_to_long(y);
    1931                 : 
    1932               0 :         nx = Z_LVAL_P(x);
    1933               0 :         ny = Z_LVAL_P(y);
    1934                 : 
    1935               0 :         retval = wmouse_trafo (*win, &ny, &nx, toscreen);
    1936                 : 
    1937               0 :         ZVAL_LONG(x, nx);
    1938               0 :         ZVAL_LONG(y, ny);
    1939                 : 
    1940               0 :         RETURN_BOOL(retval);
    1941                 : }
    1942                 : /* }}} */
    1943                 : 
    1944                 : /* {{{ proto void ncurses_getyx(resource window, int &y, int &x)
    1945                 :    Returns the current cursor position for a window */
    1946                 : PHP_FUNCTION(ncurses_getyx)
    1947               0 : {
    1948                 :         zval *handle, *x, *y;
    1949                 :         WINDOW **win;
    1950                 : 
    1951               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rzz", &handle, &y, &x) == FAILURE) {
    1952               0 :                 return;
    1953                 :         }
    1954                 : 
    1955               0 :         FETCH_WINRES(win, &handle);
    1956                 : 
    1957               0 :         convert_to_long(x);
    1958               0 :         convert_to_long(y);
    1959                 : 
    1960               0 :         getyx(*win, Z_LVAL_P(y), Z_LVAL_P(x));
    1961                 : }
    1962                 : /* }}} */
    1963                 : 
    1964                 : /* {{{ proto void ncurses_getmaxyx(resource window, int &y, int &x)
    1965                 :    Returns the size of a window */
    1966                 : PHP_FUNCTION(ncurses_getmaxyx)
    1967               0 : {
    1968                 :         zval *handle, *x, *y;
    1969                 :         WINDOW **win;
    1970                 : 
    1971               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rzz", &handle, &y, &x) == FAILURE) {
    1972               0 :                 return;
    1973                 :         }
    1974                 : 
    1975               0 :         FETCH_WINRES(win, &handle);
    1976                 : 
    1977               0 :         convert_to_long(x);
    1978               0 :         convert_to_long(y);
    1979                 : 
    1980               0 :         getmaxyx(*win, Z_LVAL_P(y), Z_LVAL_P(x));
    1981                 : }
    1982                 : /* }}} */
    1983                 : 
    1984                 : /* {{{ proto int ncurses_wmove(resource window, int y, int x)
    1985                 :    Moves windows output position */
    1986                 : PHP_FUNCTION(ncurses_wmove)
    1987               0 : {
    1988                 :         zval *handle, *x, *y;
    1989                 :         WINDOW **win;
    1990                 : 
    1991               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rzz", &handle, &y, &x) == FAILURE) {
    1992               0 :                 return;
    1993                 :         }
    1994                 : 
    1995               0 :         FETCH_WINRES(win, &handle);
    1996                 : 
    1997               0 :         convert_to_long(x);
    1998               0 :         convert_to_long(y);
    1999                 : 
    2000               0 :         RETURN_LONG(wmove(*win, Z_LVAL_P(y), Z_LVAL_P(x)));
    2001                 : }
    2002                 : /* }}} */
    2003                 : 
    2004                 : /* {{{ proto int ncurses_keypad(resource window, bool bf)
    2005                 :    Turns keypad on or off */
    2006                 : PHP_FUNCTION(ncurses_keypad)
    2007               0 : {
    2008                 :         zval *handle;
    2009                 :         zend_bool bf;
    2010                 :         WINDOW **win;
    2011                 : 
    2012               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rb", &handle, &bf) == FAILURE) {
    2013               0 :                 return;
    2014                 :         }
    2015                 : 
    2016               0 :         FETCH_WINRES(win, &handle);
    2017                 : 
    2018               0 :         RETURN_LONG(keypad(*win, bf));
    2019                 : 
    2020                 : }
    2021                 : /* }}} */
    2022                 : 
    2023                 : #ifdef HAVE_NCURSES_COLOR_SET
    2024                 : /* {{{ proto int ncurses_wcolor_set(resource window, int color_pair)
    2025                 :    Sets windows color pairings */
    2026                 : PHP_FUNCTION(ncurses_wcolor_set)
    2027               0 : {
    2028                 :         zval *handle;
    2029                 :         long color_pair;
    2030                 :         WINDOW **win;
    2031                 : 
    2032               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &handle, &color_pair) == FAILURE) {
    2033               0 :                 return;
    2034                 :         }
    2035                 : 
    2036               0 :         FETCH_WINRES(win, &handle);
    2037                 : 
    2038               0 :         RETURN_LONG(wcolor_set(*win, color_pair, 0));
    2039                 : }
    2040                 : /* }}} */
    2041                 : #endif
    2042                 : 
    2043                 : /* {{{ proto int ncurses_wclear(resource window)
    2044                 :    Clears window */
    2045                 : PHP_FUNCTION(ncurses_wclear)
    2046               0 : {
    2047                 :         zval *handle;
    2048                 :         WINDOW **win;
    2049                 : 
    2050               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &handle) == FAILURE) {
    2051               0 :                 return;
    2052                 :         }       
    2053                 : 
    2054               0 :         FETCH_WINRES(win, &handle);
    2055                 : 
    2056               0 :         RETURN_LONG(wclear(*win));
    2057                 : }
    2058                 : /* }}} */
    2059                 : 
    2060                 : /* {{{ proto int ncurses_wnoutrefresh(resource window)
    2061                 :    Copies window to virtual screen */
    2062                 : PHP_FUNCTION(ncurses_wnoutrefresh)
    2063               0 : {
    2064                 :         zval *handle;
    2065                 :         WINDOW **win;
    2066                 : 
    2067               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &handle) == FAILURE) {
    2068               0 :                 return;
    2069                 :         }
    2070                 : 
    2071               0 :         FETCH_WINRES(win, &handle);
    2072                 : 
    2073               0 :         RETURN_LONG(wnoutrefresh(*win));
    2074                 : }
    2075                 : /* }}} */
    2076                 : 
    2077                 : /* {{{ proto int ncurses_waddstr(resource window, string str [, int n])
    2078                 :    Outputs text at current postion in window */
    2079                 : PHP_FUNCTION(ncurses_waddstr)
    2080               0 : {
    2081                 :         zval *handle;
    2082                 :         char *str;
    2083                 :         int str_len;
    2084               0 :         long n = 0;
    2085                 :         WINDOW **win;
    2086                 : 
    2087               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rs|l", &handle, &str, &str_len, &n) == FAILURE) {
    2088               0 :                 return;
    2089                 :         }
    2090                 : 
    2091               0 :         FETCH_WINRES(win, &handle);
    2092               0 :         if (!n) {
    2093               0 :                 RETURN_LONG(waddstr(*win, str));
    2094                 :         } else {
    2095               0 :                 RETURN_LONG(waddnstr(*win, str, n));
    2096                 :         }
    2097                 : }
    2098                 : /* }}} */
    2099                 : 
    2100                 : /* {{{ proto int ncurses_wgetch(resource window)
    2101                 :    Reads a character from keyboard (window) */
    2102                 : PHP_FUNCTION(ncurses_wgetch)
    2103               0 : {
    2104                 :         zval *handle;
    2105                 :         WINDOW **win;
    2106                 : 
    2107               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &handle) == FAILURE) {
    2108               0 :                 return;
    2109                 :         }
    2110                 : 
    2111               0 :         FETCH_WINRES(win, &handle);
    2112                 : 
    2113               0 :         RETURN_LONG(wgetch(*win));
    2114                 : }
    2115                 : /* }}} */
    2116                 : 
    2117                 : /* {{{ proto int ncurses_wattroff(resource window, int attrs)
    2118                 :    Turns off attributes for a window */
    2119                 : PHP_FUNCTION(ncurses_wattroff)
    2120               0 : {
    2121                 :         zval *handle;
    2122                 :         WINDOW **win;
    2123                 :         long attrs;
    2124                 : 
    2125               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &handle, &attrs) == FAILURE) {
    2126               0 :                 return;
    2127                 :         }
    2128                 : 
    2129               0 :         FETCH_WINRES(win, &handle);
    2130                 : 
    2131               0 :         RETURN_LONG(wattroff(*win, attrs));
    2132                 : }
    2133                 : /* }}} */
    2134                 : 
    2135                 : /* {{{ proto int ncurses_wattron(resource window, int attrs)
    2136                 :    Turns on attributes for a window */
    2137                 : PHP_FUNCTION(ncurses_wattron)
    2138               0 : {
    2139                 :         zval *handle;
    2140                 :         WINDOW **win;
    2141                 :         long attrs;
    2142                 : 
    2143               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &handle, &attrs) == FAILURE) {
    2144               0 :                 return;
    2145                 :         }
    2146                 : 
    2147               0 :         FETCH_WINRES(win, &handle);
    2148                 : 
    2149               0 :         RETURN_LONG(wattron(*win, attrs));
    2150                 : }
    2151                 : /* }}} */
    2152                 : 
    2153                 : /* {{{ proto int ncurses_wattrset(resource window, int attrs)
    2154                 :    Set the attributes for a window */
    2155                 : PHP_FUNCTION(ncurses_wattrset)
    2156               0 : {
    2157                 :         zval *handle;
    2158                 :         WINDOW **win;
    2159                 :         long attrs;
    2160                 : 
    2161               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rl", &handle, &attrs) == FAILURE) {
    2162               0 :                 return;
    2163                 :         }
    2164                 : 
    2165               0 :         FETCH_WINRES(win, &handle);
    2166                 : 
    2167               0 :         RETURN_LONG(wattrset(*win, attrs));
    2168                 : }
    2169                 : /* }}} */
    2170                 : 
    2171                 : /* {{{ proto int ncurses_wstandend(resource window)
    2172                 :    End standout mode for a window */
    2173                 : PHP_FUNCTION(ncurses_wstandend)
    2174               0 : {
    2175                 :         zval *handle;
    2176                 :         WINDOW **win;
    2177                 : 
    2178               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &handle) == FAILURE) {
    2179               0 :                 return;
    2180                 :         }
    2181                 : 
    2182               0 :         FETCH_WINRES(win, &handle);
    2183                 : 
    2184               0 :         RETURN_LONG(wstandend(*win));
    2185                 : }
    2186                 : /* }}} */
    2187                 : 
    2188                 : /* {{{ proto int ncurses_wstandout(resource window)
    2189                 :    Enter standout mode for a window */
    2190                 : PHP_FUNCTION(ncurses_wstandout)
    2191               0 : {
    2192                 :         zval *handle;
    2193                 :         WINDOW **win;
    2194                 : 
    2195               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &handle) == FAILURE) {
    2196               0 :                 return;
    2197                 :         }
    2198                 : 
    2199               0 :         FETCH_WINRES(win, &handle);
    2200                 : 
    2201               0 :         RETURN_LONG(wstandout(*win));
    2202                 : }
    2203                 : /* }}} */
    2204                 : 
    2205                 : #if HAVE_NCURSES_PANEL
    2206                 : /* {{{ proto resource ncurses_new_panel(resource window)
    2207                 :    Create a new panel and associate it with window */
    2208                 : PHP_FUNCTION(ncurses_new_panel)
    2209               0 : {
    2210                 :         zval *handle;
    2211                 :         WINDOW **win;
    2212                 :         PANEL **panel;
    2213                 : 
    2214               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &handle) == FAILURE) {
    2215               0 :                 return;
    2216                 :         }
    2217                 : 
    2218               0 :         FETCH_WINRES(win, &handle);
    2219                 : 
    2220               0 :         panel = (PANEL **)emalloc(sizeof(PANEL *));
    2221               0 :         *panel = new_panel(*win);
    2222                 : 
    2223               0 :         if (*panel == NULL) {
    2224               0 :                 efree(panel);
    2225               0 :                 RETURN_FALSE;
    2226                 :         } else {
    2227               0 :                 long id = ZEND_REGISTER_RESOURCE(return_value, panel, le_ncurses_panels);
    2228               0 :                 set_panel_userptr(*panel, (void*)id);
    2229                 :         }
    2230                 : 
    2231                 : }
    2232                 : /* }}} */
    2233                 : 
    2234                 : /* {{{ proto bool ncurses_del_panel(resource panel)
    2235                 :    Remove panel from the stack and delete it (but not the associated window) */
    2236                 : PHP_FUNCTION(ncurses_del_panel)
    2237               0 : {
    2238                 :         zval *handle;
    2239                 : 
    2240               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &handle) == FAILURE) {
    2241               0 :                 return;
    2242                 :         }
    2243               0 :         zend_list_delete(Z_RESVAL_P(handle));
    2244                 : 
    2245               0 :         RETURN_TRUE;
    2246                 : }
    2247                 : /* }}} */
    2248                 : 
    2249                 : /* {{{ proto int ncurses_hide_panel(resource panel)
    2250                 :    Remove panel from the stack, making it invisible */
    2251                 : PHP_FUNCTION(ncurses_hide_panel)
    2252               0 : {
    2253                 :         zval *handle;
    2254                 :         PANEL **panel;
    2255                 : 
    2256               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &handle) == FAILURE) {
    2257               0 :                 return;
    2258                 :         }
    2259                 :         
    2260               0 :         FETCH_PANEL(panel, &handle);
    2261                 : 
    2262               0 :         RETURN_LONG(hide_panel(*panel));
    2263                 : 
    2264                 : }
    2265                 : /* }}} */
    2266                 : 
    2267                 : /* {{{ proto int ncurses_show_panel(resource panel)
    2268                 :    Places an invisible panel on top of the stack, making it visible */
    2269                 : PHP_FUNCTION(ncurses_show_panel)
    2270               0 : {
    2271                 :         zval *handle;
    2272                 :         PANEL **panel;
    2273                 : 
    2274               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &handle) == FAILURE) {
    2275               0 :                 return;
    2276                 :         }
    2277                 : 
    2278               0 :         FETCH_PANEL(panel, &handle);
    2279                 : 
    2280               0 :         RETURN_LONG(show_panel(*panel));
    2281                 : 
    2282                 : }
    2283                 : /* }}} */
    2284                 : 
    2285                 : /* {{{ proto int ncurses_top_panel(resource panel)
    2286                 :    Moves a visible panel to the top of the stack */
    2287                 : PHP_FUNCTION(ncurses_top_panel)
    2288               0 : {
    2289                 :         zval *handle;
    2290                 :         PANEL **panel;
    2291                 : 
    2292               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &handle) == FAILURE) {
    2293               0 :                 return;
    2294                 :         }
    2295                 : 
    2296               0 :         FETCH_PANEL(panel, &handle);
    2297                 : 
    2298               0 :         RETURN_LONG(top_panel(*panel));
    2299                 : 
    2300                 : }
    2301                 : /* }}} */
    2302                 : 
    2303                 : /* {{{ proto int ncurses_bottom_panel(resource panel)
    2304                 :    Moves a visible panel to the bottom of the stack */
    2305                 : PHP_FUNCTION(ncurses_bottom_panel)
    2306               0 : {
    2307                 :         zval *handle;
    2308                 :         PANEL **panel;
    2309                 : 
    2310               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &handle) == FAILURE) {
    2311               0 :                 return;
    2312                 :         }
    2313                 : 
    2314               0 :         FETCH_PANEL(panel, &handle);
    2315                 : 
    2316               0 :         RETURN_LONG(bottom_panel(*panel));
    2317                 : 
    2318                 : }
    2319                 : /* }}} */
    2320                 : 
    2321                 : /* {{{ proto int ncurses_move_panel(resource panel, int startx, int starty)
    2322                 :    Moves a panel so that it's upper-left corner is at [startx, starty] */
    2323                 : PHP_FUNCTION(ncurses_move_panel)
    2324               0 : {
    2325                 :         zval *handle;
    2326                 :         PANEL **panel;
    2327                 :         long startx, starty;
    2328                 : 
    2329               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rll", &handle, &startx, &starty) == FAILURE) {
    2330               0 :                 return;
    2331                 :         }
    2332                 : 
    2333               0 :         FETCH_PANEL(panel, &handle);
    2334                 : 
    2335               0 :         RETURN_LONG(move_panel(*panel, startx, starty));
    2336                 : 
    2337                 : }
    2338                 : /* }}} */
    2339                 : 
    2340                 : /* {{{ proto int ncurses_replace_panel(resource panel, resource window)
    2341                 :    Replaces the window associated with panel */
    2342                 : PHP_FUNCTION(ncurses_replace_panel)
    2343               0 : {
    2344                 :         zval *phandle, *whandle;
    2345                 :         PANEL **panel;
    2346                 :         WINDOW **window;
    2347                 : 
    2348               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "rr", &phandle, &whandle) == FAILURE) {
    2349               0 :                 return;
    2350                 :         }
    2351                 : 
    2352               0 :         FETCH_PANEL(panel, &phandle);
    2353               0 :         FETCH_WINRES(window, &whandle);
    2354                 : 
    2355               0 :         RETURN_LONG(replace_panel(*panel, *window));
    2356                 : 
    2357                 : }
    2358                 : /* }}} */
    2359                 : 
    2360                 : /* {{{ proto resource ncurses_panel_above(resource panel)
    2361                 :    Returns the panel above panel. If panel is null, returns the bottom panel in the stack */
    2362                 : PHP_FUNCTION(ncurses_panel_above)
    2363               0 : {
    2364               0 :         zval *phandle = NULL;
    2365                 :         PANEL **panel;
    2366                 :         PANEL *above;
    2367                 : 
    2368               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r!", &phandle) == FAILURE) {
    2369               0 :                 return;
    2370                 :         }
    2371                 : 
    2372               0 :         if (phandle) {
    2373               0 :                 FETCH_PANEL(panel, &phandle);
    2374               0 :                 above = panel_above(*panel);
    2375                 :         } else {
    2376               0 :                 IS_NCURSES_INITIALIZED();
    2377               0 :                 above = panel_above((PANEL *)0);
    2378                 :         }
    2379                 : 
    2380               0 :         if (above) {
    2381               0 :                 long id = (long)panel_userptr(above);
    2382               0 :                 zend_list_addref(id);
    2383               0 :                 RETURN_RESOURCE(id);
    2384                 :         } else {
    2385               0 :                 RETURN_FALSE;
    2386                 :         }
    2387                 : }
    2388                 : /* }}} */
    2389                 : 
    2390                 : /* {{{ proto resource ncurses_panel_below(resource panel)
    2391                 :    Returns the panel below panel. If panel is null, returns the top panel in the stack */
    2392                 : PHP_FUNCTION(ncurses_panel_below)
    2393               0 : {
    2394               0 :         zval *phandle = NULL;
    2395                 :         PANEL **panel;
    2396                 :         PANEL *below;
    2397                 : 
    2398               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r!", &phandle) == FAILURE) {
    2399               0 :                 return;
    2400                 :         }
    2401                 : 
    2402               0 :         if (phandle) {
    2403               0 :                 FETCH_PANEL(panel, &phandle);
    2404               0 :                 below = panel_below(*panel);
    2405                 :         } else {
    2406               0 :                 below = panel_below((PANEL *)0);
    2407                 :         }
    2408               0 :         if (below) {
    2409               0 :                 long id = (long)panel_userptr(below);
    2410               0 :                 zend_list_addref(id);
    2411               0 :                 RETURN_RESOURCE(id);
    2412                 :         } else {
    2413               0 :                 RETURN_FALSE;
    2414                 :         }
    2415                 : }
    2416                 : /* }}} */
    2417                 : 
    2418                 : /* {{{ proto resource ncurses_panel_window(resource panel)
    2419                 :    Returns the window associated with panel */
    2420                 : PHP_FUNCTION(ncurses_panel_window)
    2421               0 : {
    2422               0 :         zval *phandle = NULL;
    2423                 :         PANEL **panel;
    2424                 :         WINDOW **win;
    2425                 : 
    2426               0 :         if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "r", &phandle) == FAILURE) {
    2427               0 :                 return;
    2428                 :         }
    2429                 : 
    2430               0 :         FETCH_PANEL(panel, &phandle);
    2431                 : 
    2432               0 :         win = (WINDOW **)emalloc(sizeof(WINDOW *));
    2433               0 :         *win = panel_window(*panel);
    2434                 : 
    2435               0 :         if (*win == NULL) {
    2436               0 :                 efree(win);
    2437               0 :                 RETURN_FALSE;
    2438                 :         }
    2439               0 :         ZEND_REGISTER_RESOURCE(return_value, win, le_ncurses_windows);
    2440                 : }
    2441                 : /* }}} */
    2442                 : 
    2443                 : /* {{{ proto void ncurses_update_panels(void)
    2444                 :    Refreshes the virtual screen to reflect the relations between panels in the stack. */
    2445                 : PHP_FUNCTION(ncurses_update_panels)
    2446               0 : {
    2447               0 :         IS_NCURSES_INITIALIZED();
    2448               0 :         update_panels();
    2449                 : }
    2450                 : /* }}} */
    2451                 : #endif /* HAVE_NCURSES_PANEL */
    2452                 : 
    2453                 : /*
    2454                 :  * Local variables:
    2455                 :  * tab-width: 4
    2456                 :  * c-basic-offset: 4
    2457                 :  * End:
    2458                 :  * vim600: sw=4 ts=4 fdm=marker
    2459                 :  * vim<600: sw=4 ts=4
    2460                 :  */

Generated by: LTP GCOV extension version 1.5

Generated at Thu, 19 Nov 2009 08:20:13 +0000 (5 days ago)

Copyright © 2005-2009 The PHP Group
All rights reserved.