2 +--------------------------------------------------------------------+
4 +--------------------------------------------------------------------+
5 | Redistribution and use in source and binary forms, with or without |
6 | modification, are permitted provided that the conditions mentioned |
7 | in the accompanying LICENSE file are met. |
8 +--------------------------------------------------------------------+
9 | Copyright (c) 2004-2011, Michael Wallner <mike@php.net> |
10 +--------------------------------------------------------------------+
13 #ifndef PHP_HTTP_NEGOTIATE_H
14 #define PHP_HTTP_NEGOTIATE_H
16 typedef char *(*php_http_negotiate_func_t
)(const char *test
, double *quality
, HashTable
*supported TSRMLS_DC
);
18 extern char *php_http_negotiate_language_func(const char *test
, double *quality
, HashTable
*supported TSRMLS_DC
);
19 extern char *php_http_negotiate_default_func(const char *test
, double *quality
, HashTable
*supported TSRMLS_DC
);
21 PHP_HTTP_API HashTable
*php_http_negotiate(const char *value
, HashTable
*supported
, php_http_negotiate_func_t neg TSRMLS_DC
);
23 static inline HashTable
*php_http_negotiate_language(HashTable
*supported TSRMLS_DC
)
25 HashTable
*result
= NULL
;
26 char *value
= php_http_env_get_request_header(ZEND_STRL("Accept-Language") TSRMLS_CC
);
29 result
= php_http_negotiate(value
, supported
, php_http_negotiate_language_func TSRMLS_CC
);
36 static inline HashTable
*php_http_negotiate_encoding(HashTable
*supported TSRMLS_DC
)
38 HashTable
*result
= NULL
;
39 char *value
= php_http_env_get_request_header(ZEND_STRL("Accept-Encoding") TSRMLS_CC
);
42 result
= php_http_negotiate(value
, supported
, NULL TSRMLS_CC
);
49 static inline HashTable
*php_http_negotiate_charset(HashTable
*supported TSRMLS_DC
)
51 HashTable
*result
= NULL
;
52 char *value
= php_http_env_get_request_header(ZEND_STRL("Accept-Charset") TSRMLS_CC
);
55 result
= php_http_negotiate(value
, supported
, NULL TSRMLS_CC
);
62 static inline HashTable
*php_http_negotiate_content_type(HashTable
*supported TSRMLS_DC
)
64 HashTable
*result
= NULL
;
65 char *value
= php_http_env_get_request_header(ZEND_STRL("Accept") TSRMLS_CC
);
68 result
= php_http_negotiate(value
, supported
, NULL TSRMLS_CC
);
83 * vim600: noet sw=4 ts=4 fdm=marker
84 * vim<600: noet sw=4 ts=4