/* }}} */
-/* {{{ proto mixed readline_info([string varname] [, string newvalue])
- Gets/sets various internal readline variables. */
-
#define SAFE_STRING(s) ((s)?(char*)(s):"")
+/* {{{ proto mixed readline_info([string varname [, string newvalue]])
+ Gets/sets various internal readline variables. */
PHP_FUNCTION(readline_info)
{
- zval **what;
+ char *what;
zval **value;
- int oldval;
+ int what_len, oldval;
char *oldstr;
int ac = ZEND_NUM_ARGS();
- if (ac < 0 || ac > 2 || zend_get_parameters_ex(ac, &what, &value) == FAILURE) {
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|sZ", &what, &what_len, &value) == FAILURE) {
+ return;
}
if (ac == 0) {
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);
} else {
- convert_to_string_ex(what);
-
- if (! strcasecmp(Z_STRVAL_PP(what),"line_buffer")) {
+ if (!strcasecmp(what,"line_buffer")) {
oldstr = rl_line_buffer;
if (ac == 2) {
/* XXX if (rl_line_buffer) free(rl_line_buffer); */
rl_line_buffer = strdup(Z_STRVAL_PP(value));
}
RETVAL_STRING(SAFE_STRING(oldstr),1);
- } else if (! strcasecmp(Z_STRVAL_PP(what),"point")) {
+ } else if (!strcasecmp(what, "point")) {
RETVAL_LONG(rl_point);
- } else if (! strcasecmp(Z_STRVAL_PP(what),"end")) {
+ } else if (!strcasecmp(what, "end")) {
RETVAL_LONG(rl_end);
#ifdef HAVE_LIBREADLINE
- } else if (! strcasecmp(Z_STRVAL_PP(what),"mark")) {
+ } else if (!strcasecmp(what, "mark")) {
RETVAL_LONG(rl_mark);
- } else if (! strcasecmp(Z_STRVAL_PP(what),"done")) {
+ } else if (!strcasecmp(what, "done")) {
oldval = rl_done;
if (ac == 2) {
convert_to_long_ex(value);
rl_done = Z_LVAL_PP(value);
}
RETVAL_LONG(oldval);
- } else if (! strcasecmp(Z_STRVAL_PP(what),"pending_input")) {
+ } else if (!strcasecmp(what, "pending_input")) {
oldval = rl_pending_input;
if (ac == 2) {
convert_to_string_ex(value);
rl_pending_input = Z_STRVAL_PP(value)[0];
}
RETVAL_LONG(oldval);
- } else if (! strcasecmp(Z_STRVAL_PP(what),"prompt")) {
+ } else if (!strcasecmp(what, "prompt")) {
RETVAL_STRING(SAFE_STRING(rl_prompt),1);
- } else if (! strcasecmp(Z_STRVAL_PP(what),"terminal_name")) {
+ } else if (!strcasecmp(what, "terminal_name")) {
RETVAL_STRING((char *)SAFE_STRING(rl_terminal_name),1);
#endif
#if HAVE_ERASE_EMPTY_LINE
- } else if (! strcasecmp(Z_STRVAL_PP(what),"erase_empty_line")) {
+ } else if (!strcasecmp(what, "erase_empty_line")) {
oldval = rl_erase_empty_line;
if (ac == 2) {
convert_to_long_ex(value);
}
RETVAL_LONG(oldval);
#endif
- } else if (! strcasecmp(Z_STRVAL_PP(what),"library_version")) {
+ } else if (!strcasecmp(what,"library_version")) {
RETVAL_STRING((char *)SAFE_STRING(rl_library_version),1);
- } else if (! strcasecmp(Z_STRVAL_PP(what),"readline_name")) {
+ } else if (!strcasecmp(what, "readline_name")) {
oldstr = (char*)rl_readline_name;
if (ac == 2) {
/* XXX if (rl_readline_name) free(rl_readline_name); */
}
/* }}} */
-/* {{{ proto bool readline_add_history([string prompt])
+/* {{{ proto bool readline_add_history(string prompt)
Adds a line to the history */
PHP_FUNCTION(readline_add_history)
{
- zval **arg;
- int ac = ZEND_NUM_ARGS();
+ char *arg;
+ int arg_len;
- if (ac != 1 || zend_get_parameters_ex(ac, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "s", &arg, &arg_len) == FAILURE) {
+ return;
}
- convert_to_string_ex(arg);
- add_history(Z_STRVAL_PP(arg));
+ add_history(arg);
RETURN_TRUE;
}
Clears the history */
PHP_FUNCTION(readline_clear_history)
{
- int ac = ZEND_NUM_ARGS();
-
- if (ac != 0) {
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters_none() == FAILURE) {
+ return;
}
clear_history();
}
#endif
/* }}} */
-/* {{{ proto bool readline_read_history([string filename] [, int from] [,int to])
+/* {{{ proto bool readline_read_history([string filename])
Reads the history */
PHP_FUNCTION(readline_read_history)
{
- zval **arg;
- char *filename = NULL;
- int ac = ZEND_NUM_ARGS();
+ char *arg = NULL;
+ int arg_len;
- if (ac < 0 || ac > 1 || zend_get_parameters_ex(ac, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &arg, &arg_len) == FAILURE) {
+ return;
}
/* XXX from & to NYI */
-
- if (ac == 1) {
- convert_to_string_ex(arg);
- filename = Z_STRVAL_PP(arg);
- }
-
- if (read_history(filename)) {
+ if (read_history(arg)) {
RETURN_FALSE;
} else {
RETURN_TRUE;
Writes the history */
PHP_FUNCTION(readline_write_history)
{
- zval **arg;
- char *filename = NULL;
- int ac = ZEND_NUM_ARGS();
-
- if (ac < 0 || ac > 1 || zend_get_parameters_ex(ac, &arg) == FAILURE) {
- WRONG_PARAM_COUNT;
- }
+ char *arg = NULL;
+ int arg_len;
- if (ac == 1) {
- convert_to_string_ex(arg);
- filename = Z_STRVAL_PP(arg);
+ if (zend_parse_parameters(ZEND_NUM_ARGS() TSRMLS_CC, "|s", &arg, &arg_len) == FAILURE) {
+ return;
}
- if (write_history(filename)) {
+ if (write_history(arg)) {
RETURN_FALSE;
} else {
RETURN_TRUE;
HashTable *myht = Z_ARRVAL(_readline_array);
zval **entry;
- if (! state) {
+ if (!state) {
zend_hash_internal_pointer_reset(myht);
}
RETURN_FALSE;
}
- if (_readline_completion)
+ if (_readline_completion) {
FREE_ZVAL(_readline_completion);
+ }
MAKE_STD_ZVAL(_readline_completion);
*_readline_completion = *arg;