home *** CD-ROM | disk | FTP | other *** search
/ OS/2 Shareware BBS: 10 Tools / 10-Tools.zip / lzo100.zip / lzo-1.00 / tests / chksum.c < prev    next >
C/C++ Source or Header  |  1997-05-27  |  2KB  |  86 lines

  1. /* chksum.c -- compute a checksum
  2.  
  3.    This file is part of the LZO real-time data compression library.
  4.  
  5.    Copyright (C) 1997 Markus Franz Xaver Johannes Oberhumer
  6.    Copyright (C) 1996 Markus Franz Xaver Johannes Oberhumer
  7.  
  8.    The LZO library is free software; you can redistribute it and/or
  9.    modify it under the terms of the GNU General Public License as
  10.    published by the Free Software Foundation; either version 2 of
  11.    the License, or (at your option) any later version.
  12.  
  13.    The LZO library is distributed in the hope that it will be useful,
  14.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  15.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  16.    GNU General Public License for more details.
  17.  
  18.    You should have received a copy of the GNU General Public License
  19.    along with the LZO library; see the file COPYING.
  20.    If not, write to the Free Software Foundation, Inc.,
  21.    59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
  22.  
  23.    Markus F.X.J. Oberhumer
  24.    markus.oberhumer@jk.uni-linz.ac.at
  25.  */
  26.  
  27.  
  28. #include <stdio.h>
  29. #include <stdlib.h>
  30.  
  31. #include <lzoconf.h>
  32.  
  33.  
  34. /*************************************************************************
  35. //
  36. **************************************************************************/
  37.  
  38. static lzo_byte block[128*1024L];
  39.  
  40.  
  41. int main(int argc, char *argv[])
  42. {
  43.     lzo_uint block_len;
  44.     lzo_uint32 adler, crc;
  45.  
  46.     if (argc < 0 || argv == NULL)    /* avoid warning about unused args */
  47.         return 0;
  48.  
  49.     if (lzo_init() != LZO_E_OK)
  50.     {
  51.         printf("lzo_init() failed !!!\n");
  52.         return 3;
  53.     }
  54.  
  55. /* prepare the block */
  56.     block_len = sizeof(block);
  57.     lzo_memset(block, 0, block_len);
  58.  
  59. /* adler32 checksum */
  60.     adler = lzo_adler32(0, NULL, 0);
  61.     adler = lzo_adler32(adler, block, block_len);
  62.     if (adler != 0x001e0001UL)
  63.     {
  64.         printf("adler32 checksum error !!! (0x%08lx)\n", (long) adler);
  65.         return 2;
  66.     }
  67.  
  68. /* crc32 checksum */
  69.     crc = lzo_crc32(0, NULL, 0);
  70.     crc = lzo_crc32(crc, block, block_len);
  71.     if (crc != 0x7ee8cdcdUL)
  72.     {
  73.         printf("crc32 checksum error !!! (0x%08lx)\n", (long) crc);
  74.         return 1;
  75.     }
  76.  
  77.     printf("Checksum test passed.\n");
  78.     return 0;
  79. }
  80.  
  81.  
  82. /*
  83. vi:ts=4
  84. */
  85.  
  86.