summaryrefslogtreecommitdiff
path: root/sapi/phpdbg/phpdbg_io.c
diff options
context:
space:
mode:
authorAnatol Belski <ab@php.net>2014-11-18 21:18:52 +0100
committerAnatol Belski <ab@php.net>2014-11-18 21:18:52 +0100
commitc6bad96f306df8e8b656472e618283ced5083cdb (patch)
tree7e5b52aa07777f0336b0944a228bf66f8f56b31f /sapi/phpdbg/phpdbg_io.c
parent4262663e4caa82ba17666781a95bdcb872b4e109 (diff)
parent64a39dc7b07d4b54d050a3a5c15045fe91c0b651 (diff)
downloadphp-git-c6bad96f306df8e8b656472e618283ced5083cdb.tar.gz
Merge remote-tracking branch 'origin/master' into native-tls
* origin/master: (398 commits) NEWS add test for bug #68381 Fixed bug #68381 Set FPM log level earlier during init proper dllexport move to size_t where zend_string is used internally fix some datatype mismatches return after the warning, to fix uninitialized salt usage fix datatype mismatches add missing type specifier fix datatype mismatches fix unsigned check "extern" shouldn't be used for definitions joined identical conditional blocks simplify fpm tests SEND_VAR_NO_REF optimization Add test for bug #68442 Add various tests for FPM - covering recent bugs (68420, 68421, 68423, 68428) - for UDS - for ping and status URI - for multi pool and multi mode Include small MIT FastCGI client library from https://github.com/adoy/PHP-FastCGI-Client Get rid of zend_free_op structure (use zval* instead). Get rid of useless TSRMLS arguments. Add new FPM test for IPv4/IPv6 ... Conflicts: win32/build/config.w32
Diffstat (limited to 'sapi/phpdbg/phpdbg_io.c')
-rw-r--r--sapi/phpdbg/phpdbg_io.c49
1 files changed, 49 insertions, 0 deletions
diff --git a/sapi/phpdbg/phpdbg_io.c b/sapi/phpdbg/phpdbg_io.c
index 97f0356285..a2a5c5969f 100644
--- a/sapi/phpdbg/phpdbg_io.c
+++ b/sapi/phpdbg/phpdbg_io.c
@@ -47,6 +47,55 @@
ZEND_EXTERN_MODULE_GLOBALS(phpdbg);
+/* is easy to generalize ... but not needed for now */
+PHPDBG_API int phpdbg_consume_stdin_line(char *buf TSRMLS_DC) {
+ int bytes = PHPDBG_G(input_buflen), len = 0;
+
+ if (PHPDBG_G(input_buflen)) {
+ memcpy(buf, PHPDBG_G(input_buffer), bytes);
+ }
+
+ PHPDBG_G(last_was_newline) = 1;
+
+ do {
+ int i;
+ if (bytes <= 0) {
+ continue;
+ }
+
+ for (i = len; i < len + bytes; i++) {
+ if (buf[i] == '\x03') {
+ if (i != len + bytes - 1) {
+ memmove(buf + i, buf + i + 1, len + bytes - i - 1);
+ }
+ len--;
+ i--;
+ continue;
+ }
+ if (buf[i] == '\n') {
+ PHPDBG_G(input_buflen) = len + bytes - 1 - i;
+ if (PHPDBG_G(input_buflen)) {
+ memcpy(PHPDBG_G(input_buffer), buf + i + 1, PHPDBG_G(input_buflen));
+ }
+ if (i != PHPDBG_MAX_CMD - 1) {
+ buf[i + 1] = 0;
+ }
+ return i;
+ }
+ }
+
+ len += bytes;
+ } while ((bytes = phpdbg_mixed_read(PHPDBG_G(io)[PHPDBG_STDIN].fd, buf + len, PHPDBG_MAX_CMD - len, -1 TSRMLS_CC)) > 0);
+
+ if (bytes <= 0) {
+ PHPDBG_G(flags) |= PHPDBG_IS_QUITTING | PHPDBG_IS_DISCONNECTED;
+ zend_bailout();
+ return 0;
+ }
+
+ return bytes;
+}
+
PHPDBG_API int phpdbg_consume_bytes(int sock, char *ptr, int len, int tmo TSRMLS_DC) {
int got_now, i = len, j;
char *p = ptr;