CnC_Remastered_Collection

Command and Conquer: Red Alert
Log | Files | Refs | README | LICENSE

CRCSTRAW.CPP (6426B)


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