return fd;
} /* }}} */
-int phpdbg_open_sockets(short listen[2], FILE* streams[2]) /* {{{ */
+int phpdbg_open_sockets(int listen[2], FILE* streams[2]) /* {{{ */
{
int sockets[2] = {
- phpdbg_open_socket(listen[0]),
- phpdbg_open_socket(listen[1])
+ phpdbg_open_socket((short)listen[0]),
+ phpdbg_open_socket((short)listen[1])
};
int accepted[2] = {-1, -1};
memset(&address, 0, size);
accepted[0] = accept(
- sockets[0], &address, &size);
+ sockets[0], (struct sockaddr *) &address, &size);
memset(&address, 0, size);
accepted[1] = accept(
- sockets[1], &address, &size);
+ sockets[1], (struct sockaddr *) &address, &size);
}
streams[0] = fdopen(accepted[0], "r");
int run = 0;
int step = 0;
char *bp_tmp_file;
- short listen[2];
+ int listen[2];
FILE* streams[2] = {NULL, NULL};
#ifdef ZTS
if (!cleaning &&
(listen[0] && listen[1])) {
phpdbg_open_sockets(listen, streams);
- /* now is a sensible time to announce listen settings on the console */
}
phpdbg->ini_defaults = phpdbg_ini_defaults;
#endif
PG(modules_activated) = 0;
+
+ /* set flags from command line */
+ PHPDBG_G(flags) = flags;
/* setup io here */
if (streams[0] && streams[1]) {
PHPDBG_G(io)[PHPDBG_STDIN] = streams[0];
PHPDBG_G(io)[PHPDBG_STDOUT] = streams[1];
PHPDBG_G(io)[PHPDBG_STDERR] = stderr;
-
signal(SIGPIPE, SIG_IGN);
} else {
/* local console */
free(oplog_file);
}
- /* set flags from command line */
- PHPDBG_G(flags) = flags;
-
/* set default colors */
phpdbg_set_color_ex(PHPDBG_COLOR_PROMPT, PHPDBG_STRL("white-bold") TSRMLS_CC);
phpdbg_set_color_ex(PHPDBG_COLOR_ERROR, PHPDBG_STRL("red-bold") TSRMLS_CC);
if (!(PHPDBG_G(flags) & PHPDBG_IS_QUITTING)) {
if (buffered == NULL) {
- fflush(PHPDBG_G(io)[PHPDBG_STDOUT]);
+ if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {
+ fflush(PHPDBG_G(io)[PHPDBG_STDOUT]);
+ }
#ifndef HAVE_LIBREADLINE
char buf[PHPDBG_MAX_CMD];
- if (!phpdbg_write(phpdbg_get_prompt(TSRMLS_C)) ||
+ if ((!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE) && !phpdbg_write(phpdbg_get_prompt(TSRMLS_C))) ||
!fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) {
/* the user has gone away */
phpdbg_error("Failed to read console !");
zend_bailout();
return NULL;
}
-
+
cmd = buf;
#else
- cmd = readline(phpdbg_get_prompt(TSRMLS_C));
+ if ((PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {
+ char buf[PHPDBG_MAX_CMD];
+ if (fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) {
+ cmd = buf;
+ } else cmd = NULL;
+ } else cmd = readline(phpdbg_get_prompt(TSRMLS_C));
+
if (!cmd) {
/* the user has gone away */
phpdbg_error("Failed to read console !");
return NULL;
}
- add_history(cmd);
+ if (!(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {
+ add_history(cmd);
+ }
#endif
} else cmd = buffered;
#endif
#ifdef HAVE_LIBREADLINE
- if (!buffered && cmd) {
+ if (!buffered && cmd &&
+ !(PHPDBG_G(flags) & PHPDBG_IS_REMOTE)) {
free(cmd);
}
#endif