--- /dev/null
+ncurses
+Hartmut Holzgraefe
--- /dev/null
+# $Id$
+
+LTLIBRARY_NAME = libncurses.la
+LTLIBRARY_SOURCES = ncurses.c ncurses_fe.c ncurses_functions.c
+LTLIBRARY_SHARED_NAME = ncurses.la
+LTLIBRARY_SHARED_LIBADD = $(NCURSES_SHARED_LIBADD)
+
+include $(top_srcdir)/build/dynlib.mk
--- /dev/null
+int addch(int);
+int addchnstr(int *, int);
+int addchstr(int *);
+int addnstr(string, int);
+int addstr(string);
+int assume_default_colors (int, int);
+int attr_get(int *, int *, void *);
+int attr_off(int, void *);
+int attr_on(int, void *);
+int attr_set(int, int, void *);
+int attroff(int);
+int attron(int);
+int attrset(int);
+int baudrate(void);
+int beep(void);
+int bkgd(int);
+void bkgdset(int);
+int border(int,int,int,int,int,int,int,int);
+int box(resource, int, int);
+bool can_change_color(void);
+int cbreak(void);
+int chgat(int, int, int, void *);
+int clear(void);
+int clearok(resource,bool);
+int clrtobot(void);
+int clrtoeol(void);
+int color_content(int,int*,int*,int*);
+int color_set(int,void*);
+int copywin(resource,resource,int,int,int,int,int,int,int);
+int curs_set(int);
+int def_prog_mode(void);
+int def_shell_mode(void);
+int define_key (string, int);
+int delay_output(int);
+int delch(void);
+int deleteln(void);
+void delscreen(SCREEN *);
+int delwin(resource);
+int doupdate(void);
+int echo(void);
+int echochar(int);
+int endwin(void);
+int erase(void);
+char erasechar(void);
+void filter(void);
+int flash(void);
+int flushinp(void);
+int getbkgd(resource);
+int getch(void);
+int getmouse(MEVENT *);
+int getnstr(string, int);
+int getstr(string);
+int halfdelay(int);
+bool has_colors(void);
+bool has_ic(void);
+bool has_il(void);
+int has_key(int); /* do we have given key? */
+int hline(int, int);
+void idcok(resource, bool);
+int idlok(resource, bool);
+void immedok(resource, bool);
+int inch(void);
+int inchnstr(int *, int);
+int inchstr(int *);
+int init_color(int,int,int,int);
+int init_pair(int,int,int);
+int innstr(string, int);
+int insch(int);
+int insdelln(int);
+int insertln(void);
+int insnstr(string, int);
+int insstr(string);
+int instr(string);
+int intrflush(resource,bool);
+bool is_linetouched(resource,int);
+bool is_wintouched(resource);
+bool isendwin(void);
+int keyok (int, bool);
+int keypad(resource,bool);
+char killchar(void);
+int leaveok(resource,bool);
+int mcprint(string, int); /* direct data to printer */
+int meta(resource,bool);
+int mouseinterval(int);
+mmask_t mousemask(mmask_t, mmask_t *);
+int move(int, int);
+int mvaddch(int, int, int);
+int mvaddchnstr(int, int, int *, int);
+int mvaddchstr(int, int, int *);
+int mvaddnstr(int, int, string, int);
+int mvaddstr(int, int, string);
+int mvchgat(int, int, int, int, int, void *);
+int mvcur(int,int,int,int);
+int mvdelch(int, int);
+int mvderwin(resource, int, int);
+int mvgetch(int, int);
+int mvgetnstr(int, int, string, int);
+int mvgetstr(int, int, string);
+int mvhline(int, int, int, int);
+int mvinch(int, int);
+int mvinchnstr(int, int, int *, int);
+int mvinchstr(int, int, int *);
+int mvinnstr(int, int, string, int);
+int mvinsch(int, int, int);
+int mvinsnstr(int, int, string, int);
+int mvinsstr(int, int, string);
+int mvinstr(int, int, string);
+int mvprintw(int,int, string,...);
+int mvscanw(int,int, string,...);
+int mvwaddch(resource, int, int, int);
+int mvwaddchnstr(resource, int, int, int *, int);
+int mvwaddchstr(resource, int, int, int *);
+int mvwaddnstr(resource, int, int, string, int);
+int mvwaddstr(resource, int, int, string);
+int mvwchgat(resource, int, int, int, int, int, void *);
+int mvwdelch(resource, int, int);
+int mvwgetch(resource, int, int);
+int mvwgetnstr(resource, int, int, string, int);
+int mvwgetstr(resource, int, int, string);
+int mvwhline(resource, int, int, int, int);
+int mvwin(resource,int,int);
+int mvwinch(resource, int, int);
+int mvwinchstr(resource, int, int, int *);
+int mvwinnstr(resource, int, int, string, int);
+int mvwinsch(resource, int, int, int);
+int mvwinsnstr(resource, int, int, string, int);
+int mvwinsstr(resource, int, int, string);
+int mvwinstr(resource, int, int, string);
+int mvwinchnstr(resource, int, int, int *, int);
+int mvwprintw(resource,int,int, string,...);
+int mvwscanw(resource,int,int, string,...);
+int mvwvline(resource,int, int, int, int);
+int napms(int);
+int nl(void);
+int nocbreak(void);
+int nodelay(resource,bool);
+int noecho(void);
+int nonl(void);
+void noqiflush(void);
+int noraw(void);
+int notimeout(resource,bool);
+int overlay(resource,resource);
+int overwrite(resource,resource);
+int pair_content(int,int*,int*);
+int pechochar(resource, int);
+int pnoutrefresh(resource,int,int,int,int,int,int);
+int prefresh(resource,int,int,int,int,int,int);
+int printw( string,...);
+int putp(string);
+int putwin(resource, FILE *);
+void qiflush(void);
+int raw(void);
+int redrawwin(resource);
+int refresh(void);
+int reset_prog_mode(void);
+int reset_shell_mode(void);
+int resetty(void);
+int resizeterm (int, int);
+int ripoffline(int, int (*init)(resource, int));
+int savetty(void);
+int scanw( string,...);
+int scr_dump(string);
+int scr_init(string);
+int scr_restore(string);
+int scr_set(string);
+int scrl(int);
+int scroll(resource);
+int scrollok(resource,bool);
+int setscrreg(int,int);
+int slk_attroff(int);
+int slk_attr_off(int, void *); /* generated:WIDEC */
+int slk_attron(int);
+int slk_attr_on(int,void*); /* generated:WIDEC */
+int slk_attrset(int);
+int slk_attr(void);
+int slk_attr_set(int,int,void*);
+int slk_clear(void);
+int slk_color(int);
+int slk_init(int);
+int slk_noutrefresh(void);
+int slk_refresh(void);
+int slk_restore(void);
+int slk_set(int,string,int);
+int slk_touch(void);
+int standend(void);
+int standout(void);
+int start_color(void);
+int syncok(resource, bool);
+int termattrs(void);
+int tigetflag( string);
+int tigetnum( string);
+void timeout(int);
+int typeahead(int);
+int ungetch(int);
+int ungetmouse(MEVENT *);
+int untouchwin(resource);
+int use_default_colors (void);
+void use_env(bool);
+int use_extended_names (bool);
+int vidattr(int);
+int vidputs(int, int (*)(int));
+int vline(int, int);
+int vw_printw(resource, string,va_list);
+int vw_scanw(resource, string,va_list);
+int vwprintw(resource, string,va_list);
+int vwscanw(resource, string,va_list);
+int waddch(resource, int);
+int waddchnstr(resource,int *const,int);
+int waddchstr(resource,int *);
+int waddnstr(resource,stringconst,int);
+int waddstr(resource,string);
+int wattr_get(resource, int *, int *, void *);
+int wattr_off(resource, int, void *);
+int wattr_on(resource, int, void *);
+int wattr_set(resource, int, int, void *);
+int wattroff(resource, int);
+int wattron(resource, int);
+int wattrset(resource, int);
+int wbkgd(resource,int);
+void wbkgdset(resource,int);
+int wborder(resource,int,int,int,int,int,int,int,int);
+int wchgat(resource, int, int, int, void *);
+int wclear(resource);
+int wclrtobot(resource);
+int wclrtoeol(resource);
+int wcolor_set(resource,int,void*);
+void wcursyncup(resource);
+int wdelch(resource);
+int wdeleteln(resource);
+int wechochar(resource, int);
+bool wenclose(resource, int, int);
+int werase(resource);
+int wgetch(resource);
+int wgetnstr(resource,string,int);
+int wgetstr(resource, string);
+int whline(resource, int, int);
+int winch(resource);
+int winchnstr(resource, int *, int);
+int winchstr(resource, int *);
+int winnstr(resource, string, int);
+int winsch(resource, int);
+int winsdelln(resource,int);
+int winsertln(resource);
+int winsnstr(resource, string,int);
+int winsstr(resource, string);
+int winstr(resource, string);
+bool wmouse_trafo(resource win,int* y, int* x, bool to_screen);
+int wmove(resource,int,int);
+int wnoutrefresh(resource);
+int wprintw(resource, string,...);
+int wredrawln(resource,int,int);
+int wrefresh(resource);
+int wresize (resource, int, int);
+int wscanw(resource, string,...);
+int wscrl(resource,int);
+int wsetscrreg(resource,int,int);
+int wstandend(resource);
+int wstandout(resource);
+void wsyncdown(resource);
+void wsyncup(resource);
+void wtimeout(resource,int);
+int wtouchln(resource,int,int,int);
+int wvline(resource,int,int);
--- /dev/null
+dnl $Id$
+dnl config.m4 for extension ncurses
+
+PHP_ARG_WITH(ncurses, for ncurses support,
+[ --with-ncurses Include ncurses support])
+
+if test "$PHP_NCURSES" != "no"; then
+ # --with-ncurses -> check with-path
+ SEARCH_PATH="/usr/local /usr"
+ SEARCH_FOR="/include/curses.h"
+ if test -r $PHP_NCURSES/; then # path given as parameter
+ NCURSES_DIR=$PHP_NCURSES
+ else # search default path list
+ AC_MSG_CHECKING(for ncurses files in default path)
+ for i in $SEARCH_PATH ; do
+ if test -r $i/$SEARCH_FOR; then
+ NCURSES_DIR=$i
+ AC_MSG_RESULT(found in $i)
+ fi
+ done
+ fi
+
+ if test -z "$NCURSES_DIR"; then
+ AC_MSG_RESULT(not found)
+ AC_MSG_ERROR(Please reinstall the ncurses distribution)
+ fi
+
+ # --with-ncurses -> add include path
+ PHP_ADD_INCLUDE($NCURSES_DIR/include)
+
+ # --with-ncurses -> chech for lib and symbol presence
+ LIBNAME=ncurses
+ LIBSYMBOL=initscr
+ old_LIBS=$LIBS
+ LIBS="$LIBS -L$NCURSES_DIR/lib -lm -ldl"
+ AC_CHECK_LIB($LIBNAME, $LIBSYMBOL, [AC_DEFINE(HAVE_NCURSESLIB,1,[ ])],
+ [AC_MSG_ERROR(wrong ncurses lib version or lib not found)])
+ LIBS=$old_LIBS
+
+ PHP_SUBST(NCURSES_SHARED_LIBADD)
+ PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $NCURSES_DIR/lib, SAPRFC_SHARED_LIBADD)
+
+ PHP_EXTENSION(ncurses, $ext_shared)
+fi
--- /dev/null
+<?php
+$n=0;
+ncurses_init();
+if(ncurses_has_colors()){
+ncurses_start_color();
+ ncurses_init_pair(1,NCURSES_COLOR_RED,NCURSES_COLOR_BLACK);
+ ncurses_init_pair(2,NCURSES_COLOR_GREEN,NCURSES_COLOR_BLACK);
+ ncurses_init_pair(3,NCURSES_COLOR_YELLOW,NCURSES_COLOR_BLACK);
+ ncurses_init_pair(4,NCURSES_COLOR_BLUE,NCURSES_COLOR_BLACK);
+ ncurses_init_pair(5,NCURSES_COLOR_MAGENTA,NCURSES_COLOR_BLACK);
+ ncurses_init_pair(6,NCURSES_COLOR_CYAN,NCURSES_COLOR_BLACK);
+ ncurses_init_pair(7,NCURSES_COLOR_WHITE,NCURSES_COLOR_BLACK);
+}
+while(1){
+for ($x=0; $x<80; $x++) {
+for ($y=0; $y<24; $y++) {
+ $n++;
+ ncurses_move($y,$x);
+ ncurses_addch($n+64);
+ ncurses_color_set($n%8);
+ ncurses_refresh();
+ if($n>26)$n=0;
+}
+}
+}
+ncurses_getch();
+?>
+
--- /dev/null
+/*
+ +----------------------------------------------------------------------+
+ | PHP version 4.0 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 2.02 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available at through the world-wide-web at |
+ | http://www.php.net/license/2_02.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Hartmut Holzgraefe <hartmut@six.de> |
+ | |
+ +----------------------------------------------------------------------+
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "php_ini.h"
+#include "php_ncurses.h"
+
+/* If you declare any globals in php_ncurses.h uncomment this:
+ZEND_DECLARE_MODULE_GLOBALS(ncurses)
+*/
+
+/* True global resources - no need for thread safety here */
+int le_ncurses;
+
+
+static void ncurses_destruct(zend_rsrc_list_entry *rsrc) {
+ WINDOW **pwin = (WINDOW **)rsrc->ptr;
+
+ delwin(*pwin);
+ efree(pwin);
+}
+
+
+/* {{{ ncurses_module_entry
+ */
+zend_module_entry ncurses_module_entry = {
+ "ncurses",
+ ncurses_functions,
+ PHP_MINIT(ncurses),
+ PHP_MSHUTDOWN(ncurses),
+ PHP_RINIT(ncurses), /* Replace with NULL if there's nothing to do at request start */
+ PHP_RSHUTDOWN(ncurses), /* Replace with NULL if there's nothing to do at request end */
+ PHP_MINFO(ncurses),
+ STANDARD_MODULE_PROPERTIES
+};
+/* }}} */
+
+#ifdef COMPILE_DL_NCURSES
+ZEND_GET_MODULE(ncurses)
+#endif
+
+/* {{{ PHP_INI
+ */
+/* Remove comments and fill if you need to have entries in php.ini
+PHP_INI_BEGIN()
+ STD_PHP_INI_ENTRY("ncurses.value", "42", PHP_INI_ALL, OnUpdateInt, global_value, zend_ncurses_globals, ncurses_globals)
+ STD_PHP_INI_ENTRY("ncurses.string", "foobar", PHP_INI_ALL, OnUpdateString, global_string, zend_ncurses_globals, ncurses_globals)
+PHP_INI_END()
+*/
+/* }}} */
+
+#define PHP_NCURSES_CONST(x) REGISTER_LONG_CONSTANT("NCURSES_"#x, x, CONST_CS | CONST_PERSISTENT)
+
+/* {{{ PHP_MINIT_FUNCTION
+ */
+PHP_MINIT_FUNCTION(ncurses)
+{
+/* Remove comments if you have entries in php.ini
+ REGISTER_INI_ENTRIES();
+*/
+
+ PHP_NCURSES_CONST(COLOR_BLACK);
+ PHP_NCURSES_CONST(COLOR_RED);
+ PHP_NCURSES_CONST(COLOR_GREEN);
+ PHP_NCURSES_CONST(COLOR_YELLOW);
+ PHP_NCURSES_CONST(COLOR_BLUE);
+ PHP_NCURSES_CONST(COLOR_MAGENTA);
+ PHP_NCURSES_CONST(COLOR_CYAN);
+ PHP_NCURSES_CONST(COLOR_WHITE);
+
+ le_ncurses = zend_register_list_destructors_ex(ncurses_destruct, NULL, "ncurses_hanlde", module_number);
+
+ return SUCCESS;
+}
+/* }}} */
+
+/* {{{ PHP_MSHUTDOWN_FUNCTION
+ */
+PHP_MSHUTDOWN_FUNCTION(ncurses)
+{
+/* Remove comments if you have entries in php.ini
+ UNREGISTER_INI_ENTRIES();
+ endwin();
+*/
+
+ return SUCCESS;
+}
+/* }}} */
+
+/* Remove if there's nothing to do at request start */
+/* {{{ PHP_RINIT_FUNCTION
+ */
+PHP_RINIT_FUNCTION(ncurses)
+{
+ return SUCCESS;
+}
+/* }}} */
+
+/* Remove if there's nothing to do at request end */
+/* {{{ PHP_RSHUTDOWN_FUNCTION
+ */
+PHP_RSHUTDOWN_FUNCTION(ncurses)
+{
+ return SUCCESS;
+}
+/* }}} */
+
+/* {{{ PHP_MINFO_FUNCTION
+ */
+PHP_MINFO_FUNCTION(ncurses)
+{
+ php_info_print_table_start();
+ php_info_print_table_header(2, "ncurses support", "enabled");
+ php_info_print_table_end();
+
+ /* Remove comments if you have entries in php.ini
+ DISPLAY_INI_ENTRIES();
+ */
+}
+/* }}} */
+
+/* Remove the following function when you have succesfully modified config.m4
+ so that your module can be compiled into PHP, it exists only for testing
+ purposes. */
+
+/* Every user-visible function in PHP should document itself in the source */
+/* {{{ proto string confirm_ncurses_compiled(string arg)
+ Return a string to confirm that the module is compiled in */
+PHP_FUNCTION(confirm_ncurses_compiled)
+{
+ zval **arg;
+ int len;
+ char string[256];
+
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &arg) == FAILURE) {
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_string_ex(arg);
+
+ len = sprintf(string, "Congratulations! You have successfully modified ext/%.78s/config.m4. Module %.78s is now compiled into PHP.", "ncurses", Z_STRVAL_PP(arg));
+ RETURN_STRINGL(string, len, 1);
+}
+/* }}} */
+/* The previous line is meant for vim and emacs, so it can correctly fold and
+ unfold functions in source code. See the corresponding marks just before
+ function definition, where the functions purpose is also documented. Please
+ follow this convention for the convenience of others editing your code.
+*/
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * End:
+ * vim600: sw=4 ts=4 tw=78 fdm=marker
+ * vim<600: sw=4 ts=4 tw=78
+ */
--- /dev/null
+<?
+$module = 'ncurses';
+$function = 'confirm_' . $module . '_compiled';
+if (extension_loaded($module)) {
+ $str = $function($module);
+} else {
+ $str = "Module $module is not compiled into PHP";
+}
+echo "$str\n";
+?>
--- /dev/null
+/*
+ +----------------------------------------------------------------------+
+ | PHP version 4.0 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 2.02 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available at through the world-wide-web at |
+ | http://www.php.net/license/2_02.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Hartmut Holzgraefe <hartmut@six.de> |
+ | |
+ +----------------------------------------------------------------------+
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "php_ini.h"
+#include "php_ncurses.h"
+
+/* ncurses_functions[]
+ *
+ * Every user visible function must have an entry in ncurses_functions[].
+ */
+function_entry ncurses_functions[] = {
+ PHP_FE(confirm_ncurses_compiled, NULL) /* For testing, remove later. */
+ PHP_FE(ncurses_init, NULL)
+ PHP_FE(ncurses_end, NULL)
+ PHP_FE(ncurses_getch, NULL)
+ PHP_FE(ncurses_move, NULL)
+ PHP_FE(ncurses_addch, NULL)
+ PHP_FE(ncurses_refresh, NULL)
+ PHP_FE(ncurses_has_colors, NULL)
+ PHP_FE(ncurses_start_color, NULL)
+ PHP_FE(ncurses_color_set, NULL)
+ PHP_FE(ncurses_init_pair, NULL)
+ PHP_FE(ncurses_newwin, NULL)
+ PHP_FE(ncurses_delwin, NULL)
+ {NULL, NULL, NULL} /* Must be the last line in ncurses_functions[] */
+};
--- /dev/null
+/*
+ +----------------------------------------------------------------------+
+ | PHP version 4.0 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 2.02 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available at through the world-wide-web at |
+ | http://www.php.net/license/2_02.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Hartmut Holzgraefe <hartmut@six.de> |
+ | |
+ +----------------------------------------------------------------------+
+ */
+
+#ifdef HAVE_CONFIG_H
+#include "config.h"
+#endif
+
+#include "php.h"
+#include "php_ini.h"
+#include "php_ncurses.h"
+
+/* {{{ proto int ncurses_addch(int ch)
+ */
+PHP_FUNCTION(ncurses_addch)
+{
+ zval **ch;
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &ch) == FAILURE){
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_long_ex(ch);
+
+ RETURN_LONG(addch(_INT(ch)));
+}
+/* }}} */
+
+/* {{{ proto int ncurses_color_set(int pair)
+ */
+PHP_FUNCTION(ncurses_color_set)
+{
+ zval **pair;
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &pair) == FAILURE){
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_long_ex(pair);
+
+ RETURN_LONG(color_set(_INT(pair),NULL));
+}
+/* }}} */
+
+/* {{{ proto int ncurses_newwin(int ch)
+ */
+PHP_FUNCTION(ncurses_delwin)
+{
+ zval **handle;
+ if (ZEND_NUM_ARGS() != 1 || zend_get_parameters_ex(1, &handle) == FAILURE){
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_long_ex(handle);
+
+ /* TODO resource type check */
+
+ zend_list_delete((*handle)->value.lval);
+}
+/* }}} */
+
+/* {{{ proto int ncurses_end()
+ */
+PHP_FUNCTION(ncurses_end)
+{
+ RETURN_LONG(endwin()); /* endialize the curses library */
+}
+/* }}} */
+
+/* {{{ proto int ncurses_getch()
+ */
+PHP_FUNCTION(ncurses_getch)
+{
+ RETURN_LONG(getch());
+}
+/* }}} */
+
+/* {{{ proto int ncurses_has_colors()
+ */
+PHP_FUNCTION(ncurses_has_colors)
+{
+ RETURN_LONG(has_colors());
+}
+/* }}} */
+
+/* {{{ proto int ncurses_init()
+ */
+PHP_FUNCTION(ncurses_init)
+{
+ initscr(); /* initialize the curses library */
+ keypad(stdscr, TRUE); /* enable keyboard mapping */
+ (void) nonl(); /* tell curses not to do NL->CR/NL on output */
+ (void) cbreak(); /* take input chars one at a time, no wait for \n */}
+/* }}} */
+
+/* {{{ proto int ncurses_init_pair(int pair, int fg, int bg)
+ */
+PHP_FUNCTION(ncurses_init_pair)
+{
+ zval **pair, **fg, **bg;
+ if (ZEND_NUM_ARGS() != 3 || zend_get_parameters_ex(3, &pair, &fg, &bg) == FAILURE){
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_long_ex(pair);
+ convert_to_long_ex(fg);
+ convert_to_long_ex(bg);
+
+ RETURN_LONG(init_pair(_INT(pair),_INT(fg),_INT(bg)));
+}
+/* }}} */
+
+/* {{{ proto int ncurses_move(int x, int y)
+ */
+PHP_FUNCTION(ncurses_move)
+{
+ zval **x, **y;
+ if (ZEND_NUM_ARGS() != 2 || zend_get_parameters_ex(2, &x, &y) == FAILURE){
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_long_ex(x);
+ convert_to_long_ex(y);
+
+ RETURN_LONG(move(_INT(x),_INT(y)));
+}
+/* }}} */
+
+/* {{{ proto int ncurses_newwin(int ch)
+ */
+PHP_FUNCTION(ncurses_newwin)
+{
+ zval **rows,**cols,**y,**x;
+ WINDOW **pwin = (WINDOW **)emalloc(sizeof(WINDOW *));
+
+ if (ZEND_NUM_ARGS() != 4 || zend_get_parameters_ex(4, &rows,&cols,&y,&x) == FAILURE){
+ WRONG_PARAM_COUNT;
+ }
+
+ convert_to_long_ex(rows);
+ convert_to_long_ex(cols);
+ convert_to_long_ex(y);
+ convert_to_long_ex(x);
+
+ *pwin=newwin(_INT(rows),_INT(cols),_INT(y),_INT(x));
+
+ if(!*pwin) {
+ efree(pwin);
+ RETURN_FALSE;
+ }
+
+ ZEND_REGISTER_RESOURCE(return_value, pwin, le_ncurses);
+}
+/* }}} */
+
+/* {{{ proto int ncurses_refresh(int ch)
+ */
+PHP_FUNCTION(ncurses_refresh)
+{
+ RETURN_LONG(refresh());
+}
+/* }}} */
+
+/* {{{ proto int ncurses_start_color()
+ */
+PHP_FUNCTION(ncurses_start_color)
+{
+ RETURN_LONG(start_color());
+}
+/* }}} */
--- /dev/null
+/*
+ +----------------------------------------------------------------------+
+ | PHP version 4.0 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 2.02 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available at through the world-wide-web at |
+ | http://www.php.net/license/2_02.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Hartmut Holzgraefe <hartmut@six.de> |
+ | |
+ +----------------------------------------------------------------------+
+ */
+
+#ifndef PHP_NCURSES_H
+#define PHP_NCURSES_H
+
+#include <curses.h>
+
+#define _STRING(x) ((*x)->value.str.val)
+#define _INT(x) ((*x)->value.lval)
+#define _HASH(x) ((*x)->value.ht)
+
+extern int le_ncurses;
+
+extern zend_module_entry ncurses_module_entry;
+#define phpext_ncurses_ptr &ncurses_module_entry
+
+extern function_entry ncurses_functions[];
+#include "php_ncurses_fe.h"
+
+#ifdef PHP_WIN32
+#define PHP_NCURSES_API __declspec(dllexport)
+#else
+#define PHP_NCURSES_API
+#endif
+
+PHP_MINIT_FUNCTION(ncurses);
+PHP_MSHUTDOWN_FUNCTION(ncurses);
+PHP_RINIT_FUNCTION(ncurses);
+PHP_RSHUTDOWN_FUNCTION(ncurses);
+PHP_MINFO_FUNCTION(ncurses);
+
+/*
+ Declare any global variables you may need between the BEGIN
+ and END macros here:
+
+ZEND_BEGIN_MODULE_GLOBALS(ncurses)
+ int global_value;
+ char *global_string;
+ZEND_END_MODULE_GLOBALS(ncurses)
+*/
+
+/* In every function that needs to use variables in php_ncurses_globals,
+ do call NCURSES_LS_FETCH(); after declaring other variables used by
+ that function, and always refer to them as NCURSES_G(variable).
+ You are encouraged to rename these macros something shorter, see
+ examples in any other php module directory.
+*/
+
+#ifdef ZTS
+#define NCURSES_G(v) (ncurses_globals->v)
+#define NCURSES_LS_FETCH() zend_ncurses_globals *ncurses_globals = ts_resource(ncurses_globals_id)
+#else
+#define NCURSES_G(v) (ncurses_globals.v)
+#define NCURSES_LS_FETCH()
+#endif
+
+#endif /* PHP_NCURSES_H */
+
+
+/*
+ * Local variables:
+ * tab-width: 4
+ * c-basic-offset: 4
+ * indent-tabs-mode: t
+ * End:
+ */
--- /dev/null
+/*
+ +----------------------------------------------------------------------+
+ | PHP version 4.0 |
+ +----------------------------------------------------------------------+
+ | Copyright (c) 1997, 1998, 1999, 2000, 2001 The PHP Group |
+ +----------------------------------------------------------------------+
+ | This source file is subject to version 2.02 of the PHP license, |
+ | that is bundled with this package in the file LICENSE, and is |
+ | available at through the world-wide-web at |
+ | http://www.php.net/license/2_02.txt. |
+ | If you did not receive a copy of the PHP license and are unable to |
+ | obtain it through the world-wide-web, please send a note to |
+ | license@php.net so we can mail you a copy immediately. |
+ +----------------------------------------------------------------------+
+ | Authors: Hartmut Holzgraefe <hartmut@six.de> |
+ | |
+ +----------------------------------------------------------------------+
+ */
+
+#ifndef PHP_NCURSES_FE_H
+#define PHP_NCURSES_FE_H
+
+PHP_FUNCTION(confirm_ncurses_compiled); /* For testing, remove later. */
+PHP_FUNCTION(ncurses_init);
+PHP_FUNCTION(ncurses_end);
+PHP_FUNCTION(ncurses_getch);
+PHP_FUNCTION(ncurses_move);
+PHP_FUNCTION(ncurses_addch);
+PHP_FUNCTION(ncurses_refresh);
+PHP_FUNCTION(ncurses_has_colors);
+PHP_FUNCTION(ncurses_start_color);
+PHP_FUNCTION(ncurses_color_set);
+PHP_FUNCTION(ncurses_init_pair);
+PHP_FUNCTION(ncurses_newwin);
+PHP_FUNCTION(ncurses_delwin);
+
+#endif
--- /dev/null
+--TEST--
+Check for ncurses presence
+--SKIPIF--
+<?php if (!extension_loaded("ncurses")) print "skip"; ?>
+--POST--
+--GET--
+--FILE--
+<?php
+echo "ncurses extension is available";
+/*
+ you can add regression tests for your extension here
+
+ the output of your test code has to be equal to the
+ text in the --EXPECT-- section below for the tests
+ to pass, differences between the output and the
+ expected text are interpreted as failure
+
+ see php4/tests/README for further information on
+ writing regression tests
+*/
+?>
+--EXPECT--
+ncurses extension is available
\ No newline at end of file