247247#include <fcntl.h>
248248#include <stdio.h>
249249#include <stdarg.h>
250+ #include <stdint.h>
250251#include <stdlib.h>
251252#include <string.h>
252253#include <sys/stat.h>
@@ -509,7 +510,7 @@ typedef enum modes { k_generate_avl, k_extract, k_list, k_rewrite } modes;
509510typedef enum errors { err_end_of_sector = -5001 , err_iso_rewritten = -5002 , err_iso_no_files = -5003 } errors ;
510511
511512typedef void (* progress_callback )( xoff_t in_current_value , xoff_t in_final_value );
512- typedef int32_t (* traversal_callback )( void * in_node , void * in_context , long in_depth );
513+ typedef int32_t (* traversal_callback )( void * in_node , void * in_context , int32_t in_depth );
513514
514515typedef struct dir_node dir_node ;
515516typedef struct create_list create_list ;
@@ -526,20 +527,20 @@ struct dir_node {
526527 unsigned char attributes ;
527528 unsigned char filename_length ;
528529
529- unsigned long file_size ;
530- unsigned long start_sector ;
530+ uint32_t file_size ;
531+ uint32_t start_sector ;
531532};
532533
533534struct dir_node_avl {
534- unsigned long offset ;
535+ uint32_t offset ;
535536 xoff_t dir_start ;
536537
537538 char * filename ;
538- unsigned long file_size ;
539- unsigned long start_sector ;
539+ uint32_t file_size ;
540+ uint32_t start_sector ;
540541 dir_node_avl * subdirectory ;
541542
542- unsigned long old_start_sector ;
543+ uint32_t old_start_sector ;
543544
544545 avl_skew skew ;
545546 dir_node_avl * left ;
@@ -553,13 +554,13 @@ struct create_list {
553554};
554555
555556typedef struct FILE_TIME {
556- unsigned long l ;
557- unsigned long h ;
557+ uint32_t l ;
558+ uint32_t h ;
558559} FILE_TIME ;
559560
560561typedef struct wdsafp_context {
561562 xoff_t dir_start ;
562- unsigned long * current_sector ;
563+ uint32_t * current_sector ;
563564} wdsafp_context ;
564565
565566typedef struct write_tree_context {
@@ -579,13 +580,13 @@ avl_result avl_left_grown( dir_node_avl **in_root );
579580avl_result avl_right_grown ( dir_node_avl * * in_root );
580581dir_node_avl * avl_fetch ( dir_node_avl * in_root , char * in_filename );
581582avl_result avl_insert ( dir_node_avl * * in_root , dir_node_avl * in_node );
582- int32_t avl_traverse_depth_first ( dir_node_avl * in_root , traversal_callback in_callback , void * in_context , avl_traversal_method in_method , long in_depth );
583+ int32_t avl_traverse_depth_first ( dir_node_avl * in_root , traversal_callback in_callback , void * in_context , avl_traversal_method in_method , int32_t in_depth );
583584
584585void boyer_moore_done ();
585- char * boyer_moore_search ( char * in_text , long in_text_len );
586- int32_t boyer_moore_init ( char * in_pattern , long in_pat_len , long in_alphabet_size );
586+ char * boyer_moore_search ( char * in_text , int32_t in_text_len );
587+ int32_t boyer_moore_init ( char * in_pattern , int32_t in_pat_len , int32_t in_alphabet_size );
587588
588- int32_t free_dir_node_avl ( void * in_dir_node_avl , void * , long );
589+ int32_t free_dir_node_avl ( void * in_dir_node_avl , void * , int32_t );
589590int32_t extract_file ( int32_t in_xiso , dir_node * in_file , modes in_mode , char * path );
590591int32_t decode_xiso ( char * in_xiso , char * in_path , modes in_mode , char * * out_iso_path , bool in_ll_compat );
591592int32_t verify_xiso ( int32_t in_xiso , int32_t * out_root_dir_sector , int32_t * out_root_dir_size , char * in_iso_name );
@@ -599,22 +600,22 @@ int32_t write_directory( dir_node_avl *in_avl, int32_t in_xiso, int32_t in_depth
599600int32_t write_file ( dir_node_avl * in_avl , write_tree_context * in_context , int32_t in_depth );
600601int32_t write_tree ( dir_node_avl * in_avl , write_tree_context * in_context , int32_t in_depth );
601602int32_t calculate_total_files_and_bytes ( dir_node_avl * in_avl , void * in_context , int32_t in_depth );
602- int32_t calculate_directory_size ( dir_node_avl * in_avl , unsigned long * out_size , long in_depth );
603+ int32_t calculate_directory_size ( dir_node_avl * in_avl , uint32_t * out_size , int32_t in_depth );
603604int32_t calculate_directory_requirements ( dir_node_avl * in_avl , void * in_context , int32_t in_depth );
604- int32_t calculate_directory_offsets ( dir_node_avl * in_avl , unsigned long * io_context , int32_t in_depth );
605+ int32_t calculate_directory_offsets ( dir_node_avl * in_avl , uint32_t * io_context , int32_t in_depth );
605606int32_t write_dir_start_and_file_positions ( dir_node_avl * in_avl , wdsafp_context * io_context , int32_t in_depth );
606- int32_t write_volume_descriptors ( int32_t in_xiso , unsigned long in_total_sectors );
607+ int32_t write_volume_descriptors ( int32_t in_xiso , uint32_t in_total_sectors );
607608
608609#if DEBUG
609610void write_sector ( int32_t in_xiso , xoff_t in_start , char * in_name , char * in_extension );
610611#endif
611612
612613
613- static long s_pat_len ;
614+ static int32_t s_pat_len ;
614615static bool s_quiet = false;
615616static char * s_pattern = nil ;
616- static long * s_gs_table = nil ;
617- static long * s_bc_table = nil ;
617+ static int32_t * s_gs_table = nil ;
618+ static int32_t * s_bc_table = nil ;
618619static xoff_t s_total_bytes = 0 ;
619620static int s_total_files = 0 ;
620621static char * s_copy_buffer = nil ;
@@ -640,7 +641,7 @@ int main( int argc, char **argv ) {
640641 create_list * create = nil , * p , * q , * * r ;
641642 int32_t i , fd , opt_char , err = 0 , isos = 0 ;
642643 bool extract = true, rewrite = false, free_user = false, free_pass = false, x_seen = false, delete = false, optimized ;
643- char * cwd = nil , * path = nil , * buf = nil , * new_iso_path = nil , tag [ XISO_OPTIMIZED_TAG_LENGTH * sizeof (long ) ];
644+ char * cwd = nil , * path = nil , * buf = nil , * new_iso_path = nil , tag [ XISO_OPTIMIZED_TAG_LENGTH * sizeof (int32_t ) ];
644645
645646 if ( argc < 2 ) { usage (); exit ( 1 ); }
646647
@@ -819,7 +820,7 @@ int main( int argc, char **argv ) {
819820 }
820821 }
821822
822- if ( ! err ) exiso_log ( "\n%u files in %s total %lld bytes\n" , s_total_files , rewrite ? new_iso_path : argv [ i ], (long long int ) s_total_bytes );
823+ if ( ! err ) exiso_log ( "\n%u files in %s total %lld bytes\n" , s_total_files , rewrite ? new_iso_path : argv [ i ], (int64_t ) s_total_bytes );
823824
824825 if ( new_iso_path ) {
825826 if ( ! err ) exiso_log ( "\n%s successfully rewritten%s%s\n" , argv [ i ], path ? " as " : "." , path ? new_iso_path : "" );
@@ -831,7 +832,7 @@ int main( int argc, char **argv ) {
831832 if ( err == err_iso_no_files ) err = 0 ;
832833 }
833834
834- if ( ! err && isos > 1 ) exiso_log ( "\n%u files in %u xiso's total %lld bytes\n" , s_total_files_all_isos , isos , (long long int ) s_total_bytes_all_isos );
835+ if ( ! err && isos > 1 ) exiso_log ( "\n%u files in %u xiso's total %lld bytes\n" , s_total_files_all_isos , isos , (int64_t ) s_total_bytes_all_isos );
835836 if ( s_warned ) exiso_log ( "\nWARNING: Warning(s) were issued during execution--review stderr!\n" );
836837
837838 boyer_moore_done ();
@@ -928,7 +929,7 @@ int32_t create_xiso( char *in_root_directory, char *in_output_directory, dir_nod
928929 dir_node_avl root ;
929930 FILE_TIME * ft = nil ;
930931 write_tree_context wt_context ;
931- unsigned long start_sector ;
932+ uint32_t start_sector ;
932933 int32_t i , n , xiso = -1 , err = 0 ;
933934 char * cwd = nil , * buf = nil , * iso_name , * xiso_path , * iso_dir ;
934935
@@ -1060,7 +1061,7 @@ int32_t create_xiso( char *in_root_directory, char *in_output_directory, dir_nod
10601061
10611062 if ( ! in_root ) {
10621063 if ( err ) { exiso_log ( "\ncould not create %s%s\n" , iso_name ? iso_name : "xiso" , iso_name && ! in_name ? ".iso" : "" ); }
1063- else exiso_log ( "\nsucessfully created %s%s (%u files totalling %lld bytes added)\n" , iso_name ? iso_name : "xiso" , iso_name && ! in_name ? ".iso" : "" , s_total_files , (long long int ) s_total_bytes );
1064+ else exiso_log ( "\nsucessfully created %s%s (%u files totalling %lld bytes added)\n" , iso_name ? iso_name : "xiso" , iso_name && ! in_name ? ".iso" : "" , s_total_files , (int64_t ) s_total_bytes );
10641065 }
10651066
10661067 if ( root .subdirectory != EMPTY_SUBDIRECTORY ) avl_traverse_depth_first ( root .subdirectory , free_dir_node_avl , nil , k_postfix , 0 );
@@ -1505,7 +1506,7 @@ int32_t avl_compare_key( char *in_lhs, char *in_rhs ) {
15051506}
15061507
15071508
1508- int32_t avl_traverse_depth_first ( dir_node_avl * in_root , traversal_callback in_callback , void * in_context , avl_traversal_method in_method , long in_depth ) {
1509+ int32_t avl_traverse_depth_first ( dir_node_avl * in_root , traversal_callback in_callback , void * in_context , avl_traversal_method in_method , int32_t in_depth ) {
15091510 int32_t err ;
15101511
15111512 if ( in_root == nil ) return 0 ;
@@ -1541,19 +1542,19 @@ int32_t avl_traverse_depth_first( dir_node_avl *in_root, traversal_callback in_c
15411542#endif
15421543
15431544
1544- int32_t boyer_moore_init ( char * in_pattern , long in_pat_len , long in_alphabet_size ) {
1545- long i , j , k , * backup , err = 0 ;
1545+ int32_t boyer_moore_init ( char * in_pattern , int32_t in_pat_len , int32_t in_alphabet_size ) {
1546+ int32_t i , j , k , * backup , err = 0 ;
15461547
15471548 s_pattern = in_pattern ;
15481549 s_pat_len = in_pat_len ;
15491550
1550- if ( ( s_bc_table = (long * ) malloc ( in_alphabet_size * sizeof (long ) ) ) == nil ) mem_err ();
1551+ if ( ( s_bc_table = (int32_t * ) malloc ( in_alphabet_size * sizeof (int32_t ) ) ) == nil ) mem_err ();
15511552
15521553 if ( ! err ) {
15531554 for ( i = 0 ; i < in_alphabet_size ; ++ i ) s_bc_table [ i ] = in_pat_len ;
15541555 for ( i = 0 ; i < in_pat_len - 1 ; ++ i ) s_bc_table [ (unsigned char ) in_pattern [ i ] ] = in_pat_len - i - 1 ;
15551556
1556- if ( ( s_gs_table = (long * ) malloc ( 2 * ( in_pat_len + 1 ) * sizeof (long ) ) ) == nil ) mem_err ();
1557+ if ( ( s_gs_table = (int32_t * ) malloc ( 2 * ( in_pat_len + 1 ) * sizeof (int32_t ) ) ) == nil ) mem_err ();
15571558 }
15581559
15591560 if ( ! err ) {
@@ -1587,8 +1588,8 @@ void boyer_moore_done() {
15871588}
15881589
15891590
1590- char * boyer_moore_search ( char * in_text , long in_text_len ) {
1591- long i , j , k , l ;
1591+ char * boyer_moore_search ( char * in_text , int32_t in_text_len ) {
1592+ int32_t i , j , k , l ;
15921593
15931594 for ( i = j = s_pat_len - 1 ; j < in_text_len && i >= 0 ; ) {
15941595 if ( in_text [ j ] == s_pattern [ i ] ) { -- i ; -- j ; }
@@ -1615,7 +1616,7 @@ int32_t extract_file( int32_t in_xiso, dir_node *in_file, modes in_mode , char*
16151616 char c ;
16161617 int32_t err = 0 ;
16171618 bool warn = false;
1618- unsigned long i , size , totalsize = 0 , totalpercent = 0 ;
1619+ uint32_t i , size , totalsize = 0 , totalpercent = 0 ;
16191620 int32_t out ;
16201621
16211622 if ( s_remove_systemupdate && strstr ( path , s_systemupdate ) )
@@ -1669,7 +1670,7 @@ int32_t extract_file( int32_t in_xiso, dir_node *in_file, modes in_mode , char*
16691670}
16701671
16711672
1672- int32_t free_dir_node_avl ( void * in_dir_node_avl , void * in_context , long in_depth ) {
1673+ int32_t free_dir_node_avl ( void * in_dir_node_avl , void * in_context , int32_t in_depth ) {
16731674 dir_node_avl * avl = (dir_node_avl * ) in_dir_node_avl ;
16741675
16751676 if ( avl -> subdirectory && avl -> subdirectory != EMPTY_SUBDIRECTORY ) avl_traverse_depth_first ( avl -> subdirectory , free_dir_node_avl , nil , k_postfix , 0 );
@@ -1727,7 +1728,7 @@ int32_t write_tree( dir_node_avl *in_avl, write_tree_context *in_context, int32_
17271728
17281729int32_t write_file ( dir_node_avl * in_avl , write_tree_context * in_context , int32_t in_depth ) {
17291730 char * buf , * p ;
1730- unsigned long bytes , n , size ;
1731+ uint32_t bytes , n , size ;
17311732 int32_t err = 0 , fd = -1 , i ;
17321733
17331734 if ( ! in_avl -> subdirectory ) {
@@ -1829,7 +1830,7 @@ int32_t write_directory( dir_node_avl *in_avl, int32_t in_xiso, int32_t in_depth
18291830}
18301831
18311832
1832- int32_t calculate_directory_offsets ( dir_node_avl * in_avl , unsigned long * io_current_sector , int32_t in_depth ) {
1833+ int32_t calculate_directory_offsets ( dir_node_avl * in_avl , uint32_t * io_current_sector , int32_t in_depth ) {
18331834 wdsafp_context context ;
18341835
18351836 if ( in_avl -> subdirectory ) {
@@ -1885,8 +1886,8 @@ int32_t calculate_directory_requirements( dir_node_avl *in_avl, void *in_context
18851886}
18861887
18871888
1888- int32_t calculate_directory_size ( dir_node_avl * in_avl , unsigned long * out_size , long in_depth ) {
1889- unsigned long length ;
1889+ int32_t calculate_directory_size ( dir_node_avl * in_avl , uint32_t * out_size , int32_t in_depth ) {
1890+ uint32_t length ;
18901891
18911892 if ( in_depth == 0 ) * out_size = 0 ;
18921893
@@ -1947,7 +1948,7 @@ int32_t generate_avl_tree_local( dir_node_avl **out_root, int32_t *io_n ) {
19471948 free ( avl );
19481949 continue ;
19491950 }
1950- s_total_bytes += avl -> file_size = (unsigned long ) sb .st_size ;
1951+ s_total_bytes += avl -> file_size = (uint32_t ) sb .st_size ;
19511952 ++ s_total_files ;
19521953 } else {
19531954 free ( avl -> filename );
@@ -1984,8 +1985,8 @@ FILE_TIME *alloc_filetime_now( void ) {
19841985 if ( ! err ) {
19851986 tmp = ( (double ) now + ( 369.0 * 365.25 * 24 * 60 * 60 - ( 3.0 * 24 * 60 * 60 + 6.0 * 60 * 60 ) ) ) * 1.0e7 ;
19861987
1987- ft -> h = (unsigned long ) ( tmp * ( 1.0 / ( 4.0 * (double ) ( 1 << 30 ) ) ) );
1988- ft -> l = (unsigned long ) ( tmp - ( (double ) ft -> h ) * 4.0 * (double ) ( 1 << 30 ) );
1988+ ft -> h = (uint32_t ) ( tmp * ( 1.0 / ( 4.0 * (double ) ( 1 << 30 ) ) ) );
1989+ ft -> l = (uint32_t ) ( tmp - ( (double ) ft -> h ) * 4.0 * (double ) ( 1 << 30 ) );
19891990
19901991 little32 ( ft -> h ); // convert to little endian here because this is a PC only struct and we won't read it anyway
19911992 little32 ( ft -> l );
@@ -2011,7 +2012,7 @@ FILE_TIME *alloc_filetime_now( void ) {
20112012// write_volume_descriptors() assumes that the iso file block from offset
20122013// 0x8000 to 0x8808 has been zeroed prior to entry.
20132014
2014- int32_t write_volume_descriptors ( int32_t in_xiso , unsigned long in_total_sectors ) {
2015+ int32_t write_volume_descriptors ( int32_t in_xiso , uint32_t in_total_sectors ) {
20152016 int32_t big , err = 0 , little ;
20162017 char date [] = "0000000000000000" ;
20172018 char spaces [ ECMA_119_VOLUME_CREATION_DATE - ECMA_119_VOLUME_SET_IDENTIFIER ];
0 commit comments