Skip to content

Commit 5e872b9

Browse files
committed
Use set width data types instead of long/long long
1 parent dbad75a commit 5e872b9

File tree

1 file changed

+42
-42
lines changed

1 file changed

+42
-42
lines changed

extract-xiso.c

+42-42
Original file line numberDiff line numberDiff line change
@@ -509,7 +509,7 @@ typedef enum modes { k_generate_avl, k_extract, k_list, k_rewrite } modes;
509509
typedef enum errors { err_end_of_sector = -5001, err_iso_rewritten = -5002, err_iso_no_files = -5003 } errors;
510510

511511
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 );
512+
typedef int32_t (*traversal_callback)( void *in_node, void *in_context, int32_t in_depth );
513513

514514
typedef struct dir_node dir_node;
515515
typedef struct create_list create_list;
@@ -526,20 +526,20 @@ struct dir_node {
526526
unsigned char attributes;
527527
unsigned char filename_length;
528528

529-
unsigned long file_size;
530-
unsigned long start_sector;
529+
u_int32_t file_size;
530+
u_int32_t start_sector;
531531
};
532532

533533
struct dir_node_avl {
534-
unsigned long offset;
534+
u_int32_t offset;
535535
xoff_t dir_start;
536536

537537
char *filename;
538-
unsigned long file_size;
539-
unsigned long start_sector;
538+
u_int32_t file_size;
539+
u_int32_t start_sector;
540540
dir_node_avl *subdirectory;
541541

542-
unsigned long old_start_sector;
542+
u_int32_t old_start_sector;
543543

544544
avl_skew skew;
545545
dir_node_avl *left;
@@ -553,13 +553,13 @@ struct create_list {
553553
};
554554

555555
typedef struct FILE_TIME {
556-
unsigned long l;
557-
unsigned long h;
556+
u_int32_t l;
557+
u_int32_t h;
558558
} FILE_TIME;
559559

560560
typedef struct wdsafp_context {
561561
xoff_t dir_start;
562-
unsigned long *current_sector;
562+
u_int32_t *current_sector;
563563
} wdsafp_context;
564564

565565
typedef struct write_tree_context {
@@ -579,13 +579,13 @@ avl_result avl_left_grown( dir_node_avl **in_root );
579579
avl_result avl_right_grown( dir_node_avl **in_root );
580580
dir_node_avl *avl_fetch( dir_node_avl *in_root, char *in_filename );
581581
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 );
582+
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 );
583583

584584
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 );
585+
char *boyer_moore_search( char *in_text, int32_t in_text_len );
586+
int32_t boyer_moore_init( char *in_pattern, int32_t in_pat_len, int32_t in_alphabet_size );
587587

588-
int32_t free_dir_node_avl( void *in_dir_node_avl, void *, long );
588+
int32_t free_dir_node_avl( void *in_dir_node_avl, void *, int32_t );
589589
int32_t extract_file( int32_t in_xiso, dir_node *in_file, modes in_mode, char *path );
590590
int32_t decode_xiso( char *in_xiso, char *in_path, modes in_mode, char **out_iso_path, bool in_ll_compat );
591591
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 +599,22 @@ int32_t write_directory( dir_node_avl *in_avl, int32_t in_xiso, int32_t in_depth
599599
int32_t write_file( dir_node_avl *in_avl, write_tree_context *in_context, int32_t in_depth );
600600
int32_t write_tree( dir_node_avl *in_avl, write_tree_context *in_context, int32_t in_depth );
601601
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 );
602+
int32_t calculate_directory_size( dir_node_avl *in_avl, u_int32_t *out_size, int32_t in_depth );
603603
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 );
604+
int32_t calculate_directory_offsets( dir_node_avl *in_avl, u_int32_t *io_context, int32_t in_depth );
605605
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 );
606+
int32_t write_volume_descriptors( int32_t in_xiso, u_int32_t in_total_sectors );
607607

608608
#if DEBUG
609609
void write_sector( int32_t in_xiso, xoff_t in_start, char *in_name, char *in_extension );
610610
#endif
611611

612612

613-
static long s_pat_len;
613+
static int32_t s_pat_len;
614614
static bool s_quiet = false;
615615
static char *s_pattern = nil;
616-
static long *s_gs_table = nil;
617-
static long *s_bc_table = nil;
616+
static int32_t *s_gs_table = nil;
617+
static int32_t *s_bc_table = nil;
618618
static xoff_t s_total_bytes = 0;
619619
static int s_total_files = 0;
620620
static char *s_copy_buffer = nil;
@@ -640,7 +640,7 @@ int main( int argc, char **argv ) {
640640
create_list *create = nil, *p, *q, **r;
641641
int32_t i, fd, opt_char, err = 0, isos = 0;
642642
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) ];
643+
char *cwd = nil, *path = nil, *buf = nil, *new_iso_path = nil, tag[ XISO_OPTIMIZED_TAG_LENGTH * sizeof(int32_t) ];
644644

645645
if ( argc < 2 ) { usage(); exit( 1 ); }
646646

@@ -819,7 +819,7 @@ int main( int argc, char **argv ) {
819819
}
820820
}
821821

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 );
822+
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 );
823823

824824
if ( new_iso_path ) {
825825
if ( ! err ) exiso_log( "\n%s successfully rewritten%s%s\n", argv[ i ], path ? " as " : ".", path ? new_iso_path : "" );
@@ -831,7 +831,7 @@ int main( int argc, char **argv ) {
831831
if ( err == err_iso_no_files ) err = 0;
832832
}
833833

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 );
834+
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 );
835835
if ( s_warned ) exiso_log( "\nWARNING: Warning(s) were issued during execution--review stderr!\n" );
836836

837837
boyer_moore_done();
@@ -928,7 +928,7 @@ int32_t create_xiso( char *in_root_directory, char *in_output_directory, dir_nod
928928
dir_node_avl root;
929929
FILE_TIME *ft = nil;
930930
write_tree_context wt_context;
931-
unsigned long start_sector;
931+
u_int32_t start_sector;
932932
int32_t i, n, xiso = -1, err = 0;
933933
char *cwd = nil, *buf = nil, *iso_name, *xiso_path, *iso_dir;
934934

@@ -1060,7 +1060,7 @@ int32_t create_xiso( char *in_root_directory, char *in_output_directory, dir_nod
10601060

10611061
if ( ! in_root ) {
10621062
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 );
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, (int64_t) s_total_bytes );
10641064
}
10651065

10661066
if ( root.subdirectory != EMPTY_SUBDIRECTORY ) avl_traverse_depth_first( root.subdirectory, free_dir_node_avl, nil, k_postfix, 0 );
@@ -1505,7 +1505,7 @@ int32_t avl_compare_key( char *in_lhs, char *in_rhs ) {
15051505
}
15061506

15071507

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 ) {
1508+
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 ) {
15091509
int32_t err;
15101510

15111511
if ( in_root == nil ) return 0;
@@ -1541,19 +1541,19 @@ int32_t avl_traverse_depth_first( dir_node_avl *in_root, traversal_callback in_c
15411541
#endif
15421542

15431543

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;
1544+
int32_t boyer_moore_init( char *in_pattern, int32_t in_pat_len, int32_t in_alphabet_size ) {
1545+
int32_t i, j, k, *backup, err = 0;
15461546

15471547
s_pattern = in_pattern;
15481548
s_pat_len = in_pat_len;
15491549

1550-
if ( ( s_bc_table = (long *) malloc( in_alphabet_size * sizeof(long) ) ) == nil ) mem_err();
1550+
if ( ( s_bc_table = (int32_t *) malloc( in_alphabet_size * sizeof(int32_t) ) ) == nil ) mem_err();
15511551

15521552
if ( ! err ) {
15531553
for ( i = 0; i < in_alphabet_size; ++i ) s_bc_table[ i ] = in_pat_len;
15541554
for ( i = 0; i < in_pat_len - 1; ++i ) s_bc_table[ (unsigned char) in_pattern[ i ] ] = in_pat_len - i - 1;
15551555

1556-
if ( ( s_gs_table = (long *) malloc( 2 * ( in_pat_len + 1 ) * sizeof(long) ) ) == nil ) mem_err();
1556+
if ( ( s_gs_table = (int32_t *) malloc( 2 * ( in_pat_len + 1 ) * sizeof(int32_t) ) ) == nil ) mem_err();
15571557
}
15581558

15591559
if ( ! err ) {
@@ -1587,8 +1587,8 @@ void boyer_moore_done() {
15871587
}
15881588

15891589

1590-
char *boyer_moore_search( char *in_text, long in_text_len ) {
1591-
long i, j, k, l;
1590+
char *boyer_moore_search( char *in_text, int32_t in_text_len ) {
1591+
int32_t i, j, k, l;
15921592

15931593
for ( i = j = s_pat_len - 1; j < in_text_len && i >= 0; ) {
15941594
if ( in_text[ j ] == s_pattern[ i ] ) { --i; --j; }
@@ -1615,7 +1615,7 @@ int32_t extract_file( int32_t in_xiso, dir_node *in_file, modes in_mode , char*
16151615
char c;
16161616
int32_t err = 0;
16171617
bool warn = false;
1618-
unsigned long i, size, totalsize = 0, totalpercent = 0;
1618+
u_int32_t i, size, totalsize = 0, totalpercent = 0;
16191619
int32_t out;
16201620

16211621
if ( s_remove_systemupdate && strstr( path, s_systemupdate ) )
@@ -1669,7 +1669,7 @@ int32_t extract_file( int32_t in_xiso, dir_node *in_file, modes in_mode , char*
16691669
}
16701670

16711671

1672-
int32_t free_dir_node_avl( void *in_dir_node_avl, void *in_context, long in_depth ) {
1672+
int32_t free_dir_node_avl( void *in_dir_node_avl, void *in_context, int32_t in_depth ) {
16731673
dir_node_avl *avl = (dir_node_avl *) in_dir_node_avl;
16741674

16751675
if ( avl->subdirectory && avl->subdirectory != EMPTY_SUBDIRECTORY ) avl_traverse_depth_first( avl->subdirectory, free_dir_node_avl, nil, k_postfix, 0 );
@@ -1727,7 +1727,7 @@ int32_t write_tree( dir_node_avl *in_avl, write_tree_context *in_context, int32_
17271727

17281728
int32_t write_file( dir_node_avl *in_avl, write_tree_context *in_context, int32_t in_depth ) {
17291729
char *buf, *p;
1730-
unsigned long bytes, n, size;
1730+
u_int32_t bytes, n, size;
17311731
int32_t err = 0, fd = -1, i;
17321732

17331733
if ( ! in_avl->subdirectory ) {
@@ -1829,7 +1829,7 @@ int32_t write_directory( dir_node_avl *in_avl, int32_t in_xiso, int32_t in_depth
18291829
}
18301830

18311831

1832-
int32_t calculate_directory_offsets( dir_node_avl *in_avl, unsigned long *io_current_sector, int32_t in_depth ) {
1832+
int32_t calculate_directory_offsets( dir_node_avl *in_avl, u_int32_t *io_current_sector, int32_t in_depth ) {
18331833
wdsafp_context context;
18341834

18351835
if ( in_avl->subdirectory ) {
@@ -1885,8 +1885,8 @@ int32_t calculate_directory_requirements( dir_node_avl *in_avl, void *in_context
18851885
}
18861886

18871887

1888-
int32_t calculate_directory_size( dir_node_avl *in_avl, unsigned long *out_size, long in_depth ) {
1889-
unsigned long length;
1888+
int32_t calculate_directory_size( dir_node_avl *in_avl, u_int32_t *out_size, int32_t in_depth ) {
1889+
u_int32_t length;
18901890

18911891
if ( in_depth == 0 ) *out_size = 0;
18921892

@@ -1947,7 +1947,7 @@ int32_t generate_avl_tree_local( dir_node_avl **out_root, int32_t *io_n ) {
19471947
free( avl );
19481948
continue;
19491949
}
1950-
s_total_bytes += avl->file_size = (unsigned long) sb.st_size;
1950+
s_total_bytes += avl->file_size = (u_int32_t) sb.st_size;
19511951
++s_total_files;
19521952
} else {
19531953
free( avl->filename );
@@ -1984,8 +1984,8 @@ FILE_TIME *alloc_filetime_now( void ) {
19841984
if ( ! err ) {
19851985
tmp = ( (double) now + ( 369.0 * 365.25 * 24 * 60 * 60 - ( 3.0 * 24 * 60 * 60 + 6.0 * 60 * 60 ) ) ) * 1.0e7;
19861986

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 ) );
1987+
ft->h = (u_int32_t) ( tmp * ( 1.0 / ( 4.0 * (double) ( 1 << 30 ) ) ) );
1988+
ft->l = (u_int32_t) ( tmp - ( (double) ft->h ) * 4.0 * (double) ( 1 << 30 ) );
19891989

19901990
little32( ft->h ); // convert to little endian here because this is a PC only struct and we won't read it anyway
19911991
little32( ft->l );
@@ -2011,7 +2011,7 @@ FILE_TIME *alloc_filetime_now( void ) {
20112011
// write_volume_descriptors() assumes that the iso file block from offset
20122012
// 0x8000 to 0x8808 has been zeroed prior to entry.
20132013

2014-
int32_t write_volume_descriptors( int32_t in_xiso, unsigned long in_total_sectors ) {
2014+
int32_t write_volume_descriptors( int32_t in_xiso, u_int32_t in_total_sectors ) {
20152015
int32_t big, err = 0, little;
20162016
char date[] = "0000000000000000";
20172017
char spaces[ ECMA_119_VOLUME_CREATION_DATE - ECMA_119_VOLUME_SET_IDENTIFIER ];

0 commit comments

Comments
 (0)