juggle around negotiation stuff
authorMichael Wallner <mike@php.net>
Sat, 14 Jan 2012 10:54:42 +0000 (10:54 +0000)
committerMichael Wallner <mike@php.net>
Sat, 14 Jan 2012 10:54:42 +0000 (10:54 +0000)
php_http_env.c
php_http_negotiate.h

index 789f42b7b84c0ded07280b71402a08aef71091fe..ae099848d0784b1fc535508b2a973f8e517d4f5f 100644 (file)
@@ -714,62 +714,6 @@ PHP_METHOD(HttpEnv, setResponseCode)
        RETURN_FALSE;
 }
 
-
-#define PHP_HTTP_DO_NEGOTIATE_DEFAULT(supported) \
-       { \
-               zval **value; \
-                \
-               zend_hash_internal_pointer_reset((supported)); \
-               if (SUCCESS == zend_hash_get_current_data((supported), (void *) &value)) { \
-                       RETVAL_ZVAL(*value, 1, 0); \
-               } else { \
-                       RETVAL_NULL(); \
-               } \
-       }
-
-#define PHP_HTTP_DO_NEGOTIATE_HANDLE_DEFAULT(supported, rs_array) \
-       PHP_HTTP_DO_NEGOTIATE_DEFAULT(supported); \
-       if (rs_array) { \
-               HashPosition pos; \
-               zval **value_ptr; \
-                \
-               FOREACH_HASH_VAL(pos, supported, value_ptr) { \
-                       zval *value = php_http_ztyp(IS_STRING, *value_ptr); \
-                       add_assoc_double(rs_array, Z_STRVAL_P(value), 1.0); \
-                       zval_ptr_dtor(&value); \
-               } \
-       }
-
-#define PHP_HTTP_DO_NEGOTIATE_HANDLE_RESULT(result, supported, rs_array) \
-       { \
-               char *key; \
-               uint key_len; \
-               ulong idx; \
-                \
-               if (zend_hash_num_elements(result) && HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(result, &key, &key_len, &idx, 1, NULL)) { \
-                       RETVAL_STRINGL(key, key_len-1, 0); \
-               } else { \
-                       PHP_HTTP_DO_NEGOTIATE_DEFAULT(supported); \
-               } \
-               \
-               if (rs_array) { \
-                       zend_hash_copy(Z_ARRVAL_P(rs_array), result, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); \
-               } \
-               \
-               zend_hash_destroy(result); \
-               FREE_HASHTABLE(result); \
-       }
-
-#define PHP_HTTP_DO_NEGOTIATE(type, supported, rs_array) \
-       { \
-               HashTable *result; \
-               if ((result = php_http_negotiate_ ##type(supported TSRMLS_CC))) { \
-                       PHP_HTTP_DO_NEGOTIATE_HANDLE_RESULT(result, supported, rs_array); \
-               } else { \
-                       PHP_HTTP_DO_NEGOTIATE_HANDLE_DEFAULT(supported, rs_array); \
-               } \
-       }
-
 PHP_METHOD(HttpEnv, negotiateLanguage)
 {
        HashTable *supported;
index 5a0d6af40079355dde36ed8284f2544aec70722a..23c03ae853ee14df1622d2f7c4b8c44ed4aca32d 100644 (file)
@@ -71,6 +71,62 @@ static inline HashTable *php_http_negotiate_content_type(HashTable *supported TS
        return result;
 }
 
+#define PHP_HTTP_DO_NEGOTIATE_DEFAULT(supported) \
+       { \
+               zval **value; \
+                \
+               zend_hash_internal_pointer_reset((supported)); \
+               if (SUCCESS == zend_hash_get_current_data((supported), (void *) &value)) { \
+                       RETVAL_ZVAL(*value, 1, 0); \
+               } else { \
+                       RETVAL_NULL(); \
+               } \
+       }
+
+#define PHP_HTTP_DO_NEGOTIATE_HANDLE_DEFAULT(supported, rs_array) \
+       PHP_HTTP_DO_NEGOTIATE_DEFAULT(supported); \
+       if (rs_array) { \
+               HashPosition pos; \
+               zval **value_ptr; \
+                \
+               FOREACH_HASH_VAL(pos, supported, value_ptr) { \
+                       zval *value = php_http_ztyp(IS_STRING, *value_ptr); \
+                       add_assoc_double(rs_array, Z_STRVAL_P(value), 1.0); \
+                       zval_ptr_dtor(&value); \
+               } \
+       }
+
+#define PHP_HTTP_DO_NEGOTIATE_HANDLE_RESULT(result, supported, rs_array) \
+       { \
+               char *key; \
+               uint key_len; \
+               ulong idx; \
+                \
+               if (zend_hash_num_elements(result) && HASH_KEY_IS_STRING == zend_hash_get_current_key_ex(result, &key, &key_len, &idx, 1, NULL)) { \
+                       RETVAL_STRINGL(key, key_len-1, 0); \
+               } else { \
+                       PHP_HTTP_DO_NEGOTIATE_DEFAULT(supported); \
+               } \
+               \
+               if (rs_array) { \
+                       zend_hash_copy(Z_ARRVAL_P(rs_array), result, (copy_ctor_func_t) zval_add_ref, NULL, sizeof(zval *)); \
+               } \
+               \
+               zend_hash_destroy(result); \
+               FREE_HASHTABLE(result); \
+       }
+
+#define PHP_HTTP_DO_NEGOTIATE(type, supported, rs_array) \
+       { \
+               HashTable *result; \
+               if ((result = php_http_negotiate_ ##type(supported TSRMLS_CC))) { \
+                       PHP_HTTP_DO_NEGOTIATE_HANDLE_RESULT(result, supported, rs_array); \
+               } else { \
+                       PHP_HTTP_DO_NEGOTIATE_HANDLE_DEFAULT(supported, rs_array); \
+               } \
+       }
+
+
 #endif
 
 /*