cd ../gtk ==> cd ../ui/gtk
[obnox/wireshark/wip.git] / wsutil / crc16-plain.h
1 /**
2  * \file crc16-plain.h
3  * Functions and types for CRC checks.
4  *
5  * Generated on Wed Mar 18 14:12:15 2009,
6  * by pycrc v0.7, http://www.tty1.net/pycrc/
7  * using the configuration:
8  *    Width        = 16
9  *    Poly         = 0x8005
10  *    XorIn        = 0x0000
11  *    ReflectIn    = True
12  *    XorOut       = 0x0000
13  *    ReflectOut   = True
14  *    Algorithm    = table-driven
15  *    Direct       = True
16  *
17  * Modified 2009-03-16 not to include <stdint.h> as our Win32 environment
18  * appears not to have it; we're using GLib types, instead.
19  *****************************************************************************/
20 #ifndef __CRC____PLAIN_H__
21 #define __CRC____PLAIN_H__
22
23 #include "glib.h"
24 #include <stdlib.h>
25
26 #ifdef __cplusplus
27 extern "C" {
28 #endif
29
30 /**
31  * The definition of the used algorithm.
32  *****************************************************************************/
33 #define CRC_ALGO_TABLE_DRIVEN 1
34
35 /**
36  * The type of the CRC values.
37  *
38  * This type must be big enough to contain at least 16 bits.
39  *****************************************************************************/
40 typedef guint16 crc16_plain_t;
41
42 /**
43  * Reflect all bits of a \a data word of \a data_len bytes.
44  *
45  * \param data         The data word to be reflected.
46  * \param data_len     The width of \a data expressed in number of bits.
47  * \return     The reflected data.
48  *****************************************************************************/
49 long crc16_plain_reflect(long data, size_t data_len);
50
51 /**
52  * Calculate the initial crc value.
53  *
54  * \return     The initial crc value.
55  *****************************************************************************/
56 static inline crc16_plain_t crc16_plain_init(void)
57 {
58     return 0x0000;
59 }
60
61 /**
62  * Update the crc value with new data.
63  *
64  * \param crc      The current crc value.
65  * \param data     Pointer to a buffer of \a data_len bytes.
66  * \param data_len Number of bytes in the \a data buffer.
67  * \return         The updated crc value.
68  *****************************************************************************/
69 crc16_plain_t crc16_plain_update(crc16_plain_t crc, const unsigned char *data, size_t data_len);
70
71 /**
72  * Calculate the final crc value.
73  *
74  * \param crc  The current crc value.
75  * \return     The final crc value.
76  *****************************************************************************/
77 static inline crc16_plain_t crc16_plain_finalize(crc16_plain_t crc)
78 {
79     return crc ^ 0x0000;
80 }
81
82
83 #ifdef __cplusplus
84 }           /* closing brace for extern "C" */
85 #endif
86
87 #endif      /* __CRC____PLAIN_H__ */