1 /* 2 +----------------------------------------------------------------------+ 3 | Copyright (c) The PHP Group | 4 +----------------------------------------------------------------------+ 5 | This source file is subject to version 3.01 of the PHP license, | 6 | that is bundled with this package in the file LICENSE, and is | 7 | available through the world-wide-web at the following url: | 8 | https://www.php.net/license/3_01.txt | 9 | If you did not receive a copy of the PHP license and are unable to | 10 | obtain it through the world-wide-web, please send a note to | 11 | license@php.net so we can mail you a copy immediately. | 12 +----------------------------------------------------------------------+ 13 | Authors: Felipe Pena <felipe@php.net> | 14 | Authors: Joe Watkins <joe.watkins@live.co.uk> | 15 | Authors: Bob Weinand <bwoebi@php.net> | 16 +----------------------------------------------------------------------+ 17 */ 18 19 #ifndef PHPDBG_OUT_H 20 #define PHPDBG_OUT_H 21 22 #ifndef PHPDBG_DEBUG 23 # define PHPDBG_DEBUG 0 24 #endif 25 26 /** 27 * Error/notice/formatting helpers 28 */ 29 enum { 30 P_ERROR = 1, 31 P_NOTICE, 32 P_WRITELN, 33 P_WRITE, 34 P_STDOUT, 35 P_STDERR, 36 P_LOG 37 }; 38 39 PHPDBG_API int phpdbg_print(int severity, int fd, const char *strfmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4); 40 PHPDBG_API int phpdbg_log_internal(int fd, const char *fmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 2, 3); 41 PHPDBG_API int phpdbg_out_internal(int fd, const char *fmt, ...) PHP_ATTRIBUTE_FORMAT(printf, 2, 3); 42 43 #define phpdbg_error(strfmt, ...) phpdbg_print(P_ERROR , PHPDBG_G(io)[PHPDBG_STDOUT].fd, strfmt, ##__VA_ARGS__) 44 #define phpdbg_notice(strfmt, ...) phpdbg_print(P_NOTICE , PHPDBG_G(io)[PHPDBG_STDOUT].fd, strfmt, ##__VA_ARGS__) 45 #define phpdbg_writeln(strfmt, ...) phpdbg_print(P_WRITELN, PHPDBG_G(io)[PHPDBG_STDOUT].fd, strfmt, ##__VA_ARGS__) 46 #define phpdbg_write(strfmt, ...) phpdbg_print(P_WRITE , PHPDBG_G(io)[PHPDBG_STDOUT].fd, strfmt, ##__VA_ARGS__) 47 48 #define phpdbg_log(fmt, ...) phpdbg_log_internal(PHPDBG_G(io)[PHPDBG_STDOUT].fd, fmt, ##__VA_ARGS__) 49 #define phpdbg_out(fmt, ...) phpdbg_out_internal(PHPDBG_G(io)[PHPDBG_STDOUT].fd, fmt, ##__VA_ARGS__) 50 51 #define phpdbg_script(type, strfmt, ...) phpdbg_print(type, PHPDBG_G(io)[PHPDBG_STDOUT].fd, strfmt, ##__VA_ARGS__) 52 53 #define phpdbg_asprintf(buf, ...) _phpdbg_asprintf(buf, ##__VA_ARGS__) 54 PHPDBG_API int _phpdbg_asprintf(char **buf, const char *format, ...); 55 56 #if PHPDBG_DEBUG 57 # define phpdbg_debug(strfmt, ...) phpdbg_log_internal(PHPDBG_G(io)[PHPDBG_STDERR].fd, strfmt, ##__VA_ARGS__) 58 #else 59 # define phpdbg_debug(strfmt, ...) 60 #endif 61 62 PHPDBG_API void phpdbg_free_err_buf(void); 63 PHPDBG_API void phpdbg_activate_err_buf(bool active); 64 PHPDBG_API int phpdbg_output_err_buf(const char *strfmt, ...); 65 66 int phpdbg_process_print(int fd, int type, const char *msg, int msglen); 67 68 69 /* {{{ For separation */ 70 #define SEPARATE "------------------------------------------------" /* }}} */ 71 72 #endif /* PHPDBG_OUT_H */ 73