mirror of
https://github.com/php-win-ext/pecl-expect.git
synced 2026-03-24 13:02:07 +01:00
Compare commits
23 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a291a8ff3b | ||
|
|
48d03837f9 | ||
|
|
5fdde4afbf | ||
|
|
98a048f820 | ||
|
|
c02699dde7 | ||
|
|
8133790622 | ||
|
|
178e5c07c5 | ||
|
|
9b925ac532 | ||
|
|
4411953272 | ||
|
|
f80a041dac | ||
|
|
ea50047133 | ||
|
|
e16b06dede | ||
|
|
80e342cf6b | ||
|
|
3e030e95e6 | ||
|
|
e4b08ad2de | ||
|
|
ce1a540073 | ||
|
|
f85ba457db | ||
|
|
b7d18cfbb9 | ||
|
|
c5895a300f | ||
|
|
925378d4ae | ||
|
|
4e2f9109e1 | ||
|
|
f6251794c5 | ||
|
|
2246eef8d7 |
28
config.m4
28
config.m4
@@ -5,17 +5,37 @@ dnl
|
||||
PHP_ARG_WITH(expect,for expect support,
|
||||
[ --with-expect[=DIR] Include expect support (requires libexpect >= 5.43.0).])
|
||||
|
||||
PHP_ARG_WITH(tcldir,specify path to Tcl needed by expect,
|
||||
[ --with-tcldir[=DIR] Specify path to Tcl config script (tclConfig.sh).])
|
||||
|
||||
if test "$PHP_EXPECT" != "no"; then
|
||||
for i in $PHP_EXPECT /usr/local /usr ; do
|
||||
if test -f $i/include/expect.h; then
|
||||
LIBEXPECT_DIR=$i
|
||||
|
||||
for i in $PHP_EXPECT/include/expect.h $PHP_EXPECT/include/*/expect.h \
|
||||
/usr/local/include/expect.h /usr/local/include/*/expect.h \
|
||||
/usr/include/expect.h /usr/include/*/expect.h ;
|
||||
do
|
||||
if test -f $i; then
|
||||
LIBEXPECT_INCLUDE_DIR=`dirname $i`
|
||||
LIBEXPECT_DIR=`dirname $LIBEXPECT_INCLUDE_DIR`
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
for i in $PHP_TCLDIR/tclConfig.sh /usr/lib/tcl*/tclConfig.sh \
|
||||
/usr/local/lib/tcl*/tclConfig.sh \
|
||||
/System/Library/Frameworks/Tcl.framework/Versions/Current/tclConfig.sh;
|
||||
do
|
||||
if test -f $i; then
|
||||
. $i
|
||||
break
|
||||
fi
|
||||
done
|
||||
|
||||
PHP_ADD_LIBRARY_WITH_PATH(tcl$TCL_VERSION, $TCL_PREFIX/lib, EXPECT_SHARED_LIBADD)
|
||||
PHP_ADD_LIBRARY_WITH_PATH(expect, $LIBEXPECT_DIR/lib, EXPECT_SHARED_LIBADD)
|
||||
PHP_ADD_INCLUDE($LIBEXPECT_DIR/include)
|
||||
PHP_ADD_INCLUDE($LIBEXPECT_INCLUDE_DIR)
|
||||
|
||||
PHP_NEW_EXTENSION(expect, expect.c expect_fopen_wrapper.c, $ext_shared)
|
||||
PHP_SUBST(EXPECT_SHARED_LIBADD)
|
||||
fi
|
||||
|
||||
|
||||
218
expect.c
218
expect.c
@@ -12,18 +12,30 @@
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Michael Spector <michael@zend.com> |
|
||||
| Author: Michael Spector <michael@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $ Id: $ */
|
||||
|
||||
#include "php_expect.h"
|
||||
#include <string.h>
|
||||
#include <errno.h>
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_expect_popen, 0, 0, 1)
|
||||
ZEND_ARG_INFO(0, command)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
ZEND_BEGIN_ARG_INFO_EX(arginfo_expect_expectl, 0, 0, 2)
|
||||
ZEND_ARG_INFO(0, stream)
|
||||
ZEND_ARG_INFO(0, expect_cases)
|
||||
ZEND_ARG_INFO(1, match)
|
||||
ZEND_END_ARG_INFO()
|
||||
|
||||
/* {{{ expect_functions[] */
|
||||
function_entry expect_functions[] = {
|
||||
PHP_FE(expect_popen, NULL)
|
||||
PHP_FE(expect_expectl, third_arg_force_ref)
|
||||
zend_function_entry expect_functions[] = {
|
||||
PHP_FE(expect_popen, arginfo_expect_popen)
|
||||
PHP_FE(expect_expectl, arginfo_expect_expectl)
|
||||
{ NULL, NULL, NULL }
|
||||
};
|
||||
/* }}} */
|
||||
@@ -40,7 +52,7 @@ zend_module_entry expect_module_entry = {
|
||||
NULL,
|
||||
NULL,
|
||||
PHP_MINFO(expect),
|
||||
"0.1",
|
||||
PHP_EXPECT_VERSION,
|
||||
STANDARD_MODULE_PROPERTIES
|
||||
};
|
||||
/* }}} */
|
||||
@@ -49,13 +61,47 @@ zend_module_entry expect_module_entry = {
|
||||
ZEND_GET_MODULE(expect)
|
||||
#endif
|
||||
|
||||
ZEND_DECLARE_MODULE_GLOBALS(expect)
|
||||
|
||||
/* {{{ php_expect_init_globals
|
||||
*/
|
||||
static void php_expect_init_globals (zend_expect_globals *globals TSRMLS_DC)
|
||||
{
|
||||
globals->logfile_stream = NULL;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ php_expect_destroy_globals
|
||||
*/
|
||||
static void php_expect_destroy_globals(zend_expect_globals *globals TSRMLS_DC)
|
||||
{
|
||||
if (globals->logfile_stream) {
|
||||
php_stream_close(globals->logfile_stream);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_INI_MH
|
||||
* */
|
||||
static PHP_INI_MH(OnSetExpectTimeout)
|
||||
{
|
||||
if (new_value) {
|
||||
exp_timeout = atoi(new_value);
|
||||
return SUCCESS;
|
||||
}
|
||||
return FAILURE;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
/* {{{ PHP_INI_MH
|
||||
* */
|
||||
static PHP_INI_MH(OnSetExpectMatchMax)
|
||||
{
|
||||
if (new_value) {
|
||||
exp_match_max = atoi(new_value);
|
||||
return SUCCESS;
|
||||
}
|
||||
return FAILURE;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -65,12 +111,17 @@ static PHP_INI_MH(OnSetExpectTimeout)
|
||||
static PHP_INI_MH(OnSetExpectLogUser)
|
||||
{
|
||||
if (new_value) {
|
||||
if (strncasecmp("on", new_value, sizeof("on"))) {
|
||||
exp_loguser = atoi(new_value);
|
||||
} else {
|
||||
if (strncasecmp("on", new_value, sizeof("on")) == 0
|
||||
|| strncasecmp("true", new_value, sizeof("true")) == 0
|
||||
|| strncasecmp("yes", new_value, sizeof("yes")) == 0
|
||||
|| strncasecmp("1", new_value, sizeof("1")) == 0) {
|
||||
exp_loguser = 1;
|
||||
} else {
|
||||
exp_loguser = 0;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
return FAILURE;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
@@ -79,12 +130,25 @@ static PHP_INI_MH(OnSetExpectLogUser)
|
||||
* */
|
||||
static PHP_INI_MH(OnSetExpectLogFile)
|
||||
{
|
||||
if (EXPECT_G(logfile_stream)) {
|
||||
php_stream_close(EXPECT_G(logfile_stream));
|
||||
}
|
||||
if (new_value_length > 0) {
|
||||
exp_logfile = fopen (new_value, "a");
|
||||
if (!exp_logfile) {
|
||||
php_error_docref (NULL TSRMLS_CC, E_ERROR, "could not open log file for writting");
|
||||
php_stream* stream = php_stream_open_wrapper (new_value, "a", 0, NULL);
|
||||
if (!stream) {
|
||||
php_error_docref (NULL TSRMLS_CC, E_ERROR, "could not open log file for writing");
|
||||
return FAILURE;
|
||||
}
|
||||
stream->flags |= PHP_STREAM_FLAG_NO_SEEK;
|
||||
if (php_stream_cast(stream, PHP_STREAM_AS_STDIO, (void **) &exp_logfile, REPORT_ERRORS) != SUCCESS) {
|
||||
return FAILURE;
|
||||
}
|
||||
EXPECT_G(logfile_stream) = stream;
|
||||
exp_logfile_all = 1;
|
||||
} else {
|
||||
EXPECT_G(logfile_stream) = NULL;
|
||||
exp_logfile = NULL;
|
||||
exp_logfile_all = 0;
|
||||
}
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -95,6 +159,7 @@ PHP_INI_BEGIN()
|
||||
PHP_INI_ENTRY("expect.timeout", "10", PHP_INI_ALL, OnSetExpectTimeout)
|
||||
PHP_INI_ENTRY_EX("expect.loguser", "1", PHP_INI_ALL, OnSetExpectLogUser, php_ini_boolean_displayer_cb)
|
||||
PHP_INI_ENTRY("expect.logfile", "", PHP_INI_ALL, OnSetExpectLogFile)
|
||||
PHP_INI_ENTRY("expect.match_max", "5000", PHP_INI_ALL, OnSetExpectMatchMax)
|
||||
PHP_INI_END()
|
||||
|
||||
|
||||
@@ -111,6 +176,18 @@ PHP_MINIT_FUNCTION(expect)
|
||||
REGISTER_LONG_CONSTANT("EXP_FULLBUFFER", EXP_FULLBUFFER, CONST_CS | CONST_PERSISTENT);
|
||||
|
||||
REGISTER_INI_ENTRIES();
|
||||
|
||||
Tcl_Interp *interp = Tcl_CreateInterp();
|
||||
if (Tcl_Init(interp) == TCL_ERROR) {
|
||||
php_error_docref (NULL TSRMLS_CC, E_ERROR,
|
||||
"Unable to initialize TCL interpreter: %s", Tcl_GetStringResult (interp));
|
||||
return FAILURE;
|
||||
}
|
||||
if (Expect_Init(interp) == TCL_ERROR) {
|
||||
php_error_docref (NULL TSRMLS_CC, E_ERROR,
|
||||
"Unable to initialize Expect: %s", Tcl_GetStringResult (interp));
|
||||
return FAILURE;
|
||||
}
|
||||
|
||||
return SUCCESS;
|
||||
}
|
||||
@@ -133,7 +210,8 @@ PHP_MSHUTDOWN_FUNCTION(expect)
|
||||
PHP_MINFO_FUNCTION(expect)
|
||||
{
|
||||
php_info_print_table_start();
|
||||
php_info_print_table_row(2, "Expect support", "enabled");
|
||||
php_info_print_table_header(2, "Expect support", "enabled");
|
||||
php_info_print_table_row(2, "Version", PHP_EXPECT_VERSION);
|
||||
php_info_print_table_row(2, "Stream wrapper support", "expect://");
|
||||
php_info_print_table_end();
|
||||
|
||||
@@ -151,6 +229,7 @@ PHP_FUNCTION(expect_popen)
|
||||
int command_len;
|
||||
FILE *fp;
|
||||
php_stream *stream = NULL;
|
||||
zval *z_pid;
|
||||
|
||||
if (ZEND_NUM_ARGS() != 1) { WRONG_PARAM_COUNT; }
|
||||
|
||||
@@ -164,6 +243,13 @@ PHP_FUNCTION(expect_popen)
|
||||
if (!stream) {
|
||||
RETURN_FALSE;
|
||||
}
|
||||
|
||||
stream->flags |= PHP_STREAM_FLAG_NO_SEEK;
|
||||
|
||||
MAKE_STD_ZVAL (z_pid);
|
||||
ZVAL_LONG (z_pid, exp_pid);
|
||||
stream->wrapperdata = z_pid;
|
||||
|
||||
php_stream_to_zval(stream, return_value);
|
||||
}
|
||||
/* }}} */
|
||||
@@ -174,7 +260,7 @@ PHP_FUNCTION(expect_popen)
|
||||
*/
|
||||
PHP_FUNCTION(expect_expectl)
|
||||
{
|
||||
struct exp_case *ecases, *ec, matchedcase;
|
||||
struct exp_case *ecases, *ecases_ptr, matchedcase;
|
||||
zval *z_stream, *z_cases, *z_match=NULL, **z_case, **z_value;
|
||||
php_stream *stream;
|
||||
int fd, argc;
|
||||
@@ -187,15 +273,20 @@ PHP_FUNCTION(expect_expectl)
|
||||
}
|
||||
|
||||
php_stream_from_zval (stream, &z_stream);
|
||||
if (php_stream_cast (stream, PHP_STREAM_AS_FD, (void*)&fd, 1) != SUCCESS || fd < 0) {
|
||||
php_error_docref (NULL TSRMLS_CC, E_ERROR, "couldn't cast expect stream to a file descriptor");
|
||||
return;
|
||||
|
||||
if (!stream->wrapperdata) {
|
||||
php_error_docref (NULL TSRMLS_CC, E_ERROR, "supplied argument is not a valid stream resource");
|
||||
return;
|
||||
}
|
||||
|
||||
if (php_stream_cast (stream, PHP_STREAM_AS_FD, (void*)&fd, REPORT_ERRORS) != SUCCESS || fd < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
argc = zend_hash_num_elements (Z_ARRVAL_P(z_cases));
|
||||
ecases = (struct exp_case*) safe_emalloc (argc + 1, sizeof(struct exp_case), 0);
|
||||
ecases_ptr = ecases;
|
||||
|
||||
ec = ecases;
|
||||
zend_hash_internal_pointer_reset (Z_ARRVAL_P(z_cases));
|
||||
|
||||
while (zend_hash_get_current_data (Z_ARRVAL_P(z_cases), (void **)&z_case) == SUCCESS)
|
||||
@@ -209,8 +300,8 @@ PHP_FUNCTION(expect_expectl)
|
||||
return;
|
||||
}
|
||||
|
||||
ec->re = NULL;
|
||||
ec->type = exp_glob;
|
||||
ecases_ptr->re = NULL;
|
||||
ecases_ptr->type = exp_glob;
|
||||
|
||||
/* Gather pattern */
|
||||
if (zend_hash_index_find(Z_ARRVAL_PP(z_case), 0, (void **)&z_pattern) != SUCCESS) {
|
||||
@@ -223,7 +314,7 @@ PHP_FUNCTION(expect_expectl)
|
||||
php_error_docref (NULL TSRMLS_CC, E_ERROR, "pattern must be of string type");
|
||||
return;
|
||||
}
|
||||
ec->pattern = Z_STRVAL_PP(z_pattern);
|
||||
ecases_ptr->pattern = Z_STRVAL_PP(z_pattern);
|
||||
|
||||
/* Gather value */
|
||||
if (zend_hash_index_find(Z_ARRVAL_PP(z_case), 1, (void **)&z_value) != SUCCESS) {
|
||||
@@ -231,7 +322,7 @@ PHP_FUNCTION(expect_expectl)
|
||||
php_error_docref (NULL TSRMLS_CC, E_ERROR, "missing parameter for value at index: 1");
|
||||
return;
|
||||
}
|
||||
ec->value = key;
|
||||
ecases_ptr->value = key;
|
||||
|
||||
/* Gather expression type (optional, default: EXPECT_GLOB) */
|
||||
if (zend_hash_index_find(Z_ARRVAL_PP(z_case), 2, (void **)&z_exp_type) == SUCCESS) {
|
||||
@@ -245,54 +336,71 @@ PHP_FUNCTION(expect_expectl)
|
||||
php_error_docref (NULL TSRMLS_CC, E_ERROR, "expression type must be either EXPECT_GLOB, EXPECT_EXACT or EXPECT_REGEXP");
|
||||
return;
|
||||
}
|
||||
ec->type = Z_LVAL_PP(z_exp_type);
|
||||
ecases_ptr->type = Z_LVAL_PP(z_exp_type);
|
||||
}
|
||||
|
||||
ec++;
|
||||
ecases_ptr++;
|
||||
zend_hash_move_forward(Z_ARRVAL_P(z_cases));
|
||||
}
|
||||
ec->type = exp_end;
|
||||
ecases_ptr->pattern = NULL;
|
||||
ecases_ptr->re = NULL;
|
||||
ecases_ptr->value = 0;
|
||||
ecases_ptr->type = exp_end;
|
||||
|
||||
key = exp_expectv (fd, ecases);
|
||||
int exp_retval = exp_expectv (fd, ecases);
|
||||
int case_found = 0;
|
||||
if (exp_retval >= 0) {
|
||||
key = exp_retval;
|
||||
|
||||
int exp_match_len = exp_match_end - exp_match;
|
||||
if (z_match && exp_match && exp_match_len > 0) {
|
||||
char *tmp = (char *)emalloc (sizeof(char) * (exp_match_len + 1));
|
||||
strlcpy (tmp, exp_match, exp_match_len + 1);
|
||||
zval_dtor (z_match);
|
||||
array_init(z_match);
|
||||
add_index_string(z_match, 0, tmp, 1);
|
||||
/* Get case that was matched */
|
||||
matchedcase = ecases[key];
|
||||
/* If there are subpattern matches ... */
|
||||
if (matchedcase.re->startp != NULL) {
|
||||
int i;
|
||||
/* iterate across all possible 9 subpatterns (a limitation of libexpect)
|
||||
and add matching substring to matches array */
|
||||
for (i = 1; i <= 9; i++) {
|
||||
if (matchedcase.re->startp[i] != NULL) {
|
||||
int sub_match_len = matchedcase.re->endp[i] - matchedcase.re->startp[i];
|
||||
char *sub_match = (char *)emalloc (sizeof(char) * (sub_match_len + 1));
|
||||
strlcpy (sub_match, matchedcase.re->startp[i], sub_match_len + 1);
|
||||
add_next_index_string(z_match, sub_match, 1);
|
||||
efree (sub_match);
|
||||
int exp_match_len = exp_match_end - exp_match;
|
||||
if (z_match && exp_match && exp_match_len > 0) {
|
||||
char *tmp = (char *)emalloc (sizeof(char) * (exp_match_len + 1));
|
||||
strlcpy (tmp, exp_match, exp_match_len + 1);
|
||||
zval_dtor (z_match);
|
||||
array_init(z_match);
|
||||
add_index_string(z_match, 0, tmp, 1);
|
||||
/* Get case that was matched */
|
||||
matchedcase = ecases[key];
|
||||
/* If there are subpattern matches ... */
|
||||
if (matchedcase.re != NULL && matchedcase.re->startp != NULL) {
|
||||
int i;
|
||||
/* iterate across all possible 9 subpatterns (a limitation of libexpect)
|
||||
and add matching substring to matches array */
|
||||
for (i = 1; i <= 9; i++) {
|
||||
if (matchedcase.re->startp[i] != NULL) {
|
||||
int sub_match_len = matchedcase.re->endp[i] - matchedcase.re->startp[i];
|
||||
char *sub_match = (char *)emalloc (sizeof(char) * (sub_match_len + 1));
|
||||
strlcpy (sub_match, matchedcase.re->startp[i], sub_match_len + 1);
|
||||
add_next_index_string(z_match, sub_match, 1);
|
||||
efree (sub_match);
|
||||
}
|
||||
}
|
||||
}
|
||||
efree (tmp);
|
||||
}
|
||||
efree (tmp);
|
||||
}
|
||||
|
||||
if (zend_hash_index_find (Z_ARRVAL_P(z_cases), key, (void **)&z_case) == SUCCESS) {
|
||||
if (zend_hash_index_find(Z_ARRVAL_PP(z_case), 1, (void **)&z_value) == SUCCESS) {
|
||||
*return_value = **z_value;
|
||||
zval_copy_ctor (return_value);
|
||||
if (zend_hash_index_find (Z_ARRVAL_P(z_cases), key, (void **)&z_case) == SUCCESS) {
|
||||
if (zend_hash_index_find(Z_ARRVAL_PP(z_case), 1, (void **)&z_value) == SUCCESS) {
|
||||
*return_value = **z_value;
|
||||
zval_copy_ctor (return_value);
|
||||
case_found = 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
else {
|
||||
RETURN_LONG (key);
|
||||
}
|
||||
|
||||
// Free compiled patterns:
|
||||
ecases_ptr = ecases;
|
||||
while (ecases_ptr != NULL && ecases_ptr->type != exp_end) {
|
||||
if (ecases_ptr->re != NULL) {
|
||||
free(ecases_ptr->re);
|
||||
}
|
||||
ecases_ptr++;
|
||||
}
|
||||
efree (ecases);
|
||||
|
||||
if (!case_found) {
|
||||
RETURN_LONG(exp_retval);
|
||||
}
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Michael Spector <michael@zend.com> |
|
||||
| Author: Michael Spector <michael@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
|
||||
85
package.xml
85
package.xml
@@ -1,34 +1,53 @@
|
||||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!DOCTYPE package SYSTEM "http://pear.php.net/dtd/package-1.0">
|
||||
<package>
|
||||
<name>expect</name>
|
||||
<summary>PHP extension for expect library</summary>
|
||||
<description>This extension allows to interact with processes through PTY, using expect library.</description>
|
||||
<license>PHP License</license>
|
||||
<maintainers>
|
||||
<maintainer>
|
||||
<user>michael</user>
|
||||
<name>Michael Spector</name>
|
||||
<email>michael@php.net</email>
|
||||
</maintainer>
|
||||
</maintainers>
|
||||
|
||||
<release>
|
||||
<version>0.2.2</version>
|
||||
<date>2006-07-05</date>
|
||||
<state>beta</state>
|
||||
<notes>Fix segfault on scenario with EXP_TIMEOUT.
|
||||
</notes>
|
||||
</release>
|
||||
|
||||
<filelist>
|
||||
<dir role="doc" name="/">
|
||||
<file role="src">config.m4</file>
|
||||
<file role="src">expect.dsp</file>
|
||||
<file role="src">config.w32</file>
|
||||
<file role="src">expect.c</file>
|
||||
<file role="src">expect_fopen_wrapper.c</file>
|
||||
<file role="src">php_expect.h</file>
|
||||
</dir>
|
||||
</filelist>
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<package packagerversion="1.9.0" version="2.0" xmlns="http://pear.php.net/dtd/package-2.0" xmlns:tasks="http://pear.php.net/dtd/tasks-1.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://pear.php.net/dtd/tasks-1.0
|
||||
http://pear.php.net/dtd/tasks-1.0.xsd
|
||||
http://pear.php.net/dtd/package-2.0
|
||||
http://pear.php.net/dtd/package-2.0.xsd">
|
||||
<name>expect</name>
|
||||
<channel>pecl.php.net</channel>
|
||||
<summary>PHP extension for expect library</summary>
|
||||
<description>This extension allows to interact with processes through PTY, using expect library.
|
||||
</description>
|
||||
<lead>
|
||||
<name>Michael Spector</name>
|
||||
<user>michael</user>
|
||||
<email>michael@php.net</email>
|
||||
<active>yes</active>
|
||||
</lead>
|
||||
<date>2015-09-11</date>
|
||||
<time>15:25:00</time>
|
||||
<version>
|
||||
<release>0.3.2</release>
|
||||
<api>0.3.2</api>
|
||||
</version>
|
||||
<stability>
|
||||
<release>stable</release>
|
||||
<api>stable</api>
|
||||
</stability>
|
||||
<license uri="http://www.php.net/license">PHP License</license>
|
||||
<notes>
|
||||
Fixed #70458
|
||||
</notes>
|
||||
<contents>
|
||||
<dir name="/">
|
||||
<file name="config.m4" role="src" />
|
||||
<file name="config.w32" role="src" />
|
||||
<file name="expect.c" role="src" />
|
||||
<file name="expect.dsp" role="src" />
|
||||
<file name="expect_fopen_wrapper.c" role="src" />
|
||||
<file name="php_expect.h" role="src" />
|
||||
</dir> <!-- / -->
|
||||
</contents>
|
||||
<dependencies>
|
||||
<required>
|
||||
<php>
|
||||
<min>4.0.0</min>
|
||||
</php>
|
||||
<pearinstaller>
|
||||
<min>1.4.0b1</min>
|
||||
</pearinstaller>
|
||||
</required>
|
||||
</dependencies>
|
||||
<providesextension>expect</providesextension>
|
||||
<extsrcrelease />
|
||||
</package>
|
||||
|
||||
16
php_expect.h
16
php_expect.h
@@ -12,7 +12,7 @@
|
||||
| obtain it through the world-wide-web, please send a note to |
|
||||
| license@php.net so we can mail you a copy immediately. |
|
||||
+----------------------------------------------------------------------+
|
||||
| Author: Michael Spector <michael@zend.com> |
|
||||
| Author: Michael Spector <michael@php.net> |
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
@@ -30,11 +30,15 @@
|
||||
#include <SAPI.h>
|
||||
#include <ext/standard/info.h>
|
||||
|
||||
#include <tcl.h>
|
||||
#include <expect_tcl.h>
|
||||
#include <expect.h>
|
||||
|
||||
extern zend_module_entry expect_module_entry;
|
||||
#define phpext_expect_ptr &expect_module_entry
|
||||
|
||||
#define PHP_EXPECT_VERSION "0.3.2"
|
||||
|
||||
#ifdef PHP_WIN32
|
||||
#define PHP_EXPECT_API __declspec(dllexport)
|
||||
#else
|
||||
@@ -50,6 +54,16 @@ PHP_FUNCTION(expect_expectl);
|
||||
|
||||
extern php_stream_wrapper php_expect_wrapper;
|
||||
|
||||
ZEND_BEGIN_MODULE_GLOBALS(expect)
|
||||
php_stream* logfile_stream;
|
||||
ZEND_END_MODULE_GLOBALS(expect)
|
||||
|
||||
#ifdef ZTS
|
||||
#define EXPECT_G(v) TSRMG(expect_globals_id, zend_expect_globals *, v)
|
||||
#else
|
||||
#define EXPECT_G(v) (expect_globals.v)
|
||||
#endif
|
||||
|
||||
#ifdef ZTS
|
||||
#include "TSRM.h"
|
||||
#endif /* ZTS */
|
||||
|
||||
24
tests/bug12268.phpt
Normal file
24
tests/bug12268.phpt
Normal file
@@ -0,0 +1,24 @@
|
||||
--TEST--
|
||||
PECL Bug #12268 CGI
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("expect") || php_sapi_name() == 'cli') print "skip"; ?>
|
||||
--INI--
|
||||
expect.loguser=0
|
||||
expect.logfile=php://output
|
||||
--FILE--
|
||||
<?php
|
||||
if (php_sapi_name() == 'cli') exit;
|
||||
|
||||
$stream = expect_popen("echo Hello");
|
||||
|
||||
ob_start();
|
||||
|
||||
expect_expectl ($stream, array());
|
||||
|
||||
$r = ob_get_contents();
|
||||
fclose ($stream);
|
||||
|
||||
print "Output: $r";
|
||||
?>
|
||||
--EXPECT--
|
||||
Output: Hello
|
||||
16
tests/bug22566.phpt
Normal file
16
tests/bug22566.phpt
Normal file
@@ -0,0 +1,16 @@
|
||||
--TEST--
|
||||
PECL Bug #22566 CGI
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("expect")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
var_dump(ini_set('expect.timeout', 3));
|
||||
var_dump(ini_set('expect.match_max', '2000'));
|
||||
var_dump(ini_get('expect.timeout'));
|
||||
var_dump(ini_get('expect.match_max'));
|
||||
?>
|
||||
--EXPECT--
|
||||
string(2) "10"
|
||||
string(4) "5000"
|
||||
string(1) "3"
|
||||
string(4) "2000"
|
||||
14
tests/bug6996.phpt
Normal file
14
tests/bug6996.phpt
Normal file
@@ -0,0 +1,14 @@
|
||||
--TEST--
|
||||
PECL Bug #6996
|
||||
--SKIPIF--
|
||||
<?php if (!extension_loaded("expect")) print "skip"; ?>
|
||||
--FILE--
|
||||
<?php
|
||||
$stream = popen ("expect://echo 2>/dev/null", "r");
|
||||
|
||||
expect_expectl ($stream, array());
|
||||
|
||||
fclose ($stream);
|
||||
?>
|
||||
--EXPECTF--
|
||||
Fatal error: expect_expectl(): supplied argument is not a valid stream resource in %s on line %d
|
||||
Reference in New Issue
Block a user