A
download fc32.c
Language: C
Copyright: Copyright 1999 G. Adam Stanislav.
LOC: 32
Project Info
grub.org - Distributed Internet Crawler(grub)
Server: SourceForge
Type: cvs
...ge\g\grub\grub\client\util\
   alt_ftw.c
   alt_ftw.h
   bin_test_util.dsp
   clog.cpp
   clog.h
   ConfigFileInfo.h
   crc.h
   crc_32.c
   crc_32.cpp
   crc_32.h
   crc_test.c
   crc_test.cpp
   crc32.c
   crc32.h
   dbl_list.c
   dbl_list.h
   delay.cpp
   delay.h
   diagnose.h
   fc32.c
   file_data.c
   file_data.h
   getopt.c
   getopt.h
   grubconf.c
   grubconf.h
   GrubExp.cpp
   GrubExp.h
   Gui.cpp
   Gui.h
   intl.h
   lib_util.dsp
   lockfile.cpp
   lockfile.h
   Makefile.am
   parsecfg.c
   parsecfg.h
   platform.h
   rmfiles.c
   rmfiles.h
   ServerSettings.cpp
   ServerSettings.h
   sniptype.h
   StatusInterface.cpp
   StatusInterface.h
   strip_url.c
   strip_url.h
   test_util.cpp

/*
 * fc32.c - A sample program for the use with fast CRC-32 routines.
 * It calculates the CRC-32 of a file.
 *
 * Copyright 1999 G. Adam Stanislav.
 * All rights reserved.
 */
#include <stdio.h>
#include "crc32.h"

#define	BUFFERSIZE	1024

unsigned char buffer[BUFFERSIZE];

int main(int argc, char *argv[]) {
	FILE *file;
	unsigned int crc = initcrc32();

	if (argc > 2) {
		fprintf(stderr, "FC32 Usage: fc32 [file]\n");
		return 1;
	}

	if (argc == 2) {
		file = fopen(argv[1], "r");
		if (file == NULL) {
			fprintf(stderr, "FC32: Can't open %s\n", argv[1]);
			return 2;
		}
	}
	else
		file = stdin;

	while (!feof(file))
		crc = partialcrc32(crc,
			buffer,
			fread(buffer,
				sizeof(unsigned char),
				BUFFERSIZE,
				file));

	if (file != stdin)
		fclose(file);

	printf("CRC-32 = %08x\n", finishcrc32(crc));
	return 0;
}

About Koders | Resources | Downloads | Support | Black Duck | Terms of Service | DMCA | Privacy Policy | Contact Us