mswsp: Remove null check (CID1355407)
[jlayton/wireshark.git] / wsutil / crc7.h
1 /*
2  * crc7.h
3  *
4  * Functions and types for CRC checks.
5  *
6  * Wireshark - Network traffic analyzer
7  * By Gerald Combs <gerald@wireshark.org>
8  * Copyright 1998 Gerald Combs
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2
13  * of the License, or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
23  *
24  * Generated on Wed Jul 11 17:24:57 2012,
25  * by pycrc v0.7.10, http://www.tty1.net/pycrc/
26  * using the configuration:
27  *    Width        = 7
28  *    Poly         = 0x45
29  *    XorIn        = 0x00
30  *    ReflectIn    = False
31  *    XorOut       = 0x00
32  *    ReflectOut   = False
33  *    Algorithm    = table-driven
34  ****************************************************************************
35  */
36 #ifndef __CRC7__H__
37 #define __CRC7__H__
38
39 #include "ws_symbol_export.h"
40
41 #ifdef __cplusplus
42 extern "C" {
43 #endif
44
45
46 /**
47  * The definition of the used algorithm.
48  *****************************************************************************/
49 #define CRC_ALGO_TABLE_DRIVEN 1
50
51 /**
52  * Calculate the initial crc value.
53  *
54  * \return     The initial crc value.
55  *****************************************************************************/
56 static inline guint8 crc7init(void)
57 {
58     return 0x00 << 1;
59 }
60
61
62 /**
63  * Update the crc value with new data.
64  *
65  * \param crc      The current crc value.
66  * \param data     Pointer to a buffer of \a data_len bytes.
67  * \param data_len Number of bytes in the \a data buffer.
68  * \return         The updated crc value.
69  *****************************************************************************/
70 WS_DLL_PUBLIC guint8 crc7update(guint8 crc, const unsigned char *data, int data_len);
71
72
73 /**
74  * Calculate the final crc value.
75  *
76  * \param crc  The current crc value.
77  * \return     The final crc value.
78  *****************************************************************************/
79 static inline guint8 crc7finalize(guint8 crc)
80 {
81     return (crc >> 1) ^ 0x00;
82 }
83
84
85 #ifdef __cplusplus
86 }           /* closing brace for extern "C" */
87 #endif
88
89 #endif      /* __CRC7__H__ */