LTP GCOV extension - code coverage report
Current view: directory - ext/http - php_http_message_api.h
Test: PHP Code Coverage
Date: 2007-04-10 Instrumented lines: 13
Code covered: 100.0 % Executed lines: 13
Legend: not executed executed

       1                 : /*
       2                 :     +--------------------------------------------------------------------+
       3                 :     | PECL :: http                                                       |
       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-2007, Michael Wallner <mike@php.net>            |
      10                 :     +--------------------------------------------------------------------+
      11                 : */
      12                 : 
      13                 : /* $Id: php_http_message_api.h,v 1.25 2007/02/07 11:50:27 mike Exp $ */
      14                 : 
      15                 : #ifndef PHP_HTTP_MESSAGE_API_H
      16                 : #define PHP_HTTP_MESSAGE_API_H
      17                 : 
      18                 : #include "php_http_info_api.h"
      19                 : 
      20                 : typedef enum _http_message_type_t {
      21                 :         HTTP_MSG_NONE           = 0,
      22                 :         HTTP_MSG_REQUEST        = IS_HTTP_REQUEST,
      23                 :         HTTP_MSG_RESPONSE       = IS_HTTP_RESPONSE,
      24                 : } http_message_type;
      25                 : 
      26                 : typedef struct _http_message_t http_message;
      27                 : 
      28                 : struct _http_message_t {
      29                 :         phpstr body;
      30                 :         HashTable hdrs;
      31                 :         http_message_type type;
      32                 :         struct http_info http;
      33                 :         http_message *parent;
      34                 : };
      35                 : 
      36                 : /* required minimum length of an HTTP message "HTTP/1.1" */
      37                 : #define HTTP_MSG_MIN_SIZE 8
      38                 : 
      39                 : /* shorthand for type checks */
      40                 : #define HTTP_MSG_TYPE(TYPE, msg) ((msg) && ((msg)->type == HTTP_MSG_ ##TYPE))
      41                 : 
      42                 : #define http_message_new() http_message_init_ex(NULL, 0)
      43                 : #define http_message_init(m) http_message_init_ex((m), 0)
      44                 : #define http_message_init_ex(m, t) _http_message_init_ex((m), (t) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
      45                 : #define http_message_init_rel(m, t) _http_message_init_ex((m), (t) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC)
      46                 : PHP_HTTP_API http_message *_http_message_init_ex(http_message *m, http_message_type t ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
      47                 : #define http_message_init_env(m, t) _http_message_init_env((m), (t) TSRMLS_CC ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC)
      48                 : PHP_HTTP_API http_message *_http_message_init_env(http_message *m, http_message_type t TSRMLS_DC ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC);
      49                 : 
      50                 : #define http_message_set_type(m, t) _http_message_set_type((m), (t))
      51                 : PHP_HTTP_API void _http_message_set_type(http_message *m, http_message_type t);
      52                 : 
      53                 : #define http_message_set_info(m, i) _http_message_set_info((m), (i))
      54                 : PHP_HTTP_API void _http_message_set_info(http_message *message, http_info *info);
      55                 : 
      56                 : #define http_message_header(m, h) _http_message_header_ex((m), (h), sizeof(h), 1)
      57                 : #define http_message_header_ex _http_message_header_ex
      58                 : static inline zval *_http_message_header_ex(http_message *msg, char *key_str, size_t key_len, int join)
      59             295 : {
      60                 :         zval **header;
      61             295 :         if (SUCCESS == zend_hash_find(&msg->hdrs, key_str, key_len, (void *) &header)) {
      62             135 :                 if (join && Z_TYPE_PP(header) == IS_ARRAY) {
      63                 :                         zval *header_str, **val;
      64                 :                         HashPosition pos;
      65                 :                         phpstr str;
      66                 :                         
      67               1 :                         phpstr_init(&str);
      68               1 :                         MAKE_STD_ZVAL(header_str);
      69               3 :                         FOREACH_VAL(pos, *header, val) {
      70               2 :                                 phpstr_appendf(&str, PHPSTR_LEN(&str) ? ", %s":"%s", Z_STRVAL_PP(val));
      71                 :                         }
      72               1 :                         phpstr_fix(&str);
      73               1 :                         ZVAL_STRINGL(header_str, PHPSTR_VAL(&str), PHPSTR_LEN(&str), 0);
      74               1 :                         return header_str;
      75                 :                 } else {
      76             134 :                         ZVAL_ADDREF(*header);
      77             134 :                         return *header;
      78                 :                 }
      79                 :         }
      80             160 :         return NULL;
      81                 : }
      82                 : 
      83                 : #define http_message_count(c, m) \
      84                 : { \
      85                 :         http_message *__tmp_msg = (m); \
      86                 :         for (c = 0; __tmp_msg; __tmp_msg = __tmp_msg->parent, ++(c)); \
      87                 : }
      88                 : 
      89                 : #define http_message_parse(m, l) http_message_parse_ex(NULL, (m), (l))
      90                 : #define http_message_parse_ex(h, m, l) _http_message_parse_ex((h), (m), (l) ZEND_FILE_LINE_CC ZEND_FILE_LINE_EMPTY_CC TSRMLS_CC)
      91                 : #define http_message_parse_rel(h, m, l) _http_message_parse_ex((h), (m), (l) ZEND_FILE_LINE_RELAY_CC ZEND_FILE_LINE_ORIG_RELAY_CC TSRMLS_CC)
      92                 : PHP_HTTP_API http_message *_http_message_parse_ex(http_message *msg, const char *message, size_t length ZEND_FILE_LINE_DC ZEND_FILE_LINE_ORIG_DC TSRMLS_DC);
      93                 : 
      94                 : #define http_message_tostring(m, s, l) _http_message_tostring((m), (s), (l))
      95                 : PHP_HTTP_API void _http_message_tostring(http_message *msg, char **string, size_t *length);
      96                 : 
      97                 : #define http_message_serialize(m, s, l) _http_message_serialize((m), (s), (l))
      98                 : PHP_HTTP_API void _http_message_serialize(http_message *message, char **string, size_t *length);
      99                 : 
     100                 : #define http_message_reverse(m) _http_message_reverse(m)
     101                 : PHP_HTTP_API http_message *_http_message_reverse(http_message *msg);
     102                 : 
     103                 : #define http_message_interconnect(m1, m2) _http_message_interconnect((m1), (m2))
     104                 : PHP_HTTP_API http_message *_http_message_interconnect(http_message *m1, http_message *m2);
     105                 : 
     106                 : #define http_message_tostruct_recursive(m, s) _http_message_tostruct_recursive((m), (s) TSRMLS_CC)
     107                 : PHP_HTTP_API void _http_message_tostruct_recursive(http_message *msg, zval *strct TSRMLS_DC);
     108                 : 
     109                 : #define http_message_send(m) _http_message_send((m) TSRMLS_CC)
     110                 : PHP_HTTP_API STATUS _http_message_send(http_message *message TSRMLS_DC);
     111                 : 
     112                 : #define http_message_dup(m) _http_message_dup((m) TSRMLS_CC)
     113                 : PHP_HTTP_API http_message *_http_message_dup(http_message *msg TSRMLS_DC);
     114                 : 
     115                 : #define http_message_dtor(m) _http_message_dtor((m))
     116                 : PHP_HTTP_API void _http_message_dtor(http_message *message);
     117                 : 
     118                 : #define http_message_free(m) _http_message_free((m))
     119                 : PHP_HTTP_API void _http_message_free(http_message **message);
     120                 : 
     121                 : #endif
     122                 : 
     123                 : /*
     124                 :  * Local variables:
     125                 :  * tab-width: 4
     126                 :  * c-basic-offset: 4
     127                 :  * End:
     128                 :  * vim600: noet sw=4 ts=4 fdm=marker
     129                 :  * vim<600: noet sw=4 ts=4
     130                 :  */
     131                 : 

Generated by: LTP GCOV extension version 1.5