-/* $Id: php_http_headers_api.h 300300 2010-06-09 07:29:35Z mike $ */
-
-#include "php_http.h"
-
-#include <ext/standard/php_string.h>
-
-#ifndef PHP_HTTP_DBG_NEG
-# define PHP_HTTP_DBG_NEG 0
-#endif
-
-char *php_http_negotiate_language_func(const char *test, double *quality, HashTable *supported TSRMLS_DC)
-{
- zval **value;
- HashPosition pos;
- const char *dash_test;
-
- FOREACH_HASH_VAL(pos, supported, value) {
-#if PHP_HTTP_DBG_NEG
- fprintf(stderr, "strcasecmp('%s', '%s')\n", Z_STRVAL_PP(value), test);
-#endif
- if (!strcasecmp(Z_STRVAL_PP(value), test)) {
- return Z_STRVAL_PP(value);
- }
- }
-
- /* no distinct match found, so try primaries */
- if ((dash_test = strchr(test, '-'))) {
- FOREACH_HASH_VAL(pos, supported, value) {
- int len = dash_test - test;
-#if PHP_HTTP_DBG_NEG
- fprintf(stderr, "strncasecmp('%s', '%s', %d)\n", Z_STRVAL_PP(value), test, len);
-#endif
- if ( (!strncasecmp(Z_STRVAL_PP(value), test, len)) &&
- ( (Z_STRVAL_PP(value)[len] == '\0') ||
- (Z_STRVAL_PP(value)[len] == '-'))) {
- *quality *= .9;
- return Z_STRVAL_PP(value);
- }
- }
- }
-
- return NULL;
-}
-
-
-char *php_http_negotiate_default_func(const char *test, double *quality, HashTable *supported TSRMLS_DC)
-{
- zval **value;
- HashPosition pos;
- (void) quality;
-
- FOREACH_HASH_VAL(pos, supported, value) {
-#if PHP_HTTP_DBG_NEG
- fprintf(stderr, "strcasecmp('%s', '%s')\n", Z_STRVAL_PP(value), test);
-#endif
- if (!strcasecmp(Z_STRVAL_PP(value), test)) {
- return Z_STRVAL_PP(value);
- }
- }
-
- return NULL;
-}
-