first check-in of feisty meow codebase. many things broken still due to recent
[feisty_meow.git] / core / library / structures / checksums.h
1 #ifndef CHECKSUMS_GROUP
2 #define CHECKSUMS_GROUP
3
4 /*****************************************************************************\
5 *                                                                             *
6 *  Name   : checksums group                                                   *
7 *  Author : Chris Koeritz                                                     *
8 *                                                                             *
9 *******************************************************************************
10 * Copyright (c) 1992-$now By Author.  This program is free software; you can  *
11 * redistribute it and/or modify it under the terms of the GNU General Public  *
12 * License as published by the Free Software Foundation; either version 2 of   *
13 * the License or (at your option) any later version.  This is online at:      *
14 *     http://www.fsf.org/copyleft/gpl.html                                    *
15 * Please send any updates to: fred@gruntose.com                               *
16 \*****************************************************************************/
17
18 #include <basis/definitions.h>
19
20 /* @file checksums.h
21   A collection of useful checksum calculators.
22 */
23
24 namespace structures {
25
26 class checksums
27 {
28 public:
29
30   static basis::abyte byte_checksum(const basis::abyte *data, int length);
31     //!< simple byte-sized checksum based on additive roll-over.
32
33   static basis::un_int short_checksum(const basis::abyte *data, int length);
34     //!< simple shorty checksum based on additive roll-over.
35
36   static basis::un_short fletcher_checksum(const basis::abyte *data, int length);
37     //!< A positionally computed error detection value.
38
39   static basis::un_short rolling_fletcher_checksum(basis::un_short previous, const basis::abyte *data, int len);
40     //!< Fletcher checksums applied to streaming data.
41     /*!< this is not strictly a fletcher checksum, but it uses the normal
42     fletcher checksum on the specified data and XORs it with the "previous"
43     value of the checksum.  this leads to a regenerable number that should
44     always be the same if done on the same data using the same chunking
45     factor (the "len"), although of course the last piece of data does not
46     have to be "len" bytes. */
47
48   static unsigned int bizarre_checksum(const basis::abyte *data, int length);
49     //!< A different type of checksum with somewhat unknown properties.
50     /*!< It attempts to be incorporate positioning of the bytes. */
51
52   static basis::un_int hash_bytes(const void *key_data, int key_length);
53     //!< returns a value that can be used for indexing into a hash table.
54     /*!< the returned value is loosely based on the "key_data" and the
55     "key_length" we are provided with. */
56 };
57
58 } //namespace.
59
60 #endif
61