Home | History | Annotate | Download | only in include
      1 /*---------------------------------------------------------------------------*
      2  *  pcrc.h  *
      3  *                                                                           *
      4  *  Copyright 2007, 2008 Nuance Communciations, Inc.                               *
      5  *                                                                           *
      6  *  Licensed under the Apache License, Version 2.0 (the 'License');          *
      7  *  you may not use this file except in compliance with the License.         *
      8  *                                                                           *
      9  *  You may obtain a copy of the License at                                  *
     10  *      http://www.apache.org/licenses/LICENSE-2.0                           *
     11  *                                                                           *
     12  *  Unless required by applicable law or agreed to in writing, software      *
     13  *  distributed under the License is distributed on an 'AS IS' BASIS,        *
     14  *  WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. *
     15  *  See the License for the specific language governing permissions and      *
     16  *  limitations under the License.                                           *
     17  *                                                                           *
     18  *---------------------------------------------------------------------------*/
     19 
     20 #ifndef PCRC_H
     21 #define PCRC_H
     22 
     23 
     24 
     25 #include "PortPrefix.h"
     26 #include "ptypes.h"
     27 
     28 /**
     29  * @addtogroup PCRCModule PCRC API functions
     30  *
     31  * @{
     32  */
     33 
     34 /**
     35  * Computes the CRC-encoding of the block of data.
     36  *
     37  * @param data The data on which to compute the CRC
     38  * @param size the size of the data.
     39  * @return the CRC of the data.
     40  */
     41 PORTABLE_API unsigned int pcrcComputeData(const void *data, unsigned int size);
     42 
     43 
     44 /**
     45  * Computes the CRC-encoding of a string.
     46  *
     47  * @param str The string for which to compute the CRC
     48  * @return the CRC of the string.
     49  */
     50 PORTABLE_API unsigned int pcrcComputeString(const LCHAR *str);
     51 
     52 
     53 /**
     54  * Initial value to pass to the pcrcUpdateData to ensist consistency with
     55  * pcrcComputeData.
     56  */
     57 #define CRC_INITIAL_VALUE (~0U)
     58 
     59 /**
     60  * Updates the CRC when adding a new byte.
     61  *
     62  * @param crc The initial crc value.
     63  * @param data datum to append to the crc
     64  * @param size the size of the data.
     65  * @return the new crc value.
     66  */
     67 PORTABLE_API unsigned int pcrcUpdateData(unsigned int crc,
     68     const void * data,
     69     unsigned int size);
     70 
     71 /**
     72  * @}
     73  */
     74 
     75 
     76 #endif
     77