1 // This may look like C code, but it is really -*- C++ -*-
2
3 // ------------------------------------------------------------------
4 // The Goldware Library
5 // Copyright (C) 1990-1999 Odinn Sorensen
6 // Copyright (C) 1999-2000 Alexander S. Aganichev
7 // ------------------------------------------------------------------
8 // This library is free software; you can redistribute it and/or
9 // modify it under the terms of the GNU Library General Public
10 // License as published by the Free Software Foundation; either
11 // version 2 of the License, or (at your option) any later version.
12 //
13 // This 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 GNU
16 // Library General Public License for more details.
17 //
18 // You should have received a copy of the GNU Library General Public
19 // License along with this program; if not, write to the Free
20 // Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
21 // MA 02111-1307, USA
22 // ------------------------------------------------------------------
23 // $Id: gcrcm32.cpp,v 1.2 2005/10/31 22:18:26 ssianky Exp $
24 // ------------------------------------------------------------------
25 // CRC-16, CRC-32 and Hashing
26 // ------------------------------------------------------------------
27
28 #include <gctype.h>
29 #include <gcrcall.h>
30
31
32 // ------------------------------------------------------------------
33 // Generate CRC-32 of a memory block
34
memCrc32(const void * _m,long l,bool __case,dword mask)35 dword memCrc32(const void* _m, long l, bool __case, dword mask) {
36
37 long n;
38 dword crc = mask;
39 const char *m = (const char *)_m;
40
41 if(__case) {
42 for(n=0; n<l; n++)
43 crc = updCrc32(g_toupper(*m++), crc);
44 }
45 else {
46 for(n=0; n<l; n++)
47 crc = updCrc32(*m++, crc);
48 }
49
50 return crc;
51 }
52
53
54 // ------------------------------------------------------------------
55