- add HttpResponse::guessContentType() through libmagic
[m6w6/ext-http] / php_http_api.h
index 8906e2cda71793ae61fc92852e73c4fa3f4d8c49..42a99e0adff6c013a3f7fd51e8882770fb5c48e3 100644 (file)
@@ -19,6 +19,7 @@
 #define PHP_HTTP_API_H
 
 #include "php_http_std_defs.h"
+#include "php_http_send_api.h"
 
 #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);
@@ -35,6 +36,9 @@ extern STATUS _http_parse_key_list(const char *list, HashTable *items, char sepa
 #define http_error_ex _http_error_ex
 extern void _http_error_ex(long type, long code, const char *format, ...) PHP_ATTRIBUTE_FORMAT(printf, 3, 4);
 
+#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);
+
 #define http_exit(s, h) http_exit_ex((s), (h), NULL, 1)
 #define http_exit_ex(s, h, b, e) _http_exit_ex((s), (h), (b), (e) TSRMLS_CC)
 extern STATUS _http_exit_ex(int status, char *header, char *body, zend_bool send_header TSRMLS_DC);
@@ -60,6 +64,10 @@ PHP_HTTP_API STATUS _http_get_request_body_ex(char **body, size_t *length, zend_
 #define http_chunked_decode(e, el, d, dl) _http_chunked_decode((e), (el), (d), (dl) TSRMLS_CC)
 PHP_HTTP_API const char *_http_chunked_decode(const char *encoded, size_t encoded_len, char **decoded, size_t *decoded_len TSRMLS_DC);
 
+#define http_guess_content_type(mf, mm, d, l, m) _http_guess_content_type((mf), (mm), (d), (l), (m) TSRMLS_CC)
+PHP_HTTP_API char *_http_guess_content_type(const char *magic_file, long magic_mode, void *data_ptr, size_t data_len, http_send_mode mode TSRMLS_DC);
+
+
 #define http_locate_body _http_locate_body
 static inline const char *_http_locate_body(const char *message)
 {
@@ -75,6 +83,17 @@ static inline const char *_http_locate_body(const char *message)
        }
 }
 
+#define http_locate_eol _http_locate_eol
+static inline const char *_http_locate_eol(const char *line, size_t *eol_len)
+{
+       const char *eol = strpbrk(line, "\r\n");
+       
+       if (eol_len) {
+               *eol_len = eol ? ((eol[0] == '\r' && eol[1] == '\n') ? 2 : 1) : 0;
+       }
+       return eol;
+}
+
 #endif
 
 /*