~ubuntu-branches/debian/jessie/acoustid-fingerprinter/jessie

« back to all changes in this revision

Viewing changes to crc.h

  • Committer: Bazaar Package Importer
  • Author(s): Clint Adams
  • Date: 2011-05-12 19:54:52 UTC
  • Revision ID: james.westby@ubuntu.com-20110512195452-bj6g545s1bx7edvc
Tags: upstream-0.1
ImportĀ upstreamĀ versionĀ 0.1

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
 * \file crc.h
 
3
 * Functions and types for CRC checks.
 
4
 *
 
5
 * Generated on Sun Oct 24 10:58:41 2010,
 
6
 * by pycrc v0.7.6, http://www.tty1.net/pycrc/
 
7
 * using the configuration:
 
8
 *    Width        = 32
 
9
 *    Poly         = 0x04c11db7
 
10
 *    XorIn        = 0xffffffff
 
11
 *    ReflectIn    = True
 
12
 *    XorOut       = 0xffffffff
 
13
 *    ReflectOut   = True
 
14
 *    Algorithm    = table-driven
 
15
 *****************************************************************************/
 
16
#ifndef __CRC_H__
 
17
#define __CRC_H__
 
18
 
 
19
#include <stdint.h>
 
20
#include <stdlib.h>
 
21
 
 
22
#ifdef __cplusplus
 
23
extern "C" {
 
24
#endif
 
25
 
 
26
 
 
27
/**
 
28
 * The definition of the used algorithm.
 
29
 *****************************************************************************/
 
30
#define CRC_ALGO_TABLE_DRIVEN 1
 
31
 
 
32
 
 
33
/**
 
34
 * The type of the CRC values.
 
35
 *
 
36
 * This type must be big enough to contain at least 32 bits.
 
37
 *****************************************************************************/
 
38
typedef unsigned long crc_t;
 
39
 
 
40
 
 
41
/**
 
42
 * Reflect all bits of a \a data word of \a data_len bytes.
 
43
 *
 
44
 * \param data         The data word to be reflected.
 
45
 * \param data_len     The width of \a data expressed in number of bits.
 
46
 * \return             The reflected data.
 
47
 *****************************************************************************/
 
48
crc_t crc_reflect(crc_t data, size_t data_len);
 
49
 
 
50
 
 
51
/**
 
52
 * Calculate the initial crc value.
 
53
 *
 
54
 * \return     The initial crc value.
 
55
 *****************************************************************************/
 
56
#define crc_init()      (0xffffffff)
 
57
 
 
58
 
 
59
/**
 
60
 * Update the crc value with new data.
 
61
 *
 
62
 * \param crc      The current crc value.
 
63
 * \param data     Pointer to a buffer of \a data_len bytes.
 
64
 * \param data_len Number of bytes in the \a data buffer.
 
65
 * \return         The updated crc value.
 
66
 *****************************************************************************/
 
67
crc_t crc_update(crc_t crc, const unsigned char *data, size_t data_len);
 
68
 
 
69
 
 
70
/**
 
71
 * Calculate the final crc value.
 
72
 *
 
73
 * \param crc  The current crc value.
 
74
 * \return     The final crc value.
 
75
 *****************************************************************************/
 
76
#define crc_finalize(crc)      (crc ^ 0xffffffff)
 
77
 
 
78
 
 
79
#ifdef __cplusplus
 
80
}           /* closing brace for extern "C" */
 
81
#endif
 
82
 
 
83
#endif      /* __CRC_H__ */