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 - ext/hash - hash_crc32.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 34 34 100.0 %
Date: 2019-05-06 Functions: 7 7 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :   +----------------------------------------------------------------------+
       3             :   | PHP Version 7                                                        |
       4             :   +----------------------------------------------------------------------+
       5             :   | Copyright (c) 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             :   | Authors: Michael Wallner <mike@php.net>                              |
      16             :   |          Sara Golemon <pollita@php.net>                              |
      17             :   +----------------------------------------------------------------------+
      18             : */
      19             : 
      20             : #include "php_hash.h"
      21             : #include "php_hash_crc32.h"
      22             : #include "php_hash_crc32_tables.h"
      23             : 
      24         131 : PHP_HASH_API void PHP_CRC32Init(PHP_CRC32_CTX *context)
      25             : {
      26         131 :         context->state = ~0;
      27         131 : }
      28             : 
      29         365 : PHP_HASH_API void PHP_CRC32Update(PHP_CRC32_CTX *context, const unsigned char *input, size_t len)
      30             : {
      31             :         size_t i;
      32             : 
      33        4108 :         for (i = 0; i < len; ++i) {
      34        3743 :                 context->state = (context->state << 8) ^ crc32_table[(context->state >> 24) ^ (input[i] & 0xff)];
      35             :         }
      36         365 : }
      37             : 
      38         364 : PHP_HASH_API void PHP_CRC32BUpdate(PHP_CRC32_CTX *context, const unsigned char *input, size_t len)
      39             : {
      40             :         size_t i;
      41             : 
      42        4266 :         for (i = 0; i < len; ++i) {
      43        3902 :                 context->state = (context->state >> 8) ^ crc32b_table[(context->state ^ input[i]) & 0xff];
      44             :         }
      45         364 : }
      46             : 
      47          44 : PHP_HASH_API void PHP_CRC32CUpdate(PHP_CRC32_CTX *context, const unsigned char *input, size_t len)
      48             : {
      49             :         size_t i;
      50             : 
      51        2004 :         for (i = 0; i < len; ++i) {
      52        1960 :                 context->state = (context->state >> 8) ^ crc32c_table[(context->state ^ input[i]) & 0xff];
      53             :         }
      54          44 : }
      55             : 
      56          42 : PHP_HASH_API void PHP_CRC32LEFinal(unsigned char digest[4], PHP_CRC32_CTX *context)
      57             : {
      58          42 :         context->state=~context->state;
      59          42 :         digest[3] = (unsigned char) ((context->state >> 24) & 0xff);
      60          42 :         digest[2] = (unsigned char) ((context->state >> 16) & 0xff);
      61          42 :         digest[1] = (unsigned char) ((context->state >> 8) & 0xff);
      62          42 :         digest[0] = (unsigned char) (context->state & 0xff);
      63          42 :         context->state = 0;
      64          42 : }
      65             : 
      66          87 : PHP_HASH_API void PHP_CRC32BEFinal(unsigned char digest[4], PHP_CRC32_CTX *context)
      67             : {
      68          87 :         context->state=~context->state;
      69          87 :         digest[0] = (unsigned char) ((context->state >> 24) & 0xff);
      70          87 :         digest[1] = (unsigned char) ((context->state >> 16) & 0xff);
      71          87 :         digest[2] = (unsigned char) ((context->state >> 8) & 0xff);
      72          87 :         digest[3] = (unsigned char) (context->state & 0xff);
      73          87 :         context->state = 0;
      74          87 : }
      75             : 
      76          12 : PHP_HASH_API int PHP_CRC32Copy(const php_hash_ops *ops, PHP_CRC32_CTX *orig_context, PHP_CRC32_CTX *copy_context)
      77             : {
      78          12 :         copy_context->state = orig_context->state;
      79          12 :         return SUCCESS;
      80             : }
      81             : 
      82             : const php_hash_ops php_hash_crc32_ops = {
      83             :         (php_hash_init_func_t) PHP_CRC32Init,
      84             :         (php_hash_update_func_t) PHP_CRC32Update,
      85             :         (php_hash_final_func_t) PHP_CRC32LEFinal,
      86             :         (php_hash_copy_func_t) PHP_CRC32Copy,
      87             :         4, /* what to say here? */
      88             :         4,
      89             :         sizeof(PHP_CRC32_CTX),
      90             :         0
      91             : };
      92             : 
      93             : const php_hash_ops php_hash_crc32b_ops = {
      94             :         (php_hash_init_func_t) PHP_CRC32Init,
      95             :         (php_hash_update_func_t) PHP_CRC32BUpdate,
      96             :         (php_hash_final_func_t) PHP_CRC32BEFinal,
      97             :         (php_hash_copy_func_t) PHP_CRC32Copy,
      98             :         4, /* what to say here? */
      99             :         4,
     100             :         sizeof(PHP_CRC32_CTX),
     101             :         0
     102             : };
     103             : 
     104             : const php_hash_ops php_hash_crc32c_ops = {
     105             :         (php_hash_init_func_t) PHP_CRC32Init,
     106             :         (php_hash_update_func_t) PHP_CRC32CUpdate,
     107             :         (php_hash_final_func_t) PHP_CRC32BEFinal,
     108             :         (php_hash_copy_func_t) PHP_CRC32Copy,
     109             :         4, /* what to say here? */
     110             :         4,
     111             :         sizeof(PHP_CRC32_CTX),
     112             :         0
     113             : };

Generated by: LCOV version 1.10

Generated at Mon, 06 May 2019 17:58:15 +0000 (998 days ago)

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