#include "php_http_cache_api.h"
#include "php_http_headers_api.h"
+#ifdef ZEND_ENGINE_2
+# include "php_http_exception_object.h"
+#endif
+
ZEND_EXTERN_MODULE_GLOBALS(http);
/* char *pretty_key(char *, size_t, zend_bool, zebd_bool) */
-char *pretty_key(char *key, size_t key_len, zend_bool uctitle, zend_bool xhyphen)
+char *_http_pretty_key(char *key, size_t key_len, zend_bool uctitle, zend_bool xhyphen)
{
if (key && key_len) {
unsigned i, wasalpha;
}
/* }}} */
+/* {{{ void http_error(long, long, char*) */
+void _http_error_ex(long type, long code, const char *format, ...)
+{
+ va_list args;
+ TSRMLS_FETCH();
+
+ va_start(args, format);
+ if (type == E_THROW) {
+#ifdef ZEND_ENGINE_2
+ char *message;
+ vspprintf(&message, 0, format, args);
+ zend_throw_exception(http_exception_get_default(), message, code TSRMLS_CC);
+#else
+ type = E_WARNING;
+#endif
+ }
+ if (type != E_THROW) {
+ php_verror(NULL, "", type, format, args TSRMLS_CC);
+ }
+ va_end(args);
+}
+/* }}} */
+
/* {{{ static STATUS http_ob_stack_get(php_ob_buffer *, php_ob_buffer **) */
static STATUS http_ob_stack_get(php_ob_buffer *o, php_ob_buffer **s)
{
/* read in chunk size */
while (isxdigit(*e_ptr)) {
if (i == 9) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,
- "Chunk size is too long: 0x%s...", hex_len);
+ http_error_ex(E_WARNING, HTTP_E_PARSE, "Chunk size is too long: 0x%s...", hex_len);
efree(*decoded);
return FAILURE;
}
/* new line */
if (strncmp(e_ptr, HTTP_CRLF, 2)) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,
- "Invalid character (expected 0x0D 0x0A; got: %x %x)",
- *e_ptr, *(e_ptr + 1));
+ http_error_ex(E_WARNING, HTTP_E_PARSE, "Invalid character (expected 0x0D 0x0A; got: %x %x)", *e_ptr, *(e_ptr + 1));
efree(*decoded);
return FAILURE;
}
char *error = NULL;
chunk_len = strtol(hex_len, &error, 16);
if (error == hex_len) {
- php_error_docref(NULL TSRMLS_CC, E_WARNING,
- "Invalid chunk size string: '%s'", hex_len);
+ http_error_ex(E_WARNING, HTTP_E_PARSE, "Invalid chunk size string: '%s'", hex_len);
efree(*decoded);
return FAILURE;
}
#include "php_http_std_defs.h"
-char *pretty_key(char *key, size_t key_len, zend_bool uctitle, zend_bool xhyphen);
+#define pretty_key(key, key_len, uctitle, xhyphen) _http_pretty_key(key, key_len, uctitle, xhyphen)
+extern char *_http_pretty_key(char *key, size_t key_len, zend_bool uctitle, zend_bool xhyphen);
+
+#define http_error(type, code, string) _http_error_ex(type, code, "%s", string)
+#define http_error_ex _http_error_ex
+extern void _http_error_ex(long type, long code, const char *format, ...);
#define HTTP_GSC(var, name, ret) HTTP_GSP(var, name, return ret)
#define HTTP_GSP(var, name, ret) \