version 1.1.1.1, 2012/02/21 23:48:00
|
version 1.1.1.4, 2014/06/15 20:03:54
|
Line 2
|
Line 2
|
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| PHP Version 5 | |
| PHP Version 5 | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| Copyright (c) 1997-2012 The PHP Group | | | Copyright (c) 1997-2014 The PHP Group | |
+----------------------------------------------------------------------+ |
+----------------------------------------------------------------------+ |
| This source file is subject to version 3.01 of the PHP license, | |
| This source file is subject to version 3.01 of the PHP license, | |
| that is bundled with this package in the file LICENSE, and is | |
| that is bundled with this package in the file LICENSE, and is | |
Line 26
|
Line 26
|
|
|
#include "php.h" |
#include "php.h" |
#include "php_readline.h" |
#include "php_readline.h" |
|
#include "readline_cli.h" |
|
|
#if HAVE_LIBREADLINE || HAVE_LIBEDIT |
#if HAVE_LIBREADLINE || HAVE_LIBEDIT |
|
|
Line 66 static zval *_readline_completion = NULL;
|
Line 67 static zval *_readline_completion = NULL;
|
static zval _readline_array; |
static zval _readline_array; |
|
|
PHP_MINIT_FUNCTION(readline); |
PHP_MINIT_FUNCTION(readline); |
|
PHP_MSHUTDOWN_FUNCTION(readline); |
PHP_RSHUTDOWN_FUNCTION(readline); |
PHP_RSHUTDOWN_FUNCTION(readline); |
|
PHP_MINFO_FUNCTION(readline); |
|
|
/* }}} */ |
/* }}} */ |
|
|
Line 141 static const zend_function_entry php_readline_function
|
Line 144 static const zend_function_entry php_readline_function
|
PHP_FE(readline_callback_read_char, arginfo_readline_callback_read_char) |
PHP_FE(readline_callback_read_char, arginfo_readline_callback_read_char) |
PHP_FE(readline_callback_handler_remove, arginfo_readline_callback_handler_remove) |
PHP_FE(readline_callback_handler_remove, arginfo_readline_callback_handler_remove) |
PHP_FE(readline_redisplay, arginfo_readline_redisplay) |
PHP_FE(readline_redisplay, arginfo_readline_redisplay) |
|
#endif |
|
#if HAVE_RL_ON_NEW_LINE |
PHP_FE(readline_on_new_line, arginfo_readline_on_new_line) |
PHP_FE(readline_on_new_line, arginfo_readline_on_new_line) |
#endif |
#endif |
PHP_FE_END |
PHP_FE_END |
Line 151 zend_module_entry readline_module_entry = {
|
Line 156 zend_module_entry readline_module_entry = {
|
"readline", |
"readline", |
php_readline_functions, |
php_readline_functions, |
PHP_MINIT(readline), |
PHP_MINIT(readline), |
|
PHP_MSHUTDOWN(readline), |
NULL, |
NULL, |
NULL, |
|
PHP_RSHUTDOWN(readline), |
PHP_RSHUTDOWN(readline), |
NULL, | PHP_MINFO(readline), |
NO_VERSION_YET, | PHP_VERSION, |
STANDARD_MODULE_PROPERTIES |
STANDARD_MODULE_PROPERTIES |
}; |
}; |
|
|
Line 166 ZEND_GET_MODULE(readline)
|
Line 171 ZEND_GET_MODULE(readline)
|
PHP_MINIT_FUNCTION(readline) |
PHP_MINIT_FUNCTION(readline) |
{ |
{ |
using_history(); |
using_history(); |
return SUCCESS; | return PHP_MINIT(cli_readline)(INIT_FUNC_ARGS_PASSTHRU); |
} |
} |
|
|
|
PHP_MSHUTDOWN_FUNCTION(readline) |
|
{ |
|
return PHP_MSHUTDOWN(cli_readline)(SHUTDOWN_FUNC_ARGS_PASSTHRU); |
|
} |
|
|
PHP_RSHUTDOWN_FUNCTION(readline) |
PHP_RSHUTDOWN_FUNCTION(readline) |
{ |
{ |
if (_readline_completion) { |
if (_readline_completion) { |
Line 186 PHP_RSHUTDOWN_FUNCTION(readline)
|
Line 196 PHP_RSHUTDOWN_FUNCTION(readline)
|
return SUCCESS; |
return SUCCESS; |
} |
} |
|
|
|
PHP_MINFO_FUNCTION(readline) |
|
{ |
|
PHP_MINFO(cli_readline)(ZEND_MODULE_INFO_FUNC_ARGS_PASSTHRU); |
|
} |
|
|
/* }}} */ |
/* }}} */ |
|
|
/* {{{ proto string readline([string prompt]) |
/* {{{ proto string readline([string prompt]) |
Line 244 PHP_FUNCTION(readline_info)
|
Line 259 PHP_FUNCTION(readline_info)
|
#endif |
#endif |
add_assoc_string(return_value,"library_version",(char *)SAFE_STRING(rl_library_version),1); |
add_assoc_string(return_value,"library_version",(char *)SAFE_STRING(rl_library_version),1); |
add_assoc_string(return_value,"readline_name",(char *)SAFE_STRING(rl_readline_name),1); |
add_assoc_string(return_value,"readline_name",(char *)SAFE_STRING(rl_readline_name),1); |
|
add_assoc_long(return_value,"attempted_completion_over",rl_attempted_completion_over); |
} else { |
} else { |
if (!strcasecmp(what,"line_buffer")) { |
if (!strcasecmp(what,"line_buffer")) { |
oldstr = rl_line_buffer; |
oldstr = rl_line_buffer; |
Line 298 PHP_FUNCTION(readline_info)
|
Line 314 PHP_FUNCTION(readline_info)
|
rl_readline_name = strdup(Z_STRVAL_PP(value));; |
rl_readline_name = strdup(Z_STRVAL_PP(value));; |
} |
} |
RETVAL_STRING(SAFE_STRING(oldstr),1); |
RETVAL_STRING(SAFE_STRING(oldstr),1); |
} | } else if (!strcasecmp(what, "attempted_completion_over")) { |
| oldval = rl_attempted_completion_over; |
| if (value) { |
| convert_to_long_ex(value); |
| rl_attempted_completion_over = Z_LVAL_PP(value); |
| } |
| RETVAL_LONG(oldval); |
| } |
} |
} |
} |
} |
|
|
Line 365 PHP_FUNCTION(readline_read_history)
|
Line 388 PHP_FUNCTION(readline_read_history)
|
char *arg = NULL; |
char *arg = NULL; |
int arg_len; |
int arg_len; |
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &arg, &arg_len) == FAILURE) { | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|p", &arg, &arg_len) == FAILURE) { |
return; |
return; |
} |
} |
|
|
|
if (php_check_open_basedir(arg TSRMLS_CC)) { |
|
RETURN_FALSE; |
|
} |
|
|
/* XXX from & to NYI */ |
/* XXX from & to NYI */ |
if (read_history(arg)) { |
if (read_history(arg)) { |
RETURN_FALSE; |
RETURN_FALSE; |
Line 385 PHP_FUNCTION(readline_write_history)
|
Line 412 PHP_FUNCTION(readline_write_history)
|
char *arg = NULL; |
char *arg = NULL; |
int arg_len; |
int arg_len; |
|
|
if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &arg, &arg_len) == FAILURE) { | if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|p", &arg, &arg_len) == FAILURE) { |
return; |
return; |
} |
} |
|
|
|
if (php_check_open_basedir(arg TSRMLS_CC)) { |
|
RETURN_FALSE; |
|
} |
|
|
if (write_history(arg)) { |
if (write_history(arg)) { |
RETURN_FALSE; |
RETURN_FALSE; |
} else { |
} else { |
Line 561 PHP_FUNCTION(readline_callback_handler_install)
|
Line 592 PHP_FUNCTION(readline_callback_handler_install)
|
FREE_ZVAL(_prepped_callback); |
FREE_ZVAL(_prepped_callback); |
} |
} |
|
|
MAKE_STD_ZVAL(_prepped_callback); | ALLOC_ZVAL(_prepped_callback); |
*_prepped_callback = *callback; | MAKE_COPY_ZVAL(&callback, _prepped_callback); |
zval_copy_ctor(_prepped_callback); | |
|
|
rl_callback_handler_install(prompt, php_rl_callback_handler); |
rl_callback_handler_install(prompt, php_rl_callback_handler); |
|
|
Line 604 PHP_FUNCTION(readline_redisplay)
|
Line 634 PHP_FUNCTION(readline_redisplay)
|
} |
} |
/* }}} */ |
/* }}} */ |
|
|
|
#endif |
|
|
|
#if HAVE_RL_ON_NEW_LINE |
/* {{{ proto void readline_on_new_line(void) |
/* {{{ proto void readline_on_new_line(void) |
Inform readline that the cursor has moved to a new line */ |
Inform readline that the cursor has moved to a new line */ |
PHP_FUNCTION(readline_on_new_line) |
PHP_FUNCTION(readline_on_new_line) |