verify_mode_2_form_2_encoder.c
上传用户:weiliju62
上传日期:2007-01-06
资源大小:619k
文件大小:2k
源码类别:
SCSI/ASPI
开发平台:
MultiPlatform
- /* test program for the sector formatting library */
- #include <stdio.h>
- #include <string.h>
- #include <unistd.h>
- #include <fcntl.h>
- #include "ecc.h"
- int main(int argc, char *argv[])
- {
- int fin;
- unsigned int sector = 0;
- unsigned int verified = 0;
- int address;
- if (argc < 2) {
- fprintf(stderr, "Usage: %s 2352-byte-sector-filen", argv[0]);
- return 0;
- }
- if (argv[1][0] == '-') {
- fin = STDIN_FILENO;
- } else {
- fin = open(argv[1], O_RDONLY);
- }
- if (fin == -1) {
- perror("");
- fprintf(stderr, "could not open file %s for reading.n",argv[1]);
- exit(1);
- }
- address = 150;
- for (; 1; sector++) {
- unsigned char inbuf[2448];
- unsigned char inbuf_copy[2448];
- unsigned int result;
- int have_read;
- /* get one original sector */
- have_read = 0;
- while (2352 != have_read) {
- int retval;
- retval = read(fin, inbuf+have_read, 2352-have_read);
- if (retval < 0) break;
- if (retval == 0)
- break;
- have_read += retval;
- }
- if (have_read != 2352)
- break;
- /* make a copy to work on */
- memcpy(inbuf_copy, inbuf, 2352);
- #if 0
- /* check CRC value */
- if (memcmp(inbuf_copy+2348, "