#include <stdio.h>
#include <stdlib.h>
+#include <string.h>
#include <zlib.h> /* /usr(/local)/include/zlib.h */
#include <zconf.h>
FILE *fin,*fout;
z_stream z;
-unsigned int *index_buf = NULL;
-unsigned int *crc_buf = NULL;
-unsigned char *block_buf1 = NULL;
-unsigned char *block_buf2 = NULL;
+uint32_t *index_buf = NULL;
+uint32_t *crc_buf = NULL;
+uint8_t *block_buf1 = NULL;
+uint8_t *block_buf2 = NULL;
/****************************************************************************
compress ISO to CSO
CISO_H ciso;
int ciso_total_block;
-unsigned long long check_file_size(FILE *fp)
+uint64_t check_file_size(FILE *fp)
{
- unsigned long long pos;
+ uint64_t pos;
if( fseek(fp,0,SEEK_END) < 0)
return -1;
****************************************************************************/
int decomp_ciso(void)
{
- unsigned long long file_size;
- unsigned int index , index2;
- unsigned long long read_pos , read_size;
+ uint64_t file_size;
+ uint32_t index , index2;
+ uint64_t read_pos , read_size;
int total_sectors;
int index_size;
int block;
ciso_total_block = ciso.total_bytes / ciso.block_size;
/* allocate index block */
- index_size = (ciso_total_block + 1 ) * sizeof(unsigned long);
+ index_size = (ciso_total_block + 1 ) * sizeof(uint32_t);
index_buf = malloc(index_size);
block_buf1 = malloc(ciso.block_size);
block_buf2 = malloc(ciso.block_size*2);
/* show info */
printf("Decompress '%s' to '%s'\n",fname_in,fname_out);
- printf("Total File Size %ld bytes\n",ciso.total_bytes);
+ printf("Total File Size %lld bytes\n",ciso.total_bytes);
printf("block size %d bytes\n",ciso.block_size);
printf("total blocks %d blocks\n",ciso_total_block);
printf("index align %d\n",1<<ciso.align);
****************************************************************************/
int comp_ciso(int level)
{
- unsigned long long file_size;
- unsigned long long write_pos;
+ uint64_t file_size;
+ uint64_t write_pos;
int total_sectors;
int index_size;
int block;
int align,align_b,align_m;
file_size = check_file_size(fin);
- if(file_size<0)
+ if(file_size==(uint64_t)-1LL)
{
printf("Can't get file size\n");
return 1;
}
/* allocate index block */
- index_size = (ciso_total_block + 1 ) * sizeof(unsigned long);
+ index_size = (ciso_total_block + 1 ) * sizeof(uint32_t);
index_buf = malloc(index_size);
crc_buf = malloc(index_size);
block_buf1 = malloc(ciso.block_size);
/* show info */
printf("Compress '%s' to '%s'\n",fname_in,fname_out);
- printf("Total File Size %ld bytes\n",ciso.total_bytes);
+ printf("Total File Size %lld bytes\n",ciso.total_bytes);
printf("block size %d bytes\n",ciso.block_size);
printf("index align %d\n",1<<ciso.align);
printf("compress level %d\n",level);
percent_cnt = percent_period;
printf("compress %3d%% avarage rate %3d%%\r"
,block / percent_period
- ,block==0 ? 0 : 100*write_pos/(block*0x800));
+ ,block==0 ? 0 : (uint32_t)(100*write_pos/(block*0x800)));
}
if (deflateInit2(&z, level , Z_DEFLATED, -15,8,Z_DEFAULT_STRATEGY) != Z_OK)
int level;
int result;
- fprintf(stderr, "Compressed ISO9660 converter Ver.1.01 by BOOSTER\n");
+ fprintf(stderr, "Compressed ISO9660 converter Ver.1.02 by BOOSTER\n");
if (argc != 4)
{
Copyright 2005 BOOSTER
*/
+#include <stdint.h>
+
+#ifndef __CISO_H__
+#define __CISO_H__
+/*
+ complessed ISO(9660) header format
+*/
+typedef struct ciso_header
+{
+ uint8_t magic[4]; /* +00 : 'C','I','S','O' */
+ uint32_t header_size; /* +04 : header size (==0x18) */
+ uint64_t total_bytes; /* +08 : number of original data size */
+ uint32_t block_size; /* +10 : number of compressed block size */
+ uint8_t ver; /* +14 : version 01 */
+ uint8_t align; /* +15 : align of index value */
+ uint8_t rsv_06[2]; /* +16 : reserved */
+#if 0
+// INDEX BLOCK
+ uint32_t index[0]; /* +18 : block[0] index */
+ uint32_t index[1]; /* +1C : block[1] index */
+ :
+ :
+ uint32_t index[last]; /* +?? : block[last] */
+ uint32_t index[last+1]; /* +?? : end of last data point */
+// DATA BLOCK
+ uint8_t data[]; /* +?? : compressed or plain sector data */
+#endif
+}CISO_H;
+
+/*
+note:
+
+file_pos_sector[n] = (index[n]&0x7fffffff) << CISO_H.align
+file_size_sector[n] = ( (index[n+1]&0x7fffffff) << CISO_H.align) - file_pos_sector[n]
+
+if(index[n]&0x80000000)
+ // read 0x800 without compress
+else
+ // read file_size_sector[n] bytes and decompress data
+*/
+
+#endif
-#ifndef __CISO_H__\r
-#define __CISO_H__\r
-/*\r
- complessed ISO(9660) header format\r
-*/\r
-typedef struct ciso_header\r
-{\r
- unsigned char magic[4]; /* +00 : 'C','I','S','O' */\r
- unsigned long header_size; /* +04 : header size (==0x18) */\r
- unsigned long long total_bytes; /* +08 : number of original data size */\r
- unsigned long block_size; /* +10 : number of compressed block size */\r
- unsigned char ver; /* +14 : version 01 */\r
- unsigned char align; /* +15 : align of index value */\r
- unsigned char rsv_06[2]; /* +16 : reserved */\r
-#if 0\r
-// INDEX BLOCK\r
- unsigned int index[0]; /* +18 : block[0] index */\r
- unsigned int index[1]; /* +1C : block[1] index */\r
- :\r
- :\r
- unsigned int index[last]; /* +?? : block[last] */\r
- unsigned int index[last+1]; /* +?? : end of last data point */\r
-// DATA BLOCK\r
- unsigned char data[]; /* +?? : compressed or plain sector data */\r
-#endif\r
-}CISO_H;\r
-\r
-/*\r
-note:\r
-\r
-file_pos_sector[n] = (index[n]&0x7fffffff) << CISO_H.align\r
-file_size_sector[n] = ( (index[n+1]&0x7fffffff) << CISO_H.align) - file_pos_sector[n]\r
-\r
-if(index[n]&0x80000000)\r
- // read 0x800 without compress\r
-else\r
- // read file_size_sector[n] bytes and decompress data\r
-*/\r
-\r
-#endif\r