PHP  
 PHP: Test and Code Coverage Analysis
downloads | QA | documentation | faq | getting help | mailing lists | reporting bugs | php.net sites | links | my php.net 
 

LTP GCOV extension - code coverage report
Current view: directory - http - php_http_url_api.h
Test: PHP Code Coverage
Date: 2008-09-05 Instrumented lines: 51
Code covered: 80.4 % Executed lines: 41
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_url_api.h,v 1.13 2007/09/17 19:37:29 mike Exp $ */
      14                 : 
      15                 : #ifndef PHP_HTTP_URL_API_H
      16                 : #define PHP_HTTP_URL_API_H
      17                 : 
      18                 : #include "ext/standard/url.h"
      19                 : 
      20                 : extern PHP_MINIT_FUNCTION(http_url);
      21                 : 
      22                 : #define http_absolute_url(u) _http_absolute_url_ex((u), HTTP_URL_REPLACE TSRMLS_CC)
      23                 : #define http_absolute_url_ex(u, f) _http_absolute_url_ex((u), (f) TSRMLS_CC)
      24                 : PHP_HTTP_API char *_http_absolute_url_ex(const char *url, int flags TSRMLS_DC);
      25                 : 
      26                 : #define HTTP_URL_REPLACE                0x000
      27                 : #define HTTP_URL_JOIN_PATH              0x001
      28                 : #define HTTP_URL_JOIN_QUERY             0x002
      29                 : #define HTTP_URL_STRIP_USER             0x004
      30                 : #define HTTP_URL_STRIP_PASS             0x008
      31                 : #define HTTP_URL_STRIP_AUTH             (HTTP_URL_STRIP_USER|HTTP_URL_STRIP_PASS)
      32                 : #define HTTP_URL_STRIP_PORT             0x020
      33                 : #define HTTP_URL_STRIP_PATH             0x040
      34                 : #define HTTP_URL_STRIP_QUERY    0x080
      35                 : #define HTTP_URL_STRIP_FRAGMENT 0x100
      36                 : #define HTTP_URL_STRIP_ALL ( \
      37                 :         HTTP_URL_STRIP_AUTH | \
      38                 :         HTTP_URL_STRIP_PORT | \
      39                 :         HTTP_URL_STRIP_PATH | \
      40                 :         HTTP_URL_STRIP_QUERY | \
      41                 :         HTTP_URL_STRIP_FRAGMENT \
      42                 : )
      43                 : #define HTTP_URL_FROM_ENV               0x1000
      44                 : 
      45                 : #define http_build_url(f, o, n, p, s, l) _http_build_url((f), (o), (n), (p), (s), (l) TSRMLS_CC)
      46                 : PHP_HTTP_API void _http_build_url(int flags, const php_url *old_url, const php_url *new_url, php_url **url_ptr, char **url_str, size_t *url_len TSRMLS_DC);
      47                 : 
      48                 : #define http_urlencode_hash(h, q) _http_urlencode_hash_ex((h), 1, NULL, 0, (q), NULL TSRMLS_CC)
      49                 : #define http_urlencode_hash_ex(h, o, p, pl, q, ql) _http_urlencode_hash_ex((h), (o), (p), (pl), (q), (ql) TSRMLS_CC)
      50                 : PHP_HTTP_API STATUS _http_urlencode_hash_ex(HashTable *hash, zend_bool override_argsep, char *pre_encoded_data, size_t pre_encoded_len, char **encoded_data, size_t *encoded_len TSRMLS_DC);
      51                 : 
      52                 : #define http_urlencode_hash_recursive(ht, s, as, al, pr, pl) _http_urlencode_hash_recursive((ht), (s), (as), (al), (pr), (pl) TSRMLS_CC)
      53                 : PHP_HTTP_API STATUS _http_urlencode_hash_recursive(HashTable *ht, phpstr *str, const char *arg_sep, size_t arg_sep_len, const char *prefix, size_t prefix_len TSRMLS_DC);
      54                 : 
      55                 : #define http_url_from_struct(u, ht) _http_url_from_struct((u), (ht) TSRMLS_CC)
      56                 : static inline php_url *_http_url_from_struct(php_url *url, HashTable *ht TSRMLS_DC)
      57               5 : {
      58                 :         zval **e;
      59                 :         
      60               5 :         if (!url) {
      61               5 :                 url = ecalloc(1, sizeof(php_url));
      62                 :         }
      63                 :         
      64               5 :         if ((SUCCESS == zend_hash_find(ht, "scheme", sizeof("scheme"), (void *) &e))
      65                 :                         && (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)) {
      66               5 :                 url->scheme = estrndup(Z_STRVAL_PP(e), Z_STRLEN_PP(e));
      67                 :         }
      68               5 :         if ((SUCCESS == zend_hash_find(ht, "user", sizeof("user"), (void *) &e))
      69                 :                         && (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)) {
      70               0 :                 url->user = estrndup(Z_STRVAL_PP(e), Z_STRLEN_PP(e));
      71                 :         }
      72               5 :         if ((SUCCESS == zend_hash_find(ht, "pass", sizeof("pass"), (void *) &e))
      73                 :                         && (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)) {
      74               0 :                 url->pass = estrndup(Z_STRVAL_PP(e), Z_STRLEN_PP(e));
      75                 :         }
      76               5 :         if ((SUCCESS == zend_hash_find(ht, "host", sizeof("host"), (void *) &e))
      77                 :                         && (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)) {
      78               4 :                 url->host = estrndup(Z_STRVAL_PP(e), Z_STRLEN_PP(e));
      79                 :         }
      80               5 :         if ((SUCCESS == zend_hash_find(ht, "path", sizeof("path"), (void *) &e))
      81                 :                         && (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)) {
      82               2 :                 url->path = estrndup(Z_STRVAL_PP(e), Z_STRLEN_PP(e));
      83                 :         }
      84               5 :         if ((SUCCESS == zend_hash_find(ht, "query", sizeof("query"), (void *) &e))
      85                 :                         && (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)) {
      86               1 :                 url->query = estrndup(Z_STRVAL_PP(e), Z_STRLEN_PP(e));
      87                 :         }
      88               5 :         if ((SUCCESS == zend_hash_find(ht, "fragment", sizeof("fragment"), (void *) &e))
      89                 :                         && (Z_TYPE_PP(e) == IS_STRING) && Z_STRLEN_PP(e)) {
      90               2 :                 url->fragment = estrndup(Z_STRVAL_PP(e), Z_STRLEN_PP(e));
      91                 :         }
      92               5 :         if (SUCCESS == zend_hash_find(ht, "port", sizeof("port"), (void *) &e)) {
      93               2 :                 if (Z_TYPE_PP(e) == IS_LONG) {
      94               2 :                         url->port = (unsigned short) Z_LVAL_PP(e);
      95                 :                 } else {
      96               0 :                         zval *o = *e;
      97                 :                         
      98               0 :                         convert_to_long_ex(e);
      99               0 :                         url->port = (unsigned short) Z_LVAL_PP(e);
     100               0 :                         if (o != *e) zval_ptr_dtor(e);
     101                 :                 }
     102                 :         }
     103                 :         
     104               5 :         return url;
     105                 : }
     106                 : 
     107                 : #define http_url_tostruct(u, strct) _http_url_tostruct((u), (strct) TSRMLS_CC)
     108                 : static inline HashTable *_http_url_tostruct(php_url *url, zval *strct TSRMLS_DC)
     109               1 : {
     110                 :         zval arr;
     111                 :         
     112               1 :         if (strct) {
     113               1 :                 switch (Z_TYPE_P(strct)) {
     114                 :                         default:
     115               1 :                                 zval_dtor(strct);
     116               1 :                                 array_init(strct);
     117                 :                         case IS_ARRAY:
     118                 :                         case IS_OBJECT:
     119               1 :                                 INIT_ZARR(arr, HASH_OF(strct));
     120                 :                 }
     121                 :         } else {
     122               0 :                 INIT_PZVAL(&arr);
     123               0 :                 array_init(&arr);
     124                 :         }
     125                 :         
     126               1 :         if (url) {
     127               1 :                 if (url->scheme) {
     128               1 :                         add_assoc_string(&arr, "scheme", url->scheme, 1);
     129                 :                 }
     130               1 :                 if (url->user) {
     131               0 :                         add_assoc_string(&arr, "user", url->user, 1);
     132                 :                 }
     133               1 :                 if (url->pass) {
     134               0 :                         add_assoc_string(&arr, "pass", url->pass, 1);
     135                 :                 }
     136               1 :                 if (url->host) {
     137               1 :                         add_assoc_string(&arr, "host", url->host, 1);
     138                 :                 }
     139               1 :                 if (url->port) {
     140               1 :                         add_assoc_long(&arr, "port", (long) url->port);
     141                 :                 }
     142               1 :                 if (url->path) {
     143               1 :                         add_assoc_string(&arr, "path", url->path, 1);
     144                 :                 }
     145               1 :                 if (url->query) {
     146               1 :                         add_assoc_string(&arr, "query", url->query, 1);
     147                 :                 }
     148               1 :                 if (url->fragment) {
     149               1 :                         add_assoc_string(&arr, "fragment", url->fragment, 1);
     150                 :                 }
     151                 :         }
     152                 :         
     153               1 :         return Z_ARRVAL(arr);
     154                 : }
     155                 : 
     156                 : #endif
     157                 : 
     158                 : /*
     159                 :  * Local variables:
     160                 :  * tab-width: 4
     161                 :  * c-basic-offset: 4
     162                 :  * End:
     163                 :  * vim600: noet sw=4 ts=4 fdm=marker
     164                 :  * vim<600: noet sw=4 ts=4
     165                 :  */
     166                 : 

Generated by: LTP GCOV extension version 1.5

Generated at Fri, 05 Sep 2008 19:43:36 +0000 (31 hours ago)

Copyright © 2005-2008 The PHP Group
All rights reserved.