LTP GCOV extension - code coverage report
Current view: directory - ext/hash - hash_adler32.c
Test: PHP Code Coverage
Date: 2007-04-10 Instrumented lines: 18
Code covered: 0.0 % Executed lines: 0
Legend: not executed executed

       1                 : /*
       2                 :   +----------------------------------------------------------------------+
       3                 :   | PHP Version 5                                                        |
       4                 :   +----------------------------------------------------------------------+
       5                 :   | Copyright (c) 1997-2007 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: hash_adler32.c,v 1.3.2.4.2.2 2007/01/08 22:29:25 nlopess Exp $ */
      21                 : 
      22                 : #include "php_hash.h"
      23                 : #include "php_hash_adler32.h"
      24                 : 
      25                 : PHP_HASH_API void PHP_ADLER32Init(PHP_ADLER32_CTX *context)
      26               0 : {
      27               0 :         context->state = 1;
      28               0 : }
      29                 : 
      30                 : PHP_HASH_API void PHP_ADLER32Update(PHP_ADLER32_CTX *context, const unsigned char *input, size_t len)
      31               0 : {
      32                 :         php_hash_uint32 i, s[2];
      33                 :         
      34               0 :         s[0] = context->state & 0xffff;
      35               0 :         s[1] = (context->state >> 16) & 0xffff;
      36               0 :         for (i = 0; i < len; ++i) {
      37               0 :                 s[0] = (s[0] + input[i]) % 65521;
      38               0 :                 s[1] = (s[1] + s[0]) % 65521;
      39                 :         }
      40               0 :         context->state = s[0] + (s[1] << 16);
      41               0 : }
      42                 : 
      43                 : PHP_HASH_API void PHP_ADLER32Final(unsigned char digest[4], PHP_ADLER32_CTX *context)
      44               0 : {
      45               0 :         digest[3] = (unsigned char) ((context->state >> 24) & 0xff);
      46               0 :         digest[2] = (unsigned char) ((context->state >> 16) & 0xff);
      47               0 :         digest[1] = (unsigned char) ((context->state >> 8) & 0xff);
      48               0 :         digest[0] = (unsigned char) (context->state & 0xff);
      49               0 :         context->state = 0;
      50               0 : }
      51                 : 
      52                 : const php_hash_ops php_hash_adler32_ops = {
      53                 :         (php_hash_init_func_t) PHP_ADLER32Init,
      54                 :         (php_hash_update_func_t) PHP_ADLER32Update,
      55                 :         (php_hash_final_func_t) PHP_ADLER32Final,
      56                 :         4, /* what to say here? */
      57                 :         4,
      58                 :         sizeof(PHP_ADLER32_CTX)
      59                 : };
      60                 : 
      61                 : /*
      62                 :  * Local variables:
      63                 :  * tab-width: 4
      64                 :  * c-basic-offset: 4
      65                 :  * End:
      66                 :  * vim600: sw=4 ts=4 fdm=marker
      67                 :  * vim<600: sw=4 ts=4
      68                 :  */

Generated by: LTP GCOV extension version 1.5