Point Cloud Library (PCL) 1.14.0
Loading...
Searching...
No Matches
opennurbs_crc.h
1/* $NoKeywords: $ */
2/*
3//
4// Copyright (c) 1993-2012 Robert McNeel & Associates. All rights reserved.
5// OpenNURBS, Rhinoceros, and Rhino3D are registered trademarks of Robert
6// McNeel & Associates.
7//
8// THIS SOFTWARE IS PROVIDED "AS IS" WITHOUT EXPRESS OR IMPLIED WARRANTY.
9// ALL IMPLIED WARRANTIES OF FITNESS FOR ANY PARTICULAR PURPOSE AND OF
10// MERCHANTABILITY ARE HEREBY DISCLAIMED.
11//
12// For complete openNURBS copyright information see <http://www.opennurbs.org>.
13//
14////////////////////////////////////////////////////////////////
15*/
16
17#if !defined(OPENNURBS_CRC_INC_)
18#define OPENNURBS_CRC_INC_
19
20ON_BEGIN_EXTERNC
21
22/*
23Description:
24 Continues 16 bit CRC calulation to include the buffer.
25
26Parameters:
27 current_remainder - [in]
28 sizeof_buffer - [in] number of bytes in buffer
29 buffer - [in]
30
31Example:
32 16 bit CRC calculations are typically done something like this:
33
34 const ON__UINT16 crc_seed = 0; // or 1, or your favorite starting value
35
36 // Compute CRC on "good" data
37 unsigned ON__UINT16 first_crc = crc_seed;
38 first_crc = ON_CRC16( first_crc, size1, buffer1 );
39 ...
40 first_crc = ON_CRC16( first_crc, sizeN, bufferN );
41 unsigned char two_zero_bytes[2] = (0,0);
42 first_crc = ON_CRC16( first_crc, 2, two_zero_bytes );
43
44 // make sure 16 bit CRC calculation is valid
45 ON__UINT16 check_crc_calculation = ON_CRC16( first_crc, 2, &first_crc );
46 if ( check_crc_calculation != 0 )
47 {
48 printf("ON_CRC16() calculated a bogus 16 bit CRC\n");
49 }
50
51 // Do something that may potentially change the values in
52 // the buffers (like storing them on a faulty disk).
53
54 // Compute CRC on "suspect" data
55 ON__UINT16 second_crc = crc_seed;
56 second_crc = ON_CRC16( second_crc, size1, buffer1 );
57 ...
58 second_crc = ON_CRC16( second_crc, sizeN, bufferN );
59 if ( 0 != ON_CRC16( second_crc, 2, &first_crc ) )
60 {
61 printf( "The value of at least one byte has changed.\n" );
62 }
63*/
64ON_DECL
65ON__UINT16 ON_CRC16(
66 ON__UINT16 current_remainder,
67 std::size_t sizeof_buffer,
68 const void* buffer
69 );
70
71/*
72Description:
73 Continues 32 bit CRC calulation to include the buffer
74
75 ON_CRC32() is a slightly altered version of zlib 1.3.3's crc32()
76 and the zlib "legal stuff" is reproduced below.
77
78 ON_CRC32() and zlib's crc32() compute the same values. ON_CRC32()
79 was renamed so it wouldn't clash with the other crc32()'s that are
80 out there and the argument order was switched to match that used by
81 the legacy ON_CRC16().
82
83Parameters:
84 current_remainder - [in]
85 sizeof_buffer - [in] number of bytes in buffer
86 buffer - [in]
87
88Example:
89 32 bit CRC calculations are typically done something like this:
90
91 const ON__UINT32 crc_seed = 0; // or 1, or your favorite starting value
92
93 //Compute CRC on "good" data
94 ON__UINT32 first_crc = crc_seed;
95 first_crc = ON_CRC32( first_crc, size1, buffer1 );
96 ...
97 first_crc = ON_CRC32( first_crc, sizeN, bufferN );
98
99 // Do something that may potentially change the values in
100 // the buffers (like storing them on a faulty disk).
101
102 // Compute CRC on "suspect" data
103 ON__UINT32 second_crc = crc_seed;
104 second_crc = ON_CRC32( second_crc, size1, buffer1 );
105 ...
106 second_crc = ON_CRC32( second_crc, sizeN, bufferN );
107 if ( second_crc != first_crc )
108 {
109 printf( "The value of at least one byte has changed.\n" );
110 }
111*/
112ON_DECL
113ON__UINT32 ON_CRC32(
114 ON__UINT32 current_remainder,
115 std::size_t sizeof_buffer,
116 const void* buffer
117 );
118
119/*
120zlib.h -- interface of the 'zlib' general purpose compression library
121version 1.1.3, July 9th, 1998
122
123Copyright (C) 1995-1998 Jean-loup Gailly and Mark Adler
124
125This software is provided 'as-is', without any express or implied
126warranty. In no event will the authors be held liable for any damages
127arising from the use of this software.
128
129Permission is granted to anyone to use this software for any purpose,
130including commercial applications, and to alter it and redistribute it
131freely, subject to the following restrictions:
132
1331. The origin of this software must not be misrepresented; you must not
134 claim that you wrote the original software. If you use this software
135 in a product, an acknowledgment in the product documentation would be
136 appreciated but is not required.
1372. Altered source versions must be plainly marked as such, and must not be
138 misrepresented as being the original software.
1393. This notice may not be removed or altered from any source distribution.
140
141Jean-loup Gailly Mark Adler
142jloup@gzip.org madler@alumni.caltech.edu
143
144The data format used by the zlib library is described by RFCs (Request for
145Comments) 1950 to 1952 in the files ftp://ds.internic.net/rfc/rfc1950.txt
146(zlib format), rfc1951.txt (deflate format) and rfc1952.txt (gzip format).
147
148*/
149
150ON_END_EXTERNC
151
152#endif