}
if (stat[0].st_dev == stat[1].st_dev && stat[0].st_ino == stat[1].st_ino) {
- phpdbg_script(P_STDOUT, "%.*s", buf, count);
+ phpdbg_script(P_STDOUT, "%.*s", (int) count, buf);
return count;
}
if (stat[2].st_dev == stat[1].st_dev && stat[2].st_ino == stat[1].st_ino) {
- phpdbg_script(P_STDERR, "%.*s", buf, count);
+ phpdbg_script(P_STDERR, "%.*s", (int) count, buf);
return count;
}
break;
sigaction(SIGBUS, &signal_struct, &PHPDBG_G(old_sigsegv_signal));
#endif
+ php_output_activate(TSRMLS_C);
+ php_output_deactivate(TSRMLS_C);
+
+ php_output_activate(TSRMLS_C);
+
if (php_request_startup(TSRMLS_C) == SUCCESS) {
int i;
-
- SG(request_info).argc = argc - php_optind + 1;
+
+ SG(request_info).argc = argc - php_optind + 1;
SG(request_info).argv = emalloc(SG(request_info).argc * sizeof(char *));
for (i = SG(request_info).argc; --i;) {
SG(request_info).argv[i] = estrdup(argv[php_optind - 1 + i]);
php_hash_environment(TSRMLS_C);
}
- /* make sure to turn off buffer for ev command */
- php_output_activate(TSRMLS_C);
- php_output_deactivate(TSRMLS_C);
-
/* do not install sigint handlers for remote consoles */
/* sending SIGINT then provides a decent way of shutting down the server */
#ifndef _WIN32
}
phpdbg_out:
#endif
-
+
{
int i;
/* free argv */
#ifndef ZTS
/* force cleanup of auto and core globals */
zend_hash_clean(CG(auto_globals));
- memset(
- &core_globals, 0, sizeof(php_core_globals));
+ memset( &core_globals, 0, sizeof(php_core_globals));
#endif
if (ini_entries) {
free(ini_entries);
if (ini_override) {
free(ini_override);
}
-
+
/* this must be forced */
CG(unclean_shutdown) = 0;
-
+
/* this is just helpful */
PG(report_memleaks) = 0;
php_request_shutdown((void*)0);
+ php_output_deactivate(TSRMLS_C);
+
zend_try {
php_module_shutdown(TSRMLS_C);
} zend_end_try();
if (cleaning || remote) {
goto phpdbg_main;
}
-
+
#ifdef ZTS
/* bugggy */
/* tsrm_shutdown(); */
if (sapi_name) {
free(sapi_name);
}
-
+
#ifdef _WIN32
free(bp_tmp_file);
#else
}
*s_ptr++ = ';';
} else {
- *s_ptr++ = s[i];
+ *s_ptr++ = old_s[i];
}
} while (i++ < old_slen);
}
if (msg) {
msgoutlen = asprintf(&msgout, "%.*s\n", msglen, msg);
} else {
- msgoutlen = asprintf(&msgout, "\n");
+ msgoutlen = 1;
+ msgout = strdup("\n");
}
break;
if (msg) {
msgoutlen = asprintf(&msgout, "%.*s\n", msglen, msg);
} else {
- msgoutlen = asprintf(&msgout, "");
+ msgoutlen = 0;
+ msgout = strdup("");
}
break;
fprintf(fp, "<stream type=\"%s\">", type == P_STDERR ? "stderr" : "stdout");
PHPDBG_G(in_script_xml) = type;
}
- buf = php_escape_html_entities((char *) msg, msglen, (size_t *) &buflen, 0, ENT_NOQUOTES, PG(internal_encoding) && PG(internal_encoding)[0] ? PG(internal_encoding) : (SG(default_charset) ? SG(default_charset) : "UTF-8") TSRMLS_CC);
+ buf = php_escape_html_entities((unsigned char *) msg, msglen, (size_t *) &buflen, 0, ENT_NOQUOTES, PG(internal_encoding) && PG(internal_encoding)[0] ? PG(internal_encoding) : (SG(default_charset) ? SG(default_charset) : "UTF-8") TSRMLS_CC);
fprintf(fp, "%.*s", buflen, buf);
efree(buf);
} else {
if ((PHPDBG_G(flags) & PHPDBG_WRITE_XML)) {
if (msgout) {
- buf = php_escape_html_entities(msgout, msgoutlen, (size_t *) &buflen, 0, ENT_COMPAT, PG(internal_encoding) && PG(internal_encoding)[0] ? PG(internal_encoding) : (SG(default_charset) ? SG(default_charset) : "UTF-8") TSRMLS_CC);
+ buf = php_escape_html_entities((unsigned char *) msgout, msgoutlen, (size_t *) &buflen, 0, ENT_COMPAT, PG(internal_encoding) && PG(internal_encoding)[0] ? PG(internal_encoding) : (SG(default_charset) ? SG(default_charset) : "UTF-8") TSRMLS_CC);
xmloutlen = fprintf(fp, "<%s severity=\"%s\" %.*s msgout=\"%.*s\" />", tag, severity, xmllen, xml, buflen, buf);
efree(buf);
return msgout ? msgoutlen : xmloutlen;
} /* }}} */
-PHPDBG_API void phpdbg_free_err_buf(TSRMLS_D) {
- if (PHPDBG_G(err_buf).type == 0) {
- return;
- }
-
- PHPDBG_G(err_buf).type = 0;
-
- efree(PHPDBG_G(err_buf).tag);
- efree(PHPDBG_G(err_buf).msg);
- efree(PHPDBG_G(err_buf).xml);
-}
-
-PHPDBG_API void phpdbg_activate_err_buf(zend_bool active TSRMLS_DC) {
- PHPDBG_G(err_buf).active = active;
-}
-
-PHPDBG_API int phpdbg_output_err_buf(const char *tag, const char *xmlfmt, const char *strfmt TSRMLS_DC, ...) {
- int len;
- va_list args;
- int errbuf_active = PHPDBG_G(err_buf).active;
-
- PHPDBG_G(err_buf).active = 0;
-
-#ifdef ZTS
- va_start(args, tsrm_ls);
-#else
- va_start(args, strfmt);
-#endif
- len = phpdbg_vprint(PHPDBG_G(err_buf).type TSRMLS_CC, PHPDBG_G(err_buf).fp, tag ? tag : PHPDBG_G(err_buf).tag, xmlfmt, strfmt, args);
- va_end(args);
-
- PHPDBG_G(err_buf).active = errbuf_active;
- phpdbg_free_err_buf(TSRMLS_C);
-
- return len;
-}
-
PHPDBG_API int phpdbg_vprint(int type TSRMLS_DC, FILE *fp, const char *tag, const char *xmlfmt, const char *strfmt, va_list args) {
char *msg = NULL, *xml = NULL;
int msglen = 0, xmllen = 0;
int len;
+ va_list argcpy;
if (strfmt != NULL && strlen(strfmt) > 0L) {
- msglen = phpdbg_xml_vasprintf(&msg, strfmt, 0, args TSRMLS_CC);
+ va_copy(argcpy, args);
+ msglen = phpdbg_xml_vasprintf(&msg, strfmt, 0, argcpy TSRMLS_CC);
+ va_end(argcpy);
}
if (PHPDBG_G(flags) & PHPDBG_WRITE_XML) {
if (xmlfmt != NULL && strlen(xmlfmt) > 0L) {
- xmllen = phpdbg_xml_vasprintf(&xml, xmlfmt, 1, args TSRMLS_CC);
+ va_copy(argcpy, args);
+ xmllen = phpdbg_xml_vasprintf(&xml, xmlfmt, 1, argcpy TSRMLS_CC);
+ va_end(argcpy);
}
}
if (PHPDBG_G(err_buf).active && type != P_STDOUT && type != P_STDERR) {
PHPDBG_G(err_buf).type = type;
PHPDBG_G(err_buf).fp = fp;
- PHPDBG_G(err_buf).tag = estrdup(tag);
+ PHPDBG_G(err_buf).tag = strdup(tag);
PHPDBG_G(err_buf).msg = msg;
PHPDBG_G(err_buf).msglen = msglen;
PHPDBG_G(err_buf).xml = xml;
return len;
}
+PHPDBG_API void phpdbg_free_err_buf(TSRMLS_D) {
+ if (PHPDBG_G(err_buf).type == 0) {
+ return;
+ }
+
+ PHPDBG_G(err_buf).type = 0;
+
+ free(PHPDBG_G(err_buf).tag);
+ free(PHPDBG_G(err_buf).msg);
+ free(PHPDBG_G(err_buf).xml);
+}
+
+PHPDBG_API void phpdbg_activate_err_buf(zend_bool active TSRMLS_DC) {
+ PHPDBG_G(err_buf).active = active;
+}
+
+PHPDBG_API int phpdbg_output_err_buf(const char *tag, const char *xmlfmt, const char *strfmt TSRMLS_DC, ...) {
+ int len;
+ va_list args;
+ int errbuf_active = PHPDBG_G(err_buf).active;
+
+ PHPDBG_G(err_buf).active = 0;
+
+#ifdef ZTS
+ va_start(args, tsrm_ls);
+#else
+ va_start(args, strfmt);
+#endif
+ len = phpdbg_vprint(PHPDBG_G(err_buf).type TSRMLS_CC, PHPDBG_G(err_buf).fp, tag ? tag : PHPDBG_G(err_buf).tag, xmlfmt, strfmt, args);
+ va_end(args);
+
+ PHPDBG_G(err_buf).active = errbuf_active;
+ phpdbg_free_err_buf(TSRMLS_C);
+
+ return len;
+}
+
PHPDBG_API int phpdbg_print(int type TSRMLS_DC, FILE *fp, const char *tag, const char *xmlfmt, const char *strfmt, ...) {
va_list args;
+ int len;
va_start(args, strfmt);
- phpdbg_vprint(type TSRMLS_CC, fp, tag, xmlfmt, strfmt, args);
+ len = phpdbg_vprint(type TSRMLS_CC, fp, tag, xmlfmt, strfmt, args);
va_end(args);
+
+ return len;
}
PHPDBG_API int phpdbg_xml_internal(FILE *fp TSRMLS_DC, const char *fmt, ...) {