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

LCOV - code coverage report
Current view: top level - main - php_logos.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 15 29 51.7 %
Date: 2014-07-27 Functions: 3 5 60.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :    +----------------------------------------------------------------------+
       3             :    | PHP Version 5                                                        |
       4             :    +----------------------------------------------------------------------+
       5             :    | Copyright (c) 1997-2013 The PHP Group                                |
       6             :    +----------------------------------------------------------------------+
       7             :    | This source file is subject to version 3.01 of the PHP license,      |
       8             :    | that is bundled with this package in the file LICENSE, and is        |
       9             :    | available through the world-wide-web at the following url:           |
      10             :    | http://www.php.net/license/3_01.txt                                  |
      11             :    | If you did not receive a copy of the PHP license and are unable to   |
      12             :    | obtain it through the world-wide-web, please send a note to          |
      13             :    | license@php.net so we can mail you a copy immediately.               |
      14             :    +----------------------------------------------------------------------+
      15             :    | Author: Hartmut Holzgraefe <hholzgra@php.net>                        |
      16             :    +----------------------------------------------------------------------+
      17             : */
      18             : 
      19             : /* $Id$ */
      20             : 
      21             : #include "php.h"
      22             : #include "logos.h"
      23             : #include "php_logos.h"
      24             : #include "ext/standard/info.h"
      25             : #include "SAPI.h"
      26             : 
      27             : typedef struct _php_info_logo { 
      28             :         const char *mimetype;
      29             :         int mimelen;
      30             :         const unsigned char *data; 
      31             :         int size; 
      32             : } php_info_logo;
      33             : 
      34             : static HashTable phpinfo_logo_hash;
      35             : 
      36       58023 : PHPAPI int php_register_info_logo(char *logo_string, const char *mimetype, const unsigned char *data, int size)
      37             : {
      38             :         php_info_logo info_logo;
      39             : 
      40       58023 :         info_logo.mimetype = mimetype;
      41       58023 :         info_logo.mimelen  = strlen(mimetype);
      42       58023 :         info_logo.data     = data;
      43       58023 :         info_logo.size     = size;
      44             : 
      45       58023 :         return zend_hash_add(&phpinfo_logo_hash, logo_string, strlen(logo_string), &info_logo, sizeof(php_info_logo), NULL);
      46             : }
      47             : 
      48           0 : PHPAPI int php_unregister_info_logo(char *logo_string)
      49             : {
      50           0 :         return zend_hash_del(&phpinfo_logo_hash, logo_string, strlen(logo_string));
      51             : }
      52             : 
      53       19341 : int php_init_info_logos(void)
      54             : {
      55       19341 :         if(zend_hash_init(&phpinfo_logo_hash, 0, NULL, NULL, 1)==FAILURE) 
      56           0 :                 return FAILURE;
      57             : 
      58       19341 :         php_register_info_logo(PHP_LOGO_GUID    , "image/gif", php_logo    , sizeof(php_logo));
      59       19341 :         php_register_info_logo(PHP_EGG_LOGO_GUID, "image/gif", php_egg_logo, sizeof(php_egg_logo));
      60       19341 :         php_register_info_logo(ZEND_LOGO_GUID   , "image/gif", zend_logo   , sizeof(zend_logo));
      61             : 
      62       19341 :         return SUCCESS;
      63             : }
      64             : 
      65       19376 : int php_shutdown_info_logos(void)
      66             : {
      67       19376 :         zend_hash_destroy(&phpinfo_logo_hash);
      68       19376 :         return SUCCESS;
      69             : }
      70             : 
      71             : #define CONTENT_TYPE_HEADER "Content-Type: "
      72           0 : int php_info_logos(const char *logo_string TSRMLS_DC)
      73             : {
      74             :         php_info_logo *logo_image;
      75             :         char *content_header;
      76             :         int len;
      77             : 
      78           0 :         if(FAILURE==zend_hash_find(&phpinfo_logo_hash, (char *) logo_string, strlen(logo_string), (void **)&logo_image))
      79           0 :                 return 0;
      80             : 
      81           0 :         len = sizeof(CONTENT_TYPE_HEADER) - 1 + logo_image->mimelen;
      82           0 :         content_header = emalloc(len + 1);
      83           0 :         memcpy(content_header, CONTENT_TYPE_HEADER, sizeof(CONTENT_TYPE_HEADER) - 1);
      84           0 :         memcpy(content_header + sizeof(CONTENT_TYPE_HEADER) - 1 , logo_image->mimetype, logo_image->mimelen);
      85           0 :         content_header[len] = '\0';
      86           0 :         sapi_add_header(content_header, len, 0);
      87             : 
      88           0 :         PHPWRITE(logo_image->data, logo_image->size);
      89           0 :         return 1;
      90             : }
      91             : 
      92             : /*
      93             :  * Local variables:
      94             :  * tab-width: 4
      95             :  * c-basic-offset: 4
      96             :  * End:
      97             :  * vim600: sw=4 ts=4 fdm=marker
      98             :  * vim<600: sw=4 ts=4
      99             :  */

Generated by: LCOV version 1.10

Generated at Sun, 27 Jul 2014 12:58:42 +0000 (2 days ago)

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