diff -urN vche-1.7.2/src/Makefile vche-1.7.2-64/src/Makefile --- vche-1.7.2/src/Makefile Tue Aug 17 01:09:48 1999 +++ vche-1.7.2-64/src/Makefile Sun Jan 26 15:53:23 2003 @@ -11,6 +11,14 @@ make -f Rules.make VCHE_RAW=1 make -f Rules.make mostly_clean make -f Rules.make VCHE_NC=1 + + make -f Rules.make mostly_clean + make -f Rules.make VCHE_VC=1 LARGE_FILE=1 + make -f Rules.make mostly_clean + make -f Rules.make VCHE_RAW=1 LARGE_FILE=1 + make -f Rules.make mostly_clean + make -f Rules.make VCHE_NC=1 LARGE_FILE=1 + mostly_clean: make -f Rules.make mostly_clean diff -urN vche-1.7.2/src/Rules.make vche-1.7.2-64/src/Rules.make --- vche-1.7.2/src/Rules.make Sun Nov 7 23:24:53 1999 +++ vche-1.7.2-64/src/Rules.make Sun Jan 26 15:54:36 2003 @@ -13,7 +13,7 @@ PROG_NC = vche-nc LIB_NC = nclib.o -VC_PROGRAMS = $(PROG_VC) $(PROG_RAW) $(PROG_NC) +VC_PROGRAMS = $(PROG_VC) $(PROG_RAW) $(PROG_NC) $(PROG_VC)64 $(PROG_RAW)64 $(PROG_NC)64 ifdef VCHE_VC VC_OBJ = $(LIB_VC) @@ -70,6 +70,11 @@ # Compiler flags CCOPTS = -O2 -fomit-frame-pointer + +ifdef LARGE_FILE +CCOPTS += -D_LARGEFILE_SOURCE -D_LARGEFILE64_SOURCE -D_FILE_OFFSET_BITS=64 +VC_PROG := $(VC_PROG)64 +endif # It's the shell that make will use. SHELL = /bin/sh diff -urN vche-1.7.2/src/common.h vche-1.7.2-64/src/common.h --- vche-1.7.2/src/common.h Mon Nov 8 20:59:16 1999 +++ vche-1.7.2-64/src/common.h Sun Jan 26 15:46:55 2003 @@ -221,6 +221,12 @@ #define VC_CASE_SENSITIVE 0 #define VC_CASE_INSENSITIVE 1 +#if _FILE_OFFSET_BITS == 64 +#define OFF_T_SCANF_FMT "%ll" +#else +#define OFF_T_SCANF_FMT "%l" +#endif + /* * Global variables */ @@ -268,7 +274,7 @@ extern int bread; -extern long vc_filesize; +extern off_t vc_filesize; #if defined(VCHE_VC) @@ -307,7 +313,7 @@ /* The double linked list file structure */ struct ll_file { char *filename; - long filepos; + off_t filepos; struct ll_file *next; struct ll_file *prev; }; @@ -324,7 +330,7 @@ /* The linked list for editing changes */ struct ll_edit { char byte; - long filepos; + off_t filepos; struct ll_edit *next; }; @@ -339,7 +345,7 @@ extern int current_color; #endif -extern long fpos; +extern off_t fpos; extern int edit_mask; @@ -352,7 +358,7 @@ void edit_insert_in_obuffer( char byte, int what_attr); /* file.c */ -#define file_getpos() lseek( fd, (long) 0, SEEK_CUR); +#define file_getpos() lseek( fd, (off_t) 0, SEEK_CUR); int file_go_next( void); int file_go_prev( void); void file_open( char *filename); @@ -366,7 +372,7 @@ void file_next_block( void); void file_prev_block( void); void file_getsize( void); -int file_is_a_valid_offset( long offset); +int file_is_a_valid_offset( off_t offset); /* help.c */ void help( void); @@ -377,7 +383,7 @@ void hex_mainloop( int view_or_edit); void hex_showfile( void); void hex_fill_hex_buffer( char *buf, int size); -void hex_fill_offset_buffer( long pos); +void hex_fill_offset_buffer( off_t pos); void hex_fill_ascii_buffer( char *buf, int size); #if defined(VCHE_VC) void hex_fill_zero_buffer( char *buf, int size); @@ -417,7 +423,7 @@ int ll_file_browse_next( int nitems); int ll_file_browse_back( int nitems); struct ll_edit *ll_edit_alloc( char byte); -void ll_edit_add( char byte, long filepos, struct ll_edit *tmp); +void ll_edit_add( char byte, off_t filepos, struct ll_edit *tmp); void ll_edit_free( void); /* misc.c */ @@ -425,7 +431,7 @@ void draw_filename( char *filename); void draw_main_screen( void); void draw_fkeys( struct fkey_text fkt[]); -void draw_offset_n_perc( long offset); +void draw_offset_n_perc( off_t offset); void set_flag( int flag); void *allocate_mem( int size); char *trim_spaces( char *s); diff -urN vche-1.7.2/src/edit.c vche-1.7.2-64/src/edit.c --- vche-1.7.2/src/edit.c Tue Aug 17 01:09:48 1999 +++ vche-1.7.2-64/src/edit.c Sun Jan 26 15:25:31 2003 @@ -951,7 +951,7 @@ free( temp); } - lseek( fd, (long) fpos, SEEK_SET); + lseek( fd, (off_t) fpos, SEEK_SET); ll_edit_head = NULL; diff -urN vche-1.7.2/src/file.c vche-1.7.2-64/src/file.c --- vche-1.7.2/src/file.c Mon Nov 8 20:53:39 1999 +++ vche-1.7.2-64/src/file.c Sun Jan 26 15:44:18 2003 @@ -23,7 +23,7 @@ #include "common.h" /* The size of the file we are viewing or editing */ -long vc_filesize; +off_t vc_filesize; int file_go_next( void) { @@ -138,7 +138,7 @@ return; } - fpos = lseek( fd, ( long) bytes_per_row, SEEK_CUR); + fpos = lseek( fd, ( off_t) bytes_per_row, SEEK_CUR); hex_showfile(); } @@ -147,12 +147,12 @@ { if( vc_filesize >= 0 && fpos < bytes_per_row) { term_beep(); - fpos = lseek( fd, (long) 0, SEEK_SET); + fpos = lseek( fd, (off_t) 0, SEEK_SET); hex_showfile(); return; } - fpos = lseek( fd, ( long) -1 * bytes_per_row, SEEK_CUR); + fpos = lseek( fd, ( off_t) -1 * bytes_per_row, SEEK_CUR); hex_showfile(); } @@ -166,7 +166,7 @@ return; } - fpos = lseek( fd, ( long) 1, SEEK_CUR); + fpos = lseek( fd, ( off_t) 1, SEEK_CUR); hex_showfile(); } @@ -178,7 +178,7 @@ return; } - fpos = lseek( fd, ( long) -1, SEEK_CUR); + fpos = lseek( fd, ( off_t) -1, SEEK_CUR); hex_showfile(); } @@ -189,7 +189,7 @@ return; } - fpos = lseek( fd, (long) 0, SEEK_SET); + fpos = lseek( fd, (off_t) 0, SEEK_SET); hex_showfile(); } @@ -203,7 +203,7 @@ return; } - fpos = lseek( fd, (long) vc_filesize - (vc_filesize % bytes_to_read), SEEK_SET); + fpos = lseek( fd, (off_t) vc_filesize - (vc_filesize % bytes_to_read), SEEK_SET); hex_showfile(); } @@ -217,7 +217,7 @@ return; } - fpos = lseek( fd, (long) bytes_to_read, SEEK_CUR); + fpos = lseek( fd, (off_t) bytes_to_read, SEEK_CUR); hex_showfile(); } @@ -225,12 +225,12 @@ { if( vc_filesize >= 0 && fpos < bytes_to_read) { term_beep(); - fpos = lseek( fd, (long) 0, SEEK_SET); + fpos = lseek( fd, (off_t) 0, SEEK_SET); hex_showfile(); return; } - fpos = lseek( fd, (long) -1 * bytes_to_read, SEEK_CUR); + fpos = lseek( fd, (off_t) -1 * bytes_to_read, SEEK_CUR); hex_showfile(); } @@ -255,7 +255,7 @@ anyway, it will give wrong offsets when the device size is greater than LONG_MAX */ double low = 0; - long size = 0; + off_t size = 0; int i = 0; vc_filesize = stbuf.st_size; @@ -310,20 +310,20 @@ */ low = 0; - for( high = 1024; file_is_a_valid_offset( (long) high); high *= 2) + for( high = 1024; file_is_a_valid_offset( (off_t) high); high *= 2) low = high; while( low < high - 1) { const double mid = ( low + high) / 2; - if( file_is_a_valid_offset( (long) mid)) + if( file_is_a_valid_offset( (off_t) mid)) low = mid; else high = mid; } lseek( fd, 0L, SEEK_SET); - vc_filesize = ( long) low + 1; + vc_filesize = ( off_t) low + 1; break; /* Enter it manually */ @@ -348,9 +348,9 @@ #endif if( !strncasecmp( size_str, "0x", 2)) - sscanf( size_str, "%lx", &vc_filesize); + sscanf( size_str, OFF_T_SCANF_FMT "x", &vc_filesize); else - vc_filesize = atol( size_str); + sscanf( size_str, OFF_T_SCANF_FMT "d", &vc_filesize); #if defined(VCHE_VC) || defined(VCHE_RAW) lib_load_screen(); @@ -379,7 +379,7 @@ } -int file_is_a_valid_offset( long offset) +int file_is_a_valid_offset( off_t offset) { char c; diff -urN vche-1.7.2/src/hex.c vche-1.7.2-64/src/hex.c --- vche-1.7.2/src/hex.c Fri Aug 20 01:27:23 1999 +++ vche-1.7.2-64/src/hex.c Sun Jan 26 15:33:45 2003 @@ -45,7 +45,7 @@ char *offset_buffer; -long fpos; /* File position */ +off_t fpos; /* File position */ int bread; /* bytes read */ int bytes_to_read; /* Quantity of bytes to read */ @@ -90,7 +90,7 @@ set_flag( FLAG_READONLY); ll_file_current->filepos = fpos; file_open( ll_file_current->filename); - fpos = lseek( fd, (long) ll_file_current->filepos, SEEK_SET); + fpos = lseek( fd, (off_t) ll_file_current->filepos, SEEK_SET); draw_filename( ll_file_current->filename); hex_showfile(); lib_flush(); @@ -103,7 +103,7 @@ case 'n': ll_file_current->filepos = fpos; if( file_go_next() == -1) break; - fpos = lseek( fd, (long) ll_file_current->filepos, SEEK_SET); + fpos = lseek( fd, (off_t) ll_file_current->filepos, SEEK_SET); draw_filename( ll_file_current->filename); hex_showfile(); lib_flush(); @@ -112,7 +112,7 @@ case 'p': ll_file_current->filepos = fpos; if( file_go_prev() == -1) break; - fpos = lseek( fd, (long) ll_file_current->filepos, SEEK_SET); + fpos = lseek( fd, (off_t) ll_file_current->filepos, SEEK_SET); draw_filename( ll_file_current->filename); hex_showfile(); lib_flush(); @@ -294,7 +294,7 @@ void hex_showfile( void) { - long lfpos; + off_t lfpos; int startxy; int size; int line; @@ -308,7 +308,7 @@ bread = read( fd, hbuffer, bytes_to_read); - lseek( fd, (long) fpos, SEEK_SET); + lseek( fd, (off_t) fpos, SEEK_SET); if( bread < bytes_to_read) memset( hbuffer + bread, 0, bytes_to_read - bread); @@ -389,7 +389,7 @@ } -void hex_fill_offset_buffer( long pos) +void hex_fill_offset_buffer( off_t pos) { register char *bp = offset_buffer + 10; diff -urN vche-1.7.2/src/linkedlist.c vche-1.7.2-64/src/linkedlist.c --- vche-1.7.2/src/linkedlist.c Tue Aug 17 01:09:48 1999 +++ vche-1.7.2-64/src/linkedlist.c Sun Jan 26 15:27:23 2003 @@ -265,7 +265,7 @@ ll_file_current->filepos = fpos; ll_file_current = ll_file_browse_curr; file_open( ll_file_current->filename); - fpos = lseek( fd, (long) ll_file_current->filepos, SEEK_SET); + fpos = lseek( fd, (off_t) ll_file_current->filepos, SEEK_SET); draw_filename( ll_file_current->filename); hex_showfile(); lib_flush(); @@ -555,7 +555,7 @@ return p; } -void ll_edit_add( char byte, long filepos, struct ll_edit *tmp) +void ll_edit_add( char byte, off_t filepos, struct ll_edit *tmp) { struct ll_edit *p = ll_edit_alloc( byte); diff -urN vche-1.7.2/src/misc.c vche-1.7.2-64/src/misc.c --- vche-1.7.2/src/misc.c Mon Nov 8 22:23:36 1999 +++ vche-1.7.2-64/src/misc.c Sun Jan 26 15:29:07 2003 @@ -46,7 +46,7 @@ of the screen columns, and will be filled with spaces ' ' */ char *space_buffer; -static void print_long( long value, int prec); +static void print_long( off_t value, int prec); struct vc_flags flags; char *trans_buffer; @@ -176,14 +176,14 @@ } while( nfk[ i]); } -void draw_offset_n_perc( long offset) +void draw_offset_n_perc( off_t offset) { double d_offset; double d_filesize; double d_percent; /* I need to use "double" because the multiplication - could overflow the "long" arguments if the file + could overflow the "off_t" arguments if the file is too big. */ d_offset = offset; @@ -194,14 +194,14 @@ else d_percent = ( d_offset * 100) / d_filesize; - print_long( ( long) d_percent, 3); + print_long( ( off_t) d_percent, 3); lib_cputs( vc_cols - 4, 0, 3, trans_buffer, VC_COLOR_BACKCYAN); print_long( offset, 13); lib_cputs( vc_cols - 18, 0, 13, trans_buffer, VC_COLOR_BACKCYAN); } -void print_long( long value, int prec) +void print_long( off_t value, int prec) { register char *bp = trans_buffer + prec; diff -urN vche-1.7.2/src/search.c vche-1.7.2-64/src/search.c --- vche-1.7.2/src/search.c Fri Aug 20 01:50:31 1999 +++ vche-1.7.2-64/src/search.c Sun Jan 26 15:58:19 2003 @@ -31,10 +31,10 @@ int vc_case_sensitive; char srch[ 64]; /* The string to search */ -static long search_again_offset; -static long re_search; +static off_t search_again_offset; +static off_t re_search; -static void search_string( char *str, long offset); +static void search_string( char *str, off_t offset); static long search_in_memory( char *sbuffer, char *pattern, long sizes, long sizep); static void search_hilite_byte( char byte, int what_attr); @@ -124,14 +124,14 @@ WINDOW *w; #endif char posstr[ 64]; - long newpos = -1; + off_t newpos = -1; #if defined(VCHE_VC) || defined(VCHE_RAW) lib_save_screen(); #endif memset( &posstr, 0, sizeof( posstr)); - sprintf( posstr, "%ld", fpos); + sprintf( posstr, OFF_T_SCANF_FMT "d", fpos); #if defined(VCHE_NC) w = @@ -147,9 +147,9 @@ #endif if( !strncasecmp( posstr, "0x", 2)) - sscanf( posstr, "%lx", &newpos); + sscanf( posstr, OFF_T_SCANF_FMT "x", &newpos); else - newpos = atol( posstr); + sscanf( posstr, OFF_T_SCANF_FMT "d", &newpos); if( vc_filesize >= 0 && (newpos < 0 || newpos > vc_filesize)) { lib_alert( "Invalid offset!", 5); @@ -161,7 +161,7 @@ return; } - fpos = lseek( fd, (long) newpos, SEEK_SET); + fpos = lseek( fd, (off_t) newpos, SEEK_SET); #if defined(VCHE_VC) || defined(VCHE_RAW) lib_load_screen(); @@ -170,7 +170,7 @@ #endif } -static void search_string( char *str, long offset) +static void search_string( char *str, off_t offset) { #if defined(VCHE_NC) WINDOW *w; @@ -178,14 +178,14 @@ struct ll_edit *node; struct ll_edit *tmp; char search_buf[ 8192]; /* Buffer used to read data from file */ - long filepos = 0; /* File position */ - long bytes_read; /* Bytes read from file */ + off_t filepos = 0; /* File position */ + off_t bytes_read; /* Bytes read from file */ long sizep = strlen( str); /* Size of pattern to search */ long retv; /* Return value for search_in_memory function */ int i = 0; search_again_offset = 0; - lseek( fd, (long) offset, SEEK_SET); + lseek( fd, (off_t) offset, SEEK_SET); #if defined(VCHE_VC) || defined(VCHE_RAW) lib_save_screen(); @@ -234,13 +234,13 @@ #elif defined(VCHE_NC) delwin( w); #endif - lseek( fd, (long) fpos, SEEK_SET); + lseek( fd, (off_t) fpos, SEEK_SET); return; } /* String found partially, lseek to the matching characters */ if( retv == -2) - lseek( fd, (long) filepos + re_search, SEEK_SET); + lseek( fd, (off_t) filepos + re_search, SEEK_SET); } /* end while(....) */ lib_alert( "String not found", 5); @@ -250,7 +250,7 @@ delwin( w); #endif - lseek( fd, (long) fpos, SEEK_SET); + lseek( fd, (off_t) fpos, SEEK_SET); } /*