mirror of
https://github.com/php-win-ext/pecl-expect.git
synced 2026-03-24 05:02:05 +01:00
Compare commits
1 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
50ecf39bfd |
@@ -13,10 +13,6 @@ if test "$PHP_EXPECT" != "no"; then
|
||||
fi
|
||||
done
|
||||
|
||||
if test -z "$LIBEXPECT_DIR"; then
|
||||
AC_MSG_ERROR(expect extension requires libexpect version >= 5.43.0)
|
||||
fi
|
||||
|
||||
PHP_ADD_LIBRARY_WITH_PATH(expect, $LIBEXPECT_DIR/lib, EXPECT_SHARED_LIBADD)
|
||||
PHP_ADD_INCLUDE($LIBEXPECT_DIR/include)
|
||||
|
||||
|
||||
@@ -21,26 +21,43 @@
|
||||
#include "php.h"
|
||||
#include "php_expect.h"
|
||||
#include "php_streams.h"
|
||||
#include <sys/wait.h>
|
||||
|
||||
php_stream *php_expect_stream_opener (php_stream_wrapper *wrapper, char *command, char *mode, int options,
|
||||
php_stream *php_expect_stream_open (php_stream_wrapper *wrapper, char *command, char *mode, int options,
|
||||
char **opened_command, php_stream_context *context STREAMS_DC TSRMLS_DC)
|
||||
{
|
||||
FILE *fp;
|
||||
|
||||
if (strncasecmp("expect://", command, sizeof("expect://")-1) == 0) {
|
||||
command += sizeof("expect://")-1;
|
||||
}
|
||||
|
||||
if ((fp = exp_popen(command)) != NULL) {
|
||||
return php_stream_fopen_from_pipe (fp, "");
|
||||
php_stream* stream = php_stream_fopen_from_pipe (fp, mode);
|
||||
zval *z_pid;
|
||||
MAKE_STD_ZVAL (z_pid);
|
||||
ZVAL_LONG (z_pid, exp_pid);
|
||||
stream->wrapperdata = z_pid;
|
||||
return stream;
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static int php_expect_stream_close (php_stream_wrapper *wrapper, php_stream *stream TSRMLS_DC)
|
||||
{
|
||||
zval* z_pid = stream->wrapperdata;
|
||||
int s = 0;
|
||||
waitpid (Z_LVAL_P(z_pid), &s, 0);
|
||||
zval_ptr_dtor (&z_pid);
|
||||
stream->wrapperdata = NULL;
|
||||
return s;
|
||||
}
|
||||
/* }}} */
|
||||
|
||||
|
||||
static php_stream_wrapper_ops php_expect_wrapper_ops = {
|
||||
php_expect_stream_opener,
|
||||
NULL, /* close */
|
||||
php_expect_stream_open,
|
||||
php_expect_stream_close, /* close */
|
||||
NULL, /* stat */
|
||||
NULL, /* stat_url */
|
||||
NULL, /* opendir */
|
||||
|
||||
Reference in New Issue
Block a user