X-Git-Url: https://git.m6w6.name/?a=blobdiff_plain;f=php_http_negotiate.h;h=5a0d6af40079355dde36ed8284f2544aec70722a;hb=707ee66a824e2bb5daad723f75682aea777b09a3;hp=d8814faba41794523d5158156bb5cf73efe6d96f;hpb=d3485e3b28336153dca690e872ffe1ddc60fedd2;p=m6w6%2Fext-http diff --git a/php_http_negotiate.h b/php_http_negotiate.h index d8814fa..5a0d6af 100644 --- a/php_http_negotiate.h +++ b/php_http_negotiate.h @@ -6,29 +6,23 @@ | modification, are permitted provided that the conditions mentioned | | in the accompanying LICENSE file are met. | +--------------------------------------------------------------------+ - | Copyright (c) 2004-2010, Michael Wallner | + | Copyright (c) 2004-2011, Michael Wallner | +--------------------------------------------------------------------+ */ -/* $Id: php_http_headers_api.h 300300 2010-06-09 07:29:35Z mike $ */ - #ifndef PHP_HTTP_NEGOTIATE_H #define PHP_HTTP_NEGOTIATE_H -typedef char *(*php_http_negotiate_func_t)(const char *test, double *quality, HashTable *supported TSRMLS_DC); - -extern char *php_http_negotiate_language_func(const char *test, double *quality, HashTable *supported TSRMLS_DC); -extern char *php_http_negotiate_default_func(const char *test, double *quality, HashTable *supported TSRMLS_DC); - -PHP_HTTP_API HashTable *php_http_negotiate(const char *value, HashTable *supported, php_http_negotiate_func_t neg TSRMLS_DC); +PHP_HTTP_API HashTable *php_http_negotiate(const char *value_str, size_t value_len, HashTable *supported, const char *primary_sep_str, size_t primary_sep_len TSRMLS_DC); static inline HashTable *php_http_negotiate_language(HashTable *supported TSRMLS_DC) { HashTable *result = NULL; - char *value = php_http_env_get_request_header(ZEND_STRL("Accept-Language") TSRMLS_CC); + size_t length; + char *value = php_http_env_get_request_header(ZEND_STRL("Accept-Language"), &length TSRMLS_CC); if (value) { - result = php_http_negotiate(value, supported, php_http_negotiate_language_func TSRMLS_CC); + result = php_http_negotiate(value, length, supported, "-", 1 TSRMLS_CC); } STR_FREE(value); @@ -38,10 +32,11 @@ static inline HashTable *php_http_negotiate_language(HashTable *supported TSRMLS static inline HashTable *php_http_negotiate_encoding(HashTable *supported TSRMLS_DC) { HashTable *result = NULL; - char *value = php_http_env_get_request_header(ZEND_STRL("Accept-Encoding") TSRMLS_CC); + size_t length; + char *value = php_http_env_get_request_header(ZEND_STRL("Accept-Encoding"), &length TSRMLS_CC); if (value) { - result = php_http_negotiate(value, supported, NULL TSRMLS_CC); + result = php_http_negotiate(value, length, supported, NULL, 0 TSRMLS_CC); } STR_FREE(value); @@ -51,10 +46,11 @@ static inline HashTable *php_http_negotiate_encoding(HashTable *supported TSRMLS static inline HashTable *php_http_negotiate_charset(HashTable *supported TSRMLS_DC) { HashTable *result = NULL; - char *value = php_http_env_get_request_header(ZEND_STRL("Accept-Charset") TSRMLS_CC); + size_t length; + char *value = php_http_env_get_request_header(ZEND_STRL("Accept-Charset"), &length TSRMLS_CC); if (value) { - result = php_http_negotiate(value, supported, NULL TSRMLS_CC); + result = php_http_negotiate(value, length, supported, NULL, 0 TSRMLS_CC); } STR_FREE(value); @@ -64,17 +60,17 @@ static inline HashTable *php_http_negotiate_charset(HashTable *supported TSRMLS_ static inline HashTable *php_http_negotiate_content_type(HashTable *supported TSRMLS_DC) { HashTable *result = NULL; - char *value = php_http_env_get_request_header(ZEND_STRL("Accept") TSRMLS_CC); + size_t length; + char *value = php_http_env_get_request_header(ZEND_STRL("Accept"), &length TSRMLS_CC); if (value) { - result = php_http_negotiate(value, supported, NULL TSRMLS_CC); + result = php_http_negotiate(value, length, supported, "/", 1 TSRMLS_CC); } STR_FREE(value); return result; } - #endif /*