247
247
#include <fcntl.h>
248
248
#include <stdio.h>
249
249
#include <stdarg.h>
250
+ #include <stdint.h>
250
251
#include <stdlib.h>
251
252
#include <string.h>
252
253
#include <sys/stat.h>
@@ -509,7 +510,7 @@ typedef enum modes { k_generate_avl, k_extract, k_list, k_rewrite } modes;
509
510
typedef enum errors { err_end_of_sector = -5001 , err_iso_rewritten = -5002 , err_iso_no_files = -5003 } errors ;
510
511
511
512
typedef 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 );
513
514
514
515
typedef struct dir_node dir_node ;
515
516
typedef struct create_list create_list ;
@@ -526,20 +527,20 @@ struct dir_node {
526
527
unsigned char attributes ;
527
528
unsigned char filename_length ;
528
529
529
- unsigned long file_size ;
530
- unsigned long start_sector ;
530
+ uint32_t file_size ;
531
+ uint32_t start_sector ;
531
532
};
532
533
533
534
struct dir_node_avl {
534
- unsigned long offset ;
535
+ uint32_t offset ;
535
536
xoff_t dir_start ;
536
537
537
538
char * filename ;
538
- unsigned long file_size ;
539
- unsigned long start_sector ;
539
+ uint32_t file_size ;
540
+ uint32_t start_sector ;
540
541
dir_node_avl * subdirectory ;
541
542
542
- unsigned long old_start_sector ;
543
+ uint32_t old_start_sector ;
543
544
544
545
avl_skew skew ;
545
546
dir_node_avl * left ;
@@ -553,13 +554,13 @@ struct create_list {
553
554
};
554
555
555
556
typedef struct FILE_TIME {
556
- unsigned long l ;
557
- unsigned long h ;
557
+ uint32_t l ;
558
+ uint32_t h ;
558
559
} FILE_TIME ;
559
560
560
561
typedef struct wdsafp_context {
561
562
xoff_t dir_start ;
562
- unsigned long * current_sector ;
563
+ uint32_t * current_sector ;
563
564
} wdsafp_context ;
564
565
565
566
typedef struct write_tree_context {
@@ -579,13 +580,13 @@ avl_result avl_left_grown( dir_node_avl **in_root );
579
580
avl_result avl_right_grown ( dir_node_avl * * in_root );
580
581
dir_node_avl * avl_fetch ( dir_node_avl * in_root , char * in_filename );
581
582
avl_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 );
583
584
584
585
void 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 );
587
588
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 );
589
590
int32_t extract_file ( int32_t in_xiso , dir_node * in_file , modes in_mode , char * path );
590
591
int32_t decode_xiso ( char * in_xiso , char * in_path , modes in_mode , char * * out_iso_path , bool in_ll_compat );
591
592
int32_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
599
600
int32_t write_file ( dir_node_avl * in_avl , write_tree_context * in_context , int32_t in_depth );
600
601
int32_t write_tree ( dir_node_avl * in_avl , write_tree_context * in_context , int32_t in_depth );
601
602
int32_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 );
603
604
int32_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 );
605
606
int32_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 );
607
608
608
609
#if DEBUG
609
610
void write_sector ( int32_t in_xiso , xoff_t in_start , char * in_name , char * in_extension );
610
611
#endif
611
612
612
613
613
- static long s_pat_len ;
614
+ static int32_t s_pat_len ;
614
615
static bool s_quiet = false;
615
616
static 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 ;
618
619
static xoff_t s_total_bytes = 0 ;
619
620
static int s_total_files = 0 ;
620
621
static char * s_copy_buffer = nil ;
@@ -640,7 +641,7 @@ int main( int argc, char **argv ) {
640
641
create_list * create = nil , * p , * q , * * r ;
641
642
int32_t i , fd , opt_char , err = 0 , isos = 0 ;
642
643
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 ) ];
644
645
645
646
if ( argc < 2 ) { usage (); exit ( 1 ); }
646
647
@@ -819,7 +820,7 @@ int main( int argc, char **argv ) {
819
820
}
820
821
}
821
822
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 );
823
824
824
825
if ( new_iso_path ) {
825
826
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 ) {
831
832
if ( err == err_iso_no_files ) err = 0 ;
832
833
}
833
834
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 );
835
836
if ( s_warned ) exiso_log ( "\nWARNING: Warning(s) were issued during execution--review stderr!\n" );
836
837
837
838
boyer_moore_done ();
@@ -928,7 +929,7 @@ int32_t create_xiso( char *in_root_directory, char *in_output_directory, dir_nod
928
929
dir_node_avl root ;
929
930
FILE_TIME * ft = nil ;
930
931
write_tree_context wt_context ;
931
- unsigned long start_sector ;
932
+ uint32_t start_sector ;
932
933
int32_t i , n , xiso = -1 , err = 0 ;
933
934
char * cwd = nil , * buf = nil , * iso_name , * xiso_path , * iso_dir ;
934
935
@@ -1060,7 +1061,7 @@ int32_t create_xiso( char *in_root_directory, char *in_output_directory, dir_nod
1060
1061
1061
1062
if ( ! in_root ) {
1062
1063
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 );
1064
1065
}
1065
1066
1066
1067
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 ) {
1505
1506
}
1506
1507
1507
1508
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 ) {
1509
1510
int32_t err ;
1510
1511
1511
1512
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
1541
1542
#endif
1542
1543
1543
1544
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 ;
1546
1547
1547
1548
s_pattern = in_pattern ;
1548
1549
s_pat_len = in_pat_len ;
1549
1550
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 ();
1551
1552
1552
1553
if ( ! err ) {
1553
1554
for ( i = 0 ; i < in_alphabet_size ; ++ i ) s_bc_table [ i ] = in_pat_len ;
1554
1555
for ( i = 0 ; i < in_pat_len - 1 ; ++ i ) s_bc_table [ (unsigned char ) in_pattern [ i ] ] = in_pat_len - i - 1 ;
1555
1556
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 ();
1557
1558
}
1558
1559
1559
1560
if ( ! err ) {
@@ -1587,8 +1588,8 @@ void boyer_moore_done() {
1587
1588
}
1588
1589
1589
1590
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 ;
1592
1593
1593
1594
for ( i = j = s_pat_len - 1 ; j < in_text_len && i >= 0 ; ) {
1594
1595
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*
1615
1616
char c ;
1616
1617
int32_t err = 0 ;
1617
1618
bool warn = false;
1618
- unsigned long i , size , totalsize = 0 , totalpercent = 0 ;
1619
+ uint32_t i , size , totalsize = 0 , totalpercent = 0 ;
1619
1620
int32_t out ;
1620
1621
1621
1622
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*
1669
1670
}
1670
1671
1671
1672
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 ) {
1673
1674
dir_node_avl * avl = (dir_node_avl * ) in_dir_node_avl ;
1674
1675
1675
1676
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_
1727
1728
1728
1729
int32_t write_file ( dir_node_avl * in_avl , write_tree_context * in_context , int32_t in_depth ) {
1729
1730
char * buf , * p ;
1730
- unsigned long bytes , n , size ;
1731
+ uint32_t bytes , n , size ;
1731
1732
int32_t err = 0 , fd = -1 , i ;
1732
1733
1733
1734
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
1829
1830
}
1830
1831
1831
1832
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 ) {
1833
1834
wdsafp_context context ;
1834
1835
1835
1836
if ( in_avl -> subdirectory ) {
@@ -1885,8 +1886,8 @@ int32_t calculate_directory_requirements( dir_node_avl *in_avl, void *in_context
1885
1886
}
1886
1887
1887
1888
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 ;
1890
1891
1891
1892
if ( in_depth == 0 ) * out_size = 0 ;
1892
1893
@@ -1947,7 +1948,7 @@ int32_t generate_avl_tree_local( dir_node_avl **out_root, int32_t *io_n ) {
1947
1948
free ( avl );
1948
1949
continue ;
1949
1950
}
1950
- s_total_bytes += avl -> file_size = (unsigned long ) sb .st_size ;
1951
+ s_total_bytes += avl -> file_size = (uint32_t ) sb .st_size ;
1951
1952
++ s_total_files ;
1952
1953
} else {
1953
1954
free ( avl -> filename );
@@ -1984,8 +1985,8 @@ FILE_TIME *alloc_filetime_now( void ) {
1984
1985
if ( ! err ) {
1985
1986
tmp = ( (double ) now + ( 369.0 * 365.25 * 24 * 60 * 60 - ( 3.0 * 24 * 60 * 60 + 6.0 * 60 * 60 ) ) ) * 1.0e7 ;
1986
1987
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 ) );
1989
1990
1990
1991
little32 ( ft -> h ); // convert to little endian here because this is a PC only struct and we won't read it anyway
1991
1992
little32 ( ft -> l );
@@ -2011,7 +2012,7 @@ FILE_TIME *alloc_filetime_now( void ) {
2011
2012
// write_volume_descriptors() assumes that the iso file block from offset
2012
2013
// 0x8000 to 0x8808 has been zeroed prior to entry.
2013
2014
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 ) {
2015
2016
int32_t big , err = 0 , little ;
2016
2017
char date [] = "0000000000000000" ;
2017
2018
char spaces [ ECMA_119_VOLUME_CREATION_DATE - ECMA_119_VOLUME_SET_IDENTIFIER ];
0 commit comments