CRCSTRAW.CPP 6.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. /*
  2. ** Command & Conquer Red Alert(tm)
  3. ** Copyright 2025 Electronic Arts Inc.
  4. **
  5. ** This program is free software: you can redistribute it and/or modify
  6. ** it under the terms of the GNU General Public License as published by
  7. ** the Free Software Foundation, either version 3 of the License, or
  8. ** (at your option) any later version.
  9. **
  10. ** This program is distributed in the hope that it will be useful,
  11. ** but WITHOUT ANY WARRANTY; without even the implied warranty of
  12. ** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  13. ** GNU General Public License for more details.
  14. **
  15. ** You should have received a copy of the GNU General Public License
  16. ** along with this program. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. /* $Header: /CounterStrike/CRCSTRAW.CPP 1 3/03/97 10:24a Joe_bostic $ */
  19. /***********************************************************************************************
  20. *** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ***
  21. ***********************************************************************************************
  22. * *
  23. * Project Name : Command & Conquer *
  24. * *
  25. * File Name : CRCSTRAW.CPP *
  26. * *
  27. * Programmer : Joe L. Bostic *
  28. * *
  29. * Start Date : 07/02/96 *
  30. * *
  31. * Last Update : July 3, 1996 [JLB] *
  32. * *
  33. *---------------------------------------------------------------------------------------------*
  34. * Functions: *
  35. * CRCStraw::Get -- Fetch the data requested and calculate CRC on it. *
  36. * CRCStraw::Result -- Returns with the CRC of all data passed through the straw. *
  37. * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
  38. #include "crcstraw.h"
  39. /***********************************************************************************************
  40. * CRCStraw::Get -- Fetch the data requested and calculate CRC on it. *
  41. * *
  42. * This routine will fetch the number of bytes requested. The data will not be modified *
  43. * by this straw segment, but the CRC engine will examine the data so as to keep an *
  44. * accurate CRC value. *
  45. * *
  46. * INPUT: source -- Pointer to the buffer to hold the data requested. *
  47. * *
  48. * length -- The number of bytes requested. *
  49. * *
  50. * OUTPUT: Returns with the actual number of bytes stored in the buffer. If this number is *
  51. * less than that requested, then this indicates that the data stream has been *
  52. * exhausted. *
  53. * *
  54. * WARNINGS: none *
  55. * *
  56. * HISTORY: *
  57. * 07/03/1996 JLB : Created. *
  58. *=============================================================================================*/
  59. int CRCStraw::Get(void * source, int slen)
  60. {
  61. if (source == NULL || slen < 1) {
  62. return(0);
  63. }
  64. int counter = Straw::Get(source, slen);
  65. CRC(source, counter);
  66. return(counter);
  67. }
  68. /***********************************************************************************************
  69. * CRCStraw::Result -- Returns with the CRC of all data passed through the straw. *
  70. * *
  71. * This routine will return the CRC value of the data that has passed through this straw *
  72. * segment. *
  73. * *
  74. * INPUT: none *
  75. * *
  76. * OUTPUT: Returns with the CRC value of the data this straw segment has seen. *
  77. * *
  78. * WARNINGS: none *
  79. * *
  80. * HISTORY: *
  81. * 07/03/1996 JLB : Created. *
  82. *=============================================================================================*/
  83. long CRCStraw::Result(void) const
  84. {
  85. return(CRC());
  86. }