Leaked source code of windows server 2003
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

117 lines
4.5 KiB

  1. /*
  2. * $Header: /entproj/all/base/etfile/crcutil.h_v 1.3 Wed Dec 07 15:05:30 1994 markbc $
  3. * $Log: /entproj/all/base/etfile/crcutil.h_v $
  4. *
  5. * Rev 1.3 Wed Dec 07 15:05:30 1994 markbc
  6. * Alpha port checkin
  7. *
  8. * Rev 1.2 19 Oct 1994 15:44:08 chucker
  9. * Synced up headers with the code.
  10. *
  11. * Rev 1.1 18 Aug 1994 11:33:46 dilkie
  12. * Protected INIFILE stuff
  13. *
  14. * Rev 1.0 11 Aug 1994 17:22:46 JackK
  15. * Initial file check in
  16. */
  17. /***********************************************************************
  18. * Prototypes and typedefs for the CRC utility routines.
  19. *
  20. * Author: Gary P. Mussar
  21. * This code is released to the public domain. There are no restrictions,
  22. * however, acknowledging the author by keeping this comment around
  23. * would be appreciated.
  24. ***********************************************************************/
  25. //#include <os_spec.h>
  26. /***********************************************************************
  27. * If we can handle ANSI prototyping, lets do it.
  28. ***********************************************************************/
  29. //#ifdef __cplusplus
  30. //extern "C" { /* Assume C declarations for C++ */
  31. //#endif /* __cplusplus */
  32. //#ifdef NEEDPROTOS
  33. #define PARMS(x) x
  34. //#else
  35. //#define PARMS(x) ()
  36. //#endif
  37. /***********************************************************************
  38. * The following #defines are used to define the types of variables
  39. * used to hold or manipulate CRCs. The 16 bit CRCs require a data
  40. * type with at least 16 bits. The 32 bit CRCs require a data type
  41. * with at least 32 bits. In addition, the data bits reserved for the
  42. * CRC must be manipulated in an unsigned fashion. It is possible to
  43. * define a data type which is larger than required to hold the CRC,
  44. * however, this is an inefficient use of memory and usually results
  45. * in less efficient code when manipulating the CRCs.
  46. ***********************************************************************/
  47. #define CRC16 unsigned short int
  48. #define CRC32 UINT32
  49. /***********************************************************************
  50. * Utilities for fast CRC using table lookup
  51. *
  52. * I_CRCxx - Initialize the 256 entry CRC lookup table based on the
  53. * specified generator polynomial.
  54. * Input:
  55. * Table[256] - Lookup table
  56. * *GenPolynomial - Pointer to generator polynomial
  57. *
  58. * F_CRCxx - Calculate CRC over an array of characters using fast
  59. * table lookup.
  60. * Input:
  61. * Table[256] - Lookup table
  62. * *CRC - Pointer to the variable containing the result of
  63. * CRC calculations of previous characters. The CRC
  64. * variable must be initialized to a known value
  65. * before the first call to this routine.
  66. * *dataptr - Pointer to array of characters to be included in
  67. * the CRC calculation.
  68. * count - Number of characters in the array.
  69. *
  70. * S_CRCxx - Calculate CRC over an array of characters using slower but
  71. * smaller non-table lookup method.
  72. * Input:
  73. * *GenPolynomial - Pointer to generator polynomial
  74. * *CRC - Pointer to the variable containing the result of
  75. * CRC calculations of previous characters. The CRC
  76. * variable must be initialized to a known value
  77. * before the first call to this routine.
  78. * *dataptr - Pointer to array of characters to be included in
  79. * the CRC calculation.
  80. * count - Number of characters in the array.
  81. ***********************************************************************/
  82. extern void I_CRC16 PARMS((CRC16 Table[256], \
  83. CRC16 *GenPolynomial));
  84. extern void F_CRC16 PARMS((CRC16 Table[256], \
  85. CRC16 *CRC, \
  86. const void *dataptr, \
  87. unsigned int count));
  88. extern void S_CRC16 PARMS((CRC16 *GenPolynomial, \
  89. CRC16 *CRC, \
  90. const void *dataptr, \
  91. unsigned int count));
  92. extern void I_CRC32 PARMS((CRC32 Table[256], \
  93. CRC32 *GenPolynomial));
  94. extern void F_CRC32 PARMS((CRC32 Table[256], \
  95. CRC32 *CRC, \
  96. const void *dataptr, \
  97. unsigned int count));
  98. extern void S_CRC32 PARMS((CRC32 *GenPolynomial, \
  99. CRC32 *CRC, \
  100. const void *dataptr, \
  101. unsigned int count));
  102. //#ifdef __cplusplus
  103. //} /* Assume C declarations for C++ */
  104. //#endif /* __cplusplus */