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_adler32.c (source / functions) Hit Total Coverage
Test: PHP Code Coverage Lines: 24 26 92.3 %
Date: 2019-05-06 Functions: 4 4 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_adler32.h"
      22             : 
      23          17 : PHP_HASH_API void PHP_ADLER32Init(PHP_ADLER32_CTX *context)
      24             : {
      25          17 :         context->state = 1;
      26          17 : }
      27             : 
      28          15 : PHP_HASH_API void PHP_ADLER32Update(PHP_ADLER32_CTX *context, const unsigned char *input, size_t len)
      29             : {
      30             :         uint32_t i, s[2];
      31             : 
      32          15 :         s[0] = context->state & 0xffff;
      33          15 :         s[1] = (context->state >> 16) & 0xffff;
      34         557 :         for (i = 0; i < len; ++i) {
      35         542 :                 s[0] += input[i];
      36         542 :                 s[1] += s[0];
      37         542 :                 if (s[1]>=0x7fffffff)
      38             :                 {
      39           0 :                         s[0] = s[0] % 65521;
      40           0 :                         s[1] = s[1] % 65521;
      41             :                 }
      42             :         }
      43          15 :         s[0] = s[0] % 65521;
      44          15 :         s[1] = s[1] % 65521;
      45          15 :         context->state = s[0] + (s[1] << 16);
      46          15 : }
      47             : 
      48          17 : PHP_HASH_API void PHP_ADLER32Final(unsigned char digest[4], PHP_ADLER32_CTX *context)
      49             : {
      50          17 :         digest[0] = (unsigned char) ((context->state >> 24) & 0xff);
      51          17 :         digest[1] = (unsigned char) ((context->state >> 16) & 0xff);
      52          17 :         digest[2] = (unsigned char) ((context->state >> 8) & 0xff);
      53          17 :         digest[3] = (unsigned char) (context->state & 0xff);
      54          17 :         context->state = 0;
      55          17 : }
      56             : 
      57           4 : PHP_HASH_API int PHP_ADLER32Copy(const php_hash_ops *ops, PHP_ADLER32_CTX *orig_context, PHP_ADLER32_CTX *copy_context)
      58             : {
      59           4 :         copy_context->state = orig_context->state;
      60           4 :         return SUCCESS;
      61             : }
      62             : 
      63             : const php_hash_ops php_hash_adler32_ops = {
      64             :         (php_hash_init_func_t) PHP_ADLER32Init,
      65             :         (php_hash_update_func_t) PHP_ADLER32Update,
      66             :         (php_hash_final_func_t) PHP_ADLER32Final,
      67             :         (php_hash_copy_func_t) PHP_ADLER32Copy,
      68             :         4, /* what to say here? */
      69             :         4,
      70             :         sizeof(PHP_ADLER32_CTX),
      71             :         0
      72             : };

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.