uint32 calculate_crc_for_opened_file(OpenedFile& OFile)
{
	uint32 crc = 0;
	unsigned char *buffer;

	/* Build the crc table */
	if(build_crc_table())
	{
		buffer = new byte[BUFFER_SIZE];
		if(buffer) 
		{
			crc= calculate_file_crc(buffer, BUFFER_SIZE, OFile);
			delete []buffer;
		}
		
		/* free the crc table! */
		free_crc_table();
	}

	return crc;
}
Exemple #2
0
/* Calculate the crc for a file using the given buffer.. */
unsigned long calculate_data_crc(
    unsigned char *buffer,
    long length)
{
    unsigned long crc= 0l;

    assert(buffer);

    /* Build the crc table */
    if(build_crc_table())
    {
        /* The odd permutions ensure that we get the same crc as for a file */
        crc = 0xFFFFFFFFL;
        crc = calculate_buffer_crc(length, crc, buffer);
        crc ^= 0xFFFFFFFFL;

        /* free the crc table! */
        free_crc_table();
    }

    return crc;
}
Exemple #3
0
unsigned long calculate_crc_for_opened_file(
    short refnum)
{
    unsigned long crc;
    unsigned char *buffer;

    /* Build the crc table */
    if(build_crc_table())
    {
        buffer= (unsigned char *) malloc(BUFFER_SIZE*sizeof(unsigned char));
        if(buffer)
        {
            crc= calculate_file_crc(buffer, BUFFER_SIZE, refnum);

            free(buffer);
        }

        /* free the crc table! */
        free_crc_table();
    }

    return crc;
}