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: 30 30 100.0 %
Date: 2014-12-15 Functions: 6 6 100.0 %
Legend: Lines: hit not hit

          Line data    Source code
       1             : /*
       2             :   +----------------------------------------------------------------------+
       3             :   | PHP Version 5                                                        |
       4             :   +----------------------------------------------------------------------+
       5             :   | Copyright (c) 1997-2014 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             : /* $Id$ */
      21             : 
      22             : #include "php_hash.h"
      23             : #include "php_hash_crc32.h"
      24             : #include "php_hash_crc32_tables.h"
      25             : 
      26          90 : PHP_HASH_API void PHP_CRC32Init(PHP_CRC32_CTX *context)
      27             : {
      28          90 :         context->state = ~0;
      29          90 : }
      30             : 
      31         372 : PHP_HASH_API void PHP_CRC32Update(PHP_CRC32_CTX *context, const unsigned char *input, size_t len)
      32             : {
      33             :         size_t i;
      34             :         
      35        4251 :         for (i = 0; i < len; ++i) {
      36        3879 :                 context->state = (context->state << 8) ^ crc32_table[(context->state >> 24) ^ (input[i] & 0xff)];
      37             :         }
      38         372 : }
      39             : 
      40         369 : PHP_HASH_API void PHP_CRC32BUpdate(PHP_CRC32_CTX *context, const unsigned char *input, size_t len)
      41             : {
      42             :         size_t i;
      43             :         
      44        4218 :         for (i = 0; i < len; ++i) {
      45        3849 :                 context->state = (context->state >> 8) ^ crc32b_table[(context->state ^ input[i]) & 0xff];
      46             :         }
      47         369 : }
      48             : 
      49          44 : PHP_HASH_API void PHP_CRC32Final(unsigned char digest[4], PHP_CRC32_CTX *context)
      50             : {
      51          44 :         context->state=~context->state;
      52          44 :         digest[3] = (unsigned char) ((context->state >> 24) & 0xff);
      53          44 :         digest[2] = (unsigned char) ((context->state >> 16) & 0xff);
      54          44 :         digest[1] = (unsigned char) ((context->state >> 8) & 0xff);
      55          44 :         digest[0] = (unsigned char) (context->state & 0xff);
      56          44 :         context->state = 0;
      57          44 : }
      58             : 
      59          44 : PHP_HASH_API void PHP_CRC32BFinal(unsigned char digest[4], PHP_CRC32_CTX *context)
      60             : {
      61          44 :         context->state=~context->state;
      62          44 :         digest[0] = (unsigned char) ((context->state >> 24) & 0xff);
      63          44 :         digest[1] = (unsigned char) ((context->state >> 16) & 0xff);
      64          44 :         digest[2] = (unsigned char) ((context->state >> 8) & 0xff);
      65          44 :         digest[3] = (unsigned char) (context->state & 0xff);
      66          44 :         context->state = 0;
      67          44 : }
      68             : 
      69           6 : PHP_HASH_API int PHP_CRC32Copy(const php_hash_ops *ops, PHP_CRC32_CTX *orig_context, PHP_CRC32_CTX *copy_context)
      70             : {
      71           6 :         copy_context->state = orig_context->state;
      72           6 :         return SUCCESS;
      73             : }
      74             : 
      75             : const php_hash_ops php_hash_crc32_ops = {
      76             :         (php_hash_init_func_t) PHP_CRC32Init,
      77             :         (php_hash_update_func_t) PHP_CRC32Update,
      78             :         (php_hash_final_func_t) PHP_CRC32Final,
      79             :         (php_hash_copy_func_t) PHP_CRC32Copy,
      80             :         4, /* what to say here? */
      81             :         4,
      82             :         sizeof(PHP_CRC32_CTX)
      83             : };
      84             : 
      85             : const php_hash_ops php_hash_crc32b_ops = {
      86             :         (php_hash_init_func_t) PHP_CRC32Init,
      87             :         (php_hash_update_func_t) PHP_CRC32BUpdate,
      88             :         (php_hash_final_func_t) PHP_CRC32BFinal,
      89             :         (php_hash_copy_func_t) PHP_CRC32Copy,
      90             :         4, /* what to say here? */
      91             :         4,
      92             :         sizeof(PHP_CRC32_CTX)
      93             : };
      94             : 
      95             : /*
      96             :  * Local variables:
      97             :  * tab-width: 4
      98             :  * c-basic-offset: 4
      99             :  * End:
     100             :  * vim600: sw=4 ts=4 fdm=marker
     101             :  * vim<600: sw=4 ts=4
     102             :  */

Generated by: LCOV version 1.10

Generated at Mon, 15 Dec 2014 17:02:42 +0000 (2 days ago)

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