+extern void _http_error_ex(long type TSRMLS_DC, long code, const char *format, ...);
+
+#define HTTP_CHECK_CURL_INIT(ch, init, action) \
+ if ((!(ch)) && (!((ch) = init))) { \
+ http_error(HE_WARNING, HTTP_E_REQUEST, "Could not initialize curl"); \
+ action; \
+ }
+#define HTTP_CHECK_CONTENT_TYPE(ct, action) \
+ if (!strchr((ct), '/')) { \
+ http_error_ex(HE_WARNING, HTTP_E_INVALID_PARAM, \
+ "Content type \"%s\" does not seem to contain a primary and a secondary part", (ct)); \
+ action; \
+ }
+#define HTTP_CHECK_MESSAGE_TYPE_RESPONSE(msg, action) \
+ if (!HTTP_MSG_TYPE(RESPONSE, (msg))) { \
+ http_error(HE_NOTICE, HTTP_E_MESSAGE_TYPE, "HttpMessage is not of type HTTP_MSG_RESPONSE"); \
+ action; \
+ }
+#define HTTP_CHECK_MESSAGE_TYPE_REQUEST(msg, action) \
+ if (!HTTP_MSG_TYPE(REQUEST, (msg))) { \
+ http_error(HE_NOTICE, HTTP_E_MESSAGE_TYPE, "HttpMessage is not of type HTTP_MSG_REQUEST"); \
+ action; \
+ }
+#define HTTP_CHECK_GZIP_LEVEL(level, action) \
+ if (level < -1 || level > 9) { \
+ http_error_ex(HE_WARNING, HTTP_E_INVALID_PARAM, "Invalid compression level (-1 to 9): %d", level); \
+ action; \
+ }
+
+#define HTTP_CHECK_HEADERS_SENT(action) \
+ if (SG(headers_sent) && !SG(request_info).no_headers) { \
+ char *output_start_filename = php_get_output_start_filename(TSRMLS_C); \
+ int output_start_lineno = php_get_output_start_lineno(TSRMLS_C); \
+ \
+ if (output_start_filename) { \
+ http_error_ex(HE_WARNING, HTTP_E_HEADER, "Cannot modify header information - headers already sent by (output started at %s:%d)", \
+ output_start_filename, output_start_lineno); \
+ } else { \
+ http_error(HE_WARNING, HTTP_E_HEADER, "Cannot modify header information - headers already sent"); \
+ } \
+ action; \
+ }
+
+#define HTTP_CHECK_OPEN_BASEDIR(file, act) \
+ if ((PG(open_basedir) && *PG(open_basedir)) || PG(safe_mode)) \
+ { \
+ const char *tmp = file; \
+ \
+ if (!strncasecmp(tmp, "file:", lenof("file:"))) { \
+ tmp += lenof("file:"); \
+ while ((tmp - (const char *)file < 7) && (*tmp == '/' || *tmp == '\\')) ++tmp; \
+ } \
+ \
+ if ( (tmp != file || !strstr(file, "://")) && \
+ (!*tmp || php_check_open_basedir(tmp TSRMLS_CC) || \
+ (PG(safe_mode) && !php_checkuid(tmp, "rb+", CHECKUID_CHECK_MODE_PARAM)))) { \
+ act; \
+ } \
+ }
+
+#define http_log(f, i, m) _http_log_ex((f), (i), (m) TSRMLS_CC)
+extern void http_log_ex(char *file, const char *ident, const char *message TSRMLS_DC);