com php-src: ...: phpdbg.c phpdbg.h phpdbg_cmd.c phpdbg _utils.h

From: Date: Fri, 22 Nov 2013 16:15:24 +0000
Subject: com php-src: ...: phpdbg.c phpdbg.h phpdbg_cmd.c phpdbg _utils.h
Groups: php.cvs 
Request: Send a blank email to php-cvs+get-74714@lists.php.net to get a copy of this message
Commit: 022eb18d1de326fe5a5f8ea4c42b414c14d7ff7a Author: krakjoe <joe.watkins@live.co.uk> Fri, 22 Nov 2013 16:15:24 +0000 Parents: e0c4f87a897e005f5927baa8a747e6266d052813 Branches: PHP-5.6 Link: http://git.php.net/?p=php-src.git;a=commitdiff;h=022eb18d1de326fe5a5f8ea4c42b414c14d7ff7a Log: .. Changed paths: M phpdbg..c M phpdbg.h M phpdbg_cmd.c M phpdbg_utils.h Diff: diff --git a/phpdbg.c b/phpdbg.c index 27fedee..f15f49f 100644 --- a/phpdbg.c +++ b/phpdbg.c @@ -44,6 +44,9 @@ static inline void php_phpdbg_globals_ctor(zend_phpdbg_globals *pg) /* {{{ */ pg->lcmd = NULL; pg->flags = PHPDBG_DEFAULT_FLAGS; pg->oplog = NULL; + pg->io[PHPDBG_STDIN] = NULL; + pg->io[PHPDBG_STDOUT] = NULL; + pg->io[PHPDBG_STDERR] = NULL; memset(&pg->lparam, 0, sizeof(phpdbg_param_t)); } /* }}} */ @@ -339,7 +342,9 @@ static inline int php_sapi_phpdbg_ub_write(const char *message, unsigned int len static inline void php_sapi_phpdbg_flush(void *context) /* {{{ */ { - fflush(stdout); + TSRMLS_FETCH(); + + fflush(PHPDBG_G(io)[PHPDBG_STDOUT]); } /* }}} */ /* {{{ sapi_module_struct phpdbg_sapi_module @@ -636,6 +641,11 @@ phpdbg_main: PG(modules_activated) = 0; + /* set up basic io here */ + PHPDBG_G(io)[PHPDBG_STDIN] = stdin; + PHPDBG_G(io)[PHPDBG_STDOUT] = stdout; + PHPDBG_G(io)[PHPDBG_STDERR] = stderr; + if (exec) { /* set execution context */ PHPDBG_G(exec) = phpdbg_resolve_path( exec TSRMLS_CC); diff --git a/phpdbg.h b/phpdbg.h index 1cff51e..aa6c7ca 100644 --- a/phpdbg.h +++ b/phpdbg.h @@ -112,6 +112,11 @@ #define PHPDBG_ISSUES "http://github.com/krakjoe/phpdbg/issues" #define PHPDBG_VERSION "0.0.2-dev" /* }}} */ +/* {{{ output descriptors */ +#define PHPDBG_STDIN 0 +#define PHPDBG_STDOUT 1 +#define PHPDBG_STDERR 2 /* }}} */ + /* {{{ structs */ ZEND_BEGIN_MODULE_GLOBALS(phpdbg) HashTable bp[PHPDBG_BREAK_TABLES]; /* break points */ @@ -127,6 +132,7 @@ ZEND_BEGIN_MODULE_GLOBALS(phpdbg) HashTable seek; /* seek oplines */ zend_ulong flags; /* phpdbg flags */ HashTable registered; /* registered */ + FILE *io[3]; /* stdin/stdout/stderr */ ZEND_END_MODULE_GLOBALS(phpdbg) /* }}} */ #endif /* PHPDBG_H */ diff --git a/phpdbg_cmd.c b/phpdbg_cmd.c index 75b55df..28f085e 100644 --- a/phpdbg_cmd.c +++ b/phpdbg_cmd.c @@ -218,7 +218,7 @@ phpdbg_input_t *phpdbg_read_input(char *buffered TSRMLS_DC) /* {{{ */ #ifndef HAVE_LIBREADLINE char buf[PHPDBG_MAX_CMD]; if (!phpdbg_write(PROMPT) || - !fgets(buf, PHPDBG_MAX_CMD, stdin)) { + !fgets(buf, PHPDBG_MAX_CMD, PHPDBG_G(io)[PHPDBG_STDIN])) { /* the user has gone away */ phpdbg_error("Failed to read console !"); PHPDBG_G(flags) |= PHPDBG_IS_QUITTING; diff --git a/phpdbg_utils.h b/phpdbg_utils.h index 0a6ad4f..1178dca 100644 --- a/phpdbg_utils.h +++ b/phpdbg_utils.h @@ -44,11 +44,11 @@ enum { int phpdbg_print(int TSRMLS_DC, FILE*, const char*, ...); -#define phpdbg_error(fmt, ...) phpdbg_print(P_ERROR TSRMLS_CC, stdout, fmt, ##__VA_ARGS__) -#define phpdbg_notice(fmt, ...) phpdbg_print(P_NOTICE TSRMLS_CC, stdout, fmt, ##__VA_ARGS__) -#define phpdbg_writeln(fmt, ...) phpdbg_print(P_WRITELN TSRMLS_CC, stdout, fmt, ##__VA_ARGS__) -#define phpdbg_write(fmt, ...) phpdbg_print(P_WRITE TSRMLS_CC, stdout, fmt, ##__VA_ARGS__) -#define phpdbg_log(fmt, ...) phpdbg_print(P_LOG TSRMLS_CC, stdout, fmt, ##__VA_ARGS__) +#define phpdbg_error(fmt, ....) phpdbg_print(P_ERROR TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDOUT], fmt, ##__VA_ARGS__) +#define phpdbg_notice(fmt, ...) phpdbg_print(P_NOTICE TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDOUT], fmt, ##__VA_ARGS__) +#define phpdbg_writeln(fmt, ...) phpdbg_print(P_WRITELN TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDOUT], fmt, ##__VA_ARGS__) +#define phpdbg_write(fmt, ...) phpdbg_print(P_WRITE TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDOUT], fmt, ##__VA_ARGS__) +#define phpdbg_log(fmt, ...) phpdbg_print(P_LOG TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDOUT], fmt, ##__VA_ARGS__) #define phpdbg_error_ex(out, fmt, ...) phpdbg_print(P_ERROR TSRMLS_CC, out, fmt, ##__VA_ARGS__) #define phpdbg_notice_ex(out, fmt, ...) phpdbg_print(P_NOTICE TSRMLS_CC, out, fmt, ##__VA_ARGS__) @@ -57,7 +57,7 @@ int phpdbg_print(int TSRMLS_DC, FILE*, const char*, ...); #define phpdbg_log_ex(out, fmt, ...) phpdbg_print(P_LOG TSRMLS_CC, out, fmt, ##__VA_ARGS__) #if PHPDBG_DEBUG -# define phpdbg_debug(fmt, ...) phpdbg_print(P_LOG TSRMLS_CC, stderr, fmt, ##__VA_ARGS__) +# define phpdbg_debug(fmt, ...) phpdbg_print(P_LOG TSRMLS_CC, PHPDBG_G(io)[PHPDBG_STDERR], fmt, ##__VA_ARGS__) #else # define phpdbg_debug(fmt, ...) #endif

« previous php.cvs (#74714) next »