encrypted isz file for testing.
[delutions.git] / isz2iso / isz.c
blob691462a0288554c74cda003f201895cf4830e641
1 #include <stdio.h>
2 #include <stdlib.h>
3 #include <memory.h>
4 #include <inttypes.h>
5 #include "isz.h"
7 char * progname;
9 void usage(void) {
10 printf("isz converter\n");
11 printf("usage:\n\t%s file.isz\n",progname);
12 exit(EXIT_FAILURE);
15 void pread( void * ptr, size_t size, size_t count, FILE * stream ) {
16 size_t s = fread(ptr,size,count,stream);
17 if (s < (size*count)) {
18 fprintf(stderr,"read too little\n");
22 int main (int argc, char ** argv) {
23 progname = argv[0];
25 fprintf(stderr," isz struct sz: 0x%X, %u\n",
26 (unsigned int)sizeof(isz_header),(unsigned int)sizeof(isz_header));
28 if (argc < 2) {
29 usage();
32 isz_header * header = malloc(sizeof(isz_header));
33 if (header == NULL) {
34 fputs("malloc error\n",stderr);
35 exit(EXIT_FAILURE);
38 FILE * isz = fopen(argv[1],"rb");
39 if (isz == NULL) {
40 fprintf(stderr,"could not open %s\n",argv[1]);
41 exit(EXIT_FAILURE);
44 pread(header,1,sizeof(isz_header),isz);
46 if ( memcmp( header->signature, ISZ_MAGIC,
47 sizeof(ISZ_MAGIC)) ) {
48 fputs("Invalid Magic.\n",stderr);
49 exit(EXIT_FAILURE);
52 if (header->header_size != sizeof(isz_header) ) {
53 fprintf(stderr, "Failure: ISZ file header size incorrect (is %lu, should be %lu)\n\
54 Possibly older isz version, unsupported\n",
55 (long unsigned int)(header->header_size), sizeof(isz_header));
56 exit(EXIT_FAILURE);
59 printf("Version : %u\n",header->version);
60 printf("Volume Serial : %lu\n",(long)(header->vsn_1<<8)+header->vsn_2);
61 printf("Sector Size : %d\n", header->sector_sz);
62 printf("Total Sectors : %d\n",header->total_sectors);
63 printf("Calculated Size : %d Bytes\n", (header->sector_sz) * (header->total_sectors) );
65 printf("Password Flag : %d\n", header->has_password);
66 printf("Segment Size : %ld\n", header->segment_sz);
67 printf("Num Blocks/Chunks : %d\n", header->nblocks);
68 printf("Block/Chunk Size : %d\n", header->block_sz);
70 printf("Chunk Ptr len : %d\n", header->block_ptr_sz);
71 printf("Segment Number : %d\n", header->segment_num);
73 printf("Chunk Ptr Offset : %d\n", header->chunk_offset);
74 printf("Segment Offset : %d\n", header->segment_offset);
75 printf("Data Offset : %d\n", header->data_offset);
77 exit(EXIT_SUCCESS);