| 1 | /* Copyright (c) 2003 by Michael J. Roberts. All Rights Reserved. */ |
| 2 | /* |
| 3 | Name |
| 4 | vmcrc.h - compute a CRC-32 checksum of a data stream |
| 5 | Function |
| 6 | |
| 7 | Notes |
| 8 | |
| 9 | Modified |
| 10 | 06/21/03 MJRoberts - Creation |
| 11 | */ |
| 12 | |
| 13 | #ifndef VMCRC_H |
| 14 | #define VMCRC_H |
| 15 | |
| 16 | #include <stdlib.h> |
| 17 | |
| 18 | class CVmCRC32 |
| 19 | { |
| 20 | public: |
| 21 | CVmCRC32() |
| 22 | { |
| 23 | /* start with zero in the accumulator */ |
| 24 | acc_ = 0; |
| 25 | } |
| 26 | |
| 27 | /* add the given buffer into the checksum */ |
| 28 | void scan_bytes(const void *ptr, size_t len); |
| 29 | |
| 30 | /* retrieve the current checksum value */ |
| 31 | unsigned long get_crc_val() const { return acc_; } |
| 32 | |
| 33 | protected: |
| 34 | /* the checksum accumulator */ |
| 35 | unsigned long acc_; |
| 36 | }; |
| 37 | |
| 38 | |
| 39 | #endif /* VMCRC_H */ |