LCOV - code coverage report
Current view: top level - http - php_http.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 59 63 93.7 %
Date: 2014-11-03 12:21:11 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       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-2014, Michael Wallner <mike@php.net>            |
      10             :     +--------------------------------------------------------------------+
      11             : */
      12             : 
      13             : #include "php_http_api.h"
      14             : 
      15             : #include <php_ini.h>
      16             : #include <ext/standard/info.h>
      17             : 
      18             : #include <zlib.h>
      19             : 
      20             : #if PHP_HTTP_HAVE_CURL
      21             : #       include <curl/curl.h>
      22             : #       if PHP_HTTP_HAVE_EVENT
      23             : #               if PHP_HTTP_HAVE_EVENT2
      24             : #                       include <event2/event.h>
      25             : #                       include <event2/event_struct.h>
      26             : #               else
      27             : #                       include <event.h>
      28             : #               endif
      29             : #       endif
      30             : #endif
      31             : #if PHP_HTTP_HAVE_SERF
      32             : #       include <serf.h>
      33             : #endif
      34             : 
      35             : ZEND_DECLARE_MODULE_GLOBALS(php_http);
      36             : 
      37             : #ifdef COMPILE_DL_HTTP
      38             : ZEND_GET_MODULE(http)
      39             : #endif
      40             : 
      41             : zend_function_entry http_functions[] = {
      42             :         EMPTY_FUNCTION_ENTRY
      43             : };
      44             : 
      45             : PHP_MINIT_FUNCTION(http);
      46             : PHP_MSHUTDOWN_FUNCTION(http);
      47             : PHP_RINIT_FUNCTION(http);
      48             : PHP_RSHUTDOWN_FUNCTION(http);
      49             : PHP_MINFO_FUNCTION(http);
      50             : 
      51             : static zend_module_dep http_module_deps[] = {
      52             :         ZEND_MOD_REQUIRED("raphf")
      53             :         ZEND_MOD_REQUIRED("propro")
      54             :         ZEND_MOD_REQUIRED("spl")
      55             : #ifdef PHP_HTTP_HAVE_HASH
      56             :         ZEND_MOD_REQUIRED("hash")
      57             : #endif
      58             : #ifdef PHP_HTTP_HAVE_ICONV
      59             :         ZEND_MOD_REQUIRED("iconv")
      60             : #endif
      61             : #ifdef PHP_HTTP_HAVE_JSON
      62             :         ZEND_MOD_REQUIRED("json")
      63             : #endif
      64             :         {NULL, NULL, NULL, 0}
      65             : };
      66             : 
      67             : zend_module_entry http_module_entry = {
      68             :         STANDARD_MODULE_HEADER_EX,
      69             :         NULL,
      70             :         http_module_deps,
      71             :         "http",
      72             :         http_functions,
      73             :         PHP_MINIT(http),
      74             :         PHP_MSHUTDOWN(http),
      75             :         PHP_RINIT(http),
      76             :         PHP_RSHUTDOWN(http),
      77             :         PHP_MINFO(http),
      78             :         PHP_PECL_HTTP_VERSION,
      79             :         STANDARD_MODULE_PROPERTIES
      80             : };
      81             : 
      82             : int http_module_number;
      83             : 
      84             : #if PHP_DEBUG && !HAVE_GCOV
      85             : void _dpf(int type, const char *data, size_t length)
      86             : {
      87             :         static const char _sym[] = "><><><";
      88             :         if (type) {
      89             :                 int nwp = 0;
      90             :                 for (fprintf(stderr, "%c ", _sym[type-1]); length--; data++) {
      91             :                         int ip = PHP_HTTP_IS_CTYPE(print, *data);
      92             :                         if (!ip && *data != '\r' && *data != '\n') nwp = 1;
      93             :                         fprintf(stderr, ip?"%c":"\\x%02x", (int) (*data & 0xff));
      94             :                         if (!nwp && *data == '\n' && length) {
      95             :                                 fprintf(stderr, "\n%c ", _sym[type-1]);
      96             :                         }
      97             :                 }
      98             :                 fprintf(stderr, "\n");
      99             :         } else {
     100             :                 fprintf(stderr, "# %.*s\n", (int) length, data);
     101             :         }
     102             : }
     103             : #endif
     104             : 
     105         408 : static void php_http_globals_init_once(zend_php_http_globals *G)
     106             : {
     107         408 :         memset(G, 0, sizeof(*G));
     108         408 : }
     109             : 
     110             : #if 0
     111             : static inline void php_http_globals_init(zend_php_http_globals *G TSRMLS_DC)
     112             : {
     113             : }
     114             : 
     115             : static inline void php_http_globals_free(zend_php_http_globals *G TSRMLS_DC)
     116             : {
     117             : }
     118             : #endif
     119             : 
     120             : #if ZTS && PHP_DEBUG && !HAVE_GCOV
     121             : zend_php_http_globals *php_http_globals(void)
     122             : {
     123             :         TSRMLS_FETCH();
     124             :         return PHP_HTTP_G;
     125             : }
     126             : #endif
     127             : 
     128             : PHP_INI_BEGIN()
     129             :         STD_PHP_INI_ENTRY("http.etag.mode", "crc32b", PHP_INI_ALL, OnUpdateString, env.etag_mode, zend_php_http_globals, php_http_globals)
     130             : PHP_INI_END()
     131             : 
     132         408 : PHP_MINIT_FUNCTION(http)
     133             : {
     134         408 :         http_module_number = module_number;
     135         408 :         ZEND_INIT_MODULE_GLOBALS(php_http, php_http_globals_init_once, NULL);
     136         408 :         REGISTER_INI_ENTRIES();
     137             :         
     138         408 :         if (0
     139         408 :         || SUCCESS != PHP_MINIT_CALL(http_exception)
     140         408 :         || SUCCESS != PHP_MINIT_CALL(http_cookie)
     141         408 :         || SUCCESS != PHP_MINIT_CALL(http_encoding)
     142         408 :         || SUCCESS != PHP_MINIT_CALL(http_filter)
     143         408 :         || SUCCESS != PHP_MINIT_CALL(http_header)
     144         408 :         || SUCCESS != PHP_MINIT_CALL(http_message)
     145         408 :         || SUCCESS != PHP_MINIT_CALL(http_message_parser)
     146         408 :         || SUCCESS != PHP_MINIT_CALL(http_message_body)
     147         408 :         || SUCCESS != PHP_MINIT_CALL(http_querystring)
     148         408 :         || SUCCESS != PHP_MINIT_CALL(http_client)
     149         408 :         || SUCCESS != PHP_MINIT_CALL(http_client_request)
     150         408 :         || SUCCESS != PHP_MINIT_CALL(http_client_response)
     151             : #if PHP_HTTP_HAVE_CURL
     152         408 :         || SUCCESS != PHP_MINIT_CALL(http_curl)
     153         408 :         || SUCCESS != PHP_MINIT_CALL(http_client_curl)
     154             : #endif
     155         408 :         || SUCCESS != PHP_MINIT_CALL(http_url)
     156         408 :         || SUCCESS != PHP_MINIT_CALL(http_env)
     157         408 :         || SUCCESS != PHP_MINIT_CALL(http_env_request)
     158         408 :         || SUCCESS != PHP_MINIT_CALL(http_env_response)
     159         408 :         || SUCCESS != PHP_MINIT_CALL(http_params)
     160             :         ) {
     161           0 :                 return FAILURE;
     162             :         }
     163             :         
     164         408 :         return SUCCESS;
     165             : }
     166             : 
     167             : 
     168             : 
     169         408 : PHP_MSHUTDOWN_FUNCTION(http)
     170             : {
     171         408 :         UNREGISTER_INI_ENTRIES();
     172             :         
     173         408 :         if (0
     174         408 :         || SUCCESS != PHP_MSHUTDOWN_CALL(http_message)
     175             : #if PHP_HTTP_HAVE_CURL
     176         408 :         || SUCCESS != PHP_MSHUTDOWN_CALL(http_client_curl)
     177         408 :         || SUCCESS != PHP_MSHUTDOWN_CALL(http_curl)
     178             : #endif
     179         408 :         || SUCCESS != PHP_MSHUTDOWN_CALL(http_client)
     180             :         ) {
     181           0 :                 return FAILURE;
     182             :         }
     183             :         
     184         408 :         return SUCCESS;
     185             : }
     186             : 
     187         408 : PHP_RINIT_FUNCTION(http)
     188             : {
     189         408 :         if (0
     190         408 :         || SUCCESS != PHP_RINIT_CALL(http_env)
     191             :         ) {
     192           0 :                 return FAILURE;
     193             :         }
     194             :         
     195         408 :         return SUCCESS;
     196             : }
     197             : 
     198         408 : PHP_RSHUTDOWN_FUNCTION(http)
     199             : {
     200         408 :         if (0
     201         408 :         || SUCCESS != PHP_RSHUTDOWN_CALL(http_env)
     202             :         ) {
     203           0 :                 return FAILURE;
     204             :         }
     205             :         
     206         408 :         return SUCCESS;
     207             : }
     208             : 
     209           1 : PHP_MINFO_FUNCTION(http)
     210             : {
     211             :         php_http_buffer_t buf;
     212             : 
     213           1 :         php_http_buffer_init(&buf);
     214             : 
     215           1 :         php_info_print_table_start();
     216           1 :         php_info_print_table_header(2, "HTTP Support", "enabled");
     217           1 :         php_info_print_table_row(2, "Extension Version", PHP_PECL_HTTP_VERSION);
     218           1 :         php_info_print_table_end();
     219             :         
     220           1 :         php_info_print_table_start();
     221           1 :         php_info_print_table_header(3, "Used Library", "Compiled", "Linked");
     222           1 :         php_info_print_table_row(3, "libz", ZLIB_VERSION, zlibVersion());
     223             : #if PHP_HTTP_HAVE_CURL
     224             :         {
     225           1 :                 curl_version_info_data *cv = curl_version_info(CURLVERSION_NOW);
     226           1 :                 php_info_print_table_row(3, "libcurl", LIBCURL_VERSION, cv->version);
     227             :         }
     228             : #else
     229             :         php_info_print_table_row(3, "libcurl", "disabled", "disabled");
     230             : #endif
     231             : 
     232             : #if PHP_HTTP_HAVE_EVENT
     233           1 :         php_info_print_table_row(3, "libevent",
     234             : #       ifdef LIBEVENT_VERSION
     235             :                         LIBEVENT_VERSION,
     236             : #       else
     237             :                         PHP_HTTP_EVENT_VERSION,
     238             : #       endif
     239             :                         event_get_version());
     240             : #else
     241             :         php_info_print_table_row(3, "libevent", "disabled", "disabled");
     242             : #endif
     243             : 
     244           1 :         php_info_print_table_end();
     245             :         
     246           1 :         DISPLAY_INI_ENTRIES();
     247           1 : }
     248             : 
     249             : 
     250             : /*
     251             :  * Local variables:
     252             :  * tab-width: 4
     253             :  * c-basic-offset: 4
     254             :  * End:
     255             :  * vim600: noet sw=4 ts=4 fdm=marker
     256             :  * vim<600: noet sw=4 ts=4
     257             :  */
     258             : 

Generated by: LCOV version 1.11