+ HTTP_KEYLIST_FIXVAL();
+ HTTP_KEYLIST_VAL(&array, keydup, val, vallen);
+ efree(keydup);
+ } while (!done);
+
+ return SUCCESS;
+}
+/* }}} */
+
+/* {{{ void http_error(long, long, char*) */
+void _http_error_ex(long type TSRMLS_DC, long code, const char *format, ...)
+{
+ va_list args;
+
+ va_start(args, format);
+#ifdef ZEND_ENGINE_2
+ if ((type == E_THROW) || (PG(error_handling) == EH_THROW)) {
+ char *message;
+
+ vspprintf(&message, 0, format, args);
+ zend_throw_exception(http_exception_get_for_code(code), message, code TSRMLS_CC);
+ efree(message);
+ } else
+#endif
+ php_verror(NULL, "", type, format, args TSRMLS_CC);
+ va_end(args);
+}
+/* }}} */
+
+/* {{{ void http_log(char *, char *, char *) */
+void _http_log_ex(char *file, const char *ident, const char *message TSRMLS_DC)
+{
+ time_t now;
+ struct tm nowtm;
+ char datetime[20] = {0};
+
+ now = HTTP_GET_REQUEST_TIME();
+ strftime(datetime, sizeof(datetime), "%Y-%m-%d %H:%M:%S", php_localtime_r(&now, &nowtm));
+
+#define HTTP_LOG_WRITE(file, type, msg) \
+ if (file && *file) { \
+ php_stream *log = php_stream_open_wrapper(file, "ab", REPORT_ERRORS|ENFORCE_SAFE_MODE, NULL); \
+ \
+ if (log) { \
+ php_stream_printf(log TSRMLS_CC, "%s\t[%s]\t%s\t<%s>%s", datetime, type, msg, SG(request_info).request_uri, PHP_EOL); \
+ php_stream_close(log); \
+ } \
+ \