From: Michael Wallner Date: Mon, 30 Jul 2012 18:31:46 +0000 (+0000) Subject: add php_http_message_zip(): merge request/response messages for history X-Git-Tag: RELEASE_2_1_0_RC3~10^2^2~116 X-Git-Url: https://git.m6w6.name/?a=commitdiff_plain;h=b340a8fa0aacc9727d54bb3957eb6902bc350004;p=m6w6%2Fext-http add php_http_message_zip(): merge request/response messages for history --- diff --git a/php_http_message.c b/php_http_message.c index 34d9ed8..04e8706 100644 --- a/php_http_message.c +++ b/php_http_message.c @@ -462,6 +462,24 @@ PHP_HTTP_API php_http_message_t *php_http_message_reverse(php_http_message_t *ms return msg; } +PHP_HTTP_API php_http_message_t *php_http_message_zip(php_http_message_t *one, php_http_message_t *two) +{ + php_http_message_t *dst = php_http_message_copy(one, NULL), *src = php_http_message_copy(two, NULL), *tmp_dst, *tmp_src, *ret = dst; + + while(dst && src) { + tmp_dst = dst->parent; + tmp_src = src->parent; + dst->parent = src; + if (tmp_dst) { + src->parent = tmp_dst; + } + src = tmp_src; + dst = tmp_dst; + } + + return ret; +} + PHP_HTTP_API php_http_message_t *php_http_message_copy_ex(php_http_message_t *from, php_http_message_t *to, zend_bool parents) { php_http_message_t *temp, *copy = NULL; diff --git a/php_http_message.h b/php_http_message.h index fb991f5..766c0b4 100644 --- a/php_http_message.h +++ b/php_http_message.h @@ -61,6 +61,7 @@ PHP_HTTP_API void php_http_message_to_callback(php_http_message_t *msg, php_http PHP_HTTP_API void php_http_message_serialize(php_http_message_t *message, char **string, size_t *length); PHP_HTTP_API php_http_message_t *php_http_message_reverse(php_http_message_t *msg); +PHP_HTTP_API php_http_message_t *php_http_message_zip(php_http_message_t *one, php_http_message_t *two); #define php_http_message_count(c, m) \ { \