arj-3.10.22/ 777 0 0 0 10256535570 6575 5ustar arj-3.10.22/ansi.c 666 0 0 14532 7450452336 7760 0ustar /* * $Id: ansi.c,v 1.1.1.1 2002/03/27 23:25:18 andrew_belov Exp $ * --------------------------------------------------------------------------- * Routines to display ANSI comments are located here. Not all routines are * supported - first of all, this restriction applies to graphic commands. It * has to be noted that the code comes from some PASCAL snippet - therefore, * arrays are 1-based. * */ #include "arj.h" DEBUGHDR(__FILE__) /* Debug information block */ #define TEXTCOLOR_MASK 0x07 /* Basic colors */ #define TEXTFORE_MASK 0x0F /* Text */ #define TESTBACK_MASK 0xF0 /* Background */ #define TEXT_BRIGHT 8 /* Bright text bit */ #define TEXT_BLINK 0x80 /* Blinking text bit */ #ifndef DIRECT_TO_ANSI static char ansi_initialized=0; /* 1 once init_ansi() is called */ static char ansi_commands[]="HFABCDNJMSUK"; static int esc_found; /* 1 if the last character was ESC */ static int ansi_seq_found; /* 1 if a valid sequence is detected */ static char ansi_ptr; /* Offset within internal buffer */ static char ansi_buf[22]; /* Internal buffer */ static int ansi_bright; /* 1 will enable bright characters */ static int ansi_blink; /* 1 makes the blinking or bright background (0x80) */ static unsigned char ansi_saved_x; /* Saved X coordinate */ static unsigned char ansi_saved_y; /* Saved Y coordinate */ /* Initializes ANSI display structures */ static void init_ansi() { memset(ansi_buf, 32, sizeof(ansi_buf)); ansi_bright=ansi_blink=0; esc_found=0; ansi_seq_found=0; ansi_ptr=0; ansi_saved_x=ansi_saved_y=1; } /* Processes the ANSI sequence stored in the buffer */ static void process_ansi_cmd() { char pad_buf[20]; char cur_pos; char tmp_pos; /* Temporary pointer */ char dec_pos; char param; /* Current decimal position */ char tmp_color=0; char tmp_back; param=0; dec_pos=1; pad_buf[1]=pad_buf[2]=1; for(cur_pos=1; cur_pos!=ansi_ptr; cur_pos++) { if(param==0) /* Parameters start at 1 */ param++; if(isdigit((int)ansi_buf[cur_pos])&&dec_pos<3) { pad_buf[param]=(dec_pos==1)?ansi_buf[cur_pos]-'0':pad_buf[param]*10+ansi_buf[cur_pos]-'0'; dec_pos++; } else { if(ansi_buf[cur_pos]==ANSI_DELIMITER) { if(dec_pos==1) pad_buf[param]=1; param++; dec_pos=1; } } } /* The parameters are referenced as (X; Y) */ switch(ansi_buf[ansi_ptr]) { /* Move the cursor X rows up */ case 'A': gotoxy(wherex(), wherey()-pad_buf[1]); break; /* Move the cursor X rows down */ case 'B': gotoxy(wherex(), wherey()+pad_buf[1]); break; /* Move the cursor X columns left */ case 'C': gotoxy(wherex()+pad_buf[1], wherey()); break; /* Move the cursor X columns right */ case 'D': gotoxy(wherex()-pad_buf[1], wherey()); break; /* Set the cursor position to (Y; X) */ case 'F': case 'H': gotoxy(pad_buf[2], pad_buf[1]); break; /* Clear the screen (quite incorrect, since only ^[[2J does it) */ case 'J': clrscr(); break; /* Clear all character from current position to end of line */ case 'K': clreol(); break; /* Set the text attributes */ case 'M': for(tmp_pos=1; tmp_pos<=param; tmp_pos++) { switch(pad_buf[tmp_pos]) { /* Set the default attributes */ case 0: textcolor(7); textbackground(0); ansi_bright=ansi_blink=0; break; /* Set the bright mode on */ case 1: ansi_bright=1; textcolor(getcurattr()&TEXTFORE_MASK|TEXT_BRIGHT); break; /* Set the blinking mode on */ case 5: ansi_blink=1; textattr(getcurattr()|TEXT_BLINK); break; /* Set the inverse video on. The code in original ARJ is a bit incorrect here, because it swaps the foreground and background colors. */ case 7: textattr(0x70); break; /* Make the text invisible by setting the foreground color the same as the background color. */ case 8: tmp_back=(getcurattr()>>4)|TEXTCOLOR_MASK; textcolor(tmp_back); break; /* Set the text foreground color */ case 30: case 31: case 32: case 33: case 34: case 35: case 36: case 37: switch(pad_buf[tmp_pos]) { case 30: tmp_color=0; break; case 31: tmp_color=4; break; case 32: tmp_color=2; break; case 33: tmp_color=6; break; case 34: tmp_color=1; break; case 35: tmp_color=5; break; case 36: tmp_color=3; break; case 37: tmp_color=7; break; } if(ansi_bright) tmp_color|=TEXT_BRIGHT; if(ansi_blink) tmp_color|=TEXT_BLINK; textcolor(tmp_color); break; /* Set the background colors */ case 40: textbackground(0); break; case 41: textbackground(4); break; case 42: textbackground(2); break; case 43: textbackground(6); break; case 44: textbackground(1); break; case 45: textbackground(5); break; case 46: textbackground(3); break; case 47: textbackground(7); break; } } break; /* Save the current cursor coordinates */ case 'S': ansi_saved_x=(unsigned char)wherex(); ansi_saved_y=(unsigned char)wherey(); break; /* Restore the saved coordinates */ case 'U': gotoxy((int)ansi_saved_x, (int)ansi_saved_y); break; } } /* Accumulates given characters and displays ANSI sequences once they're formed */ void display_ansi(char c) { if(!ansi_initialized) { init_ansi(); ansi_initialized=1; } if(c==ANSI_ESC) { esc_found=1; return; } if(c==ANSI_BRACKET&&esc_found) { ansi_seq_found=1; return; } if(esc_found&&ansi_seq_found) { ansi_buf[++ansi_ptr]=toupper(c); if(ansi_ptr #include #include "arj.h" DEBUGHDR(__FILE__) /* Debug information block */ /* Expiry date/time */ #define EXPIRABLE 0 /* 1 -> allow expiry as such */ #define EXPIRY_YR 1980 #define EXPIRY_MO 1 #define EXPIRY_DY 1 #define EXPIRY_H 0 #define EXPIRY_M 0 #define EXPIRY_S 0 /* Local variables */ static char fixed_arjtemp[]="ARJTEMP.$$$"; static char arjtemp_wildcard[]="ARJTEMP.$??"; static char wildcard_pattern[]="?*[]^"; static int tmp_archive_exists; static int tmp_archive_removed; static unsigned long ticks; static unsigned int limit; static char brief_help[]="arjs.txt"; static char full_help[]="arjl.txt"; static char sort_filename[]="arjsort.$$$"; static char *arj_env_str=NULL; static char single_spc[]=" "; /* Forward references */ static void finish_archive_name(char *name); static void final_cleanup(void); /* Checks if all the files given to ARJ were successfully processed. */ static void file_arg_cleanup(struct flist_root *flist) { int cur_arg; FILE_COUNT cur_file; char *tmp_name; for(cur_arg=0; cur_argfiles>0) { tmp_name=malloc_msg(FILENAME_MAX); for(cur_file=0; cur_filefiles; cur_file++) { flist_retrieve(tmp_name, NULL, flist, cur_file); msg_cprintf(H_ERR, M_CANT_FIND, tmp_name); if(listfile_err_opt) { if(errorlevel==ARJ_ERL_SUCCESS) errorlevel=ARJ_ERL_WARNING; errors++; } } free(tmp_name); } } /* Depending on the command given, issues some special setup */ static void cmd_setup(int *cmd, int *is_add_cmd) { int cnv_cmd; int add_cmd; char *tmp_swptr; char *vptr; unsigned long vol_size; cnv_cmd=*cmd; switch(*cmd) { case ARJ_CMD_MOVE: cnv_cmd=ARJ_CMD_ADD; delete_processed=DP_ADD; case ARJ_CMD_ADD: if(freshen_criteria) cnv_cmd=ARJ_CMD_FRESHEN; if(update_criteria) cnv_cmd=ARJ_CMD_UPDATE; break; case ARJ_CMD_REM_BAK: current_chapter=RESERVED_CHAPTER; break; case ARJ_CMD_FRESHEN: if(freshen_criteria==FC_NONE) freshen_criteria=FC_EXISTING; break; case ARJ_CMD_UPDATE: if(update_criteria==FC_NONE) update_criteria=FC_EXISTING; break; case ARJ_CMD_SECURE: sign_with_arjsec=1; break; case ARJ_CMD_ADDC: cnv_cmd=ARJ_CMD_UPDATE; update_criteria=UC_NEW_OR_DIFFERENT; chapter_mode=CHAP_USE; break; case ARJ_CMD_CNVC: cnv_cmd=ARJ_CMD_COPY; chapter_mode=CHAP_USE; break; case ARJ_CMD_DELC: cnv_cmd=ARJ_CMD_DELETE; chapter_mode=CHAP_USE; break; case ARJ_CMD_EXEC: cnv_cmd=ARJ_CMD_EXTR_NP; execute_cmd=1; if(extraction_filename[0]=='\0') { extraction_filename=fixed_arjtemp; extract_to_file=1; } break; case ARJ_CMD_SAMPLE: cnv_cmd=ARJ_CMD_PRINT; print_with_more=1; break; case ARJ_CMD_PRINT: if(!prompt_for_more) break; print_with_more=1; break; case ARJ_CMD_V_LIST: cnv_cmd=ARJ_CMD_LIST; std_list_cmd=1; break; case ARJ_CMD_EXTRACT: cnv_cmd=ARJ_CMD_EXTR_NP; subdir_extraction=1; break; } if(cnv_cmd==ARJ_CMD_EXTR_NP&&delete_processed&&!execute_cmd) { cnv_cmd=ARJ_CMD_DELETE; delete_processed=DP_EXTRACT; } add_cmd=msg_strchr(M_ADD_COMMANDS, (char)cnv_cmd)!=NULL; if(file_args<0) { if(!append_curtime) error(M_NO_FILE_GIVEN); else { archive_name[0]='\0'; file_args++; finish_archive_name(archive_name); } } if(cnv_cmd==ARJ_CMD_DELETE&&file_args==0&&delete_processed!=DP_EXTRACT) error(M_NO_DELETE_ARG); if(cnv_cmd!=ARJ_CMD_COMMENT&&msg_strchr(M_MODIFY_COMMANDS, (char)cnv_cmd)!=NULL&¤t_chapter!=0&¤t_chapter<=CHAPTERS_MAX) error(M_BAD_SYNTAX); if(add_cmd&&multivolume_option) { if(volume_limit0) error(M_BAD_SYNTAX); if(win32_platform&&lfn_mode==LFN_DUAL) error(M_BAD_SYNTAX); if(chapter_mode==CHAP_REMOVE&&cnv_cmd!=ARJ_CMD_COPY) error(M_BAD_SYNTAX); if(test_archive_crc>=TC_CRC_AND_CONTENTS&&exclude_paths) error(M_JT_UNUSABLE, "-e/-e1"); if(test_archive_crc>=TC_CRC_AND_CONTENTS&&fix_longnames) error(M_JT_UNUSABLE, "-2l"); if(arcmail_sw&&serialize_exts) error(M_JO_UNUSABLE, "-2a"); #if TARGET==DOS if(priority.class!=0) error(M_OS_DEPENDENT, "-2p"); #endif if(ea_supported&&restart_at_filename) error(M_CANT_RESTART_W_EAS); if(assign_work_directory&&work_directory[0]=='\0') error(M_MISSING_FILENAME_ARG, "-w"); if(extract_to_file&&extraction_filename[0]=='\0') error(M_MISSING_FILENAME_ARG, "-jw"); if(create_list_file&&list_file[0]=='\0') error(M_MISSING_FILENAME_ARG, "-l"); if(create_index&&index_name[0]=='\0') error(M_MISSING_FILENAME_ARG, "-ji"); if(restart_at_filename&&filename_to_restart[0]=='\0'&&index_name[0]=='\0') error(M_MISSING_FILENAME_ARG, "-jn"); if((cnv_cmd==ARJ_CMD_EXTR_NP||cnv_cmd==ARJ_CMD_EXTRACT)&&use_comment&&archive_cmt_name[0]=='\0') error(M_MISSING_FILENAME_ARG, "-z"); if(chk_arj_version) { tmp_swptr=swptr_hv; if(tmp_swptr[0]=='\0'||tmp_swptr[0]=='R'||tmp_swptr[0]=='r') { if(!is_registered) exit(ARJ_ERL_WARNING); else if(tmp_swptr[0]!='\0') tmp_swptr++; } if(tmp_swptr[0]!='\0') { msg_strcpy(strcpy_buf, M_VERSION); vptr=strcpy_buf; if(vptr[0]offset&&archive_ext_list[offset]!='\0'&&archive_ext_list[offset]!='.'); while(c_offset=params_max) error(M_ARGTABLE_OVERFLOW); f_arg_array[file_args++]=token; } } else f_arg_array[file_args++]=token; } } } return(cmd); } /* Ctrl+C handler */ static void ctrlc_handler(SIGHDLPARAMS) { ctrlc_processing=1; /* Check if we are able to honor the request. If we aren't, raise the signal again and make a speedy getaway. */ if(!ctrlc_not_busy) raise(SIGINT); else { error_occured=1; /* ARJ needs termination */ signal(SIGINT, NULL); /* Restore default Ctrl+C handler */ msg_cprintf(H_SIG, M_BREAK_SIGNALED); exit(ARJ_ERL_BREAK); } } /* Termination handler */ #ifndef NO_TERM_HDL static void term_handler(SIGHDLPARAMS) { error_occured=1; /* ARJ needs termination */ signal(SIGTERM, NULL); msg_cprintf(H_SIG, M_SIGTERM); exit(ARJ_ERL_BREAK); } #endif /* Executes an OS command with checking for break */ void exec_cmd(char *cmd) { flush_kbd(); ctrlc_not_busy=0; /* Say that we are busy */ system_cmd(cmd); ctrlc_not_busy=1; if(ctrlc_processing) /* If processing was delayed... */ #if COMPILER==BCC ctrlc_handler(); #else ctrlc_handler(0); #endif } /* atexit routine - closes all files and frees memory */ static void final_cleanup(void) { short pad; static int double_shutdown=0; file_close(idxstream); file_close(aistream); file_close(atstream); idxstream=NULL; aistream=NULL; atstream=NULL; if(aostream!=NULL) { if(last_hdr_offset>0L) { fseek(aostream, last_hdr_offset+2L, SEEK_SET); pad=0; fwrite(&pad, 1, 2, aostream); } file_close(aostream); aostream=NULL; } #if TARGET!=UNIX||defined(HAVE_FCLOSEALL) fcloseall(); #endif if(tmp_archive_name!=NULL) { if(tmp_archive_removed) { rename_with_check(tmp_archive_name, archive_name); tmp_archive_name[0]='\0'; } if(!keep_tmp_archive&&tmp_archive_name[0]!='\0'&&(!tmp_archive_used||!tmp_archive_exists)) file_unlink(tmp_archive_name); if(tmp_archive_used==1) file_unlink(archive_name); free(tmp_archive_name); tmp_archive_name=NULL; } if(tmp_tmp_filename!=NULL) { if(!keep_tmp_file&&tmp_tmp_filename[0]!='\0') file_unlink(tmp_tmp_filename); free(tmp_tmp_filename); tmp_tmp_filename=NULL; } if(debug_enabled&&strchr(debug_opt, 'v')!=NULL) { msg_cprintf(0, M_EXITING_PROGRAM); if(double_shutdown) msg_cprintf(0, M_HERE_TWICE); if(verify_heap()) msg_cprintf(H_ERR, M_BAD_HEAP); } if(double_shutdown) return; double_shutdown=1; flist_cleanup(&flist_main); flist_cleanup(&flist_order); flist_cleanup(&flist_exclusion); flist_cleanup(&flist_archive); #if defined(HAVE_EAS) flist_cleanup(&flist_ea); flist_cleanup(&flist_xea); #endif #if TARGET==UNIX if(l_entries.list!=NULL) farfree(l_entries.list); #endif if(quiet_mode) freopen(dev_con, m_w, stdout); if(ferror(stdout)) msg_fprintf(stderr, M_DISK_FULL); if(debug_enabled&&strchr(debug_opt, 't')!=NULL) { ticks=get_ticks()-ticks; msg_cprintf(H_HL|H_NFMT, M_FINAL_TIMING, ticks); } if(!store_by_suffix) free(archive_suffixes); cfa_shutdown(); if(arj_env_str!=NULL) free_env_str(arj_env_str); if(eh!=NULL) { eh_release(eh); eh=NULL; } if(ntext!=NULL) /* ASR fix for 2.76.05 */ free(ntext); free_fmsg(arj_env_name); free(header); free(archive_name); free(misc_buf); free(strcpy_buf); free(exe_name); farfree(order); free(f_arg_array); #ifdef COLOR_OUTPUT scrn_reset(); #endif } /* Waits and then prints an error message */ static void wait_error(FMSG *errmsg) { arj_delay(5); error(errmsg); } /* Checks if the ARJ beta has expired */ static void arj_exec_validation() { #if !defined(COMMERCIAL)&&EXPIRABLE==1 struct timestamp cur_time, expiry_time; #endif limit=0; #if !defined(COMMERCIAL)&&EXPIRABLE==1 /* See top of this module for definitions */ cur_time_stamp(&cur_time); make_timestamp(&expiry_time, EXPIRY_YR, EXPIRY_MO, EXPIRY_DY, EXPIRY_H, EXPIRY_M, EXPIRY_S); if(ts_cmp(&cur_time, &expiry_time)>=0) limit=100; #endif /* The EXE validation must occur here. Skipped for speed-up */ } /* This is not an optimization -- ASR fix for High C -- 05/04/2001 */ #if COMPILER==HIGHC&&!defined(DEBUG) #pragma on(Optimize_for_space) #endif /* Main routine */ int main(int argc, char *argv[]) { int cmd; int is_add_cmd; unsigned long start_time, proc_time; FILE_COUNT i; int j; int cur_arg; FILE *stream; char *tmp_ptr, *tptr, *endptr; int got_str=0; char *name; int flist_type; FILE_COUNT numfiles; int expand_wildcards; int entry; int sort_f; FILE_COUNT count; FILE_COUNT cur_file; int ansi_cpf; FILE *tmp_stdout; FILE_COUNT default_capacity=EXT_FILELIST_CAPACITY; #if TARGET==WIN32 win32_platform=1; #else win32_platform=0; #endif #ifdef COLOR_OUTPUT no_colors=redirected=!is_tty(stdout); #endif errorlevel=0; ignore_errors=0; ansi_cpf=0; in_key=1; params_max=argc+PARAMS_MAX; order=NULL; f_arg_array=NULL; #ifdef USE_TZSET tzset(); #endif ticks=get_ticks(); detect_lfns(); detect_eas(); ticks=get_ticks(); cmd=preprocess_cmdline(argc, argv); set_file_apis(use_ansi_cp); /* ARJ32 only (from v 2.72) */ #ifndef NO_FATAL_ERROR_HDL install_smart_handler(); #endif /* Perform STDOUT setup -- ASR fix for IBM C Set++, VisualAge C++ and GLIBC builds */ #ifdef STDOUT_SETBUF_FIX setbuf(stdout, NULL); setbuf(stderr, NULL); #endif new_stderr=NULL; if(quiet_mode) new_stderr=fopen(dev_null, m_w); if(quiet_mode==ARJ_QUIET||quiet_mode==ARJ_SILENT) new_stdout=new_stderr; /* Test for low-memory DOS situtations */ #if TARGET==DOS free(malloc_msg(10000)); farfree(farmalloc_msg(9000)); #endif /* Locate the executables. On UNIX systems, before assuming /usr/bin/arj, we try to guess if ARGV contains a somewhat qualified filename. This is a special hack for PACKAGER. */ exe_name=(char *)malloc_msg(CCHMAXPATH); #ifndef SKIP_GET_EXE_NAME get_exe_name(exe_name); #else get_exe_name(exe_name, argv[0]); #endif case_path(arj_env_name); init_crc(); start_time=get_ticks(); ctrlc_processing=0; tmp_archive_removed=0; tmp_archive_exists=0; is_registered=1; #ifdef COMMERCIAL is_commercial=1; #else is_commercial=0; #endif archive_suffixes=NULL; header=(char *)malloc_msg(HEADERSIZE_MAX); archive_name=(char *)malloc_msg(FILENAME_MAX); archive_name[0]='\0'; /* ASR fix for ARJ -i in ARJ 2.73 */ misc_buf=(char *)malloc_msg(FILENAME_MAX+INPUT_LENGTH); tmp_tmp_filename=(char *)malloc_msg(FILENAME_MAX); strcpy_buf=(char *)malloc_msg(200); order=(FILE_COUNT FAR *)farmalloc_msg(params_max*sizeof(FILE_COUNT)); f_arg_array=(char **)malloc_msg(params_max*sizeof(char *)); limit=20; parse_reg_key(); arj_exec_validation(); set_file_apis(use_ansi_cp); init(); flist_init(&flist_main, 0, FL_STANDARD); flist_init(&flist_exclusion, 0, FL_STANDARD); flist_init(&flist_order, 0, FL_STANDARD); flist_init(&flist_archive, 0, FL_STANDARD); #if defined(HAVE_EAS) flist_init(&flist_ea, 0, FL_STANDARD); flist_init(&flist_xea, 0, FL_STANDARD); #endif if(signal(SIGINT, ctrlc_handler)==SIG_ERR) error(M_SIGNAL_FAILED); #ifndef NO_TERM_HDL if(signal(SIGTERM, term_handler)==SIG_ERR) error(M_SIGNAL_FAILED); #endif #ifdef HAVE_BREAK_HANDLER if(signal(SIGBREAK, term_handler)==SIG_ERR) error(M_SIGNAL_FAILED); #endif atexit(final_cleanup); for(i=0; i<10; i++) is_registered=reg_validation(regdata+REG_KEY1_SHIFT, regdata+REG_KEY2_SHIFT, regdata+REG_NAME_SHIFT, regdata+REG_HDR_SHIFT); check_fmsg(CHKMSG_SKIP); if((tmp_stdout=new_stdout)==new_stderr&&!is_registered) new_stdout=stderr; msg_strcpy(strcpy_buf, M_VERSION); msg_cprintf(0, M_ARJ_BANNER, M_ARJ_BINDING, strcpy_buf, build_date); if(!is_registered&&!msg_strcmp((FMSG *)(regdata+REG_KEY2_SHIFT), M_REG_TYPE)) msg_cprintf(0, M_REGISTERED_TO, regdata+REG_NAME_SHIFT); else msg_cprintf(0, (FMSG *)lf); new_stdout=tmp_stdout; proc_time=get_ticks(); flist_init(&flist_exclusion, FCLIM_EXCLUSION, FL_STANDARD); #if defined(HAVE_EAS) flist_init(&flist_ea, FCLIM_EA, FL_STANDARD); flist_init(&flist_xea, FCLIM_EA, FL_STANDARD); #endif switch_char='\0'; if(!disable_arj_sw) { if((arj_env_str=malloc_env_str(arj_env_name))!=NULL) parse_arj_sw(cmd, arj_env_str, header); else { #ifndef SKIP_GET_EXE_NAME split_name(exe_name, archive_name, NULL); msg_strcat(archive_name, M_ARJ_CFG); if(file_exists(archive_name)) parse_arj_sw(cmd, archive_name, header); #else msg_strcpy(misc_buf, M_ARJ_CFG); sprintf(archive_name, "%s/.%s", getenv("HOME"), misc_buf); if(!file_exists(archive_name)) sprintf(archive_name, "/etc/%s", misc_buf); if(file_exists(archive_name)) parse_arj_sw(cmd, archive_name, header); #endif archive_name[0]='\0'; /* ASR fix */ } } if(install_errhdl) ignore_errors=1; if(force_lfn) lfn_supported=LFN_SUPPORTED; if(use_ansi_cp==ANSICP_CONVERT) ansi_cpf=1; set_file_apis(use_ansi_cp); #ifndef NO_FATAL_ERROR_HDL if(win32_platform) install_smart_handler(); #endif if(lfn_mode==LFN_NONE||lfn_mode==LFN_IGNORE) lfn_supported=LFN_NOT_SUPPORTED; if(lfn_supported!=LFN_NOT_SUPPORTED&&lfn_mode==LFN_DUAL) lfn_supported=LFN_COMP; is_registered=!is_registered; if(!is_registered&®data[REG_NAME_SHIFT]!='\0') wait_error(M_CRC_ERROR); cmd=0; if(rsp_name[0]=='\0') { for(cur_arg=1; cur_arg0) { /* ASR fix: check for overrun -- 25/08/2001 */ while(*tptr=='\0'&&((endptr-tptr)>0)) tptr++; if((endptr-tptr)>0) { cmd=parse_cmdline(tptr, cmd); while(*tptr!='\0'&&((endptr-tptr)>0)) tptr++; } } } fclose(stream); if(!got_str) error(M_CANTREAD); } if(install_errhdl) ignore_errors=1; if(force_lfn) lfn_supported=LFN_SUPPORTED; set_file_apis(use_ansi_cp); #ifndef NO_FATAL_ERROR_HDL if(win32_platform) install_smart_handler(); #endif if(file_args>=0) { case_path(archive_name); finish_archive_name(archive_name); } for(j=0; j0) set_priority(&priority); #endif if(run_cmd_at_start&&start_cmd[0]!='\0') exec_cmd(start_cmd); if(!exclude_files) { flist_cleanup(&flist_exclusion); flist_init(&flist_exclusion, FCLIM_EXCLUSION, FL_STANDARD); } flist_add_files(&flist_exclusion, NULL, arjtemp_wildcard, 0, 0, 0, NULL); if(filter_same_or_newer||filter_older) convert_time_limits(); if(cmd==ARJ_CMD_WHERE||extm_mode) search_setup(); else if(execute_cmd) get_exec_cmd(); if(garble_enabled) { if(!strcmp(garble_password, "?")) { tptr=(char *)malloc_msg(INPUT_LENGTH+1); msg_cprintf(0, M_ENTER_PWD); read_line_noecho(tptr, INPUT_LENGTH); garble_password=malloc_str(tptr); if(is_add_cmd||cmd=='G') { msg_cprintf(0, M_VERIFY_PWD); read_line_noecho(tptr, INPUT_LENGTH); if(strcmp(tptr, garble_password)) error(M_PWD_MISMATCH); } free(tptr); } } if(garble_password[0]=='\0'&&(cmd==ARJ_CMD_GARBLE||garble_enabled)) error(M_NO_PWD_OPTION); limit=20; if(append_curtime) append_curtime_proc(); if(is_add_cmd&&file_exists(archive_name)) { tmp_archive_exists=1; if(tmp_archive_name==NULL) { tmp_archive_used=-1; tmp_archive_name=malloc_msg(FILENAME_MAX); tmp_archive_name[0]='\0'; tmp_archive_used=0; } split_name(archive_name, tmp_archive_name, NULL); strcat(tmp_archive_name, arjtemp_spec); find_tmp_filename(tmp_archive_name); if(!stricmp(archive_name, tmp_archive_name)) error(M_CANTRENAME, archive_name, tmp_archive_name); file_unlink(tmp_archive_name); tmp_archive_removed=1; rename_with_check(archive_name, tmp_archive_name); } set_file_apis(1); arj_exec_validation(); set_file_apis(use_ansi_cp); #if TARGET!=UNIX if(cmd!=ARJ_CMD_ORDER) flist_type=find_dupl_drivespecs(f_arg_array, file_args)?FL_HASH:FL_STANDARD; else flist_type=FL_STANDARD; #else flist_type=FL_STANDARD; #endif numfiles=default_capacity; if((tptr=strchr(debug_opt, 'i'))!=NULL) { tptr++; numfiles=(FILE_COUNT)strtol(tptr, &tptr, 10); } if(strchr(debug_opt, 'q')!=NULL) flist_type=FL_STANDARD; flist_init(&flist_main, numfiles, (char)flist_type); flist_init(&flist_order, FILELIST_CAPACITY, (char)FL_STANDARD); if(is_add_cmd) { arch_wildcard_allowed=1; expand_wildcards=1; } else expand_wildcards=0; name=malloc_msg(FILENAME_MAX); for(j=limit; j0) error(M_FOUND_N_ERRORS, errors); return(errorlevel); } arj-3.10.22/arj.h 666 0 0 3560 7653041620 7561 0ustar /* * $Id: arj.h,v 1.4 2003/04/27 20:54:41 andrew_belov Exp $ * --------------------------------------------------------------------------- * This file must be included FIRST in all modules. It defines the system-wide * equates and types, as well as it does some compiler-specific job. * */ #ifndef ARJ_INCLUDED #define ARJ_INCLUDED #include "bindings.h" #include "environ.h" #include "defines.h" #include "date_sig.h" #include "arjtypes.h" #if SFX_LEVEL!=ARJSFXJR #include "filemode.h" #include "file_reg.h" #include "encode.h" #include "decode.h" #include "enc_gwy.h" #include "fardata.h" #include "arj_user.h" #include "ext_hdr.h" #include "arj_arcv.h" #include "arj_file.h" #endif #include "crc32.h" #if SFX_LEVEL!=ARJSFXJR #include "exe_sear.h" #include "chk_fmsg.h" #include "filelist.h" #include "arj_proc.h" #include "arjsec_h.h" #include "arjsec_l.h" #include "debug.h" #include "misc.h" #include "ntstream.h" #include "ea_mgr.h" #include "uxspec.h" #include "garble.h" #endif #if SFX_LEVEL>=ARJSFXV||defined(ARJDISP)||defined(REARJ) #include "scrnio.h" #endif #if SFX_LEVEL!=ARJSFXJR #include "ansi.h" #include "recovery.h" #include "crc16tab.h" #include "gost.h" #include "gost_t.h" #include "gost40.h" #endif #if SFX_LEVEL==ARJ #include #elif SFX_LEVEL==ARJSFXV #include #elif SFX_LEVEL==ARJSFX #include #elif SFX_LEVEL==ARJSFXJR #include #elif defined(REARJ) #include #elif defined(REGISTER) #include #elif defined(ARJDISP) #include #elif defined(SFXSTUB) #include #endif #if SFX_LEVEL<=ARJSFXV&&SFX_LEVEL>=ARJSFX #include "arjsfx.h" #endif #if SFX_LEVEL>=ARJSFX||defined(REARJ)||defined(REGISTER) #include "externs.h" #endif #ifdef REARJ #include "rearj.h" #endif #if SFX_LEVEL>=ARJ /* Prototypes */ void create_excl_list(char *names); void exec_cmd(char *cmd); #endif #endif arj-3.10.22/arjcrypt.c 666 0 0 23615 7675307434 10675 0ustar /* * $Id: arjcrypt.c,v 1.5 2003/06/22 11:12:28 andrew_belov Exp $ * --------------------------------------------------------------------------- * This file is a small module that performs stand-alone strong GOST 28147-89 * encryption. * */ #include "arj.h" #if TARGET==DOS #include #include "gost_asm.h" #include "det_x86.h" #elif TARGET==OS2 #endif #include "msg_crp.h" #include "arjcrypt.h" DEBUGHDR(__FILE__) /* Debug information block */ /* OS/2 DLL variable */ #if TARGET==OS2&&COMPILER==MSC int _acrtused=0; #endif /* To identify ourselves, we must have a signature: */ static char id[]="NortheastXXXXXXXX"; /* Currently unused */ #if TARGET==DOS static char signature[]=ARJCRYPT_SIG; static void entry(); static unsigned short entry_point=(unsigned short)&entry; static int use_32=0; /* Allow 32-bit instructions */ #endif /* Local data */ static unsigned long default_key[8]={3, 10, 6, 12, 5, 9, 0, 7}; static int last_bytes=0; /* Number of significant bytes in the last block */ static unsigned long back_code[2]={0L}; /* Recently encrypted data */ static unsigned long ext_code[2]={0L}; /* The code used by gost_cipher() */ static unsigned long gost_key[8]={0L}; /* Encryption key */ static unsigned long gost64_key[16]={0L};/* ARJCRYPT v 2.0 encryption key */ static int flags=0; /* Encryption type */ static int key64_len=0; /* Length of ARJCRYPT v 2 intial encryption password */ #ifdef WORDS_BIGENDIAN static const int ord[8]={3,2,1,0,7,6,5,4}; #define bf(x) ord[x] static void adjust_byte_order(char *p,const int len) { int l4; for (l4=len>>2;l4;l4--) { char tmp,*p1,*p2; p1 = p +1; p2 = p1+1; tmp = *p2; *p2++ = *p1; *p1-- = tmp; tmp = *p1; *p1 = *p2; *p2 = tmp; p = p2+1; } } static void codec(void (*fct)(unsigned char FAR *, unsigned char FAR *, int), unsigned char FAR *buf, int len) { if (!(len&7) && !last_bytes) adjust_byte_order(buf,len); (*fct)(buf,buf,len); if (!(len&7) && !last_bytes) adjust_byte_order(buf,len); } #else #define bf(x) (x) #define codec(fct,buf,len) (fct(buf,buf,len)) #endif /* GOST encoding/decoding loop */ static void gost_loop(unsigned long *src, unsigned long *dest, unsigned long *key) { unsigned long mod1, mod2; int i; #if TARGET==DOS if(use_32) { gost_loop_32(src, dest, key); return; } #endif mod1=src[0]; mod2=src[1]; for(i=0; i<3; i++) { mod2^=gost_term(mod1+key[0]); mod1^=gost_term(mod2+key[1]); mod2^=gost_term(mod1+key[2]); mod1^=gost_term(mod2+key[3]); mod2^=gost_term(mod1+key[4]); mod1^=gost_term(mod2+key[5]); mod2^=gost_term(mod1+key[6]); mod1^=gost_term(mod2+key[7]); } mod2^=gost_term(mod1+key[7]); mod1^=gost_term(mod2+key[6]); mod2^=gost_term(mod1+key[5]); mod1^=gost_term(mod2+key[4]); mod2^=gost_term(mod1+key[3]); mod1^=gost_term(mod2+key[2]); mod2^=gost_term(mod1+key[1]); mod1^=gost_term(mod2+key[0]); dest[0]=mod2; dest[1]=mod1; } /* So-called "gamma"-ciphering that does both encoding and decoding */ static void gost_cipher_proc(unsigned char FAR *src, unsigned char FAR *dest, int len) { unsigned long FAR *tmp_sptr; /* Pointer to source area */ unsigned long FAR *tmp_dptr; /* Pointer to target area */ int remainder; /* Number of bytes in the last block */ remainder=len%8; if(remainder==0&&last_bytes==0) { tmp_sptr=(unsigned long *)src; tmp_dptr=(unsigned long *)dest; len>>=3; while(len--!=0) { back_code[0]+=GOST_I_PAT_LO; if(back_code[0]>=3; while(len--!=0) { gost_loop(back_code, back_code, gost_key); back_code[0]=tmp_dptr[0]=tmp_sptr[0]^back_code[0]; back_code[1]=tmp_dptr[1]=tmp_sptr[1]^back_code[1]; tmp_sptr+=2; tmp_dptr+=2; } } else { bc_offset=(unsigned char *)back_code; while(len--!=0) { if(last_bytes==0) gost_loop(back_code, back_code, gost_key); bc_offset[bf(last_bytes)]=*(dest++)=*(src++)^bc_offset[bf(last_bytes)]; last_bytes++; last_bytes%=8; } } } /* Decoding sequence */ static void gost_decode(unsigned char FAR *src, unsigned char FAR *dest, int len) { unsigned long FAR *tmp_sptr; /* Pointer to source area */ unsigned long FAR *tmp_dptr; /* Pointer to target area */ int remainder; /* Number of bytes in the last block */ unsigned long d_data; /* Decoded data collector */ unsigned char *bc_offset; /* Offset within back_code */ unsigned char dec_sym; /* Currently processed symbol */ remainder=len%8; if(remainder==0&&last_bytes==0) { tmp_sptr=(unsigned long FAR *)src; tmp_dptr=(unsigned long FAR *)dest; len>>=3; while(len--!=0) { gost_loop(back_code, back_code, gost_key); d_data=tmp_sptr[0]; tmp_dptr[0]=d_data^back_code[0]; back_code[0]=d_data; d_data=tmp_sptr[1]; tmp_dptr[1]=d_data^back_code[1]; back_code[1]=d_data; tmp_sptr+=2; tmp_dptr+=2; } } else { bc_offset=(unsigned char *)back_code; while(len--!=0) { if(last_bytes==0) gost_loop(back_code, back_code, gost_key); dec_sym=*(src++); *(dest++)=dec_sym^bc_offset[bf(last_bytes)]; bc_offset[bf(last_bytes++)]=dec_sym; last_bytes%=8; } } } /* Copies characters of a string, appending a null byte to the result */ static int far_strncpy(char FAR *dest, char FAR *src, int limit) { int k; char *d; d=dest; for(k=0; ksizeof(gost_key)) { for(i=0; i<8; i++) gost_key[i]=gost64_key[i+8]; for(i=0; imode) { case ARJCRYPT_INIT: #if TARGET==DOS use_32=detect_x86()==0x386; #endif memset(gost_key, 0, sizeof(gost_key)); far_strncpy((char FAR *)gost_key, exblock_ptr->password, sizeof(gost_key)); modifier[0]=exblock_ptr->l_modifier[0]; modifier[1]=exblock_ptr->l_modifier[1]; flags=ENCRYPT_GOST256; last_bytes=0; calc_gost_pattern(); gost_crtkey(modifier); gost_loop(modifier, back_code, gost_key); exblock_ptr->rc=ARJCRYPT_RC_INITIALIZED; break; case ARJCRYPT_V2_INIT: #if TARGET==DOS use_32=detect_x86()==0x386; #endif memset(gost_key, 0, sizeof(gost_key)); far_strncpy((char FAR *)gost_key, exblock_ptr->password, sizeof(gost_key)); memset(gost64_key, 0, sizeof(gost64_key)); key64_len=far_strncpy((char FAR *)gost64_key, exblock_ptr->password, sizeof(gost64_key)); modifier[0]=exblock_ptr->l_modifier[0]; modifier[1]=exblock_ptr->l_modifier[1]; flags=exblock_ptr->flags; last_bytes=0; calc_gost_pattern(); gost_crtkey(modifier); gost_loop(modifier, back_code, gost_key); exblock_ptr->rc=(flags==ENCRYPT_GOST256||key64_len<=32)?ARJCRYPT_RC_INITIALIZED:ARJCRYPT_RC_INIT_V2; break; case ARJCRYPT_ENCODE: codec(gost_encode, exblock_ptr->data, exblock_ptr->len); exblock_ptr->rc=ARJCRYPT_RC_OK; break; case ARJCRYPT_DECODE: codec(gost_decode, exblock_ptr->data, exblock_ptr->len); exblock_ptr->rc=ARJCRYPT_RC_OK; break; case ARJCRYPT_CIPHER: case ARJCRYPT_DECIPHER: codec(gost_cipher_proc, exblock_ptr->data, exblock_ptr->len); exblock_ptr->rc=ARJCRYPT_RC_OK; break; default: exblock_ptr->rc=ARJCRYPT_RC_ERROR; break; } #if TARGET==DOS exblock_ptr->ret_addr(); #endif } arj-3.10.22/arjcrypt.h 666 0 0 2447 7450456510 10651 0ustar /* * $Id: arjcrypt.h,v 1.1.1.1 2002/03/28 00:01:13 andrew_belov Exp $ * --------------------------------------------------------------------------- * All defines regarding ARJCRYPT operations are stored in this file * */ #ifndef ARJCRYPT_INCLUDED #define ARJCRYPT_INCLUDED /* Signature for identifying ARJCRYPT modules */ #define ARJCRYPT_SIG "Signature to search" /* ARJCRYPT operation modes */ #define ARJCRYPT_V2_INIT 0 #define ARJCRYPT_INIT 1 #define ARJCRYPT_ENCODE 2 #define ARJCRYPT_DECODE 3 #define ARJCRYPT_CIPHER 4 #define ARJCRYPT_DECIPHER 5 /* ARJCRYPT return codes */ #define ARJCRYPT_RC_OK 0 #define ARJCRYPT_RC_INITIALIZED 2 #define ARJCRYPT_RC_INIT_V2 3 #define ARJCRYPT_RC_ERROR -1 /* Inquiry types */ #define ARJCRYPT_INQ_INIT 1 /* Initialization request */ #define ARJCRYPT_INQ_RSP 2 /* Initialization response */ #pragma pack(1) /* Structure of exchange block */ struct arjcrypt_exblock { int mode; int len; char FAR *data; char FAR *password; unsigned long l_modifier[2]; int rc; int (FAR *ret_addr)(); int inq_type; /* ARJCRYPT v 2.0+ */ int flags; /* ARJCRYPT v 2.0+ */ }; #pragma pack() #endif arj-3.10.22/arjdata.c 666 0 0 15501 10040214256 10433 0ustar /* * $Id: arjdata.c,v 1.6 2004/04/17 11:44:46 andrew_belov Exp $ * --------------------------------------------------------------------------- * User-modifyable resource information. It must be kept binding-independent. * */ #include #include "arj.h" /* Tags */ #define TAG_CHAR '@' #define TAG_SPECIAL_BEGIN '{' #define TAG_SPECIAL_END '}' /* Alignments */ #define ALIGN_NONE 0 #define ALIGN_RIGHT 1 #define ALIGN_CENTER 2 /* Resource list hash array. The syntax is: */ static char *resources[][2]= { /* Version */ { "VERSION", #ifdef TILED "2.78" #else "3.10" #endif }, /* ARJ Software, Inc. counterparts (note: always 4 chars, spaces allowed!) */ { "COUNTERPARTS", "2.7x" /* The docs mention DOS */ }, /* Short product description */ { "PRODUCT", "ARJ" #if TARGET==OS2 "/2" #endif #ifndef TILED #if TARGET==OS2 "-" #endif "32" #endif }, /* Platform */ { "PLATFORM", #if TARGET==DOS "DOS" #elif TARGET==OS2 "OS/2" #elif TARGET==WIN32 "Win32" #elif TARGET==UNIX #if defined(linux) "Linux" #elif defined(__FreeBSD__) "FreeBSD" #elif defined(SUNOS) "SunOS" #elif defined(__QNXNTO__) "QNX" #else "UNIX" #endif #endif }, /* Platform -- legal filename format */ { "PLATFORM_FN", #if TARGET==OS2 "OS2", #elif TARGET==UNIX "UNIX", #else "@PLATFORM", #endif }, /* Platform specification for FILE_ID.DIZ (appended to description) */ { "PLATFORM_APPENDIX", #if defined(linux) "/Linux", #elif defined(__FreeBSD__) "/FreeBSD", #elif defined(SUNOS) "/SunOS", #elif defined(__QNXNTO__) "/QNX", #elif TARGET==WIN32 "/Win32", #else "", #endif }, /* Long product description */ { "PRODUCT_LONG", #if TARGET==DOS #if LOCALE==LANG_en "ARJ version @VERSION Open-Source" #elif LOCALE==LANG_ru "ARJ, ¢¥àá¨ï @VERSION" #endif #else #if LOCALE==LANG_en "ARJ for @PLATFORM, version @VERSION" #elif LOCALE==LANG_ru "ARJ ¤«ï @PLATFORM, ¢¥àá¨ï @VERSION" #endif #endif }, /* Registration token */ { "REGTYPE", #ifdef TILED "A2" #else "A3" #endif }, /* Extension of executables (for resources) */ {"EXE_EXT", EXE_EXTENSION}, /* Archive extension */ {"ARJ_EXT", #if TARGET==DOS ".ARJ" /* ASR 27/10/2000 -- for packaging under OS/2 MDOS */ #else ".arj" #endif }, /* Ending marker */ {NULL, NULL} }; /* Returns year (for Q&D copyright formatting) */ static int cur_year() { struct tm *stm; time_t cur_unixtime; cur_unixtime=time(NULL); stm=localtime(&cur_unixtime); return(stm->tm_year+1900); } /* Date formatter */ void date_fmt(char *dest) { #if LOCALE==LANG_en static char *mon[]={"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"}; #elif LOCALE==LANG_fr static char *mon[]={"janvier", "fevrier", "mars", "avril", "mai", "juin", "juillet", "aout", "septembre", "octobre", "novembre", "decembre"}; #elif LOCALE==LANG_de static char *mon[]={"Januar", "Februar", "Maerz", "April", "Mai", "Juni", "Juli", "August", "September", "Oktober", "November", "Dezember"}; #elif LOCALE==LANG_ru static char *mon[]={"ï­¢ àï", "䥢ࠫï", "¬ àâ ", " ¯à¥«ï", "¬ ï", "¨î­ï", "¨î«ï", " ¢£ãáâ ", "ᥭâï¡àï", "®ªâï¡àï", "­®ï¡àï", "¤¥ª ¡àï"}; #endif time_t cur_unixtime; struct tm *stm; #if LOCALE==LANG_en char *enstr; /* -rd, -th, ... */ #endif cur_unixtime=time(NULL); stm=localtime(&cur_unixtime); #if LOCALE==LANG_en if(stm->tm_mday==1||stm->tm_mday==21||stm->tm_mday==31) enstr="st"; else if(stm->tm_mday==2||stm->tm_mday==22) enstr="nd"; else if(stm->tm_mday==3||stm->tm_mday==23) enstr="rd"; else enstr="th"; sprintf(dest, "%s %d%s, %d", mon[stm->tm_mon], stm->tm_mday, enstr, cur_year()); #elif LOCALE==LANG_fr sprintf(dest, "%d %s %d", stm->tm_mday, mon[stm->tm_mon], cur_year()); #elif LOCALE==LANG_de sprintf(dest, "%d %s %d", stm->tm_mday, mon[stm->tm_mon], cur_year()); #elif LOCALE==LANG_ru sprintf(dest, "%d %s %d £.", stm->tm_mday, mon[stm->tm_mon], cur_year()); #endif } /* A safe strcpy() */ static void safe_strcpy(char *dest, char *src) { memmove(dest, src, strlen(src)+1); } /* Context substitution routine */ char *expand_tags(char *str, int limit) { int i, j, sl; int l, rl; /* Tag/substitution length */ int align_lmargin=0, align_rmargin=0; int align_type=ALIGN_NONE; char *p, *et; int shift; char date_stg[128]; int repl_len, repl_j; sl=strlen(str); p=str; while(*p!='\0') { if(*p==TAG_CHAR) { if(*(p+1)==TAG_CHAR) { strcpy(p, p+1); p++; } else if(*(p+1)==TAG_SPECIAL_BEGIN&&(et=strchr(p+3, TAG_SPECIAL_END))!=NULL) { switch(*(p+2)) { case 'd': case 'y': if(*(p+2)=='y') sprintf(date_stg, "%u", cur_year()); else date_fmt(date_stg); rl=strlen(date_stg); if(sl+rl0&&sl+shiftrepl_len) { repl_j=j; repl_len=l; } } } if(repl_len==0) { printf("ARJDATA: unknown tag <%s>\n", p); p++; } else { rl=strlen(resources[repl_j][1]); /* Is it OK to stick the substitution in? */ if((sl+=rl)>=limit) return(NULL); safe_strcpy(p+rl, p+repl_len+1); memcpy(p, resources[repl_j][1], rl); } } } else p++; } return(str); } arj-3.10.22/arjdata.h 666 0 0 510 7450456516 10374 0ustar /* * $Id: arjdata.h,v 1.1.1.1 2002/03/28 00:01:19 andrew_belov Exp $ * --------------------------------------------------------------------------- * Prototypes of the functions located in ARJDATA.C are declared here. * */ #ifndef ARJDATA_INCLUDED #define ARJDATA_INCLUDED char *expand_tags(char *str, int limit); #endif arj-3.10.22/arjdisp.c 666 0 0 11544 7675307434 10471 0ustar /* * $Id: arjdisp.c,v 1.5 2003/06/22 11:12:28 andrew_belov Exp $ * --------------------------------------------------------------------------- * This is a sample graphical interface program. * */ #include "arj.h" #include DEBUGHDR(__FILE__) /* Debug information block */ /* Local variables */ static char *archive_name; static char *filename; static long uncompsize; static long bytes; static long compsize; static char cmd_verb; static char msg_lf[]="\n"; char strform[]="%s"; /* Export it for scrnio.c, too (a byte saved is a byte gained) */ /* Pseudographical controls */ #if TARGET==UNIX static char indo='*'; static char win_top []="/----------------------------------------------------------------------------\\"; static char win_border[]="|"; static char win_bottom[]="\\----------------------------------------------------------------------------/"; static char ind_top []="+--------------------------------------------------+"; static char ind_middle[]="|..................................................|"; static char ind_bottom[]="+--------------------------------------------------+"; #else static char indo='²'; static char win_top []="ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"; static char win_border[]="³"; static char win_bottom[]="ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"; static char ind_top []="ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿"; static char ind_middle[]="³þþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþþ³"; static char ind_bottom[]="ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"; #endif /* Shows the initial screen */ static void show_init_scrn() { int i; char *t; textbackground(1); textcolor(7); clrscr(); gotoxy(2, 2); scrprintf(win_top); for(i=3; i<24; i++) { gotoxy(2, i); scrprintf(win_border); gotoxy(79, i); scrprintf(win_border); } gotoxy(2, 24); scrprintf(win_bottom); gotoxy(10, 5); scrprintf(M_ARJDISP_COPYRIGHT); gotoxy(10, 6); scrprintf(M_ARJDISP_DISTRIBUTION); gotoxy(10, 7); scrprintf(M_ARJDISP_LICENSE); gotoxy(16, 10); scrprintf(M_PROCESSING_ARCHIVE, archive_name); t=strtok(M_ARJDISP_INFO, msg_lf); i=13; while(t!=NULL&&i<=23) { gotoxy(10, i++); scrprintf(strform, t); t=strtok(NULL, msg_lf); } gotoxy(16, 20); scrprintf(M_PRESS_ANY_KEY); uni_getch(); gotoxy(1, 24); } /* Archive processing screen */ static void show_proc_scrn() { int i; static char progress[80]; textbackground(1); textcolor(7); if(bytes==0L) { clrscr(); gotoxy(2, 2); scrprintf(win_top); for(i=3; i<24; i++) { gotoxy(2, i); scrprintf(win_border); gotoxy(79, i); scrprintf(win_border); } gotoxy(2, 24); scrprintf(win_bottom); gotoxy(10, 5); scrprintf(M_ARJDISP_COPYRIGHT); gotoxy(10, 6); scrprintf(M_ARJDISP_DISTRIBUTION); gotoxy(10, 7); scrprintf(M_ARJDISP_LICENSE); gotoxy(16, 10); scrprintf(M_PROCESSING_ARCHIVE, archive_name); gotoxy(16, 12); switch(cmd_verb) { case ARJ_CMD_ADD: case ARJ_CMD_FRESHEN: case ARJ_CMD_MOVE: case ARJ_CMD_UPDATE: scrprintf(M_ADDING_FILE, filename); break; case ARJ_CMD_TEST: scrprintf(M_TESTING_FILE, filename); break; case ARJ_CMD_EXTR_NP: case ARJ_CMD_EXTRACT: scrprintf(M_EXTRACTING_FILE, filename); break; default: scrprintf(M_PROCESSING_FILE, filename); break; } gotoxy(15, 14); scrprintf(ind_top); gotoxy(15, 15); scrprintf(ind_middle); gotoxy(15, 16); scrprintf(ind_bottom); gotoxy(16, 18); scrprintf(M_ARJDISP_CTR_START); } else { i=calc_percentage(bytes, uncompsize)/20; gotoxy(16, 15); memset(progress, indo, i); progress[i]='\0'; scrprintf(progress); gotoxy(16, 18); scrprintf(M_ARJDISP_CTR, calc_percentage(bytes, uncompsize)/10); } gotoxy(16, 15); if(bytes==uncompsize) gotoxy(1, 24); } /* Ending screen */ static void show_ending_scrn() { int i; textbackground(1); textcolor(7); clrscr(); gotoxy(2, 2); scrprintf(win_top); for(i=3; i<24; i++) { gotoxy(2, i); scrprintf(win_border); gotoxy(79, i); scrprintf(win_border); } gotoxy(2, 24); scrprintf(win_bottom); gotoxy(10, 5); scrprintf(M_ARJDISP_COPYRIGHT); gotoxy(10, 6); scrprintf(M_ARJDISP_DISTRIBUTION); gotoxy(10, 7); scrprintf(M_ARJDISP_LICENSE); gotoxy(16, 10); scrprintf(M_FINISHED_PROCESSING, archive_name); gotoxy(1, 24); scrn_reset(); arj_delay(2); } /* Main routine */ int main(int argc, char **argv) { if(argc==2) { if(!strcmp(argv[1], "test")) system("arj t arj*" EXE_EXTENSION " -hep -*"); } if(argc!=7) error(M_ARJDISP_BANNER); archive_name=argv[1]; filename=argv[2]; uncompsize=atol(argv[3]); bytes=atol(argv[4]); compsize=atol(argv[5]); cmd_verb=argv[6][0]; if(cmd_verb=='+') show_init_scrn(); else if(cmd_verb=='-') show_ending_scrn(); else show_proc_scrn(); return(0); } arj-3.10.22/arjsec_h.c 666 0 0 10530 7656253266 10607 0ustar /* * $Id: arjsec_h.c,v 1.5 2003/05/07 18:55:51 andrew_belov Exp $ * --------------------------------------------------------------------------- * The high-level ARJ-security envelope verification routine is contained in * this module. * */ #include "arj.h" DEBUGHDR(__FILE__) /* Debug information block */ /* Returns ARJ-security signature and 0 when successful. */ #if SFX_LEVEL>=ARJSFX int get_arjsec_signature(FILE *stream, long offset, char *signature, int iter) { #if SFX_LEVEL<=ARJSFXV&&!defined(COMMERCIAL) return(0); #else unsigned char tail[ARJSEC_RECORD_SIZE]; unsigned long tmp_tail[8]; unsigned long block[8]; /* CRC accumulation */ unsigned char *dest; int i; /* We need to retain the position when processing ARJSFX archives */ #if SFX_LEVEL<=ARJSFXV unsigned long cur_pos; int c; #endif #if SFX_LEVEL<=ARJSFXV msg_cprintf(0, M_VERIFYING_ARJSEC); cur_pos=ftell(stream); #endif fseek(stream, offset, SEEK_SET); if(fread(tail, 1, sizeof(tail), stream)!=ARJSEC_RECORD_SIZE) return(1); #if SFX_LEVEL>=ARJ fseek(stream, 0L, SEEK_SET); #endif crc32term=CRC_MASK; crc32_for_block(tail, ARJSEC_RECORD_SIZE-4); if(crc32term!=mget_dword(&tail[ARJSEC_RECORD_SIZE-4])) return(1); dest=tail+40; for(i=0; i<76; i++) *(dest++)^=0x80|tail[8+i%32]; memcpy(signature, tail+40, 76); /* The owner's name is already stored at this point, now just make sure that we have the envelope in its original, unmodified form. */ #if SFX_LEVEL>=ARJ dest=tail+40; arjsec_newblock(block+4); while(*dest!='\0') arjsec_crcterm(block+4, *(dest++)); arjsec_invert(block+4); arjsec_read(block, stream, offset); #ifdef WORDS_BIGENDIAN for (i=0;i>2;i++) tmp_tail[i]=mget_dword(tail+8+(i<<2)); #else memcpy(tmp_tail, tail+8, sizeof(tmp_tail)); #endif arjsec_term(block+4, tmp_tail, iter); i=0; if(tmp_tail[0]!=block[0]) i++; if(tmp_tail[1]!=block[1]) i++; if(tmp_tail[2]!=block[2]) i++; if(tmp_tail[3]!=block[3]) i++; arjsec_invert(block); arjsec_xor(block, block+4); if(tmp_tail[4]!=block[0]) i++; if(tmp_tail[5]!=block[1]) i++; if(tmp_tail[6]!=block[2]) i++; if(tmp_tail[7]!=block[3]) i++; #else #ifdef WORDS_BIGENDIAN for (i=0;i>2;i++) tmp_tail[i]=mget_dword(tail+8+(i<<2)); #else memcpy(tmp_tail, tail+8, sizeof(tmp_tail)); #endif rewind(stream); dest=signature; arjsec_newblock(block+4); while(*dest!='\0') arjsec_crcterm(block+4, *(dest++)); arjsec_invert(block+4); arjsec_newblock(block); while(--offset>=0L&&(c=fgetc(stream))!=EOF) arjsec_crcterm(block, (char)c); arjsec_invert(block); arjsec_term(block+4, tmp_tail, iter); i=0; if(memcmp(tmp_tail, block, 16)) i++; arjsec_invert(block); block[0]^=block[4]; block[1]^=block[5]; block[2]^=block[6]; block[3]^=block[7]; if(memcmp(tmp_tail+4, block, 16)) i++; fseek(stream, cur_pos, SEEK_SET); if(i==0) { msg_cprintf(0, M_VALID_ENVELOPE); valid_envelope=1; } #endif return(i); /* Number of errors */ #endif } #endif /* Verifies registration information */ #if SFX_LEVEL>=ARJ||defined(REARJ)||defined(ARJUTIL) int verify_reg_name(char *key1, char *key2, char *name, char *validation) { unsigned long encrypt_pad[8], sec_blk[8]; int i; char c, j; #if defined(WORDS_BIGENDIAN)&&!defined(ARJUTIL) for (i=0;i<8;i++) encrypt_pad[i]=mget_dword(validation+(i<<2)); #else memcpy(encrypt_pad, validation, 32); #endif arjsec_newblock(sec_blk+4); for(i=0; key1[i]!='\0'; i++) arjsec_crcterm(sec_blk+4, (unsigned char)toupper(key1[i])); arjsec_invert(sec_blk+4); arjsec_newblock(sec_blk); for(i=0; key2[i]!='\0'; i++) arjsec_crcterm(sec_blk, (unsigned char)toupper(key2[i])); j='\0'; for(i=0; name[i]!='\0'; i++) { c=toupper(name[i]); if(c!=' '||j!=' ') arjsec_crcterm(sec_blk, c); j=c; } arjsec_invert(sec_blk); arjsec_term(sec_blk+4, encrypt_pad, ARJSEC_ITER); i=0; if(encrypt_pad[0]!=sec_blk[0]) i++; if(encrypt_pad[1]!=sec_blk[1]) i++; if(encrypt_pad[2]!=sec_blk[2]) i++; if(encrypt_pad[3]!=sec_blk[3]) i++; arjsec_invert(sec_blk); if((sec_blk[0]^sec_blk[4])!=encrypt_pad[4]) i++; if((sec_blk[1]^sec_blk[5])!=encrypt_pad[5]) i++; if((sec_blk[2]^sec_blk[6])!=encrypt_pad[6]) i++; if((sec_blk[3]^sec_blk[7])!=encrypt_pad[7]) i++; return(i); } #endif arj-3.10.22/arjsec_h.h 666 0 0 1143 7450456516 10567 0ustar /* * $Id: arjsec_h.h,v 1.1.1.1 2002/03/28 00:01:19 andrew_belov Exp $ * --------------------------------------------------------------------------- * Prototypes of the functions located in ARJSEC_H.C are declared here. * */ #ifndef ARJSEC_H_INCLUDED #define ARJSEC_H_INCLUDED #define ARJSEC_SIG_MAXLEN 80 /* Maximum signature length */ /* Prototypes */ int get_arjsec_signature(FILE *stream, long offset, char *signature, int iter); int verify_reg_name(char *key1, char *key2, char *name, char *validation); void create_reg_key(char *key1, char *key2, char *name, char *validation); #endif arj-3.10.22/arjsec_l.c 666 0 0 21063 10040213576 10613 0ustar /* * $Id: arjsec_l.c,v 1.3 2004/04/17 11:39:42 andrew_belov Exp $ * --------------------------------------------------------------------------- * Various low-level ARJ-security calculation routines are contained in this * module. * */ #include "arj.h" DEBUGHDR(__FILE__) /* Debug information block */ /* This file should not compiled for noncommercial SFXV at all! */ #if defined(COMMERCIAL)||SFX_LEVELARJSFXV /* Seed table */ #if SFX_LEVEL>=ARJ||defined(REARJ) #define SHORT_SEED #endif #ifdef SHORT_SEED static unsigned char arjsec_seeds[]={0xDD, 0x90, 0x53, 0x1D, 0x77, 0x59, 0xEF, 0x3D}; #else static unsigned short arjsec_seeds[]={0xDD0D, 0x4920, 0x5503, 0x614D, 0x6767, 0x6569, 0xDEFF, 0x030D}; #endif #if SFX_LEVEL>=ARJ /* Appends an ARJ-SECURITY envelope to the file, returning a nonzero value if failed. */ int create_envelope(FILE *stream, unsigned long offset, int iter) { #ifndef COMMERCIAL return(1); #else /* Code removed! */ return(1); #endif } #endif /* Basic processing of the given signature. Separate term variables are used so the code will be optimized by placing some of them into GP registers. */ void arjsec_term(unsigned long *block, unsigned long *dest, int iter) { unsigned long block_acc[4]; unsigned long exchange[16]; /* Intermediate buffer */ int i; unsigned long chksum; /* Checksum of block_acc */ unsigned short term0, term1, term2, term3; exchange[0]=dest[0]; exchange[1]=dest[1]; exchange[2]=dest[2]; exchange[3]=dest[3]; exchange[4]=dest[4]; exchange[5]=dest[5]; exchange[6]=dest[6]; exchange[7]=dest[7]; exchange[8]=block[0]; exchange[9]=block[1]; exchange[10]=block[2]; exchange[11]=block[3]; exchange[12]=0x81406215; exchange[13]=0x4B435021; exchange[14]=0x89ABCDEF; exchange[15]=0x08088405; block_acc[0]=block[0]; block_acc[1]=block[1]; block_acc[2]=block[2]; block_acc[3]=block[3]; chksum=block_acc[0]+block_acc[1]+block_acc[2]+block_acc[3]; for(i=0; i>(i%32)); chksum*=(((unsigned long)i<<1)|1); chksum^=block_acc[i%4]>>(unsigned long)((i>>2)%31); chksum^=block_acc[(i>>3)&3]<<((i>>5)%31); chksum=crc32_for_char(chksum, (unsigned char)(i%256)); term0=(unsigned short)(chksum>>0)%8; term1=(unsigned short)(chksum>>5)%8; term2=(unsigned short)(chksum>>11)%16; term3=(unsigned short)(chksum>>17)%16; #ifdef SHORT_SEED term2^=((unsigned short)arjsec_seeds[term0]>>4)%16; #else term2^=((unsigned short)arjsec_seeds[term0]>>8)%16; #endif term3^=arjsec_seeds[term1]%16; if(term1>=8&&term1<=11) term1%=8; if(term1==term2) term2=((term2+1)%16); if(term1==term3) term3=((term3+1)%16); switch(term0) { case 0: exchange[term1]+=exchange[term2]-exchange[term3]; break; case 1: exchange[term1]*=((exchange[term2]^exchange[term3])|1L); break; case 2: exchange[term1]=exchange[term1]<<(term2*2+term3%2)|exchange[term1]>>(32-(term2*2+term3%2)); break; case 3: exchange[term1]=crc32_for_char(exchange[term1], (unsigned char)(exchange[term2]>>0)); exchange[term1]=crc32_for_char(exchange[term1], (unsigned char)(exchange[term2]>>8)); exchange[term1]=crc32_for_char(exchange[term1], (unsigned char)(exchange[term2]>>16)); exchange[term1]=crc32_for_char(exchange[term1], (unsigned char)(exchange[term2]>>24)); exchange[term1]^=exchange[term3]; break; case 4: exchange[term1]=crc32_for_char(exchange[term1], (unsigned char)((exchange[term2]^exchange[term3])>>0)); exchange[term1]=crc32_for_char(exchange[term1], (unsigned char)((exchange[term2]^exchange[term3])>>8)); exchange[term1]=crc32_for_char(exchange[term1], (unsigned char)((exchange[term2]^exchange[term3])>>16)); exchange[term1]=crc32_for_char(exchange[term1], (unsigned char)((exchange[term2]^exchange[term3])>>24)); break; case 5: exchange[term1]+=(unsigned long)((term2<<4)+term3); break; case 6: exchange[term1]-=(unsigned long)((term2<<4)+term3); break; case 7: exchange[term1]*=(exchange[term2]*2L+1L); exchange[term1]+=exchange[(term2^term3)|8L]; exchange[term1]*=(exchange[term3]&exchange[term2])|0x1234567; break; } } dest[0]=exchange[0]; dest[1]=exchange[1]; dest[2]=exchange[2]; dest[3]=exchange[3]; dest[4]=exchange[4]; dest[5]=exchange[5]; dest[6]=exchange[6]; dest[7]=exchange[7]; } #if (SFX_LEVEL>=ARJ)||defined(REARJ)||defined(ARJUTIL) /* Decodes encrypted ARJ-security data */ void arjsec_xor(unsigned long *dest, unsigned long *src) { dest[0]^=src[0]; dest[1]^=src[1]; dest[2]^=src[2]; dest[3]^=src[3]; } #endif /* Prepares a garble block with a special pattern */ void arjsec_newblock(unsigned long *dest) { dest[3]=0xFFFFFFFF; dest[0]=0xDB7E936C; dest[1]=0x5AD6F7EF; dest[2]=0x1951C153; } /* Performs a CRC inversion upon the given encrypted block */ void arjsec_invert(unsigned long *block) { unsigned long tmp_block[3]; int i; tmp_block[2]=block[0]; tmp_block[1]=block[1]; tmp_block[0]=block[2]; for(i=0; i<29; i++) { tmp_block[2]=crc32_for_char(tmp_block[2], (unsigned char)((i<<0)|(tmp_block[1]>>24))); tmp_block[2]=crc32_for_char(tmp_block[2], (unsigned char)((i<<1)|(tmp_block[1]>>16))); tmp_block[2]=crc32_for_char(tmp_block[2], (unsigned char)((i<<2)|(tmp_block[1]>>8))); tmp_block[2]=crc32_for_char(tmp_block[2], (unsigned char)((i<<3)|(tmp_block[1]>>0))); tmp_block[1]=crc32_for_char(tmp_block[1], (unsigned char)((i<<0)|(tmp_block[0]>>24))); tmp_block[1]=crc32_for_char(tmp_block[1], (unsigned char)((i<<1)|(tmp_block[0]>>16))); tmp_block[1]=crc32_for_char(tmp_block[1], (unsigned char)((i<<2)|(tmp_block[0]>>8))); tmp_block[1]=crc32_for_char(tmp_block[1], (unsigned char)((i<<3)|(tmp_block[0]>>0))); tmp_block[0]=crc32_for_char(tmp_block[0], (unsigned char)((i<<0)|((tmp_block[2]+tmp_block[1])>>24))); tmp_block[0]=crc32_for_char(tmp_block[0], (unsigned char)((i<<1)|((tmp_block[2]+tmp_block[1])>>16))); tmp_block[0]=crc32_for_char(tmp_block[0], (unsigned char)((i<<2)|((tmp_block[2]+tmp_block[1])>>8))); tmp_block[0]=crc32_for_char(tmp_block[0], (unsigned char)((i<<3)|((tmp_block[2]+tmp_block[1])>>0))); } block[3]^=0xFFFFFFFF; block[0]=tmp_block[2]; block[1]=tmp_block[1]; block[2]=tmp_block[0]; } /* Performs CRC rotation in the block, based on the character given */ void arjsec_crcterm(unsigned long *block, unsigned char c) { unsigned short hi, lo, t; block[3]=crc32_for_char(block[3], c); block[0]=crc32_for_char(block[0]^block[1], (unsigned char)(c^(unsigned char)block[2])); block[1]*=((block[0]>>16)<<16)+(unsigned long)((unsigned short)block[0]|((unsigned short)c)<<8|1); block[1]++; block[2]+=block[0]; block[2]+=crc32_for_char(block[1], (unsigned char)block[0]); hi=(unsigned short)(block[2]>>16); lo=(unsigned short)block[2]; hi=(hi<<(c%16))+(hi>>(16-c%16)); t=hi&0x8000; hi<<=1; hi+=lo%2; lo=(lo>>1)+t; lo=(lo<<(16-c%16))+(lo>>(c%16)); block[2]=((unsigned long)hi<<16)+(unsigned long)lo; } #if SFX_LEVEL>=ARJ /* Reads an ARJ-security envelope from the file, performing some preliminary analysis. */ void arjsec_read(unsigned long *block, FILE *stream, unsigned long len) { unsigned char tmp_block[512]; unsigned char *tmp_bptr; unsigned char c; int buf_len; int bytes_read; unsigned long term, term2; unsigned short lo, lo2, hi2, hi, t; arjsec_newblock(block); while(len>0) { buf_len=(len>sizeof(tmp_block))?sizeof(tmp_block):len; bytes_read=fread(tmp_block, 1, buf_len, stream); tmp_bptr=tmp_block; if(bytes_read==0) break; len-=(unsigned long)bytes_read; crc32term=block[3]; crc32_for_block(tmp_block, bytes_read); block[3]=crc32term; while((--bytes_read)>=0) { c=*(tmp_bptr++); term=block[0]^block[1]; term=(term>>8)^((unsigned long)get_crc32tab((term%256)^c^(unsigned char)block[2])); block[0]=term; term2=(((term>>16)<<16)+(((unsigned long)c<<8)+1))|(term%65536L); lo=(unsigned short)block[1]; hi=(unsigned short)(block[1]>>16); lo2=(unsigned short)term2; hi2=(unsigned short)(term2>>16); hi*=lo2; hi2=hi2*lo+hi; term=((unsigned long)lo*(unsigned long)lo2)+(((unsigned long)hi2)<<16L)+1L; block[1]=term; block[2]+=block[0]; term=(term>>8)^get_crc32tab((term%256)^(unsigned char)block[0]); term+=block[2]; hi=(unsigned short)(term>>16); lo=(unsigned short)term; hi=(hi<<(c%16))+(hi>>(16-c%16)); t=hi&0x8000; hi<<=1; hi+=lo%2; lo=(lo>>1)+t; lo=(lo<<(16-c%16))+(lo>>(c%16)); block[2]=((unsigned long)hi<<16)+(unsigned long)lo; } } arjsec_invert(block); } #endif #endif /* !COMMERCIAL */ arj-3.10.22/arjsec_l.h 666 0 0 1513 7450456516 10574 0ustar /* * $Id: arjsec_l.h,v 1.1.1.1 2002/03/28 00:01:19 andrew_belov Exp $ * --------------------------------------------------------------------------- * Prototypes of the functions located in ARJSEC_L.C are declared here. * */ #ifndef ARJSEC_L_INCLUDED #define ARJSEC_L_INCLUDED /* Prototypes */ int create_envelope(FILE *stream, unsigned long offset, int iter); void arjsec_term(unsigned long *block, unsigned long *dest, int iter); void arjsec_xor(unsigned long *dest, unsigned long *src); void arjsec_newblock(unsigned long *dest); void arjsec_invert(unsigned long *block); void arjsec_crcterm(unsigned long *block, unsigned char c); void arjsec_read(unsigned long *block, FILE *stream, unsigned long len); void rev_arjsec_term(unsigned long *block, unsigned long *dest, int iter); void arjsec_revert(unsigned long *block); #endif arj-3.10.22/arjsfx.c 666 0 0 26766 10256070052 10344 0ustar /* * $Id: arjsfx.c,v 1.7 2005/06/21 19:53:14 andrew_belov Exp $ * --------------------------------------------------------------------------- * All SFX modules except ARJSFXJR result from this file. * */ #include #include #include "arj.h" #include "arjsfx.h" DEBUGHDR(__FILE__) /* Debug information block */ /* Local variables */ static char cmd_args[SFX_COMMAND_SIZE+1]; #if SFX_LEVEL>=ARJSFXV static unsigned long ticks; #endif static unsigned int limit; #if SFX_LEVEL>=ARJSFXV /* Checks if all the files given to ARJ were successfully processed. */ static void file_arg_cleanup() { int cur_arg; unsigned int cur_file; char *tmp_name; for(cur_arg=0; cur_arg=ARJSFXV if(is_switch(token)) analyze_arg(token); #else if(!skip_switch_processing&&switch_char==0&&strchr(switch_chars, token[0])!=NULL) { switch_char=(int)token[0]; analyze_arg(token); } else if(!skip_switch_processing&&switch_char!=0&&(int)token[0]==switch_char) analyze_arg(token); #endif else { name_len=strlen(token); fn_end=token[name_len-1]; if(file_args==0&&target_dir[0]=='\0'&&strchr(path_separators, fn_end)!=NULL) target_dir=token; else { if(file_args>=params_max) error(M_ARGTABLE_OVERFLOW); f_arg_array[file_args++]=token; } } } /* Issues predefined switch processing, if any */ #if SFX_LEVEL>=ARJSFXV char FAR *preprocess_comment(char FAR *comment) #else char *preprocess_comment(char *comment) #endif { char ctr; char *aptr, *endptr; int quoted=0, slashed; char c; if(comment[0]==')'&&comment[1]==')') { comment+=2; aptr=cmd_args; for(ctr=1; ctr0) { while(*aptr=='\0') aptr++; if((endptr-aptr)>0) { parse_cmdline(aptr); while(*aptr!='\0'&&(endptr-aptr)>0) aptr++; } } if(*comment=='\n') comment++; } return(comment); } /* Ctrl+C handler */ static void ctrlc_handler(SIGHDLPARAMS) { #if SFX_LEVEL>=ARJSFXV ctrlc_processing=1; #endif /* Check if we are able to honor the request. If we aren't, raise the signal again and make a speedy getaway. */ #if SFX_LEVEL>=ARJSFXV if(!ctrlc_not_busy) raise(SIGINT); else { error_occured=1; /* ARJSFX needs termination */ #endif signal(SIGINT, NULL); /* Restore default Ctrl+C handler */ #if SFX_LEVEL>=ARJSFXV msg_cprintf(0, M_BREAK_SIGNALED); exit(ARJ_ERL_BREAK); #else msg_cprintf(0, M_BREAK_SIGNALED); exit(ARJSFX_ERL_ERROR); #endif #if SFX_LEVEL>=ARJSFXV } #endif } /* Termination handler */ #ifndef NO_TERM_HDL static void term_handler(SIGHDLPARAMS) { /* Check if we are able to honor the request. If we aren't, raise the signal again and make a speedy getaway. */ #if SFX_LEVEL>=ARJSFXV error_occured=1; /* ARJSFX needs termination */ #endif signal(SIGTERM, NULL); /* Restore default SIGTERM handler */ #if SFX_LEVEL>=ARJSFXV msg_cprintf(0, M_SIGTERM); exit(ARJ_ERL_BREAK); #else msg_cprintf(0, M_SIGTERM); exit(ARJSFX_ERL_ERROR); #endif } #endif /* atexit routine - closes all files and frees memory */ static void final_cleanup(void) { #if SFX_LEVEL>=ARJSFXV file_close(aistream); aistream=NULL; file_close(atstream); atstream=NULL; #else if(atstream!=NULL) fclose(atstream); #endif #if SFX_LEVEL>=ARJSFXV if(tmp_tmp_filename!=NULL&&!keep_tmp_file&&tmp_tmp_filename[0]!='\0') file_unlink(tmp_tmp_filename); #else if(tmp_tmp_filename[0]!='\0') file_unlink(tmp_tmp_filename); #endif #if SFX_LEVEL>=ARJSFXV&&(TARGET!=UNIX||defined(HAVE_FCLOSEALL)) fcloseall(); #endif if(quiet_mode) freopen(dev_con, m_w, stdout); #if SFX_LEVEL>=ARJSFXV if(ferror(stdout)) msg_fprintf(stderr, M_DISK_FULL); if(debug_enabled&&strchr(debug_opt, 't')!=NULL) { ticks=get_ticks()-ticks; msg_cprintf(0, M_FINAL_TIMING, ticks); } #endif } #if SFX_LEVEL>=ARJSFXV /* Waits and then prints an error message */ static void wait_error(FMSG *errmsg) { arj_delay(5); error(errmsg); } /* Displays the ARJSFX logo */ void show_sfx_logo() { char *tptr, *nptr; if(!logo_shown) { for(nptr=tptr=archive_name; *tptr!='\0'; tptr++) if(strchr(path_separators, *tptr)!=NULL) nptr=tptr+1; msg_cprintf(0, M_ARJSFX_BANNER, M_VERSION, nptr, build_date); msg_cprintf(0, lf); logo_shown=1; } } #endif /* Checks if the SFX has been tampered with (currently stub) */ static void arj_exec_validation() { limit=0; } /* Executes a command */ static void exec_command(char *cmd) { #if SFX_LEVEL>=ARJSFXV char *cur_dir; #else char cur_dir[FILENAME_MAX]; #endif if(target_dir[0]=='\0') system_cmd(cmd); else { #if SFX_LEVEL>=ARJSFXV cur_dir=(char *)malloc_msg(FILENAME_MAX); #endif file_getcwd(cur_dir, FILENAME_MAX); file_chdir(target_dir); system_cmd(cmd); file_chdir(cur_dir); #if SFX_LEVEL>=ARJSFXV free(cur_dir); #endif } } /* Main routine */ int main(int argc, char *argv[]) { int cur_arg; #if SFX_LEVEL>=ARJSFXV int cmd; int is_add_cmd; unsigned long start_time, proc_time; FILE_COUNT i; FILE *stream; char *tmp_ptr, *tptr; int got_str; char *name; int flist_type; FILE_COUNT numfiles; int expand_wildcards; int entry; int sort_f; FILE_COUNT count; FILE_COUNT cur_file; int tmp_reg; #else char *tmp_ptr; #endif #ifdef COLOR_OUTPUT no_colors=redirected=!is_tty(stdout); #endif #if SFX_LEVEL>=ARJSFXV errorlevel=0; ignore_errors=0; new_stdout=stdout; lfn_supported=LFN_NOT_SUPPORTED; ticks=get_ticks(); detect_lfns(); detect_eas(); #ifndef NO_FATAL_ERROR_HDL install_smart_handler(); #endif build_crc32_table(); #else build_crc32_table(); detect_lfns(); file_packing=1; #endif #ifdef USE_TZSET tzset(); #endif #ifdef STDOUT_SETBUF_FIX /* ASR fix for IBM C Set / GLIBC */ setbuf(stdout, NULL); setbuf(stderr, NULL); #endif #if SFX_LEVEL>=ARJSFXV start_time=get_ticks(); flist_init(&flist_main, FCLIM_ARCHIVE, FL_STANDARD); ctrlc_processing=0; header=(char *)malloc_msg(HEADERSIZE_MAX); archive_name=(char *)malloc_msg(FILENAME_MAX); /* Original ARJSFX reserves 200 bytes for misc_buf but, taking into account that LFNs can be large enough, more space is to be reserved. */ misc_buf=(char *)malloc_msg(FILENAME_MAX+INPUT_LENGTH); tmp_tmp_filename=(char *)malloc_msg(FILENAME_MAX); limit=20; init(); if(signal(SIGINT, ctrlc_handler)==SIG_ERR) error(M_SIGNAL_FAILED); #ifndef NO_TERM_HDL if(signal(SIGTERM, term_handler)==SIG_ERR) error(M_SIGNAL_FAILED); #endif atexit(final_cleanup); #else tmp_tmp_filename[0]='\0'; target_dir=nullstr; garble_password=nullstr; extr_cmd_text=nullstr; #endif #ifndef SKIP_GET_EXE_NAME get_exe_name(archive_name); #else strcpy(archive_name, argv[0]); #endif exe_name=archive_name; #if SFX_LEVEL<=ARJSFX for(tmp_ptr=exe_name; *tmp_ptr!='\0'; tmp_ptr++) if(*tmp_ptr==PATHSEP_DEFAULT) exe_name=tmp_ptr+1; atexit(final_cleanup); signal(SIGINT, ctrlc_handler); #ifndef NO_TERM_HDL signal(SIGTERM, term_handler); #endif #endif check_fmsg(CHKMSG_SKIP); #if SFX_LEVEL>=ARJSFXV skip_switch_processing=0; #else switch_char=0; #endif for(cur_arg=1; cur_arg=ARJSFXV if(install_errhdl) ignore_errors=1; if(quiet_mode) freopen(dev_null, m_w, stdout); #endif if(argc>1) skip_preset_options=1; arj_exec_validation(); if(help_issued) { #if SFX_LEVEL>=ARJSFXV show_sfx_logo(); #else msg_cprintf(0, M_ARJSFX_BANNER, exe_name); #endif check_fmsg(CHKMSG_SFX_HELP); #if SFX_LEVEL>=ARJSFXV exit(ARJ_ERL_SUCCESS); #else exit(ARJSFX_ERL_SUCCESS); #endif } #if SFX_LEVEL>=ARJSFXV if(limit!=0) wait_error(M_CRC_ERROR); limit=20; arj_exec_validation(); proc_time=get_ticks(); check_fmsg(CHKMSG_SKIP); perform_cmd(); #else process_archive(); #endif /* Cleanup for ARJSFXV */ #if SFX_LEVEL>=ARJSFXV file_arg_cleanup(); #endif if(errors>0) error(M_FOUND_N_ERRORS, errors); #if SFX_LEVEL>=ARJSFXV if(errorlevel!=ARJ_ERL_SUCCESS) exit(errorlevel); #endif #if SFX_LEVEL>=ARJSFXV if(extr_cmd_text[0]!='\0') #else if(execute_extr_cmd&&extr_cmd_text[0]!='\0') #endif { if(licensed_sfx) { msg_cprintf(0, M_EXECUTING_CMD, extr_cmd_text); arj_delay(2); exec_command(extr_cmd_text); } else { #if SFX_LEVEL>=ARJSFXV msg_sprintf(misc_buf, M_EXTR_CMD_QUERY, extr_cmd_text); if(query_action(REPLY_YES, QUERY_CRITICAL, (FMSG *)misc_buf)) exec_command(extr_cmd_text); #else msg_cprintf(0, M_EXTR_CMD_QUERY, extr_cmd_text); if(query_action()) exec_command(extr_cmd_text); #endif } } #if SFX_LEVEL>=ARJSFXV return(ARJ_ERL_SUCCESS); #else return(ARJSFX_ERL_SUCCESS); #endif } #if SFX_LEVEL>=ARJSFXV /* Converts a filename entered from command-line to standard form */ static void cnv_cmdline_fnm(char *name) { strip_lf(name); alltrim(name); } /* General SFX setup */ void sfx_setup() { int expand_wildcards; char *name; int i; char *tptr, *tmp_ptr; FILE *stream; FILE_COUNT count; if(quiet_mode) freopen(dev_null, m_w, stdout); if(file_args>=0) case_path(archive_name); case_path(target_dir); case_path(extraction_filename); if(extract_to_file&&extraction_filename[0]=='\0') error(M_MISSING_FILENAME_ARG, "-w"); if(garble_enabled&&garble_password[0]=='\0') error(M_NO_PWD_OPTION); if(file_args==0) f_arg_array[file_args++]=all_wildcard; if(ignore_crc_errors) keep_tmp_file=1; if(handle_labels&&label_drive=='\0'&&target_dir[0]!='\0'&&target_dir[1]==':') label_drive=target_dir[0]; if(extract_expath) { cmd_verb=ARJ_CMD_EXTRACT; subdir_extraction=1; } else if(extract_cmd) { cmd_verb=ARJ_CMD_EXTRACT; extract_expath=1; } else if(list_sfx_cmd) cmd_verb=ARJ_CMD_LIST; else if(test_sfx_cmd) cmd_verb=ARJ_CMD_TEST; else if(verbose_list) { cmd_verb=ARJ_CMD_LIST; std_list_cmd=1; } else cmd_verb=ARJ_CMD_EXTRACT; expand_wildcards=0; name=malloc_msg(FILENAME_MAX); for(i=0; i=ARJSFXV char FAR *preprocess_comment(char FAR *comment); #elif SFX_LEVEL>=ARJSFX char *preprocess_comment(char *comment); #endif void show_sfx_logo(); void sfx_setup(); #endif arj-3.10.22/arjsfxjr.c 666 0 0 47033 10040213576 10667 0ustar /* * $Id: arjsfxjr.c,v 1.8 2004/04/17 11:39:43 andrew_belov Exp $ * --------------------------------------------------------------------------- * This is the source for ARJSFXJR, the smallest SFX module. * */ #include "arj.h" #include #if TARGET!=UNIX #include #include #endif #include #include #include #include #if COMPILER!=BCC #include #include #endif #if TARGET==DOS #include /* Weird, eh? */ #endif #if TARGET==UNIX #include #include #endif DEBUGHDR(__FILE__) /* Debug information block */ /* Local variables */ static int file_type; static int aistream; /* ARJSFXJR does not use FILE * */ static unsigned short bitbuf; static int bitcount; static unsigned char subbitbuf; static long compsize; static long origsize; static char in_cache[CACHE_SIZE_SFXJR]; /* Cache for incoming data */ static char *in_cache_ptr; /* Pointer to fetch incoming data */ static int fill_level; /* Cache fill level */ static unsigned short reg_id; /* ARJSFX registration ID */ static unsigned int basic_hdr_size; static char header[HEADERSIZE_MAX]; static unsigned long header_crc; static unsigned char first_hdr_size; static unsigned char arj_flags; static unsigned int method; static unsigned long ftime_stamp; static unsigned long file_crc; static unsigned short entry_pos; static unsigned int file_mode; static char *hdr_filename; static char *hdr_comment; static char filename[FILENAME_MAX]; static char comment[COMMENT_MAX]; static char archive_name[FILENAME_MAX]; static unsigned char dec_text[DICSIZ]; static unsigned short left[2*NC-1]; static unsigned short right[2*NC-1]; static unsigned char pt_len[NPT]; static unsigned short c_table[CTABLESIZE]; static unsigned short pt_table[PTABLESIZE]; static unsigned char c_len[NC]; static int blocksize; static char cmd_args[SFX_COMMAND_SIZE+1]; static int st_argc; static char nullstr[]=""; static char test_mode=0; /* 1 if test mode (-t) is enabled */ static int atstream=0; /* Output file handle */ static int overwrite_existing=0; /* -o enables this mode */ static int allow_skipping=0; /* (-n) no errors on skipped files */ static unsigned int errors=0; /* Number of errors */ static unsigned int warnings=0; /* Number of non-fatal errors */ static unsigned int total_files=0; /* Total number of files in archive */ static int unpack_in_progress=0; /* Unpack procedure indicator */ static char *dest_dir=nullstr; /* Destination directory */ static char pathsep_sfxjr[]="\\:"; /* A simplified path separator list */ /* Local forward-referenced functions */ static void decode(); /* Converts a numerical variable to string */ static void numtostr(unsigned int n, char *str) { char *sptr; int i, j; char t; i=0; sptr=str; *sptr='\0'; do { sptr[++i]=(char)(n%10)+'0'; n/=10U; } while(n!=0); for(j=0; j<=i; j++) { t=str[i]; str[i]=str[j]; str[j]=t; i--; } } /* The only screen output routine */ static void sfxjr_puts(FMSG *str) { static char s_cr='\r'; #ifdef FMSG_ST char c; #endif #if TARGET==DOS&&COMPILER==BORLAND kbhit(); /* Don't know/care why it's here */ #endif while(*str!='\0') { if(*str=='\n') _write(1, &s_cr, 1); #ifdef FMSG_ST c=*str; _write(1, &c, 1); #else _write(1, str, 1); #endif str++; } } /* Writes a LF */ static void nputlf() { static char s_crlf[]={'\r', '\n'}; _write(1, &s_crlf, 2); } /* Error output routine. Very simplified, like all others. */ static void error(FMSG *errmsg) { nputlf(); sfxjr_puts(errmsg); nputlf(); exit(ARJSFXJR_ERL_ERROR); } /* Converts a filename to the format used in current OS (simply substitutes the UNIX separators with DOS ones) */ static void name_to_hdr(char *name) { int i; for(i=0; name[i]!='\0'; i++) { if(name[i]==PATHSEP_UNIX) name[i]=PATHSEP_DEFAULT; } } /* Looks for a path separator in the given filename/pathnamee */ static char *find_pathsep(char *name) { if(*name=='\0') return(NULL); while(*name!='\0') { if(*name==PATHSEP_DEFAULT) return(name); name++; } return((file_type==ARJT_DIR)?name:NULL); } /* Creates the necessary subdirectories before extracting a file */ static void create_subdir_tree(char *name) { char tmp_name[FILENAME_MAX]; int rc; char *nptr; nptr=name; /* Skip over preceding drive specifications */ if(nptr[0]!='\0'&&nptr[1]==':') nptr+=2; if(nptr[0]=='.') { if(nptr[1]=='.'&&nptr[2]==PATHSEP_DEFAULT) nptr++; if(nptr[1]==PATHSEP_DEFAULT) nptr++; } if(nptr[0]!=PATHSEP_DEFAULT) nptr++; while((nptr=find_pathsep(nptr))!=NULL) { strcpy(tmp_name, name); tmp_name[nptr-name]='\0'; #if TARGET==UNIX rc=chmod(tmp_name, 0755); #else rc=_chmod(tmp_name, 0); #endif if(rc==-1) { #if TARGET!=UNIX&&!defined(__EMX__) if(mkdir(tmp_name)) return; #else if(mkdir(tmp_name, 666)) return; #endif } else if(!(rc&FATTR_DIREC)) return; nptr++; } } #ifdef WORDS_BIGENDIAN #define mget_byte(p) (*(unsigned char FAR *)(p)&0xFF) /* Reads two bytes from the input archive */ unsigned int mget_word(char *p) { unsigned int b0, b1; b0=mget_byte(p); b1=mget_byte(p+1); return (b1<<8)|b0; } #else #define mget_word(p) (*(unsigned short *)(p)&0xFFFF) #endif /* Reads four bytes from the input archive */ #ifdef WORDS_BIGENDIAN unsigned long mget_dword(char *p) { unsigned long w0, w1; w0=mget_word(p); w1=mget_word(p+2); return (w1<<16)|w0; } #else #define mget_dword(p) (*(unsigned long *)(p)) #endif unsigned int fget_word() { char b[2]; if(_read(aistream, b, 2)!=2) error(M_CANTREAD); #ifdef WORDS_BIGENDIAN return (mget_byte(b+1)<<8)|mget_byte(b); #else return mget_word(b); #endif } /* Reads four bytes from the input archive */ unsigned long fget_dword() { char b[4]; if(_read(aistream, b, 4)!=4) error(M_CANTREAD); #ifdef WORDS_BIGENDIAN return (mget_word(b+2)<<16)|mget_word(b); #else return mget_dword(b); #endif } /* Reads N bits from the input file into the buffer */ static void fillbuf(int n) { unsigned int nbytes; bitbuf=(bitbuf<bitcount) { bitbuf|=subbitbuf<<(n-=bitcount); if(compsize!=0L) { if(fill_level<=0) { nbytes=(unsigned int)min(compsize, (long)CACHE_SIZE_SFXJR); fill_level=_read(aistream, in_cache, nbytes); if(fill_level<0) error(M_CANTREAD); in_cache_ptr=in_cache; } subbitbuf=(unsigned char)*in_cache_ptr++; fill_level--; compsize--; } else subbitbuf=0; bitcount=CHAR_BIT; } bitbuf|=subbitbuf>>(bitcount-=n); } /* Reads and returns N bits */ static unsigned short getbits(int n) { unsigned short x; x=bitbuf>>(CHAR_BIT*2-n); fillbuf(n); return(x); } /* Initializes bitwise reading mode */ static void init_getbits() { fill_level=0; bitbuf=0; subbitbuf=0; bitcount=0; fillbuf(CHAR_BIT*2); } /* Reads a block from the file, updating CRC */ static int fread_crc(char *buffer, int count) { int n; n=_read(aistream, buffer, count); if(n>0) { origsize+=(unsigned long)n; crc32_for_block(buffer, n); } return(n); } /* Writes the output buffer to a file, updating the CRC */ static void fwrite_crc(char *buffer, int count) { crc32_for_block(buffer, count); if(!test_mode) { if(_write(atstream, buffer, count)HEADERSIZE_MAX) error(M_BAD_HEADER); crc32term=CRC_MASK; fread_crc(header, basic_hdr_size); if((header_crc=fget_dword())!=(crc32term^CRC_MASK)) error(M_HEADER_CRC_ERROR); /* Selectively fetch header values */ first_hdr_size=header[0]; arj_flags=header[4]; method=(unsigned int)header[5]; file_type=(unsigned int)header[6]; ftime_stamp=mget_dword(header+8); compsize=mget_dword(header+12); origsize=mget_dword(header+16); file_crc=mget_dword(header+20); entry_pos=mget_word(header+24); file_mode=mget_dword(header+26); hdr_filename=header+first_hdr_size; strncpy(filename, hdr_filename, FILENAME_MAX); filename[FILENAME_MAX-1]='\0'; if(arj_flags&PATHSYM_FLAG) name_to_hdr(filename); if((long)origsize<0||(long)compsize<0) error(M_BAD_HEADER); hdr_comment=header+strlen(hdr_filename)+first_hdr_size+1; strncpy(comment, hdr_comment, COMMENT_MAX); comment[COMMENT_MAX-1]='\0'; /* Skip over extended headers, if any */ while((header_id=fget_word())!=0) _lseek(aistream, (long)header_id+4L, SEEK_CUR); return(1); } /* Unarchives a stored file */ static void unstore() { int fetch_size; while(compsize!=0L) { fetch_size=(int)min(compsize, (unsigned long)DICSIZ); compsize-=(unsigned long)fetch_size; if(_read(aistream, dec_text, fetch_size)!=fetch_size) error(M_CANTREAD); fwrite_crc(dec_text, fetch_size); sfxjr_puts(M_SFXJR_TICKER); } } /* Skips an archived file */ static void skip_file(FMSG *reason) { sfxjr_puts(reason); sfxjr_puts(M_SKIPPED); sfxjr_puts((FMSG *)filename); nputlf(); _lseek(aistream, compsize, SEEK_CUR); } /* Unpacks a single file, making all necessary checks */ static int unpack_file() { int c; char tmp_name[FILENAME_MAX]; if(!test_mode) { strcpy(tmp_name, dest_dir); strcat(tmp_name, filename); strcpy(filename, tmp_name); atstream=_open(filename, O_BINARY|O_RDONLY); if(atstream>=0) { _close(atstream); if(!overwrite_existing) { skip_file(M_FILE_EXISTS); if(!allow_skipping) warnings++; return(0); } } create_subdir_tree(filename); if(file_type!=ARJT_DIR&&(atstream=open(filename, O_CREAT|O_TRUNC|O_BINARY|O_RDWR, S_IREAD|S_IWRITE))<0) { skip_file(M_CANTOPEN_F); errors++; return(0); } unpack_in_progress=1; } sfxjr_puts(M_EXTRACTING); sfxjr_puts(filename); c=strlen(filename); while(c++<12) sfxjr_puts(M_VD_SPACE); crc32term=CRC_MASK; sfxjr_puts(M_VD_SPACE); if(file_type!=ARJT_DIR) { if(method>0) decode(); else unstore(); if(!test_mode) _close(atstream); } if(!test_mode) { #if TARGET==UNIX { struct utimbuf ut; ut.actime=ut.modtime=ftime_stamp; utime(filename, &ut); } #elif TARGET==WIN32 file_setftime(filename, ftime_stamp); #else if((atstream=_open(filename, O_BINARY|O_RDWR))>0) { file_setftime_on_hf(atstream, ftime_stamp); _close(atstream); } #endif #if COMPILER==BCC _chmod(filename, 1, file_mode&STD_ATTRS); #elif COMPILER==MSC||COMPILER==MSVC #if TARGET==DOS _dos_setfileattr(filename, file_mode&STD_ATTRS); #elif TARGET==OS2 DosSetFileMode(filename, file_mode&STD_ATTRS, 0L); #elif TARGET==WIN32 SetFileAttributes(filename, file_mode&STD_ATTRS); #endif #endif } atstream=0; unpack_in_progress=0; if((crc32term^CRC_MASK)==file_crc) sfxjr_puts(M_OK); else { sfxjr_puts(M_CRC_ERROR); errors++; } nputlf(); return(1); } /* Analyzes command-line parameters */ static int analyze_arg(char *arg) { if(arg[0]=='-') { switch(arg[1]) { case 'n': case 'N': allow_skipping=1; return(0); case 'o': case 'O': overwrite_existing=1; return(0); case 't': case 'T': test_mode=1; return(0); case '*': return(0); default: return(1); } } else { if(dest_dir[0]!='\0'||strchr(pathsep_sfxjr, arg[strlen(arg)-1])==NULL) return(1); dest_dir=arg; } return(0); } /* ARJSFXJR allows comment preprocessing, too... */ static char *preprocess_comment(char *comment) { int arg_rc; char ctr; char *aptr, *endptr; if(comment[0]==')'&&comment[1]==')') { comment+=2; arg_rc=0; aptr=cmd_args; for(ctr=1; ctr0) { while(*aptr=='\0') aptr++; if((endptr-aptr)>0) { arg_rc=analyze_arg(aptr); while(*aptr!='\0'&&(endptr-aptr)>0) aptr++; } } if(arg_rc) error(M_INVALID_SWITCH); if(*comment=='\n') comment++; } return(comment); } /* SFX opening routine */ static void process_archive() { char *cmt_ptr; char numfiles[10]; if((aistream=_open(archive_name, O_BINARY|O_RDONLY))<0) { sfxjr_puts(M_CANTOPEN); sfxjr_puts((FMSG *)archive_name); nputlf(); exit(ARJSFXJR_ERL_FATAL); } sfxjr_puts(M_PROCESSING_ARCHIVE); sfxjr_puts((FMSG *)archive_name); nputlf(); find_sfx_header(); get_reg_id(); if(reg_id!=REG_ID) reg_id=0; if(!read_header()) error(M_BAD_HEADER); cmt_ptr=comment; if(st_argc==1) cmt_ptr=preprocess_comment(cmt_ptr); sfxjr_puts((FMSG *)cmt_ptr); while(read_header()) if(unpack_file()) total_files++; numtostr(total_files, numfiles); /* German NLS fix -- ASR 12/10/2000 */ #if LOCALE==LANG_de sfxjr_puts(numfiles); sfxjr_puts(M_FILES); sfxjr_puts(M_EXTRACTED); #else sfxjr_puts(M_EXTRACTED); sfxjr_puts(numfiles); sfxjr_puts(M_FILES); #endif nputlf(); _close(aistream); } /* Ctrl+Break handler */ #if COMPILER==BCC static int ctrlc_handler() #else static void ctrlc_handler(int sig) #endif { sfxjr_puts(M_BREAK_SIGNALED); exit(ARJSFXJR_ERL_FATAL); #if COMPILER==BCC return(0); #endif } /* Pre-exit cleanup routine */ static void final_cleanup(void) { if(atstream!=0) _close(atstream); if(unpack_in_progress) unlink(filename); } /* Main routine */ int main(int argc, char **argv) { int arg_rc; unsigned int i; st_argc=argc; arg_rc=0; for(i=1; i0)?ARJSFXJR_ERL_ERROR:ARJSFXJR_ERL_SUCCESS); } /* Creates a table for decoding */ static void NEAR make_table(int nchar, unsigned char *bitlen, int tablebits, unsigned short *table, int tablesize) { unsigned short count[17], weight[17], start[18]; unsigned short *p; unsigned int i, k, len, ch, jutbits, avail, nextcode, mask; for(i=1; i<=16; i++) count[i]=0; for(i=0; (int)i>=jutbits; weight[i]=1<<(tablebits-i); } while(i<=16) { weight[i]=1<<(16-i); i++; } i=start[tablebits+1]>>jutbits; if(i!=(unsigned short)(1<<16)) { k=1<(unsigned int)tablesize) error(M_BADTABLE); for(i=start[len]; i>jutbits]; i=len-tablebits; while(i!=0) { if(*p==0) { right[avail]=left[avail]=0; *p=avail++; } if(k&mask) p=&right[*p]; else p=&left[*p]; k<<=1; i--; } *p=ch; } start[len]=nextcode; } } } /* Reads length of data pending */ void read_pt_len(int nn, int nbit, int i_special) { int i, n; short c; unsigned short mask; n=getbits(nbit); if(n==0) { c=getbits(nbit); for(i=0; i=NPT) /* ASR fix to prevent overrun */ n=NPT; while(i>13; if(c==7) { mask=1<<12; while(mask&bitbuf) { mask>>=1; c++; } } fillbuf((c<7)?3:(int)(c-3)); pt_len[i++]=(unsigned char)c; if(i==i_special) { c=getbits(2); while(--c>=0) pt_len[i++]=0; } } while(i>8]; if(c>=NT) { mask=1<<7; do { if(bitbuf&mask) c=right[c]; else c=left[c]; mask>>=1; } while(c>=NT); } fillbuf((int)(pt_len[c])); if(c<=2) { if(c==0) c=1; else if(c==1) c=getbits(4)+3; else c=getbits(CBIT)+20; while(--c>=0) c_len[i++]=0; } else c_len[i++]=(unsigned char)(c-2); } while(i>4]; if(j>=NC) { mask=1<<3; do { j=(bitbuf&mask)?right[j]:left[j]; mask>>=1; } while(j>=NC); } fillbuf((int)(c_len[j])); return(j); } /* Decodes a pointer to already decoded data */ static unsigned short decode_p() { unsigned short j, mask; j=pt_table[bitbuf>>8]; if(j>=NP) { mask=1<<7; do { j=(bitbuf&mask)?right[j]:left[j]; mask>>=1; } while(j>=NP); } fillbuf((int)(pt_len[j])); if(j!=0) { j--; j=(1<0L) { if((c=decode_c())<=UCHAR_MAX) { dec_text[r]=(unsigned char)c; count--; if(++r>=DICSIZ) { r=0; sfxjr_puts(M_SFXJR_TICKER); fwrite_crc(dec_text, DICSIZ); } } else { j=c-(UCHAR_MAX+1-THRESHOLD); count-=(unsigned long)j; i=r-decode_p()-1; if(i<0) i+=DICSIZ; if(r>i&&r=0) dec_text[r++]=dec_text[i++]; } else { while(--j>=0) { dec_text[r]=dec_text[i]; if(++r>=DICSIZ) { r=0; sfxjr_puts(M_SFXJR_TICKER); fwrite_crc(dec_text, DICSIZ); } if(++i>=DICSIZ) i=0; } } } } if(r>0) fwrite_crc(dec_text, r); } arj-3.10.22/arjtypes.c 666 0 0 16723 10256504126 10704 0ustar /* * $Id: arjtypes.c,v 1.9 2005/06/23 10:00:54 andrew_belov Exp $ * --------------------------------------------------------------------------- * This module provides some multiplatform property types which cover both DOS * (as internally involved in ARJ) and UNIX requirements. * */ #include #include "arj.h" DEBUGHDR(__FILE__) /* Debug information block */ /* Timestamp macros */ #define get_tx(m,d,h,n) (((unsigned long)(m)<<21)+((unsigned long)(d)<<16)+((unsigned long)(h)<<11)+((n)<<5)) #define get_tstamp(y,m,d,h,n,s) ((((unsigned long)((y)-1980))<<25)+get_tx((m),(d),(h),(n))+((s)/2)) #define ts_year(ts) ((unsigned int)(((ts)>>25)&0x7f)+1980) #define ts_month(ts) ((unsigned int)((ts)>>21)&0x0f) /* 1..12 means Jan..Dec */ #define ts_day(ts) ((unsigned int)((ts)>>16)&0x1f) /* 1..31 means 1st..31st */ #define ts_hour(ts) ((unsigned int)((ts)>>11)&0x1f) #define ts_min(ts) ((unsigned int)((ts)>>5)&0x3f) #define ts_sec(ts) ((unsigned int)(((ts)&0x1f)*2)) static char monthdays[12]={31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; /* Q&D helper macro */ #define is_unix(host_os) (host_os==OS_UNIX||host_os==OS_NEXT) /* Timestamp storage structures */ #if SFX_LEVEL>=ARJSFX static char time_list_format[]="%04u-%02u-%02u %02u:%02u:%02u"; #endif /* * File mode routines */ /* Parses a file mode specifier from the archive. The idea is to allow creation of DOS attributes under UNIX, but no features exist for DOS->UNIX conversion. */ void fm_store(struct file_mode *dest, int host_os, int mode) { if(host_os==OS_SPECIAL) dest->dos=dest->native=mode; if(is_unix(OS)) { dest->native=mode; dest->dos=FATTR_ARCH; if(is_unix(OS)&&!(mode&FATTR_IWUSR)) dest->dos|=FATTR_RDONLY; } else /* Assume a DOS-style system */ dest->dos=dest->native=mode; } /* Retrieves a native file mode corresponding to the host OS */ unsigned int fm_native(struct file_mode *fm, int host_os) { return(is_unix(host_os)?fm->native:fm->dos); } /* * Timestamp routines */ #ifdef LOCALTIME_WORKAROUND /* Folds a timestamp into the range handled by LIBC routines, returning a modified timestamp and a number of years to compensate. */ static unsigned int fold_timestamp(unsigned long *tt) { unsigned long v, d; d=(unsigned long)(*tt)/86400; if(d>=47482&&d<=47846) { /* 2100 -> 1993 */ *tt-=39081*86400UL; return(2100-1993); } else if(d>=47847) { /* 2101... -> 2005... */ *tt-=35063*86400UL; return(2101-2005); } else { /* Wrap into 28-year cycles (1970...1997) */ v=((unsigned long)*tt)/((28*365+7)*86400); *tt=((unsigned long)*tt)%((28*365+7)*86400); return(v*28); } /* NOTREACHED */ } /* The ARJ workaround for localtime */ struct tm *arj_localtime(const time_t *ts) { unsigned int v; unsigned long tt; struct tm *rc; tt=*ts; v=fold_timestamp(&tt); rc=localtime((time_t *)&tt); if(rc!=NULL) rc->tm_year+=v; return(rc); } #endif /* Returns 1 if there's a leap year */ static int isleapyear(int year) { if(year%400==0) return(1); if(year%100==0) return(0); if(year%4==0) return(1); return(0); } /* Converts a UNIX timestamp to the DOS style */ static unsigned long ts_unix2dos(const long ts) { struct tm *stm; stm=arj_localtime((time_t*)&ts); return(get_tstamp(stm->tm_year+1900, stm->tm_mon+1, stm->tm_mday, stm->tm_hour, stm->tm_min, stm->tm_sec)); } /* Creates a Unix timestamp from the given date and time */ static unsigned long mk_unixtime(int y, int m, int d, int hh, int mm, int ss) { unsigned long u=0, ts; unsigned int i, v; /* Clash with NetBSD/x86-64 patch: leaving rc as unsigned long still permits to escape the year 2038 problem in favor of year 2106 problem, while a dedicated time_t structure can be expected as a 64-bit value on relevant platforms -- ASR fix 25/01/2004 */ unsigned long rc; time_t tt; long tzshift, shiftd1, shiftd2; struct tm *stm; if(y>=2001) { i=y-2001; u=11323; /* The following piece of code is rather paranoid in 16/32-bit world, where the timestamps are limited to year 2108. */ #if defined(__32BIT__)||defined(TILED) if(i>=400) { u+=1022679L*(i/400); i%=400; } #endif if(i>=100) { u+=36524L*(i/100); i%=100; } u+=1461L*(i/4); u+=365L*(i%4); } else if(y>=1973) u=1096+(y-1973)/4*1461L+((y-1973)%4)*365L; else u=(y-1970)*365L; for(i=1; itm_hour*3600+(long)stm->tm_min*60; shiftd1=stm->tm_mday; ts=rc; #ifdef LOCALTIME_WORKAROUND v=fold_timestamp(&ts); stm=gmtime((const long *)&ts); debug_assert(stm!=NULL); stm->tm_year+=v; #else stm=gmtime((const long *)&ts); #endif shiftd2=stm->tm_mday; /* Local time overruns GMT, add 24 hours for safety */ if(shiftd1=28) tzshift+=86400; else if(shiftd1>shiftd2&&shiftd1>=28&&shiftd2==1) tzshift-=86400; else if(shiftd1>shiftd2) tzshift+=86400; else if(shiftd1tm_hour*3600+(long)stm->tm_min*60; tzshift%=86400; /* Fix the timezone if it does not roll over the zero */ return((tzshift>0&&rc=1&&m<=12); debug_assert(d>=1&&d<=31); #endif return(mk_unixtime(y, m, d, hh, mm, ss)); } /* Stores a timestamp */ void ts_store(struct timestamp *dest, int host_os, unsigned long value) { if(host_os==OS_SPECIAL) dest->dos=dest->unixtime=value; else if(is_unix(host_os)) { dest->unixtime=value; dest->dos=ts_unix2dos(value); } else { dest->dos=value; dest->unixtime=ts_dos2unix(value); } } /* Retrieves a native timestamp corresponding to the host OS */ unsigned long ts_native(struct timestamp *ts, int host_os) { return(is_unix(host_os)?ts->unixtime:ts->dos); } /* Compares two timestamps */ int ts_cmp(struct timestamp *ts1, struct timestamp *ts2) { unsigned long tsn1, tsn2; tsn1=ts_native(ts1, OS); tsn2=ts_native(ts2, OS); if(tsn1=ARJ||defined(REARJ) /* Produces an ARJ timestamp from the given date */ void make_timestamp(struct timestamp *dest, int y, int m, int d, int hh, int mm, int ss) { dest->unixtime=mk_unixtime(y, m, d, hh, mm, ss); dest->dos=ts_unix2dos(dest->unixtime); } #endif #if SFX_LEVEL>=ARJSFX /* Restores the given timestamp to character form */ void timestamp_to_str(char *str, struct timestamp *ts) { struct tm *stm; stm=arj_localtime((time_t *)&ts->unixtime); /* Workaround for a MS C v 7.0 CRT bug */ #if TARGET==DOS&&COMPILER==MSC&&_MSC_VER==700 if(stm->tm_year<70) /* 31 -> 101 */ stm->tm_year+=70; #endif sprintf(str, time_list_format, stm->tm_year+1900, stm->tm_mon+1, stm->tm_mday, stm->tm_hour, stm->tm_min, stm->tm_sec); } #endif arj-3.10.22/arjtypes.h 666 0 0 2452 7450456530 10652 0ustar /* * $Id: arjtypes.h,v 1.1.1.1 2002/03/28 00:01:28 andrew_belov Exp $ * --------------------------------------------------------------------------- * OS-independent types are to be declared here. * */ #ifndef ARJTYPES_INCLUDED #define ARJTYPES_INCLUDED /* Message classes */ #ifdef FMSG_ST typedef char FAR FMSG; typedef FMSG * FAR FMSGP; typedef FMSG * FAR NMSGP; #else typedef char FMSG; typedef char *FMSGP; typedef char *NMSGP; #endif /* File access mode record */ struct file_mode { int dos; /* For internals of ARJ (-hb, etc.) */ int native; }; /* Timestamp record */ struct timestamp { unsigned long dos; /* Local */ unsigned long unixtime; /* GMT */ }; /* A handy macro for verifying the validity of timestamps */ #define ts_valid(t) (t.dos!=0L) /* Prototypes */ void fm_store(struct file_mode *dest, int host_os, int mode); unsigned int fm_native(struct file_mode *fm, int host_os); void ts_store(struct timestamp *dest, int host_os, unsigned long value); unsigned long ts_native(struct timestamp *ts, int host_os); int ts_cmp(struct timestamp *ts1, struct timestamp *ts2); void make_timestamp(struct timestamp *dest, int y, int m, int d, int hh, int mm, int ss); void timestamp_to_str(char *str, struct timestamp *ts); #endif arj-3.10.22/arj_arcv.c 666 0 0 264773 10256070050 10656 0ustar /* * $Id: arj_arcv.c,v 1.16 2005/06/21 19:53:13 andrew_belov Exp $ * --------------------------------------------------------------------------- * Archive management routines are stored here (all these have nothing to do * neither with commands nor with the "user" part). * */ #include "arj.h" DEBUGHDR(__FILE__) /* Debug information block */ #define MAX_COMMENT_LINES 25 /* As stated in the documentation */ #define SECURED_MODE 0x78 /* file_mode of ARJ SECURITY headers */ /* Ways of processing for the extended header structure */ #define EHUF_WRITE 0x0001 /* Write the header */ #define EHUF_COMMIT 0x0002 /* Advance the pointer(s) */ #define EHUF_SETFLAGS 0x0004 /* Set the volume flag */ /* * Local variables */ static char *tmp_comment=NULL; /* Temporary comment storage */ static char *tmp_hptr; /* Pointer to parts of header */ static char arjdisp_default[]="arjdisp" EXE_EXTENSION; /* External display module */ #if SFX_LEVEL>=ARJSFXV static unsigned char ea_pwd_modifier; /* For garbled EAs */ static char arjprot_id; /* Identifies ARJ-PROTECT block in the main header */ #endif /* A table of permissions for binary/text files */ #if SFX_LEVEL>=ARJ static char *read_perms[]={m_rb, m_r}; /* For encoding only */ #endif #if SFX_LEVEL>=ARJSFXV static char *sim_perms[]={m_rbp, m_rp}; #endif static char *write_perms[]={m_wb, m_w}; /* Index file IDs */ #if SFX_LEVEL>=ARJ static char idxid_fault[]="?"; #endif /* * A set of macros and functions to read the header */ /* These macros read and write a byte from the header */ #define setup_hget(ptr) (tmp_hptr=(ptr)) #define setup_hput(ptr) (tmp_hptr=(ptr)) #define hget_byte() (*(tmp_hptr++)&0xFF) #define hput_byte(c) (*(tmp_hptr++)=(char) (c)) /* Reads two bytes from the header, incrementing the pointer */ static unsigned int hget_word() { unsigned int result; result=mget_word(tmp_hptr); tmp_hptr+=sizeof(short); return result; } /* Reads four bytes from the header, incrementing the pointer */ static unsigned long hget_longword() { unsigned long result; result=mget_dword(tmp_hptr); tmp_hptr+=sizeof(unsigned long); return result; } #if SFX_LEVEL>=ARJ /* Writes two bytes to the header, incrementing the pointer */ static void hput_word(unsigned int w) { mput_word(w,tmp_hptr); tmp_hptr+=sizeof(unsigned short); } /* Writes four bytes to the header, incrementing the pointer */ static void hput_longword(unsigned long l) { mput_dword(l,tmp_hptr); tmp_hptr+=sizeof(unsigned long); } /* Calculates and stores the basic header size */ static void calc_basic_hdr_size() { basic_hdr_size=(unsigned int)first_hdr_size+strlen(hdr_filename)+1+ strlen(hdr_comment)+1; } #endif #if SFX_LEVEL>=ARJSFXV /* Calculates and stores the offset of comment within a preallocated header */ static void calc_comment_offset() { hdr_comment=&header[(int)first_hdr_size+strlen(hdr_filename)+1]; } #endif #if SFX_LEVEL>=ARJ /* Allocates near memory for a temporary comment image, and copies the comment to this area. */ static void replicate_comment() { tmp_comment=malloc_msg(COMMENT_MAX); far_strcpy((char FAR *)tmp_comment, comment); } /* Removes the temporary comment from memory, copying its contents to original comment storage area (the one in the FAR memory). */ static void dump_tmp_comment() { if(tmp_comment!=NULL) { far_strcpy(comment, (char FAR *)tmp_comment); free(tmp_comment); } } /* Returns 1 if the given type is a file type, not a comment */ static int is_file_type(int t) { return((t==ARJT_BINARY||t==ARJT_TEXT||t==ARJT_DIR||file_type==ARJT_UXSPECIAL||t==ARJT_LABEL)?1:0); } #endif /* Finds archive header, returning its offset within file, or -1 if it can't be located. search_all is used to search through the entire file. */ long find_header(int search_all, FILE *stream) { long end_pos; long tmp_pos; int id; tmp_pos=ftell(stream); #if SFX_LEVEL>=ARJSFXV if(archive_size==0L) { fseek(stream, 0L, SEEK_END); archive_size=ftell(stream)-2L; #if SFX_LEVEL<=ARJSFXV fseek(stream, tmp_pos, SEEK_SET); #endif } end_pos=archive_size; if(!search_all) { if(end_pos>=tmp_pos+HSLIMIT_ARJ) end_pos=tmp_pos+HSLIMIT_ARJ; } while(tmp_pos=ARJSFXV while(tmp_pos=ARJSFXV if(tmp_pos>=end_pos) return(-1); #endif if((basic_hdr_size=fget_word(stream))<=HEADERSIZE_MAX) { crc32term=CRC_MASK; fread_crc(header, basic_hdr_size, stream); #if SFX_LEVEL>=ARJ if(fget_longword(stream)==(crc32term^CRC_MASK)||ignore_crc_errors==ICE_CRC) #else if(fget_longword(stream)==(crc32term^CRC_MASK)) #endif { fseek(stream, tmp_pos, SEEK_SET); return(tmp_pos); } } tmp_pos++; } return(-1); } #if SFX_LEVEL>=ARJ /* Displays a header error */ static void display_hdr_error_proc(FMSG *errmsg, char *name, unsigned int l) { #ifdef DEBUG debug_report(dbg_cur_file, l, 'V'); #endif if(!ignore_archive_errors) error(errmsg, name); msg_cprintf(0, errmsg, name); nputlf(); } #define display_hdr_error(errmsg, name) display_hdr_error_proc(errmsg, name, __LINE__) #else #define display_hdr_error(errmsg, dptr) error(errmsg, dptr) #endif /* Checks size of compressed files for abnormal effects (e.g. size<0) */ static int check_file_size() { return((long)origsize<0||(long)compsize<0); } /* Reads an archive or file header ( is archive filename just for user interface, and first, when == 0, specifies that the archive header is being read). Returns 0 if the end of archive has been reached. */ #if SFX_LEVEL>=ARJSFXV int read_header(int first, FILE *stream, char *name) #else int read_header(int first) #define stream aistream #endif { unsigned short header_id; #if SFX_LEVEL>=ARJSFXV char id; /* Extended header identifier */ char is_continued; struct ext_hdr FAR *tmp_eh; unsigned int remainder, fetch_size; char FAR *dptr; char transfer_buf[64]; #endif #if SFX_LEVEL>=ARJSFXV flush_kbd(); if(ignore_crc_errors!=ICE_NONE) { if(ignore_crc_errors==ICE_FORMAT) /* Allow malformed header signatures */ { cur_header_pos=ftell(stream); if((header_id=fget_word(stream))==HEADER_ID) { if((basic_hdr_size=fget_word(stream))==0) return(0); } fseek(stream, cur_header_pos, SEEK_SET); } if(find_header(1, stream)<0L) { display_hdr_error(M_BAD_HEADER, NULL); return(0); } } cur_header_pos=ftell(stream); #endif /* Strictly check the header ID */ if((header_id=fget_word(stream))!=HEADER_ID) { #if SFX_LEVEL>=ARJSFXV if(first!=0) display_hdr_error(M_NOT_ARJ_ARCHIVE, name); else #endif display_hdr_error(M_BAD_HEADER, NULL); return(0); } if((basic_hdr_size=fget_word(stream))==0) return(0); if(basic_hdr_size>HEADERSIZE_MAX) { display_hdr_error(M_BAD_HEADER, NULL); return(0); } crc32term=CRC_MASK; fread_crc(header, basic_hdr_size, stream); if((header_crc=fget_longword(stream))!=(crc32term^CRC_MASK)) { display_hdr_error(M_HEADER_CRC_ERROR, NULL); #if SFX_LEVEL>=ARJSFXV return(0); #endif } setup_hget(header); first_hdr_size=hget_byte(); arj_nbr=hget_byte(); arj_x_nbr=hget_byte(); host_os=hget_byte(); arj_flags=hget_byte(); method=hget_byte(); file_type=hget_byte(); password_modifier=hget_byte(); ts_store(&ftime_stamp, host_os, hget_longword()); compsize=hget_longword(); origsize=hget_longword(); file_crc=hget_longword(); entry_pos=hget_word(); fm_store(&file_mode, host_os, hget_word()); #if SFX_LEVEL>=ARJSFXV /* Before v 2.50, we could only read host data here. With the introduction of chapter archives, chapter numbers are stored in this field. NOTE: it will be wise to check that the compressor's version (arj_nbr) is >= 7 ... */ ext_flags=hget_byte(); chapter_number=hget_byte(); #if SFX_LEVEL>=ARJ if(modify_command&&ts_cmp(&ftime_stamp, &ftime_max)>0&&is_file_type(file_type)) ftime_max=ftime_stamp; #else if(ts_cmp(&ftime_stamp, &ftime_max)>0&&file_type!=ARJT_COMMENT) ftime_max=ftime_stamp; #endif resume_position=0L; continued_prevvolume=0; /* v 2.62+ - reset ext. timestamps */ ts_store(&atime_stamp, OS_SPECIAL, 0L); if(first) { arjprot_id=0; #if SFX_LEVEL>=ARJ prot_blocks=0; #endif if(first_hdr_size>=FIRST_HDR_SIZE_V) { #if SFX_LEVEL>=ARJ prot_blocks=hget_byte(); #else hget_byte(); #endif arjprot_id=hget_byte(); hget_word(); if(arjprot_id&SFXSTUB_FLAG) use_sfxstub=1; } } else { if(first_hdr_size=ARJSFXV file_garbled=(arj_flags&GARBLED_FLAG)?1:0; garble_ftime=ts_native(&ftime_stamp, host_os); #endif hdr_filename=&header[first_hdr_size]; /* To conserve space, the calc_comment_offset() is placed in-line */ #if SFX_LEVEL>=ARJSFXV calc_comment_offset(); #else hdr_comment=&header[(int)first_hdr_size+strlen(hdr_filename)+1]; #endif #if SFX_LEVEL>=ARJSFXV far_strcpyn((char FAR *)filename, (char FAR *)hdr_filename, FILENAME_MAX); far_strcpyn(comment, (char FAR *)hdr_comment, COMMENT_MAX); #else strncpy(filename, hdr_filename, FILENAME_MAX); strncpy(comment, hdr_comment, COMMENT_MAX); #endif if(first==0&&lfn_supported==LFN_SUPPORTED&&dual_name) { #if SFX_LEVEL>=ARJSFXV far_strcpyn((char FAR *)filename, (char FAR *)hdr_comment, FILENAME_MAX); far_strcpyn(comment, (char FAR *)hdr_filename, COMMENT_MAX); #else strncpy(filename, hdr_comment, FILENAME_MAX); strncpy(comment, hdr_filename, COMMENT_MAX); #endif } filename[FILENAME_MAX-1]='\0'; comment[COMMENT_MAX-1]='\0'; #if SFX_LEVEL>=ARJSFXV if(!test_host_os((int)host_os)&&file_type==ARJT_TEXT) #else if(!test_host_os((int)host_os)) #endif to_7bit(filename); if(arj_flags&PATHSYM_FLAG) name_to_hdr(filename); if(test_host_os((int)host_os)) #if SFX_LEVEL>=ARJSFXV entry_pos=split_name(filename, NULL, NULL); #else entry_pos=split_name(filename); #endif #if SFX_LEVEL<=ARJSFX list_adapted_name=filename+entry_pos; #endif #if SFX_LEVEL>=ARJ /* Convert the comment to 7 bits if the host OS is unknown to us */ if(!test_host_os(host_os)) { replicate_comment(); to_7bit(tmp_comment); dump_tmp_comment(); } #elif SFX_LEVEL==ARJSFX if(!test_host_os(host_os)) to_7bit(comment); /* The advantage of NEAR memory... */ #endif #if SFX_LEVEL>=ARJ /* This was a stub initially, and, anyway, is no longer applicable -- ASR 16/02/2001 */ /* ftime_stamp=import_timestamp(ftime_stamp); */ #endif #if SFX_LEVEL<=ARJSFX file_garbled=(arj_flags&GARBLED_FLAG)?1:0; #endif if(first!=0) { #if SFX_LEVEL>=ARJ if(arj_flags&GARBLED_FLAG) encryption_applied=1; #endif #if SFX_LEVEL>=ARJSFXV continued_nextvolume=(arj_flags&VOLUME_FLAG)?1:0; #endif if(arj_flags&SECURED_FLAG) { security_state=ARJSEC_SECURED; #if SFX_LEVEL>=ARJ secured_size=origsize; #endif arjsec_offset=file_crc; } #if SFX_LEVEL>=ARJSFXV ext_hdr_flags=ext_flags&0x0F; /* Mask only the currently supported values */ #endif if(arj_flags&DUAL_NAME_FLAG) dual_name=1; #if SFX_LEVEL>=ARJSFXV if(arj_flags&ANSICP_FLAG) ansi_codepage=1; #if SFX_LEVEL>=ARJ if(arj_flags&PROT_FLAG) arjprot_tail=1; /* Chapter-archive specific processing */ if(first==1&&chapter_number>0) { if(add_command&¤t_chapter<=CHAPTERS_MAX) { chapter_number++; comment_entries++; } if(!first_vol_passed) total_chapters=chapter_number; else chapter_number=total_chapters; if(total_chapters>CHAPTERS_MAX) error(M_TOO_MANY_CHAPTERS, CHAPTERS_MAX); } #endif #endif } #if SFX_LEVEL>=ARJSFXV else { if(arj_flags&VOLUME_FLAG) #if SFX_LEVEL>=ARJ volume_flag_set=force_volume_flag=1; #else volume_flag_set=1; #endif else volume_flag_set=0; } #endif #if SFX_LEVEL>=ARJ if(file_type==ARJT_CHAPTER&&chapter_number>recent_chapter) recent_chapter=chapter_number; /* ARJSFX/ARJSFXV archives have some limitations, check it here */ if(create_sfx!=SFXCRT_NONE||(sfx_desc_word!=0&&modify_command)) { if(method==4) error(M_INVALID_METHOD_SFX); if(total_chapters>0) error(M_CHAPTER_SFX_CREATION); if(!multivolume_option&&file_type==ARJT_LABEL) error(M_NO_LABELS_IN_SFX); if(!win32_platform&&create_sfx&&!multivolume_option&& ext_hdr_flags>ENCRYPT_GOST256L) error(M_WRONG_ENC_VERSION, ext_hdr_flags); /* ARJSFXJR archives have yet more limitations that need to be checked */ if(create_sfx==SFXCRT_SFXJR||sfx_desc_word==SFXDESC_SFXJR) { #if TARGET==UNIX if(file_type==ARJT_TEXT) #else if(file_type==ARJT_TEXT||lfn_supported!=LFN_NOT_SUPPORTED) #endif error(M_TEXTMODE_LFN_SFXJR); #if defined(HAVE_EAS) if(ea_supported) error(M_TEXTMODE_LFN_SFXJR); #endif /* Check for systems that are hostile to ARJSFXJR */ #if TARGET==DOS if(host_os!=OS) error(M_TEXTMODE_LFN_SFXJR); #elif TARGET!=UNIX if(!test_host_os(host_os)) error(M_TEXTMODE_LFN_SFXJR); #endif if(arj_flags&GARBLED_FLAG) error(M_NO_GARBLE_IN_SFXJR); } } #endif #if SFX_LEVEL>=ARJSFXV /* Reset the extended header buffers for noncontinued files */ if(!(arj_flags&EXTFILE_FLAG)&&cur_header_pos!=main_hdr_offset) { if(eh!=NULL) { eh_release(eh); eh=NULL; valid_ext_hdr=0; } ea_pwd_modifier=password_modifier; } #endif /* Process extended headers, if any */ while((header_id=fget_word(stream))!=0) { #if SFX_LEVEL>=ARJSFXV crc32term=CRC_MASK; if(fread(&id, 1, 1, stream)==0) error(M_CANTREAD); crc32_for_block(&id, 1); valid_ext_hdr=1; /* Skip the extended headers if the file is continued from the previous volume and we haven't caught the beginning */ if((arj_flags&EXTFILE_FLAG)&&eh==NULL) { fseek(stream, (long)header_id+3L, SEEK_CUR); valid_ext_hdr=0; } else { /* Perform early allocation of the extended header block */ if(eh==NULL) eh=eh_alloc(); /* Get the continuation flag */ if(fread(&is_continued, 1, 1, stream)==0) error(M_CANTREAD); crc32_for_block(&is_continued, 1); /* Collect the scattered data */ remainder=header_id-2; tmp_eh=eh_append(eh, id, NULL, remainder); dptr=tmp_eh->raw+(tmp_eh->size-remainder); tmp_eh->flags=is_continued?EH_PROCESSING:EH_UNPROCESSED; while(remainder>0) { fetch_size=min(remainder, sizeof(transfer_buf)); if(fread(transfer_buf, 1, fetch_size, stream)!=fetch_size) error(M_CANTREAD); far_memmove(dptr, transfer_buf, fetch_size); crc32_for_block(transfer_buf, fetch_size); remainder-=fetch_size; dptr+=fetch_size; } if(fget_longword(stream)!=(crc32term^CRC_MASK)) { if(ignore_crc_errors!=ICE_CRC) error(M_BAD_HEADER); else { eh_release(eh); eh=NULL; } } } #else fseek(stream, (long)header_id+4L, SEEK_CUR); #endif } return(1); } #if SFX_LEVEL<=ARJSFX #undef stream #endif #if SFX_LEVEL>=ARJ /* Fill general purpose header fields */ static void fill_general_hdr() { arj_nbr=ARJ_VERSION; arj_x_nbr=ARJ_X_VERSION; if(file_type==ARJT_DIR) arj_x_nbr=ARJ_XD_VERSION; else if(file_type==ARJT_UXSPECIAL) arj_x_nbr=ARJ_XU_VERSION; #if TARGET==DOS host_os=OS; #else host_os=(dos_host==CHO_USE_DOS)?OS_DOS:OS; #endif /* If LFNs are supported, stamp Win95 or WinNT/Win32 OS code */ #if TARGET==DOS if(lfn_supported!=LFN_NOT_SUPPORTED) { host_os=OS_WIN95; if(win32_platform) if(test_for_winnt()) host_os=OS_WINNT; /* Same as OS_WIN32 */ } #endif } /* Fills the basic header */ void create_header(int first) { setup_hput(header); hput_byte(first_hdr_size); hput_byte(arj_nbr); hput_byte(arj_x_nbr); if(first&&dos_host==CHO_COMMENT) host_os=OS_DOS; hput_byte(host_os); hput_byte(arj_flags); hput_byte((char)method); hput_byte((char)file_type); hput_byte((!ts_valid(secondary_ftime))?password_modifier:0); if(ts_valid(secondary_ftime)) { hput_longword(ts_native(&secondary_ftime, OS)); garble_ftime=ts_native(&secondary_ftime, OS); } else { garble_ftime=ts_native(&ftime_stamp, host_os); hput_longword(garble_ftime); } hput_longword(compsize); hput_longword(origsize); hput_longword(file_crc); hput_word(entry_pos); hput_word(fm_native(&file_mode, host_os)); hput_byte(ext_flags); hput_byte(chapter_number); if(first) { if(first_hdr_size>=FIRST_HDR_SIZE_V) { hput_byte((char)prot_blocks); hput_byte(arjprot_id); hput_word(0); } } else { if(first_hdr_size0&&(p_eh=eh_find_pending(p_eh))!=NULL) { rem_size=p_eh->size-p_eh->cur_offset; if((unsigned long)cur_capacity+2<=rem_size) { if(action&EHUF_COMMIT) { p_eh->flags=EH_PROCESSING; p_eh->cur_offset+=ext_hdr_capacity; } remainder=min(cur_capacity, rem_size); cont_id=1; cur_capacity=0; } else { if(action&EHUF_COMMIT) p_eh->flags=EH_FINALIZED; remainder=rem_size; /* ASR fix 15/05/2003 */ /* Take out the ID/length/CRC32 and the data */ cur_capacity-=rem_size+EXT_HDR_OVERHEAD; cont_id=0; } if(action&EHUF_WRITE) { fput_word(remainder+2, aostream); crc32term=CRC_MASK; id=p_eh->tag; fwrite_crc(&id, 1, aostream); fwrite_crc(&cont_id, 1, aostream); dptr=p_eh->raw+p_eh->cur_offset; while(remainder>0) { fetch_size=min(sizeof(transfer_buf), remainder); far_memmove((char FAR *)transfer_buf, dptr, fetch_size); fwrite_crc(transfer_buf, fetch_size, aostream); dptr+=fetch_size; remainder-=fetch_size; } fput_dword(crc32term^CRC_MASK, aostream); } p_eh=p_eh->next; } if(multivolume_option&&p_eh!=NULL&&cur_capacity<=0&&(action&EHUF_SETFLAGS)) volume_flag_set=1; if(action&EHUF_COMMIT) ext_hdr_capacity=cur_capacity; } /* Writes the archive header to the aostream, calculating its CRC */ void write_header() { unsigned long hdr_offset; hdr_offset=ftell(aostream); if(ts_cmp(&ftime_stamp, &ftime_max)>0&&is_file_type(file_type)) ftime_max=ftime_stamp; fput_word(HEADER_ID, aostream); fput_word(basic_hdr_size, aostream); if(fflush(aostream)) error(M_DISK_FULL); if(hdr_offset>last_hdr_offset) last_hdr_offset=hdr_offset; if(file_type!=ARJT_COMMENT&&chapter_number>max_chapter) max_chapter=chapter_number; crc32term=CRC_MASK; fwrite_crc(header, basic_hdr_size, aostream); fput_dword(header_crc=crc32term^CRC_MASK, aostream); /* Store a portion or the entire extended header */ if(eh!=NULL&&hdr_offset!=main_hdr_offset) proc_ext_hdr(EHUF_WRITE|EHUF_SETFLAGS); fput_word(0, aostream); } /* Renames a file in archive. Returns 1 if a header update occured, 0 if not (no filename entered) */ int rename_file() { msg_cprintf(H_HL|H_NFMT, M_CURRENT_FILENAME, filename); msg_cprintf(0, M_ENTER_NEW_FILENAME); read_line(filename, FILENAME_MAX); alltrim(filename); if(filename[0]=='\0') return(0); far_strcpyn(comment, (char FAR *)hdr_comment, COMMENT_MAX); strcpy(hdr_filename, filename); case_path(hdr_filename); entry_pos=split_name(hdr_filename, NULL, NULL); if(translate_path(hdr_filename)) arj_flags|=PATHSYM_FLAG; else arj_flags&=~PATHSYM_FLAG; calc_comment_offset(); far_strcpyn((char FAR *)hdr_comment, comment, COMMENT_MAX); create_header(0); calc_basic_hdr_size(); return(1); } /* Reads a comment from the given file and stores it in the buffer. Supplying a null filename to it will strip the comment (note that null filename is NUL in DOS and /dev/null under UNIX) */ static void read_comment(char *buffer, char *name) { FILE *stream; int llen; /* Length of last read line */ if(!strcmp_os(buffer, dev_null)) return; stream=file_open_noarch(name, m_r); while(fgets(buffer, COMMENT_MAX, stream)!=NULL) { if((llen=strlen(buffer))+strlen(tmp_comment)+4>=COMMENT_MAX) break; strcat(tmp_comment, buffer); } fclose(stream); } /* A routine to supply comments */ int supply_comment(char *cmtname, char *name) { char *tmp_cmtline; int maxlines; int curline; tmp_cmtline=malloc_msg(COMMENT_MAX+1); replicate_comment(); msg_cprintf(H_HL|H_NFMT, M_CURRENT_COMMENT, name); display_comment(comment); /* ASR enhancement -- 09/01/2001 */ if(disable_comment_series&&first_vol_passed) { comment[0]='\0'; calc_basic_hdr_size(); return(1); } /* If the filename given is blank, enter the comment manually */ if(cmtname[0]=='\0') { maxlines=MAX_COMMENT_LINES; msg_cprintf(H_HL|H_NFMT, M_ENTER_COMMENT, maxlines, name); for(curline=0; curline0) { msg_strcpy(strcpy_buf, M_EMPTY_COMMENT); /* Strip blank comments */ if(!far_strcmp(comment, (char FAR *)strcpy_buf)) comment[0]='\0'; far_strcpyn((char FAR *)hdr_comment, comment, COMMENT_MAX); calc_basic_hdr_size(); return(1); } else return(0); } /* Fills the basic archive header with needed information */ void fill_archive_header() { first_hdr_size=FIRST_HDR_SIZE_V; cur_time_stamp(&ftime_stamp); compsize=ts_native(&ftime_stamp, host_os); if(ts_valid(secondary_ftime)) compsize=ts_native(&secondary_ftime, host_os); file_type=ARJT_COMMENT; method=0; entry_pos=0; origsize=0L; file_crc=0L; fm_store(&file_mode, OS_DOS, 0); host_data=0; ext_flags=0; chapter_number=0; if(chapter_mode!=0) { if(total_chapters==0) chapter_number=total_chapters=1; else chapter_number=total_chapters; } else { if(total_chapters!=0) chapter_number=total_chapters; } arj_flags=0; if(multivolume_option) arj_flags|=VOLUME_FLAG; if(add_command&&lfn_supported!=LFN_NOT_SUPPORTED&&(lfn_mode==LFN_DUAL_EXT||lfn_mode==LFN_DUAL)) arj_flags|=DUAL_NAME_FLAG; if(add_command&&use_ansi_cp) arj_flags|=ANSICP_FLAG; arjprot_id=use_sfxstub?SFXSTUB_FLAG:0; password_modifier=(char)ts_native(&ftime_stamp, OS_SPECIAL); ext_hdr_flags=0; if(garble_enabled) { arj_flags|=GARBLED_FLAG; encryption_applied=1; ext_hdr_flags=ENCRYPT_STD; if(gost_cipher==GOST256) ext_hdr_flags=ENCRYPT_UNK; else if(gost_cipher==GOST40) ext_hdr_flags=ENCRYPT_GOST40; } hdr_filename=&header[first_hdr_size]; split_name(archive_name, NULL, hdr_filename); if(translate_path(hdr_filename)) arj_flags|=PATHSYM_FLAG; calc_comment_offset(); hdr_comment[0]='\0'; fill_general_hdr(); create_header(1); calc_basic_hdr_size(); } /* Final header pass: occurs at update of multivolume archives and those containing ARJ SECURITY. The operation variable specifies the action (one of FP_*) to be made. */ void final_header(int operation) { unsigned long tmp_resume_position; int tmp_multivolume; /* Indicates that the file is continued on the next volume */ int tmp_cont_prev; /* Indicates that the file is continued from the previous volume */ unsigned long cur_pos; int cur_ext_hdr_flags; int tmp_prot_blocks; tmp_prot_blocks=prot_blocks; tmp_resume_position=resume_position; tmp_cont_prev=continued_prevvolume; tmp_multivolume=mvfile_type; cur_ext_hdr_flags=ext_hdr_flags; cur_pos=ftell(aostream); fseek(aostream, main_hdr_offset, SEEK_SET); read_header(2, aostream, archive_name); fseek(aostream, main_hdr_offset, SEEK_SET); if(operation==FP_SECURITY&&is_registered) { origsize=secured_size; file_crc=arjsec_offset; arj_flags|=SECURED_FLAG; method=2; fm_store(&file_mode, OS_SPECIAL, SECURED_MODE); } else if(operation==FP_PROT) { arj_flags|=PROT_FLAG; prot_blocks=tmp_prot_blocks; /* ASR fix - the original (v 3.02) checks for ==0 only */ if(file_crc==0L||file_crc>arjsec_offset||(arjsec_offset-file_crc)>=CACHE_SIZE) file_crc=arjsec_offset; } else if(operation==FP_VOLUME) arj_flags&=~VOLUME_FLAG; else if(operation==FP_CHAPTER) chapter_number=max_chapter; else if(operation==FP_GARBLE) { arj_flags|=GARBLED_FLAG; ext_flags=(ext_flags&0xF0)|(cur_ext_hdr_flags&0x0F); } create_header(1); write_header(); fseek(aostream, cur_pos, SEEK_SET); prot_blocks=tmp_prot_blocks; resume_position=tmp_resume_position; continued_prevvolume=tmp_cont_prev; mvfile_type=tmp_multivolume; comment[0]='\0'; /* ASR fix - the original is somewhere else */ } #endif /* Skips over the compressed data in the input file */ void skip_compdata() { #if SFX_LEVEL>=ARJSFXV if(compsize!=0L) file_seek(aistream, compsize, SEEK_CUR); #else fseek(aistream, compsize, SEEK_CUR); #endif } /* Skips over the compressed data, prompting the user */ void skip_file() { #if SFX_LEVEL>=ARJSFXV msg_cprintf(H_HL|H_NFMT, M_SKIPPED, filename); #else msg_cprintf(H_HL|H_NFMT, M_SKIPPED, filename); #endif skip_compdata(); } /* Displays ARJ$DISP screen */ void arjdisp_scrn(unsigned long bytes) { char *arjdisp_name; #if SFX_LEVEL<=ARJSFX char cmd_buf[CCHMAXPATH]; #endif #if SFX_LEVEL>=ARJSFXV ctrlc_not_busy=0; arjdisp_name=arjdisp_ptr; if(arjdisp_name[0]=='\0') arjdisp_name=arjdisp_default; #else arjdisp_name=arjdisp_default; #endif if(strcmp_os(filename, arjdisp_name)) { #if SFX_LEVEL>=ARJSFXV msg_sprintf(misc_buf, M_ARJDISP_INVOCATION, arjdisp_name, archive_name, filename, uncompsize, bytes, compsize, cmd_verb); system_cmd(misc_buf); #else msg_sprintf(cmd_buf, M_ARJDISP_INVOCATION, arjdisp_name, archive_name, filename, uncompsize, bytes, compsize, cmd_verb); system_cmd(cmd_buf); #endif } #if SFX_LEVEL>=ARJSFXV ctrlc_not_busy=1; #endif } #if SFX_LEVEL>=ARJ /* Returns CRC-32 ofthe given file */ static unsigned long crc32_for_file(char *name) { FILE *stream; char *buffer; int block_size; crc32term=CRC_MASK; if((stream=file_open(name, m_rb))!=NULL) { buffer=malloc_msg(CACHE_SIZE); while((block_size=fread(buffer, 1, CACHE_SIZE, stream))!=0) crc32_for_block(buffer, block_size); free(buffer); fclose(stream); } return(crc32term^CRC_MASK); } /* Issues various actions on currently processed file in archive */ void special_processing(int action, FILE *stream) { int garble_task; struct timestamp gtime; char *pbuf; unsigned long cur_pos; int count; char *tmp_name; garble_task=0; /* Initally, no garble post-processing is considered. */ switch(action) { case CFA_UNMARK: msg_cprintf(H_HL|H_NFMT, M_UNMARKING, filename); if((int)chapter_number!=total_chapters) error(M_CHAPTER_ERROR, 1); chapter_number--; create_header(0); break; case CFA_MARK: msg_cprintf(H_HL|H_NFMT, M_MARKING, filename); if((int)chapter_number!=total_chapters) error(M_CHAPTER_ERROR, 1); ext_flags=(unsigned char)total_chapters; create_header(0); break; case CFA_MARK_INCREMENT: msg_cprintf(H_HL|H_NFMT, M_MARKING, filename); if((int)chapter_number+1!=total_chapters) error(M_CHAPTER_ERROR, 1); chapter_number=(unsigned char)total_chapters; create_header(0); total_files++; if(host_os==OS_WIN95||host_os==OS_WINNT) { total_longnames++; if(volume_flag_set) split_longnames++; } break; case CFA_REMPATH: msg_cprintf(H_HL|H_NFMT, M_REMOVING_PATH, filename); far_strcpyn(comment, (char FAR *)hdr_comment, COMMENT_MAX); tmp_name=malloc_str(hdr_filename); split_name(tmp_name, NULL, hdr_filename); free(tmp_name); entry_pos=0; arj_flags&=~PATHSYM_FLAG; calc_comment_offset(); far_strcpyn((char FAR *)hdr_comment, comment, COMMENT_MAX); if(dual_name) { tmp_name=malloc_str(hdr_comment); split_name(tmp_name, NULL, hdr_comment); free(tmp_name); } create_header(0); calc_basic_hdr_size(); total_files++; break; case CFA_MARK_EXT: msg_cprintf(H_HL|H_NFMT, M_MARKING, filename); if(ext_flags==0) ext_flags=(unsigned char)total_chapters; if(chapter_number==0) chapter_number=(unsigned char)total_chapters; create_header(0); total_files++; break; case CFA_UNMARK_EXT: msg_cprintf(H_HL|H_NFMT, M_UNMARKING, filename); ext_flags=0; chapter_number=0; create_header(0); total_files++; break; case CFA_GARBLE: if(!(arj_flags&GARBLED_FLAG)) { msg_cprintf(H_HL|H_NFMT, M_GARBLING, filename); arj_flags|=GARBLED_FLAG; cur_time_stamp(>ime); password_modifier=ts_native(>ime, OS); garble_task=1; create_header(0); total_files++; } break; case CFA_UNGARBLE: if(arj_flags&GARBLED_FLAG) { msg_cprintf(H_HL|H_NFMT, M_UNGARBLING, filename); arj_flags&=~GARBLED_FLAG; garble_task=2; create_header(0); total_files++; } break; } if(arj_flags&GARBLED_FLAG) encryption_id=ENCID_GARBLE; write_header(); if(garble_task) garble_init(password_modifier); pbuf=(char *)malloc_msg(PROC_BLOCK_SIZE); cur_pos=ftell(stream); count=min(CACHE_SIZE-(cur_pos%CACHE_SIZE), compsize); while(compsize>0L) { if(fread(pbuf, 1, count, stream)!=count) error(M_CANTREAD); if(garble_task==1) garble_encode_stub(pbuf, count); else if(garble_task==2) garble_decode_stub(pbuf, count); if(!no_file_activity) file_write(pbuf, 1, count, aostream); compsize-=(unsigned long)count; count=min(PROC_BLOCK_SIZE, compsize); } free(pbuf); } /* Prints an "Adding..." message */ static void addition_msg(int is_update, int is_replace, char *filespec) { /* -hdx will turn off these messages */ if(!debug_enabled||strchr(debug_opt, 'x')==NULL) { if(is_update) msg_cprintf(H_HL, M_UPDATING); else if(is_replace) msg_cprintf(H_HL, M_REPLACING); else msg_cprintf(H_HL, M_ADDING); if(verbose_display==VERBOSE_STD) { if(file_type==ARJT_BINARY) msg_cprintf(0, M_BINARY_FILE); else if(file_type==ARJT_TEXT) msg_cprintf(0, M_TEXT_FILE); else if(file_type==ARJT_DIR) msg_cprintf(0, M_DIRECTORY); else if(file_type==ARJT_UXSPECIAL) msg_cprintf(0, M_UXSPECIAL_FILE); } if(continued_prevvolume&&eh_find_pending(eh)==NULL) msg_cprintf(H_HL|H_NFMT, M_AT_POSITION, format_filename(filespec), resume_position); else msg_cprintf(0, (FMSG *)strform, format_filename(filespec)); if(!verbose_display) msg_cprintf(0, (FMSG *)vd_space); else { nputlf(); if(method==0) msg_cprintf(0, M_STORING); else msg_cprintf(H_HL|H_NFMT, M_COMPRESSING, method); msg_cprintf(H_HL|H_NFMT, M_N_BYTES, uncompsize); } } } /* Initializes global variables and performs general set-up before packing a file. */ void init_packing(unsigned long offset, int is_mv) { unpackable=0; volume_flag_set=0; ext_voldata=0; compsize=origsize=0L; if(garble_enabled) garble_init(password_modifier); crc32term=CRC_MASK; if(file_type==ARJT_BINARY||file_type==ARJT_TEXT) { if(!is_mv||resume_position>0) smart_seek(resume_position, encstream); } if(!is_mv&!no_file_activity) fseek(aostream, offset, SEEK_SET); } /* Stores or compresses a single file */ static void pack_file_proc(unsigned long offset) { if(method==1||method==2||method==3) encode_stub(method); else if(method==4) encode_f_stub(); else if(method==9) hollow_encode(); if(unpackable) /* Fall back to method #0 */ { if(verbose_display==VERBOSE_STD) { msg_cprintf(0, (FMSG *)" \r"); msg_cprintf(0, M_STORING); msg_cprintf(H_HL|H_NFMT, M_N_BYTES, uncompsize); } method=0; init_packing(offset, 0); } if(method==0) store(); display_indicator(uncompsize); } /* Opens the file for encoding */ static int open_input_file() { int e; /* Error indicator */ if((encstream=file_open(filename, read_perms[file_type%2]))!=NULL) return(0); error_report(); msg_cprintf(H_ERR, M_CANTOPEN, filename); nputlf(); e=1; if(no_inarch) { if((ignore_open_errors==IAE_ACCESS&&errno==EACCES)|| (ignore_open_errors==IAE_NOTFOUND&&errno==ENOENT)|| (ignore_open_errors==IAE_ALL&&(errno==EACCES||errno==ENOENT))) e=0; } if(e) errors++; write_index_entry(idxid_fault); return(1); } /* Packs a single file, involving all neccessary checks. Returns 1 if it got packed, 0 if not, -1 in case of an error. */ int pack_file(int is_update, int is_replace) { struct timestamp ftime, atime, ctime, cur_time; unsigned long fsize; int volume_file; /* 1 if file spans across volumes */ int needs_skip; /* 1 if the file needs to be skipped */ int err_id; ATTRIB attrib; int fb; unsigned int total_chars, nd_chars; int textf=0; /* 1 if the file seems to be text */ int fetch_size; unsigned long cur_pos=0; /* Current position in output file */ int lfn; unsigned long data_pos=0; unsigned long st_ticks=0; /* Start time (used for profiling) */ unsigned int bck_method; int ratio; char timetext[20]; char FAR *raw_eh; struct mempack mempack; int lfn_xlated; char ea_res[FILENAME_MAX]; int res_len=0; char FAR *ea_blk; struct ext_hdr FAR *p_eh; if(is_replace&&new_files_only) return(0); if(!match_attrib(&properties)) { error(M_SELECTION_ERROR); return(-1); } ts_store(&ftime, OS, properties.ftime); ts_store(&atime, OS, properties.atime); ts_store(&ctime, OS, properties.ctime); if(is_update&&!skip_ts_check) { fsize=properties.fsize; volume_file=arj_flags&VOLUME_FLAG||arj_flags&EXTFILE_FLAG; needs_skip=0; if(update_criteria==UC_NEW_OR_CRC||freshen_criteria==FC_CRC) { if(!volume_file&&fsize==origsize) { if(crc32_for_file(filename)==file_crc) needs_skip=1; } } else if(update_criteria==UC_NEW_OR_DIFFERENT||freshen_criteria==FC_DIFFERENT) { if(!volume_file&&!ts_cmp(&ftime_stamp, &ftime)&&fsize==origsize) needs_skip=1; } else if(update_criteria==UC_NEW_OR_OLDER||freshen_criteria==FC_OLDER) { if(ts_cmp(&ftime, &ftime_stamp)>=0) needs_skip=1; } else if(update_criteria==UC_NEW_OR_NEWER||freshen_criteria==FC_EXISTING) { if(ts_cmp(&ftime, &ftime_stamp)<=0) needs_skip=1; } if(needs_skip) { if(verbose_display) { msg_cprintf(H_HL|H_NFMT, M_NO_CHANGE, format_filename(filename)); } special_processing((total_chapters!=0)?CFA_MARK_INCREMENT:CFA_NONE, aistream); return(1); } } if(query_for_each_file) { msg_sprintf(misc_buf, is_update?M_QUERY_UPDATE:M_QUERY_ADD, filename); if(!query_action(REPLY_YES, QUERY_ARCH_OP, (char FAR *)misc_buf)) return(0); } if(is_replace) { if(total_chapters>0) special_processing(CFA_NONE, aistream); else skip_compdata(); if(multivolume_option) { total_files++; return(2); } } else { file_type=ARJT_BINARY; first_hdr_size=continued_prevvolume?FIRST_HDR_SIZE_V:STD_HDR_SIZE; if(lfn_supported!=LFN_NOT_SUPPORTED&&!skip_time_attrs) first_hdr_size=R9_HDR_SIZE; hdr_filename=&header[first_hdr_size]; hdr_filename[0]='\0'; calc_comment_offset(); hdr_comment[0]='\0'; } method=custom_method?method_specifier:1; uncompsize=properties.fsize; attrib=properties.attrib; if(clear_archive_bit) attrib&=~FATTR_RDONLY; garble_ftime=ts_native(&ftime, OS); if(type_override) { file_type=primary_file_type; if(*swptr_t!='\0') if(search_for_extension(filename, swptr_t)) file_type=secondary_file_type; } if(continued_prevvolume&&mvfile_type>=0) file_type=mvfile_type; if(!is_filename_valid(filename)) error(M_CANTOPEN, filename); if(properties.type==ARJT_DIR) file_type=ARJT_DIR; else if(properties.type==ARJT_UXSPECIAL) file_type=ARJT_UXSPECIAL; volume_flag_set=0; user_wants_fail=0; err_id=0; if(hollow_mode!=HM_NO_CRC) { if(file_type==ARJT_DIR||file_type==ARJT_UXSPECIAL) method=0; else if(file_type==ARJT_BINARY||file_type==ARJT_TEXT) { if(open_input_file()) return(0); current_bufsiz=jh_enabled?user_bufsiz:BUFSIZ_DEFAULT; if(file_type==ARJT_TEXT) { nd_chars=0; textf=1; fetch_size=CACHE_SIZE; total_chars=0; while((fb=fgetc(encstream))!=EOF) { if(fbTEXT_UCHAR) nd_chars++; total_chars++; if(total_chars>=fetch_size) break; } if(total_chars>0) rewind(encstream); /* Select files that meet size requirements... */ if(type_override=(unsigned long)MIN_TEXT_SIZE&& total_chars0L) uncompsize-=resume_position; } } if(store_by_suffix) if(search_for_extension(filename, archive_suffixes)) method=0; if(properties.fsize==0L) method=0; if(hollow_mode==HM_CRC) method=9; else if(hollow_mode==HM_NO_CRC) method=8; if(!no_file_activity) cur_pos=ftell(aostream); cur_time_stamp(&cur_time); password_modifier=(char)ts_native(&cur_time, OS); arj_flags=0; far_strcpyn(comment, (char FAR *)hdr_comment, COMMENT_MAX); if(continued_prevvolume&&first_hdr_size=MIN_TEXT_SIZE&&origsize*5L0) { if(!no_file_activity) file_chsize(aostream, cur_pos); msg_cprintf(H_HL, M_FSTAT_1); comment_entries++; origsize=0L; resume_position=0L; continued_prevvolume=0; return(1); } write_header(); if(!no_file_activity) fseek(aostream, data_pos, SEEK_SET); if(volume_flag_set) { resume_position+=origsize; continued_prevvolume=1; mvfile_type=file_type; } else { resume_position=0L; continued_prevvolume=0; } total_uncompressed+=origsize; total_compressed+=compsize; ratio=calc_percentage(compsize, origsize); if(!debug_enabled||strchr(debug_opt, 'x')==NULL) { msg_cprintf(H_HL, M_FSTAT_2, ratio/10, ratio%10); #if defined(HAVE_EAS) if(ea_supported&&!volume_flag_set&&ea_size!=0) msg_cprintf(H_HL, M_EA_STATS_STG, ea_size); #endif if(file_type==ARJT_UXSPECIAL&&eh_lookup(eh, UXSPECIAL_ID)!=NULL) { raw_eh=eh_lookup(eh, UXSPECIAL_ID)->raw; uxspecial_stats(raw_eh, UXSTATS_SHORT); } msg_cprintf(0, lf); } if(err_id==0&&user_wants_fail) { errors++; error_report(); write_index_entry(idxid_fault); } if(create_index) { if(detailed_index) { timestamp_to_str(timetext, &ftime_stamp); if(msg_fprintf(idxstream, M_IDX_FIELD, timetext, origsize, compsize, ratio/1000, ratio%1000, filename)<0) error(M_DISK_FULL); } else { if(msg_fprintf(idxstream, M_FILENAME_FORM, filename)<0) error(M_DISK_FULL); } } total_files++; if(host_os==OS_WIN95||host_os==OS_WINNT) total_longnames++; if(eh!=NULL) proc_ext_hdr(EHUF_COMMIT); return(1); } /* Packs a file, with statistics update */ int pack_file_stub(int is_update, int is_replace) { int rc; rc=pack_file(is_update, is_replace); if(rc==1) total_written+=origsize; else { total_size-=origsize; if(rc==-1) rc=0; } return(rc); } /* Inserts a chapter mark into the archive */ int create_chapter_mark() { if(multivolume_option&&get_volfree(MULTIVOLUME_INCREMENT)=ARJ_NEWCRYPT_VERSION&&ext_hdr_flags==0&&enc_type!=ENCRYPT_OLD) { encryption_id=ENCID_GARBLE; ext_hdr_flags=enc_type; } while(read_header(0, arc, name)) { msg_cprintf(H_HL, M_ADDING); msg_cprintf(H_HL|H_NFMT, M_FILENAME_FORM, filename); write_index_entry(nullstr); special_processing(CFA_NONE, arc); rc++; } cfa_store(i, FLFLAG_PROCESSED); } fclose(arc); } return(rc); } #endif /* Inserts base directory into filespec */ void add_base_dir(char *name) { #if SFX_LEVEL>=ARJ char *tmp; #else char tmp[FILENAME_MAX]; #endif if(target_dir[0]!='\0') { #if SFX_LEVEL>=ARJ tmp=malloc_str(name); strcpy(name, target_dir); strcat(name, tmp); free(tmp); #else strcpy(tmp, name); strcpy(name, target_dir); strcat(name, tmp); #endif } } /* Checks if the file can be unpacked */ static int test_unpack_condition(char *name) { int answer; /* Reply to overwrite/append queries */ int fr; struct timestamp ftime; unsigned long fsize; int volume_file; unsigned long append_pos; #if SFX_LEVEL>=ARJSFXV char *fname; /* Formatted name */ char arc_time[22], disk_time[22]; struct file_properties properties; #endif #if SFX_LEVEL>=ARJSFXV fname=format_filename(name); #endif if(!file_exists(name)) { #if SFX_LEVEL>=ARJSFXV if(freshen_criteria!=FC_NONE||continued_prevvolume) { #if SFX_LEVEL>=ARJ if(continued_prevvolume&&start_at_ext_pos&&ext_pos!=0L) { answer=yes_on_all_queries||skip_append_query; if(answer==0) { msg_cprintf(H_HL|H_NFMT, M_NOT_EXISTS, fname); answer=query_action(REPLY_YES, QUERY_APPEND, M_QUERY_CONTINUE); if(answer==1) { resume_position=0L; continued_prevvolume=0; create_subdir_tree(name, yes_on_all_queries, file_type); return(0); } } } #endif msg_cprintf(H_HL|H_NFMT, M_NOT_EXISTS, fname); return(1); } create_subdir_tree(name, yes_on_all_queries, file_type); return(0); #else if(freshen_criteria!=FC_NONE) { msg_cprintf(H_HL|H_NFMT, M_NOT_EXISTS, name); return(1); } else { create_subdir_tree(name, file_type); return(0); } #endif } #if SFX_LEVEL>=ARJSFXV fr=file_find(name, &properties); if(fr||(properties.type!=ARJT_DIR&& properties.type!=ARJT_BINARY&& properties.type!=ARJT_UXSPECIAL)) { msg_cprintf(H_ERR, M_CANTOPEN, name); msg_cprintf(0, (FMSG *)", "); return(2); } #endif if(new_files_only) { #if SFX_LEVEL>=ARJSFXV msg_cprintf(H_HL|H_NFMT, M_EXISTS, name); #else msg_cprintf(H_HL|H_NFMT, M_EXISTS, name); #endif return(1); } #if SFX_LEVEL>=ARJSFXV ts_store(&ftime, OS, properties.ftime); #else ts_store(&ftime, OS, file_getftime(name)); #endif if(!skip_ts_check) { #if SFX_LEVEL>=ARJ fsize=properties.fsize; volume_file=0; if(arj_flags&VOLUME_FLAG||arj_flags&EXTFILE_FLAG) { fsize=origsize; volume_file=1; } if(update_criteria==UC_NEW_OR_CRC||freshen_criteria==FC_CRC) { if(!volume_file&&fsize==origsize) { if(crc32_for_file(filename)==file_crc) { msg_cprintf(H_HL|H_NFMT, M_IS_SAME, fname); return(1); } } } else if(update_criteria==UC_NEW_OR_DIFFERENT||freshen_criteria==FC_DIFFERENT) { if(!ts_cmp(&ftime_stamp, &ftime)&&fsize==origsize) { msg_cprintf(H_HL|H_NFMT, M_IS_SAME, fname); return(1); } } else if(update_criteria==UC_NEW_OR_OLDER||freshen_criteria==FC_OLDER) { if(ts_cmp(&ftime, &ftime_stamp)<=0) { msg_cprintf(H_HL|H_NFMT, M_IS_SAME_OR_OLDER, fname); return(1); } } else if(update_criteria==UC_NEW_OR_NEWER||freshen_criteria==FC_EXISTING) { if(ts_cmp(&ftime, &ftime_stamp)>=0) { msg_cprintf(H_HL|H_NFMT, M_IS_SAME_OR_NEWER, fname); return(1); } } #else if(update_criteria!=UC_NONE&&freshen_criteria!=FC_NONE) { if(ts_cmp(&ftime, &ftime_stamp)>=0) { #if SFX_LEVEL>=ARJSFXV msg_cprintf(H_HL|H_NFMT, M_IS_SAME_OR_NEWER, fname); #else msg_cprintf(H_HL|H_NFMT, M_IS_SAME_OR_NEWER, name); #endif return(1); } } #endif } #if SFX_LEVEL>=ARJSFXV if(yes_on_all_queries&&!skip_ts_check&&continued_prevvolume&& (file_type==ARJT_TEXT||file_type==ARJT_BINARY)&&!ts_cmp(&ftime_stamp, &ftime)&& eh_find_pending(eh)!=NULL) { msg_cprintf(H_HL|H_NFMT, M_IS_NOT_SAME_DATE, fname); return(2); } #endif #if SFX_LEVEL>=ARJ if(serialize_exts!=EXT_NO_SERIALIZE) return(find_num_ext(name, serialize_exts)?2:0); if(arcmail_sw) return(find_arcmail_name(name)?2:0); #endif #if SFX_LEVEL>=ARJSFXV if(yes_on_all_queries) return(0); #else if(yes_on_all_queries||overwrite_existing) return(0); #endif /* Multivolume preprocessing */ #if SFX_LEVEL>=ARJSFXV #if SFX_LEVEL>=ARJ if(continued_prevvolume||start_at_ext_pos) #else if(continued_prevvolume) #endif { if(skip_append_query||(file_type!=ARJT_BINARY&&file_type!=ARJT_TEXT)) return(0); msg_cprintf(0, (!ts_cmp(&ftime_stamp, &ftime))?M_EXISTS:M_IS_NOT_SAME_DATE, fname); #if SFX_LEVEL>=ARJ append_pos=start_at_ext_pos?ext_pos:resume_position; #else append_pos=resume_position; #endif msg_sprintf(misc_buf, M_QUERY_APPEND, append_pos); return(query_action(REPLY_YES, QUERY_APPEND, (FMSG *)misc_buf)?0:-1); } #endif #if SFX_LEVEL>=ARJSFXV if(overwrite_existing /* ASR fix 31/03/2003: for new recursion order, skip directory overwrite prompt unless the user has specified "-2r". */ #if SFX_LEVEL>=ARJ ||(properties.type==ARJT_DIR&&!recursion_order) #endif ) return(0); timestamp_to_str(arc_time, &ftime_stamp); timestamp_to_str(disk_time, &ftime); msg_cprintf(H_HL|H_NFMT, M_ARJ_VS_DISK, origsize, arc_time+2, properties.fsize, disk_time+2); msg_cprintf(0, (ts_cmp(&ftime, &ftime_stamp)>=0)?M_IS_SAME_OR_NEWER:M_EXISTS, fname); return(query_action(REPLY_YES, QUERY_OVERWRITE, M_QUERY_OVERWRITE)?0:-1); #else msg_cprintf(0, (ts_cmp(&ftime_stamp, &ftime)>0)?M_EXISTS:M_IS_SAME_OR_NEWER, name); msg_cprintf(0, M_QUERY_OVERWRITE); return(query_action()?0:-1); #endif } #if SFX_LEVEL>=ARJSFXV /* Queries the user about renaming the file and performs neccessary checks */ static int query_for_rename(char *name) { if(!query_action(REPLY_YES, QUERY_EXTRACT_RENAME, M_QUERY_EXTRACT_RENAME)) { skip_file(); errors++; return(0); } if(kbd_cleanup_on_input) fetch_keystrokes(); msg_cprintf(0, M_ENTER_NEW_FILENAME); if(read_line(name, FILENAME_MAX)==0) { skip_file(); errors++; return(0); } #if SFX_LEVEL>=ARJ if(translate_unix_paths) unix_path_to_dos(name); #endif case_path(name); if(test_unpack_condition(name)) { skip_file(); errors++; return(0); } else return(1); } #endif /* Checks if the OS and current conditions allow unpacking */ #if SFX_LEVEL>=ARJ static int test_unpack_env(int disk_touched) #else static int test_unpack_env() #endif { /* The text below is NOT a typo, this check is really used in ARJSFXV (since headers may be damaged, and so on...) */ #if SFX_LEVEL>=ARJSFXV if(arj_x_nbr>EXTR_LEVEL) { msg_cprintf(H_HL|H_NFMT, M_UNKNOWN_VERSION, (int)arj_x_nbr); skip_file(); return(-1); } #endif if(file_garbled&&!garble_enabled) { #if SFX_LEVEL>=ARJSFXV msg_cprintf(0, M_FILE_IS_GARBLED); #else msg_cprintf(0, M_FILE_IS_GARBLED); #endif skip_file(); return(-1); } #if SFX_LEVEL>=ARJSFXV #if SFX_LEVEL>=ARJ if((method>MAXMETHOD&&method<8)||(method==MAXMETHOD&&arj_nbr==1)) #else if(method>3) #endif { /* ARJ 0.xx -m4 is not supported */ msg_cprintf(H_HL|H_NFMT, M_UNKNOWN_METHOD, (int)method); skip_file(); return(-1); } #if SFX_LEVEL>=ARJ if(file_type!=ARJT_BINARY&&file_type!=ARJT_TEXT&&file_type!=ARJT_DIR&& file_type!=ARJT_COMMENT&&file_type!=ARJT_LABEL&&file_type!=ARJT_CHAPTER&& file_type!=ARJT_UXSPECIAL) #else if(file_type!=ARJT_BINARY&&file_type!=ARJT_TEXT&&file_type!=ARJT_DIR&& file_type!=ARJT_LABEL&&file_type!=ARJT_UXSPECIAL) #endif { msg_cprintf(H_HL|H_NFMT, M_UNKNOWN_FILE_TYPE, file_type); skip_file(); return(-1); } #endif /* Check for ability to extract Windows 95 LFNs */ #if TARGET==DOS #if SFX_LEVEL>=ARJ if(disk_touched&&(host_os==OS_WIN95||host_os==OS_WINNT)) { if(lfn_supported==LFN_NOT_SUPPORTED&&lfn_mode<=LFN_NONE) { msg_cprintf(0, M_REQUIRES_WIN95); skip_file(); return(-1); } } #else if(host_os==OS_WIN95&&lfn_supported==LFN_NOT_SUPPORTED&&!process_lfn_archive) { #if SFX_LEVEL>=ARJSFXV msg_cprintf(0, M_REQUIRES_WIN95); #else msg_cprintf(0, M_REQUIRES_WIN95); #endif skip_file(); return(-1); } #endif #endif return(0); } /* Unpacks a single file (NOT the main extraction routine; see below) */ static void unpack_file(int action) { unsigned long st_ticks=0; #if SFX_LEVEL>=ARJSFXV uncompsize=origsize; #endif /* Verbose display option is missing from ARJSFXV but is supported by ARJSFX */ #if SFX_LEVEL==ARJSFX if(verbose_display) msg_cprintf(H_HL|H_NFMT, M_N_BYTES, origsize); #endif crc32term=CRC_MASK; #if SFX_LEVEL>=ARJSFXV if(debug_enabled&&strchr(debug_opt, 't')!=NULL) st_ticks=get_ticks(); #endif #if SFX_LEVEL>=ARJSFXV if(file_type==ARJT_BINARY||file_type==ARJT_TEXT) #else if(file_type!=ARJT_DIR&&file_type!=ARJT_UXSPECIAL) #endif { #if SFX_LEVEL>=ARJ if(hollow_mode==HM_CRC||method==9) hollow_decode(action); else if(method!=8&&test_archive_crc!=TC_ATTRIBUTES) { if(method==0) unstore(action); else if(method>=1&&method<=3) decode(action); else if(method==4) decode_f(action); } #else #if SFX_LEVEL<=ARJSFX garble_init(password_modifier); uncompsize=origsize; #endif if(method==0) unstore(action); else decode(action); #endif } display_indicator(uncompsize); #if SFX_LEVEL>=ARJSFXV skip_compdata(); #endif #if SFX_LEVEL>=ARJSFXV if(debug_enabled) { #if SFX_LEVEL>=ARJ if(strchr(debug_opt, 'k')!=NULL) compsize=0L; #endif if(strchr(debug_opt, 't')!=NULL) msg_cprintf(H_HL|H_NFMT, M_N_TICKS, st_ticks=get_ticks()-st_ticks); } #endif #if SFX_LEVEL<=ARJSFX if((crc32term^CRC_MASK)==file_crc) msg_cprintf(0, M_OK); else { msg_cprintf(H_ALERT, M_CRC_ERROR); errors++; } #endif } /* Test/search routine */ #if SFX_LEVEL>=ARJ int unpack_validation(int cmd) #else int unpack_validation() #endif { int action; #if SFX_LEVEL>=ARJSFXV int found; /* 1 if the file is present */ int errflag; int nf_error; /* Non-fatal error */ int pattern; /* Current search pattern */ #endif #if SFX_LEVEL>=ARJ struct file_properties properties; #endif #if SFX_LEVEL>=ARJ found=1; errflag=nf_error=0; pattern_found=0; identical_filedata=1; if(test_unpack_env(0)) return(0); #else if(test_unpack_env()) return(0); #endif #if SFX_LEVEL>=ARJ if(cmd==ARJ_CMD_WHERE) { action=BOP_SEARCH; msg_sprintf(misc_buf, M_SEARCHING, filename); if(search_mode==SEARCH_DEFAULT||search_mode==SEARCH_SHOW_NAMES) alltrim(misc_buf); if(search_mode<=SEARCH_BRIEF) { msg_cprintf(0, (FMSG *)strform, misc_buf); if(search_mode==SEARCH_DEFAULT) msg_cprintf(0, (FMSG *)lf); if(search_mode==SEARCH_BRIEF) msg_cprintf(0, (FMSG *)cr); } for(pattern=0; pattern=TC_CRC_AND_CONTENTS) { if(test_archive_crc==TC_CRC_AND_CONTENTS||total_chapters==0||((unsigned int)ext_flags<=total_chapters&&(unsigned int)chapter_number>=total_chapters)) { if(test_archive_crc!=TC_ADDED_FILES||flist_is_in_archive(&flist_main, filename)) { if(test_archive_crc!=TC_ADDED_FILES||total_chapters==0||(unsigned int)chapter_number==total_chapters) { if(method==8||test_archive_crc==TC_ATTRIBUTES) { action=BOP_COMPARE; if(file_find(filename, &properties)) found=0; } else { if(file_type==ARJT_BINARY||file_type==ARJT_TEXT) { action=BOP_COMPARE; if((tstream=file_open(filename, read_perms[file_type%2]))==NULL) { action=BOP_NONE; found=0; errflag=1; if((ignore_open_errors==IAE_ACCESS&&errno==EACCES)|| (ignore_open_errors==IAE_NOTFOUND&&errno==ENOENT)|| (ignore_open_errors==IAE_ALL&&(errno==EACCES||errno==ENOENT))) errflag=0; } else smart_seek(resume_position, tstream); } else if(file_type==ARJT_DIR) { if(!is_directory(filename)) { errflag=1; found=0; } } } } } } } } #else action=BOP_NONE; #if SFX_LEVEL>=ARJSFXV msg_cprintf(H_HL|H_NFMT, M_TESTING, format_filename(filename)); msg_cprintf(0, (FMSG *)vd_space); #else msg_cprintf(H_HL|H_NFMT, M_TESTING, filename); #endif #endif atstream=NULL; #if SFX_LEVEL>=ARJSFXV if(file_garbled) garble_init(password_modifier); #endif unpack_file(action); #if SFX_LEVEL>=ARJ if(!found) { msg_cprintf(0, M_NOT_FOUND); if(errflag) { if(errorlevel==ARJ_ERL_SUCCESS) errorlevel=ARJ_ERL_CRC_ERROR; errors++; } nf_error=1; } if(action==BOP_COMPARE&&(method==8||test_archive_crc==TC_ATTRIBUTES)) { compsize=0L; crc32term=file_crc^CRC_MASK; if(ts_native(&ftime_stamp, OS)==properties.ftime&&origsize==properties.fsize) msg_cprintf(0, M_MATCHED); else { if(verbose_display) { if(ts_native(&ftime_stamp, OS)!=properties.ftime) msg_cprintf(0, M_BY_DATE); if(origsize!=properties.fsize) msg_cprintf(0, M_BY_SIZE); } msg_cprintf(0, M_NOT_MATCHED); if(errorlevel==ARJ_ERL_SUCCESS) errorlevel=ARJ_ERL_CRC_ERROR; errors++; nf_error=1; } } else if(action==BOP_COMPARE) { if(verbose_display) { file_find(filename, &properties); if(ts_native(&ftime_stamp, OS)!=properties.ftime) msg_cprintf(0, M_BY_DATE); if(origsize!=properties.fsize) msg_cprintf(0, M_BY_SIZE); } if(identical_filedata&&!volume_flag_set&&fgetc(tstream)==EOF) msg_cprintf(0, M_MATCHED); else if(identical_filedata&&volume_flag_set) msg_cprintf(0, M_MATCHED); else { if(verbose_display) msg_cprintf(0, M_BY_DATA); msg_cprintf(0, M_NOT_MATCHED); if(errorlevel==ARJ_ERL_SUCCESS) errorlevel=ARJ_ERL_CRC_ERROR; errors++; nf_error=1; } fclose(tstream); } #endif #if SFX_LEVEL>=ARJSFXV if(file_crc==(crc32term^CRC_MASK)&&compsize==0L) { #if SFX_LEVEL>=ARJ if(cmd!=ARJ_CMD_WHERE) msg_cprintf(0, M_OK); #else msg_cprintf(0, M_OK); #endif } else { msg_cprintf(H_ALERT, M_CRC_ERROR); if(errorlevel==ARJ_ERL_SUCCESS) errorlevel=ARJ_ERL_CRC_ERROR; errors++; #if SFX_LEVEL>=ARJ nf_error=1; #endif } #endif #if SFX_LEVEL>=ARJ if(cmd==ARJ_CMD_WHERE) { for(pattern=0; pattern0) { nf_error=1; msg_cprintf(H_OPER, M_FOUND_N_OCCURENCES, search_occurences[pattern], search_str[pattern]); } } } if(nf_error) write_index_entry(idxid_fault); return(((pattern_found&&extm_mode==EXTM_MATCHING)||(!pattern_found&&extm_mode==EXTM_MISMATCHING))?2:1); #endif #if SFX_LEVEL<=ARJSFXV return(1); #endif } #if SFX_LEVEL>=ARJ /* Checks filename upon extraction */ static int extract_fn_proc() { char tmp_name[FILENAME_MAX], efn[FILENAME_MAX]; int entry; skip_compdata(); strcpy(tmp_name, filename); entry=entry_pos; if(subdir_extraction) { strcpy(efn, target_dir); default_case_path(efn+strlen(efn), tmp_name+(exclude_paths?left_trim:0)); } else { strcpy(efn, target_dir); strcat(efn, tmp_name+entry); } if(!file_exists(efn)) { msg_cprintf(H_HL|H_NFMT, M_SKIPPED, efn); errors++; write_index_entry(idxid_fault); return(0); } if(show_filenames_only||!strcmp_os(filename, efn)) msg_cprintf(H_HL|H_NFMT, M_RESTORING_PROPERTIES, efn); else { msg_cprintf(H_HL|H_NFMT, M_RESTORING_PROPERTIES, format_filename(filename)); msg_cprintf(H_HL|H_NFMT, M_TO, format_filename(efn)); } if(!test_host_os((int)host_os)&&file_type==ARJT_BINARY) msg_cprintf(0, M_FOREIGN_BINARY); nputlf(); if(test_host_os((int)host_os)&&(hollow_mode==HM_RESTORE_ATTRS||hollow_mode==HM_RESTORE_ALL)) dos_chmod(efn, file_mode.native); if(hollow_mode==HM_RESTORE_DATES||hollow_mode==HM_RESTORE_ALL) { file_setftime(efn, ts_native(&ftime_stamp, OS)); if(lfn_supported!=LFN_NOT_SUPPORTED&&ts_valid(atime_stamp)) { file_setctime(efn, ts_native(&ctime_stamp, OS)); file_setatime(efn, ts_native(&atime_stamp, OS)); } } return(1); } #endif #if SFX_LEVEL>=ARJSFXV /* Allocates memory for and unpacks extended attributes */ char FAR *unpack_ea(struct ext_hdr FAR *eh) { char FAR *raw_eh; struct mempack mempack; unsigned char p_modifier; char FAR *ea_blk; p_modifier=password_modifier; password_modifier=ea_pwd_modifier; ea_blk=eh->raw; mempack.origsize=(unsigned int)((unsigned char)ea_blk[2])*256U+(unsigned char)ea_blk[1]; raw_eh=(char FAR *)farmalloc_msg(mempack.origsize); mempack.compsize=eh->size-3; mempack.method=ea_blk[0]; mempack.comp=ea_blk+3; mempack.orig=raw_eh; unpack_mem(&mempack); password_modifier=p_modifier; return(raw_eh); } #endif /* Unpacks a single file */ #if SFX_LEVEL>=ARJ int unpack_file_proc(int to_console, FILE_COUNT num) #else int unpack_file_proc() #endif { #if SFX_LEVEL>=ARJSFXV int action; /* Passed to the decoding routines */ int disk_touched; /* Indicates if the output is directed to a file, not to console */ char *fname; /* Formatted filename */ unsigned long tmp_compsize; unsigned long cur_pos; unsigned long alloc_size; /* Size of file rounded up to the next allocation unit boundary */ struct ext_hdr FAR *p_eh; int uxspec_rc; #endif char tmp_name[FILENAME_MAX]; char FAR *raw_eh; #if SFX_LEVEL>=ARJSFXV char out_name[FILENAME_MAX]; int tmp_entry, out_entry; char subdir[8]; int dir_num; int trim; unsigned long tmp_crc; #endif #if SFX_LEVEL>=ARJ action=BOP_NONE; #endif #if SFX_LEVEL>=ARJSFXV if(!handle_labels&&file_type==ARJT_LABEL) { skip_compdata(); return(0); } #endif #if SFX_LEVEL>=ARJ disk_touched=!to_console; if(!debug_enabled||strchr(debug_opt, 'x')==NULL) { if(hollow_mode>HM_NO_CRC) return(extract_fn_proc()); if(method==8||method==9||test_unpack_env(disk_touched)) { errors++; write_index_entry(idxid_fault); return(0); } } #else if(test_unpack_env()) { #if SFX_LEVEL>=ARJSFXV errors++; #endif return(0); } #endif #if SFX_LEVEL>=ARJ if(file_type==ARJT_CHAPTER) { fname=format_filename(filename); msg_cprintf(H_HL|H_NFMT, M_EXTRACTING, fname); msg_cprintf(0, (FMSG *)vd_space); msg_cprintf(0, M_OK); } else { #endif #if SFX_LEVEL>=ARJ if(extm_mode!=EXTM_NONE) { tmp_compsize=compsize; cur_pos=ftell(aistream); if(unpack_validation(ARJ_CMD_WHERE)!=2) return(0); fseek(aistream, cur_pos, SEEK_SET); compsize=tmp_compsize; } #endif #if SFX_LEVEL>=ARJSFXV if(chk_free_space) { alloc_size=((origsize+(unsigned long)alloc_unit_size-1L)/(unsigned long)alloc_unit_size)*(unsigned long)alloc_unit_size; if(file_getfree(target_dir)=ARJ msg_cprintf(0, M_NOT_ENOUGH_SPACE); #else msg_sprintf(misc_buf, M_NOT_ENOUGH_SPACE, filename); if(!query_action(REPLY_YES, QUERY_CRITICAL, (FMSG *)misc_buf)) exit(ARJSFX_ERL_ERROR); #endif skip_file(); errors++; #if SFX_LEVEL>=ARJ write_index_entry(idxid_fault); #endif return(0); } } #endif #if SFX_LEVEL>=ARJSFXV #if SFX_LEVEL>=ARJ if(execute_cmd&&file_type!=ARJT_BINARY&&file_type!=ARJT_TEXT) return(0); strcpy(tmp_name, filename); tmp_entry=entry_pos; if(to_console) { if(comment_display==CMTD_PCMD) action=BOP_DISPLAY; atstream=stdout; file_settype(atstream, file_type); if(!help_issued) msg_cprintf(H_NFMT, M_EXTRACTING_1_TO_2, format_filename(filename), "STDOUT"); } else { #endif if(file_type==ARJT_LABEL) { #ifdef HAVE_DRIVES #if SFX_LEVEL>=ARJ msg_cprintf(H_HL|H_NFMT, M_EXTRACTING, fname=format_filename(filename)); #else msg_cprintf(H_HL|H_NFMT, M_EXTRACTING, format_filename(filename)); #endif msg_cprintf(0, (FMSG *)vd_space); if(!file_setlabel(filename, label_drive, file_mode.native, ts_native(&ftime_stamp, OS))) { msg_cprintf(0, M_OK); return(1); } else { msg_cprintf(0, M_SET_LABEL_ERROR); errors++; #if SFX_LEVEL>=ARJ write_index_entry(idxid_fault); #endif return(0); } #else skip_file(); #endif } #if SFX_LEVEL>=ARJ if((host_os==OS_WIN95||host_os==OS_WINNT)&&lfn_mode==LFN_DUAL_EXT) { msg_sprintf(tmp_name, M_WIN95_LFN_TRANSL, (int)(num%1000)); tmp_entry=split_name(tmp_name, NULL, NULL); } subdir[0]='\0'; if(current_chapter!=chapter_to_process) { dir_num=(int)max(ext_flags, current_chapter); sprintf(subdir, "%03d%c", dir_num, PATHSEP_DEFAULT); } #endif if(extract_to_file) strcpy(out_name, extraction_filename); else { if(lowercase_names) { #if SFX_LEVEL>=ARJ strlower(tmp_name); #else strlower(filename); #endif } #if SFX_LEVEL>=ARJ if(subdir_extraction) #else if(!subdir_extraction) #endif { strcpy(out_name, (target_dir[0]=='\0')?nullstr:target_dir); #if SFX_LEVEL>=ARJ strcat(out_name, subdir); out_entry=strlen(out_name); trim=exclude_paths?left_trim:0; default_case_path(out_name+out_entry, tmp_name+trim); #else strcat(out_name, filename); #endif } else { strcpy(out_name, target_dir); #if SFX_LEVEL>=ARJ strcat(out_name, subdir); strcat(out_name, tmp_name+tmp_entry); #else strcat(out_name, filename+entry_pos); #endif } } if(continued_prevvolume&&ofstream!=NULL) { crc32term=CRC_MASK; crc32_for_string(filename+entry_pos); if(crc32term!=volume_crc) error(M_INVALID_MV_SEQ); far_strcpy((char FAR *)tmp_tmp_filename, tmp_filename); atstream=ofstream; ofstream=NULL; tmp_filename[0]='\0'; } else { disk_touched=test_unpack_condition(out_name); if(disk_touched) { if(disk_touched==1||disk_touched==2||skip_rename_prompt) { if(disk_touched==2) errors++; skip_file(); #if SFX_LEVEL>=ARJ write_index_entry(idxid_fault); #endif return(0); } else { if(!query_for_rename(out_name)) { #if SFX_LEVEL>=ARJ write_index_entry(idxid_fault); #endif return(0); } } } if(file_type==ARJT_BINARY||file_type==ARJT_TEXT) { cycle:; #if SFX_LEVEL>=ARJ if(clear_archive_bit) dos_chmod(out_name, STD_FATTR_NOARCH); #else if(overwrite_ro) dos_chmod(out_name, STD_FATTR_NOARCH); #endif #if SFX_LEVEL>=ARJ atstream=file_open(out_name, (continued_prevvolume||ext_pos>0L)?sim_perms[file_type%2]:write_perms[file_type%2]); #else atstream=file_open(out_name, continued_prevvolume?sim_perms[file_type%2]:write_perms[file_type%2]); #endif if(atstream!=NULL&&!extract_to_file&&is_file(atstream)) { file_close(atstream); atstream=NULL; } if(atstream==NULL) { #if SFX_LEVEL>=ARJ error_report(); #endif msg_cprintf(H_ERR, M_CANTOPEN, out_name); nputlf(); if(yes_on_all_queries||skip_rename_prompt) { skip_file(); errors++; #if SFX_LEVEL>=ARJ write_index_entry(idxid_fault); #endif return(0); } if(!query_for_rename(out_name)) { #if SFX_LEVEL>=ARJ write_index_entry(idxid_fault); #endif return(0); } else goto cycle; } #if SFX_LEVEL>=ARJ if(start_at_ext_pos) { fseek(atstream, 0L, SEEK_END); if(ftell(atstream)>ext_pos) fseek(atstream, ext_pos, SEEK_SET); } else smart_seek(resume_position, atstream); #else smart_seek(resume_position, atstream); #endif } strcpy(tmp_tmp_filename, out_name); } if(show_filenames_only||!strcmp_os(filename, tmp_tmp_filename)) msg_cprintf(H_HL|H_NFMT, M_EXTRACTING, format_filename(filename)); else { strcpy(out_name, format_filename(tmp_tmp_filename)); msg_cprintf(H_HL|H_NFMT, M_EXTRACTING_1_TO_2, format_filename(filename), out_name); } #if SFX_LEVEL>=ARJ if((continued_prevvolume||start_at_ext_pos)&&eh_find_pending(eh)==NULL) #elif SFX_LEVEL>=ARJSFXV if(continued_prevvolume&&eh_find_pending(eh)==NULL) #else if(continued_prevvolume) #endif msg_cprintf(H_HL|H_NFMT, M_AT_POSITION_N, ftell(atstream)); #if SFX_LEVEL>=ARJ } #endif #endif /* For ARJSFX, use a simplified algorithm... */ #if SFX_LEVEL==ARJSFX if(test_unpack_env()) return(0); strcpy(tmp_name, target_dir); strcat(tmp_name, test_mode?filename:list_adapted_name); if(test_unpack_condition(tmp_name)) { skip_file(); return(0); } strcpy(tmp_tmp_filename, tmp_name); if(file_type!=ARJT_DIR&&file_type!=ARJT_UXSPECIAL) { if((atstream=file_open(tmp_tmp_filename, write_perms[file_type%2]))==NULL) { msg_cprintf(H_ERR, M_CANTOPEN, tmp_tmp_filename); fputc(LF, stdout); skip_file(); errors++; return(0); } } if(strcmp_os(filename, tmp_tmp_filename)) msg_cprintf(H_HL|H_NFMT, M_EXTRACTING_1_TO_2, filename, tmp_tmp_filename); else msg_cprintf(H_HL|H_NFMT, M_EXTRACTING, filename); if(verbose_display) { if(file_type==ARJT_BINARY&&!test_host_os(host_os)) msg_cprintf(0, M_FOREIGN_BINARY); else fputc(LF, stdout); msg_cprintf(0, method==0?M_UNSTORING:M_UNCOMPRESSING); } unpack_file(BOP_NONE); if(file_type!=ARJT_DIR&&file_type!=ARJT_UXSPECIAL) fclose(atstream); file_setftime(tmp_tmp_filename, ts_native(&ftime_stamp, OS)); if(test_host_os(host_os)) dos_chmod(tmp_tmp_filename, file_mode.native); atstream=NULL; #endif /* ...and the rest may be safely omitted for ARJSFX modules */ #if SFX_LEVEL>=ARJSFXV if(!test_host_os((int)host_os)&&file_type==ARJT_BINARY) msg_cprintf(0, M_FOREIGN_BINARY); #if SFX_LEVEL>=ARJ if(!verbose_display) msg_cprintf(0, (FMSG *)vd_space); else { nputlf(); if(method==0) msg_cprintf(0, M_UNSTORING); else msg_cprintf(H_HL|H_NFMT, M_UNCOMPRESSING, method); msg_cprintf(H_HL|H_NFMT, M_N_BYTES, origsize); } #else msg_cprintf(0, (FMSG *)vd_space); #endif if(file_garbled) garble_init(password_modifier); #if SFX_LEVEL<=ARJSFXV action=BOP_NONE; #endif if(print_with_more) action=BOP_LIST; unpack_file(action); tmp_crc=crc32term^CRC_MASK; #if SFX_LEVEL>=ARJ if(to_console) { file_settype(atstream, ARJT_TEXT); /* This way, pipe redirections can't be tracked under UNIX, e.g. "arj p test.arj myfile>newfile" will not set the timestamp of newfile to the one of test.arj->myfile. */ #if TARGET!=UNIX file_setftime_on_stream(atstream, ts_native(&ftime_stamp, OS)); #endif atstream=NULL; } else { #endif if(volume_flag_set) { ofstream=atstream; atstream=NULL; crc32term=CRC_MASK; crc_for_string(filename+entry_pos); volume_crc=crc32term; far_strcpy(tmp_filename, (char FAR *)tmp_tmp_filename); volume_ftime=ftime_stamp; msg_cprintf(0, M_CONTINUED_NEXTVOL); } else { if(file_type==ARJT_BINARY||file_type==ARJT_TEXT) { fclose(atstream); atstream=NULL; } /* Process the extended header information */ if(valid_ext_hdr) { /* Create UNIX special files if able to */ #if TARGET==UNIX if(file_type==ARJT_UXSPECIAL&&(p_eh=eh_lookup(eh, UXSPECIAL_ID))!=NULL) { raw_eh=p_eh->raw; /* No unpacking, etc. (for now) */ if((uxspec_rc=set_uxspecial(raw_eh, tmp_tmp_filename))!=0) { switch(uxspec_rc) { #if TARGET==UNIX case UXSPEC_RC_FOREIGN_OS: msg_cprintf(H_ALERT, M_FOREIGN_SYSTEM); break; case UXSPEC_RC_NOLINK: msg_cprintf(H_ALERT, M_NO_LINKING); break; #if SFX_LEVEL>=ARJ case UXSPEC_RC_SUPPRESSED: msg_cprintf(H_ALERT, M_UXSPEC_SUPPRESSED); break; #endif #endif default: msg_cprintf(H_ERR, M_CANT_SET_UXSPECIAL); break; } if(errorlevel==ARJ_ERL_SUCCESS) errorlevel=ARJ_ERL_WARNING; } else uxspecial_stats(raw_eh, UXSTATS_SHORT); } #else if(file_type==ARJT_UXSPECIAL) { msg_cprintf(H_ALERT, M_UXSPECIAL_UNSUPP); msg_cprintf(0, (FMSG *)vd_space); } #endif /* Restore the file owner */ #if TARGET==UNIX if(((p_eh=eh_lookup(eh, OWNER_ID))!=NULL|| (p_eh=eh_lookup(eh, OWNER_ID_NUM))!=NULL) #if SFX_LEVEL>=ARJ &&do_chown #endif ) { raw_eh=p_eh->raw; /* No unpacking, etc. (for now) */ if(set_owner(raw_eh, tmp_tmp_filename, (p_eh->tag==OWNER_ID))) { msg_cprintf(H_ERR, M_CANT_CHOWN); if(errorlevel==ARJ_ERL_SUCCESS) errorlevel=ARJ_ERL_WARNING; } } #endif /* Deflate and store the extended attributes */ #ifdef HAVE_EAS if(ea_supported&&(p_eh=eh_lookup(eh, EA_ID))!=NULL) { raw_eh=unpack_ea(p_eh); if(set_ea(raw_eh, tmp_tmp_filename)) { msg_cprintf(H_ALERT, M_CANT_SET_EA); if(errorlevel==ARJ_ERL_SUCCESS) errorlevel=ARJ_ERL_WARNING; } else { ea_size=get_ea_size(tmp_tmp_filename); if(ea_size>0) { msg_cprintf(H_HL, M_EA_STATS_STG, ea_size); msg_cprintf(0, (FMSG *)vd_space); } } farfree(raw_eh); } #endif } /* Set the timestamps, since the file won't be affected by any modifications anymore */ file_setftime(tmp_tmp_filename, ts_native(&ftime_stamp, OS)); if(lfn_supported!=LFN_NOT_SUPPORTED&&ts_valid(atime_stamp)) { file_setctime(tmp_tmp_filename, ts_native(&ctime_stamp, OS)); file_setatime(tmp_tmp_filename, ts_native(&atime_stamp, OS)); } /* Finalize by restoring the attirbutes */ if(test_host_os(host_os)&&!execute_cmd) { #if SFX_LEVEL>=ARJ if(filter_fa_arch<=FAA_RESTORE_CLEAR) dos_chmod(tmp_tmp_filename, file_mode.native); if(filter_fa_arch==FAA_RESTORE_CLEAR||filter_fa_arch==FAA_EXCL_CLEAR) dos_clear_arch_attr(tmp_tmp_filename); #else dos_chmod(tmp_tmp_filename, file_mode.native); #endif } } #if SFX_LEVEL>=ARJ } #endif if(tmp_crc==file_crc&&compsize==0L) { #if SFX_LEVEL>=ARJ if(!help_issued) { msg_cprintf(0, M_OK); write_index_entry(((host_os==OS_WIN95||host_os==OS_WINNT)&&lfn_mode==LFN_DUAL_EXT)?tmp_name:nullstr); } #else msg_cprintf(0, M_OK); #endif } else { if(!print_with_more) { msg_cprintf(H_ALERT, M_CRC_ERROR); if(errorlevel==ARJ_ERL_SUCCESS) errorlevel=ARJ_ERL_CRC_ERROR; errors++; if(!ignore_crc_errors) { file_unlink(tmp_tmp_filename); tmp_tmp_filename[0]='\0'; return(0); } #if SFX_LEVEL>=ARJ else write_index_entry(idxid_fault); #endif } } #if SFX_LEVEL>=ARJ if(execute_cmd) { exec_cmd(cmd_to_exec); file_unlink(tmp_tmp_filename); } #endif #endif tmp_tmp_filename[0]='\0'; #if SFX_LEVEL>=ARJ } #endif return(1); } /* Looks for the requested file in the filelist */ #if SFX_LEVEL>=ARJ FILE_COUNT flist_lookup(FILE_COUNT tag) #else FILE_COUNT flist_lookup() #endif { char tmp_name[FILENAME_MAX]; FILE_COUNT i; int tmp_entry; #if SFX_LEVEL>=ARJSFXV int flag; char *nptr; int lp_entry, st_entry; char lp_name[FILENAME_MAX], st_name[FILENAME_MAX]; FILE_COUNT num, ubound; /* For by-number tagging */ int n_st, n_tmp; #endif #if SFX_LEVEL>=ARJ if(add_command&&total_chapters!=0&&chapter_number=ARJSFXV for(i=0; i=ARJ if((!add_command||flag==FLFLAG_TO_PROCESS)&& (!order_command||flag==FLFLAG_TO_PROCESS)&& (flag==FLFLAG_TO_PROCESS||flag==FLFLAG_PROCESSED)) #else if(flag==FLFLAG_TO_PROCESS||flag==FLFLAG_PROCESSED) #endif { #if SFX_LEVEL>=ARJ flist_retrieve(tmp_name, NULL, &flist_main, i); #else retrieve_entry(tmp_name, &flist_main, i); #endif #if SFX_LEVEL>=ARJ if(add_command) { if(debug_enabled&&strchr(debug_opt, 'y')!=NULL) { strcpy(lp_name, tmp_name); strcpy(st_name, filename); } else { default_case_path(lp_name, tmp_name); default_case_path(st_name, filename); } tmp_entry=split_name(lp_name, NULL, NULL); st_entry=split_name(st_name, NULL, NULL); if(exclude_paths==EP_PATH) { if(match_wildcard(st_name, lp_name+tmp_entry)) return(i+1); } else if(tmp_entry-lp_entry==st_entry) { if(!strncmp_os(st_name, lp_name+lp_entry, st_entry)) { if(match_wildcard(st_name+st_entry, lp_name+tmp_entry)) return(i+1); } } } else { #endif #if SFX_LEVEL>=ARJ if(debug_enabled&&strchr(debug_opt, 'y')!=NULL) { default_case_path(lp_name, tmp_name); default_case_path(st_name, filename); } else { #endif strcpy(lp_name, tmp_name); strcpy(st_name, filename); #if SFX_LEVEL>=ARJ } #endif tmp_entry=split_name(lp_name, NULL, NULL); st_entry=split_name(st_name, NULL, NULL); #if SFX_LEVEL>=ARJ if(select_by_number) { nptr=tmp_name; num=(unsigned int)strtoul(nptr, &nptr, 10); if(num==tag) return(i+1); if(*nptr=='-') { nptr++; ubound=(unsigned int)strtoul(nptr, &nptr, 10); if(ubound==0) ubound=EXT_FILELIST_CAPACITY; if(num<=tag&&tag<=ubound) return(i+1); } } else { if(total_chapters!=0) { if(current_chapter==RESERVED_CHAPTER&&(int)ext_flags==total_chapters&&(int)chapter_number==total_chapters) return(0); if(current_chapter==0&&(int)ext_flags<=total_chapters&&(int)chapter_numberchapter_to_process||(int)chapter_number=ARJ } #endif #if SFX_LEVEL>=ARJ } #endif } } #else for(i=0; i=ARJ /* Deletes a file from the archive */ int arcv_delete(FILE_COUNT num) { char del_action; unsigned long cur_pos; if(query_for_each_file) { msg_sprintf(misc_buf, M_QUERY_DELETE, filename); if(!query_action(REPLY_YES, QUERY_ARCH_OP, (char FAR *)misc_buf)) return(0); } if(file_type==ARJT_CHAPTER&&chapter_number!=0&&chapter_mode!=CHAP_NONE&¤t_chapter<=CHAPTERS_MAX) return(0); del_action=1; if(delete_processed==DP_EXTRACT) { cur_pos=(unsigned long)ftell(aistream); if(!unpack_file_proc(0, num)) { fseek(aistream, cur_pos, SEEK_SET); return(0); } } else { if(!destfile_extr_validation()) return(0); if(total_chapters!=0&¤t_chapter==RESERVED_CHAPTER&&(int)chapter_number==total_chapters) { special_processing(CFA_MARK, aistream); del_action=0; } else { if((total_chapters!=0&¤t_chapter==RESERVED_CHAPTER&&(int)chapter_number0) error(M_FOUND_N_ERRORS, errors); } #endif arj-3.10.22/arj_arcv.h 666 0 0 3232 7450456542 10600 0ustar /* * $Id: arj_arcv.h,v 1.1.1.1 2002/03/28 00:01:38 andrew_belov Exp $ * --------------------------------------------------------------------------- * Prototypes of the functions located in ARJ_ARCV.C are declared here. * */ #ifndef ARJ_ARCV_INCLUDED #define ARJ_ARCV_INCLUDED /* Header sizes */ #define STD_HDR_SIZE 30 /* Size of standard header */ #define R9_HDR_SIZE 46 /* Minimum size of header that holds DTA/DTC */ /* Prototypes */ long find_header(int search_all, FILE *stream); #if SFX_LEVEL>=ARJSFXV int read_header(int first, FILE *stream, char *name); #else int read_header(int first); #endif void create_header(int first); void write_header(); int rename_file(); int supply_comment(char *cmtname, char *name); void fill_archive_header(); void final_header(int operation); void skip_compdata(); void skip_file(); void arjdisp_scrn(unsigned long bytes); void special_processing(int action, FILE *stream); void init_packing(unsigned long offset, int is_mv); int pack_file(int is_update, int is_replace); int pack_file_stub(int is_update, int is_replace); int create_chapter_mark(); int store_label(); FILE_COUNT copy_archive(); void add_base_dir(char *name); #if SFX_LEVEL>=ARJ int unpack_validation(int cmd); #else int unpack_validation(); #endif char FAR *unpack_ea(struct ext_hdr FAR *eh); #if SFX_LEVEL>=ARJ int unpack_file_proc(int to_console, FILE_COUNT num); #else int unpack_file_proc(); #endif #if SFX_LEVEL>=ARJ FILE_COUNT flist_lookup(FILE_COUNT tag); #else FILE_COUNT flist_lookup(); #endif int arcv_delete(FILE_COUNT num); void tmp_archive_cleanup(); void archive_cleanup(); #endif arj-3.10.22/arj_file.c 666 0 0 75125 10256070050 10611 0ustar /* * $Id: arj_file.c,v 1.10 2005/06/21 19:53:13 andrew_belov Exp $ * --------------------------------------------------------------------------- * Various archive-management functions (mostly, file-related ones) are stored * here. * */ #include "arj.h" DEBUGHDR(__FILE__) /* Debug information block */ /* Character used in counters */ #if TARGET!=UNIX #define COUNTER_CHAR 0xB2 #else #define COUNTER_CHAR '#' #endif #define UNDISP_CHAR '?' /* Replaces nonprintable characters */ /* Local variables */ static char reply_help[]="?"; /* Request for help */ #if SFX_LEVEL>=ARJ static char ext_digits[]=".%03d"; /* Pattern used to serialize extensions */ #endif /* Counter formatting sequences */ #if SFX_LEVEL>=ARJSFXV static char del_single[]="\b\b\b\b\b"; static char del_double[]="\b\b\b\b\b\b\b\b\b\b"; static char sfmt_single[]=" %s"; static char sfmt_double[]=" %s"; static char sfmt_bytes[]="%10ld%s"; static char sfmt_start_graph[]=" 0%%%s"; static char sfmt_numeric[]="%4d%%%s"; #if SFX_LEVEL>=ARJ static char sfmt_start_num[]=" %d%%"; #if TARGET!=UNIX static char sfmt_graph[]="þþþþþþþþþþ%s"; static char sfmt_mid_graph[]="þþþþþ%s"; #else static char sfmt_graph[]="..........%s"; static char sfmt_mid_graph[]=".....%s"; #endif static char sfmt_short_numeric[]="%4d%%"; #endif #else static char sfmt_sfx[]="%4d%%\b\b\b\b\b"; #endif /* Local forward-referenced functions */ static int display_block(char *str, int len); static int block_op(int action, char *block, int len); #if SFX_LEVEL>=ARJSFXV /* Closes the file given */ int file_close(FILE *stream) { if(stream!=NULL) return(fclose(stream)); else return(-1); } /* Opens a file, possibly clearing its FA_ARCH attribute (read-only modes are not affected) */ FILE *file_open_noarch(char *name, char *mode) { FILE *stream; #if TARGET!=UNIX if(clear_archive_bit&&(mode[0]=='w'||mode[0]=='a'||mode[1]=='+'||mode[2]=='+')) dos_chmod(name, STD_FATTR_NOARCH); #endif if((stream=file_open(name, mode))==NULL) error(M_CANTOPEN, name); return(stream); } #endif #if SFX_LEVEL>=ARJ /* Overwrites a file, querying user if it exists */ FILE *file_create(char *name, char *mode) { if(file_exists(name)) { if(!yes_on_all_queries&&!overwrite_existing) { msg_cprintf(0, M_EXISTS, name); if(!query_action(REPLY_YES, QUERY_OVERWRITE, M_QUERY_OVERWRITE)) error(M_CANTOPEN, name); } #if TARGET!=UNIX if(clear_archive_bit&&(mode[0]=='w'||mode[0]=='a'||mode[1]=='+'||mode[2]=='+')) dos_chmod(name, STD_FATTR_NOARCH); #endif } return(file_open(name, mode)); } #endif #ifndef REARJ /* Reads a byte from the file */ int fget_byte(FILE *stream) { int buffer; buffer=fgetc(stream); if(buffer==EOF) { if(ignore_archive_errors) { #if SFX_LEVEL>=ARJSFXV msg_cprintf(H_ERR, M_CANTREAD); #else msg_cprintf(H_ERR, M_CANTREAD); #endif return(0); } else error(M_CANTREAD); } return(buffer&0xFF); } /* Reads two bytes from the file */ unsigned int fget_word(FILE *stream) { unsigned int b0, b1; b0=fget_byte(stream); b1=fget_byte(stream); return((b1<<8)|b0); } /* Reads four bytes from the file */ unsigned long fget_longword(FILE *stream) { unsigned int w0, w1; w0=fget_word(stream); w1=fget_word(stream); return(((unsigned long)w1<<16)|(unsigned long)w0); } /* Reads a block from the file, updating CRC */ int fread_crc(char *buffer, int count, FILE *stream) { int n; n=fread(buffer, 1, count, stream); if(n>0) { origsize+=(unsigned long)n; crc_for_block((char *)buffer, n); } return(n); } #endif #if SFX_LEVEL>=ARJ /* Writes a block, updating the CRC term */ void fwrite_crc(char *buffer, int count, FILE *stream) { crc_for_block(buffer, count); if(stream!=NULL) file_write(buffer, 1, count, stream); } #endif #ifndef REARJ /* Processes the given block upon extraction. Returns a nonzero value if the extraction is to be terminated. */ int extraction_stub(char *block, int block_len, int action) { char c; char *block_ptr; int cn; #if SFX_LEVEL>=ARJ if(!debug_enabled||strchr(debug_opt, 'c')==NULL) crc_for_block(block, block_len); #else crc32_for_block(block, block_len); #endif if(!file_packing) /* Not applicable for memory data */ { if(encmem_limit=ARJ if(action==BOP_LIST||action==BOP_SEARCH||action==BOP_COMPARE||action==BOP_DISPLAY) return(block_op(action, block, block_len)); #endif if(atstream==NULL) return(0); /* Strip high bit from files created by different OS */ if(file_type==ARJT_TEXT&&host_os!=OS #if SFX_LEVEL>=ARJ &&type_override!=FT_BINARY #endif ) { block_ptr=block; while(block_len-->0) { c=*(block_ptr++); c&=0x7F; if(fputc((int)c, atstream)==EOF) error(M_DISK_FULL); } } else { /* HACK for IBM LIBC implementations under 32-bit OS/2 */ #if SFX_LEVEL>=ARJSFXV&&TARGET==OS2&&(COMPILER==ICC||defined(LIBC)) int fn=fileno(atstream); if(fn<6) { _setmode(fn, file_type?0x4000:0x8000); /* O_TEXT:O_BINARY */ cn=write(fn, block, block_len); } else cn=fwrite(block, 1, block_len, atstream); #else cn=fwrite(block, 1, block_len, atstream); #endif #if SFX_LEVEL>=ARJSFXV if(is_tty(atstream)) cn=block_len; #endif if(cn!=block_len) error(M_DISK_FULL); } return(0); } /* Executed when decoding is initialized */ void decode_start_stub() { #if SFX_LEVEL>=ARJ subbitbuf=0; #endif bitbuf=0; byte_buf=0; bitcount=0; fillbuf(CHAR_BIT*2); #if SFX_LEVEL>=ARJSFXV mem_stats(); #endif } #endif #if SFX_LEVEL>=ARJSFXV /* Executed when the decoding memory variables are released */ void decode_end_stub() { /* Currently empty, may contain debugging checks if needed. */ } #endif #if SFX_LEVEL>=ARJ /* Finds an non-existent filename that matches the given format string. The format string must contain "%d" somewhere because the names are numbered. */ char *find_tmp_filename(char *name_format) { char tmp_name[CCHMAXPATH]; int i; for(i=0; i<=99; i++) { sprintf(tmp_name, name_format, i); if(!file_exists(tmp_name)) return(strcpy(name_format, tmp_name)); } error(M_CANTOPEN, name_format); return(0); /* not reached, avoid warning */ } /* Creates an numeric extension to the name, returns -1 if failed */ int find_num_ext(char *name, int mode) { char tmp_name[CCHMAXPATHCOMP]; char tmp_ext[CCHMAXPATHCOMP]; int name_offset; char *ext_offset; int ext_num; strcpy(tmp_name, name); name_offset=split_name(tmp_name, NULL, NULL); if((ext_offset=strchr(&tmp_name[name_offset], '.'))==NULL) strcat(tmp_name, ext_digits); else { strcpy(tmp_ext, ext_offset); /* Remember the original extension */ strcpy(ext_offset, ext_digits); /* Substitute extension */ if(mode==EXT_INSERT) strcat(tmp_name, tmp_ext); /* Complete with original extension */ } for(ext_num=0; ext_num<999; ext_num++) { sprintf(name, tmp_name, ext_num); if(!file_exists(name)) return(0); } msg_cprintf(0, M_EXISTS, name); return(-1); } /* Treats filename as an ARCmail packet and finds a suitable name for it */ int find_arcmail_name(char *name) { unsigned long counter; char *nptr; char c; for(counter=0L; counter<100000000L; counter++) { if((nptr=strchr(name+1, '.'))==NULL) nptr=name+strlen(name); nptr--; do { c=*nptr; if(!isdigit(c)) c='0'; else c++; if(c>'9') { *nptr='0'; if(nptr==name) { msg_cprintf(0, M_RANGE_EXCEEDED, name); return(-1); } nptr--; } else *nptr=c; } while(c>'9'); if(!file_exists(name)) return(0); } msg_cprintf(0, M_EXISTS, name); return(-1); } #endif #if SFX_LEVEL>=ARJSFXV /* Puts the given character to the console */ static int nputc(int c) { msg_cprintf(0, (FMSG *)"%c", c); return(c); } #endif #if SFX_LEVEL>=ARJ /* Reads a command for execution from the stdin */ void query_cmd() { char cmd[CMDLINE_LENGTH]; msg_cprintf(0, M_COMMAND); read_line(cmd, sizeof(cmd)); alltrim(cmd); if(cmd[0]!='\0') exec_cmd(cmd); } #endif /* Compares the first n characters of two MSG-strings (used exclusively by query_action_proc()) */ #if SFX_LEVEL>=ARJ static int cmp_far_str(char FAR *str1, char FAR *str2, int length) { int result; char *nstr1, *nstr2; nstr1=malloc_far_str(str1); nstr2=malloc_far_str(str2); result=strncmp(nstr1, nstr2, length); free(nstr1); free(nstr2); return(result); } #define msg_strncmp(str1, str2, length) cmp_far_str((char FAR *)str1, (char FAR *)str2, length) #else #define msg_strncmp strncmp #endif /* Query routine - used exclusively by query_action() */ #if SFX_LEVEL>=ARJSFXV static int query_action_proc(int def, int qtype, char *query) { char reply_text[INPUT_LENGTH]; int sel, key, ukey; char *sel_ptr, *rt_ptr; int rt_len; if(query!=NULL) msg_cprintf(H_PROMPT, (FMSG *)strform, query); #if SFX_LEVEL>=ARJ if(qtype!=QUERY_CRITICAL&&queries_assume_no[qtype]) { msg_cprintf(H_OPER, M_NO); msg_cprintf(0, (FMSG *)lf); return(0); } if(qtype!=QUERY_CRITICAL&&queries_assume_yes[qtype]) { msg_cprintf(H_OPER, M_YES); msg_cprintf(0, (FMSG *)lf); return(1); } #endif if(kbd_cleanup_on_input) fetch_keystrokes(); #if SFX_LEVEL>=ARJ if(accept_shortcut_keys) { while(1) { do { while(1) { key=uni_getch(); /* If possible default action selected */ if(def!=0&&key==LF) { msg_cprintf(0, (FMSG *)lf); if(def==1) return(1); if(def==2) return(0); } ukey=toupper(key); far_strcpy(strcpy_buf, M_REPLIES); sel_ptr=strchr(strcpy_buf, ukey); sel=sel_ptr-strcpy_buf; if(ukey!=0&&sel_ptr!=NULL&&(qtype!=QUERY_CRITICAL||sel<=REPLY_QUIT)) break; fetch_keystrokes(); nputc(BEL); } nputc(key); msg_cprintf(0, (FMSG *)lf); } while(sel>MAX_REPLY); switch(sel) { case REPLY_YES: return(1); case REPLY_NO: return(0); case REPLY_QUIT: exit(ARJ_ERL_WARNING); case REPLY_ALL: if(qtype!=QUERY_CRITICAL) queries_assume_yes[qtype]=1; return(1); case REPLY_SKIP: if(qtype!=QUERY_CRITICAL) queries_assume_no[qtype]=1; return(0); case REPLY_GLOBAL: yes_on_all_queries=1; return(1); case REPLY_COMMAND: query_cmd(); if(query!=NULL) msg_cprintf(H_PROMPT, (FMSG *)strform, query); } } /* There is no way down here */ } #endif /* Use an editable field */ while(1) { read_line(reply_text, INPUT_LENGTH); for(rt_ptr=reply_text; rt_ptr[0]==' '; rt_ptr++); if((rt_len=strlen(rt_ptr))>0) { strupper(rt_ptr); if(!msg_strncmp(rt_ptr, reply_help, rt_len)) { far_strcpy(strcpy_buf, (qtype==QUERY_CRITICAL)?M_REPLIES_HELP:M_ALL_REPLIES_HELP); msg_cprintf(0, (FMSG *)strcpy_buf); continue; } else if(!msg_strncmp(rt_ptr, M_NO, rt_len)) return(0); else if(!msg_strncmp(rt_ptr, M_YES, rt_len)) return(1); else if(!msg_strncmp(rt_ptr, M_QUIT, rt_len)) exit(1); else if(qtype!=QUERY_CRITICAL) { #if SFX_LEVEL>=ARJ if(!msg_strncmp(rt_ptr, M_ALWAYS, rt_len)) { if(qtype!=QUERY_CRITICAL) queries_assume_yes[qtype]=1; return(1); } if(!msg_strncmp(rt_ptr, M_SKIP, rt_len)) { if(qtype!=QUERY_CRITICAL) queries_assume_no[qtype]=1; return(0); } #endif if(!msg_strncmp(rt_ptr, M_GLOBAL, rt_len)) { yes_on_all_queries=1; return(1); } #if SFX_LEVEL>=ARJ if(!msg_strncmp(rt_ptr, M_COMMAND, rt_len)) { query_cmd(); if(query!=NULL) msg_cprintf(H_PROMPT, (FMSG *)strform, query); continue; } #endif } } else { if(def==1) return(1); if(def==2) return(0); } fetch_keystrokes(); nputc(BEL); msg_cprintf(0, M_REPLIES_HELP); } } #else int query_action() { #ifndef REARJ char buf[40]; #else char buf[80]; #endif char *buf_ptr; int sl, rc; char *fmsg_ptr; while(1) { read_line(buf, sizeof(buf)); buf_ptr=buf; while(*buf_ptr==' ') buf_ptr++; if((sl=strlen(buf_ptr))!=0) { strupper(buf_ptr); fmsg_ptr=malloc_fmsg(M_NO); rc=strncmp(buf_ptr, fmsg_ptr, sl); free_fmsg(fmsg_ptr); if(!rc) return(0); fmsg_ptr=malloc_fmsg(M_YES); rc=strncmp(buf_ptr, fmsg_ptr, sl); free_fmsg(fmsg_ptr); if(!rc) return(1); #ifndef REARJ fmsg_ptr=malloc_fmsg(M_QUIT); rc=strncmp(buf_ptr, fmsg_ptr, sl); free_fmsg(fmsg_ptr); if(!rc) exit(ARJSFX_ERL_ERROR); #endif } msg_cprintf(0, M_REPLIES_HELP); } } #endif #if SFX_LEVEL>=ARJSFXV /* Standard procedure that queries user. Accepts the following parameters: - def=0 if no default action, or number of reply to be selected w/ENTER. - qtype is the standard query number to allow pre-selections. - query is the query text. */ int query_action(int def, int qtype, FMSG *query) { #if SFX_LEVEL>=ARJ char *nquery; int result; FILE *tmp_stdout; if((tmp_stdout=new_stdout)==new_stderr) new_stdout=stderr; result=query_action_proc(def, qtype, nquery=malloc_fmsg(query)); free_fmsg(nquery); new_stdout=tmp_stdout; return(result); #else return(query_action_proc(def, qtype, query)); #endif } /* Prompts the user to press ENTER */ int pause() { char *tmp_query; FILE *tmp_stdout; int rc; if((tmp_stdout=new_stdout)==new_stderr) new_stdout=stderr; tmp_query=malloc_fmsg(M_PRESS_ENTER); rc=query_action_proc(1, QUERY_PRESS_ENTER, tmp_query); new_stdout=tmp_stdout; free_fmsg(tmp_query); return(rc); } /* Puts a LF character to the stdout */ void nputlf() { msg_cprintf(0, (FMSG *)lf); } #endif #if SFX_LEVEL>=ARJ /* Deletes files specified by the given wildcard. Returns 1 if no files were found to delete. */ int delete_files(char *name) { char tmp_name[CCHMAXPATHCOMP]; struct flist_root root; FILE_COUNT curfile; flist_init(&root, FCLIM_DELETION, FL_STANDARD); if(flist_add_files(&root, NULL, name, 1, 0, FETCH_FILES, NULL)) return(1); for(curfile=0; curfile=ARJSFXV void display_comment(char FAR *cmt) #else void display_comment(char *cmt) #endif { unsigned char c; #if SFX_LEVEL>=ARJSFXV int is_ansi=0; #endif #if TARGET==OS2 USHORT af; #endif #if SFX_LEVEL>=ARJ if(new_stderr==new_stdout) return; #endif #if TARGET==OS2 fflush(stdout); VioGetAnsi(&af, 0); VioSetAnsi(ANSI_ON, 0); #endif while((c=*(cmt++))!='\0') { #if SFX_LEVEL>=ARJSFXV if(c==ANSI_ESC) is_ansi=1; #endif #if SFX_LEVEL>=ARJSFXV&&!defined(DIRECT_TO_ANSI) if(is_ansi) { display_ansi(c); if(c==LF) display_ansi(CR); } else { #endif /* Substitute non-printable control characters with "?"'s */ #ifndef DIRECT_TO_ANSI if(c<' '&&c!=TAB&&c!=LF&&c!=CR) c=UNDISP_CHAR; #endif #if SFX_LEVEL>=ARJSFXV nputc((int)c); #else fputc((int)c, stdout); #endif #if SFX_LEVEL>=ARJ if(c==LF) { lines_scrolled++; if(lines_scrolled>=lines_per_page-1) { lines_scrolled=0; if(!yes_on_all_queries&&prompt_for_more&&is_tty(stdout)) { if(!pause()) return; } } } #endif #if SFX_LEVEL>=ARJSFXV&&!defined(DIRECT_TO_ANSI) } #endif } #if SFX_LEVEL>=ARJSFXV if(is_ansi) { #ifdef DIRECT_TO_ANSI printf("\x1B[0m\n"); #else display_ansi(LF); #endif } #endif #if TARGET==OS2 VioSetAnsi(af, 0); #endif } #if SFX_LEVEL>=ARJ /* Puts repeatable character to stdout */ static char *nputnc(char *dest, int c, int count) { while(count-->0) *(dest++)=c; return(dest); } #endif /* Displays progress indicator */ void display_indicator(long bytes) { int pct; char ind[64]; char *p; /* Indicator width */ static unsigned char ind_sizes[]={5, 0, 11, 5, 8, 11, 11}; #if SFX_LEVEL>=ARJ static int prev_pct=0; #endif if(!file_packing) return; p=ind; if(arjdisp_enabled) arjdisp_scrn((unsigned long)bytes); /* Different conditions for ARJ and ARJSFX! */ #if SFX_LEVEL>=ARJ else if(indicator_style!=IND_NONE) { check_wrap(ind_sizes[indicator_style]); if(uncompsize<0L) { if(bytes==0L) p+=sprintf(p, sfmt_double, del_double); p+=sprintf(p, sfmt_bytes, bytes, del_double); } else { if(indicator_style==IND_NORMAL||indicator_style==IND_TOTAL_PCT) { if(bytes==0L) { p+=sprintf(p, sfmt_single, del_single); p+=sprintf(p, sfmt_start_graph, del_single); } else { if(total_size!=0&&display_totals&&indicator_style==IND_TOTAL_PCT) pct=calc_percentage(total_written+bytes, total_size); else pct=calc_percentage(bytes, uncompsize); if(pct==prev_pct&&CHECK_SENTRY()) return; p+=sprintf(p, sfmt_numeric, pct/10, del_single); } } else if(indicator_style==IND_GRAPH||indicator_style==IND_TOTAL_GRAPH) { if(bytes==0L) { p+=sprintf(p, sfmt_double, del_double); p+=sprintf(p, sfmt_graph, del_double); *p='\0'; p=ind; msg_cprintf(H_HL, (FMSG *)strform, ind); } else { if(total_size!=0&&display_totals&&indicator_style==IND_TOTAL_GRAPH) pct=calc_percentage(total_written+bytes, total_size); else pct=calc_percentage(bytes, uncompsize); if(pct==prev_pct&&CHECK_SENTRY()) return; p=nputnc(p, COUNTER_CHAR, pct/100); p=nputnc(p, '\b', pct/100); *p='\0'; p=ind; msg_cprintf(H_OPER, (FMSG *)strform, ind); } } else if(indicator_style==IND_PCT_GRAPH||indicator_style==IND_TOTAL_PCT_GRAPH||indicator_style==IND_TOTAL_PCT_LGRAPH) { if(total_size!=0&&display_totals&&(indicator_style==IND_TOTAL_PCT_GRAPH||indicator_style==IND_TOTAL_PCT_LGRAPH)) pct=calc_percentage(total_written+bytes, total_size); else pct=calc_percentage(bytes, uncompsize); if(bytes==0L) { p+=sprintf(p, sfmt_double, del_double); p+=sprintf(p, sfmt_start_num, pct/10); *p='\0'; p=ind; if(pct==prev_pct&&CHECK_SENTRY()) return; msg_cprintf(H_OPER, (FMSG *)strform, ind); msg_cprintf(H_HL, sfmt_mid_graph, del_double); } else { p+=sprintf(p, sfmt_short_numeric, pct/10); if(total_size!=0&&indicator_style==IND_TOTAL_PCT_GRAPH) pct=calc_percentage(total_written+bytes, total_size); else pct=calc_percentage(bytes, uncompsize); if(pct==prev_pct&&CHECK_SENTRY()) return; p=nputnc(p, COUNTER_CHAR, pct/200); p=nputnc(p, '\b', pct/200+5); } } } } *p='\0'; msg_cprintf(H_OPER, (FMSG *)strform, ind); prev_pct=pct; SET_SENTRY(); #elif SFX_LEVEL==ARJSFXV else if(indicator_style==IND_NORMAL||indicator_style==IND_GRAPH) { if(uncompsize<0L) { if(bytes==0L) p+=sprintf(p, sfmt_double, del_double); p+=sprintf(p, sfmt_bytes, bytes, del_double); } if(indicator_style==IND_NORMAL) { if(bytes==0L) { p+=sprintf(p, sfmt_single, del_single); p+=sprintf(p, sfmt_start_graph, del_single); } else { pct=calc_percentage(bytes, uncompsize); p+=sprintf(p, sfmt_numeric, pct/10, del_single); } } } *p='\0'; msg_cprintf(0, (FMSG *)strform, ind); #else else if(indicator_style==IND_NORMAL) { pct=calc_percentage(bytes, uncompsize); printf(sfmt_sfx, pct/10); } #endif } #endif #if SFX_LEVEL>=ARJ /* Puts a character to the output stream. The cursor position given is only for checking purposes. Returns the new cursor position. */ static int arj_putc(unsigned char c, int p) { unsigned char t[TAB_POS+1]; unsigned char *q; int rc=p; q=t; if(c==LF) { #if COMPILER==MSC *q++=CR; #endif *q++=c; rc=1; } else if(c==TAB) { do { if(p=' ')?c:UNDISP_CHAR; rc++; } *q='\0'; msg_cprintf(0, (FMSG *)strform, t); return(rc); } /* Prints the given text to stdout, querying for "more?" when needed. Returns 1 if the output was cancelled by the user in response to the "--More--?" prompt. */ static int list_with_more(char *str, unsigned int len) { FMSG *prompt; char *sptr; unsigned int i; int cur_pos; int cur_line; unsigned char c; int sf; #if COMPILER==MSC if(help_issued) fputc(CR, stdout); #endif sptr=str; prompt=prompt_for_more?M_QUERY_MORE:M_QUERY_SCANNED_ENOUGH; nputlf(); cur_line=2; cur_pos=1; i=1; while(i<=len) { c=*sptr++; if(verbose_display==VERBOSE_NONE&&!help_issued) c&=0x7F; /* Strip high bit from nonlocal text */ i++; if(i>len) c=LF; cur_pos=arj_putc(c, cur_pos); if(c==LF) { cur_line++; if(cur_line>=lines_per_page-2) { cur_line=0; sf=yes_on_all_queries||skip_scanned_query; if(!sf) { sf=query_action(REPLY_NO, QUERY_SCANNED_ENOUGH, prompt); if(prompt_for_more) sf=!sf; } if(sf) return(1); } } } if(help_issued) return(0); sf=yes_on_all_queries||skip_scanned_query; if(!sf) { sf=query_action(REPLY_NO, QUERY_SCANNED_ENOUGH, prompt); if(prompt_for_more) sf=!sf; } return(sf); } /* Compares the contents of the block with the input file. */ static int compare_fblock(char *block, int len) { int bytes_read; char FAR *tmp_block; if(identical_filedata) { tmp_block=farmalloc_msg((unsigned long)len); far_memmove(tmp_block, (char FAR *)block, len); if((bytes_read=fread(block, 1, len, tstream))!=len) identical_filedata=0; else { if(bytes_read>0) { if(far_memcmp((char FAR *)block, tmp_block, bytes_read)) identical_filedata=0; } } far_memmove((char FAR *)block, tmp_block, len); farfree(tmp_block); } return(0); } /* Displays the text found in a block. Returns the number of bytes displayed. */ static int display_found_text(unsigned char FAR *block, int offset, int block_len) { int remain; int d_offset; int column; unsigned int c; int i; d_offset=offset; remain=min(fdisp_lines*TXTD_LENGTH, block_len); if(remain>TXTD_LENGTH) { msg_cprintf(0, M_MARK_LLINE); d_offset=(remain/2>offset)?0:offset-remain/2; } block+=d_offset; column=0; i=0; while(i=TXTD_LENGTH) { msg_cprintf(0, lf); column=0; } c=*(block++); if(verbose_display) { if(cCON_UBOUND) c=UNDISP_CHAR; fputc(c, new_stdout); i++; d_offset++; column++; } msg_cprintf(0, lf); return(i-(offset-d_offset)); } /* Performs a search for the given pattern in memory block */ static int t_search_stub(char *pattern, char *cmpblock, char FAR *block, int skip, int block_len) { int len; int matches; int search_offset; int limit; char c; int t_offset; char *p; len=strlen(pattern); matches=0; search_offset=0; c=*pattern; limit=(len>=block_len)?0:block_len-len; t_offset=skip; p=&cmpblock[skip]; while(t_offsetsearch_offset) search_offset=t_offset+display_found_text(block, t_offset, block_len)-len; if(extm_mode!=EXTM_NONE) break; } } t_offset++; p++; } return(matches); } /* Performs a search in the block of continuous data. */ static int search_in_block(char *block, int block_len) { int tmp_len, tail_len; char *sstr_ptr; char FAR *block_ptr; char FAR *reserve_ptr; int i; block_ptr=(char FAR *)block; reserve_ptr=(char FAR *)search_reserve; if(ignore_pcase) { block_ptr=farmalloc_msg((unsigned long)block_len); far_memmove(block_ptr, (char FAR *)block, block_len); toupper_loc(block, block_len); if(reserve_size!=0) { reserve_ptr=farmalloc_msg(160L); far_memmove(reserve_ptr, (char FAR *)search_reserve, reserve_size); toupper_loc(search_reserve, reserve_size); } } for(i=0; iINPUT_LENGTH)?INPUT_LENGTH:block_len; memcpy(search_reserve+reserve_size, block, tmp_len); if(ignore_pcase) far_memmove(&reserve_ptr[reserve_size], block_ptr, tmp_len); tail_len=reserve_size-strlen(sstr_ptr)+1; search_occurences[i]+=(long)t_search_stub(sstr_ptr, search_reserve, reserve_ptr, tail_len, reserve_size+tmp_len); if(pattern_found&&extm_mode!=EXTM_NONE) break; } search_occurences[i]+=(long)t_search_stub(sstr_ptr, block, block_ptr, 0, block_len); if(pattern_found&&extm_mode!=EXTM_NONE) break; } if(ignore_pcase) { far_memmove((char FAR *)block, block_ptr, block_len); farfree(block_ptr); if(reserve_size!=0) farfree(reserve_ptr); } reserve_size=(block_len>INPUT_LENGTH)?INPUT_LENGTH:block_len; memcpy(search_reserve, block+(block_len-reserve_size), reserve_size); return(0); } /* Displays a block of text using ANSI comment display routine. */ static int display_block(char *str, int len) { if(new_stdout!=new_stderr) { while((len--)>0) { #ifndef DIRECT_TO_ANSI display_ansi(*(str++)); #else putchar(*(str++)); #endif } } return(0); } /* Performs various actions involving the given block. */ static int block_op(int action, char *block, int len) { if(action==BOP_LIST) return(list_with_more(block, len)); else if(action==BOP_DISPLAY) return(display_block(block, len)); else if(action==BOP_SEARCH) return(search_in_block(block, len)); else if(action==BOP_COMPARE) return(compare_fblock(block, len)); else return(0); } #endif #if SFX_LEVEL>=ARJ||defined(REARJ) /* Renames file and ensures that it has been successfully renamed */ #ifdef REARJ int rename_with_check(char *oldname, char *newname) { if(!no_file_activity) { if(file_rename(oldname, newname)) return(-1); if(file_exists(oldname)||!file_exists(newname)) return(-1); } return(0); } #else void rename_with_check(char *oldname, char *newname) { if(!file_test_access(oldname)) { if(!file_rename(oldname, newname)) { if(!file_exists(oldname)&&file_exists(newname)) return; } } error(M_CANTRENAME, oldname, newname); } #endif #endif /* SFX_LEVEL>=ARJ||defined(REARJ) */ #if SFX_LEVEL>=ARJ /* Returns number of occurences in the given string */ static int count_chars(char *str, char c) { int occurs=0; char *tmp_ptr; for(tmp_ptr=str; *tmp_ptr!='\0'; tmp_ptr++) if(*tmp_ptr==c) occurs++; return(occurs); } /* Deletes the processed files */ int delete_processed_files(struct flist_root *root) { char name[FILENAME_MAX]; unsigned int count; int depth, max_depth; FILE_COUNT i; FILE *t; /* If break is requested, cancel the deletion */ if(ctrlc_processing) return(0); max_depth=0; count=0; for(i=0; ifiles; i++) { if(cfa_get(i)==FLFLAG_PROCESSED) count++; } if(delete_processed==DP_STD&&!yes_on_all_queries&&!query_delete) { msg_sprintf(misc_buf, M_QUERY_DELETE_N_FILES, count); if(!query_action(REPLY_YES, QUERY_DELETE_N_FILES, (char FAR *)misc_buf)) return(0); } msg_cprintf(0, M_DELETE_COUNT, count); for(i=0; ifiles; i++) { if(cfa_get(i)==FLFLAG_PROCESSED) { flist_retrieve(name, NULL, root, i); depth=count_chars(name, PATHSEP_DEFAULT); if(depth>max_depth) max_depth=depth; if(!is_directory(name)) { /* ASR fix for 2.78-TCO */ if(delete_processed!=DP_ADD_TRUNC) { if(file_unlink(name)) { msg_cprintf(H_ERR, M_CANT_DELETE, name); nputlf(); } } else { if((t=file_open(name, m_rbp))==NULL) { msg_cprintf(H_ERR, M_CANT_TRUNCATE, name); nputlf(); } file_chsize(t, 0); fclose(t); } cfa_store(i, FLFLAG_DELETED); } } } for(depth=max_depth; depth>=0; depth--) { for(i=0; ifiles; i++) { if(cfa_get(i)==FLFLAG_PROCESSED) { flist_retrieve(name, NULL, root, i); if(count_chars(name, PATHSEP_DEFAULT)>=depth&&is_directory(name)) { if(file_rmdir(name)) { msg_cprintf(H_ERR, M_CANT_DELETE, name); nputlf(); } cfa_store(i, FLFLAG_DELETED); } } } } return(0); } /* Writes a byte to the file */ void fput_byte(int b, FILE *stream) { if(!no_file_activity) { if(fputc(b, stream)==EOF) error(M_DISK_FULL); } } /* Writes two bytes to the file */ void fput_word(unsigned int w, FILE *stream) { fput_byte(w&0xFF, stream); fput_byte(w>>8, stream); } /* Writes four bytes to the file */ void fput_dword(unsigned long l, FILE *stream) { #ifdef WORDS_BIGENDIAN fput_word((unsigned int)(l&0xFFFF), stream); fput_word((unsigned int)(l>>16), stream); #else if(!no_file_activity) { if(!fwrite(&l,4,1,stream)) error(M_DISK_FULL); } #endif } /* Writes the compressed data */ void flush_compdata() { if(out_bytes>0) { compsize+=(unsigned long)out_bytes; if(compsize>origsize&&(!garble_enabled||!file_packing)) unpackable=1; else { if(!no_file_activity) { if(garble_enabled) garble_encode_stub(out_buffer, out_bytes); if(file_packing) { file_write(out_buffer, 1, out_bytes, aostream); } else { far_memmove(packblock_ptr, (char FAR *)out_buffer, out_bytes); packblock_ptr+=out_bytes; } out_avail=PUTBIT_SIZE; } } out_bytes=0; } } /* Initializes compressed data output */ void init_putbits() { unsigned long fp; bitcount=0; byte_buf=0; bitbuf=0; out_bytes=0; if(!file_packing||no_file_activity) fp=0L; else { fp=ftell(aostream); if(fp>MAX_FILE_SIZE) error(M_FILE_IS_TOO_LARGE); } out_buffer=malloc_msg(PUTBIT_SIZE); out_avail=PUTBIT_SIZE-(fp%PUTBIT_SIZE); if(out_avail>PUTBIT_SIZE) error(M_PUTBIT_SIZE_ERROR); mem_stats(); } /* Ends the bitwise output */ void shutdown_putbits() { if(!unpackable) { putbits(CHAR_BIT-1, 0); if(out_bytes!=0) flush_compdata(); } free(out_buffer); out_bytes=0; } /* Clears the archive attribute for a set of files */ int group_clear_arch(struct flist_root *root) { char name[FILENAME_MAX]; FILE_COUNT i; if(ctrlc_processing) return(0); for(i=0; ifiles; i++) { if(cfa_get(i)==FLFLAG_PROCESSED) { flist_retrieve(name, NULL, root, i); if(dos_clear_arch_attr(name)) msg_cprintf(H_ERR, M_CANT_RESET, name); cfa_store(i, FLFLAG_DELETED); } } return(0); } #endif arj-3.10.22/arj_file.h 666 0 0 3550 7653041620 10557 0ustar /* * $Id: arj_file.h,v 1.3 2003/04/27 20:54:41 andrew_belov Exp $ * --------------------------------------------------------------------------- * Prototypes of the functions located in ARJ_FILE.C are declared here. * */ #ifndef ARJ_FILE_INCLUDED #define ARJ_FILE_INCLUDED /* Writes a block to the output file and verifies if all has been written */ #define file_write(block, el, len, stream) \ { \ if(fwrite(block, el, len, stream)!=len) \ error(M_DISK_FULL); \ } /* Prototypes */ int file_close(FILE *stream); FILE *file_open_noarch(char *name, char *mode); FILE *file_create(char *name, char *mode); int fget_byte(FILE *stream); unsigned int fget_word(FILE *stream); unsigned long fget_longword(FILE *stream); int fread_crc(char *buffer, int count, FILE *stream); void fwrite_crc(char *buffer, int count, FILE *stream); int extraction_stub(char *block, int block_len, int action); void decode_start_stub(); void decode_end_stub(); char *find_tmp_filename(char *name_format); int find_num_ext(char *name, int mode); int find_arcmail_name(char *name); void query_cmd(); #if SFX_LEVEL>=ARJSFXV int query_action(int def, int qtype, FMSG *query); #else int query_action(); #endif int pause(); void nputlf(); int delete_files(char *name); #if SFX_LEVEL>=ARJSFXV void display_comment(char FAR *cmt); #else void display_comment(char *cmt); #endif void display_indicator(long bytes); #ifdef REARJ int rename_with_check(char *oldname, char *newname); #else void rename_with_check(char *oldname, char *newname); #endif int delete_processed_files(struct flist_root *root); void fput_byte(int c, FILE *stream); void fput_word(unsigned int w, FILE *stream); void fput_dword(unsigned long l, FILE *stream); void flush_compdata(); void init_putbits(); void shutdown_putbits(); int group_clear_arch(struct flist_root *root); #endif arj-3.10.22/arj_proc.c 666 0 0 200237 10256070050 10647 0ustar /* * $Id: arj_proc.c,v 1.18 2005/06/21 19:53:13 andrew_belov Exp $ * --------------------------------------------------------------------------- * This file contains many of the functions that are called by various ARJ * modules. Everything is OS-independent, all OS-dependent procedures must be * moved to ENVIRON.C. * */ #include "arj.h" DEBUGHDR(__FILE__) /* Debug information block */ /* Other defines */ #define FNAME_FLEN 27 /* Length of formatted filename */ /* String table (may need some localization in the future...) */ #if SFX_LEVEL>=ARJ||defined(REARJ) static char strtime_filler[]="00000000000000"; #endif #if SFX_LEVEL>=ARJ static char time_tail_pattern[]="%04d%02d%02d%03d%02d%02d%02d"; static char date_digit_format[]="%04d%02d%02d"; static char allowed_attrs[]=TAG_LIST; static char vol_st_id[]=" - "; /* A substring of M_NEXT_VOL_STATS */ #endif #if SFX_LEVEL>=ARJSFXV static char nonexistent_name[]="..."; #endif #if SFX_LEVEL>=ARJSFXV||defined(REARJ) /* The first byte in integrity_pattern[] is changed to avoid confusion with the pattern to search */ static unsigned char integrity_pattern[]={0xB1, 0x03, 0xB0, 0x02, 0xB0, 0x03, 0xB0, 0x04, 0xB0, 0x05, 0}; #endif #if SFX_LEVEL>=ARJ static int hswitch; /* Indicates that we have a "-h..." */ static int jswitch; /* Indicates that we have a "-j..." */ static int os2switch; /* ARJ/2 switches (-h2, -2) */ static int noswitch; #endif #if SFX_LEVEL>=ARJ static int *sw_index[]={&jswitch, &hswitch, &allow_any_attrs, &filter_fa_arch, &skip_ts_check, &delete_processed, &exclude_paths, &freshen_criteria, &garble_enabled, &indicator_style, &keep_bak, &create_list_file, &custom_method, &new_files_only, &filter_same_or_newer, &fnm_matching, &query_for_each_file, &recurse_subdirs, ×tamp_override, &type_override, &update_criteria, &multivolume_option, &assign_work_directory, &exclude_files, &yes_on_all_queries, &use_comment, &help_issued, &listchars_allowed, &handle_labels, &disable_arj_sw, &select_by_number, &install_errhdl, &quiet_mode, &rsp_per_line, &noswitch, &lowercase_names, NULL}; static int *jsw_index[]={&jswitch, &comment_display, &chapter_mode, &exit_after_count, &chk_free_space, &create_sfx, &validate_style, &select_backup_files, &jh_enabled, &create_index, &keep_tmp_archive, &show_filenames_only, &max_compression, &restart_at_filename, &serialize_exts, &prompt_for_more, &set_string_parameter, &ignore_crc_errors, &store_by_suffix, &test_archive_crc, &translate_unix_paths, &verbose_display, &extract_to_file, &start_at_ext_pos, &assume_yes, &supply_comment_file, &hollow_mode, &skip_time_attrs, NULL}; static int *hsw_index[]={&hswitch, &clear_archive_bit, &filter_attrs, &run_cmd_at_start, &debug_enabled, &arjsec_opt, &lfn_mode, &gost_cipher, &detailed_index, &protfile_option, &listfile_err_opt, &filelist_storage, &nonexist_filespec, &extm_mode, &arjdisp_enabled, &ignore_open_errors, &ignore_archive_errors, &disable_sharing, &set_target_directory, &allow_mv_update, &chk_arj_version, &search_mode, &override_archive_exts, &use_ansi_cp, &sign_with_arjsec, &append_curtime, &marksym_expansion, &force_lfn, &noswitch, NULL}; static int *os2sw_index[]={&os2switch, &arcmail_sw, &noswitch, &crit_eas, &dos_host, &include_eas, &disable_comment_series, &suppress_hardlinks, &start_with_seek, &skip_century, &fix_longnames, &do_chown, &priority.class, &recursion_order, &symlink_accuracy, &noswitch, &exclude_eas, NULL}; static int *jysw_index[]={&skip_append_query, &prompt_for_mkdir, &query_delete, &skip_space_query, &skip_rename_prompt, &overwrite_existing, &kbd_cleanup_on_input, &skip_scanned_query, &skip_next_vol_query, &accept_shortcut_keys, NULL}; #elif SFX_LEVEL==ARJSFXV static int *sw_index[]={&skip_integrity_test, &prompt_for_directory, &skip_ts_check, &chk_free_space, &extract_expath, &freshen_criteria, &garble_enabled, &help_issued, &indicator_style, &process_lfn_archive, &skip_preset_options, &list_sfx_cmd, &overwrite_ro, &new_files_only, &gost_cipher, &fnm_matching, &ignore_crc_errors, &disable_sharing, &test_sfx_cmd, &update_criteria, &verbose_list, &extract_to_file, &extract_cmd, &yes_on_all_queries, &assume_yes, &help_issued, &skip_volumes, &debug_enabled, &quiet_mode, &handle_labels, &arjdisp_enabled, &execute_extr_cmd, &lowercase_names, NULL}; static int *jysw_index[]={&skip_append_query, &prompt_for_mkdir, &skip_space_query, &skip_extract_query, &skip_rename_prompt, &overwrite_existing, &kbd_cleanup_on_input, &skip_next_vol_query, NULL}; #elif SFX_LEVEL==ARJSFX static int *sw_index[]={&extract_expath, &list_sfx_cmd, &test_sfx_cmd, &verbose_list, &extract_cmd, &show_ansi_comments, &prompt_for_directory, &skip_ts_check, &arjdisp_enabled, &freshen_criteria, &garble_enabled, &indicator_style, &process_lfn_archive, &verbose_display, &make_directories, &new_files_only, &overwrite_existing, &fnm_matching, &skip_integrity_test, &update_criteria, &skip_extract_query, &yes_on_all_queries, &quiet_mode, &help_issued, &help_issued, &execute_extr_cmd}; #endif /* Local functions */ #if SFX_LEVEL>=ARJ static int compare_exts(char *name, char *pad); #endif #if SFX_LEVEL>=ARJ /* Encodes a block of data */ void garble_encode_stub(char *data, int len) { garble_encode(data, len); } /* Decodes a block of data */ void garble_decode_stub(char *data, int len) { garble_decode(data, len); } #endif #if SFX_LEVEL>=ARJ /* Returns day of year */ static int day_of_year(struct tm *tms) { int m, y, rc; rc=0; for(m=tms->tm_mon; m>0; m--) { switch(m) { case 1: rc+=31; break; case 2: rc+=28; y=tms->tm_year+1900; if((y%4==0)&&(y%100!=0||y%400==0)) rc++; break; case 3: rc+=31; break; case 4: rc+=30; break; case 5: rc+=31; break; case 6: rc+=30; break; case 7: rc+=31; break; case 8: rc+=31; break; case 9: rc+=30; break; case 10: rc+=31; break; case 11: rc+=30; break; } } return(rc+tms->tm_mday); } /* Appends current date/time to the archive filename in accordance with the "-h#" option */ void append_curtime_proc() { time_t curtime; struct tm *tms; char time_pad[19]; char ext[32]; char *ext_pos; char *aptr, *tptr; char *dptr=time_pad; /* ASR fix for High C -- 29/03/2001 */ int l, lim; int doy; /* Day of year */ curtime=time(NULL); tms=arj_localtime(&curtime); doy=day_of_year(tms); sprintf(time_pad, time_tail_pattern, tms->tm_year+1900, tms->tm_mon+1, tms->tm_mday, doy, tms->tm_hour, tms->tm_min, tms->tm_sec); if((ext_pos=strchr(archive_name+split_name(archive_name, NULL, NULL), '.'))!=NULL) { strncpy(ext, ext_pos, sizeof(ext)); *ext_pos='\0'; } else ext[0]='\0'; if(time_str[0]=='\0') { if(append_curtime==ATS_DUAL) strcat(archive_name, time_pad+7); else if(append_curtime==ATS_TIME) strcat(archive_name, time_pad+8); else if(append_curtime==ATS_DATE) { time_pad[8]='\0'; strcat(archive_name, time_pad+2); } } else /* Custom format */ { l=strlen(time_str); aptr=archive_name+strlen(archive_name)+l; *aptr='\0'; lim=0; for(tptr=time_str+l-1; (tptr-time_str)>=0; tptr--) { if(*tptr==*(tptr+1)) *(--aptr)=(lim>0)?dptr[--lim]:*tptr; else { switch(*tptr) { case 'Y': dptr=time_pad; lim=4; *(--aptr)=dptr[--lim]; break; case 'M': dptr=time_pad+4; lim=2; *(--aptr)=dptr[--lim]; break; case 'D': dptr=time_pad+6; lim=2; *(--aptr)=dptr[--lim]; break; case 'N': dptr=time_pad+8; lim=3; *(--aptr)=dptr[--lim]; break; case 'h': dptr=time_pad+11; lim=2; *(--aptr)=dptr[--lim]; break; case 'm': dptr=time_pad+13; lim=2; *(--aptr)=dptr[--lim]; break; case 's': dptr=time_pad+15; lim=2; *(--aptr)=dptr[--lim]; break; default: *(--aptr)=*tptr; } } } } strcat(archive_name, ext); } /* Adds an ending backslash to the given pathname if it doesn't contain one */ void add_pathsep(char *path) { int len; if((len=strlen(path))==0) /* Maybe current path? */ return; if(strchr(path_separators, path[len-1])==NULL) { path[len]=PATHSEP_DEFAULT; path[len+1]='\0'; } } /* Converts the timestamps given by the user to the internal storage format */ void convert_time_limits() { char *cptr; time_t tmp_ts; time_t ts; struct tm *tms; struct timestamp arj_ts; /* ARJ-format timestamp storage */ if(filter_same_or_newer==TCHECK_NDAYS) { tmp_ts=strtoul(timestr_newer, &cptr, 10)*(-86400L); ts=sum_time(tmp_ts, time(NULL)); tms=arj_localtime(&ts); if(tms==NULL) /* ASR fix 21/02/2001 -- IBM LIBC */ error(M_INVALID_DATE); sprintf(misc_buf, date_digit_format, tms->tm_year+1900, tms->tm_mon+1, tms->tm_mday); timestr_newer=malloc_str(misc_buf); /* MEMORY LEAK! (Never freed) */ } if(filter_older==TCHECK_NDAYS) { tmp_ts=strtoul(timestr_older, &cptr, 10)*(-86400L); ts=sum_time(tmp_ts, time(NULL)); tms=arj_localtime(&ts); if(tms==NULL) /* ASR fix 21/02/2001 -- IBM LIBC */ error(M_INVALID_DATE); sprintf(misc_buf, date_digit_format, tms->tm_year+1900, tms->tm_mon+1, tms->tm_mday); timestr_older=malloc_str(misc_buf); /* MEMORY LEAK! (Never freed) */ } if(timestr_older[0]!='\0') convert_strtime(&tested_ftime_older, timestr_older); if(timestr_newer[0]!='\0') convert_strtime(&tested_ftime_newer, timestr_newer); if(timestr_older[0]=='\0'&×tr_newer[0]=='\0') { ts=time(NULL); tms=arj_localtime(&ts); make_timestamp(&arj_ts, tms->tm_year, tms->tm_mon+1, tms->tm_mday, 0, 0, 0); if(timestr_newer[0]=='\0') tested_ftime_newer=arj_ts; if(timestr_older[0]=='\0') tested_ftime_older=arj_ts; } } /* Analyzes ARJ_SW settings */ void parse_arj_sw(int cmd, char *arj_sw, char *dest) { int use_file; /* 1 if ARJ_SW represents a file */ char *buf; char *dptr, *varname; char *sptr; FILE *stream; char *sw, *sw_p; use_file=0; while(arj_sw[0]==' ') arj_sw++; if(strchr(switch_chars, arj_sw[0])==NULL) { buf=dest; dptr=dest+FILENAME_MAX+1; sptr=dest+FILENAME_MAX*2+2; sptr[0]='\0'; dptr[0]='\0'; stream=file_open_noarch(arj_sw, m_r); while(fgets(buf, FILENAME_MAX, stream)!=NULL) { strip_lf(buf); if(buf[0]=='#') continue; else if(!use_file&&buf[0]=='+'&&buf[1]==' ') { strcpy(sptr, buf+1); use_file=1; } else if(!use_file&&buf[0]=='-'&&buf[1]==' ') { strcat(dptr, buf+2); strcat(dptr, " "); use_file=1; } else if((cmd==ARJ_CMD_ADDC&&!strnicmp(buf, "AC ", 3))|| (cmd==ARJ_CMD_CNVC&&!strnicmp(buf, "CC ", 3))|| (cmd==ARJ_CMD_DELC&&!strnicmp(buf, "DC ", 3))) { strcpy(dptr, buf+3); use_file=1; break; } else { if(toupper((int)buf[0])==cmd&&buf[1]==' ') { strcpy(dptr, buf+2); use_file=1; break; } } } fclose(stream); strcat(dptr, sptr); sw=malloc_str(dptr); } else sw=malloc_str(arj_sw); varname=use_file?arj_sw:arj_env_name; sw_p=malloc_str(sw); /* Tokenize switch */ for(dptr=sw; *dptr!='\0'; dptr++) if(*dptr==' ') *dptr='\0'; sptr=dptr; dptr=sw; while((dptr-sptr)<0) { while(*dptr=='\0') dptr++; if((dptr-sptr)<0) { if(is_switch(dptr)) analyze_arg(dptr); while(*dptr!='\0'&&(dptr-sptr)<0) dptr++; } } if(!translate_unix_paths) switch_char=0; msg_cprintf(H_HL|H_NFMT, M_USING_ENV_VAR, varname, sw_p); free(sw_p); } /* Copies a part of archive */ void copy_bytes(unsigned long nbytes) { char *buf; unsigned int fetch_size; buf=malloc_msg(PROC_BLOCK_SIZE); fseek(aistream, 0L, SEEK_SET); while(nbytes>0L) { fetch_size=(unsigned int)min(PROC_BLOCK_SIZE, nbytes); if(fread(buf, 1, fetch_size, aistream)!=fetch_size) error(M_CANTREAD); if(fwrite(buf, 1, fetch_size, aostream)!=fetch_size) error(M_DISK_FULL); nbytes-=(unsigned long)fetch_size; } free(buf); } /* Returns 1 if the given filename did not contain any UNIX-style ('/') path separators, and all native path separators have been converted to UNIX-style ones ('/'). 0 is returned if the filename initially contained a UNIX-style separator. When it returns 1, the PATHSYM_FLAG in arj_flags is set by parent procedure. */ int translate_path(char *name) { int i; if(strchr(name, PATHSEP_UNIX)!=NULL) return(0); for(i=0; name[i]!=0; i++) if(name[i]==PATHSEP_DEFAULT) name[i]=PATHSEP_UNIX; return(1); } /* Restarts archive processing from the specified file */ void restart_proc(char *dest) { char *r_name, *c_name; char *dptr; char vol_stats[40]; char *vs_ptr; int i; int vs_match; int vn=0, vc=0; /* ASR fix for High C -- 29/03/2001 */ unsigned long vs=0; /* ASR fix for High C -- 29/03/2001 */ FILE_COUNT cur_file; int nd; dptr=dest; r_name=malloc_msg(FILENAME_MAX); c_name=malloc_msg(FILENAME_MAX); strcpy(r_name, filename_to_restart); msg_strcpy(vol_stats, M_NEXT_VOLUME_STATS); vs_ptr=vol_stats; i=0; while(*vs_ptr!='\0') { if(!strncmp(vs_ptr, vol_st_id, sizeof(vol_st_id)-1)) break; i++; vs_ptr++; } i+=sizeof(vol_st_id)-1; if(filename_to_restart[0]=='\0'&&index_name[0]!='\0') { vs_match=0; r_name[0]='\0'; idxstream=file_open_noarch(index_name, m_r); while(fgets(dptr, FILENAME_MAX, idxstream)!=NULL) { strip_lf(dptr); if(!memcmp(dptr, vol_stats, i)) { vs_match=1; vn=atoi(dptr+i); vc=atoi(dptr+i+4); vs=atoi(dptr+i+6); strcpy(r_name, dptr+i+17); } } fclose(idxstream); if(vs_match==0) error(M_RESTART_INFO_NF); else { resume_volume_num=vn; if(vc==1) { start_at_ext_pos=1; ext_pos=vs; } else if(vc==2) error(M_NOTHING_TO_DO); } } for(cur_file=0L; cur_file=flist_main.files) error(M_CANT_FIND_RST_FILE, r_name); free(c_name); free(r_name); if(create_sfx) { nd=split_name(archive_name, NULL, NULL); vs_ptr=strchr(archive_name+nd, '.'); if(vs_ptr==NULL) msg_strcat(archive_name, M_EXE_EXT); else msg_strcpy(vs_ptr, M_EXE_EXT); } } /* Looks for an extension of the given filename in the extension list */ int search_for_extension(char *name, char *ext_list) { int match; char *endptr; char ext_pad[EXTENSION_MAX+1]; char *t_ptr; int i; match=0; endptr=&ext_list[strlen(ext_list)]; t_ptr=ext_list; while(t_ptr!=endptr) { if(*t_ptr=='.') t_ptr++; ext_pad[0]='.'; for(i=0; iremain&&bufsiz>MIN_CRITICAL_BUFSIZ) bufsiz>>=1; if(bufsiz0) inc=remain; if(inc<=0) { volume_flag_set=1; return(0); } if((long)increment*2L>remain) { if(inc>1000) rc=(inc-inc%500)>>1; else if(inc>2000) rc=inc-1000; else rc=(inc>512)?inc>>1:inc; } /* Mistrust the return value. That would help to get around certain compiler optimization bugs (as with OpenWatcom v 1.1RC) - at least the wrong value won't be passed to fread() causing buffer overrun. */ return(min(rc, increment)); } /* Compares the extension from pad with the file's extension. Returns 1 if there was a match. */ static int compare_exts(char *name, char *pad) { int k; /* si = name, di = pad */ if(strlen(pad)==1&&strchr(name, '.')==NULL) return(1); k=strlen(name)-strlen(pad); if(k<0) return(0); else return(strcmp_os(name+k, pad)==0); } /* "Stores" a file by simply copying it */ void store() { int fetch_size; unsigned int mem_size; char *fetch; int to_read; fetch=(char *)malloc_msg(PROC_BLOCK_SIZE); mem_stats(); origsize=0L; cpos=0; ext_voldata=0; display_indicator(0L); crc32term=CRC_MASK; to_read=PROC_BLOCK_SIZE; if(multivolume_option&&file_packing) to_read=check_multivolume(to_read); if(file_packing) { while((fetch_size=fread_crc(fetch, to_read, encstream))>0) { if(garble_enabled) garble_encode_stub(fetch, fetch_size); if(!no_file_activity) { file_write(fetch, 1, fetch_size, aostream); } display_indicator(origsize); if(multivolume_option) to_read=check_multivolume(to_read); } } else { while(encmem_remain!=0) { mem_size=min((unsigned int)PROC_BLOCK_SIZE, encmem_remain); far_memmove((char FAR *)fetch, encblock_ptr, mem_size); crc32_for_block(fetch, mem_size); if(garble_enabled) garble_encode_stub(fetch, mem_size); far_memmove(packblock_ptr, (char FAR *)fetch, mem_size); encblock_ptr+=mem_size; packblock_ptr+=mem_size; origsize+=mem_size; encmem_remain-=mem_size; /* Changed this order. This is an ASR fix for High C beta -- 05/04/2001 */ } } free(fetch); compsize=origsize; } /* Performs a "hollow" file processing (just calculates the CRC) */ void hollow_encode() { int fetch_size; char *fetch; fetch=(char *)malloc_msg(PROC_BLOCK_SIZE); mem_stats(); origsize=0L; out_bytes=0; cpos=0; ext_voldata=0; display_indicator(0L); crc32term=CRC_MASK; fetch_size=PROC_BLOCK_SIZE; while(fread_crc(fetch, fetch_size, encstream)!=0) display_indicator(origsize); free(fetch); compsize=0L; } #endif #if SFX_LEVEL>=ARJ||defined(REARJ) /* Retrieves a pair of decimal digits from the given pointer */ static int get_dec_pair(char *str) { if(str[0]=='\0') return(0); if(str[1]=='\0') return((int)str[0]-'0'); return((int)(str[0]-'0')*10+(int)(str[1]-'0')); } /* Converts the given time string ("yyyymmddhhmmss") to the internal timestamp format */ void convert_strtime(struct timestamp *dest, char *str) { char tmp_strtime[30]; int y, m, d, hh, mm, ss; /* Timestamp components */ strncpy(tmp_strtime, str, 14); tmp_strtime[14]='\0'; strcat(tmp_strtime, strtime_filler); y=get_dec_pair(tmp_strtime); if(y>=19&&y<80) { y=y*100+get_dec_pair(tmp_strtime+2); m=get_dec_pair(tmp_strtime+4); d=get_dec_pair(tmp_strtime+6); hh=get_dec_pair(tmp_strtime+8); mm=get_dec_pair(tmp_strtime+10); ss=get_dec_pair(tmp_strtime+12); } else { m=get_dec_pair(tmp_strtime+2); d=get_dec_pair(tmp_strtime+4); hh=get_dec_pair(tmp_strtime+6); mm=get_dec_pair(tmp_strtime+8); ss=get_dec_pair(tmp_strtime+10); y+=(y>=80)?1900:2000; } if(m<1||m>12||d<1||d>31||hh>23||mm>59||ss>59) error(M_INVALID_DATE_STRING, str); make_timestamp(dest, y, m, d, hh, mm, ss); } #endif #if SFX_LEVEL>=ARJSFXV||defined(REARJ) /* Checks integrity of the executable file */ int check_integrity(char *name) { #if SFX_LEVEL>=ARJ char *buf; int f_len=PROC_BLOCK_SIZE; #else char buf[CACHE_SIZE]; int f_len=CACHE_SIZE; #endif FILE *stream; int p_len; int fetch, i; int c; char *bptr; unsigned long wr_pos; unsigned long fsize, cur_pos; char pattern[20]; unsigned long st_crc, st_fsize; /* Stored parameters */ #if SFX_LEVEL>=ARJ buf=(char *)malloc_msg(f_len); #endif stream=file_open(name, m_rb); if(stream==NULL) { msg_cprintf(H_ERR, M_CANTOPEN, name); #if SFX_LEVEL>=ARJ nputlf(); return(0); #else return(1); #endif } strcpy(pattern, (char *)integrity_pattern); pattern[0]--; p_len=strlen(pattern); fseek(stream, 0L, SEEK_END); fsize=ftell(stream); fseek(stream, 0L, SEEK_SET); crc32term=CRC_MASK; cur_pos=0L; while(1) { fseek(stream, cur_pos, SEEK_SET); fetch=fread(buf, 1, f_len, stream); if(fetch==0) #if SFX_LEVEL>=ARJSFXV error(M_CANTREAD); #else pause_error(M_NO_INTEGRITY_PATTERN); #endif fetch-=p_len; bptr=buf; for(i=0; i=ARJSFXV error(M_CANTREAD); #else pause_error(M_NO_INTEGRITY_PATTERN); #endif if(fread(&st_fsize, 1, 4, stream)!=4) #if SFX_LEVEL>=ARJSFXV error(M_CANTREAD); #else pause_error(M_NO_INTEGRITY_PATTERN); #endif #ifdef WORDS_BIGENDIAN /* Another dirty hack */ st_crc = mget_dword((char*) &st_crc); st_fsize = mget_dword((char*) &st_fsize); #endif crc32term=CRC_MASK; fseek(stream, 0L, SEEK_SET); for(cur_pos=0L; cur_pos=ARJSFXV error(M_CANTREAD); #else pause_error(M_NO_INTEGRITY_PATTERN); #endif crc32term=crc32_for_char(crc32term, (unsigned char)c); } cur_pos+=8L; fseek(stream, cur_pos, SEEK_SET); while(cur_pos=ARJSFXV error(M_CANTREAD); #else pause_error(M_NO_INTEGRITY_PATTERN); #endif crc32term=crc32_for_char(crc32term, (unsigned char)c); cur_pos++; } fsize+=2L; #if SFX_LEVEL>=ARJ free(buf); #endif fclose(stream); #if SFX_LEVEL>=ARJSFXV return(crc32term==st_crc&&fsize==st_fsize); #else if(crc32term==st_crc&&fsize==st_fsize) msg_cprintf(0, M_INTEGRITY_OK); else pause_error(M_INTEGRITY_VIOLATED); return(0); #endif } #endif /* Converts a filename to the format used in current OS (simply substitutes the UNIX separators with DOS ones) */ void name_to_hdr(char *name) { int i; for(i=0; name[i]!='\0'; i++) { if(name[i]==PATHSEP_UNIX) name[i]=PATHSEP_DEFAULT; } } #if SFX_LEVEL>=ARJSFXV /* Formats the given filename to look properly in the "Adding..." and other messages. */ char *format_filename(char *name) { int f_pos, tf_pos; char *result; int ctr; /* Path delimiter counter */ int len; static char name_holder[FNAME_FLEN+1]; int i; if(show_filenames_only) f_pos=split_name(name, NULL, NULL); else f_pos=0; tf_pos=f_pos; ctr=1; while(name[tf_pos]!='\0') { if(tf_pos>0&&name[tf_pos]==PATHSEP_DEFAULT) ctr++; tf_pos++; } len=ctr*CCHMAXPATH+ctr; if(len>FNAME_FLEN-1) len=FNAME_FLEN-1; result=&name[f_pos]; if(strlen(result)=ARJ /* Parses the given argument to a file attribute bitmap */ static void parse_attrs(char *str) { char *sptr, *attrptr; char *g_attr; char c; int attrno; file_attr_mask=TAG_FILES; if(*str=='\0') file_attr_mask=TAG_RDONLY|TAG_SYSTEM|TAG_HIDDEN|TAG_DIREC|TAG_LABEL| TAG_CHAPTER|TAG_NORMAL|TAG_WINLFN; else { sptr=str; attrptr=allowed_attrs; while((c=*sptr++)!='\0') { c=toupper(c); if((g_attr=strchr(attrptr, c))==NULL) error(M_INVALID_SWITCH, str); attrno=g_attr-attrptr-1; if(attrno>=0) file_attr_mask|=1<=ARJSFXV /* Returns 1 if the switch has a "tail" of extra dataa */ static int get_switch_state(char *sw) { if(sw[0]=='\0') return(0); if((sw[0]=='+'||sw[0]=='-')&&sw[1]=='\0') return(0); return(1); } /* Parses query list given by -jy for ARJ and -y for ARJSFX */ static void parse_yes_queries(char *sw) { char *swptr; unsigned int c; int **index; FMSG *table; FMSG *entry; int num; swptr=sw; while((c=(unsigned int)*(swptr++))!='\0') { c=toupper(c); index=jysw_index; table=M_JYSW_TABLE; if((entry=msg_strchr(table, (char)c))==NULL) error(M_INVALID_SWITCH, sw); num=entry-table; if(*swptr=='+') { *index[num]=1; swptr++; } else if(*swptr=='-') { *index[num]=0; swptr++; } *index[num]=!*index[num]; } } #endif #if SFX_LEVEL>=ARJ&&TARGET==UNIX /* Disables/enables archiving for a particular block device */ static void add_blkdev_spec(char *swptr) { int is_excl=0; char *fnm; if(swptr[0]=='-') { is_excl=1; swptr++; } else if(swptr[0]=='+') swptr++; fnm=(swptr[0]=='\0')?".":swptr; set_dev_mode(is_excl); if(add_dev(fnm)) msg_cprintf(H_ALERT, M_BAD_DEV_SPEC, fnm); } #endif #if SFX_LEVEL>=ARKSFXV /* A user-friendly strtoul(). Can tell between hex and decimal notations */ unsigned long stoul(char *p, char **rp) { unsigned int radix; unsigned long rc; char c; if(rp==NULL) rp=&p; if(p==NULL) { *rp=p; return(0); } if(p[0]=='0'&&p[1]=='x') { p+=2; radix=16; } else radix=10; rc=strtoul(p, rp, radix); c=toupper(**rp); if(c=='K') { *rp++; rc*=1000L; } else if(c=='M') { *rp++; rc*=1000000L; } else if(c=='G') { *rp++; rc*=1000000000L; } else if(c=='T'||c=='P'||c=='E') /* BUGBUG: Reserved */ { *rp++; rc*=0xFFFFFFFF; } return(rc); } #endif #if SFX_LEVEL>=ARJSFXJR /* Sets internal variables depending on the switch given */ void analyze_arg(char *sw) { char *swptr; unsigned int c; FMSG *entry; int num; /* Switch number within the table */ #if SFX_LEVEL>=ARJSFXV int done; FMSG *table; FMSG *params; int **index; char lim; int sw_tail; #endif #if SFX_LEVEL>=ARJ int type; char vol_sw; /* -v... subswitch storage */ int p_len; char *p_ptr; unsigned long cnv_num; #endif swptr=sw; if(swptr[0]==swptr[1]&&swptr[2]=='\0') skip_switch_processing=1; else { swptr++; #if SFX_LEVEL>=ARJ hswitch=jswitch=os2switch=0; if(toupper(*swptr)=='H'&&*(swptr+1)=='2') swptr++; if(*swptr=='2') { os2switch=1; swptr++; } #endif #if SFX_LEVEL>=ARJSFXV done=0; #endif while((c=(unsigned int)*(swptr++))!='\0') { c=toupper(c); #if SFX_LEVEL>=ARJ if(jswitch) { table=M_JSW_TABLE; params=M_JSW_PARAMS; index=jsw_index; } else if(hswitch) { table=M_HSW_TABLE; params=M_HSW_PARAMS; index=hsw_index; } else if(os2switch) { table=M_OS2SW_TABLE; params=M_OS2SW_PARAMS; index=os2sw_index; } else { table=M_SW_TABLE; params=M_SW_PARAMS; index=sw_index; } #elif SFX_LEVEL>=ARJSFXV table=M_SW_TABLE; params=M_SW_PARAMS; index=sw_index; #endif #if SFX_LEVEL>=ARJSFXV entry=msg_strchr(table, (char)c); #else entry=msg_strchr(M_SW_TABLE, (char)c); #endif if(entry==NULL) { #if SFX_LEVEL>=ARJSFXV error(M_INVALID_SWITCH, sw); #else msg_cprintf(0, M_ARJSFX_BANNER, exe_name); msg_cprintf(0, M_INVALID_SWITCH, (char)c); check_fmsg(CHKMSG_NOSKIP); exit(ARJSFX_ERL_ERROR); #endif } #if SFX_LEVEL>=ARJSFXV num=entry-table; #else num=entry-M_SW_TABLE; #endif #if SFX_LEVEL>=ARJSFXV lim=params[num]; sw_tail=get_switch_state(swptr); #endif /* ARJ parameters */ #if SFX_LEVEL>=ARJ if(!jswitch&&!hswitch&&!os2switch&&c=='G'&&sw_tail) { done=1; garble_enabled=1; garble_password=swptr; } else if(!jswitch&&!hswitch&&!os2switch&&c=='E'&&sw_tail) { done=1; left_trim=(unsigned int)stoul(swptr, &swptr); exclude_paths=(left_trim==0)?EP_PATH:EP_BASEDIR; } else if(!jswitch&&!hswitch&&!os2switch&&c=='L'&&sw_tail) { done=1; create_list_file=1; list_file=swptr; } else if(!jswitch&&!hswitch&&!os2switch&&c=='O'&&sw_tail) { done=1; if(toupper(*swptr)=='B') { if(*++swptr=='-') filter_older=TCHECK_NOTHING; else { filter_older=TCHECK_FTIME; timestr_older=swptr; } } else if(toupper(*swptr)=='D') { swptr++; if(*swptr=='-') filter_same_or_newer=TCHECK_NOTHING; else if(toupper(*swptr)=='B') { filter_older=TCHECK_NDAYS; swptr++; timestr_older=swptr; } else { filter_same_or_newer=TCHECK_NDAYS; timestr_newer=swptr; } } else if(toupper(*swptr)=='C') { swptr++; if(toupper(*swptr)=='B') { filter_older=TCHECK_CTIME; swptr++; timestr_older=swptr; } else { filter_same_or_newer=TCHECK_CTIME; timestr_newer=swptr; } } else if(toupper(*swptr)=='A') { swptr++; if(toupper(*swptr)=='B') { filter_older=TCHECK_ATIME; swptr++; timestr_older=swptr; } else { filter_same_or_newer=TCHECK_ATIME; timestr_newer=swptr; } } else { filter_same_or_newer=TCHECK_FTIME; timestr_newer=swptr; } } else if(!jswitch&&!hswitch&&!os2switch&&c=='T'&&sw_tail) { done=1; type_override=FT_BINARY; type=(int)(*swptr-'0'); if(type!=ARJT_BINARY&&type!=ARJT_TEXT) error(M_INVALID_SWITCH, sw); swptr++; /* ASR fix 25/01/2004: the "-t1gf" combination was the only way to enforce "text with graphics" which was not trivial. Now "-t1g" should do it as well. */ if(type==ARJT_TEXT) type_override=FT_TEXT; while((c=toupper(*swptr))=='G'||c=='F') { if(c=='G') type_override=FT_TEXT_GRAPHICS; else if(c=='F'&&type_override2) error(M_INVALID_SWITCH, sw); if(swptr[1]!=':'&&swptr[1]!='\0') error(M_INVALID_SWITCH, sw); } else if(!jswitch&&!hswitch&&!os2switch&&c=='+'&&sw_tail) done=1; else if(hswitch&&c=='B') { done=1; filter_attrs=1; parse_attrs(swptr); } else if(hswitch&&c=='C'&&sw_tail) { done=1; run_cmd_at_start=1; start_cmd=swptr; } else if(hswitch&&c=='D') { if(*swptr=='\0') error(M_INVALID_SWITCH, sw); done=1; debug_enabled=1; debug_opt=swptr; } else if(hswitch&&c=='G') { done=1; gost_cipher=GOST256; if(*swptr=='!'&&swptr[1]=='\0') gost_cipher=GOST40; else arjcrypt_name=swptr; } else if(hswitch&&c=='M') { done=1; filelist_storage=BST_DISK; max_filenames=(FILE_COUNT)stoul(swptr, &swptr); if(max_filenames==0) max_filenames=EXT_FILELIST_CAPACITY; if(*swptr=='!'&&swptr[1]!='\0') swptr_hm=++swptr; #if TARGET==DOS else if(*swptr=='!'&&swptr[1]=='\0') filelist_storage=BST_XMS; #endif } else if(hswitch&&c=='N') { done=1; nonexist_filespec=1; nonexist_name=swptr; } else if(hswitch&&c=='P') { done=1; arjdisp_enabled=1; arjdisp_ptr=swptr; } else if(hswitch&&c=='T') { done=1; set_target_directory=1; p_len=strlen(swptr); p_ptr=&swptr[p_len-1]; while(*p_ptr==' ') p_ptr--; if(strchr(path_separators, *p_ptr)!=NULL) target_dir=swptr; else { strcpy(target_dir=malloc_msg(p_len+2), swptr); target_dir[p_len]=PATHSEP_DEFAULT; target_dir[p_len+1]='\0'; } } else if(hswitch&&c=='V') { done=1; chk_arj_version=1; swptr_hv=swptr; } else if(hswitch&&c=='X') { done=1; override_archive_exts=1; archive_ext_list=swptr; if(swptr[0]!='.'||swptr[1]=='\0') error(M_INVALID_SWITCH, sw); } else if(hswitch&&c=='Z') { done=1; sign_with_arjsec=1; arjsec_env_name=swptr; } else if(hswitch&&c=='#'&&*swptr!='\0'&&!isdigit(*swptr)) { done=1; append_curtime=1; time_str=swptr; } else if(jswitch&&c=='C'&&sw_tail) { done=1; exit_after_count=1; exit_count=(FILE_COUNT)stoul(swptr, &swptr); } else if(jswitch&&c=='D'&&sw_tail) { done=1; chk_free_space=1; minfree=stoul(swptr, &swptr); } else if(jswitch&&c=='B'&&sw_tail) { done=1; chapter_mode=CHAP_USE; if(*swptr=='*') { swptr++; current_chapter=1; chapter_to_process=RESERVED_CHAPTER; } else { cnv_num=stoul(swptr, &swptr); chapter_to_process=current_chapter=(int)cnv_num; if(*swptr++=='-') { if(*swptr=='\0') chapter_to_process=RESERVED_CHAPTER; else { cnv_num=stoul(swptr, &swptr); chapter_to_process=(int)cnv_num; if(chapter_to_process>CHAPTERS_MAX) error(M_INVALID_SWITCH, sw); } } if(current_chapter==0&&chapter_to_process==0) chapter_mode=CHAP_REMOVE; } } else if(jswitch&&c=='H'&&sw_tail) { done=1; jh_enabled=1; cnv_num=stoul(swptr, &swptr); if(cnv_num<(unsigned long)MIN_BUFSIZ||cnv_num>(unsigned long)MAX_USER_BUFSIZ) error(M_INVALID_SWITCH, sw); #if MAX_BUFSIZ(unsigned long)MAX_BUFSIZ) cnv_num=MAX_BUFSIZ; #endif user_bufsiz=(unsigned int)cnv_num; } else if(jswitch&&c=='I'&&sw_tail) { done=1; create_index=1; index_name=swptr; } else if(jswitch&&c=='N'&&sw_tail) { done=1; restart_at_filename=1; filename_to_restart=swptr; } else if(jswitch&&c=='Q'&&sw_tail) { done=1; set_string_parameter=1; string_parameter=swptr; } else if(jswitch&&c=='P'&&sw_tail) { done=1; prompt_for_more=1; cnv_num=stoul(swptr, &swptr); if(cnv_num>0L) lines_per_page=(int)cnv_num; } else if(jswitch&&c=='S'&&sw_tail) { done=1; store_by_suffix=1; free_fmsg(archive_suffixes); archive_suffixes=swptr; } else if(jswitch&&c=='W'&&sw_tail) { done=1; extract_to_file=1; extraction_filename=swptr; } else if(jswitch&&c=='X'&&sw_tail) { done=1; start_at_ext_pos=1; ext_pos=stoul(swptr, &swptr); } else if(jswitch&&c=='Y'&&sw_tail) { done=1; assume_yes=1; yes_query_list=swptr; parse_yes_queries(yes_query_list); } else if(jswitch&&c=='Z'&&sw_tail) { done=1; supply_comment_file=1; comment_file=swptr; } #if TARGET==UNIX else if(os2switch&&c=='B') { done=1; add_blkdev_spec(swptr); } #endif else if(os2switch&&c=='E') { done=1; if(!sw_tail) ea_supported=0; else { include_eas=1; #if defined(HAVE_EAS) flist_add_files(&flist_ea, NULL, swptr, 0, 0, 0, NULL); #endif } } else if(os2switch&&c=='I'&&sw_tail) { done=1; start_with_seek=1; arcv_ext_pos=stoul(swptr, &swptr); } else if(os2switch&&c=='P') { if(!sw_tail) error(M_INVALID_SWITCH, sw); priority.class=stoul(swptr, &swptr); if(priority.class<1||priority.class>PRIORITY_CLASSES) error(M_INVALID_SWITCH, sw); #if TARGET==OS2||TARGET==WIN32 if((p_ptr=strchr(swptr, ':'))==NULL) priority.delta=0; else { swptr=p_ptr+1; priority.delta=stoul(swptr, &swptr); #if TARGET==OS2 if(priority.delta<-31||priority.delta>31) #elif TARGET==WIN32 if(priority.delta<-2||priority.delta>2) #else #error No priority delta limits! #endif error(M_INVALID_SWITCH, sw); } #else priority.delta=0; #endif } #ifdef COLOR_OUTPUT else if(os2switch&&c=='T') { done=!parse_colors(swptr); if(!done) error(M_INVALID_SWITCH, sw); } #endif else if(os2switch&&c=='X') { done=1; if(!sw_tail) error(M_MISSING_FILENAME_ARG, "-2x"); else { exclude_eas=1; #if defined(HAVE_EAS) flist_add_files(&flist_xea, NULL, swptr, 0, 0, 0, NULL); #endif } } else if(*swptr=='+') { *index[num]=1; swptr++; } else if(*swptr=='-') { *index[num]=0; swptr++; } else if(*swptr>='0'&&*swptr<='9') { if(!debug_enabled||strchr(debug_opt, 's')==NULL) { if(*swptr>lim) error(M_INVALID_SWITCH, sw); } *index[num]=(int)(*(swptr++)+1-'0'); } else *index[num]=!*index[num]; /* ARJSFXV parameters */ #elif SFX_LEVEL==ARJSFXV if(c=='G'&&sw_tail) { done=1; garble_enabled=1; garble_password=swptr; } else if(c=='+'&&sw_tail) done=1; else if(c=='&') { if(*swptr=='\0') error(M_INVALID_SWITCH, sw); done=1; debug_enabled=1; debug_opt=swptr; } else if(c=='@') { done=1; arjdisp_enabled=1; arjdisp_ptr=swptr; } else if(c=='!') { done=1; execute_extr_cmd=1; extr_cmd_text=swptr; } else if(c=='$'&&sw_tail) { done=1; handle_labels=1; label_drive=toupper(*swptr); if(!isalpha(*swptr)||strlen(swptr)>2) error(M_INVALID_SWITCH, sw); if(swptr[1]!=':'&&swptr[1]!='\0') error(M_INVALID_SWITCH, sw); } else if(c=='W'&&sw_tail) { done=1; extract_to_file=1; extraction_filename=swptr; } else if(c=='D'&&sw_tail) { done=1; chk_free_space=1; minfree=stoul(swptr, &swptr); } else if(c=='#'&&sw_tail) { done=1; skip_volumes=1; first_volume_number=stoul(swptr, &swptr); } else if(c=='O'&&sw_tail) { done=1; gost_cipher=GOST256; arjcrypt_name=swptr; } else if(c=='Z'&&sw_tail) { done=1; assume_yes=1; yes_query_list=swptr; parse_yes_queries(yes_query_list); } else if(*swptr=='+') { *index[num]=1; swptr++; } else if(*swptr=='-') { *index[num]=0; swptr++; } else if(*swptr>='0'&&*swptr<='3') { if(!debug_enabled||strchr(debug_opt, 's')==NULL) { if(*swptr>lim) error(M_INVALID_SWITCH, sw); } *index[num]=(int)(*(swptr++)+1-'0'); } else *index[num]=!*index[num]; /* ARJSFX parameters */ #elif SFX_LEVEL==ARJSFX *sw_index[num]=1; if(c=='G'&&*swptr!='\0') { garble_password=swptr; while(*swptr!='\0') swptr++; } if(c=='!') { extr_cmd_text=swptr; while(*swptr!='\0') swptr++; } #endif #if SFX_LEVEL>=ARJSFXV if(done) { while(*swptr!='\0') swptr++; } #endif } } } #endif #if SFX_LEVEL>=ARJSFXV /* Initializes system variables with default settings prior to setup procedures */ void init() { unsigned int i; #if SFX_LEVEL>=ARJ multivolume_option=0; #else multivolume_option=1; #endif #if SFX_LEVEL>=ARJ for(i=0; i=ARJ for(i=0; i=ARJ primary_file_type=ARJT_BINARY; #endif listchar=LISTCHAR_DEFAULT; #if SFX_LEVEL>=ARJ lines_per_page=query_screen_height(); #endif listchars_allowed=1; ctrlc_not_busy=1; #if SFX_LEVEL>=ARJ file_args=-1; #else file_args=0; #endif #if SFX_LEVEL<=ARJSFXV extract_expath=0; extract_cmd=0; list_sfx_cmd=0; verbose_list=0; test_sfx_cmd=0; error_occured=0; licensed_sfx=0; logo_shown=0; #endif #if SFX_LEVEL>=ARJ max_filenames=EXT_FILELIST_CAPACITY; ctrlc_processing=0; display_totals=0; lines_scrolled=0; #endif errors=0; #if SFX_LEVEL>=ARJ ts_store(&tested_ftime_newer, OS_SPECIAL, 0); ts_store(&tested_ftime_older, OS_SPECIAL, 0); last_hdr_offset=0L; tmp_archive_used=0; arch_wildcard_allowed=0; file_attr_mask=TAG_FILES; recursion_order=RO_LAST; encryption_id=0; use_ansi_cp=0; filter_fa_arch=0; serialize_exts=0; #else file_garbled=0; #endif allow_any_attrs=0; #if SFX_LEVEL>=ARJ set_target_directory=0; chapter_mode=0; #endif install_errhdl=0; #if SFX_LEVEL<=ARJSFXV prompt_for_directory=0; #endif debug_enabled=0; #if SFX_LEVEL>=ARJ delete_processed=0; run_cmd_at_start=0; arjsec_opt=0; exclude_paths=0; execute_cmd=0; start_at_ext_pos=0; start_with_seek=0; arcv_ext_pos=0; subdir_extraction=0; extm_mode=0; override_archive_exts=0; disable_comment_series=0; skip_century=CENT_DEFAULT; show_filenames_only=0; force_lfn=0; chk_free_space=0; freshen_criteria=FC_NONE; validate_style=0; jh_enabled=0; clear_archive_bit=0; ignore_archive_errors=0; ignore_open_errors=0; detailed_index=0; create_index=0; keep_bak=0; keep_tmp_archive=0; sign_with_arjsec=0; handle_labels=0; listfile_err_opt=0; create_list_file=0; std_list_cmd=0; filelist_storage=0; max_compression=0; custom_method=0; skip_time_attrs=0; indicator_style=0; yes_on_all_queries=0; disable_sharing=0; skip_switch_processing=0; no_file_activity=0; new_files_only=0; filter_same_or_newer=0; rsp_per_line=0; gost_cipher=0; marksym_expansion=0; fnm_matching=0; arcmail_sw=0; dos_host=0; priority.class=priority.delta=0; #endif arjdisp_enabled=0; #if SFX_LEVEL<=ARJSFXV subdir_extraction=0; execute_cmd=0; show_filenames_only=0; chk_free_space=0; freshen_criteria=FC_NONE; validate_style=VALIDATE_ALL; garble_enabled=0; overwrite_ro=0; handle_labels=0; listfile_err_opt=0; std_list_cmd=0; indicator_style=0; yes_on_all_queries=0; disable_sharing=1; skip_switch_processing=0; new_files_only=0; fnm_matching=0; execute_extr_cmd=0; #endif #if SFX_LEVEL>=ARJ protfile_option=0; query_for_each_file=0; set_string_parameter=0; lowercase_names=0; #endif ignore_crc_errors=0; recurse_subdirs=0; quiet_mode=0; #if SFX_LEVEL<=ARJSFXV skip_volumes=0; #endif keep_tmp_file=0; print_with_more=0; #if SFX_LEVEL<=ARJSFXV valid_envelope=0; process_lfn_archive=0; skip_preset_options=0; #endif #if SFX_LEVEL>=ARJ search_mode=0; select_backup_files=0; filter_attrs=0; create_sfx=0; lfn_mode=0; comment_display=0; #endif skip_ts_check=0; #if SFX_LEVEL>=ARJ store_by_suffix=0; test_archive_crc=0; timestamp_override=0; type_override=0; translate_unix_paths=0; #endif update_criteria=UC_NONE; #if SFX_LEVEL>=ARJ verbose_display=0; chk_arj_version=0; beep_between_volumes=0; allow_mv_update=0; mv_cmd_state=0; whole_files_in_mv=0; #endif #if SFX_LEVEL>=ARJSFXV /* To keep v 2.71 order */ use_sfxstub=0; #endif #if SFX_LEVEL>=ARJ assign_work_directory=0; #endif extract_to_file=0; assume_yes=0; kbd_cleanup_on_input=0; skip_append_query=0; prompt_for_mkdir=0; #if SFX_LEVEL>=ARJ query_delete=0; #endif skip_space_query=0; skip_rename_prompt=0; overwrite_existing=0; #if SFX_LEVEL>=ARJ skip_scanned_query=0; #endif skip_next_vol_query=0; #if SFX_LEVEL>=ARJ accept_shortcut_keys=0; #else reg_id=0; first_volume_number=0; #endif #if SFX_LEVEL>=ARJ use_comment=0; supply_comment_file=0; current_chapter=0; chapter_to_process=0; resume_volume_num=0; exit_count=0; left_trim=0; ext_pos=0; #endif label_drive=0; minfree=0L; #if SFX_LEVEL>=ARJ volume_limit=0L; mv_reserve_space=0L; t_volume_offset=0L; #endif av_uncompressed=0L; av_compressed=0L; av_total_files=0; av_total_longnames=0; #if SFX_LEVEL>=ARJ total_size=0L; user_bufsiz=current_bufsiz=BUFSIZ_DEFAULT; ntext=NULL; /* ASR fix for 2.76.06 */ #if TARGET==UNIX sl_entries.list=l_entries.list=NULL; sl_entries.total=sl_entries.alloc=l_entries.total=l_entries.alloc=0; #endif #endif nonexist_name=nonexistent_name; archive_suffixes=malloc_fmsg(M_ARCHIVE_SUFFIXES); #if SFX_LEVEL>=ARJ swptr_t=nullstr; work_directory=nullstr; #endif target_dir=nullstr; #if SFX_LEVEL>=ARJ swptr_hm=nullstr; start_cmd=nullstr; cmd_to_exec=nullstr; archive_ext_list=nullstr; index_name=nullstr; #endif debug_opt=nullstr; #if SFX_LEVEL>=ARJ timestr_newer=nullstr; timestr_older=nullstr; #else extr_cmd_text=nullstr; garble_password=nullstr; #endif arjdisp_ptr=nullstr; #if SFX_LEVEL>=ARJ filename_to_restart=nullstr; mv_cmd=nullstr; arjsec_env_name=nullstr; list_file=nullstr; arjcrypt_name=nullstr; string_parameter=nullstr; swptr_hv=nullstr; time_str=nullstr; #endif extraction_filename=nullstr; yes_query_list=nullstr; #if SFX_LEVEL>=ARJ archive_cmt_name=nullstr; comment_file=nullstr; #endif tmp_tmp_filename[0]='\0'; archive_name[0]='\0'; #if SFX_LEVEL<=ARJSFXV aistream=NULL; atstream=NULL; #endif file_packing=1; #if SFX_LEVEL>=ARJSFXV eh=NULL; valid_ext_hdr=0; #endif #if SFX_LEVEL>=ARJ include_eas=0; exclude_eas=0; crit_eas=0; fix_longnames=0; symlink_accuracy=0; do_chown=0; suppress_hardlinks=0; #endif } /* Returns 1 if the given argument is a command-line switch */ int is_switch(char *arg) { int rc; if(!skip_switch_processing&&switch_char!=0&&(int)arg[0]==switch_char) rc=1; else if(!skip_switch_processing&&switch_char==0) rc=(strchr(switch_chars, arg[0])==NULL)?0:1; else rc=0; if(rc&&switch_char==0) switch_char=(int)arg[0]; return(rc); } #endif #if SFX_LEVEL>=ARJ /* Performs general command-line analysis and returns the command being requested. */ int preprocess_cmdline(int argc, char *argv[]) { int i; int cmd; char *arg; cmd=0; new_stdout=stdout; disable_arj_sw=0; skip_switch_processing=0; rsp_name=nullstr; /* ASR fix -- 15/10/2000 (ARJ/2-32) */ switch_char=0; install_errhdl=0; quiet_mode=0; use_ansi_cp=0; file_garbled=0; garble_enabled=0; garble_password=nullstr; arj_env_name=malloc_fmsg(M_ARJ_SW); for(i=1; i=ARJSFX||defined(REARJ) /* Splits the given name to pathname and filename. On return, pathname contains ASCIIZ path specification including path terminator, filename contains ASCIIZ filename (with no preceding path terminators), and the return value is the offset of filename within the given name. */ #if SFX_LEVEL>=ARJSFXV||defined(REARJ) int split_name(char *name, char *pathname, char *filename) #else int split_name(char *name) #endif { char *f_sep, *last_sep; int i, sep_offset; last_sep=NULL; for(i=0; path_separators[i]!='\0'; i++) { if((f_sep=strrchr(name, path_separators[i]))!=NULL) { if(last_sep==NULL||f_sep>last_sep) last_sep=f_sep; } } sep_offset=(last_sep==NULL)?0:last_sep-name+1; #if SFX_LEVEL>=ARJSFXV||defined(REARJ) if(pathname!=NULL) strcpyn(pathname, name, sep_offset+1); if(filename!=NULL) strcpy(filename, name+sep_offset); #endif return(sep_offset); } #endif #if SFX_LEVEL>=ARJSFXV /* Returns the error code for error message given */ int subclass_errors(FMSG *errmsg) { if(errmsg==M_OUT_OF_MEMORY||errmsg==M_OUT_OF_NEAR_MEMORY) return(ARJ_ERL_NO_MEMORY); if(errmsg==M_HEADER_CRC_ERROR||errmsg==M_CRC_ERROR) return(ARJ_ERL_CRC_ERROR); #if SFX_LEVEL>=ARJ if(errmsg==M_DAMAGED_SEC_ARCHIVE||errmsg==M_CANT_UPDATE_SEC||errmsg==M_SKIPPING_SEC) return(ARJ_ERL_ARJSEC_ERROR); #endif if(errmsg==M_DISK_FULL) return(ARJ_ERL_DISK_FULL); if(errmsg==M_CANTOPEN) return(ARJ_ERL_CANTOPEN); if(errmsg==M_NOT_ARJ_ARCHIVE) return(ARJ_ERL_NOT_ARJ_ARCHIVE); #if SFX_LEVEL>=ARJ #if TARGET==DOS if(errmsg==M_LISTING_XMS_ERROR) return(ARJ_ERL_XMS_ERROR); #endif if(errmsg==M_TOO_MANY_CHAPTERS) return(ARJ_ERL_TOO_MANY_CHAPTERS); #endif if(errmsg==M_INVALID_SWITCH||errmsg==M_ARGTABLE_OVERFLOW||errmsg==M_NO_FILE_GIVEN|| #if SFX_LEVEL>=ARJ errmsg==M_NO_DELETE_ARG||errmsg==M_INVALID_VOL_SIZE|| errmsg==M_NO_STR_ENTERED||errmsg==M_JT_UNUSABLE|| #endif errmsg==M_NO_PWD_OPTION|| errmsg==M_MISSING_FILENAME_ARG||errmsg==M_INVALID_DATE_STRING||errmsg==M_BAD_SYNTAX) return(ARJ_ERL_USER_ERROR); return(ARJ_ERL_FATAL_ERROR); } #endif #if SFX_LEVEL>=ARJ /* Retrieves search data from string parameter given by -jq */ static int get_str_from_jq() { char *sptr, *tsptr; char *endptr; int patterns; char pt; sptr=string_parameter; if(sptr[0]!='+'&&sptr[0]!='-') error(M_INVALID_PARAM_STR, sptr); ignore_pcase=sptr[0]=='+'; fdisp_lines=(int)stoul(sptr, &sptr); patterns=0; if(*sptr!='\0') { pt=*sptr; sptr++; /* Tokenize string_parameter */ for(tsptr=sptr; *tsptr!='\0'; tsptr++) if(*tsptr==pt) *tsptr='\0'; endptr=tsptr; tsptr=sptr; while((unsigned int)tsptr<(unsigned int)endptr&&patterns=ARJSFXV /* Performs an optimized seek operation */ void file_seek(FILE *stream, long offset, int whence) { char *buffer; if(whence==SEEK_CUR&&offset>=0L&&offset<=(long)CACHE_SIZE) { buffer=malloc_msg(CACHE_SIZE); if(offset>0L) fread(buffer, 1, (int)offset, stream); free(buffer); } else fseek(stream, offset, whence); } #endif #if SFX_LEVEL>=ARJ /* Performs a search operation set-up */ void search_setup() { char entry[INPUT_LENGTH]; int patterns; if(set_string_parameter&&string_parameter[0]!='\0') patterns=get_str_from_jq(); else { ignore_pcase=query_action(REPLY_NO, QUERY_CRITICAL, M_QUERY_CASE_IGNORE); msg_cprintf(0, M_ENTER_NUM_MATCHES); read_line(entry, sizeof(entry)); fdisp_lines=stoul(entry, NULL); msg_cprintf(0, M_ENTER_SEARCH_STR, SEARCH_STR_MAX); for(patterns=0; patterns0) { if(ignore_pcase) strupper(search_str[patterns]); } if(fdisp_lines!=0) indicator_style=IND_NONE; reserve_size=0; search_reserve=malloc_msg(sizeof(entry)*2); } #endif #if (SFX_LEVEL>=ARJSFX)||defined(ARJDISP) /* Based on the unsigned long values given, calculates their proportion (per mille, so 42.3% is returned as 423). */ int calc_percentage(unsigned long partial, unsigned long total) { int dec; for(dec=0; dec<3; dec++) { if(partial<=0x19999999) partial*=10L; else total/=10L; } if(partial+total/2<=partial) { partial/=2; total/=2; } if(total==0) return(0); else return((partial+total/2)/total); } #endif #if SFX_LEVEL>=ARJSFXV /* Performs a "smart" seeking, depending on file type (special handling is performed for text files) */ void smart_seek(unsigned long position, FILE *stream) { char *tmp_buf; int fetch_size; fseek(stream, 0L, SEEK_SET); if(position>0L) { if(file_type==ARJT_BINARY) fseek(stream, position, SEEK_SET); else { tmp_buf=(char *)malloc_msg(PROC_BLOCK_SIZE); while(position>0L) { fetch_size=(int)min(position, (unsigned long)PROC_BLOCK_SIZE); if(fread(tmp_buf, 1, fetch_size, stream)!=fetch_size) error(M_SEEK_FAILED); position-=(unsigned long)fetch_size; } fseek(stream, 0L, SEEK_CUR); free(tmp_buf); } } } #endif #if SFX_LEVEL>=ARJSFX||defined(REARJ)||defined(REGISTER) /* This procedure trims the extra spaces and tabs at the left and right of line given */ void alltrim(char *cmd) { int fchars; char *lpos; lpos=cmd; for(fchars=strlen(cmd)-1; fchars>=0; fchars--) { if(cmd[fchars]!='\x09'&&cmd[fchars]!=' ') break; } if(fchars>=0) { while(lpos[0]=='\x09'||lpos[0]==' ') { lpos++; fchars--; } while(fchars>=0) { (cmd++)[0]=(lpos++)[0]; fchars--; } } cmd[0]='\0'; } #endif #if SFX_LEVEL>=ARJSFX /* Extracts a stored file */ void unstore(int action) { char *fetch; #if SFX_LEVEL>=ARJSFXV unsigned int fetch_size; unsigned long cur_pos; #endif unsigned long bytes_written; int count; #if SFX_LEVEL>=ARJSFXV fetch=NULL; for(fetch_size=PROC_BLOCK_SIZE; fetch_size>=512; fetch_size-=512) { if((fetch=(char *)malloc(fetch_size))!=NULL) break; } if(fetch==NULL) error(M_OUT_OF_MEMORY); mem_stats(); #else fetch=dec_text; #endif display_indicator(bytes_written=0L); #if SFX_LEVEL>=ARJSFXV if(file_packing) { cur_pos=ftell(aistream); count=min(fetch_size-(cur_pos%fetch_size), compsize); } else count=min(fetch_size, compsize); #else count=min(DICSIZ, compsize); #endif while(compsize>0L) { if(file_packing) { if(fread(fetch, 1, count, aistream)!=count) error(M_CANTREAD); } else { far_memmove((char FAR *)fetch, packblock_ptr, count); packblock_ptr+=count; packmem_remain-=count; } if(file_garbled) #if SFX_LEVEL>=ARJ garble_decode_stub(fetch, count); #else garble_decode(fetch, count); #endif bytes_written+=(unsigned long)count; display_indicator(bytes_written); compsize-=(unsigned long)count; if(extraction_stub(fetch, count, action)) break; #if SFX_LEVEL>=ARJSFXV count=min(fetch_size, compsize); #else count=min(DICSIZ, compsize); #endif } #if SFX_LEVEL>=ARJSFXV free(fetch); #endif } #endif #if SFX_LEVEL>=ARJ /* Performs a "hollow" file decoding (compares the CRC if requested to do so, otherwise quits). */ void hollow_decode(int action) { char *fetch; unsigned long bytes_written; unsigned long cur_pos; int count; if(action==BOP_COMPARE) { fetch=(char *)malloc_msg(PROC_BLOCK_SIZE); mem_stats(); display_indicator(bytes_written=0L); cur_pos=origsize; count=min(cur_pos, (unsigned long)PROC_BLOCK_SIZE); while(cur_pos>0L) { if(fread(fetch, 1, count, tstream)!=count) { identical_filedata=0; break; } crc32_for_block(fetch, count); bytes_written+=(unsigned long)count; display_indicator(bytes_written); cur_pos-=(unsigned long)count; count=min(PROC_BLOCK_SIZE, cur_pos); } free(fetch); } } #endif #if SFX_LEVEL>=ARJ /* Packs a memory block. The destination area must be large enough to hold an unpacked copy. */ void pack_mem(struct mempack *mempack) { unsigned long s_compsize, s_origsize; int s_method, s_packing; int s_type; unsigned long c_t; s_compsize=compsize; s_origsize=origsize; s_method=method; s_packing=file_packing; s_type=file_type; origsize=mempack->origsize; compsize=0L; method=mempack->method; encblock_ptr=mempack->orig; packblock_ptr=mempack->comp+MEMPACK_OVERHEAD; encmem_remain=mempack->origsize; packmem_remain=0; unpackable=0; file_packing=0; file_type=ARJT_BINARY; if(garble_enabled) garble_init(password_modifier); crc32term=CRC_MASK; if(method==1||method==2||method==3) encode_stub(method); else if(method==4) encode_f_stub(); if(unpackable) /* Fall back to method #0 */ { encblock_ptr=mempack->orig; packblock_ptr=mempack->comp+MEMPACK_OVERHEAD; encmem_remain=mempack->origsize; method=0; if(garble_enabled) garble_init(password_modifier); crc32term=CRC_MASK; } if(method==0) store(); c_t=crc32term^CRC_MASK; mempack->comp[0]=c_t&0x000000FF; mempack->comp[1]=(c_t&0x0000FF00)>>8; mempack->comp[2]=(c_t&0x00FF0000)>>16; mempack->comp[3]=(c_t&0xFF000000)>>24; mempack->compsize=compsize+MEMPACK_OVERHEAD; mempack->method=method; file_type=s_type; file_packing=s_packing; compsize=s_compsize; origsize=s_origsize; method=s_method; } #endif #if SFX_LEVEL>=ARJSFXV /* Unpacks a memory block. The destination area must be large enough to hold an unpacked copy. */ void unpack_mem(struct mempack *mempack) { unsigned long s_compsize, s_origsize; int s_method, s_packing, s_type; unsigned long c_t; s_type=file_type; s_compsize=compsize; s_origsize=origsize; s_method=method; s_packing=file_packing; file_type=ARJT_BINARY; origsize=mempack->origsize; encmem_limit=mempack->origsize; compsize=mempack->compsize-MEMPACK_OVERHEAD; method=mempack->method; encblock_ptr=mempack->orig; packblock_ptr=mempack->comp+MEMPACK_OVERHEAD; encmem_remain=0; file_packing=0; packmem_remain=mempack->compsize-MEMPACK_OVERHEAD; /* v 2.76.04+ - to allow for ARJCRYPT modules within SFXV, we reinitialize the encryption only for garbled files (was for garble_enabled until now) */ if(file_garbled) garble_init(password_modifier); crc32term=CRC_MASK; if(method==1||method==2||method==3) decode(BOP_NONE); #if SFX_LEVEL>=ARJ else if(method==4) decode_f(BOP_NONE); #endif else if(method==0) unstore(BOP_NONE); c_t=(unsigned long)((unsigned char)mempack->comp[0])+ ((unsigned long)((unsigned char)mempack->comp[1])<<8)+ ((unsigned long)((unsigned char)mempack->comp[2])<<16)+ ((unsigned long)((unsigned char)mempack->comp[3])<<24); if(c_t!=(crc32term^CRC_MASK)) error(M_CRC_ERROR); file_type=s_type; file_packing=s_packing; compsize=s_compsize; origsize=s_origsize; method=s_method; } #endif /* Strips ending LF character from the given string */ #if SFX_LEVEL>=ARJSFX||defined(REGISTER)||defined(REARJ) void strip_lf(char *str) { int i; if((i=strlen(str))>0) { if(str[i-1]==LF) str[i-1]='\0'; } } #endif /* Trims leftmost spaces */ #if SFX_LEVEL>=ARJ||defined(REGISTER)||defined(REARJ) char *ltrim(char *str) { char *rc; for(rc=str; *rc==' '; rc++); return(rc); } #endif #if defined(WORDS_BIGENDIAN)&&!defined(ARJDISP)&&!defined(REGISTER) /* Model-independent routine to get 2 bytes from far RAM */ unsigned int mget_word(char FAR *p) { unsigned int b0, b1; b0=mget_byte(p); b1=mget_byte(p+1); return (b1<<8)|b0; } /* Model-independent routine to get 4 bytes from far RAM */ unsigned long mget_dword(char FAR *p) { unsigned long w0, w1; w0=mget_word(p); w1=mget_word(p+2); return (w1<<16)|w0; } /* Model-independent routine to store 2 bytes in far RAM */ void mput_word(unsigned int w, char FAR *p) { mput_byte(w&0xFF, p); mput_byte(w>>8 , p+1); } /* Model-independent routine to store 4 bytes in far RAM */ void mput_dword(unsigned long d, char FAR *p) { mput_word(d&0xFFFF, p); mput_word(d>>16 , p+2); } #endif arj-3.10.22/arj_proc.h 666 0 0 4375 10004716342 10623 0ustar /* * $Id: arj_proc.h,v 1.3 2004/01/25 10:39:30 andrew_belov Exp $ * --------------------------------------------------------------------------- * Prototypes of the functions located in ARJ_PROC.C are declared here. * */ #ifndef ARJ_PROC_INCLUDED #define ARJ_PROC_INCLUDED /* Helper macros */ #define mget_byte(p) (*(unsigned char FAR *)(p)&0xFF) #define mput_byte(c, p) *(unsigned char FAR *)(p)=(unsigned char)(c) #ifndef WORDS_BIGENDIAN #define mget_word(p) (*(unsigned short *)(p)&0xFFFF) #define mput_word(w,p) (*(unsigned short *)(p)=(unsigned short)(w)) #define mget_dword(p) (*(unsigned long *)(p)) #define mput_dword(w,p) (*(unsigned long *)(p)=(unsigned long)(w)) #endif /* Prototypes */ void garble_encode_stub(char *data, int len); void garble_decode_stub(char *data, int len); void append_curtime_proc(); void add_pathsep(char *path); void convert_time_limits(); void parse_arj_sw(int cmd, char *arj_sw, char *dest); void copy_bytes(unsigned long nbytes); int translate_path(char *name); void restart_proc(char *dest); int search_for_extension(char *name, char *ext_list); unsigned long get_volfree(unsigned int increment); unsigned int check_multivolume(unsigned int increment); void store(); void hollow_encode(); void convert_strtime(struct timestamp *dest, char *str); int check_integrity(char *name); void name_to_hdr(char *name); char *format_filename(char *name); void analyze_arg(char *sw); void init(); int is_switch(char *arg); int preprocess_cmdline(int argc, char *argv[]); #if SFX_LEVEL>=ARJSFXV||defined(REARJ) int split_name(char *name, char *pathname, char *filename); #else int split_name(char *name); #endif int subclass_errors(FMSG *errmsg); void file_seek(FILE *stream, long offset, int whence); void search_setup(); int calc_percentage(unsigned long partial, unsigned long total); void smart_seek(unsigned long position, FILE *stream); void alltrim(char *cmd); void unstore(int action); void hollow_decode(int action); void pack_mem(struct mempack *mempack); void unpack_mem(struct mempack *mempack); void strip_lf(char *str); char *ltrim(char *str); #ifdef WORDS_BIGENDIAN unsigned int mget_word(char FAR *p); unsigned long mget_dword(char FAR *p); void mput_word(unsigned int w, char FAR *p); void mput_dword(unsigned long d, char FAR *p); #endif #endif arj-3.10.22/arj_user.c 666 0 0 221024 10064613030 10655 0ustar /* * $Id: arj_user.c,v 1.11 2004/06/18 16:19:37 andrew_belov Exp $ * --------------------------------------------------------------------------- * High-level routines that perform ARJ command processing are located in this * module. It may be partially inherited by ARJSFXV and ARJSFX. * */ #include "arj.h" DEBUGHDR(__FILE__) /* Debug information block */ /* Operating system names used in short listings. For their numerical equivalents see ARJ_USER.H. */ static char *host_os_names[]={"MS-DOS", "PRIMOS", "UNIX", "AMIGA", "MAC-OS", "OS/2", "APPLE GS", "ATARI ST", "NEXT", "VAX VMS", "WIN95", "WIN32", NULL}; /* Binary/Text/... - type signature */ #if SFX_LEVEL>=ARJSFXV static char type_sig[]={'B', 'T', '?', 'D', 'V', 'C', 'U'}; #else static char type_sig[]={'B', 'T', '?', 'D'}; #endif /* Combined volume/extfile flags for UNIX-mode lists */ #if TARGET==UNIX&&SFX_LEVEL>=ARJSFXV static char vfext_flags[]={' ', '>', '<', '*'}; #endif /* List order */ #if SFX_LEVEL>=ARJSFXV #if TARGET==UNIX #define LFLAGS is_chapter?'*':' ', is_in_subdir?'+':' ', method, enc_type, vfext_flags[(is_volume?1:0)+(is_extfile?2:0)] #else #define LFLAGS is_chapter?'*':' ', type_sig[uf_type], is_in_subdir?'+':' ', method, enc_type, is_volume?'V':' ', is_extfile?'X':' ' #endif #else #if TARGET==UNIX #define LFLAGS is_in_subdir?'+':' ', method, enc_type #else #define LFLAGS type_sig[uf_type], is_in_subdir?'+':' ', method, enc_type #endif #endif #if TARGET!=UNIX #define LMODESTR file_crc, mode_str #else #define LMODESTR mode_str #endif /* Y2K mess */ #if SFX_LEVEL>=ARJSFXV static char century_sig[]={' ', ' ', '1'}; /* 20th/21st/22nd centuries */ #endif /* Misc. */ static char volfmt_2digit[]="%s%02d"; static char volfmt_3digit[]="%s%03d"; static char volfmt_4digit[]="%s%4d"; static char stub_fmt[]="%s%03d%s"; static char bell[]="\a"; /* Local variables */ static FILE_COUNT total_processed; /* Number of already processed files */ static unsigned long FAR *order_list; /* List of files to order */ #if SFX_LEVEL>=ARJ static FILE_COUNT cf_num; /* Current file # */ #endif static FILE_COUNT order_fcap; /* Size of order array */ static FILE_COUNT order_fcount; /* # of files in order array */ static FILE_COUNT vol_file_num; static unsigned long saved_timestamp; #if SFX_LEVEL>=ARJ static char *arjsec_signature; #else static char arjsec_signature[ARJSEC_SIG_MAXLEN]; #endif static unsigned long first_file_offset; /* Offset of first file within arch. */ #if SFX_LEVEL>=ARJSFXV static int total_os; static int is_removable; /* 1 if the current archive is on a removable media */ #endif /* Since ARJSFX has totally static allocation, the cache buffers are statically allocated, too */ #if SFX_LEVEL<=ARJSFX&&!defined(NO_CACHING) static char cache_buf[VBUF_SFX]; #endif /* Return 1 if the given system is similar to ARJ host OS */ int test_host_os(int os) { int i; for(i=0; friendly_systems[i]>=0; i++) { if(friendly_systems[i]==os) return(1); } return(0); } #if SFX_LEVEL>=ARJ /* Allocates RAM for and composes the protection filename */ char *form_prot_name() { int name_len; char *result; /* Address of newly-formed buffer */ char *tmp_ptr; name_len=strlen(archive_name)+far_strlen(M_PROT_SUFFIX)+2; strcpy(result=malloc_msg(name_len), archive_name); name_len=split_name(result, NULL, NULL); if((tmp_ptr=strchr(&result[name_len], '.'))==NULL) msg_strcat(result, M_PROT_SUFFIX); else if(tmp_ptr[1]=='\0') msg_strcat(result, M_PROT_SUFFIX); else tmp_ptr[1]=M_PROT_SUFFIX[1]; /* Substitute first letter of extension with the one from prot_name suffix */ return(result); } #endif #if SFX_LEVEL>=ARJSFXV /* Checks for the occurence of the destination file, returns 1 if the file can be extracted, 0 if it already exists and must be skipped */ int destfile_extr_validation() { char tmp_name[FILENAME_MAX]; if(!new_files_only) return(1); strcpy(tmp_name, filename); add_base_dir(tmp_name); return(!file_exists(tmp_name)); } #endif #if SFX_LEVEL>=ARJ /* Writes an index file entry */ void write_index_entry(char *prefix) { int bytes_written; if(create_index) { if(prefix[0]=='\0') bytes_written=msg_fprintf(idxstream, M_IDXFMT_NP, filename); else bytes_written=msg_fprintf(idxstream, (strlen(prefix)>3)?M_IDXFMT_LONG:M_IDXFMT_SHORT, prefix, filename); if(bytes_written==0) error(M_DISK_FULL); } } #endif /* Outputs the listing header */ static void show_list_header() { #if SFX_LEVEL>=ARJ if(std_list_cmd) { if(verbose_display==VERBOSE_STD) return; if(verbose_display==VERBOSE_ENH) msg_cprintf(0, M_VLIST_P1); else { msg_cprintf(0, M_VLIST_HDR); msg_cprintf(0, M_VLIST_P1); } } else msg_cprintf(0, M_LIST_P1); msg_cprintf(0, verbose_display?M_LIST_P2_CHAP:M_LIST_P2); #else if(std_list_cmd) { msg_cprintf(0, M_VLIST_HDR); msg_cprintf(0, M_VLIST_P1); } else msg_cprintf(0, M_LIST_P1); msg_cprintf(0, M_LIST_P2); #endif msg_cprintf(0, M_LIST_SEPARATOR); } /* Picks the most favorable century character */ #if SFX_LEVEL>=ARJSFXV static char pick_century(char *timetext) { int n_centuries; #if SFX_LEVEL>=ARJ switch(skip_century) { case CENT_DEFAULT: if(timetext[0]=='2'&&timetext[1]=='0') n_centuries=1; else if(timetext[0]=='2'&&timetext[1]=='1') n_centuries=2; else n_centuries=0; return(century_sig[n_centuries]); case CENT_SKIP: return(' '); case CENT_SMART: if(timetext[0]=='1'||(timetext[0]=='2'&&timetext[1]=='0'&&timetext[2]<'7')) return(' '); else return(timetext[1]); } return(' '); #elif SFX_LEVEL>=ARJSFXV if(timetext[0]=='2'&&timetext[1]=='0') n_centuries=1; else if(timetext[0]=='2'&&timetext[1]=='1') n_centuries=2; else n_centuries=0; return(century_sig[n_centuries]); #endif } #endif /* List command itself */ #if SFX_LEVEL>=ARJSFXV static int list_cmd(FILE_COUNT lnum, FILE_COUNT fnum) #else static void list_cmd() #endif { int is_in_subdir; #if SFX_LEVEL>=ARJSFXV int is_volume, is_extfile; int is_chapter; /* Chapter or backup */ char FAR *raw_ea; unsigned int raw_ea_size; struct ext_hdr FAR *p_eh; #endif #if SFX_LEVEL>=ARJ char tmp_name[FILENAME_MAX]; #endif int uf_type; unsigned int ratio; unsigned int entry; char timetext[22]; char mode_str[16]; /* ASR fix for 2.77 */ char *tmp_ptr; /* Either from the host_os_names list or nullstr */ char enc_type; #if SFX_LEVEL>=ARJSFXV if(!destfile_extr_validation()) return(0); #endif #if SFX_LEVEL>=ARJSFXV if(lnum==0) show_list_header(); #else if(total_files==0) show_list_header(); #endif #if SFX_LEVEL>=ARJ for(total_os=0; host_os_names[total_os]!=NULL; total_os++); #endif enc_type=(arj_flags&GARBLED_FLAG)?ext_hdr_flags+'0':' '; #if SFX_LEVEL>=ARJSFXV is_volume=(arj_flags&VOLUME_FLAG)?1:0; is_extfile=(arj_flags&EXTFILE_FLAG)?1:0; #endif #if SFX_LEVEL>=ARJ is_chapter=(total_chapters!=0&&((int)chapter_numbertotal_chapters))?1:0; #elif SFX_LEVEL==ARJSFXV is_chapter=(arj_flags&BACKUP_FLAG)?1:0; #endif is_in_subdir=entry_pos>0; ratio=calc_percentage(compsize, origsize); total_uncompressed+=origsize; total_compressed+=compsize; #if SFX_LEVEL>=ARJSFXV if(chk_free_space) disk_space_used+=((origsize+(unsigned long)alloc_unit_size-1L)/(unsigned long)alloc_unit_size)*(unsigned long)alloc_unit_size; #endif timestamp_to_str(timetext, &ftime_stamp); #if SFX_LEVEL>=ARJ uf_type=(file_type==ARJT_BINARY||file_type==ARJT_TEXT||file_type==ARJT_DIR||file_type==ARJT_UXSPECIAL||file_type==ARJT_LABEL||file_type==ARJT_CHAPTER)?file_type:ARJT_COMMENT; #elif SFX_LEVEL==ARJSFXV uf_type=(file_type==ARJT_BINARY||file_type==ARJT_TEXT||file_type==ARJT_DIR||file_type==ARJT_UXSPECIAL||file_type==ARJT_LABEL)?file_type:ARJT_DIR; #else uf_type=(file_type==ARJT_BINARY||file_type==ARJT_TEXT||file_type==ARJT_DIR)?file_type:ARJT_DIR; #endif /* In ARJSFX, there are no non-host OSes */ #if SFX_LEVEL<=ARJSFX mode_str[0]='\0'; #else msg_strcpy(mode_str, M_EMPTY_ATTR); #endif if(test_host_os(host_os)) { get_mode_str(mode_str, file_mode.native); #if TARGET==UNIX if(file_type==ARJT_BINARY||file_type==ARJT_TEXT) mode_str[0]='-'; else mode_str[0]=tolower(type_sig[uf_type]); #endif } #if SFX_LEVEL>=ARJ strcpy(tmp_name, filename); if((uf_type==ARJT_BINARY||uf_type==ARJT_TEXT||uf_type==ARJT_DIR||file_type==ARJT_UXSPECIAL)&&(host_os==OS_WIN95||host_os==OS_WINNT)) { total_longnames++; if(volume_flag_set) split_longnames++; } #endif if(std_list_cmd) { #if SFX_LEVEL>=ARJSFXV #if SFX_LEVEL>=ARJ if(verbose_display!=VERBOSE_ENH) { if(verbose_display==VERBOSE_NONE) { #endif msg_cprintf(H_HL, M_LIST_NUM_FMT, fnum); #if SFX_LEVEL>=ARJ } #endif #if SFX_LEVEL>=ARJ entry=(exclude_paths==EP_PATH)?(unsigned int)entry_pos:0; msg_cprintf(H_HL, M_FILENAME_FORM, tmp_name+entry); #else entry=0; msg_cprintf(H_HL, M_FILENAME_FORM, filename); #endif #if SFX_LEVEL>=ARJ if(verbose_display==VERBOSE_STD) return(1); #endif if(comment[0]!='\0') { display_comment(comment); #if SFX_LEVEL>=ARJ msg_cprintf(0, (FMSG *)lf); #endif } #if SFX_LEVEL>=ARJ if(ext_flags!=0) msg_cprintf(H_HL|H_NFMT, M_CHAPTER_LIST_FMT, (int)ext_flags, (int)chapter_number); #endif #if SFX_LEVEL>=ARJ } #endif tmp_ptr=((int)host_os>=total_os)?nullstr:host_os_names[host_os]; msg_cprintf(H_HL|H_NFMT, M_REV_OS_FMT, (int)arj_nbr, tmp_ptr); #else msg_cprintf(H_HL, M_VERBOSE_NAME_FMT, filename); if(comment[0]!='\0') { if(show_ansi_comments) printf(strform, comment); else display_comment(comment); } msg_cprintf(H_HL|H_NFMT, M_REV_OS_FMT, (int)arj_nbr, host_os_names[host_os]); #endif } else #if SFX_LEVEL>=ARJ msg_cprintf(0, (strlen(tmp_name+entry_pos)>12)?M_LONG_NAME_FMT:M_SHORT_NAME_FMT, tmp_name+entry_pos); #elif SFX_LEVEL>=ARJSFXV msg_cprintf(0, (strlen(filename+entry_pos)>12)?M_LONG_NAME_FMT:M_SHORT_NAME_FMT, filename+entry_pos); #else msg_cprintf(0, (strlen(list_adapted_name)>12)?M_LONG_NAME_FMT:M_SHORT_NAME_FMT, list_adapted_name); #endif #if SFX_LEVEL>=ARJ if(verbose_display) msg_cprintf(H_HL|H_NFMT, M_VERBOSE_LIST_LINE, origsize, compsize, ratio/1000, ratio%1000, pick_century(timetext), timetext+2, (int)ext_flags, (int)chapter_number, mode_str, LFLAGS); else #endif #if SFX_LEVEL>=ARJSFXV msg_cprintf(H_HL|H_NFMT, M_STD_LIST_LINE, origsize, compsize, ratio/1000, ratio%1000, pick_century(timetext), timetext+2, LMODESTR, LFLAGS); #else msg_cprintf(H_HL|H_NFMT, M_STD_LIST_LINE, origsize, compsize, ratio/1000, ratio%1000, timetext+2, LMODESTR, LFLAGS); #endif #if SFX_LEVEL>=ARJ if(std_list_cmd&&verbose_display==VERBOSE_ENH) { if((tmp_ptr=strrchr(tmp_name, '.'))==NULL) tmp_ptr=nullstr; msg_cprintf(H_HL|H_NFMT, M_PATH_LIST_FMT, tmp_ptr, tmp_name+entry_pos, filename); } msg_cprintf(0, (FMSG *)lf); if(std_list_cmd&&ts_valid(atime_stamp)&&verbose_display!=VERBOSE_ENH) { timestamp_to_str(timetext, &atime_stamp); msg_cprintf(H_HL|H_NFMT, M_ATIME_FMT, pick_century(timetext), timetext+2); timestamp_to_str(timetext, &ctime_stamp); msg_cprintf(H_HL|H_NFMT, M_CTIME_FMT, pick_century(timetext), timetext+2); } /* Report the extended headers */ if(std_list_cmd&&valid_ext_hdr&&!(arj_flags&VOLUME_FLAG)&&verbose_display!=VERBOSE_ENH) { /* UNIX special files */ if((p_eh=eh_lookup(eh, UXSPECIAL_ID))!=NULL) uxspecial_stats(p_eh->raw, UXSTATS_LONG); /* Owner (character) */ if((p_eh=eh_lookup(eh, OWNER_ID))!=NULL) owner_stats(p_eh->raw, 1); /* Owner (UID/GID). The archiving won't allow simultaneous storage of both numeric and character IDs */ if((p_eh=eh_lookup(eh, OWNER_ID_NUM))!=NULL) owner_stats(p_eh->raw, 0); /* EAs */ if((p_eh=eh_lookup(eh, EA_ID))!=NULL&&(!file_garbled||garble_enabled)) { raw_ea=unpack_ea(p_eh); raw_ea_size=get_eablk_size(raw_ea); ratio=calc_percentage((unsigned long)p_eh->size, (unsigned long)raw_ea_size); msg_cprintf(H_HL|H_NFMT, M_EA_LIST, raw_ea_size, p_eh->size, ratio/1000, ratio%1000, get_num_eas(raw_ea)); farfree(raw_ea); } } write_index_entry(nullstr); #else #if SFX_LEVEL>=ARJSFXV msg_cprintf(0, (FMSG *)lf); #endif #endif #if SFX_LEVEL>=ARJSFXV return(1); #endif } /* A simplified set of filelist routines */ #if SFX_LEVEL<=ARJSFX /* Looks for the given fully-qualified filename in the file argument array */ static int f_arg_lookup(char *name) { int i; for(i=0; i=ARJ /* Checks if an archived file can be processed, returns 1 if yes. */ static int processing_validation() { int rc; int entry; if(filter_attrs) { rc=0; if(file_attr_mask&TAG_WINLFN&&(host_os==OS_WIN95||host_os==OS_WINNT)&& (file_type==ARJT_DIR||file_type==ARJT_UXSPECIAL||file_type==ARJT_BINARY||file_type==ARJT_TEXT)) rc=1; if(file_attr_mask&TAG_LABEL&&file_type==ARJT_LABEL) rc=1; if(file_attr_mask&TAG_CHAPTER&&file_type==ARJT_CHAPTER) rc=1; if(file_attr_mask&TAG_DIREC&&file_type==ARJT_DIR) rc=1; if(file_attr_mask&TAG_UXSPECIAL&&file_type==ARJT_UXSPECIAL) rc=1; if(file_attr_mask&TAG_NORMAL&&(file_type==ARJT_BINARY||file_type==ARJT_TEXT)) { if((file_mode.dos&FATTR_DIREC)!=FATTR_DIREC&& (file_mode.dos&FATTR_RDONLY)!=FATTR_RDONLY&& (file_mode.dos&FATTR_SYSTEM)!=FATTR_SYSTEM&& (file_mode.dos&FATTR_HIDDEN)!=FATTR_HIDDEN&& file_type!=ARJT_UXSPECIAL) rc=1; } if(file_attr_mask&TAG_RDONLY&&file_mode.dos&FATTR_RDONLY) rc=1; if(file_attr_mask&TAG_HIDDEN&&file_mode.dos&FATTR_HIDDEN) rc=1; if(file_attr_mask&TAG_SYSTEM&&file_mode.dos&FATTR_SYSTEM) rc=1; if(file_attr_mask&TAG_ARCH&&(file_mode.dos&FATTR_ARCH)!=FATTR_ARCH) return(0); if(file_attr_mask&TAG_NOT_ARCH&&file_mode.dos&FATTR_ARCH) return(0); if(!rc) return(0); } if(ts_valid(tested_ftime_newer)&&(filter_same_or_newer==TCHECK_FTIME||filter_same_or_newer==TCHECK_NDAYS)) { if(ts_cmp(&ftime_stamp, &tested_ftime_newer)<0) return(0); } if(ts_valid(tested_ftime_older)&&(filter_older==TCHECK_FTIME||filter_older==TCHECK_NDAYS)) { if(ts_cmp(&ftime_stamp, &tested_ftime_older)>=0) return(0); } /* ctime */ if(ts_valid(tested_ftime_newer)&&filter_same_or_newer==TCHECK_CTIME) { if(ts_cmp(&ctime_stamp, &tested_ftime_newer)<0) return(0); } if(ts_valid(tested_ftime_older)&&filter_older==TCHECK_CTIME) { if(ts_cmp(&ctime_stamp, &tested_ftime_older)>=0) return(0); } /* atime */ if(ts_valid(tested_ftime_newer)&&filter_same_or_newer==TCHECK_ATIME) { if(ts_cmp(&atime_stamp, &tested_ftime_newer)<0) return(0); } if(ts_valid(tested_ftime_older)&&filter_older==TCHECK_ATIME) { if(ts_cmp(&atime_stamp, &tested_ftime_older)>=0) return(0); } entry=(add_command&&exclude_paths==EP_BASEDIR)?strlen(target_dir):0; return(!flist_find(&flist_exclusion, filename+entry)); } /* Retrieves total statistics for the archive */ static void get_totals() { FILE_COUNT cur_file; if(add_command) { total_size=0L; total_written=0L; display_totals=1; for(cur_file=0; cur_file=exit_count) break; pf_num=flist_lookup(++cf_num); val_result=processing_validation(); switch(cmd) { case ARJ_CMD_ADD: if(pf_num!=0&&file_type!=ARJT_LABEL) { flist_retrieve(filename, &properties, &flist_main, pf_num-1); update_perm=1; if(serialize_exts) { msg_sprintf(misc_buf, M_QUERY_UPDATE, filename); update_perm=query_action(REPLY_YES, QUERY_UPDATE, (FMSG *)misc_buf); } if(update_perm) { if(!new_files_only) { pack_rc=pack_file_stub(0, 1); if(pack_rc!=0) { if(volume_flag_set) { vol_file_num=pf_num; break; } if(pack_rc!=1) break; cfa_store(pf_num-1, FLFLAG_PROCESSED); break; } } } cfa_store(pf_num-1, FLFLAG_SKIPPED); } special_processing(CFA_NONE, aistream); break; case ARJ_CMD_COMMENT: if(pf_num&&val_result&&(!use_comment||supply_comment_file)&&!(arj_flags&EXTFILE_FLAG)) { update_perm=1; if(query_for_each_file) { msg_sprintf(misc_buf, M_QUERY_COMMENT, filename); update_perm=query_action(REPLY_YES, QUERY_ARCH_OP, (FMSG *)misc_buf); } if(update_perm) { if(supply_comment(comment_file, filename)) comment_entries++; } } special_processing(CFA_NONE, aistream); break; case ARJ_CMD_DELETE: if(pf_num&&val_result) { if(arcv_delete(cf_num)) break; } special_processing(CFA_NONE, aistream); break; case ARJ_CMD_FRESHEN: case ARJ_CMD_UPDATE: if(pf_num&&file_type!=ARJT_LABEL) { flist_retrieve(filename, &properties, &flist_main, pf_num-1); pack_rc=pack_file_stub(1, 1); if(pack_rc!=0) { if(vol_file_num==pf_num) { if(volume_flag_set) break; if(pack_rc==1) cfa_store(vol_file_num-1, FLFLAG_PROCESSED); vol_file_num=0; break; } if(volume_flag_set) vol_file_num=pf_num; else if(pack_rc==1) cfa_store(pf_num-1, FLFLAG_PROCESSED); break; } special_processing(CFA_NONE, aistream); cfa_store(pf_num-1, FLFLAG_SKIPPED); break; } special_processing(CFA_NONE, aistream); break; case ARJ_CMD_GARBLE: sp_action=CFA_NONE; if(pf_num!=0&&val_result) { update_perm=1; if(query_for_each_file) { msg_sprintf(misc_buf, M_QUERY_GARBLE, filename); update_perm=query_action(REPLY_YES, QUERY_ARCH_OP, (FMSG *)misc_buf); } if(update_perm) sp_action=CFA_GARBLE; } special_processing(sp_action, aistream); break; case ARJ_CMD_RENAME: if(pf_num!=0&&val_result) { if(rename_file()) total_files++; } special_processing(CFA_NONE, aistream); break; case ARJ_CMD_ORDER: if(arj_flags&VOLUME_FLAG||arj_flags&EXTFILE_FLAG) error(M_CANT_ORDER_MV); if(order_fcount>=order_fcap) { if(order_fcap==0) order_fcap=flist_main.files; order_fcap+=FILELIST_INCREMENT; if((order_list=(unsigned long FAR *)farrealloc(order_list, order_fcap*sizeof(unsigned long)))==NULL) error(M_OUT_OF_MEMORY); } if(pf_num!=0) { arch_hdr_index[pf_num-1]=cur_header_pos; cfa_store(pf_num-1, FLFLAG_PROCESSED); order_list[order_fcount++]=0L; } else order_list[order_fcount++]=cur_header_pos; total_files++; skip_compdata(); break; case ARJ_CMD_REMPATH: sp_action=CFA_NONE; if(pf_num!=0&&val_result) { update_perm=1; if(query_for_each_file) { msg_sprintf(misc_buf, M_QUERY_GARBLE, filename); update_perm=query_action(REPLY_YES, QUERY_ARCH_OP, (FMSG *)misc_buf); } if(update_perm) sp_action=CFA_REMPATH; } special_processing(sp_action, aistream); break; case ARJ_CMD_JOIN: case ARJ_CMD_SECURE: special_processing(CFA_NONE, aistream); total_files++; break; case ARJ_CMD_COPY: sp_action=CFA_NONE; if(pf_num!=0&&val_result) { if(chapter_mode==CHAP_USE) sp_action=CFA_MARK_EXT; else if(chapter_mode==CHAP_REMOVE) sp_action=CFA_UNMARK_EXT; else if(garble_enabled) sp_action=CFA_UNGARBLE; } special_processing(sp_action, aistream); break; case ARJ_CMD_EXTR_NP: case ARJ_CMD_PRINT: if(pf_num!=0&&val_result) { update_perm=1; if(query_for_each_file) { if(!first_vol_passed||!continued_prevvolume) { msg_sprintf(misc_buf, M_QUERY_EXTRACT, filename); update_perm=query_action(REPLY_YES, QUERY_ARCH_OP, (FMSG *)misc_buf); } else { if(ofstream==NULL) update_perm=0; } } if(update_perm) { if(unpack_file_proc(cmd==ARJ_CMD_PRINT, cf_num)) { total_files++; if(volume_flag_set) split_files++; } tmp_tmp_filename[0]='\0'; } else skip_compdata(); } else skip_compdata(); break; case ARJ_CMD_LIST: if(pf_num!=0&&val_result) { if(list_cmd(total_files, cf_num)) total_files++; } skip_compdata(); break; case ARJ_CMD_TEST: if(pf_num!=0&&val_result) { if(test_archive_crc==TC_CRC_AND_CONTENTS) add_base_dir(filename); if(unpack_validation(cmd)) total_files++; } else skip_compdata(); break; case ARJ_CMD_WHERE: if(pf_num!=0&&val_result) { if(unpack_validation(cmd)) total_files++; } else skip_compdata(); break; } } if((cmd==ARJ_CMD_ADD||cmd==ARJ_CMD_UPDATE)&&multivolume_option&&continued_nextvolume&&!no_inarch) volume_flag_set=1; if(multivolume_option&&add_command) continued_nextvolume=1; ext_voldata=0; /* ASR fix for v 2.76.04 - prevent phantom EAs at archive joints */ if(!continued_nextvolume) { if(eh!=NULL) { eh_release(eh); eh=NULL; } } if(cmd==ARJ_CMD_ADD||cmd==ARJ_CMD_UPDATE) { if(cf_num!=0) { resume_position=0L; continued_prevvolume=0; } if(multivolume_option&&check_multivolume(MULTIVOLUME_INCREMENT)recent_chapter) create_chapter_mark(); } else if(cmd==ARJ_CMD_JOIN) total_files+=copy_archive(); else if(cmd==ARJ_CMD_ORDER) { pf_num=0; for(cur_file=0; cur_file0L) { fseek(aistream, order_list[cur_file], SEEK_SET); read_header(0, aistream, archive_name); special_processing(CFA_NONE, aistream); pf_num++; } } if(total_files!=pf_num) error(M_ORDER_CNT_MISMATCH); msg_cprintf(0, M_FILES_REORDERED); } if(cmd==ARJ_CMD_COPY&&total_chapters!=0&&!volume_flag_set&&total_files!=0&&total_chapters>recent_chapter) create_chapter_mark(); } /* Some post-processing actions */ static void finish_processing(int cmd) { int skip_query; unsigned long cur_pos, eof_pos; int entry; char *ext_ptr; char *bak_name; FILE_COUNT cur_file; int vol_code; char *msg_ptr; int ratio; unsigned long free_space; int protected=0; int is_prot; if(modify_command) { if(cmd==ARJ_CMD_DELETE&&total_files!=0&&file_args==1&&!strcmp_os(f_arg_array[0], all_wildcard)) { skip_query=yes_on_all_queries||query_delete; if(!skip_query) { msg_sprintf(misc_buf, M_QUERY_DELETE_N_FILES, total_files); if(!query_action(REPLY_YES, QUERY_DELETE_N_FILES, (FMSG *)misc_buf)) { errors++; tmp_archive_cleanup(); longjmp(main_proc, 1); } } } if(cmd==ARJ_CMD_DELETE&&total_chapters!=0&¤t_chapter!=RESERVED_CHAPTER&&total_chapters>max_chapter) final_header(FP_CHAPTER); if(cmd==ARJ_CMD_DELETE&&!first_vol_passed&&!continued_nextvolume&&ftell(aostream)==first_file_offset) { msg_cprintf(H_HL|H_NFMT, M_DELETING_EMPTY_ARCH, archive_name); file_close(aistream); aistream=NULL; if(!no_file_activity) { if(file_unlink(archive_name)) error(M_CANT_DELETE, archive_name); tmp_archive_cleanup(); } } /* ASR fix: the original didn't check for ARJ_CMD_COMMENT */ else if(total_files!=0||(cmd==ARJ_CMD_COMMENT&&comment_entries!=0)||create_sfx!=0) { fput_word(HEADER_ID, aostream); fput_word(0, aostream); last_hdr_offset=0L; if(!no_file_activity) { eof_pos=ftell(aostream); if(continued_nextvolume&&add_command&&!volume_flag_set&&!force_volume_flag) { final_header(FP_VOLUME); continued_nextvolume=0; } if(!encryption_applied&&encryption_id!=ENCID_NONE) final_header(FP_GARBLE); if(sign_with_arjsec) { msg_cprintf(0, M_WORKING); cur_pos=ftell(aostream); secured_size=cur_pos-main_hdr_offset; arjsec_offset=(unsigned long)is_registered*cur_pos; final_header(FP_SECURITY); if(create_envelope(aostream, arjsec_offset, ARJSEC_ITER)) { arj_delay(5); error(M_NO_ARJSEC_KEY); } } if(test_archive_crc) { archive_cleanup(); cmd_verb=cmd; } protected=0; if(arjprot_tail) { if(prot_blocks==0) prot_blocks=arjprot_tail; fseek(aostream, 0L, SEEK_END); arjsec_offset=ftell(aostream); if(!sign_with_arjsec) final_header(FP_PROT); protected=1; create_protfile(aostream, prot_blocks, 0); } if(multivolume_option) { fseek(aostream, 0L, SEEK_END); if(debug_enabled&&strchr(debug_opt, 'a')!=NULL&&create_index) { if(msg_fprintf(idxstream, M_ARCH_SIZE, ftell(aostream), archive_name)<0) error(M_DISK_FULL); } if(ftell(aostream)>volume_limit&&create_index) { if(msg_fprintf(idxstream, M_VOLUME_BUG, archive_name)<0) error(M_DISK_FULL); } } if(ferror(aostream)||fclose(aostream)==EOF) error(M_DISK_FULL); aostream=NULL; if(test_archive_crc&&protected) { protected=1; if(debug_enabled&&strchr(debug_opt, 'a')!=NULL) protected=2; msg_strcpy(tmp_tmp_filename, M_ARJFIXED_NAME); if(recover_file(tmp_archive_name, nullstr, tmp_tmp_filename, protected, eof_pos)) { msg_cprintf(H_HL, M_CANT_FIND_DAMAGE, archive_name); printf(lf); } else { if(create_index) { if(msg_fprintf(idxstream, M_AUTOPROT_DAMAGE, archive_name)<0) error(M_DISK_FULL); } } tmp_tmp_filename[0]='\0'; } } aostream=NULL; if(create_sfx&&!first_vol_passed) { entry=split_name(archive_name, NULL, NULL); if((ext_ptr=strchr(archive_name+entry, '.'))==NULL) msg_strcat(archive_name, M_EXE_EXT); #ifndef NULL_EXE_EXTENSION else msg_strcpy(ext_ptr, M_EXE_EXT); #endif } if(aistream!=NULL) { file_close(aistream); aistream=NULL; if(!no_file_activity) { if(keep_bak&&file_exists(archive_name)) { bak_name=(char *)malloc_msg(far_strlen(M_BAK_EXT)+strlen(archive_name)+1); strcpy(bak_name, archive_name); entry=split_name(bak_name, NULL, NULL); if((ext_ptr=strchr(bak_name+entry, '.'))==NULL) msg_strcat(bak_name, M_BAK_EXT); else msg_strcpy(ext_ptr, M_BAK_EXT); file_unlink(bak_name); rename_with_check(archive_name, bak_name); free(bak_name); } else { if(create_sfx) { if(file_exists(archive_name)) if(file_unlink(archive_name)) error(M_CANT_DELETE, archive_name); } else { if(file_unlink(archive_name)) error(M_CANT_DELETE, archive_name); } } } } if(!no_file_activity) { if(assign_work_directory) { msg_cprintf(H_HL|H_NFMT, M_COPYING_TEMP, tmp_archive_name, archive_name); tmp_archive_used=1; if(file_copy(archive_name, tmp_archive_name, test_archive_crc)) error(M_CANT_COPY_TEMP, tmp_archive_name, archive_name); tmp_archive_used=0; if(file_unlink(tmp_archive_name)) error(M_CANT_DELETE, archive_name); } else rename_with_check(tmp_archive_name, archive_name); if(create_sfx&&!first_vol_passed) msg_cprintf(0, M_SFX_CREATED); } tmp_archive_name[0]='\0'; } else { fput_word(HEADER_ID, aostream); fput_word(0, aostream); last_hdr_offset=0L; if(!no_file_activity&&delete_processed&&add_command&&test_archive_crc) { for(cur_file=0; cur_filetotal_files) { ratio=calc_percentage(av_compressed, av_uncompressed); if(total_longnames==0) msg_cprintf(H_HL|H_NFMT, M_TOTAL_STATS, av_total_files, av_uncompressed, av_compressed, ratio/1000, ratio%1000, nullstr); else msg_cprintf(H_HL|H_NFMT, M_TOTAL_STATS_LFN, av_total_files, av_uncompressed, av_compressed, ratio/1000, ratio%1000, nullstr, av_total_longnames); } } } if(chk_free_space) { free_space=file_getfree(target_dir); if(disk_space_used+minfree>free_space) { msg_cprintf(H_ALERT, M_NOT_ENOUGH_SPACE_X, disk_space_used+minfree-free_space); errors++; } } } else if(cmd==ARJ_CMD_PRINT) { if(!help_issued) msg_cprintf(H_HL|H_NFMT, M_N_FILES, total_files); } else if(cmd==ARJ_CMD_COMMENT) msg_cprintf(H_HL|H_NFMT, M_N_COMMENTS, comment_entries); else if(cmd==ARJ_CMD_ADD||cmd==ARJ_CMD_FRESHEN||cmd==ARJ_CMD_UPDATE) { if(total_files==0) { if(total_longnames==0) msg_cprintf(H_HL|H_NFMT, M_N_FILES, total_files); else msg_cprintf(H_HL|H_NFMT, M_N_FILES_LFN, total_files, total_longnames); } else { if(verbose_display==VERBOSE_STD) { msg_cprintf(0, M_FINAL_FOOTER); ratio=calc_percentage(total_compressed, total_uncompressed); msg_cprintf(H_HL|H_NFMT, M_VERBOSE_FOOTER, total_files, total_uncompressed, total_compressed, ratio/10, ratio%10); if(total_files0) msg_cprintf(H_HL|H_NFMT, M_N_COMMENTS, comment_entries); } if(security_state==ARJSEC_SIGNED&&arjsec_opt!=ARJSECP_SKIP) { msg_cprintf(H_HL|H_NFMT, M_VALID_ARJSEC, arjsec_signature); msg_strcpy(strcpy_buf, M_SDN_1); if(strstr(arjsec_signature, strcpy_buf)!=NULL) { msg_cprintf(0, M_SDN_ADD_DESC); msg_cprintf(0, M_SDN_SECURITY_TEST); } msg_strcpy(strcpy_buf, M_SDN_2); if(strstr(arjsec_signature, strcpy_buf)!=NULL) { msg_cprintf(0, M_SDN_DIST_DESC); msg_cprintf(0, M_SDN_SECURITY_TEST); } } file_close(aistream); aistream=NULL; if(arjprot_tail) msg_cprintf(0, M_ARJPROT_ENABLED, prot_blocks); if(arjsec_signature!=NULL) { free(arjsec_signature); arjsec_signature=NULL; } if(((modify_command&×tamp_override==ATO_SAVE_ARCHIVE)|| timestamp_override==ATO_NEWEST)&&ts_valid(ftime_max)) file_setftime(archive_name, ts_native(&ftime_max, OS)); else if((timestamp_override==ATO_SAVE_ORIGINAL||timestamp_override==ATO_SAVE_BOTH)&&saved_timestamp!=0L) file_setftime(archive_name, saved_timestamp); if(modify_command&&file_is_removable(archive_name)) reset_drive(archive_name); if(!modify_command&&total_processed==0&&!continued_nextvolume) { if(errorlevel==ARJ_ERL_SUCCESS) errorlevel=ARJ_ERL_WARNING; errors++; } total_processed-=split_files; av_total_files-=split_files; av_total_longnames-=split_longnames; } #endif /* Changes SFX executable name (for -ve) */ #if SFX_LEVEL>=ARJSFXV static char *iterate_sfxname() { char *rc, *p; int l; char *tmp_str; for(l=strlen(archive_name); l>0; l--) { if(archive_name[l]=='.') break; } if(l<4) { p=(l>0)?(archive_name+l):nullstr; l=0; rc=archive_name; } else { p=archive_name+l; l-=3; rc=archive_name+l; } if(volume_number>0) { tmp_str=malloc_str(archive_name); tmp_str[l]='\0'; sprintf(archive_name, stub_fmt, tmp_str, volume_number, p); free(tmp_str); } return(rc); } #endif /* Mangles the filename so it can be transformed to an aesthetic SFX name. ASR fix 26/08/2001 for UNIX. */ #if SFX_LEVEL>=ARJSFXV static void fix_sfx_name() { #ifdef NULL_EXE_EXTENSION char *digit_pos; static char exe_append[]=".exe"; if(!first_vol_passed) return; digit_pos=strrchr(archive_name, PATHSEP_DEFAULT); if(digit_pos==NULL) digit_pos=archive_name; digit_pos=strchr(digit_pos, '.'); if(digit_pos==NULL) /* "test" -> "test.exe" */ strcat(archive_name, exe_append); else if(strlen(digit_pos)<3) /* ".xx" -> ".01" */ strcpy(digit_pos, exe_append); #endif } #endif /* Extended archive processing routine. A non-zero return value indicates that processing of further volumes must be omitted. */ #if SFX_LEVEL>=ARJ static int process_archive_proc(int cmd) { struct timestamp tmp_time; static unsigned int t_buf, v_buf; char *tmp_ptr; int vol_num_digits; int encryption_version; char *vol_name_fmt; int filename_length; unsigned long avail_space; char timetext[22]; char *sfx_name; int entry; int query_result; int no_input; FILE *cmtstream; int cmt_len; char *digit_pos; unsigned long arch_size; unsigned int desc_word, reg_id; /* SFX */ order_fcount=0; order_fcap=0; order_list=NULL; arjsec_signature=NULL; volume_flag_set=0; main_hdr_offset=last_hdr_offset=0L; tmp_archive_used=0; cf_num=0; total_files=total_longnames=0; comment_entries=0; security_state=ARJSEC_NONE; disk_space_used=0L; total_uncompressed=0L; total_compressed=0L; archive_size=0L; ts_store(&ftime_max, OS_SPECIAL, 0L); saved_timestamp=0L; ext_hdr_flags=0; encryption_applied=0; split_files=0; split_longnames=0; cmd_verb=cmd; if(!setjmp(main_proc)) { set_file_apis(use_ansi_cp); v_buf=add_command?VBUF_ADD:VBUF_EXTRACT; t_buf=TBUF_ARJ; if(coreleft()>=1; if(coreleft()>=1; if((tmp_ptr=strchr(debug_opt, 'b'))!=NULL) { tmp_ptr++; v_buf=(int)strtol(tmp_ptr, &tmp_ptr, 10); } if((tmp_ptr=strchr(debug_opt, 'p'))!=NULL) { tmp_ptr++; t_buf=(int)strtol(tmp_ptr, &tmp_ptr, 10); } if((tmp_ptr=strchr(debug_opt, 'v'))!=NULL) msg_cprintf(H_HL|H_NFMT, M_BRIEF_MEMSTATS, coreleft(), t_buf, v_buf); if(chk_free_space) alloc_unit_size=get_bytes_per_cluster(target_dir); ts_store(&ftime_stamp, OS_SPECIAL, 0L); first_hdr_size=FIRST_HDR_SIZE; if(multivolume_option) { if(use_sfxstub) digit_pos=iterate_sfxname(); else { vol_num_digits=2; tmp_ptr=volfmt_2digit; fix_sfx_name(); filename_length=strlen(archive_name)-vol_num_digits; if(volume_number>99||isdigit(archive_name[filename_length-1])) { vol_num_digits=3; tmp_ptr=volfmt_3digit; filename_length--; if(volume_number>999&&lfn_supported) { if(volume_number>1000) filename_length--; tmp_ptr=volfmt_4digit; } else if(volume_number>999) volume_number=1; } if(volume_number>0) { vol_name_fmt=malloc_str(archive_name); vol_name_fmt[filename_length]='\0'; sprintf(archive_name, tmp_ptr, vol_name_fmt, volume_number); free(vol_name_fmt); } digit_pos=archive_name+filename_length; } continued_nextvolume=1; if(modify_command) { do { avail_space=file_getfree(archive_name); arch_size=0L; if(assign_work_directory&&file_exists(archive_name)) { arch_size=file_getfsize(archive_name); if(file_getfree(work_directory)<(avail_space+arch_size)*2) arch_size=0L; avail_space+=arch_size; } if(multivolume_option==MV_AVAIL) volume_limit=avail_space; if(debug_enabled&&strchr(debug_opt, 'v')!=NULL) msg_cprintf(H_HL|H_NFMT, M_AVAIL_SPACE, avail_space); if(avail_spaceavail_space) { if(!yes_on_all_queries&&!skip_space_query) { msg_cprintf(H_HL|H_NFMT, M_FILENAME_FORM, archive_name); msg_sprintf(misc_buf, M_LOW_SPACE_WARNING, avail_space); if(!query_action(REPLY_YES, QUERY_LOW_SPACE, (FMSG *)misc_buf)) return(0); } } } while((arch_size+avail_space)!=file_getfree(archive_name)); } } ctrlc_not_busy=0; aistream=NULL; if(file_exists(archive_name)) { if(modify_command) { saved_timestamp=file_getftime(archive_name); aistream=file_open_noarch(archive_name, m_rbp); } else aistream=file_open(archive_name, m_rb); fseek(aistream, arcv_ext_pos, SEEK_SET); arcv_ext_pos=0L; } ctrlc_not_busy=1; if(aistream==NULL&&msg_strchr(M_UPDATE_COMMANDS, (char)cmd)==NULL) { if(multivolume_option&&!yes_on_all_queries&&!skip_next_vol_query) { error_report(); msg_cprintf(H_ERR, M_CANTOPEN, archive_name); nputlf(); return(0); } else error(M_CANTOPEN, archive_name); } if(create_index) { cur_time_stamp(&tmp_time); timestamp_to_str(timetext, &tmp_time); if(msg_fprintf(idxstream, M_IDX_VOLUME_HEADER, timetext, resume_position, archive_name)<0) error(M_DISK_FULL); } no_inarch=1; if(aistream!=NULL) { #ifndef NO_CACHING setvbuf(aistream, NULL, _IOFBF, v_buf); #endif no_inarch=0; } if(!modify_command) msg_cprintf(H_HL|H_NFMT, M_PROCESSING_ARCHIVE, archive_name); else { if(!tmp_archive_name) { tmp_archive_used=-1; tmp_archive_name=(char *)malloc_msg(FILENAME_MAX); tmp_archive_name[0]='\0'; tmp_archive_used=0; } if(create_sfx) { if(!first_vol_passed) { sfx_name=malloc_msg(filename_length=strlen(archive_name)+far_strlen(M_EXE_EXT)+1); strcpy(sfx_name, archive_name); entry=split_name(sfx_name, NULL, NULL); if((tmp_ptr=strchr(sfx_name+entry, '.'))==NULL) msg_strcat(sfx_name, M_EXE_EXT); #ifndef NULL_EXE_EXTENSION else msg_strcpy(tmp_ptr, M_EXE_EXT); #endif if(file_exists(sfx_name)) { query_result=yes_on_all_queries||overwrite_existing; if(!query_result) { msg_cprintf(H_HL|H_NFMT, M_EXISTS, sfx_name); msg_sprintf(misc_buf, M_QUERY_UPDATE, sfx_name); query_result=query_action(REPLY_YES, QUERY_OVERWRITE, (FMSG *)misc_buf); } if(!query_result||(stricmp(archive_name, sfx_name)&&file_unlink(sfx_name))) error(M_CANT_DELETE, sfx_name); } msg_cprintf(H_HL|H_NFMT, M_CREATING_SFX, sfx_name); free(sfx_name); } } else msg_cprintf(H_HL|H_NFMT, (aistream==NULL)?M_CREATING_ARCHIVE:M_UPDATING_ARCHIVE, archive_name); if(!no_file_activity) { if(aistream==NULL) { aostream=file_open_noarch(archive_name, m_wb); file_close(aostream); aostream=NULL; file_unlink(archive_name); } tmp_archive_used=-1; if(assign_work_directory) { strcpy(tmp_archive_name, work_directory); add_pathsep(tmp_archive_name); } else split_name(archive_name, tmp_archive_name, NULL); strcat(tmp_archive_name, arjtemp_spec); find_tmp_filename(tmp_archive_name); aostream=file_open_noarch(tmp_archive_name, m_wbp); tmp_archive_used=0; #ifndef NO_CACHING setvbuf(aostream, NULL, _IOFBF, t_buf); #endif avail_space=file_getfree(tmp_archive_name); if(volume_limit>avail_space) { if(!yes_on_all_queries&&!skip_space_query) { msg_cprintf(H_HL|H_NFMT, M_FILENAME_FORM, tmp_archive_name); msg_sprintf(misc_buf, M_LOW_SPACE_WARNING, avail_space); if(!query_action(REPLY_YES, QUERY_LOW_SPACE, (FMSG *)misc_buf)) { tmp_archive_cleanup(); return(0); } } } if(create_sfx==SFXCRT_SFX&&multivolume_option) { if(!first_vol_passed) fetch_sfxv(); else if(use_sfxstub) fetch_sfxstub(); } else if(create_sfx==SFXCRT_SFX) fetch_sfx(); else if(create_sfx==SFXCRT_SFXJR) fetch_sfxjr(); /* Adjust the privileges on UNIX platforms */ #if TARGET==UNIX if(create_sfx) { if(create_sfx==SFXCRT_SFX&&multivolume_option&&first_vol_passed&&!use_sfxstub) make_nonexecutable(aostream); else make_executable(aostream); } else make_nonexecutable(aostream); #endif } } no_input=0; if(aistream==NULL) { no_input=1; fill_archive_header(); if(win32_platform&&use_ansi_cp) msg_cprintf(0, M_ANSI_CP_ARCHIVE); } else { if((main_hdr_offset=find_header(0, aistream))<0L) { msg_cprintf(H_ALERT, M_NOT_ARJ_ARCHIVE, archive_name); msg_cprintf(0, (FMSG *)lf); file_close(aistream); aistream=NULL; if(errorlevel==ARJ_ERL_SUCCESS) errorlevel=ARJ_ERL_NOT_ARJ_ARCHIVE; errors++; tmp_archive_cleanup(); return(ARJ_ERL_NOT_ARJ_ARCHIVE); } if(main_hdr_offset==0L&&modify_command&&create_sfx) copy_bytes(main_hdr_offset); if(main_hdr_offset>EXESIZE_MINSFX) { fseek(aistream, main_hdr_offset, SEEK_SET); fseek(aistream, -8L, SEEK_CUR); desc_word=fget_word(aistream); reg_id=fget_word(aistream); sfx_desc_word=desc_word; /* Perform a simple integrity check */ if(reg_id!=REG_ID&®_id!=UNREG_ID) sfx_desc_word=SFXDESC_NONSFX; if(sfx_desc_wordSFXDESC_MAX) sfx_desc_word=SFXDESC_NONSFX; } fseek(aistream, main_hdr_offset, SEEK_SET); if(!read_header(1, aistream, archive_name)) error(M_INVALID_COMMENT_HDR); if(use_sfxstub) digit_pos=iterate_sfxname(); if(modify_command&&continued_nextvolume&&!multivolume_option) { msg_cprintf(0, M_MV_UPDATE_REQ_SW); file_close(aistream); aistream=NULL; errors++; tmp_archive_cleanup(); return(0); } if(modify_command&&(cmd==ARJ_CMD_GARBLE||garble_enabled)) { if(arj_nbr>=ARJ_NEWCRYPT_VERSION&&ext_hdr_flags==0&&!encryption_applied) { ext_hdr_flags=ENCRYPT_STD; if(gost_cipher==GOST256) ext_hdr_flags=ENCRYPT_UNK; else if(gost_cipher==GOST40) ext_hdr_flags=ENCRYPT_GOST40; } else { if((gost_cipher!=GOST256||(ext_hdr_flags!=ENCRYPT_GOST256&&ext_hdr_flags!=ENCRYPT_GOST256L))&& (gost_cipher!=GOST40||ext_hdr_flags!=ENCRYPT_GOST40)&& gost_cipher!=GOST_NONE) error(M_WRONG_ENC_VERSION, 0); } } if(!win32_platform&&create_sfx&&!multivolume_option&&ext_hdr_flags>=ENCRYPT_STD) error(M_BAD_SYNTAX); if(cmd!=ARJ_CMD_COPY&&chapter_mode&&total_chapters==0) error(M_NOT_A_CHAPTER_ARCH); if(cmd==ARJ_CMD_DELETE&&delete_processed==DP_EXTRACT&&total_chapters!=0) error(M_BAD_SYNTAX); if(cmd==ARJ_CMD_DELETE&¤t_chapter==RESERVED_CHAPTER&&total_chapters==0) error(M_NOT_A_CHAPTER_ARCH); if(arjsec_opt==ARJSECP_SET_ERROR&&arj_flags&SECURED_FLAG) error(M_SKIPPING_SEC); if(protfile_option&&(multivolume_option||continued_nextvolume)&& !arjprot_tail&&is_removable) error(M_ARJPROT_REJECTED); timestamp_to_str(timetext, &ftime_stamp); msg_cprintf(H_HL|H_NFMT, M_ARCHIVE_CREATED, timetext); if(arj_nbr>=ARJ_M_VERSION) { ts_store(&tmp_time, host_os, compsize); timestamp_to_str(timetext, &tmp_time); msg_cprintf(H_HL|H_NFMT, M_MODIFIED, timetext); if(total_chapters!=0) msg_cprintf(H_HL, M_CHAPTER_NUMBER, total_chapters); } msg_cprintf(0, (FMSG *)lf); if((!modify_command||!use_comment)&&(cmd!=ARJ_CMD_COMMENT||supply_comment_file)) { if((cmd!=ARJ_CMD_LIST||!std_list_cmd||verbose_display!=VERBOSE_ENH)&&comment_display!=CMTD_NONE) display_comment(comment); } set_file_apis(ansi_codepage); if(ansi_codepage) { msg_cprintf(0, M_ANSI_CP_ARCHIVE); #if TARGET!=WIN32 if(cmd==ARJ_CMD_EXTR_NP&&!use_ansi_cp) error(M_REQUIRES_ARJ32); #endif } if(cmd==ARJ_CMD_LIST&&debug_enabled&&strchr(debug_opt, 'l')!=NULL) msg_cprintf(H_HL|H_NFMT, M_ENCRYPT_VALUE, ext_hdr_flags); } if(multivolume_option) volume_number=strtol(digit_pos, &digit_pos, 10)+1; if(modify_command) { main_hdr_offset=ftell(aostream); if(security_state) { msg_cprintf(0, M_CANT_UPDATE_SEC); msg_cprintf(0, (FMSG *)lf); file_close(aistream); aistream=NULL; errors++; errorlevel=ARJ_ERL_ARJSEC_ERROR; tmp_archive_cleanup(); return(0); } if(timestamp_override!=ATO_SAVE_BOTH) { cur_time_stamp(&tmp_time); compsize=ts_native(&tmp_time, host_os); } if(ts_valid(secondary_ftime)) compsize=ts_native(&secondary_ftime, host_os); /* Archive modification time */ if(garble_enabled) { encryption_version=garble_init(0); if(ext_hdr_flags==ENCRYPT_UNK) ext_hdr_flags=encryption_version; if(ext_hdr_flags!=0&&encryption_version!=ext_hdr_flags) error(M_WRONG_ENC_VERSION, ext_hdr_flags); } ext_flags=ext_hdr_flags; if(protfile_option) { arjprot_tail=protfile_option; if(prot_blocks==0) prot_blocks=arjprot_tail%256; /* v 2.75+ - %'ing is pointless! */ } if(sfx_desc_word!=SFXDESC_NONSFX) { if(chapter_mode) error(M_CHAPTER_SFX_CREATION); if(custom_method==5||method_specifier==4) error(M_INVALID_METHOD_SFX); if(sfx_desc_word<=SFXDESC_SFX&&multivolume_option) error(M_BAD_SYNTAX); /* Skip check for EAs - an existing archive may contain them but they are harmless! */ if(sfx_desc_word==SFXDESC_SFXJR&&(type_override||lfn_supported!=LFN_NOT_SUPPORTED)) error(M_TEXTMODE_LFN_SFXJR); if(sfx_desc_word==SFXDESC_SFXJR&&garble_enabled) error(M_NO_GARBLE_IN_SFXJR); if(sfx_desc_word==SFXDESC_SFX&&ext_hdr_flags>ENCRYPT_STD) error(M_WRONG_ENC_VERSION, ext_hdr_flags); } if(cmd==ARJ_CMD_COPY) { if(chapter_mode==CHAP_USE&&total_chapters!=0&&!multivolume_option) error(M_ALREADY_CHAPTER_ARCH); if(chapter_mode==CHAP_REMOVE&&total_chapters==0) error(M_NOT_A_CHAPTER_ARCH); if(chapter_mode==CHAP_USE&&total_chapters==0) { chapter_number=1; total_chapters=1; current_chapter=HIGHEST_CHAPTER; comment_entries++; } else if(chapter_mode==CHAP_REMOVE&&total_chapters!=0) { chapter_number=0; total_chapters=0; current_chapter=HIGHEST_CHAPTER; comment_entries++; } if(garble_enabled) { ext_flags=0; arj_flags&=~GARBLED_FLAG; if(!test_archive_crc) test_archive_crc=TC_ARCHIVE; } if(use_ansi_cp==ANSICP_SKIP) { if(arj_nbr==ARJ_ANSI_VERSION||arj_flags&ANSICP_FLAG) { msg_cprintf(H_ALERT, M_NOT_OEM_CP_ARCHIVE); file_close(aistream); aistream=NULL; errors++; errorlevel=ARJ_ERL_WARNING; tmp_archive_cleanup(); return(0); } arj_flags|=ANSICP_FLAG; comment_entries++; } if(protfile_option) { arjprot_tail=0; prot_blocks=0; arj_flags&=~PROT_FLAG; comment_entries++; } } if(add_command&&multivolume_option) arj_flags|=VOLUME_FLAG; if(arj_flags&DUAL_NAME_FLAG) dual_name=1; if(add_command&&!dual_name&&(lfn_mode==LFN_DUAL||lfn_mode==LFN_DUAL_EXT)) error(M_CANT_CNV_TO_DUAL_N); if(arj_flags&ANSICP_FLAG) ansi_codepage=1; if(add_command&&!ansi_codepage&&use_ansi_cp==ANSICP_CONVERT) error(M_ARCHIVE_CP_MISMATCH); if(!win32_platform&&ansi_codepage) error(M_ARCHIVE_CP_MISMATCH); create_header(1); if((cmd==ARJ_CMD_COMMENT&&!supply_comment_file)||use_comment) { if(supply_comment(archive_cmt_name, archive_name)) comment_entries++; } write_header(); first_file_offset=ftell(aostream); } else { first_file_offset=ftell(aistream); if(security_state&&arjsec_opt!=ARJSECP_SKIP) { if(method>ARJSEC_VERSION) { msg_cprintf(H_HL|H_NFMT, M_CANT_HANDLE_ARJSEC_V, method); msg_cprintf(0, (FMSG *)misc_buf); } else { msg_cprintf(0, M_VERIFYING_ARJSEC); if(arjsec_signature==NULL) arjsec_signature=(char *)malloc_msg(ARJSEC_SIG_MAXLEN+1); if(get_arjsec_signature(aistream, arjsec_offset, arjsec_signature, ARJSEC_ITER)) { arj_delay(5); msg_cprintf(0, M_DAMAGED_SEC_ARCHIVE); fclose(aistream); aistream=NULL; errors++; return(0); } msg_cprintf(0, M_VALID_ENVELOPE); fseek(aistream, first_file_offset, SEEK_SET); security_state=ARJSEC_SIGNED; } } if(garble_enabled) { encryption_version=garble_init(0); if((encryption_version!=ENCRYPT_GOST256&&encryption_version!=ENCRYPT_GOST256L)|| (ext_hdr_flags!=ENCRYPT_GOST256&&ext_hdr_flags!=ENCRYPT_GOST256L)) { if(ext_hdr_flags!=0&&encryption_version!=ext_hdr_flags) error(M_WRONG_ENC_VERSION, encryption_version); } } if(test_archive_crc==TC_ARCHIVE) { cmd_verb=ARJ_CMD_TEST; while(read_header(0, aistream, archive_name)) unpack_validation(ARJ_CMD_TEST); cmd_verb=cmd; if(errors!=0) error(M_FOUND_N_ERRORS, errors); fseek(aistream, first_file_offset, SEEK_SET); } if(cmd==ARJ_CMD_EXTR_NP&&use_comment&&archive_cmt_name[0]!='\0') { msg_cprintf(H_HL|H_NFMT, M_EXTRACTING_CMT_TO_F, archive_cmt_name); cmtstream=file_create(archive_cmt_name, m_w); if(hdr_comment[0]=='\0') { msg_strcpy(strcpy_buf, M_EMPTY_COMMENT); if(fputs(strcpy_buf, cmtstream)==EOF) error(M_DISK_FULL); } else { cmt_len=strlen(hdr_comment); if(fwrite(hdr_comment, 1, cmt_len, cmtstream)!=cmt_len) error(M_DISK_FULL); } comment_entries++; fclose(cmtstream); } } if((tmp_ptr=strchr(debug_opt, 'v'))!=NULL) msg_cprintf(H_HL|H_NFMT, M_BRIEF_MEMSTATS, coreleft(), t_buf, v_buf); /* The main part of the whole routine */ process_archive(cmd, no_input); finish_processing(cmd); } if(order_list!=NULL) { farfree(order_list); order_list=NULL; } file_close(aistream); aistream=NULL; return(0); } #elif SFX_LEVEL<=ARJSFXV /* Simplified routine for ARJSFXV */ #if SFX_LEVEL>=ARJSFXV static #endif void process_archive() { char timetext[22]; int query_result; FILE_COUNT pf_num; unsigned int ratio; int lt; #if SFX_LEVEL>=ARJSFXV struct timestamp tmp_time; static unsigned int t_buf, v_buf; char *tmp_ptr, *msg_ptr; char *digit_pos; int vol_num_digits; char *vol_name_fmt; int filename_length; char FAR *cmt_ptr; int no_in_arch; int enc_version; unsigned long free_space; unsigned int cf_num; #else char *cmt_ptr; int i; char tmp_name[FILENAME_MAX]; #endif #if SFX_LEVEL>=ARJSFXV cf_num=0; volume_flag_set=0; main_hdr_offset=last_hdr_offset=0L; total_files=0; comment_entries=0; security_state=ARJSEC_NONE; dual_name=0; ansi_codepage=0; disk_space_used=0L; total_uncompressed=0L; total_compressed=0L; archive_size=0L; ts_store(&ftime_max, OS, 0L); ts_store(&ftime_stamp, OS_SPECIAL, 0L); valid_ext_hdr=0; if(eh!=NULL) eh_release(eh); eh=NULL; first_hdr_size=STD_HDR_SIZE; for(total_os=0; host_os_names[total_os]!=NULL; total_os++); v_buf=VBUF_SFX; if((tmp_ptr=strchr(debug_opt, 'b'))!=NULL) { tmp_ptr++; v_buf=(int)strtol(tmp_ptr, &tmp_ptr, 10); } t_buf=TBUF_ARJ; if((tmp_ptr=strchr(debug_opt, 'p'))!=NULL) { tmp_ptr++; t_buf=(int)strtol(tmp_ptr, &tmp_ptr, 10); } if(multivolume_option) { if(use_sfxstub) digit_pos=iterate_sfxname(); else { vol_num_digits=2; tmp_ptr=volfmt_2digit; if(volume_number>99) { vol_num_digits++; tmp_ptr=volfmt_3digit; } if(volume_number>1000) /* ASR fix 20/10/2000 */ { vol_num_digits++; tmp_ptr=volfmt_4digit; } fix_sfx_name(); filename_length=strlen(archive_name)-vol_num_digits; if(volume_number>0) { vol_name_fmt=malloc_str(archive_name); vol_name_fmt[filename_length]='\0'; sprintf(archive_name, tmp_ptr, vol_name_fmt, volume_number); free(vol_name_fmt); } digit_pos=archive_name+filename_length; } continued_nextvolume=1; } ctrlc_not_busy=0; aistream=file_open(archive_name, m_rb); ctrlc_not_busy=1; if(aistream==NULL) { if(multivolume_option&&!yes_on_all_queries&&!skip_next_vol_query) { show_sfx_logo(); msg_cprintf(H_ERR, M_CANTOPEN, archive_name); msg_cprintf(0, (FMSG *)lf); return; } else error(M_CANTOPEN, archive_name); } #endif /* ARJSFX initialization... quite short */ #if SFX_LEVEL<=ARJSFX /* Set up ARJ$DISP screen if needed */ if(arjdisp_enabled) { cmd_verb=ARJDISP_CMD_START; filename[0]='+'; filename[1]='\0'; uncompsize=compsize=0L; display_indicator(0L); } if((aistream=file_open(archive_name, m_rb))==NULL) error(M_CANTOPEN, archive_name); #endif /* Initialize caching */ #ifndef NO_CACHING #if SFX_LEVEL>=ARJSFXV if(aistream!=NULL) setvbuf(aistream, NULL, _IOFBF, v_buf); #else setvbuf(aistream, cache_buf, _IOFBF, VBUF_SFX); #endif #endif /* Skip EXE header */ #if SFX_LEVEL>=ARJSFXV if(!first_vol_passed) sfx_seek(); else main_hdr_offset=find_header(0, aistream); #else sfx_seek(); #endif /* Header verification */ #if SFX_LEVEL>=ARJSFXV if(main_hdr_offset<0L) { msg_cprintf(H_ALERT, M_NOT_ARJ_ARCHIVE, archive_name); msg_cprintf(0, (FMSG *)lf); file_close(aistream); aistream=NULL; if(errorlevel==ARJ_ERL_SUCCESS) errorlevel=ARJ_ERL_NOT_ARJ_ARCHIVE; errors++; return; } fseek(aistream, main_hdr_offset, SEEK_SET); #endif /* Read the main archive header */ #if SFX_LEVEL>=ARJSFXV if(!read_header(1, aistream, archive_name)) error(M_INVALID_COMMENT_HDR); #else if(!read_header(1)) error(M_BAD_HEADER); #endif /* ARJSFXV: increment SFXNAME */ #if SFX_LEVEL>=ARJSFXV if(use_sfxstub) digit_pos=iterate_sfxname(); if(multivolume_option) volume_number=strtol(digit_pos, &digit_pos, 10)+1; #endif /* Analyze preset options */ cmt_ptr=comment; #if SFX_LEVEL>=ARJSFXV if(!first_vol_passed) { if(!skip_preset_options) cmt_ptr=preprocess_comment(cmt_ptr); sfx_setup(); show_sfx_logo(); msg_cprintf(H_HL|H_NFMT, M_PROCESSING_ARCHIVE, archive_name); timestamp_to_str(timetext, &ftime_stamp); msg_cprintf(H_HL|H_NFMT, M_ARCHIVE_CREATED, timetext); if(arj_nbr>=ARJ_M_VERSION) { ts_store(&tmp_time, host_os, compsize); timestamp_to_str(timetext, &tmp_time); msg_cprintf(H_HL|H_NFMT, M_MODIFIED, timetext); } msg_cprintf(0, (FMSG *)lf); if(ansi_codepage) msg_cprintf(0, M_ANSI_CP_ARCHIVE); if(chk_free_space) alloc_unit_size=get_bytes_per_cluster(target_dir); if(process_lfn_archive==1) lfn_supported=LFN_NOT_SUPPORTED; display_comment(cmt_ptr); if(!first_vol_passed&&cmd_verb==ARJ_CMD_EXTRACT&&!yes_on_all_queries&&!skip_extract_query) if(!query_action(REPLY_YES, QUERY_CRITICAL, M_CONTINUE_EXTRACTION)) exit(ARJ_ERL_WARNING); } #endif /* */ /* Nag screen removed */ /* */ #if SFX_LEVEL>=ARJSFXV if(!first_vol_passed) { if((garble_enabled&&!strcmp(garble_password, "?"))|| (file_garbled&&!garble_enabled&&(cmd_verb==ARJ_CMD_EXTRACT||cmd_verb==ARJ_CMD_TEST))) { garble_enabled=1; tmp_ptr=(char *)malloc_msg(INPUT_LENGTH+1); msg_cprintf(0, M_ENTER_PWD); read_line_noecho(tmp_ptr, INPUT_LENGTH); garble_password=malloc_str(tmp_ptr); free(tmp_ptr); } if(chk_free_space) alloc_unit_size=get_bytes_per_cluster(target_dir); if(process_lfn_archive==1) lfn_supported=LFN_NOT_SUPPORTED; #if SFX_LEVEL>=ARJ if(garble_enabled) { enc_version=garble_init(0); if(ext_hdr_flags!=0&&enc_version!=ext_hdr_flags) error(M_WRONG_ENC_VERSION, ext_hdr_flags); } #endif } #else if(!skip_preset_options) cmt_ptr=preprocess_comment(cmt_ptr); if(quiet_mode&&!yes_on_all_queries) quiet_mode=0; if(quiet_mode) freopen(dev_null, m_w, stdout); if(!process_lfn_archive) lfn_supported=LFN_NOT_SUPPORTED; msg_cprintf(H_HL|H_NFMT, M_ARJSFX_BANNER, exe_name); msg_cprintf(H_HL|H_NFMT, M_PROCESSING_ARCHIVE, archive_name); logo_shown=1; timestamp_to_str(timetext, &ftime_stamp); msg_cprintf(H_HL|H_NFMT, M_ARCHIVE_CREATED, timetext); if(show_ansi_comments) printf(cmt_ptr); else display_comment(cmt_ptr); /* The sfx_setup() occurs here */ if(list_sfx_cmd) cmd_verb=ARJ_CMD_LIST; else if(verbose_list) { cmd_verb=ARJ_CMD_LIST; std_list_cmd=1; } else if(test_sfx_cmd) cmd_verb=ARJ_CMD_TEST; else { cmd_verb=ARJ_CMD_EXTR_NP; test_mode=1; } if(garble_enabled&&garble_password[0]=='\0') error(M_NO_PWD_OPTION); if(file_args==0) f_arg_array[file_args++]=all_wildcard; case_path(target_dir); for(i=0; i=ARJSFXV if(!first_vol_passed&&prompt_for_directory) #else if(prompt_for_directory) #endif { query_result=0; if(target_dir[0]!='\0') { #if SFX_LEVEL>=ARJSFXV msg_sprintf(misc_buf, M_QUERY_DEST_DIR, target_dir); query_result=query_action(REPLY_YES, QUERY_CRITICAL, (FMSG *)misc_buf); #else msg_cprintf(H_HL|H_NFMT, M_QUERY_DEST_DIR, target_dir); query_result=query_action(); #endif } if(!query_result) { msg_cprintf(0, M_ENTER_INSTALL_DIR); read_line(target_dir, FILENAME_MAX-2); alltrim(target_dir); if(target_dir[0]!='\0') { if(target_dir[lt=strlen(target_dir)-1]!=PATHSEP_DEFAULT) { target_dir[lt+1]=PATHSEP_DEFAULT; target_dir[lt+2]='\0'; } case_path(target_dir); } } } if(security_state&&!skip_integrity_test) { if(get_arjsec_signature(aistream, arjsec_offset, arjsec_signature, ARJSEC_ITER)) { arj_delay(5); error(M_DAMAGED_SEC_ARCHIVE); } licensed_sfx=1; } if(test_sfx_cmd&&cmd_verb==ARJ_CMD_EXTRACT) { last_hdr_offset=ftell(aistream); #if SFX_LEVEL>=ARJSFXV while(read_header(0, aistream, archive_name)) #else while(read_header(0)) #endif unpack_validation(); if(errors!=0) error(M_FOUND_N_ERRORS, errors); fseek(aistream, last_hdr_offset, SEEK_SET); } #if SFX_LEVEL>=ARJSFXV ts_store(&ftime_stamp, OS, 0L); if(first_volume_number!=0) { volume_number=first_volume_number; first_volume_number=0; first_vol_passed=1; no_in_arch=1; } else no_in_arch=0; #endif #if SFX_LEVEL>=ARJSFXV while(!no_in_arch&&read_header(0, aistream, archive_name)) #else while(read_header(0)) #endif { pf_num=flist_lookup(); #if SFX_LEVEL>=ARJSFXV cf_num++; #endif switch(cmd_verb) { case ARJ_CMD_EXTR_NP: case ARJ_CMD_EXTRACT: if(pf_num!=0) { if(unpack_file_proc()) total_files++; tmp_tmp_filename[0]='\0'; } else skip_compdata(); break; case ARJ_CMD_LIST: if(pf_num!=0) { #if SFX_LEVEL>=ARJSFXV if(list_cmd(total_files, cf_num)) total_files++; #else list_cmd(); total_files++; #endif } skip_compdata(); break; case ARJ_CMD_TEST: if(pf_num!=0) { if(unpack_validation()) total_files++; #if SFX_LEVEL>ARJSFXV /* Avoid to skip data twice! Is this "minimal" fix safe????? */ else skip_compdata(); #endif } else skip_compdata(); break; } } #if SFX_LEVEL>=ARJSFXV total_processed+=total_files+comment_entries; av_compressed+=total_compressed; av_uncompressed+=total_uncompressed; av_total_files+=total_files; #endif #if SFX_LEVEL>=ARJSFXV if(cmd_verb==ARJ_CMD_LIST) #else if(cmd_verb==ARJ_CMD_LIST&&total_files>0) #endif { msg_cprintf(0, M_BRIEF_LIST_SEPARATOR); #if SFX_LEVEL>=ARJSFXV msg_ptr=nullstr; #endif ratio=calc_percentage(total_compressed, total_uncompressed); #if SFX_LEVEL>=ARJSFXV msg_cprintf(H_HL|H_NFMT, M_TOTAL_STATS, total_files, total_uncompressed, total_compressed, ratio/1000, ratio%1000, msg_ptr, nullstr); if(av_total_files>total_files) msg_cprintf(H_HL|H_NFMT, M_TOTAL_STATS, av_total_files, av_uncompressed, av_compressed, ratio/1000, ratio%1000, nullstr, nullstr); #else msg_cprintf(H_HL|H_NFMT, M_TOTAL_STATS, total_files, total_uncompressed, total_compressed, ratio/1000, ratio%1000); #endif #if SFX_LEVEL>=ARJSFXV if(chk_free_space) { free_space=file_getfree(target_dir); if(disk_space_used+minfree>free_space) { msg_cprintf(H_ALERT, M_NOT_ENOUGH_SPACE_X, disk_space_used+minfree-free_space); errors++; } } #endif } else { #if SFX_LEVEL>=ARJSFXV msg_cprintf(H_HL|H_NFMT, M_N_FILES, total_files); if(comment_entries!=0) msg_cprintf(H_HL|H_NFMT, M_N_COMMENTS, comment_entries); #else msg_cprintf(H_HL|H_NFMT, M_N_FILES, total_files); #endif } #if SFX_LEVEL>=ARJSFXV file_close(aistream); #else fclose(aistream); #endif #if SFX_LEVEL>=ARJSFXV aistream=NULL; if(total_processed==0&&!continued_nextvolume) { if(errorlevel==ARJ_ERL_SUCCESS) errorlevel=ARJ_ERL_WARNING; errors++; } #endif if(valid_envelope) msg_cprintf(H_HL|H_NFMT, M_VALID_ARJSEC, arjsec_signature); #if SFX_LEVEL<=ARJSFX /* ARJDISP cleanup */ if(arjdisp_enabled) { cmd_verb=ARJDISP_CMD_END; display_indicator(0L); } #endif } #endif #if SFX_LEVEL>=ARJSFXV /* Performs all archive processing actions including setup and so on... */ #if SFX_LEVEL>=ARJ void perform_cmd(int cmd) #else void perform_cmd() #endif { char *tmp_ptr; char *syscmd; int vol_num; unsigned long arch_time; char reply; #if SFX_LEVEL>=ARJ int tries; int proc_rc; #endif #if SFX_LEVEL>=ARJ /* Set up ARJ$DISP screen if needed */ if(arjdisp_enabled) { cmd_verb=ARJDISP_CMD_START; filename[0]='+'; filename[1]='\0'; uncompsize=compsize=0L; display_indicator(0L); } #endif ofstream=NULL; volume_flag_set=0; first_vol_passed=0; continued_nextvolume=0; total_processed=0; volume_number=0; resume_position=0L; is_removable=0; #if SFX_LEVEL>=ARJ if(eh!=NULL) { eh_release(eh); eh=NULL; } comment=NULL; tmp_filename=NULL; encstream=NULL; vol_file_num=0; split_files=0; dual_name=0; ansi_codepage=0; arjprot_tail=0; ext_hdr_flags=0; sfx_desc_word=0; total_chapters=0; recent_chapter=0; max_chapter=0; prot_blocks=0; #endif #if SFX_LEVEL>=ARJ modify_command=msg_strchr(M_MODIFY_COMMANDS, (char)cmd)!=NULL; add_command=msg_strchr(M_ADD_COMMANDS, (char)cmd)!=NULL; order_command=cmd==ARJ_CMD_ORDER; get_totals(); if((tmp_ptr=strchr(debug_opt, 'o'))!=NULL) convert_strtime(&secondary_ftime, ++tmp_ptr); else ts_store(&secondary_ftime, OS_SPECIAL, 0L); if(resume_volume_num!=0) { volume_number=resume_volume_num; resume_volume_num=0; first_vol_passed=1; } if(start_at_ext_pos) { resume_position=ext_pos; continued_prevvolume=1; mvfile_type=-1; } t_volume_offset=mv_reserve_space; #endif comment=farmalloc_msg(COMMENT_MAX); comment[0]='\0'; tmp_filename=farmalloc_msg(FILENAME_MAX); tmp_filename[0]='\0'; is_removable=file_is_removable(archive_name); #if SFX_LEVEL>=ARJ if(mv_cmd_state!=MVC_NONE) { if(mv_cmd[0]!='\0') { if(mv_cmd_state==MVC_DELETION) delete_files(mv_cmd); else if(mv_cmd_state==MVC_RUN_CMD) { msg_cprintf(H_PROMPT, M_COMMAND); msg_cprintf(H_HL|H_NFMT, M_FILENAME_FORM, mv_cmd); #if TARGET==UNIX nputlf(); #endif exec_cmd(mv_cmd); } } else { syscmd=(char *)malloc_msg(CMDLINE_LENGTH+1); while(1) { msg_cprintf(0, M_ENTER_CMD_EXIT); msg_cprintf(H_PROMPT, M_COMMAND); read_line(syscmd, CMDLINE_LENGTH); alltrim(syscmd); msg_strcpy(strcpy_buf, M_EXIT_CMD); if(!stricmp(strcpy_buf, syscmd)) break; if(syscmd[0]!='\0') exec_cmd(syscmd); } free(syscmd); } } #endif /* The archive processing itself occurs now */ #if SFX_LEVEL>=ARJ proc_rc=process_archive_proc(cmd); #else process_archive(); #endif #if SFX_LEVEL>=ARJ if(multivolume_option&&!proc_rc) #else if(multivolume_option) #endif { is_removable=file_is_removable(archive_name); #if SFX_LEVEL>=ARJ t_volume_offset=0L; tries=0; #endif first_vol_passed=1; #if SFX_LEVEL>=ARJ vol_num=volume_number; #endif while(continued_nextvolume) { #if SFX_LEVEL>=ARJ arch_time=file_getftime(archive_name); do { if(vol_num!=volume_number) { tries=0; vol_num=volume_number; } if(++tries>MAX_VOLUME_TRIES) { if(errorlevel==ARJ_ERL_SUCCESS) errorlevel=ARJ_ERL_FATAL_ERROR; errors++; goto all_volumes_done; } if(beep_between_volumes) msg_cprintf(0, (FMSG *)bell); if((!is_removable||skip_next_vol_query)&&(yes_on_all_queries||skip_next_vol_query)) break; reply=M_YES[0]; if(is_removable) msg_sprintf(misc_buf, M_INSERT_DISKETTE, volume_number, reply); else msg_sprintf(misc_buf, M_QUERY_NEXT_VOLUME, volume_number); if(!query_action(REPLY_YES, QUERY_NEXT_VOLUME, (FMSG *)misc_buf)) { if(errorlevel==ARJ_ERL_SUCCESS) errorlevel=ARJ_ERL_WARNING; errors++; goto all_volumes_done; } if(inhibit_change_test||tries>MAX_VOLUME_FT_CHECKS||!is_removable) break; if(!file_exists(archive_name)) break; } while(file_getftime(archive_name)==arch_time); if(mv_cmd_state!=MVC_NONE) { if(mv_cmd[0]!='\0') { if(mv_cmd_state==MVC_DELETION) delete_files(mv_cmd); else if(mv_cmd_state==MVC_RUN_CMD) { msg_cprintf(H_PROMPT, M_COMMAND); printf(strform, mv_cmd); exec_cmd(mv_cmd); } } else { syscmd=(char *)malloc_msg(CMDLINE_LENGTH+1); while(1) { msg_cprintf(0, M_ENTER_CMD_EXIT); msg_cprintf(H_PROMPT, M_COMMAND); read_line(syscmd, CMDLINE_LENGTH); alltrim(syscmd); msg_strcpy(strcpy_buf, M_EXIT_CMD); if(!stricmp(strcpy_buf, syscmd)) break; if(syscmd[0]!='\0') exec_cmd(syscmd); } free(syscmd); } } if(pause_between_volumes) arj_delay(change_vol_delay); #else if(!yes_on_all_queries&&!skip_next_vol_query) msg_cprintf(0, (FMSG *)bell); if((is_removable&&!skip_next_vol_query)||(!yes_on_all_queries&&!skip_next_vol_query)) { reply=M_YES[0]; if(is_removable) msg_sprintf(misc_buf, M_INSERT_DISKETTE, volume_number, reply); else msg_sprintf(misc_buf, M_QUERY_NEXT_VOLUME, volume_number); if(!query_action(REPLY_YES, QUERY_CRITICAL, (FMSG *)misc_buf)) { if(errorlevel==ARJ_ERL_SUCCESS) errorlevel=ARJ_ERL_WARNING; errors++; break; } } #endif /* Process next volume... */ #if SFX_LEVEL>=ARJ process_archive_proc(cmd); #else process_archive(); #endif } all_volumes_done: #if SFX_LEVEL>=ARJ if(beep_between_volumes) msg_cprintf(0, (FMSG *)bell); #else if(volume_number>1) msg_cprintf(0, (FMSG *)bell); #endif } if(ofstream!=NULL) { file_close(ofstream); ofstream=NULL; far_strcpy((char FAR *)filename, tmp_filename); file_setftime(filename, ts_native(&volume_ftime, OS)); } #if SFX_LEVEL>=ARJ if(tmp_filename!=NULL) farfree(tmp_filename); if(comment!=NULL) farfree(comment); #else farfree(tmp_filename); farfree(comment); #endif #if SFX_LEVEL>=ARJ /* ARJDISP cleanup */ if(arjdisp_enabled) { cmd_verb=ARJDISP_CMD_END; display_indicator(0L); } #endif } #endif arj-3.10.22/arj_user.h 666 0 0 1121 7450456570 10617 0ustar /* * $Id: arj_user.h,v 1.1.1.1 2002/03/28 00:02:01 andrew_belov Exp $ * --------------------------------------------------------------------------- * Prototypes of the functions located in ARJ_USER.C are declared here. * */ #ifndef ARJ_USER_INCLUDED #define ARJ_USER_INCLUDED /* Prototypes */ void arj_user_msg(FMSG *text); int test_host_os(int os); char *form_prot_name(); int destfile_extr_validation(); void write_index_entry(char *prefix); #if SFX_LEVEL>=ARJ void perform_cmd(int cmd); #else void perform_cmd(); #endif #if SFX_LEVEL<=ARJSFX void process_archive(); #endif #endif arj-3.10.22/arj_xms.asm 666 0 0 4717 7450456570 11017 0ustar ;* ;* $Id: arj_xms.asm,v 1.1.1.1 2002/03/28 00:02:01 andrew_belov Exp $ ;* --------------------------------------------------------------------------- ;* To make FILELIST.C less platform-dependent, its XMS routies are placed into ;* this file. ;* INCLUDE ASM_INCL.INC ;* ;* XMS move structure as proposed by XMS v 2.0 ;* xms_move struc blk_length dd ? src_handle dw ? src_offset dd ? dest_handle dw ? dest_offset dd ? xms_move ends ;* ;* Exported stubs ;* public detect_xms, get_xms_entry, allocate_xms, free_xms, move_xms .CODE ;* ;* Detects XMS presence. Returns 1 if it's present ;* detect_xms proc mov ah, 30h int 21h cmp al, 3 jb dx_none mov ax, 4300h int 2Fh cmp al, 80h jne dx_none mov ax, 1 jmp short dx_return dx_none: sub ax, ax dx_return: ret detect_xms endp ;* ;* Stores XMS entry point in an internal area ;* get_xms_entry proc uses es bx mov ax, 4310h int 2Fh mov word ptr xms_entry, bx mov word ptr xms_entry+2, es ret get_xms_entry endp ;* ;* Allocates N kilobytes of XMS memory ;* allocate_xms proc uses bx, kbs:word, hptr:ptr word mov ah, 9 mov dx, kbs call dword ptr xms_entry IF @DataSize push es les bx, hptr mov word ptr es:[bx], dx pop es ELSE mov bx, hptr mov word ptr ss:[bx], dx ENDIF ret allocate_xms endp ;* ;* Frees a block of XMS memory ;* free_xms proc uses bx, handle:word mov ah, 0Ah mov dx, handle call dword ptr xms_entry ret free_xms endp ;* ;* Moves a block ;* move_xms proc uses bx si ds, xms_mm:ptr xms_move mov ah, 0Bh IF @DataSize lds si, xms_mm ELSE mov si, xms_mm push ss pop ds ENDIF call dword ptr xms_entry ret move_xms endp .DATA? xms_entry dd ? end arj-3.10.22/arj_xms.h 666 0 0 1500 7450456570 10451 0ustar /* * $Id: arj_xms.h,v 1.1.1.1 2002/03/28 00:02:01 andrew_belov Exp $ * --------------------------------------------------------------------------- * Prototypes of the functions located in ARJ_XMS.ASM are declared here. * */ #ifndef ARJ_XMS_INCLUDED #define ARJ_XMS_INCLUDED /* XMS memory move structure */ struct xms_move { unsigned long length; /* Must be even */ short src_handle; /* Source handle */ unsigned long src_offset; /* Source offset */ short dest_handle; /* Destination handle */ unsigned long dest_offset; /* Destination offset */ }; /* Prototypes */ int detect_xms(); void get_xms_entry(); int allocate_xms(unsigned short kbs, short *handle); int free_xms(short handle); int move_xms(struct xms_move *xms_mm); #endif arj-3.10.22/asm_incl.inc 666 0 0 1570 7450456570 11124 0ustar ;* ;* $Id: asm_incl.inc,v 1.1.1.1 2002/03/28 00:02:01 andrew_belov Exp $ ;* --------------------------------------------------------------------------- ;* Common setup for assembly-language modules of ARJ. ;* INCLUDE ASM_DEFS.INC IFDEF FLATMODE .386p ELSE IFDEF _OS2 .286 ENDIF ENDIF IFDEF FLATMODE .MODEL FLAT, PASCAL ELSE IFNDEF SFXSTUB IFDEF MODL IFDEF _OS2 .MODEL MODL, C, OS_OS2 ELSE .MODEL MODL, C ENDIF ELSE .ERR ENDIF ENDIF ENDIF ; Mode-specific addressing IFDEF FLATMODE OPTION SEGMENT:USE16 V_DW EQU
V_WORD EQU ELSE V_DW EQU V_WORD EQU ENDIF IFNDEF FLATMODE AL_PARA EQU AL_WORD EQU ELSE AL_PARA EQU AL_WORD EQU ENDIF OPTION SCOPED arj-3.10.22/bindings.h 666 0 0 2351 7620765374 10614 0ustar /* * $Id: bindings.h,v 1.2 2003/02/07 17:21:01 andrew_belov Exp $ * --------------------------------------------------------------------------- * This file defines basic constants depending on the given SFX_LEVEL * */ #ifndef BINDINGS_INCLUDED #define BINDINGS_INCLUDED #define C_DEFS_INCLUDED #include /* If the SFX_LEVEL is not given, default to the lowest one ever possible */ #ifndef SFX_LEVEL #ifdef SFL #define SFX_LEVEL SFL #else #define SFX_LEVEL 0 #endif #endif /* Bindings (SFX_LEVEL grades) */ #define ARJ 4 #define ARJSFXV 3 #define ARJSFX 2 #define ARJSFXJR 1 #if SFX_LEVEL>=ARJ #define FMSG_ST #define FARDATA FAR #define FARCODE /* Just indicates the far code model */ #define EXTR_LEVEL ARJ_X_SUPPORTED #else #define FARDATA #define EXTR_LEVEL ARJ_X_SFX #endif #if defined(USE_COLORS)&&(SFX_LEVEL>=ARJ||defined(REARJ)) #define COLOR_OUTPUT #endif /* Debug information record. */ #ifdef DEBUG #define DEBUGHDR(fname) static char dbg_cur_file[]=fname; \ static int dbg_dummy; #else #define DEBUGHDR(fname) #endif #endif arj-3.10.22/ChangeLog 666 0 0 201266 10256534262 10473 0ustar 2005-06-23 Andrew Belov * 3.10/2.78 rev. 22: tag "arj-3_10_22". * arjtypes.c: YATF 2005-06-21 Andrew Belov * arjsfx.c, arjtypes.c, environ.h, rearj.c, scrnio.c, arj.c, arj_arcv.c, arj_file.c, arj_proc.c: Merged with recent TCO release to migrate the timestamp code and TAB handling fixes. 2005-06-18 Andrew Belov * arj_proc.c: Removed the quiet_mode logic for arjdisp_enabled (ARJDISP could operate on a separate terminal - no need to enforce and/or change quiet_mode) * integr.c: Mark an unreferenced variable as const, otherwise gcc 3.4 removes it - from Guillem Jover 2004-10-18 Andrew Belov * arj_proc.c: test fix for using quiet_mode with ARJDISP 2004-06-18 Andrew Belov * 3.10/2.78 rev. 21: tag "arj-3_10_21". * arj_arcv.c, arj_file.c, arj_proc.c, arj_user.c, arjtypes.c, environ.c, externs.c, externs.h, makefile: Merged with the remaining part of TCO fixes to make up for 3.10.21 2004-05-31 Andrew Belov * defines.h, encode.c, environ.c, environ.h, fmemcmp.asm, misc.c, rearj.c: Resync with TCO to close any outstanding bugs 2004-05-01 Andrew Belov * arj.c: Rudimentary Borland code caused the filenames in argv[] to be mishandled under Win32 2004-04-21 Andrew Belov * register.c: REGISTER might fail due to _fput_* changes 2004-04-17 Andrew Belov * 3.10/2.78 rev. 20: tag "arj-3_10_20". * environ.c: Cleaned up the DOS wildcard code * arjdata.c: The gamma cycle is now over, removing gamma version markers * arjsfxjr.c, arjtypes.c, ea_mgr.c, encode.c, environ.c, fardata.c, gost_t.c, misc.c, msgbind.c, packager.c, rearj.c, uxspec.c, arj.c, arj_arcv.c, arj_file.c, arj_user.c, arjsec_l.c: Supress warnings in GCC with -Wall - a patch from Guillem Jover 2004-04-14 Andrew Belov * arjsfx.c, defines.h, environ.h, filelist.c: Resync with current Win32 work on TCO * environ.c: Keep a wildcard trace bitmap on the stack to speed up certain searches in OS/2-32 and Win32 (OS/2-16 gets DosEditName again). Linux statvfs import solution from Guillem Jover 2004-03-21 Andrew Belov * environ.c: Workaround for partial patterns passed to fnmatch() 2004-03-17 Andrew Belov * arj_arcv.c: Removed compulsory endline insertion into comments. Fixed chapter archive access. 2004-03-16 Andrew Belov * environ.c: Fixed to compile with Linux v 2.6 headers (progressing name clash with libc) 2004-02-21 Andrew Belov * 3.10/2.78 rev. 19: tag "arj-3_10_19". * garble.c: Follow-up fix to the SKIP_GET_EXE_NAME patch 2004-02-20 Andrew Belov * arj_arcv.c, arj_proc.c, environ.c, externs.c, externs.h, misc.c, misc.h: Added the "-_" option to convert the filenames into lowercase after a patch from Konstantin Reznichenko * arj_arcv.c: Tolerate "-2l" on platforms without EA support. * garble.c: Inverted the check for SKIP_GET_EXE_NAME (regression from 2.78.13) 2004-01-25 Andrew Belov * scrnio.c, makefile, arj_proc.c, arj.c: Stdout/console fixes * msgbind.c, rearj.c, arj_proc.h, arjsfx.c, arjsfxjr.c, arjtypes.c, environ.c, arj_proc.c, arj.c: Patches from NetBSD codeline to enable NetBSD/x86-64 support 2003-10-20 Andrew Belov * make_key.c: YATF 2003-10-16 Andrew Belov * 3.10/2.78 rev. 18: tag "arj-3_10_18". * arjdata.c, exe_sear.c, packager.c: Incorporating QNX build patches by Mike Gorchak * arj_file.c, environ.c, environ.h: Merged with TCO up to 2.78.18 to introduce the final attribute fix 2003-09-19 Andrew Belov * environ.c: Fixes for compiling on SCO * fardata.c: ASP Linux v 7.3: GCC would complain on va_arg(ap,short) Patches submitted by Igor Paul March Chuk 2003-09-14 Andrew Belov * 3.10/2.78 rev. 17: tag "arj-3_10_17". * arj_file.c, arj_proc.c, fardata.c, makefile, scrnio.c, scrnio.h: Merged with TCO branch up to 2.78.17 2003-07-15 Andrew Belov * 3.10/2.78 rev. 16: tag "arj-3_10_16". * uxspec.c, uxspec.h, arj_arcv.c, defines.h: New parameter: "-2o2", to save both UID and GID in symbolic form. 2003-06-30 Andrew Belov * 3.10/2.78 rev. 15: tag "arj-3_10_15". * uxspec.c: Should return a value from set_uxspecial() when link() succeeds 2003-06-27 Andrew Belov * arj_arcv.c, arj_user.c, ea_mgr.c, environ.c: Merged with 2.78.15-TCO to fix the extended header update issue * arj_arcv.c: Prevent uncontrolled overwriting of existing files during extraction - SunOS patch from Etienne Joarlette * packager.c: Add "-+" to the archiver command line rather than response file 2003-06-22 Andrew Belov * arj.c, arjcrypt.c, arjdisp.c, arjsfx.c, arjsfxjr.c, make_key.c, makestub.c, msgbind.c, packager.c, postproc.c, rearj.c, register.c, sfxstub.c, today.c: Switched to "int main()" for consistency 2003-06-10 Andrew Belov * arj.c: Minor fix for iterating over extension names in -hx 2003-05-14 Andrew Belov * 3.10/2.78 rev. 14: tag "arj-3_10_14". * packager.c, arjdata.c: Packaging for SPARC * makefile: Link REGISTER with integr.* as a temporary workaround for POSTPROC regressions * rearj.c: Fixed handling of empty lines in REARJ.CFG 2003-05-11 Andrew Belov * 3.10/2.78 rev. 13: tag "arj-3_10_13". 2003-05-08 Andrew Belov * arj_proc.c, register.c: Updates for SPARC from Etienne Joarlette 2003-05-07 Andrew Belov * arjsec_h.c, environ.h, makefile: Updates for SPARC from Etienne Joarlette * arj_user.c: Fixed the "arj o" command (regression from 2.62.08). Display the ARJ-PROTECT safety factor. 2003-05-03 Andrew Belov * rearj.c, recovery.c, register.c, arj_proc.c, arj_user.c, arjsec_h.c, encode.c, environ.c, file_reg.c, postproc.c, arj_arcv.c: Updates for SPARC from Etienne Joarlette * arjcrypt.c: ARJCRYPT v 2.15: fixed inconsistency w/GOST256L method * fardata.c: Force CUSTOM_PRINTF for ARJ to bring "-jp" back 2003-04-27 Andrew Belov * encode.c, environ.c, environ.h, exe_sear.c, gost.c, gost40.c, join.c, postproc.c, recovery.c, arj.h, arj_arcv.c, arj_file.c, arj_file.h, arj_proc.c, arj_proc.h, arj_user.c, arjcrypt.c, arjsfxjr.c: Updates for SPARC from Etienne Joarlette 2003-04-26 Andrew Belov * environ.c: Converged the OS/2 and NT wildcard matching algorithms 2003-04-24 Andrew Belov * environ.h, filelist.c, register.c: Fixes for integration of 2.78.13 build environment 2003-04-18 Andrew Belov * garble.c, join.c: Build/packaging patches and man pages from Guillem Jover 2003-04-15 Andrew Belov * encode.c, environ.c, environ.h, recovery.c, arj_arcv.c, arjsfxjr.c, arjtypes.c: Preliminary SPARC/SunOS patches from Etienne Joarlette 2003-04-12 Andrew Belov * 3.10/2.78 rev. 12: tag "arj-3_10_12". * environ.h, rearj.c, arj.c, arj_user.c, arjdisp.c, arjsfx.c, arjtypes.c, decode.c, environ.c: Preliminary support for QNX v 6.0 using patches from Mike Gorchak * garble.c, gost40.c, arj_proc.c: Encryption fixes from 2.78.12-TCO 2003-04-06 Andrew Belov * 3.10/2.78 rev. 11: tag "arj-3_10_11". * rearj.c: Several command-line switches were blocked out. * makefile: Fixed stack overrun under OS/2-32. 2003-04-02 Andrew Belov * 3.10/2.78 rev. 10: tag "arj-3_10_10". * externs.h, uxspec.c, externs.c, environ.h, environ.c, defines.h, arj_proc.c, arj_arcv.c: Reintroduced the old (pre-2.76) directory archiving order, now optional as "-2r" * scrnio.h, scrnio.c, arj_file.c: Fixed several counter display issues 2003-02-07 Andrew Belov * 3.10/2.78 rev. 8: tag "arj-3_10_8". * uxspec.h, today.c, uxspec.c, scrnio.c, scrnio.h, register.c, recovery.c, rearj.c, packager.c, misc.c, localize.cmd, makefile, filelist.h, garble.c, fardata.h, filelist.c, fardata.c, externs.h, externs.c, environ.c, environ.h, encode.c, bindings.h, chk_fmsg.c, decode.c, defines.h, arjsfxjr.c, arjsfx.c, arjsec_h.c, arjdisp.c, arjdata.c, arj_user.c, arj_proc.c, arj_file.h, arj_file.c, arj_arcv.c, arj.h, arj.c: Merged with TCO branch up to 2.78.08 (colorstyle support and internal cleanup) 2003-01-25 Andrew Belov * 3.10/2.78 rev. 7: tag "arj-3_10_7". * postproc.c, scrnio.c, scrnio.h, packager.c, ntstream.h, ea_mgr.c, environ.c, environ.h, externs.c, garble.c, makefile, mkdir_p.cmd, msgbind.c, ntstream.c, arjcrypt.c, arjdata.c, arjdisp.c, arjsfxjr.c, defines.h, arj_user.c, arj.h, arj_arcv.c, arj_proc.c, arj.c: Added Win32 support 2002-12-13 Andrew Belov * environ.h: Migrated the FAR_BLK_MAX fix from TCO branch. * msgbind.c: Fixed to compile with GCC/EMX. 2002-07-04 Andrew Belov * arj.c: Fixed crash at startup with "ARJ Q" and no filespec. * arj_file.c, defines.h: Added "-d1" and "-d2". * arjtypes.c: Fixed wrong timestamp conversion (regression from 13/08/2001 perf. enh. for 2.77). 2002-05-14 Andrew Belov * arj_proc.c: Fixed handling of "+" and "-" modifiers in ARJ.CFG. * arj_user.c: Fixed the storage attributes for modification archive timestamp. 2002-04-14 Andrew Belov * environ.c: Fix for a GCC v 3.0 optimization bug. 2002-04-08 Andrew Belov * arj.c, arj_arcv.c, arj_proc.c, arjsec_h.c, arjsec_l.c, environ.h, externs.c, makefile, packager.c: Official Open-source release. 2002-03-27 Andrew Belov * Transferred to SourceForge. 2002-03-27 Andrew Belov * packager.c: Removed company names * arj.c, arj_user.c, arjsec_h.c, arjsec_l.c, arjsfx.c, arjsfxjr.c, crc32.c, defines.h, environ.c, makefile, msgbind.c, packager.c, rearj.c: Preparations for open-sourcing. 2002-02-26 Andrew Belov * environ.h: DeUNIXified the EMX branch. 2002-01-30 Andrew Belov * scrnio.h: Added scrn_reset() stub for Borland C. * file_crc.c: Removed (obsolete since ARJ v 2.72). * crc32.c, encode.c: Fixed to compile with Borland C v 3.1. 2002-01-12 Andrew Belov * arj_file.c: Fixed the "-i5" indicator. 2001-11-30 Andrew Belov * packager.c: Merged with German NLS for 2.71.04. 2001-11-23 Andrew Belov * asm_incl.inc: Removed the obsolete code for pure ASM modules. 2001-11-09 Andrew Belov * makefile: Introduced OpenWatcom v 11.0c compiler (LIBC). 2001-11-08 Andrew Belov * environ.h: OpenWatcom fixes. 2001-10-23 Andrew Belov * environ.c: New get_exe_name() for SKIP_GET_EXE_NAME. 2001-10-14 Andrew Belov * makefile: Fixed MS C options to avoid including .\C_DEFS.H. 2001-09-27 Andrew Belov * makefile: Converted to VisualAge C++ v 3.65. * decode.c: Fixed to shut off the VisualAge optimizer. 2001-09-23 Andrew Belov * arj_arcv.c, ext_hdr.c: Fixed some EXT_HDR regressions in 16-bit mode. 2001-09-15 Andrew Belov * arjtypes.c: Fixed time handling with XPG.4 LIBC. 2001-09-11 Andrew Belov * arjtypes.c: Fixed the display of UNIX timestamps in MS-DOS. 2001-09-09 Andrew Belov * recovery.c: Fixed protection block size calculation. * arj_arcv.c: Fixed the regression from 04/02/2001 changes. 2001-09-06 Andrew Belov * arjtypes.c: Corrected the DOS-to-UNIX timestamp conversion. 2001-09-04 Andrew Belov * makefile: Conditional compiles in medium model. * garble.c: Fixed ARJCRYPT loading/verification order. Fixed ARJCRYPT v 2.1 incompatibility. * arj_file.c: Fixed "-2a" for the ".*" pattern. 2001-09-02 Andrew Belov * arjtypes.c: Implemented fm_native(). 2001-08-31 Andrew Belov * arj_proc.c: Fixed the parsing of -t1f/-t1g. * arj_file.c: -t0 upon extraction will now retain the 8th bit. 2001-08-30 Andrew Belov * rearj.c: Added support for .tar.gz bundles. Changed to use the platform-neutral STD_*_ATTR. * environ.c: Added fork()-enabled exec_pgm() for REARJ. 2001-08-29 Andrew Belov * uxspec.c: Support for numeric UID/GID representation. 2001-08-28 Andrew Belov * packager.c: Removed the snappy ANSI screen. * makefile: Fixes for ancient Microsoft compilers. * arjtypes.c: Fixed to take DST into account with IBM LIBC. 2001-08-27 Andrew Belov * arj_proc.c: Merged the -2p parsers for OS/2 and UNIX. * arj_arcv.c: Dropped parse_unixtime() from the merge. * ansi.c, ansi.h, arj.c, arj.h, arjdata.c, arjsec_l.c, arjsfx.c, arjsfxjr.c, arj_arcv.c, arj_arcv.h, arj_file.c, arj_proc.c, arj_proc.h, arj_user.c, decode.c, defines.h, ea_mgr.c, encode.c, environ.c, environ.h, exe_sear.c, externs.c, externs.h, filelist.c, filelist.h, garble.c, makefile, misc.c, misc.h, msgbind.c, packager.c, postproc.c, rearj.c, recovery.c, scrnio.c, scrnio.h: Merged 2.76-STABLE into 2.77-CURRENT. * ansi.c: Re-fix the 14/08/2001 chg. for DIRECT_TO_ANSI. 2001-08-26 Andrew Belov * file_reg.c: Added a special hack for PACKAGER in UNIX. * arj_proc.c: Added '#' as a comment character to ARJ.CFG. 2001-08-25 Andrew Belov * scrnio.c: Added scrn_reset(). * environ.c: Tolerate EINVAL when doing fcntl()/flock(). * arj_file.c: Fixed the ANSI output with DIRECT_TO_ANSI. * arj_arcv.c: Temporary parse_unixtime() for 2.76-stable. * arjdisp.c: Added ANSI terminal reset on the ending screen. UNIX branch (7-bit ASCII). * arj.c: Fixed for argv[] expansion in UNIX. 2001-08-24 Andrew Belov * msgbind.c: Parameter inversion ("!") support. * environ.h, misc.c: Hardlink support. * file_reg.c: Fixed the case sensitivity issues. * filelist.c: Fixed for hardlink support. * arj_user.c: Introduced the UNIX list mode. 2001-08-23 Andrew Belov * uxspec.c, uxspec.h: Created. * ea_mgr.c: Moved the mget/mput_* to ARJ_PROC.*. 2001-08-21 Andrew Belov * garble.c: UNIX implementation via dlopen(). * filelist.c, filelist.h: Renamed some filelist constants. * exe_sear.c: Fixed premature fclose() in ELF get_exe_size(). 2001-08-19 Andrew Belov * environ.c: Added preliminary support for UNIX platforms. 2001-08-17 Andrew Belov * arj.c: Removed M_OS_SPECIFIC for "-2d". 2001-08-16 Andrew Belov * arjtypes.c: Fixed buggy time_t conversions. 2001-08-15 Andrew Belov * makefile: The MetaWare builds now use IBM LIBC. * defines.h: ARJ32 v 3.05 PERF ENH - introduced FDICSIZ. * decode.c: Performance enhancements to 32-bit decode_f(). 2001-08-14 Andrew Belov * ansi.h, scrnio.c, scrnio.h: Disabled the code generation for OS/2. * makefile: Introduced IBM VisualAge C++ v 3.00 compiler. The OS/2-32 compiler now defaults to VACPP. * environ.c: Moved file_copy() from ARJ_PROC.C. * arj_proc.c: Added support for priority deltas. * arj_file.c: Changed the ANSI display to use VIO under OS/2. * arj.c: Fixed -hk to work with -va. * ansi.c: Disabled code generation for OS/2. 2001-08-13 Andrew Belov * debug.h: Added assertion macros. * arjtypes.c: Bummed the mk_unixtime() to get rid of loops. 2001-07-24 Andrew Belov * encode.c: Blown out the rest of BCC-related comments. 2001-07-16 Andrew Belov * environ.c: Fixed launch of DOS archivers from REARJ. 2001-07-09 Andrew Belov * arjdata.c: Corrected to comply the English date format. 2001-06-24 Andrew Belov * environ.c: Changed memory allocation in wild_list(). * arj.c: Changed wildcard_pattern to UNIX-style. 2001-06-21 Andrew Belov * misc.c: Fixed CFA for the 16-bit world. * arj_user.c: ** Updated to ARJ v 2.76 code level **. Fixed phantom EAs appearing after updates. * arj_proc.c: unpack_mem() changed for deferred garble_init(). 2001-06-20 Andrew Belov * arj_arcv.c, environ.c: ** Updated to ARJ v 2.76 code level **. * arj.c: ** Updated to ARJ v 2.76 code level **. 2001-06-19 Andrew Belov * packager.c: Added glossary to the debug distribution. * ansi.c, arj.c, arj.h, arjdata.c, arjsec_l.c, arjsfx.c, arjsfxjr.c, arj_arcv.c, arj_arcv.h, arj_file.c, arj_proc.c, arj_proc.h, arj_user.c, defines.h, ea_mgr.c, encode.c, environ.c, environ.h, exe_sear.c, filelist.c, filelist.h, garble.c, makefile, misc.c, misc.h, msgbind.c, packager.c, postproc.c, rearj.c, recovery.c, scrnio.h: Merged recent 2.75 code with earlier revisions on 2.76 sparse tree. 2001-06-04 Andrew Belov * arj_proc.c: Fixed check_multivolume() regression from 29/03. 2001-05-11 Andrew Belov * msgbind.c: Disabled termination by signals. 2001-04-07 Andrew Belov * environ.c: Fixed file_open (regression from 2.75.18.3). 2001-04-06 Andrew Belov * ansi.c, arj.c, arj.h, arjdata.c, arjsec_l.c, arjsfx.c, arjsfxjr.c, arj_arcv.c, arj_arcv.h, arj_file.c, arj_proc.c, arj_proc.h, arj_user.c, ea_mgr.c, encode.c, environ.c, environ.h, filelist.c, filelist.h, makefile, misc.c, misc.h, msgbind.c, rearj.c, recovery.c, scrnio.h: Merged with MetaWare High C branch. 2001-04-05 Andrew Belov * rearj.c: Now uses FILE_COUNT for counting packed files. * arj_proc.c: Fixed looping with High C optimizations. * arjsfxjr.c: Fixed the CTRL+C handlers for IBM C and High C. * arjsfx.c: Fixed the counts to be FILE_COUNT. 2001-04-01 Andrew Belov * arj_file.c: Fixed display_block(). 2001-03-31 Andrew Belov * recovery.c: Fixed to compile with MetaWare High C/C++. 2001-03-29 Andrew Belov * makefile: Introduced MetaWare High C v 3.20 compiler. * arj_proc.c: Fixed to compile with MetaWare High C. * arj.c, arj.h, arjsec_l.c, arjsfx.c, arjsfxjr.c, arj_arcv.h, arj_proc.c, arj_proc.h, ea_mgr.c, environ.c, environ.h, makefile, rearj.c: Created a MetaWare High C branch. 2001-02-23 Andrew Belov * exe_sear.c: Improved the header lookup procedure. * arj_arcv.c: Added debugging dump for header errors. 2001-02-21 Andrew Belov * postproc.c: Now writes header only if changed it. * makefile: Improved debugging and added map file creation. * arj_proc.c: M_INVALID_DATE for unrecognized dates. 2001-02-20 Andrew Belov * packager.c: Added symbol file creation for DEBUG branch. 2001-02-16 Andrew Belov * environ.c: Removed import_timestamp() as obsolete. 2001-02-12 Andrew Belov * exe_sear.c: Preliminary support for ELF modules. 2001-02-10 Andrew Belov * arjtypes.h: Changed to accomodate the multiplatform modes. TYPES_INCLUDED -> ARJTYPES_INCLUDED. * arjtypes.c: Created. 2001-02-05 Andrew Belov * misc.c: Added far_memset(). * garble.c: Fixed loading of ARJCRYPT in ARJSFXV. * ea_mgr.c: Fixed EA cleanup under 32-bit OS/2. 2001-02-04 Andrew Belov * arj_arcv.c, arj_user.c: Changed to use the extended header module. 2001-02-02 Andrew Belov * ext_hdr.c: Created. 2001-02-01 Andrew Belov * msgbind.c: Added emulation of strupr()/strlwr() functions. * environ.h: Added preliminary support for UNIX platforms. 2001-01-30 Andrew Belov * garble.c: Fixed ARJCRYPT initialization for GCC/EMX. * arjcrypt.h: Implemented structure packing (so it does not get blurred with GCC). 2001-01-29 Andrew Belov * integr.c, sfxstub.c, sfx_id.c: Created. * rearj.c: Fixed for GCC/EMX. * postproc.c: ARJ/EMX executables are now packed as well. * packager.c: Fixed for new ARJDISP naming and GCC/EMX. * msgbind.c: Allowed use of the "/" path separator. * makefile: Renamed ARJ$DISP to ARJDISP (so goes the source). * arj_file.c: Added verification for NULL in file_close(). * arjsec_l.c: Disabled compilation for the shareware SFX. 2001-01-28 Andrew Belov * misc.c: Fixed the [] handling in xwild_match(). * gnu/configure.in, gnu/makefile.in: Created. 2001-01-25 Andrew Belov * environ.c: Swapped the file/subdir search in wild_list(). The getenv() stub now compiles for MS C only. 2001-01-17 Andrew Belov * misc.h: Removed the CFA addressing macros. * misc.c: Added new CFA numbering scheme. 2001-01-16 Andrew Belov * environ.h: Improved the buffering for 32-bit OS/2. Removed lreg(). 2001-01-15 Andrew Belov * packager.c: Added year substitution in copyright notice. * arjdata.c: Added the "@{y}" tag to represent year. 2001-01-12 Andrew Belov * arj_proc.c: Fixed parsing of -vxxxK and -vxxxM. 2001-01-02 Andrew Belov * ext_hdr.h: Created. 2000-12-18 Andrew Belov * arjdata.c: Fixed LOCALE branching. 2000-12-17 Andrew Belov * environ.h: Added signal parameters macro. * crc32.c: Resurrected. * crc32.asm: Removed (superseded by CRC32.C). 2000-11-14 Andrew Belov * rearj.c: Fixed locking of temporary directories. 2000-11-03 Andrew Belov * postproc.c: No action for no packing. 2000-11-02 Andrew Belov * make_key.c: Fixed to use the 10-digit format. 2000-10-31 Andrew Belov * arjdata.c: Fixed the nested tag expansion. 2000-10-29 Andrew Belov * today.c: Removed the hh:mm debug timestamp. * postproc.c: Implemented LZEXE and LXLITE packing. * makefile: Automation Release #4 - LIBC. * arj_file.c, join.c: Fixed for LIBC. * enc_asm.asm: Removed (superseded by ENCODE.C). * dec_asm.asm: Removed (superseded by DECODE.C). * arj_user.c: Fixed digit_pos setup in ARJSFXV. * arj_proc.c: Fixed "ARJ I" for large executables. 2000-10-28 Andrew Belov * makestub.c: Changed to accept the destination filename. * makefile: Automation Release #3 - concurrent compiles. * arjdata.c: Fixed for Turbo C. Fixed tag expansion. 2000-10-27 Andrew Belov * make_cmt.c: Removed (superseded by PACKAGER.C). * makefile: Debug version now uses itself for packaging. * arjsfx.c: Fixed the signal()-related warnings in MS C. 2000-10-24 Andrew Belov * packager.c: Incorporated with MAKE_CMT. * makefile: Automation Release #1 - new packaging algorithm. * crc32.asm: Fixed afl_mul in 16-bit mode. 2000-10-23 Andrew Belov * environ.h: Added the executable extensions. * arjdisp.c: Fixed the "test" option to be platform-neutral. 2000-10-21 Andrew Belov * packager.c: Created. 2000-10-19 Andrew Belov * msgbind.c: Implemented the substitution feature. * encode.c: Joined with the 01/09 edition of ENC_ASM.ASM. * arj_user.c: Fixed 3-digit volumes handling in ARJSFXV. * arjdata.c, arjdata.h: Created. 2000-10-18 Andrew Belov * misc.c: Fixed for IBM C Set++. Fixed the extended wildcard parser. * join.c: Positioning hotfix for the previous version. * arjcrypt.c, gost40.c: Fixed last_bytes increment on encoding. * exe_sear.c: SFX creation has been optimized for linear mode. * environ.c: Fixed for ARJDISP on DOS. 2000-10-17 Andrew Belov * ea_mgr.c: Updated for 32-bit OS/2. * crc32.asm: Fixed the LONG return values for 32-bit mode. 2000-10-16 Andrew Belov * sfxstub.asm: Fixed prototypes for OS/2 libraries. * environ.c: Updated for 32-bit OS/2. 2000-10-15 Andrew Belov * sfxstub.asm: Fixed for 32-bit OS/2. * reg_stmp.h: Removed (changes for 32-bit). * postproc.c: Removed the outdated REGISTER postprocessing. * join.c: Fixed for IBM C Set++. * enc_asm.asm: Completely duplicated the routines in ENCODE.C. * encode.c: Finished the portabilization. 2000-10-12 Andrew Belov * arjsfxjr.c: German NLS. 2000-10-11 Andrew Belov * encode.c: Portabilized the method 4. * decode.c: Completely portabilized the DEC_ASM.ASM. 2000-10-10 Andrew Belov * decode.c: Fixed make_table for C version of decoder. 2000-10-07 Andrew Belov * makestub.c: Include file now compiles even w/o resources. 2000-10-04 Alexander Bahlo * make_cmt.c: NLS german. 2000-10-02 Andrew Belov * decode.c: Introduced C versions of decode_c/p(). 2000-09-30 Andrew Belov * crc32_32.asm: Removed (ARJ-SECURITY performance fix renders CRC32_32.ASM obsolete). * crc32.asm: Fixed for REGVARS. * asm_incl.inc: Added REGVARS, used if compiling for FLATMODE. * arj.c: Fixed "-2d?" handling. 2000-09-13 Andrew Belov * arjsec_l.c: Slightly optimized the arjsec_read(). 2000-09-09 Andrew Belov * encode.c, enc_asm.asm: Portabilized the calling conventions. * crc32.asm: Incorporated with the CRC32_32.ASM. * arj_user.c: ** Updated to ARJ v 2.75 code level **. * arjsfxjr.c, arj_arcv.c: Brought the "malicious header" checkup in line with ARJ v 2.75. 2000-09-01 Andrew Belov * enc_asm.asm: encode_f() has been removed. * encode.c: Brought back encode_f(). 2000-08-19 Andrew Belov * makefile: Implemented REGISTER packing as in v 2.71a. * environ.c: Added a workaround for >2G free space report. * arj.c, arj_proc.c, arj_user.c: ** Updated to ARJ v 2.73 code level **. * arj_arcv.c: ** Updated to ARJ v 2.73 code level **. 2000-08-17 Andrew Belov * makefile: Removed the FILE_CRC utility. * arjcrypt.c, file_reg.c, garble.c: ** Updated to ARJ v 2.72 code level **. * arjcrypt.h: Updated to version 2.0 of the interface. 2000-08-16 Andrew Belov * arj_user.c: ** Updated to ARJ v 2.72 code level **. 2000-08-15 Andrew Belov * enc_asm.asm: encode_f(): Fixed upd_tree() call sequence. * arj_user.c: Modified century handling for CENT_*. * arj_arcv.c: Fixed misuse of new_stdout in certain places. 2000-08-12 Andrew Belov * filelist.c: Fixed block overrun due to clumsy sizeof(). * arj_file.c: ** Updated to ARJ v 2.72 code level **. 2000-08-11 Andrew Belov * misc.c: ** Updated to ARJ v 2.72 code level **. * environ.h: Corrected the multiplatform logic. * arjsfx.c: Transformed to CFA filelist model (NB: our branch uses the FILE_COUNT type everywhere!). * arjsec_l.c: Fixed the annoying C4061 messages. 2000-08-03 Andrew Belov * arjsfxjr.c, arj_arcv.c: Fixed malicious header processing. 2000-08-01 Andrew Belov * msgbind.c: Introduced a useless year tracking feature. * exe_sear.c: Fixed for using descriptive word constants. * arj_arcv.c: ** Updated to ARJ v 2.72 code level **. 2000-07-23 Andrew Belov * misc.c: Removed near_stricmp(). 2000-07-22 Andrew Belov * arj.c: Made the commercial versions unexpirable. 2000-07-07 Andrew Belov * arj_proc.c, recovery.c: ** Updated to ARJ v 2.72 code level **. * filelist.c: ** ARJ v 2.72 functionality achieved **. 2000-07-02 Andrew Belov * environ.c, exe_sear.c: ** Updated to ARJ v 2.72 code level **. * encode.c: Brought back huf_encode() and huf_encode_m3(). 2000-06-22 Andrew Belov * enc_asm.asm: A paranoid memmove argument optimization. 2000-06-02 Andrew Belov * arj_file.c: Fixed to follow the new ARJ v 2.72 ARJ_QUIET2. 2000-05-30 Andrew Belov * makefile: Fixed /B2 parameter order in MS C setup. 2000-05-17 Andrew Belov * today.c: Added German timestamp format. 2000-05-07 Andrew Belov * makefile: HELP.ARJ is now verified as we rewrite DECODE.C. 2000-05-05 Andrew Belov * enc_asm.asm: Started re-portabilization (moving code to C). 2000-04-14 Andrew Belov * makefile: @'ed out all the external commands. 2000-03-29 Andrew Belov * arj_user.c: Fixed abnormal behavior of -b and -b2 switches. 2000-03-25 Andrew Belov * makefile: Introduced IBM C Set++ v 2.10 compiler. * crc32.asm: Changes for 32-bit mode. * asm_incl.inc: Changed to allow 32-bit compiles. 2000-03-19 Andrew Belov * makefile: Converted all filename specifiers to lowercase. * arj_arcv.c, arj_user.c: ** Updated to ARJ v 2.71 code level **. 2000-03-08 Andrew Belov * register.c: ** Updated to REGISTER v 2.71 code level **. * arj_proc.c, exe_sear.c: ** Updated to ARJ v 2.71 code level **. * arjsfxjr.c: ** Updated to ARJ v 2.71 code level **. 2000-02-29 Andrew Belov * makefile: Created a separate directory for *.STS. Introduced Borland C++ v 4.00 compiler. * defines.h: Changed the default EXE size constraints. 2000-02-28 Andrew Belov * rearj.c: Fixed to compile with QuickC. * makefile: Removed path dependencies in compiler settings. 2000-02-27 Andrew Belov * types.h: Removed (superseded by ARJTYPES.H). 2000-02-20 Andrew Belov * makestub.c, sfxstub.asm: Created. 2000-02-14 Andrew Belov * rearj.c: Fixed "/J" option behavior. * ea_mgr.c: Added resolve_longname(). * arj_user.c: Added a switch to skip century display in dates. Fixed century display in dates beyond 2000. * arj_proc.c: Fixed "ARJ I" for large executables. Fixed "-v...K", "-v...M" parsing. 2000-02-10 Andrew Belov * makefile: Introduced Microsoft Visual C v 1.00 compiler. Introduced Microsoft Visual C v 1.50 compiler. 2000-02-07 Andrew Belov * make_key.c, register.c: Fixed signed/unsigned issues. * file_reg.c: Fixed signed/unsigned issues. * arj_arcv.c: Implemented RO flag clearing on add operations. 2000-02-04 Andrew Belov * msgbind.c: Changed TYPES.H -> ARJTYPES.H. * enc_asm.asm: Packed the stack cleanup sequences upon return. * arjtypes.h: Renamed to ARJTYPES.H. 1999-12-31 Andrew Belov * rearj.c: ** Updated to REARJ v 2.42 code level **. Added shutdown_initiated, ctrlc_initiated. * environ.c: Added arj_getdate() function. 1999-12-26 Andrew Belov * file_reg.h: Created. * file_reg.c: Created from ARJ.C. * arj.c: Moved all registration code to FILE_REG.C. 1999-12-05 Andrew Belov * arj_arcv.c: Fixed restoration of extended attributes. 1999-12-04 Andrew Belov * decode.c: Fixed buffer overrun in read_pt_len(). 1999-12-01 Andrew Belov * arj_proc.c: Fixed M_OUT_OF_MEMORY errors in unstore(). 1999-11-28 Andrew Belov * scrnio.c: Fixed clreol() under OS/2. 1999-11-24 Andrew Belov * rearj.h: Created. * postproc.c: Changed to portabilize the verification scheme. * arj.c, arj_user.c, environ.c: ** Updated to ARJ v 2.70 code level **. 1999-11-23 Andrew Belov * make_key.c: Created. * makefile: Moved all helper programs to one directory. 1999-11-22 Andrew Belov * arjsec_l.c: ** Updated to ARJ v 2.70 code level **. 1999-11-21 Andrew Belov * register.c: ** Updated to REGISTER v 2.70 code level **. 1999-11-20 Andrew Belov * arj_proc.c: Moved strip_lf() to this module. 1999-11-14 Andrew Belov * makefile: OS/2 SFX modules are now packed. 1999-11-09 Andrew Belov * today.c: Fixed debug time stamping. 1999-11-08 Andrew Belov * makefile: Added REARJ.CFG to all distribution packages. 1999-11-07 Andrew Belov * today.c: Added hh:mm timestamp for debug versions. 1999-11-06 Andrew Belov * environ.c: Fixed read_line_noecho() under OS/2. * ea_mgr.c: Fixed to work with Ext2FS. 1999-11-02 Andrew Belov * environ.c: Fixed file_rmdir() with "-ha" option. * arj_arcv.c, arj_user.c: Removed ARJSFXV shareware size limitation. * arj_user.c: Added automatic testing after ungarbling. * arj_proc.c: Fixed AC/CC/DC parsing from ARJ.CFG. * arj_arcv.c: Fixed read-only extraction in DOS/MSC version. * arj.c: Added configuration file lookup. 1999-10-31 Andrew Belov * arj_proc.c: Added day-of-year timestamp option. 1999-10-23 Andrew Belov * arj_arcv.c: Added CHO_COMMENT header fixup. * arj.c: Changed to allow empty filenames with -h#. 1999-10-22 Andrew Belov * rearj.c: Fixed recursive repacking. * environ.c: Fixed removable media detection with MS C/DOS. * arj_proc.c: Added custom timestamp format option. 1999-10-20 Andrew Belov * environ.c: Fixed delay() routine DOS branch. 1999-10-19 Andrew Belov * dec_asm.asm, enc_asm.asm: Optimized by using direct immediate PUSHes. 1999-10-15 Andrew Belov * environ.c: Fixed time stamping on active streams. 1999-10-10 Andrew Belov * environ.c: Fixed read_line() to return value under OS/2. * arj_arcv.c: Fixed "ARJ x -d" bug with skipped files. 1999-10-06 Andrew Belov * environ.h: Fixed missing prototype for farcoreleft(). 1999-10-03 Andrew Belov * environ.c: Fixed w95_cwd(). 1999-10-02 Andrew Belov * environ.c: Fixed get_exe_name() under DOS v 2.11/MS C. * arj_arcv.c: Fixed long filename storage under Windows 95. 1999-10-01 Andrew Belov * make_cmt.c: Created. 1999-09-28 Andrew Belov * recovery.c: Fixed negative percentage bug. * garble.c: Finally fixed DS restore. * environ.c: Fixed Windows 95 detection under MS C/C++. * arj_user.c: Fixed empty archive not being deleted. Moved DTA/DTC output in front of EAs in "ARJ V". 1999-09-27 Andrew Belov * environ.c: Fixed read_line() in xterm (XFree86 for OS/2). 1999-09-26 Andrew Belov * makefile: Now runs arjc_ to create packages. * environ.c: Changed delay() routine DOS branch. Fixed get_env_str() to work under OS/2 v 2.x. 1999-09-24 Andrew Belov * arj_user.c: Fixed problem with duplicate files appearing. List command now skips garbled EAs w/o -g. 1999-09-23 Andrew Belov * arj_arcv.c: Fixed EAs being lost when main header is read. Fixed volume flag fix (see 15/09) side-effect. * arj_arcv.c: Fixed "shadow" EAs appearing with -2e. 1999-09-22 Andrew Belov * arj_arcv.c, arj_user.c, recovery.c: ** Updated to ARJ v 3.02 code level **. 1999-09-21 Andrew Belov * recovery.c: Fixed stream/section issue for large files. * arj_user.c: Fixed memory leak with ARJ-SECURITY signatures. 1999-09-19 Andrew Belov * arj_user.c: Fixed multivolume handling of non-ARJ files. Fixed volume handling of "hollow" archives. * arj_file.c: Added check for files larger than MAX_FILE_SIZE. 1999-09-18 Andrew Belov * arj_arcv.c: Added check for encryption when building SFX. Fixed chapter mark creation with EAs enabled. 1999-09-16 Andrew Belov * today.c: Changed date format for English/American locale. 1999-09-15 Andrew Belov * arj_arcv.c: Fixed open_input_file() to ignore errors w/-hq. Fixed volume flag being reset by init_packing(). 1999-09-14 Andrew Belov * rearj.c: Fixed "invalid suffix" error when /T is used. Fixed problem with "/A" being inoperable. * makefile: Changed optimization options for MS C v 6.00. * filelist.c: Fixed subdirectory retrieval in REARJ branch. * arj_user.c: Fixed file number display in ARJSFXV -v. 1999-09-12 Andrew Belov * environ.c: Fixed directory time stamping under OS/2. * arj_user.c: Added EA display to list command. * arj_arcv.c: Fixed subdirectories being trashed in ARJSFXV. 1999-09-11 Andrew Belov * environ.c: Fixed EXE name retrieval under OS/2. 1999-09-07 Andrew Belov * ea_mgr.c, ea_mgr.h: Created. * arj_asm.h: Removed (superseded by *.H). * arj_asm.asm: Removed (superseded by *.ASM). 1999-09-05 Andrew Belov * arj_user.c: ** Updated to ARJ v 2.62d code level **. 1999-09-04 Andrew Belov * arj_arcv.c: Fixed header search stub in ARJSFX. * arjsfx.c: Fixed M_UNREG_SFX popping after help screen. 1999-09-02 Andrew Belov * arj.c: Fixed explicit target directory parsing. 1999-08-30 Andrew Belov * date_sig.h, filemode.h, today.c: Created. * makefile: Added locale-dependent timestamp production. * filemode.c: Created. 1999-08-29 Andrew Belov * arj_user.c: Fixed comment creation/display conditions. 1999-08-28 Andrew Belov * arj_file.c: Fixed filename display when rename fails. 1999-08-27 Andrew Belov * msgbind.c: Added shareware/commercial binding selection. 1999-08-26 Andrew Belov * scrnio.c: Fixed CT_NATIVE version of clreol(). * makefile: Added separate MSG include file directories. * arj_user.c: Fixed DTA/DTC output in the list command. OS/2 SFXVs are no longer limited to 360K. * arj_proc.c: Fixed response command detection. * arj_arcv.c: Shareware SFXV limit has been removed for OS/2. * arj.c: On LFN-capable systems, extension is now ".arj". * ansi.c: Fixed cursor movement with C and D commands. 1999-08-25 Andrew Belov * arj_user.c: Caching can now be disabled. * arj.c: Added dynamic environment variable allocation. 1999-08-24 Andrew Belov * arjcrypt.c, environ.c, register.c, scrnio.c: Ported to OS/2. * msgbind.c: Added multiple OS capability. 1999-08-21 Andrew Belov * scrnio.c, scrnio.h: Created. * reg_stmp.h: The registration block now appears in DOS only. * misc.c: Fixed archive bit checking in match_attrib(). Replaced far_* routines with RTL ones for MS C. * environ.c: Added far heap amount query routine for MS C. Fixed shared open under OS/2 with MS C RTL. * arj_user.c: Fixed archived files deletion. Fixed full filename display in list_cmd(). * arj_file.c: Fixed delete_files(). Fixed delete_processed_files(). * arj_arcv.c: Fixed -f option operation on extraction. Fixed skipped files being treated as errors. * arjsec_l.c: Now refuses to create envelope in unreg. ARJ. * arjdisp.c: Portabilized. * ansi.c: Moved compiler-dependent code to SCRNIO.C. 1999-08-20 Andrew Belov * misc.c: Fixed pathname matching in flist_find(). * makefile: Added debugging facilities. * filelist.c: Fixed filelist initialization. * fardata.h: Debugging macros have been added. * debug.c, debug.h: Created. * arj_user.c: Fixed multivolume command launch conditions. * arj_proc.c: Fixed -ji switch parsing. * arj_arcv.c: Fixed filename formatting in index files. Fixed filename output in copy_archive(). 1999-08-19 Andrew Belov * crc32.asm, crc32_32.asm: Added reverse CRC32 calculation. * arjsec_l.c: Added commercial security envelope creation. 1999-08-18 Andrew Belov * rearj.c: Log entry formats moved to resource file. Ported to Microsoft C. * misc.c: Fixed match_attrib(). * makefile: Introduced Microsoft C/C++ v 6.00 compiler. Introduced Microsoft QuickC v 2.50 compiler. * enc_asm.asm: Introduced Microsoft C/Quick C compatibility. * crc32_32.asm: Created from CRC32.ASM. * arj_user.c: Fixed -n option corrupting the archive. Messages have been moved to FMSG area. * arj_arcv.c: Fixed error count display in archive_cleanup(). Fixed return code in unpack_validation(). 1999-08-17 Andrew Belov * gost_t.c, gost_t.h: Created. * gost.c: Pattern data has been moved to GOST_T.C. * fmemcmp.asm: Fixed register loading. * arj_user.c: Fixed archive cleanup before testing with -jt. Fixed M_VERBOSE_FOOTER being output twice. * arj_file.c: Removed redundant check from compare_fblock(). * arj.c: Fixed M_BAD_SYNTAX error upon chapter removal. 1999-08-16 Andrew Belov * makefile: Introduced standard option for far data storage. * garble.c: Fix for Microsoft C: SS is restored from DGROUP. * environ.c: Fixed directory creation. Fixed looping on "batch" error handler. * encode.c: Added plain bufsiz decrease method. * decode.c: Fixed decoded data output in decode_f(). * arj_user.c: Fixed verbose list display in ARJSFX archives. 1999-08-15 Andrew Belov * makefile: Introduced macros for target EXE names. Introduced Microsoft C/C++ v 7.00 compiler. * ansi.c: Ported to Microsoft C. 1999-08-14 Andrew Belov * environ.c: Fixed case mapping routine. 1999-08-13 Andrew Belov * makefile: Added package/send build rule. * arj_file.c: Fixed high-ASCII characters display in help. * arjdisp.c: ** ARJDISP v 1.00 functionality achieved **. * arj.c: Fixed registration data validation. 1999-08-12 Andrew Belov * arjdisp.c, register.h, reg_stmp.h: Created. * register.c: Created. * makefile: Added ARJ$DISP build rules. Added REGISTER build rules. * fardata.c: ** Added a ARJ$DISP v 1.00 branch **. ** Added a REGISTER v 2.60 branch **. * arj_proc.c: ** Added an ARJ$DISP v 1.00 branch **. * arj.c: Fixed inability to register ARJ.EXE. 1999-08-11 Andrew Belov * rearj.c: ** REARJ v 2.28 functionality achieved **. * filelist.c: Fixed filename retrieval in REARJ branch. 1999-08-10 Andrew Belov * arj_proc.c: ** Added a REARJ v 2.28 branch **. 1999-08-09 Andrew Belov * makefile: Added REARJ build rules. * filelist.c: ** Added a REARJ v 2.28 branch **. * environ.c: Fixed w95_findfirst()/w95_findnext(). Removed lfn_test_spec[]. * environ.c: Fixed LFN detection under Windows 95. * arj_arcv.c: Fixed garble operation in special_processing(). 1999-08-08 Andrew Belov * rearj.c: Created. * arj_file.c, fardata.c: ** Added a REARJ v 2.28 branch **. 1999-08-07 Andrew Belov * postproc.c: Added ARJSFX postprocessing. * misc.c: Fixed near_stricmp(). * arj_file.c: Fixed loop bug in file_open_noarch(). * arjsfxjr.c: ** ARJSFXJR v 2.62c functionality achieved **. Fixed cache pointer loss problem. * arjsfx.c: Fixed missing EXE name in ARJSFX banner. 1999-08-06 Andrew Belov * makefile: Added ARJSFXJR build rules. * decode.c: Removed setjmp()/longjmp() from SFX bindings. 1999-08-05 Andrew Belov * makefile: Introduced ASM_DEFS include file. * asm_incl.inc: Now loads ASM_DEFS.INC for defines. * arjsfxjr.c: Created. 1999-08-04 Andrew Belov * makefile: Added ARJSFX build rules. Fixed source file list for ARJSFXV. * garble.c: Fixed DS restore when exiting from ARJCRYPT. * arj_arcv.c, arj_user.c, exe_sear.c: ** Added an ARJSFX v 2.62 branch **. * environ.h: Added VBUF/TBUF constants. * crc32.asm: Defining NC_CRC will disable crc32_for_char. * chk_fmsg.c: Reduced stack memory allocation in SFX. * arjsfx.c, arj_file.c: ** Added an ARJSFX v 2.62 branch **. 1999-08-03 Andrew Belov * garble.c: ** Added an ARJSFX v 2.62 branch **. 1999-08-02 Andrew Belov * environ.c, fardata.c, misc.c: ** Added an ARJSFX v 2.62 branch **. * externs.c: AUTOINIT concept introduced. * environ.c: Implemented recall feature in read_line(). Used lfn_test_spec[] for LFN testing. * environ.c: Fixed read-only file deletion in ARJSFXV. * decode.c: ** Added an ARJSFX v 2.62 branch **. 1999-08-01 Andrew Belov * makefile: Introduced C_DEFS include file. 1999-07-31 Andrew Belov * makefile: Added a set of assembly options. Added separate shareware/retail subdivisions. 1999-07-30 Andrew Belov * msgbind.c: Removed check for MSGTEXT_MAX to allow long SFX help messages. 1999-07-29 Andrew Belov * sfx_id.asm: Created. * makefile: Added ARJSFXV build rules. * dec_asm.asm: Method 4 disable macro renamed to ARJSFX. * arj_user.c: ** Added an ARJSFXV v 2.62 branch **. 1999-07-28 Andrew Belov * arj_user.c: Fixed query_action parameter types. * arj_proc.c: ** Added an ARJSFXV v 2.62 branch **. 1999-07-23 Andrew Belov * arj_file.c, exe_sear.c: ** Added an ARJSFXV v 2.62 branch **. 1999-07-18 Andrew Belov * arj_arcv.c: ** Added an ARJSFXV v 2.62 branch **. 1999-07-13 Andrew Belov * decode.c: DICSIZ allocation fixed. 1999-07-12 Andrew Belov * arj_user.c: Changed arg. type of arj_user_msg() to FMSG. * arj_file.c: Changed arg. type of scroll_puts() to FMSG *. 1999-07-08 Andrew Belov * decode.c, misc.c: ** Added an ARJSFXV v 2.62 branch **. * arj_arcv.c: Fixed "Bad header" error for header size==2600. Fixed ARJ$DISP invocation. 1999-07-07 Andrew Belov * garble.c: Fixed potential problem with not-standard. * filelist.c, garble.c: ** Added an ARJSFXV v 2.62 branch **. * chk_fmsg.c: ** Added an ARJSFXV v 2.62 branch **. 1999-07-05 Andrew Belov * misc.c: Added some general-purpose SFX routines. * arjsec_l.c, fardata.c: ** Added an ARJSFXV v 2.62 branch **. * arjsfx.h: Created. * arjsec_h.c: ** Added an ARJSFXV v 2.62 branch **. 1999-07-04 Andrew Belov * arjsfx.c, bindings.h, types.h: Created. * fardata.h: Macros for msg_* have been added. * environ.c: ** Added an ARJSFXV v 2.62 branch **. Added get_exe_name(). * arjtypes.h: Created. 1999-07-03 Andrew Belov * msgbind.c: Added support for external files ("@" clause). * makefile: Changed build rules for ARJ overlay linkage. Fixed dependencies for garble.c. * arj_xms.asm, asm_incl.inc, file_crc.c: Created. * filelist.c: Fixed storage method selection in hash_init(). Moved a part of XMS code to ARJ_XMS.ASM. * enc_asm.asm: Optimized make_tree by using SHR. * crc32.asm: Fixed stack frame setup in crc32_for_char. * arj_xms.h: Created. * arj_proc.c: Fixed name formation in append_curtime_proc(). Fixed sw_tail presence recognition. * arj_proc.c: Fixed '.' lookup in append_curtime_proc(). 1999-07-02 Andrew Belov * det_x86.h, gost.h, gost_asm.h: Created. * det_x86.asm, gost_asm.asm: Recompiled. * gost40.c: Moved a part of code to GOST.C/GOST.H. * gost.c: ** ARJ v 2.62c functionality achieved **. Created. * garble.c: Fixed DS being destroyed by ARJCRYPT. Fixed password modifiers type (must be signed). * arjcrypt.h: Added cipher/decipher constants. * arjcrypt.c: ** ARJ v 2.60 functionality achieved **. 1999-07-01 Andrew Belov * makefile: Added ARJCRYPT definition and build rules. * gost40.c: Fixed back_code update on encryption. Fixed stack pollution on initialization. * exe_sear.c, garble.c: Removed DOS version dependence. * garble.c: Fixed ARJCRYPT entry point calculation. Fixed ARJCRYPT module location procedure. * exe_sear.c: Fixed exit condition in browse(). Fixed fseek() origin in fetch_block(). * environ.c: Fixed file_setftime(). * arj_user.c: Fixed chapter conversion conditions. Fixed comment display conditions. * arj_arcv.c: Added missing LF before query_for_rename(). Fixed file deletion logic in chapter archives. * arjcrypt.c: Created. * arj.c: Fixed conditional exclusion filelist cleanup. 1999-06-30 Andrew Belov * misc.c: Used strncmp_os() in filename comparisons. * enc_asm.asm: Fixed near/far issues in procedures. Transferred most of C code to this module. * decode.c: Fixed count underflow condition in decode() (since now, file size is limited to 2G bytes). * arj_user.c: Added missing LF to chapter_list_fmt. * arj_file.c: Fixed EOF sequence output in shutdown_putbits(). * arj_arcv.c: Fixed CRC error display conditions. Fixed loop condition in special_processing(). Fixed rewind when falling back to method 0. * arj_arcv.c: Fixed errors related to chapter processing. * arj.c: Fixed chapter command conversion. 1999-06-29 Andrew Belov * misc.c: Fixed return type of farrealloc_msg(). * filelist.c: Swap file could not be created, fixed. * encode.c: Fixed near/far function mismatches. * arj_file.c: smft_start_numgraph contained invalid string. * arj_arcv.c: Fixed uncompsize decrease in pack_file(). 1999-06-28 Andrew Belov * filelist.c: Fixed resize conditions in add_entry(). retrieve_entry() returned garbage, fixed. * filelist.c: Fixed properties pointer abuse in add_entry(). * environ.c: Fixed directory recursion in wild_list(). * arj_user.c: aostream was unopened due to invalid condition. Fixed unexpected comment prompt. 1999-06-27 Andrew Belov * misc.c: Fixed write/increment order in to_7bit(). * makefile: Added preparation section. * environ.c: Fixed incorrect condition in is_file(). * decode.c: Fixed counter incrementation in decode_f(). Fixed stack loss due to unprototyped decode_p(). * decode.c: extraction_stub() was not called for last block. * arj_user.c: Fixed error counter incrementation. Fixed misuse of ARJ_CMD_EXTRACT. * arj_proc.c: Fixed size decrement order in unstore(). Fixed the is_switch() identification logic. * arj_proc.c: Fixed reply type in search_setup(). * arj_file.c: display_indicator() arg type is long since now. Fixed display_found_text(). * arj_arcv.c: Fixed header creation order. Fixed M_CRC_ERROR on extraction. 1999-06-26 Andrew Belov * dec_asm.asm: CX/DX were discarded by _fgetc(). Now fixed. Fixed offset calculation for left[]/right[]. 1999-06-25 Andrew Belov * dec_asm.asm: Fixed decode_p(). 1999-06-24 Andrew Belov * msgbind.c: CCHMAXPATH -> FILENAME_MAX. Destination files can now be placed into separate directories. * misc.c: Fixed buffer overrun in to_7bit(). * makefile: Now using separate directories for NLS. * externs.c: Fixed total_files type (must be int). * arj_user.c: Fixed chapter flag display in list_cmd(). Removed errorneous strform references. * arj_proc.c: Fixed processing logic in format_filename(). * arj_file.c: Fixed space display in display_comment(). Fixed word order in fget_longword(). * arj_arcv.c: Fixed archive name display. * arj.c: Fixed cnv_cmd() initialization in cmd_setup(). 1999-06-23 Andrew Belov * misc.c: Fixed return type of farmalloc_msg(). * join.c: Now the EXE name is a user-defined parameter. * environ.c: Fixed CY flag setup in call_dos_int(). Fixed directory comparison in wild_list(). 1999-06-22 Andrew Belov * arj_user.c: ** ARJ v 2.62c functionality achieved **. 1999-06-20 Andrew Belov * misc.c: Fixed matching criteria in match_attrib. 1999-06-17 Andrew Belov * integr.asm, postproc.c: Created. * makefile: Added a data module for integrity check. * arj_proc.c: ** ARJ v 2.62c functionality achieved **. 1999-06-14 Andrew Belov * externs.c, externs.h: Sorted to ARJ v 2.62c order. 1999-06-13 Andrew Belov * exe_sear.c, exe_sear.h: Created. * arj_arcv.c, exe_sear.c: ** ARJ v 2.62c functionality achieved **. 1999-06-11 Andrew Belov * arj_proc.c: Pack/Unpack stubs added, used strcmp_os. * arj_arcv.c: Used strcmp_os() wherever it was needed. 1999-05-29 Andrew Belov * fardata.c: Fixed error code display. 1999-05-25 Andrew Belov * arj_file.c: ** ARJ v 2.62c functionality achieved **. 1999-05-24 Andrew Belov * enc_gwy.c, enc_gwy.h: Created. * decode.c, encode.c: ** ARJ v 2.62c functionality achieved **. 1999-05-23 Andrew Belov * recovery.h: Added RECOVERY_THRESHOLD definition. 1999-05-16 Andrew Belov * arj_file.c: Fixed formatting in scroll_puts(). 1999-05-11 Andrew Belov * enc_asm.asm: Created from disassembly. 1999-05-09 Andrew Belov * arj_asm.h, fmemcmp.asm, fmemcmp.h: Created. * arj_file.h: Completed the block_op() tree. 1999-04-24 Andrew Belov * environ.h: Created lreg() macro to make fastcall calls. * dec_asm.asm: Created from disassembly. * crc32.asm: Fixed memory model issues. 1999-04-23 Andrew Belov * makefile: Added stack frame optimization to NEAR_COPT. 1999-04-22 Andrew Belov * makefile: Fixed CHK_FMSG.* dependencies. * decode.c, decode.h: Created. 1999-04-21 Andrew Belov * arj.h: Prototype section added (that may be unwise). 1999-04-20 Andrew Belov * msgbind.c: CRC-32 is now fully implemented. * makefile: Made separate compile paths, made response file. * chk_fmsg.c, encode.c, encode.h: Created. * chk_fmsg.h: Created. * chk_fmsg.c: ** ARJ v 2.62c functionality achieved **. 1999-04-18 Andrew Belov * crc32.h: Moved crc32 variables definition to this file. * arjsec_l.c: ** ARJ v 2.62c functionality achieved **. * arjsec_h.c, arjsec_h.h: Created. * arjsec_h.c: ** ARJ v 2.62 functionality achieved **. 1999-04-16 Andrew Belov * recovery.c: Fixed various problems in recovery procedure. * arjsec_l.c, arjsec_l.h: Created. 1999-04-11 Andrew Belov * recovery.c: ** ARJ v 2.62c functionality achieved **. * environ.c: Fixed file_open(). * crc32.asm: Removed alignment dependency. * arj_file.h: Added file_write() macro. * arj_file.c: Fixed file_create(). 1999-04-10 Andrew Belov * crc16tab.h, recovery.c, recovery.h: Created. * makefile: Fixed far data segment override options. 1999-04-09 Andrew Belov * makefile: Fixed resource rebuild logic. * gost40.c: Fixed parameter naming in stubs. * arjcrypt.h: Created. 1999-04-08 Andrew Belov * garble.c, garble.h: Created. 1999-04-07 Andrew Belov * gost40.c: ** ARJ v 2.62c functionality achieved **. 1999-04-03 Andrew Belov * gost40.c, gost40.h: Created. 1999-03-28 Andrew Belov * misc.c: Fixed various errors in far_*. * makefile: Optimized TC++/BC++ compile options. * fardata.c: Fixed memory leak in error(). * environ.c: Fixed handle leak in file_open(). 1999-03-27 Andrew Belov * makefile: Fixed link file cleanup & resource build rules. 1999-03-24 Andrew Belov * environ.h: Added strcmp_os() macro. * environ.c: Added definition of dev_null (as null device). 1999-03-23 Andrew Belov * arj_file.c: fput_* procedures fixed. * arj_arcv.c: Header parsing and storage routines added. 1999-03-21 Andrew Belov * msgbind.c: A bracketed "*" now represents "all" wildcard. * misc.c: ** Updated to ARJ v 2.62c code level **. * environ.h: import_timestamp() replaces older stub. * environ.c: import_timestamp() fixed to be OS-independent. * arj_user.c: Changed "WINNT" to "WIN32" as in ARJ v 2.62c. 1999-03-19 Andrew Belov * arj_file.c, arj_proc.c: ** Updated to ARJ v 2.62c code level **. 1999-03-14 Andrew Belov * environ.c, fardata.c: ** Updated to ARJ v 2.62c code level **. * arj.h: Fixed to compile with Turbo C++ v 1.0. 1999-03-12 Andrew Belov * externs.c: Basic header structures declared. * environ.c: Implemented fileno() calls instead of ->fd. * arj_arcv.c: Renamed find_hdr() to find_header(). 1999-03-11 Andrew Belov * arj_user.c: form_prot_name() added. 1999-03-10 Andrew Belov * environ.c: Moved friendly OS list to this module. * arj_user.c, arj_user.h: Created. 1999-03-06 Andrew Belov * arj_arcv.c, arj_arcv.h: Created. 1999-03-05 Andrew Belov * ansi.h: ANSI sequence ids added. * ansi.c: ^[[m misinterpreted foreground color codes. 1999-02-24 Andrew Belov * ansi.c: ** ARJ v 2.62 functionality achieved **. 1999-02-21 Andrew Belov * ansi.c, ansi.h: Created. 1999-02-20 Andrew Belov * environ.c, misc.c: ** ARJ v 2.62 functionality achieved **. * environ.h: CCHMAXPATHCOMP introduced. 1999-02-17 Andrew Belov * misc.c: Basic filelist management routines added. * filelist.c: ** ARJ v 2.62c functionality achieved **. 1999-02-16 Andrew Belov * misc.c: farmalloc_msg now accepts ulong parameters. 1999-02-13 Andrew Belov * filelist.c: Hash search/retrieval operations completed. 1999-02-03 Andrew Belov * filelist.c: XMS operations completed. * environ.c: Portabilized some equates. 1999-02-01 Andrew Belov * filelist.c, filelist.h: Created. * environ.c: Added create_subdir_tree. * arj_file.c: Query routine completed. 1999-01-30 Andrew Belov * fardata.c: ** ARJ v 2.62 functionality achieved **. * environ.h: Console settings. 1999-01-29 Andrew Belov * arj_file.c, arj_file.h: Created. 1999-01-28 Andrew Belov * msgbind.c: Added NULL pool identifier to produce "orphan" messages. * environ.c: Fixed find_delimiter. * arj_proc.c, arj_proc.h: Created. 1999-01-27 Andrew Belov * win95dos.h: W95_RESETDRIVE equates. * misc.c: More string routines added. * environ.c: Most of error handlers, all file_* + parser. 1999-01-26 Andrew Belov * makefile: Introduced Borland C++ v 3.x compiler. * defines.h: MSGP definitions added. * arj.c, crc32.h: Created. * crc32.asm: Recompiled. 1999-01-25 Andrew Belov * fardata.h, msgbind.c: Created. * misc.c: unix_to_dos, malloc_str .... INCOMPLETE!. 1999-01-24 Andrew Belov * environ.h: CR and LF definitions. * environ.c: Incorporated fdate/ftime in structures. 1999-01-23 Andrew Belov * win95dos.h: Incorporated ftime and fdate in W95_FFBLK. * defines.h, externs.h, misc.c, misc.h: Created. * arj.h, externs.c, fardata.c: Created. * environ.c: Added non-local API. 1999-01-21 Andrew Belov * makefile, win95dos.h: Created. * environ.h: Created. * environ.c: Added W95 LFN API. 1999-01-19 Andrew Belov * environ.c: Created. 1999-01-03 Andrew Belov * join.c: Created. arj-3.10.22/chk_fmsg.c 666 0 0 2146 7620765374 10575 0ustar /* * $Id: chk_fmsg.c,v 1.2 2003/02/07 17:21:01 andrew_belov Exp $ * --------------------------------------------------------------------------- * The purpose of this module is to check the integrity of the message section * by comparing its CRC-32 with the stored value. * */ #include "arj.h" DEBUGHDR(__FILE__) /* Debug information block */ /* Checks the integrity of FMSG section. Reports CRC error in case of CRC mismatch. */ void check_fmsg(int skip_check) { FMSGP *index_ptr; #if SFX_LEVEL>=ARJ char fmsg_buf[MSGTEXT_MAX]; #endif crc32term=CRC_MASK; #if SFX_LEVEL>=ARJ if(skip_check!=CHKMSG_SKIP) #else if(skip_check==CHKMSG_SKIP) #endif { for(index_ptr=FARMSGS; *index_ptr!=NULL; index_ptr++) { #ifdef FMSG_ST far_strcpyn((char FAR *)fmsg_buf, (char FAR *)*index_ptr, sizeof(fmsg_buf)); crc32_for_string(fmsg_buf); #else crc32_for_string(*index_ptr); #endif } if(crc32term!=FARMSGS_CRC32) error(M_CRC_ERROR); } #if SFX_LEVEL<=ARJSFXV else { msg_cprintf(0, strform, M_SFX_USAGE); msg_cprintf(0, strform, M_SFX_COMMANDS); } #endif } arj-3.10.22/chk_fmsg.h 666 0 0 527 7450456602 10553 0ustar /* * $Id: chk_fmsg.h,v 1.1.1.1 2002/03/28 00:02:10 andrew_belov Exp $ * --------------------------------------------------------------------------- * Prototypes of the functions located in CHK_FMSG.C are declared here. * */ #ifndef CHK_FMSG_INCLUDED #define CHK_FMSG_INCLUDED /* Prototypes */ void check_fmsg(int skip_check); #endif arj-3.10.22/crc16tab.c 666 0 0 4755 7450456602 10421 0ustar /* * $Id: crc16tab.c,v 1.1.1.1 2002/03/28 00:02:10 andrew_belov Exp $ * --------------------------------------------------------------------------- * A table for calculating CRC-16 is located here (referenced from RECOVERY.C) * */ unsigned short crc16tab[256]= {0x0000, 0x1021, 0x2042, 0x3063, 0x4084, 0x50A5, 0x60C6, 0x70E7, 0x8108, 0x9129, 0xA14A, 0xB16B, 0xC18C, 0xD1AD, 0xE1CE, 0xF1EF, 0x1231, 0x0210, 0x3273, 0x2252, 0x52B5, 0x4294, 0x72F7, 0x62D6, 0x9339, 0x8318, 0xB37B, 0xA35A, 0xD3BD, 0xC39C, 0xF3FF, 0xE3DE, 0x2462, 0x3443, 0x0420, 0x1401, 0x64E6, 0x74C7, 0x44A4, 0x5485, 0xA56A, 0xB54B, 0x8528, 0x9509, 0xE5EE, 0xF5CF, 0xC5AC, 0xD58D, 0x3653, 0x2672, 0x1611, 0x0630, 0x76D7, 0x66F6, 0x5695, 0x46B4, 0xB75B, 0xA77A, 0x9719, 0x8738, 0xF7DF, 0xE7FE, 0xD79D, 0xC7BC, 0x48C4, 0x58E5, 0x6886, 0x78A7, 0x0840, 0x1861, 0x2802, 0x3823, 0xC9CC, 0xD9ED, 0xE98E, 0xF9AF, 0x8948, 0x9969, 0xA90A, 0xB92B, 0x5AF5, 0x4AD4, 0x7AB7, 0x6A96, 0x1A71, 0x0A50, 0x3A33, 0x2A12, 0xDBFD, 0xCBDC, 0xFBBF, 0xEB9E, 0x9B79, 0x8B58, 0xBB3B, 0xAB1A, 0x6CA6, 0x7C87, 0x4CE4, 0x5CC5, 0x2C22, 0x3C03, 0x0C60, 0x1C41, 0xEDAE, 0xFD8F, 0xCDEC, 0xDDCD, 0xAD2A, 0xBD0B, 0x8D68, 0x9D49, 0x7E97, 0x6EB6, 0x5ED5, 0x4EF4, 0x3E13, 0x2E32, 0x1E51, 0x0E70, 0xFF9F, 0xEFBE, 0xDFDD, 0xCFFC, 0xBF1B, 0xAF3A, 0x9F59, 0x8F78, 0x9188, 0x81A9, 0xB1CA, 0xA1EB, 0xD10C, 0xC12D, 0xF14E, 0xE16F, 0x1080, 0x00A1, 0x30C2, 0x20E3, 0x5004, 0x4025, 0x7046, 0x6067, 0x83B9, 0x9398, 0xA3FB, 0xB3DA, 0xC33D, 0xD31C, 0xE37F, 0xF35E, 0x02B1, 0x1290, 0x22F3, 0x32D2, 0x4235, 0x5214, 0x6277, 0x7256, 0xB5EA, 0xA5CB, 0x95A8, 0x8589, 0xF56E, 0xE54F, 0xD52C, 0xC50D, 0x34E2, 0x24C3, 0x14A0, 0x0481, 0x7466, 0x6447, 0x5424, 0x4405, 0xA7DB, 0xB7FA, 0x8799, 0x97B8, 0xE75F, 0xF77E, 0xC71D, 0xD73C, 0x26D3, 0x36F2, 0x0691, 0x16B0, 0x6657, 0x7676, 0x4615, 0x5634, 0xD94C, 0xC96D, 0xF90E, 0xE92F, 0x99C8, 0x89E9, 0xB98A, 0xA9AB, 0x5844, 0x4865, 0x7806, 0x6827, 0x18C0, 0x08E1, 0x3882, 0x28A3, 0xCB7D, 0xDB5C, 0xEB3F, 0xFB1E, 0x8BF9, 0x9BD8, 0xABBB, 0xBB9A, 0x4A75, 0x5A54, 0x6A37, 0x7A16, 0x0AF1, 0x1AD0, 0x2AB3, 0x3A92, 0xFD2E, 0xED0F, 0xDD6C, 0xCD4D, 0xBDAA, 0xAD8B, 0x9DE8, 0x8DC9, 0x7C26, 0x6C07, 0x5C64, 0x4C45, 0x3CA2, 0x2C83, 0x1CE0, 0x0CC1, 0xEF1F, 0xFF3E, 0xCF5D, 0xDF7C, 0xAF9B, 0xBFBA, 0x8FD9, 0x9FF8, 0x6E17, 0x7E36, 0x4E55, 0x5E74, 0x2E93, 0x3EB2, 0x0ED1, 0x1EF0}; arj-3.10.22/crc16tab.h 666 0 0 523 7450456602 10373 0ustar /* * $Id: crc16tab.h,v 1.1.1.1 2002/03/28 00:02:10 andrew_belov Exp $ * --------------------------------------------------------------------------- * The CRC-16 table from CRC16TAB.C is declared here. * */ #ifndef CRC16TAB_INCLUDED #define CRC16TAB_INCLUDED /* The CRC-16 table */ extern unsigned short FAR crc16tab[256]; #endif arj-3.10.22/crc32.c 666 0 0 16251 7450456602 7742 0ustar /* * $Id: crc32.c,v 1.1.1.1 2002/03/28 00:02:10 andrew_belov Exp $ * --------------------------------------------------------------------------- * This file contains CRC32 calculation routines. * */ #include "arj.h" DEBUGHDR(__FILE__) /* Debug information block */ #define CRCPOLY 0xEDB88320L /* CRC32 polynomial */ #define UPDATE_CRC(r, c) crc32tab[((unsigned char)(r)^(unsigned char)(c))&0xFF]^(r>>CHAR_BIT) unsigned long crc32term; #ifdef ASM8086 unsigned short crc32tab_lo[256]; unsigned short crc32tab_hi[256]; static unsigned short xbp; #else unsigned long crc32tab[256]; #endif /* CRC32 initialization */ void build_crc32_table() { #ifdef ASM8086 asm{ push si push di xor di, di jmp short lt_0 } loop_ch: asm{ mov dx, di xor ax, ax mov si, 8 or si, si jmp short lt_1 } loop_term: asm{ test dx, 1 jz lt_next shr ax, 1 rcr dx, 1 xor dx, 8320h xor ax, 0EDB8h jmp short lt_next_c } lt_next: asm{ shr ax, 1 rcr dx, 1 } lt_next_c: asm{ dec si } lt_1: asm{ jg loop_term mov bx, di shl bx, 1 mov word ptr crc32tab_lo[bx], dx mov word ptr crc32tab_hi[bx], ax inc di } lt_0: asm{ cmp di, 0FFh jbe loop_ch pop di pop si } #else unsigned int i, j; unsigned long r; for(i=0; i<=UCHAR_MAX; i++) { r=i; for(j=CHAR_BIT; j>0; j--) { if(r&1) r=(r>>1)^CRCPOLY; else r>>=1; } crc32tab[i]=r; } #endif } /* Calculates CRC32 for a given block */ void crc32_for_block(char *block, unsigned int b_size) { #ifdef ASM8086 asm{ push si push di cld mov word ptr xbp, bp mov bx, offset crc32tab_lo mov cl, 4 shr bx, cl mov cx, word ptr crc32term[0] mov dx, word ptr crc32term[2] mov si, block mov di, b_size push ds mov ax, ds mov es, ax add ax, bx xor bx, bx mov bp, di and di, 3 push di shr bp, 1 shr bp, 1 jz lt_shloop } lt_accterm: #if COMPILER==BCC asm{ db 26h, 0ADh } #else asm{ lods word ptr es:[si] } #endif asm{ mov bl, cl xor bl, al mov cl, ch mov ch, dl mov dl, dh mov dh, bh mov di, bx shl di, 1 xor cx, crc32tab_lo[di] xor dx, crc32tab_hi[di] mov bl, cl xor bl, ah mov cl, ch mov ch, dl mov dl, dh mov dh, bh mov di, bx shl di, 1 xor cx, crc32tab_lo[di] xor dx, crc32tab_hi[di] } #if COMPILER==BCC asm{ db 26h, 0ADh } #else asm{ lods word ptr es:[si] } #endif asm{ mov bl, cl xor bl, al mov cl, ch mov ch, dl mov dl, dh mov dh, bh mov di, bx shl di, 1 xor cx, crc32tab_lo[di] xor dx, crc32tab_hi[di] mov bl, cl xor bl, ah mov cl, ch mov ch, dl mov dl, dh mov dh, bh mov di, bx shl di, 1 xor cx, crc32tab_lo[di] xor dx, crc32tab_hi[di] dec bp jnz lt_accterm } lt_shloop: asm{ pop bp or bp, bp jz lt_exit } lt_shift: #if COMPILER==BCC asm{ db 26h, 0ACh } #else asm{ lods byte ptr es:[si] } #endif asm{ mov bl, cl xor bl, al mov cl, ch mov ch, dl mov dl, dh mov dh, bh mov di, bx shl di, 1 xor cx, crc32tab_lo[di] xor dx, crc32tab_hi[di] dec bp jnz lt_shift } lt_exit: asm{ pop ds mov word ptr crc32term[0], cx mov word ptr crc32term[2], dx pop di pop si mov bp, word ptr xbp } #else while(b_size--) crc32term=UPDATE_CRC(crc32term, *block++); #endif } #if SFX_LEVEL>=ARJSFX||defined(REARJ)||defined(REGISTER)||defined(ARJUTIL) /* Calculates CRC32 for a given ASCIIz string */ void crc32_for_string(char *sptr) { #ifdef ASM8086 asm{ push si push di cld xor bx, bx mov si, sptr mov cx, word ptr crc32term[0] mov dx, word ptr crc32term[2] jmp short str_nchar } stracc: asm{ mov bl, cl xor bl, al mov cl, ch mov ch, dl mov dl, dh mov dh, bh mov di, bx shl di, 1 xor cx, word ptr crc32tab_lo[di] xor dx, word ptr crc32tab_hi[di] } str_nchar: asm{ lodsb or al, al jnz stracc mov word ptr crc32term[0], cx mov word ptr crc32term[2], dx pop di pop si } #else while(*sptr!='\0') crc32term=UPDATE_CRC(crc32term, (unsigned char)(*sptr++)); #endif } /* Evaluates CRC32 based on character and term given */ unsigned long crc32_for_char(unsigned long crc32_term, unsigned char newc) { #ifdef ASM8086 asm{ mov ax, word ptr crc32_term mov dx, word ptr crc32_term+2 mov bl, al mov al, ah mov ah, dl mov dl, dh mov dh, 0 xor bl, newc mov bh, 0 shl bx, 1 xor ax, word ptr crc32tab_lo[bx] xor dx, word ptr crc32tab_hi[bx] } #else return(UPDATE_CRC(crc32_term, newc)); #endif } #endif arj-3.10.22/crc32.h 666 0 0 2030 7450456602 7715 0ustar /* * $Id: crc32.h,v 1.1.1.1 2002/03/28 00:02:10 andrew_belov Exp $ * --------------------------------------------------------------------------- * Interface to the CRC32 module. * */ #ifndef CRC32_INCLUDED #define CRC32_INCLUDED /* The following are externals exported from assembly-language routines: */ extern unsigned long crc32term; #ifdef TILED extern unsigned short crc32tab_lo[256]; extern unsigned short crc32tab_hi[256]; #else extern unsigned long crc32tab[256]; #endif /* Platform-independent CRC macro */ #ifdef TILED #define get_crc32tab(i) ((((unsigned long)crc32tab_hi[i])<<16L)+(unsigned long)crc32tab_lo[i]) #else #define get_crc32tab(i) crc32tab[i] #endif /* Prototypes */ void build_crc32_table(); void crc32_for_block(char *block, unsigned int size); void crc32_for_string(char *str); unsigned long crc32_for_char(unsigned long crc32_term, unsigned char c); unsigned long rev_crc32_for_char(unsigned long crc32_term, unsigned char c); unsigned long afl_mul(unsigned long term, unsigned long multiplier); #endif arj-3.10.22/cset2/ 777 0 0 0 10256535570 7615 5ustar arj-3.10.22/cset2/arj.def 666 0 0 152 7450452546 11072 0ustar NAME ARJ/2 WINDOWCOMPAT LONGNAMES EXETYPE OS2 DESCRIPTION 'ARJ for OS/2' PROTMODE arj-3.10.22/cset2/arjcrypt.def 666 0 0 322 7450456720 12151 0ustar LIBRARY ARJCRYPT INITGLOBAL EXETYPE OS2 DESCRIPTION '32-bit GOST 28147-89 encryption plug-in for ARJ/2' PROTMODE DATA MULTIPLE CODE LOADONCALL EXPORTS entry @1 arj-3.10.22/cset2/arjdisp.def 666 0 0 160 7450456720 11747 0ustar NAME ARJDISP WINDOWCOMPAT LONGNAMES EXETYPE OS2 DESCRIPTION 'ARJDISP for OS/2' PROTMODE arj-3.10.22/cset2/arjsfx.def 666 0 0 156 7450452546 11617 0ustar NAME ARJSFX WINDOWCOMPAT LONGNAMES EXETYPE OS2 DESCRIPTION 'ARJSFX for OS/2' PROTMODE arj-3.10.22/cset2/arjsfxjr.def 666 0 0 162 7450452546 12150 0ustar NAME ARJSFXJR WINDOWCOMPAT LONGNAMES EXETYPE OS2 DESCRIPTION 'ARJSFXJR for OS/2' PROTMODE arj-3.10.22/cset2/arjsfxv.def 666 0 0 160 7450452546 12000 0ustar NAME ARJSFXV WINDOWCOMPAT LONGNAMES EXETYPE OS2 DESCRIPTION 'ARJSFXV for OS/2' PROTMODE arj-3.10.22/cset2/default.def 666 0 0 116 7450452546 11742 0ustar NAME DEFAULT WINDOWCOMPAT LONGNAMES EXETYPE OS2 PROTMODE arj-3.10.22/cset2/rearj.def 666 0 0 154 7450452546 11423 0ustar NAME REARJ WINDOWCOMPAT LONGNAMES EXETYPE OS2 DESCRIPTION 'REARJ for OS/2' PROTMODE arj-3.10.22/cset2/register.def 666 0 0 201 7450456720 12133 0ustar NAME REGISTER WINDOWCOMPAT LONGNAMES EXETYPE OS2 DESCRIPTION 'ARJ Registration Wizard for OS/2' PROTMODE arj-3.10.22/cset2/sfxstub.def 666 0 0 156 7450452546 12020 0ustar NAME SFXSTUB WINDOWCOMPAT LONGNAMES EXETYPE OS2 DESCRIPTION 'ARJ/2 SFX-STUB' PROTMODE arj-3.10.22/date_sig.h 666 0 0 454 7450456602 10550 0ustar /* * $Id: date_sig.h,v 1.1.1.1 2002/03/28 00:02:10 andrew_belov Exp $ * --------------------------------------------------------------------------- * This file declares references on data in DATE_SIG.C * */ #ifndef DATE_SIG_INCLUDED #define DATE_SIG_INCLUDED extern char build_date[]; #endif arj-3.10.22/debug.c 666 0 0 1050 7450456602 10063 0ustar /* * $Id: debug.c,v 1.1.1.1 2002/03/28 00:02:10 andrew_belov Exp $ * --------------------------------------------------------------------------- * Debug-related procedures are located here. In case of "clean" compile, this * file may be omitted. * */ #include #include "arj.h" DEBUGHDR(__FILE__) /* Debug information block */ /* Debug information report */ #ifdef DEBUG int debug_report(char *module, unsigned int line, char sign) { printf("\n*** [%c] %s:%u ***\n", sign, module, line); return(0); } #endif arj-3.10.22/debug.h 666 0 0 744 7450456602 10061 0ustar /* * $Id: debug.h,v 1.1.1.1 2002/03/28 00:02:10 andrew_belov Exp $ * --------------------------------------------------------------------------- * Prototypes of the functions located in DEBUG.C are declared here. * */ #ifndef DEBUG_INCLUDED #define DEBUG_INCLUDED /* Prototypes */ #ifdef DEBUG int debug_report(char *module, unsigned int line, char sign); #define debug_assert(f) if(!(f)) debug_report(dbg_cur_file, __LINE__, 'A') #else #define debug_assert(f) #endif #endif arj-3.10.22/decode.c 666 0 0 23712 7646035676 10264 0ustar /* * $Id: decode.c,v 1.3 2003/04/12 16:15:59 andrew_belov Exp $ * --------------------------------------------------------------------------- * The data decompression procedures are located in this module. * */ #include #include "arj.h" DEBUGHDR(__FILE__) /* Debug information block */ /* Delays for errors with garbled files */ #if SFX_LEVEL>=ARJ #define BADTABLE_G_DELAY 2 #else #define BADTABLE_G_DELAY 5 #endif /* Local variables */ static jmp_buf decode_proc; /* Jump buffer for decoding procedure */ #if SFX_LEVEL>=ARJSFXV unsigned short FAR *c_table; unsigned short FAR *pt_table; #else unsigned short c_table[CTABLESIZE]; unsigned short pt_table[PTABLESIZE]; #endif short blocksize; static long count; /* Fills the input buffer */ void fillbuf(int n) { #ifdef DEBUG int bbrc; #endif while(bitcount>(8-bitcount)); n-=bitcount; if(compsize>0) { compsize--; if(file_packing) { /* This slows the things down quite a lot so we won't put this in the release version (despite of what ARJ Software Inc. does in v 3.04!) */ #ifdef DEBUG errno=0; /* ASR fix 11/10/2000 -- POSIX/MS C */ bbrc=fgetc(aistream); if(errno!=0) msg_cprintf(0, M_DECODE_CRIT_ERROR); if(bbrc<0) msg_cprintf(0, M_DECODE_EOF); byte_buf=(unsigned char)bbrc; #else byte_buf=(unsigned char)fgetc(aistream); #endif } else /* ASR improvement for RAM-to-RAM */ { byte_buf=*packblock_ptr++; packmem_remain--; } if(file_garbled) garble_decode(&byte_buf, 1); } else byte_buf=0; bitcount=8; } bitcount-=n; bitbuf=(bitbuf<>(8-n)); byte_buf<<=n; } /* Reads a series of bits into the input buffer */ static int getbits(int n) { int rc; rc=bitbuf>>(CODE_BIT-n); fillbuf(n); return(rc); } /* Creates a table for decoding */ #if SFX_LEVEL>=ARJSFXV static void NEAR make_table(int nchar, unsigned char *bitlen, int tablebits, unsigned short FAR *table, int tablesize) #else static void NEAR make_table(int nchar, unsigned char *bitlen, int tablebits, unsigned short *table, int tablesize) #endif { unsigned short count[17], weight[17], start[18]; #if SFX_LEVEL>=ARJSFXV unsigned short FAR *p; #else unsigned short *p; #endif unsigned int i, k, len, ch, jutbits, avail, nextcode, mask; for(i=1; i<=16; i++) count[i]=0; for(i=0; (int)i=ARJSFXV msg_cprintf(H_ERR, M_BADTABLE_G); #else error(M_BADTABLE_G); #endif } else #if SFX_LEVEL>=ARJSFXV msg_cprintf(H_ERR, M_BADTABLE); #else error(M_BADTABLE); #endif #if SFX_LEVEL>=ARJSFXV longjmp(decode_proc, 1); #endif } jutbits=16-tablebits; for(i=1; (int)i<=tablebits; i++) { start[i]>>=jutbits; weight[i]=1<<(tablebits-i); } while(i<=16) { weight[i]=1<<(16-i); i++; } i=start[tablebits+1]>>jutbits; if(i!=(unsigned short)(1<<16)) { k=1<(unsigned int)tablesize) { if(file_garbled) { arj_delay(BADTABLE_G_DELAY); #if SFX_LEVEL>=ARJSFXV msg_cprintf(H_ERR, M_BADTABLE_G); #else error(M_BADTABLE_G); #endif } else #if SFX_LEVEL>=ARJSFXV msg_cprintf(H_ERR, M_BADTABLE); #else error(M_BADTABLE); #endif longjmp(decode_proc, 1); } for(i=start[len]; i>jutbits]; i=len-tablebits; while(i!=0) { if(*p==0) { right[avail]=left[avail]=0; *p=avail; avail++; } if(k&mask) p=&right[*p]; else p=&left[*p]; k<<=1; i--; } *p=ch; } start[len]=nextcode; } } } /* Reads length of data pending */ void read_pt_len(int nn, int nbit, int i_special) { int i, n; short c; unsigned short mask; n=getbits(nbit); if(n==0) { c=(short)getbits(nbit); for(i=0; i=NPT) /* FIX */ n=NPT; /* FIX */ while(i>13; if(c==7) { mask=1<<12; while(mask&bitbuf) { mask>>=1; c++; } } fillbuf((c<7)?3:(int)(c-3)); pt_len[i++]=(unsigned char)c; if(i==i_special) { c=getbits(2); while(--c>=0) pt_len[i++]=0; } } while(i>8]; if(c>=NT) { mask=1<<7; do { if(bitbuf&mask) c=right[c]; else c=left[c]; mask>>=1; } while(c>=NT); } fillbuf((int)(pt_len[c])); if(c<=2) { if(c==0) c=1; else if(c==1) { c=getbits(4); c+=3; } else { c=getbits(CBIT); c+=20; } while(--c>=0) c_len[i++]=0; } else c_len[i++]=(unsigned char)(c-2); } while(i>4]; if(j>=NC) { mask=1<<3; do { if(bitbuf&mask) j=right[j]; else j=left[j]; mask>>=1; } while(j>=NC); } fillbuf(c_len[j]); return(j); } /* Decodes a control character */ static unsigned short NEAR decode_p() { unsigned short j, mask; j=pt_table[bitbuf>>8]; if(j>=NP) { mask=1<<7; do { if(bitbuf&mask) j=right[j]; else j=left[j]; mask>>=1; } while(j>=NP); } fillbuf(pt_len[j]); if(j!=0) { j--; j=(1<=ARJSFXV if((c_table=farcalloc((unsigned long)CTABLESIZE, (unsigned long)sizeof(short)))==NULL) error(M_OUT_OF_MEMORY); if((pt_table=farcalloc((unsigned long)PTABLESIZE, (unsigned long)sizeof(short)))==NULL) error(M_OUT_OF_MEMORY); #endif decode_start_stub(); } #if SFX_LEVEL>=ARJSFXV /* Releases memory used for decoding */ static void NEAR decode_end() { farfree(c_table); farfree(pt_table); decode_end_stub(); } #endif /* Decodes the entire file */ void decode(int action) { short i; short r; short c; static short j; #if SFX_LEVEL>=ARJSFXV if(!setjmp(decode_proc)) { #endif #if SFX_LEVEL>=ARJSFXV dec_text=malloc_msg(DICSIZ); #endif decode_start(); display_indicator(0L); count=origsize; r=0; while(count>0L) { if((c=decode_c())<=UCHAR_MAX) { dec_text[r]=(unsigned char)c; count--; if(++r>=DICSIZ) { r=0; display_indicator(origsize-count); if(extraction_stub(dec_text, DICSIZ, action)) goto termination; } } else { j=c-(UCHAR_MAX+1-THRESHOLD); count-=(unsigned long)j; i=r-decode_p()-1; if(i<0) i+=DICSIZ; if(r>i&&r=0) dec_text[r++]=dec_text[i++]; } else { while(--j>=0) { dec_text[r]=dec_text[i]; if(++r>=DICSIZ) { r=0; display_indicator(origsize-count); if(extraction_stub(dec_text, DICSIZ, action)) goto termination; } if(++i>=DICSIZ) i=0; } } } } #if SFX_LEVEL>=ARJSFXV } #endif if(r>0) extraction_stub(dec_text, r, action); termination:; #if SFX_LEVEL>=ARJSFXV decode_end(); free(dec_text); #endif } #if SFX_LEVEL>=ARJ /* Backward pointer decoding */ static short decode_ptr() { short c, width, plus, pwr; plus=0; pwr=1<<9; for(width=9; width<13; width++) { c=getbits(1); if(c==0) break; plus+=pwr; pwr<<=1; } if(width!=0) c=getbits(width); c+=plus; return(c); } /* Reference length decoding */ static short decode_len() { short c, width, plus, pwr; plus=0; pwr=1; for(width=0; width<7; width++) { c=getbits(1); if(c==0) break; plus+=pwr; pwr<<=1; } if(width!=0) c=getbits(width); c+=plus; return(c); } /* Decodes the entire file, using method 4 */ void decode_f(int action) { int i; int j; int c; int r; static unsigned long ncount; if(ntext==NULL) ntext=malloc_msg(FDICSIZ); decode_start_stub(); display_indicator(0L); ncount=0L; r=0; while(ncount>8); fillbuf(8); if(++r>=FDICSIZ) { r=0; display_indicator(ncount); if(extraction_stub(ntext, FDICSIZ, action)) goto termination; } } else { j=c-1+THRESHOLD; ncount+=(unsigned long)j; if((i=r-decode_ptr()-1)<0) i+=FDICSIZ; while(j-->0) { ntext[r]=ntext[i]; if(++r>=FDICSIZ) { r=0; display_indicator(ncount); if(extraction_stub(ntext, FDICSIZ, action)) goto termination; } if(++i>=FDICSIZ) i=0; } } } if(r>0) extraction_stub(ntext, r, action); termination: decode_end_stub(); /* ASR fix - otherwise destroy it in final_cleanup() -- 15/08/2001 */ #ifdef TILED free(ntext); ntext=NULL; #endif } #endif arj-3.10.22/decode.h 666 0 0 567 7450456610 10220 0ustar /* * $Id: decode.h,v 1.1.1.1 2002/03/28 00:02:16 andrew_belov Exp $ * --------------------------------------------------------------------------- * Prototypes of the functions located in DECODE.C are declared here. * */ #ifndef DECODE_INCLUDED #define DECODE_INCLUDED /* Prototypes */ void fillbuf(int n); void decode(int action); void decode_f(int action); #endif arj-3.10.22/defines.h 666 0 0 103757 10056654210 10507 0ustar /* * $Id: defines.h,v 1.8 2004/05/31 16:08:41 andrew_belov Exp $ * --------------------------------------------------------------------------- * Various macros, OS-independent types, and so on, are to be declared here. * */ #ifndef DEFINES_INCLUDED #define DEFINES_INCLUDED #include /* Nonspecific limits */ #ifndef UCHAR_MAX #define UCHAR_MAX 255 #endif #ifndef CHAR_BIT #define CHAR_BIT 8 #endif #ifndef LONG_MAX #define LONG_MAX 0x7FFFFFFFL #endif /* Archive header definitions */ #define MAXMETHOD 4 /* v 0.14+ */ #define ARJ_VERSION 11 /* Current revision */ #define ARJ_ANSI_VERSION 9 /* Version that introduced ANSI CP (ARJ32 v 3.00-18/12/1998 ONLY!) */ #define ARJ_M_VERSION 6 /* ARJ version that supports archive last modification date. */ #define ARJ_X_VERSION 1 /* decoder version */ #define ARJ_G_VERSION 9 /* enhanced garble version */ #define ARJ_NEWCRYPT_VERSION 10 /* New encryption standard version */ #define ARJ_XD_VERSION 3 /* Version of decoder that supports directories */ #define ARJ_XU_VERSION 11 /* Version of decoder with UNIX support */ #define ARJ_X_SUPPORTED 11 /* Currently supported level (8 in official branch as of v 2.76) */ #define ARJ_X_SFX 11 /* Level supported by ARJSFX (5 in official branch as of v 2.76) */ #define ARJSEC_VERSION 2 /* Current ARJ-SECURITY version */ #define DEFAULT_METHOD 1 #define DEFAULT_TYPE 0 /* if type_sw is selected */ #define HEADER_ID 0xEA60 #define HEADER_ID_HI 0xEA #define HEADER_ID_LO 0x60 #define FIRST_HDR_SIZE 30 #define FIRST_HDR_SIZE_V 34 #define EA_ID 'E' /* EA ID in extended header */ #define UXSPECIAL_ID 'U' /* UNIX special file ID */ #define OWNER_ID 'O' /* Owner ID */ #define OWNER_ID_NUM 'o' /* Numeric owner ID */ /* NLS */ #define LANG_en 0 /* English */ #define LANG_fr 1 /* French */ #define LANG_de 2 /* German */ #define LANG_ru 3 /* Russian */ /* Registration-related data */ #define REG_ID 0xABC0 /* Indicates a registered ARJSFX */ #define UNREG_ID 0x1234 /* Indicates an unregistered ARJSFX */ #define REG_HDR_SHIFT 20 /* Bytes to skip after signature */ #define REG_HDR_LEN 32 /* Header size */ #define REG_KEY1_SHIFT (REG_HDR_SHIFT+REG_HDR_LEN) #define REG_KEY1_LEN 10 /* Registration key #1 */ #define REG_KEY2_SHIFT (REG_KEY1_SHIFT+REG_KEY1_LEN) #define REG_KEY2_LEN 10 /* Registration key #2 */ #define REG_NAME_SHIFT (REG_KEY2_SHIFT+REG_KEY2_LEN) #define REG_NAME_LEN 100 /* Registration name */ #define STD_REG_LEN 152 /* Length of the registration field */ #define ARJSEC_RECORD_SIZE 120 /* Size of ARJ-SECURITY tail */ #define ARJSEC_ITER 1021 /* # of encryption iterations */ /* Explicit delays */ #define BAD_CRC_DELAY 5 /* Integrity violations */ #define SECURITY_DELAY 5 /* ARJ-SECURITY violations */ #define STD_CHANGE_VOL_DELAY 10 /* Default delay when changing volumes */ /* Header flags */ #define GARBLED_FLAG 0x01 #define OLD_SECURED_FLAG 0x02 #define ANSICP_FLAG 0x02 /* Matches with the ARJSEC v 1.x */ #define VOLUME_FLAG 0x04 #define EXTFILE_FLAG 0x08 #define PROT_FLAG 0x08 /* Main header only (v 3.02+) */ #define PATHSYM_FLAG 0x10 #define BACKUP_FLAG 0x20 #define SECURED_FLAG 0x40 #define DUAL_NAME_FLAG 0x80 /* ARJ v 2.55+ ("-hf1" mode) */ /* Extended header flags. The following encryption flags can NOT be OR'ed together! */ #define ENCRYPT_OLD 0 /* Standard encryption in pre-2.60 */ #define ENCRYPT_STD 1 /* Standard ARJ encryption */ #define ENCRYPT_GOST256 2 /* GOST 256-bit encryption (2.55+) */ #define ENCRYPT_GOST256L 3 /* GOST 256-bit encryption (2.62d+) allows 64-byte long passwords */ #define ENCRYPT_GOST40 4 /* GOST 40-bit encryption (2.61+) */ #define ENCRYPT_UNK 16 /* To be encrypted */ /* Relocated flags */ #define SFXSTUB_FLAG 1 /* Indicates SFXSTUB presence */ /* Limits to ARJ archives */ #define COMMENT_MAX 2048 #define EXTENSION_MAX 9 /* For internal procedures */ #define HEADERSIZE_MAX (FIRST_HDR_SIZE+10+FILENAME_MAX+COMMENT_MAX) #define CHAPTERS_MAX 250 /* Limited by 1 byte for chapter # */ #define RESERVED_CHAPTER 32764 /* For special markers */ #define HIGHEST_CHAPTER (RESERVED_CHAPTER+1) #define MAX_FILE_SIZE LONG_MAX /* Size of compressed file */ /* Encoding/decoding constants */ #define CODE_BIT 16 #define THRESHOLD 3 #define DICSIZ 26624 #ifdef TILED #define FDICSIZ DICSIZ #else #define FDICSIZ 32768 /* decode_f() dictionary size */ #endif #define DICSIZ_MAX 32750 #define BUFSIZ_DEFAULT 16384 #define MAXDICBIT 16 #define MATCHBIT 8 #define MAXMATCH 256 #define NC (UCHAR_MAX+MAXMATCH+2-THRESHOLD) #define NP (MAXDICBIT+1) #define CBIT 9 #define NT (CODE_BIT+3) #define PBIT 5 #define TBIT 5 #if NT>NP #define NPT NT #else #define NPT NP #endif #define CTABLESIZE 4096 #define PTABLESIZE 256 #define STRTP 9 #define STOPP 13 #define STRTL 0 #define STOPL 7 #define PUTBIT_SIZE 512 #define MIN_CRITICAL_BUFSIZ 512 /* The minimum size allowed by the implementation */ #define MIN_BUFSIZ 2048 #define MAX_BUFSIZ FAR_BLK_MAX #define MAX_USER_BUFSIZ 65535 /* This one is here for compatibility: even if compiler doesn't allow such large values, the user should know nothing. */ #define BUFSIZ_INCREMENT 6 /* Message section defines */ #define MSGTEXT_MAX 512 /* Maximum length of individual msg (for copying far messages). It's allowed for near FMSGs to be larger */ /* Search defines */ #define SEARCH_STR_MAX 20 /* Maximum number of search patterns */ /* Extended wildcard return status */ #define XW_NONE 0 /* No wildcards */ #define XW_OK 1 /* Indicates successful parsing */ #define XW_PREM_END 2 /* Premature end of string */ #define XW_OWC 3 /* Open * wildcard */ #define XW_UNPROC 4 /* Unexpected unprocessed character */ #define XW_MISMATCH 5 /* Comparison mismatch */ #define XW_TERM 6 /* Wildcard termination */ #define XWP_NONE 0 /* Parsing was pointless */ #define XWP_TERM -1 /* Terminating '^' */ #define XWP_MDASH -2 /* Dash clause: -] or - */ #define XWP_OBRACKET -3 /* Open bracket: [ */ #define XWP_NBRACKET -4 /* Null bracket pair: [] */ /* Block operations */ #define BOP_NONE 0 /* No action */ #define BOP_LIST 1 /* List files to stdout ("arj s") */ #define BOP_SEARCH 2 /* Search for a pattern ("arj w") */ #define BOP_COMPARE 3 /* Compare against disk files */ #define BOP_DISPLAY 5 /* List without pause */ /* Changing it would result in loss of compatibility: */ #define CRC_MASK 0xFFFFFFFFL /* Console definitions */ #define CONSOLE_LINE_LENGTH 80 /* Length of output lines */ /* File types and limitations */ #define ARJT_BINARY 0 #define ARJT_TEXT 1 #define ARJT_COMMENT 2 #define ARJT_DIR 3 #define ARJT_LABEL 4 #define ARJT_CHAPTER 5 /* Chapter mark - ARJ v 2.50+ */ #define ARJT_UXSPECIAL 6 /* UNIX special file - ARJ v 2.77+ */ #define TEXT_LCHAR 7 /* Minimum displayable character */ #define TEXT_UCHAR 127 /* Maximum displayable character */ #define MIN_TEXT_SIZE 128 /* Minimum size for text files */ /* ARJ commands */ #define ARJ_CMD_ADD ((int)'A') /* Add files to archive */ #define ARJ_CMD_EXEC ((int)'B') /* Execute command */ #define ARJ_CMD_COMMENT ((int)'C') /* Comment archive files */ #define ARJ_CMD_DELETE ((int)'D') /* Delete files from archive */ #define ARJ_CMD_EXTR_NP ((int)'E') /* Extract, removing paths */ #define ARJ_CMD_FRESHEN ((int)'F') /* Freshen files in archive */ #define ARJ_CMD_GARBLE ((int)'G') /* Garble files in archive */ #define ARJ_CMD_CHK_INT ((int)'I') /* Check integrity */ #define ARJ_CMD_JOIN ((int)'J') /* Join archives */ #define ARJ_CMD_REM_BAK ((int)'K') /* Remove obsolete backup files */ #define ARJ_CMD_LIST ((int)'L') /* List archive contents */ #define ARJ_CMD_MOVE ((int)'M') /* Move files to archive */ #define ARJ_CMD_RENAME ((int)'N') /* Rename files in archive */ #define ARJ_CMD_ORDER ((int)'O') /* Order archive files */ #define ARJ_CMD_PRINT ((int)'P') /* List contents */ #define ARJ_CMD_RECOVER ((int)'Q') /* Recover damaged archive */ #define ARJ_CMD_REMPATH ((int)'R') /* Remove paths from filenames */ #define ARJ_CMD_SAMPLE ((int)'S') /* List to screen w/pause */ #define ARJ_CMD_TEST ((int)'T') /* Test an archive */ #define ARJ_CMD_UPDATE ((int)'U') /* Update files in archive */ #define ARJ_CMD_V_LIST ((int)'V') /* Verbosely list contents of archive */ #define ARJ_CMD_WHERE ((int)'W') /* Text search */ #define ARJ_CMD_EXTRACT ((int)'X') /* Extract files from archive */ #define ARJ_CMD_COPY ((int)'Y') /* Copy archive with new options */ #define ARJ_CMD_SECURE ((int)'Z') /* Create a security envelope */ #define ARJ_CMD_ADDC ((int)'1') /* Add a file to chapter archive */ #define ARJ_CMD_CNVC ((int)'2') /* Convert archive to a chapter one */ #define ARJ_CMD_DELC ((int)'3') /* Delete a chapter */ #define ARJDISP_CMD_START ((int)'+') /* Put ARJDISP banner */ #define ARJDISP_CMD_END ((int)'-') /* Clear ARJDISP screen */ /* Command line limits */ #define CMDLINE_MAX 512 /* Length of command-line options */ /* ARJ errorlevels */ #define ARJ_ERL_SUCCESS 0 #define ARJ_ERL_WARNING 1 #define ARJ_ERL_FATAL_ERROR 2 #define ARJ_ERL_CRC_ERROR 3 #define ARJ_ERL_ARJSEC_ERROR 4 #define ARJ_ERL_DISK_FULL 5 #define ARJ_ERL_CANTOPEN 6 #define ARJ_ERL_USER_ERROR 7 #define ARJ_ERL_NO_MEMORY 8 #define ARJ_ERL_NOT_ARJ_ARCHIVE 9 #define ARJ_ERL_XMS_ERROR 10 #define ARJ_ERL_BREAK 11 #define ARJ_ERL_TOO_MANY_CHAPTERS 12 /* ARJSFX errorlevels */ #define ARJSFX_ERL_SUCCESS 0 #define ARJSFX_ERL_ERROR 1 /* ARJSFXJR errorlevels */ #define ARJSFXJR_ERL_SUCCESS 0 #define ARJSFXJR_ERL_FATAL 1 #define ARJSFXJR_ERL_ERROR 2 /* REARJ errorlevels */ #define REARJ_ERL_SUCCESS 0 #define REARJ_ERL_WARNING 1 /* File not found or other warning */ #define REARJ_ERL_UNCONFIGURED 2 /* File is not a configured archive type */ #define REARJ_ERL_TGT_EXISTS 3 /* Target archive already exists */ #define REARJ_ERL_DISK_FULL 4 /* Not enough disk space */ #define REARJ_ERL_UPD_SKIPPED 5 /* User skipped or user did not select update option */ #define REARJ_ERL_UNPACK 6 /* UNPACK error */ #define REARJ_ERL_PACK 7 /* PACK error */ #define REARJ_ERL_DIRECTORIES 8 /* Target cannot support directories */ #define REARJ_ERL_COUNT 9 /* Wrong file count */ #define REARJ_ERL_SIZE 10 /* Wrong total size */ #define REARJ_ERL_INTERNAL 11 /* Internal archive REARJ error */ #define REARJ_ERL_RENAME 12 /* Rename archive error */ #define REARJ_ERL_VIRUS 13 /* Invoked /v command error (found a virus?) */ #define REARJ_ERL_OVERGROW 14 /* Output archive is larger */ /* REGISTER errorlevels */ #define REGISTER_ERL_SUCCESS 0 #define REGISTER_ERL_ERROR 1 /* Approx. EXE file sizes (currently unused) */ #define EXESIZE_ARJ 102400L #define EXESIZE_ARJSFXV 30000L #define EXESIZE_ARJSFX 14000L #define EXESIZE_ARJSFXJR 9000L #define EXESIZE_MINSFX 5000L /* The smallest header prefix that is considered as SFX (actually checked as EXESIZE_MINSFX+1) */ /* Maximum # of bytes to search for an archive header signature */ #if TARGET==DOS #define HSLIMIT_ARJ 524288L #define HSLIMIT_ARJSFX 262144L #define HSLIMIT_ARJSFXJR 131072L #elif TARGET==OS2&&defined(TILED)&&!defined(DEBUG) #define HSLIMIT_ARJ 320000L #define HSLIMIT_ARJSFX 66000L #define HSLIMIT_ARJSFXJR 18000L #else #define HSLIMIT_ARJ 16777216L /* ...so we don't know/care about it */ #define HSLIMIT_ARJSFX 8188608L #define HSLIMIT_ARJSFXJR 4094304L #endif /* Standard queries */ #define QUERY_CRITICAL 0 /* Can't be disabled */ #define QUERY_APPEND 1 /* -jya */ #define QUERY_CREATE_DIR 2 /* -jyc */ #define QUERY_DELETE_N_FILES 3 /* -jyd */ #define QUERY_LOW_SPACE 4 /* -jyk */ #define QUERY_EXTRACT_RENAME 5 /* -jyn */ #define QUERY_OVERWRITE 6 /* -jyo */ #define QUERY_SCANNED_ENOUGH 8 /* -jys */ #define QUERY_NEXT_VOLUME 9 /* -jyv */ #define QUERY_UPDATE 11 /* -jy std */ #define QUERY_PRESS_ENTER 12 /* "Press ENTER" and default is OK */ #define QUERY_ARCH_OP 13 /* archive operations (garble, etc.) */ #define TOTAL_QUERIES 14 /* Query array size */ /* Standard replies */ #define REPLY_YES 0 #define REPLY_NO 1 #define REPLY_QUIT 2 #define REPLY_ALL 3 #define REPLY_SKIP 4 #define REPLY_GLOBAL 5 #define REPLY_COMMAND 6 #define MAX_REPLY 6 /* Progrss indicator states */ #define IND_NORMAL 0 #define IND_NONE 1 #define IND_GRAPH 2 #define IND_PCT_GRAPH 3 #define IND_TOTAL_PCT 4 #define IND_TOTAL_GRAPH 5 #define IND_TOTAL_PCT_GRAPH 6 #define IND_TOTAL_PCT_LGRAPH 7 /* -i6 (undocumented in v 2.62c) */ /* Multivolume option settings */ #define MV_NONE 0 /* No -v */ #define MV_STD 1 /* Standard -v w/user defined size */ #define MV_AVAIL 2 /* Volume size depends on free space */ /* Multivolume command execution settings */ #define MVC_NONE 0 /* No command execution (default) */ #define MVC_RUN_CMD 1 /* Execute command (-vs) */ #define MVC_RUN_CMD_NOECHO 2 /* Run command w/no echo (-vz) */ #define MVC_DELETION 3 /* -vd (deletion) command */ /* -* option (quiet mode) settings */ #define ARJ_NO_QUIET 0 /* default */ #define ARJ_QUIET 1 /* -* */ #define ARJ_SILENT 2 /* -*1 */ #define ARJ_QUIET2 3 /* -*2 */ /* Archive security states */ #define ARJSEC_NONE 0 /* No ARJ-SECURITY */ #define ARJSEC_SECURED 1 /* Security envelope is present */ #define ARJSEC_SIGNED 2 /* Security signature is present */ /* ARJ-SECURITY processing options */ #define ARJSECP_STD 0 /* Default */ #define ARJSECP_SKIP 1 /* Skip test of security envelope */ #define ARJSECP_SET_ERROR 2 /* Set error on envelope */ /* Filename matching levels */ #define FMM_STD 0 /* Default */ #define FMM_FULL_PATH 1 /* Match using full pathnames (-p) */ #define FMM_SUBDIRS 2 /* Match pathname w/subdirs (-p1) */ /* LFN support modes */ #define LFN_DEFAULT 0 /* Default (no -hf) */ #define LFN_NONE 1 /* Use short names only (-hf) */ #define LFN_DUAL_EXT 2 /* Extract to W95LNAME.NNN (-hf1) */ #define LFN_IGNORE 3 /* Use LFNs in DOS (-hf2) */ #define LFN_DUAL 4 /* Use dual-mode name storage (-hf3) */ #define LFN_ALL 5 /* Set all files as LFNs (-hf4) */ /* Filelist storage classes */ #define BST_NONE 0 /* No memory allocated */ #define BST_FAR 1 /* Block is in the far memory */ #define BST_DISK 2 /* Block is on the disk */ #define BST_XMS 3 /* Block is in the XMS */ /* File search logging levels */ #define SEARCH_DEFAULT 0 /* Display everything */ #define SEARCH_BRIEF 1 /* Display nothing but totals (-hw) */ #define SEARCH_SHOW_NAMES 2 /* Display files w/matches (-hw1) */ /* GOST encryption modes */ #define GOST_NONE 0 /* No GOST encryption */ #define GOST256 1 /* 256-bit encryption (2.55+) */ #define GOST40 2 /* 40-bit encryption (2.61+) */ /* Extract files containing the given text */ #define EXTM_NONE 0 /* No match is required */ #define EXTM_MATCHING 1 /* Only extract matching files */ #define EXTM_MISMATCHING 2 /* Only extract files w/o matches */ /* -d (delete_processed) flags */ #define DP_NONE 0 /* Do not delete processed files */ #define DP_STD 1 /* Standard (-d) */ #define DP_ADD 2 /* On adds */ #define DP_STD 1 /* Standard (-d) - ask permission */ #define DP_ADD 2 /* Same as "ARJ m" */ #define DP_ADD_TRUNC 3 /* Same as DP_ADD + truncate (ASR fix for 2.78-TCO) */ #define DP_EXTRACT 10 /* On extraction */ /* Chapter archive update mode */ #define CHAP_NONE 0 /* No support for chapters */ #define CHAP_USE 1 /* Create/update/extract chapters */ #define CHAP_REMOVE 2 /* Revert a chapter archive back */ /* SFX creation states */ #define SFXCRT_NONE 0 /* Do not create a SFX */ #define SFXCRT_SFX 1 /* Create an ARJSFX/ARJSFXV EXE */ #define SFXCRT_SFXJR 2 /* Create an ARJSFXJR EXE */ /* SFX descriptive identifiers */ #define SFXDESC_NONSFX 0 /* Non-ARJSFX module */ #define SFXDESC_SFXJR 1 /* ARJSFXJR module */ #define SFXDESC_SFX 2 /* ARJSFX module */ #define SFXDESC_SFXV 3 /* ARJSFXV module */ #define SFXDESC_MIN SFXDESC_SFXJR /* Supported range of descriptors */ #define SFXDESC_MAX SFXDESC_SFXV /* Ignore CRC errors (-jr) */ #define ICE_NONE 0 /* Strict header checking */ #define ICE_FORMAT 1 /* Ignore header format errors */ #define ICE_CRC 2 /* Ignore header CRC errors only */ /* Ignore archive open errors */ #define IAE_NONE 0 /* All open errors result in failure */ #define IAE_ACCESS 1 /* Ignore open access errors (-hq) */ #define IAE_NOTFOUND 2 /* Ignore not found errors (-hq1) */ #define IAE_ALL 3 /* Ignore both of the above (-hq2) */ /* ANSI codepage handling options */ #define ANSICP_STD 0 /* Standard processing (depends on host OS) */ #define ANSICP_CONVERT 1 /* Convert to OEM codepage (-hy) */ #define ANSICP_SKIP 2 /* Process only OEM archives (-hy1) */ #define ANSICP_USE_OEM 2 /* Process only OEM archives (-hy2) */ #define ANSICP_USE_ANSI 4 /* Process only ANSI archives (-hy3) */ /* "-h#" (append time stamp) options */ #define ATS_NONE 0 /* Nothing to append */ #define ATS_DATE 1 /* Append date string */ #define ATS_TIME 2 /* Append time string */ #define ATS_DUAL 3 /* Append day number and time */ /* Comment display settings */ #define CMTD_STD 0 /* Standard comment handling style */ #define CMTD_PCMD 1 /* Use P command to display ANSI */ #define CMTD_NONE 2 /* Do not display comments */ /* Verbose settings */ #define VERBOSE_NONE 0 /* Default level */ #define VERBOSE_STD 1 /* -jv */ #define VERBOSE_ENH 2 /* -jv1 */ /* Update and freshen options */ #define UC_NONE 0 /* None (default) */ #define UC_NEW_OR_NEWER 1 /* New + newer (-u) */ #define UC_NEW_OR_OLDER 2 /* New + older (-u1) */ #define UC_NEW_OR_DIFFERENT 3 /* New + different (-u2) */ #define UC_NEW_OR_CRC 4 /* New + CRC mismatch (-u3) */ #define FC_NONE 0 /* None (default) */ #define FC_EXISTING 1 /* Existing (-f) */ #define FC_OLDER 2 /* Older (-f1) */ #define FC_DIFFERENT 3 /* Different (-f2) */ #define FC_CRC 4 /* CRC mismatch (-f3) */ /* Selectable file types */ #define FT_BINARY 1 /* Binary (default) */ #define FT_TEXT 2 /* Text */ #define FT_TEXT_FORCED 3 /* Forced text type */ #define FT_TEXT_GRAPHICS 4 /* Text with graphics */ #define FT_NO_OVERRIDE 0 /* No type specified */ /* Backup options (-jg) */ #define BS_NONE 0 /* No respect to backup files */ #define BS_SELECT 1 /* Select backup files */ #define BS_ONLY 2 /* Select ONLY backup files */ /* Timestamp override modes */ #define ATO_NONE 0 /* Default */ #define ATO_NEWEST 1 /* Set to newest (-s) */ #define ATO_SAVE_ORIGINAL 2 /* Save original timestamp (-s1) */ #define ATO_SAVE_ARCHIVE 3 /* Save archive timestamp (-s2) */ #define ATO_SAVE_BOTH 4 /* Save both timestamps (-s3) */ /* Hollow mode settings */ #define HM_NONE 0 /* Standard mode */ #define HM_CRC 1 /* Store only the CRC */ #define HM_NO_CRC 2 /* Store only date/size/attributes */ #define HM_RESTORE_ATTRS 3 /* Restore attributes */ #define HM_RESTORE_DATES 4 /* Restore dates */ #define HM_RESTORE_ALL 5 /* Restore both attributes and dates */ /* CRC testing (-jt) options */ #define TC_NONE 0 /* No testing, default */ #define TC_ARCHIVE 1 /* Test entire archive (-jt) */ #define TC_CRC_AND_CONTENTS 2 /* Test CRC and contents (-jt1) */ #define TC_ADDED_FILES 3 /* Test only added files (-jt2) */ #define TC_ATTRIBUTES 4 /* Test only fdate/fsize (-jt3) */ /* -2d (compatible Host OS) settings */ #define CHO_NATIVE 0 /* Use native OS */ #define CHO_USE_DOS 1 /* Always set host OS to DOS */ #define CHO_COMMENT 2 /* Fix comments only */ /* Recovery options */ #define RB_NONE 0 /* Default, exit on broken files */ #define RB_NORMAL 1 /* Normal mode, skip CRC errors (-jr) */ #define RB_TIGHT 2 /* Tight mode, skip header errors (-jr1) */ /* Path exclusion options */ #define EP_NONE 0 /* Default, store the full path */ #define EP_PATH 1 /* Exclude path */ #define EP_BASEDIR 2 /* Exclude base directory */ /* Century handling options */ #define CENT_DEFAULT 0 /* Default century handling */ #define CENT_SKIP 1 /* Skip century in dates (-2k) */ #define CENT_SMART 2 /* Smart handling (-2k1) */ /* Owner storage options */ #define OWNSTG_NONE 0 /* No owner storage */ #define OWNSTG_CHAR 1 /* Store in character format */ #define OWNSTG_ID 2 /* Store in UID/GID format */ #define OWNSTG_CHAR_GID 3 /* Character format + GID */ /* OS codes */ #define OS_DOS 0 /* MS-DOS */ #define OS_PRIMOS 1 /* PRIMOS */ #define OS_UNIX 2 /* UNIX-like operating systems */ #define OS_AMIGA 3 /* AMIGA */ #define OS_MACOS 4 /* Macintosh */ #define OS_OS2 5 /* OS/2, WSoD, Warp Server, eCS */ #define OS_APPLE 6 /* Apple GS */ #define OS_ATARI 7 /* ATARI ST */ #define OS_NEXT 8 /* NeXT */ #define OS_VAX 9 /* VAX/VMS */ #define OS_WIN95 10 /* Windows 95/98 */ #define OS_WINNT 11 /* Windows NT/2000 */ #define OS_WIN32 OS_WINNT /* Since ARJ v 2.62c */ #define OS_SPECIAL 0xFFFF /* Reserved for special handling */ /* Implementation-independent path separators */ #define PATHSEP_UNIX '/' #define PATHSEP_DOS '\\' /* List character */ #define LISTCHAR_DEFAULT '!' /* Time filtering capabilities */ #define TCHECK_NOTHING 0 /* Time is not checked */ #define TCHECK_FTIME 1 /* Last write time */ #define TCHECK_NDAYS 2 /* No older than N days */ #define TCHECK_CTIME 3 /* Creation time */ #define TCHECK_ATIME 4 /* Last access time */ #define NULL_TIME 0L /* Non-existent timestamp */ /* Attributes for tagging */ #define TAG_FILES 0x0000 /* All files (-hbf -> -hbndhrs) */ #define TAG_ARCH 0x0001 /* Files with FA_ARCH set (-hba) */ #define TAG_NOT_ARCH 0x0002 /* Files with FA_ARCH clear (-hbb) */ #define TAG_RDONLY 0x0004 /* Read-only files (-hbr) */ #define TAG_SYSTEM 0x0008 /* System files (-hbs) */ #define TAG_HIDDEN 0x0010 /* Hidden files (-hbf) */ #define TAG_DIREC 0x0020 /* Directories (-hbd) */ #define TAG_LABEL 0x0040 /* Volume labels (-hbl) */ #define TAG_CHAPTER 0x0080 /* Internal chapter labels (-hbc) */ #define TAG_NORMAL 0x0100 /* Normal files (-hbn) */ #define TAG_WINLFN 0x0200 /* Windows 95 long filenames (-hbw) */ #define TAG_UXSPECIAL 0x0400 /* UNIX special files (-hbu) */ #define TAG_LIST "FABRSHDLCNWU" /* Used in command prompt */ /* Archive attribute filtering */ #define FAA_NONE 0 /* Ignore archive bit (default) */ #define FAA_BACKUP 1 /* Backup changed files */ #define FAA_BACKUP_CLEAR 2 /* Backup changed, reset archive bits */ #define FAA_CLEAR 3 /* only reset archive bits */ #define FAA_RESTORE_CLEAR 4 /* reset archive bit during restore */ #define FAA_EXCL_CLEAR 5 /* do not restore bits, reset arc */ #define FAA_SKIP_ATTRS 6 /* do not restore any file attributes */ /* LFN support state */ #define LFN_NOT_SUPPORTED 0 /* Running in pure DOS */ #define LFN_SUPPORTED 1 /* Default for '95s */ #define LFN_COMP 2 /* Compatibility mode */ /* validate_path actions */ #define VALIDATE_ALL 0 /* Remove all relative specs */ #define VALIDATE_NOTHING 1 /* Do nothing */ #define VALIDATE_DRIVESPEC 2 /* Remove leading drive specs */ /* File flags in filelist table. Two different mappings existed in ARJSFXV and ARJ as of v 2.72 (eliminated 17/01/2001 -- ASR) */ #define FLFLAG_TO_PROCESS 0 /* To be processed */ #define FLFLAG_PROCESSED 1 /* Already processed */ #define FLFLAG_SKIPPED 2 /* Forced to skip */ #define FLFLAG_DELETED 3 /* Already deleted */ /* Special processing actions */ #define CFA_NONE 0 /* No special processing */ #define CFA_REMPATH 1 /* Remove paths from filenames */ #define CFA_GARBLE 2 /* Garble files */ #define CFA_MARK_INCREMENT 3 /* Marking for chapter archives... */ #define CFA_UNMARK 4 #define CFA_MARK 5 #define CFA_MARK_EXT 6 #define CFA_UNMARK_EXT 7 #define CFA_UNGARBLE 8 /* Decrypt files */ /* File list generation options */ #define FETCH_DEFAULT 0 /* Standard files */ #define FETCH_FILES 1 /* Hidden files, etc. */ #define FETCH_DIRS 2 /* Same + directories */ /* Extension serialization types */ #define EXT_NO_SERIALIZE 0 /* Do not serialize extensions */ #define EXT_SUBSTITUTE 1 /* Substitute extension */ #define EXT_INSERT 2 /* Insert number before extension */ /* Operations on final pass */ #define FP_GARBLE 0x02 /* Encryption stamping */ #define FP_SECURITY 0x15 /* Security envelope creation */ #define FP_VOLUME 0x16 /* Multivolume processing */ #define FP_CHAPTER 0x17 /* Chapter operations */ #define FP_PROT 0x18 /* ARJ-PROTECT recovery record */ /* Encryption id states */ #define ENCID_NONE 0 /* Default */ #define ENCID_GARBLE 1 /* Garble operation */ #define ENCID_UNGARBLE 2 /* Ungarble operation */ /* Message section validation flag */ #define CHKMSG_NOSKIP 0 /* Process CRC32 accumulation */ #define CHKMSG_SFX_HELP 1 /* Display ARJSFX help */ #define CHKMSG_SKIP -1 /* Skip CRC32 accumulation */ /* Hardlink suppression */ #define SHL_NONE 0 /* Normal processing */ #define SHL_DROP 1 /* Ignore (do not add/extract) */ #define SHL_SOFT 2 /* Ignore on addition, replace w/symlinks upon extraction */ /* Directory recursion order */ #define RO_LAST 0 /* Contents, then direntry */ #define RO_FIRST 1 /* Direntry, then contents */ /* Multivolume processing definitions */ #define MULTIVOLUME_RESERVE 604 /* Number of bytes to subtract */ #define MULTIVOLUME_INCREMENT 500 /* Criteria of switching to next vol. */ #define MIN_VOLUME_SIZE 10000L /* Minimal allowed volume size */ #define MAX_VOLUME_TRIES 9 /* Number of times to check if we can switch to the next volume */ #define MAX_VOLUME_FT_CHECKS 3 /* Number of times to check the file timestamp */ /* SFX definitions */ #define SFX_COMMAND_SIZE 126 /* Length of SFX options in comment (must be less than CHAR_MAX) */ /* Color highlighting */ #ifdef COLOR_OUTPUT struct color_hl { char color; char arg; }; #endif #define H_STD 0 /* Standard text */ #define H_OPER 1 /* Operation/progress counters */ #define H_HL 2 /* Highlight */ #define H_SIG 3 /* Signal */ #define H_ALERT 4 /* Alert */ #define H_PROMPT 5 /* Prompt */ #define H_COLORMASK 0x0F /* Color index */ /* Flags */ #define H_WEAK 0x10 /* After answering "NO" to the pause request, the user will be brought back to main processing loop */ #define H_NFMT 0x20 /* Revert to H_STD for formatting areas (e.g. "%d files") */ #define H_FORCE 0x40 /* Does not go off with "-*", needs "-*1" to be silenced */ #define H_ERR (H_ALERT|H_FORCE) /* Make error msgs visible */ /* Line feed is used many times so we prefer to declare is as public in ENVIRON.C and use far references to it: */ extern char simple_lf[]; #define lf simple_lf extern char simple_cr[]; #define cr simple_cr /* An extended file information structure */ struct disk_file_info { struct file_properties file_properties; char name[1]; /* Allocated dynamically */ }; /* Memory packing */ struct mempack { char FAR *comp; char FAR *orig; unsigned int compsize; unsigned int origsize; int method; }; #define MEMPACK_OVERHEAD 4 /* CRC32 (for now) */ #endif arj-3.10.22/det_x86.asm 666 0 0 2007 7450456614 10622 0ustar ;* ;* $Id: det_x86.asm,v 1.1.1.1 2002/03/28 00:02:20 andrew_belov Exp $ ;* --------------------------------------------------------------------------- ;* This code uses the classic way of determining what Intel x86 CPU is used. ;* The exact author is unknown. ;* INCLUDE ASM_INCL.INC public detect_x86 .CODE ;* ;* Returns one of the following values for corresponding CPU types: ;* ;* 0x0086 -> 8086/8088 ;* 0x0186 -> 80186/80188 ;* 0x0286 -> 80286 ;* 0x0386 -> 80386 and higher ;* detect_x86 proc pushf xor ax, ax push ax popf pushf pop ax and ax, 0F000h cmp ax, 0F000h jnz test_386 push cx mov ax, 0FFFFh mov cl, 21h shl ax, cl pop cx jnz l186 mov ax, 86h popf jmp short done l186: mov ax, 186h popf jmp short done test_386: mov ax, 7000h push ax popf pushf pop ax and ax, 7000h jnz l386 mov ax, 286h popf jmp short done l386: mov ax, 386h popf jmp short $+2 done: ret detect_x86 endp end arj-3.10.22/det_x86.h 666 0 0 517 7450456614 10255 0ustar /* * $Id: det_x86.h,v 1.1.1.1 2002/03/28 00:02:20 andrew_belov Exp $ * --------------------------------------------------------------------------- * Prototypes of the functions located in DET_X86.ASM are declared here. * */ #ifndef DET_X86_INCLUDED #define DET_X86_INCLUDED /* Prototypes */ unsigned int detect_x86(); #endif arj-3.10.22/doc/ 777 0 0 0 10256535570 7342 5ustar arj-3.10.22/doc/compile.txt 666 0 0 14512 10004716364 11627 0ustar $Id: compile.txt,v 1.7 2004/01/25 10:39:48 andrew_belov Exp $ INTRODUCTION This is a collection of developers' notes for the open-source ARJ project. HOW TO COMPILE UNIX-like systems, as well as OS/2 EMX, need to be configured first. Run "cd gnu; autoheader; autoconf; ./configure; cd .." to proceed with the standard GNU configuration process. Tip: the "configure" script would be different for UNIX-like systems and OS/2 EMX. That is the reason for not including it into the source code distribution. ** TODO: on OS/2, InnoTek GCC v 3.2.x has not been tested yet ** Next, run GNU make in the toplevel directory. If you specify "DEBUG=1", the executables will be built with debug information. See GNUmakefile for details on available options). Example: gmake DEBUG=1 gmake ARJ may be packaged in a SFX file by choosing the "package" target instead of the default target, "all". The packages created by the open-source distribution would be similar to those distributed by ARJ Software Russia. Unlike the previous closed-source releases, the open-source ARJ distribution is no longer stamped with a signature known as ARJ-SECURITY. CODE ORGANIZATION CONSIDERATIONS For clarity, handle NULL as it might be !=0, so actions like "if (!strchr(...))" are deprecated. The data structures are described with a simple "struct" statement. "typedef struct" is only used to emphasize a complex type with a "hidden" implementation, like FILE in C, which is different in various C implementations. In other words, the "typedef struct" construct has never to be used in ARJ modules, although it takes longer time to type the extra word, "struct", in declarations. Some variables may have doubtful names, like bytes_written in hollow_decode(). These result from countless cut+paste operations. Despite our attempts to keep the code scattered within several files, DOS-hosted compilers may run out of memory while compiling the source. Even more, the fact that some files are larger than 64K adversely affects the portability. Be careful when you convert an array definition like char p[SOME_CONSTANT]; to a pointer for dynamic allocation. The size of such array may be referenced with sizeof() statement. No dependencies are made on the *.H files (and actually there are very deep, sometimes even circular dependencies). Most oftenly, all targets must be recompiled when an .H file is changed. An exception may be the introduction of an equate or declaration - in this case, obviously, there is no need to force the recompile. CODING STYLE ** TODO: this section will have to be revised ** The coding style is distinct in that the single space character is used as indentation. Oftenly, the conditional expressions are writen in the following form: (control_expression)?result1:result2. Although the brackets around control_expression are a waste of space, we use them to highlight the control_expression. One may use the "BUGBUG:", "TODO:" and "FIXME:" comments ("BUGBUG:" is the preferred style) to designate code portions that need further work. COMPILER ISSUES Some compilers (e.g. Turbo C++ v 1.0) do not automatically pick default include file subdirectory from INCLUDE environment varibable. In such cases, the include path is usually specified in a corresponding .STS file. Dynamic linkage with LIBC when using IBM C Set/2 is possible only if the libraries have been converted to LINK386-compatible format (LIBCS.LIB) and the headers have been patched to fix the stdin/stdout macro abuse (results in null pointers once the optimization is turned on). The "-O2" GCC optimization parameter may impose problems in GCC v 2.9x through 3.1x. Upgrade to GCC v 3.2 is suggested. "-O2 -fno-expensive-optimizations" may also serve as a workaround. COMPILER BUGS Microsoft C compiler v 6.00A performs optimizations incorrectly, resulting in broken code. Therefore, register optimizations have been disabled. Microsoft C compiler v 6.00A (unsure about the others) prefers a function over the label with the same name in ASM clauses within functions. The run-time library in MS C v 7.00 (even with the Sep'92 patches applied) has some quirks with converting dates to/from unixtime. ARJ will report the date in M_ARCHIVE_CREATED one day before than the actual date. This bug does not occur neither with MS C v 6.0, nor with subsequent releases (Visual C/C++). Microsoft Visual C v 1.00 compiler (CL.EXE v 8.00) fails when /Os is specified. /Olerg is used as a workaround to this. An extensive analysis of the exact optimization switch that causes the failure has not been yet performed so the optimization efficiency has been scaled down to pretty inaccurate. This hasn't been investigated thoroughly but it seems that Borland C++ v 4.00 is not able to link COM files with C0T.OBJ. A workaround for this is to use C0T.OBJ from Borland C++ v 3.10 package instead. MASM v 6.00 occasionally may end up with an exception under OS/2, leaving a blank object file and therefore obstructing the compilation. Microsoft claims that it has been fixed in version 6.01. Note that this problem may no longer be observed in ARJ, as the ASM portions have been mostly eliminated in ARJ v 2.71 and at early stages of ARJ v 2.72 development. PLATFORM ISSUES When compiling under DOS, version 4.00 or higher is required due to use of "@" modifiers in MAKEFILE. Compiled executables may be run in lower versions of DOS if it's allowed by their implementation. arj-3.10.22/doc/COPYING 666 0 0 43070 7450456724 10466 0ustar GNU GENERAL PUBLIC LICENSE Version 2, June 1991 Copyright (C) 1989, 1991 Free Software Foundation, Inc. 675 Mass Ave, Cambridge, MA 02139, USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Preamble The licenses for most software are designed to take away your freedom to share and change it. By contrast, the GNU General Public License is intended to guarantee your freedom to share and change free software--to make sure the software is free for all its users. This General Public License applies to most of the Free Software Foundation's software and to any other program whose authors commit to using it. (Some other Free Software Foundation software is covered by the GNU Library General Public License instead.) You can apply it to your programs, too. When we speak of free software, we are referring to freedom, not price. Our General Public Licenses are designed to make sure that you have the freedom to distribute copies of free software (and charge for this service if you wish), that you receive source code or can get it if you want it, that you can change the software or use pieces of it in new free programs; and that you know you can do these things. To protect your rights, we need to make restrictions that forbid anyone to deny you these rights or to ask you to surrender the rights. These restrictions translate to certain responsibilities for you if you distribute copies of the software, or if you modify it. For example, if you distribute copies of such a program, whether gratis or for a fee, you must give the recipients all the rights that you have. You must make sure that they, too, receive or can get the source code. And you must show them these terms so they know their rights. We protect your rights with two steps: (1) copyright the software, and (2) offer you this license which gives you legal permission to copy, distribute and/or modify the software. Also, for each author's protection and ours, we want to make certain that everyone understands that there is no warranty for this free software. If the software is modified by someone else and passed on, we want its recipients to know that what they have is not the original, so that any problems introduced by others will not reflect on the original authors' reputations. Finally, any free program is threatened constantly by software patents. We wish to avoid the danger that redistributors of a free program will individually obtain patent licenses, in effect making the program proprietary. To prevent this, we have made it clear that any patent must be licensed for everyone's free use or not licensed at all. The precise terms and conditions for copying, distribution and modification follow. GNU GENERAL PUBLIC LICENSE TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 0. This License applies to any program or other work which contains a notice placed by the copyright holder saying it may be distributed under the terms of this General Public License. The "Program", below, refers to any such program or work, and a "work based on the Program" means either the Program or any derivative work under copyright law: that is to say, a work containing the Program or a portion of it, either verbatim or with modifications and/or translated into another language. (Hereinafter, translation is included without limitation in the term "modification".) Each licensee is addressed as "you". Activities other than copying, distribution and modification are not covered by this License; they are outside its scope. The act of running the Program is not restricted, and the output from the Program is covered only if its contents constitute a work based on the Program (independent of having been made by running the Program). Whether that is true depends on what the Program does. 1. You may copy and distribute verbatim copies of the Program's source code as you receive it, in any medium, provided that you conspicuously and appropriately publish on each copy an appropriate copyright notice and disclaimer of warranty; keep intact all the notices that refer to this License and to the absence of any warranty; and give any other recipients of the Program a copy of this License along with the Program. You may charge a fee for the physical act of transferring a copy, and you may at your option offer warranty protection in exchange for a fee. 2. You may modify your copy or copies of the Program or any portion of it, thus forming a work based on the Program, and copy and distribute such modifications or work under the terms of Section 1 above, provided that you also meet all of these conditions: a) You must cause the modified files to carry prominent notices stating that you changed the files and the date of any change. b) You must cause any work that you distribute or publish, that in whole or in part contains or is derived from the Program or any part thereof, to be licensed as a whole at no charge to all third parties under the terms of this License. c) If the modified program normally reads commands interactively when run, you must cause it, when started running for such interactive use in the most ordinary way, to print or display an announcement including an appropriate copyright notice and a notice that there is no warranty (or else, saying that you provide a warranty) and that users may redistribute the program under these conditions, and telling the user how to view a copy of this License. (Exception: if the Program itself is interactive but does not normally print such an announcement, your work based on the Program is not required to print an announcement.) These requirements apply to the modified work as a whole. If identifiable sections of that work are not derived from the Program, and can be reasonably considered independent and separate works in themselves, then this License, and its terms, do not apply to those sections when you distribute them as separate works. But when you distribute the same sections as part of a whole which is a work based on the Program, the distribution of the whole must be on the terms of this License, whose permissions for other licensees extend to the entire whole, and thus to each and every part regardless of who wrote it. Thus, it is not the intent of this section to claim rights or contest your rights to work written entirely by you; rather, the intent is to exercise the right to control the distribution of derivative or collective works based on the Program. In addition, mere aggregation of another work not based on the Program with the Program (or with a work based on the Program) on a volume of a storage or distribution medium does not bring the other work under the scope of this License. 3. You may copy and distribute the Program (or a work based on it, under Section 2) in object code or executable form under the terms of Sections 1 and 2 above provided that you also do one of the following: a) Accompany it with the complete corresponding machine-readable source code, which must be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, b) Accompany it with a written offer, valid for at least three years, to give any third party, for a charge no more than your cost of physically performing source distribution, a complete machine-readable copy of the corresponding source code, to be distributed under the terms of Sections 1 and 2 above on a medium customarily used for software interchange; or, c) Accompany it with the information you received as to the offer to distribute corresponding source code. (This alternative is allowed only for noncommercial distribution and only if you received the program in object code or executable form with such an offer, in accord with Subsection b above.) The source code for a work means the preferred form of the work for making modifications to it. For an executable work, complete source code means all the source code for all modules it contains, plus any associated interface definition files, plus the scripts used to control compilation and installation of the executable. However, as a special exception, the source code distributed need not include anything that is normally distributed (in either source or binary form) with the major components (compiler, kernel, and so on) of the operating system on which the executable runs, unless that component itself accompanies the executable. If distribution of executable or object code is made by offering access to copy from a designated place, then offering equivalent access to copy the source code from the same place counts as distribution of the source code, even though third parties are not compelled to copy the source along with the object code. 4. You may not copy, modify, sublicense, or distribute the Program except as expressly provided under this License. Any attempt otherwise to copy, modify, sublicense or distribute the Program is void, and will automatically terminate your rights under this License. However, parties who have received copies, or rights, from you under this License will not have their licenses terminated so long as such parties remain in full compliance. 5. You are not required to accept this License, since you have not signed it. However, nothing else grants you permission to modify or distribute the Program or its derivative works. These actions are prohibited by law if you do not accept this License. Therefore, by modifying or distributing the Program (or any work based on the Program), you indicate your acceptance of this License to do so, and all its terms and conditions for copying, distributing or modifying the Program or works based on it. 6. Each time you redistribute the Program (or any work based on the Program), the recipient automatically receives a license from the original licensor to copy, distribute or modify the Program subject to these terms and conditions. You may not impose any further restrictions on the recipients' exercise of the rights granted herein. You are not responsible for enforcing compliance by third parties to this License. 7. If, as a consequence of a court judgment or allegation of patent infringement or for any other reason (not limited to patent issues), conditions are imposed on you (whether by court order, agreement or otherwise) that contradict the conditions of this License, they do not excuse you from the conditions of this License. If you cannot distribute so as to satisfy simultaneously your obligations under this License and any other pertinent obligations, then as a consequence you may not distribute the Program at all. For example, if a patent license would not permit royalty-free redistribution of the Program by all those who receive copies directly or indirectly through you, then the only way you could satisfy both it and this License would be to refrain entirely from distribution of the Program. If any portion of this section is held invalid or unenforceable under any particular circumstance, the balance of the section is intended to apply and the section as a whole is intended to apply in other circumstances. It is not the purpose of this section to induce you to infringe any patents or other property right claims or to contest validity of any such claims; this section has the sole purpose of protecting the integrity of the free software distribution system, which is implemented by public license practices. Many people have made generous contributions to the wide range of software distributed through that system in reliance on consistent application of that system; it is up to the author/donor to decide if he or she is willing to distribute software through any other system and a licensee cannot impose that choice. This section is intended to make thoroughly clear what is believed to be a consequence of the rest of this License. 8. If the distribution and/or use of the Program is restricted in certain countries either by patents or by copyrighted interfaces, the original copyright holder who places the Program under this License may add an explicit geographical distribution limitation excluding those countries, so that distribution is permitted only in or among countries not thus excluded. In such case, this License incorporates the limitation as if written in the body of this License. 9. The Free Software Foundation may publish revised and/or new versions of the General Public License from time to time. Such new versions will be similar in spirit to the present version, but may differ in detail to address new problems or concerns. Each version is given a distinguishing version number. If the Program specifies a version number of this License which applies to it and "any later version", you have the option of following the terms and conditions either of that version or of any later version published by the Free Software Foundation. If the Program does not specify a version number of this License, you may choose any version ever published by the Free Software Foundation. 10. If you wish to incorporate parts of the Program into other free programs whose distribution conditions are different, write to the author to ask for permission. For software which is copyrighted by the Free Software Foundation, write to the Free Software Foundation; we sometimes make exceptions for this. Our decision will be guided by the two goals of preserving the free status of all derivatives of our free software and of promoting the sharing and reuse of software generally. NO WARRANTY 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, REPAIR OR CORRECTION. 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. END OF TERMS AND CONDITIONS How to Apply These Terms to Your New Programs If you develop a new program, and you want it to be of the greatest possible use to the public, the best way to achieve this is to make it free software which everyone can redistribute and change under these terms. To do so, attach the following notices to the program. It is safest to attach them to the start of each source file to most effectively convey the exclusion of warranty; and each file should have at least the "copyright" line and a pointer to where the full notice is found. Copyright (C) 19yy This program is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program; if not, write to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. Also add information on how to contact you by electronic and paper mail. If the program is interactive, make it output a short notice like this when it starts in an interactive mode: Gnomovision version 69, Copyright (C) 19yy name of author Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. The hypothetical commands `show w' and `show c' should show the appropriate parts of the General Public License. Of course, the commands you use may be called something other than `show w' and `show c'; they could even be mouse-clicks or menu items--whatever suits your program. You should also get your employer (if you work as a programmer) or your school, if any, to sign a "copyright disclaimer" for the program, if necessary. Here is a sample; alter the names: Yoyodyne, Inc., hereby disclaims all copyright interest in the program `Gnomovision' (which makes passes at compilers) written by James Hacker. , 1 April 1989 Ty Coon, President of Vice This General Public License does not permit incorporating your program into proprietary programs. If your program is a subroutine library, you may consider it more useful to permit linking proprietary applications with the library. If this is what you want to do, use the GNU Library General Public License instead of this License. arj-3.10.22/doc/debug.txt 666 0 0 11527 7646035704 11262 0ustar $Id: debug.txt,v 1.2 2003/04/12 16:16:05 andrew_belov Exp $ ARJ DEBUGGER'S GUIDE This file is a reference for everyone who has to deal with ARJ technical support and debugging. DEBUG CONFIGURATION Debugging begins with compiling ARJ for debug mode. Supply a DEBUG=1 clause to the make program, as in the following example: nmake MODE=OS232 COMPILER=CSET2 DEBUG=1 prepare all This will yield an unoptimized executable with some internal assertions and, possibly, further debugging functionality which is platform-specific (e.g. debug malloc() in IBM C Set/2 static libraries). The debug flavor also supports a simple malloc() tracing with "-hdm", probably useful for working out memory shortages in the 16-bit world. TOP 5 TEST CASES Whenever a large volume of changes is committed, or ARJ is being tested under a new platform, we suggest the following test scenario: 1. Ensure that all modules compile normally, and the build process finishes without errors when "make package" is issued. This warrants basic functionality to be there. 2. Examine the usual operation of ARJ module with "arj a -jt1", submitting a combination of options while archiving some "payload" (the volume to be archived is of little importance, 10 files totaling 1 megabyte would be enough for testing): arj a test -+ -v100K -jt1 -hk5 -i5 -jm -hg -garble The "-jt1" will let you see if there are any major omissions which would result in broken archives. Re-check the created archive with: arj q test.arj [should report no damage] arj v test.arj arj t -v -garble test.arj arj x -v -garble test.arj 3. Check the ARJSFX branches: ARJSFXV -> arj a test -+ -va -je ARJSFX -> arj a test -+ -je ARJSFXJR -> arj a test -+ -je1 [may need "-2x", see the output] Each of the SFX levels shares a portion of ARJ code while bringing in some distinct routines, so we put a priority on testing the SFX. 4. Check REARJ: rearj test.zip (need another archiver and a REARJ.CFG for that). REARJ utilizes the platform-specific process creation routines. 5. Verify the compatibility with the mainstream versions of ARJ available at the project download page, or from ARJ Software, Inc. Extract the created archive by using a "branded" distribution of ARJ, then do quite the contrary by packing the archive in one version, then extracting it with another one. Pay special attention to the encryption issue: XOR encryption: arj a test -hg -g... GOST 40-bit cipher: arj a test -hg! -g... GOST 128-bit modular cipher: arj a test -hg -g... Supply your password of choice for "-g..." when archiving and extracting/testing. APPENDIX: DEBUG OPTIONS A list of debug options (-hd, followed by an optional argument): . (ASR) Displays each file being added to a filelist. ? With ARJ v 2.75.03+, allows use of Extended license keys in standard ARJ. The filelist capacity shall remain the same. a Rigorous archive handling. Enables detailed information in index files, and forces recovery of ARJ-PROTECTed archives. b Sets VBUF size. VBUF is used for buffering of archive input stream. c Skips CRC checking for extracted files, thereby causing CRC errors. d Sets the dictionary size on compression, thus making ARJ compress better. The archives can still be extracted... with ARJZ only, though. f Notifies about len_cnt fixes in encoding routine. i Defines the flist_main capacity in ARJ. Extended license is not required in this case. k Zeroes compsize after the file has been unpacked. l Displays the encryption version. m (ASR, DEBUG builds only) Displays malloc()/farmalloc() arguments. n Inhibits all kinds of file generation activities. o Sets archive modification time to the desired timestamp. p Sets TBUF size. TBUF is used for buffering of archive output stream. q Reverts to the standard filelist type for flist_main. s Enables unlimited ranges for numeric switch values. t Enables the poor man's profiler (displays execution ticks). v Dumps the command-line tokens as they are processed, shows memory statistics and may have other effects as a "verbose" command. x Inhibits any sort of hollow file processing. y Uses a case-preserving way of filename/path storage. z Sets the physical filelist capacity limit. Common examples: * -hdaflmv is a usual bug reporter's test case. * -hdt may be used for performance measurements. arj-3.10.22/doc/glossary.txt 666 0 0 4535 7647001252 12010 0ustar /* $Id: glossary.txt,v 1.3 2003/04/15 13:01:31 andrew_belov Exp $ */ ARJ DEVELOPER'S GLOSSARY This file contains some abbreviations and jargon words used in ARJ source and accompanying materials. * ASR - ARJ Software Russia. Whenever mentioned in "ASR fix", this is a reminder that the original version of ARJ doesn't have such modification. By the way, here is how it works in Emacs with hilit19: (hilit-translate asrfix 'skyblue-underline) (hilit-add-pattern "ASR [Ff][Ii][Xx]" "" 'asrfix 'c-mode t) * Bindings - Fixed combinations of platform type, compiler type, NLV, debug/release type and special options. When bound together, these parameters dictate the behavior of packaging modules and affect the data types (e.g. FMSG is binding-dependent in that a combination of SFX_LEVEL and TILED parameters makes it a far pointer). * CFA - Compact Filelist array. Introduced in version 2.72 as a means of enlarging the filelist capacity. Technically it's a bitmap of flags that reflects the status of each individual file, as whether it has been already processed, or not. * G-size - Huffman dictionary size (not to confuse with Huffman buffer size) in the compression module. Permanently fixed at 26624 for compatibility reasons but may be raised with an undocumented parameter. * LIBC - Any dynamically-linked C library. Under OS/2-32, the XPG.4 LIBC. The challenge with OS/2 is that a wide choice of compilers are available; making them use IBM LIBC requires special hacking (see #ifdef`s), the reward being smaller executables. * NLV - National Language Version. (seems to be a widespread term) * TCO - Total Content Offering, originally known as an IBM service to assist legacy customers with leveraging their existing installations, providing private builds and prolonged service at special cost. In ARJ, the TCO branch(es) represent the commercial versions still being developed separately from the GPL one, and kept at a private CVS machine. The principal difference being the ARJ-SECURITY support, though the commercial line becomes more and more divergent as new code flows into the Open-Source ARJ. * YATF - Yet Another Typo Fix. Used to designate minor fixes in ChangeLogs. arj-3.10.22/doc/rev_hist.txt 666 0 0 62113 10256533004 12017 0ustar User-visible changes ==================== 2.61.01 08/11/1998 First alpha version. Minimal functionality. 2.61.02 09/11/1998 Environment filtering to avoid near memory shortage, long filenames are no longer converted to uppercase. 2.61.03 11/11/1998 ANSI comments now supported; some minor bugfixes. 2.61.04 12/11/1998 Help facility works, ARJSFXJR/2 added, -h2p & -h2d switches added, Host OS changed to OS/2, free space on HPFS volumes (up to 4GB) is now determined correctly. 2.61.05 13/11/1998 Removed ARJSFXV size limitation. The efforts are now aimed on ARJSFXV conversion... 2.61.06 15/11/1998 Fixed a glitch with "arj m ..." creating ARJSFXV archives. Note that if no files are found, "arj m" leaves a temporary file. It's the glitch of original ARJ 2.61, and it's left for compatibility. ARJSFXV: Minimal functionality achieved (no LFN yet). 2.61.07 16/11/1998 ARJSFX: Minimal functionality achieved. ARJSFXV: Shareware limitation still intact. Removed. 2.61.08 17/11/1998 ARJSFX: "1 error(s)" due to rudimentary CRC check. 2.61.09 19/11/1998 Now able to truncate files. 2.61.10 21/11/1998 GA version. -h2a switch added. 2.61.11 26/11/1998 ARJ/2 2.61.10 would cause exception 0Dh if ARJ$DISP is killed from the task list. The "clear screen" ANSI sequence now works. 2.61.12 06/12/1998 "ARJ M" fixup, code size decreased. 2.61.13 13/12/1998 ARJ/2 now also works under Windows NT. 2.61.14 31/12/1998 Minor fixes. 2.62.01 03/01/1999 First alpha version. 2.62.02 09/01/1999 Retail version. Minor fixes in the message section. 2.62.03 12/01/1999 ARJ/2 v 2.62 crashed under Windows NT when creating directories. ARJSFX/ARJSFXV might come into loop on some LFN archives. ARJ/2 might crash if LFN goes beyond 131 chars. 2.62.04 24/02/1999 Various problems with ANSI comments were fixed. Some documentation enhancements. 2.62.05 01/05/1999 ARJSFXV v 2.62c has been introduced. The 5-second delays in SFX modules have been eliminated. 2.62.06 17/06/1999 Integrity test (ARJ I) is now operable. 2.62.07 23/08/1999 ARJ i reported damage in earlier versions of ARJ/2. Modified file seek logic for newer IFS. The ARJ/2 distribution archive is now ARJ-SECURED. 2.62.08 29/08/1999 Fixed header comment corruption problem. Fixed problem with free space detection on FAT volumes larger than 1G. Enabled custom environment variable setting (-+). Added support for spaces in filenames. Changed default extension to lowercase ".arj". Resurrected the -& error handling option. Volume labels are now saved and restored. Removed Windows NT checking and host OS stamping to avoid confusion with native ARJ32 archives. Packaged a full set of ARJ utilities. 2.62.09 04/09/1999 Fixed problems introduced in 2.62.08: destination directory parsing and ARJSFX stack corruption 2.62.10 15/09/1999 Timestamps are now restored upon directory creation. Added support for extended attributes to ARJ and ARJSFXV. Fixed a problem with directories being mishandled by ARJSFXV. 2.62.11 22/09/1999 Added check for encryption when creating SFX archives. Fixed chapter mark creation with EAs enabled. Fixed to allow commenting of any ARJ chapters. Added check for files larger than 2048M. Fixed volume handling of "hollow" archives ("-j#"). Fixed handling of encrypted archives with the "j" and "y" commands. Disabled volume prompting when a volume is not an ARJ archive. Changed multi-volume function to automatically handle volumes over 99. Implemented internal ARJ-PROTECT storage as in ARJ32 v 3.02. 2.62.12 26/09/1999 Fixed "CRC error" reported for some multivolume EAs. Fixed EAs being lost in multivolume ARJ-SECURED archives. Verbose list command now skips EA records if they are garbled and no password is given. 2.70.01 05/10/1999 Changed error message display. Fixed to work in xterm of XFree86 for OS/2. Fixed possible loop when -hk is used with multivolume option. Fixed a problem with temporary archive not being deleted when no files are added. Fixed ARJ-PROTECT percentage report. Fixed "Bad header" error when running "ARJ x -d". Fixed search pattern query in "ARJ w". 2.70.02 25/10/1999 Fixed date/time stamping in ARJSFXJR. Removed M_UNREG_SFX from commercial modules. Fixed recursive repacking in REARJ. Added custom -h# format feature. Added comment compatibility option. 2.70.03 31/10/1999 Added day number option to -h#. 2.70.04 06/11/1999 Fixed extracted file postprocessing. Added automatic testing of ungarbled archives. Fixed chapter command parsing from the configuration file. Added default configuration file lookup. Fixed garble password prompting. Corrected to work with EXT2FS.IFS. 2.70.05 31/12/1999 Fixed rare "Can't find ..." errors when parsing list file. The SFX executables are now compressed with standard EXEPACK. Introduced new ARJ registration scheme. Added ARJ.KEY registration file lookup. Fixed "clear to end of line" ANSI sequence handling. Fixed "Out of memory" errors appearing after a long sequence of archive volumes. Fixed abnormal effects when extracting damaged archives. Fixed timestamp handling during extraction. Fixed recursive verification with /G in REARJ. REARJ/2 has been updated to version 2.42. 2.70.06 02/01/2000 Minor optimizations of the compression procedure. 2.70.07 06/01/2000 Added "-2L" option for .LONGNAME EA conversion on archiving. The "/J" option was not properly working in registered REARJ/2. 2.70.08 07/01/2000 Fixed a problem with valid registration keys being rejected by ARJ/2. 2.70.09 14/02/2000 Changed "-ha" option to skip read-only attributes on packing. Fixed century display in dates beyond 2000. Added "-2k" switch to skip century display in list commands. Fixed parsing of the "-v...K" and "-v...M" size modifiers. 2.71.01 19/03/2000 Fixed license information display in ARJSFXJR. Changed REGISTER.EXE to use "-arj" and "-arj32" options instead of "-all". Changed the meaning of the "-s"option of ARJSFXV to enable file sharing. Fixed the count of long filenames across volumes. Added an alternate multivolume archive naming feature. 2.71.02 25/03/2000 Fixed file handle deficiency (occured in 2.70.09 and 2.71.01) 2.71.03 29/03/2000 Fixed abnormal behavior of -b and -b2 switches. 2.71.04 28/05/2000 Moved a part of assembly code to C (up to send_block) 2.71.05 27/06/2000 Slightly optimized the compression engine. 2.71.06 03/08/2000 Fixed looping on self-pointing headers. 2.72.01 16/06/2000 Reproduced basic STDOUT concepts 2.72.02 02/07/2000 Switched to C versions of huf_encode_*() 2.72.03 10/08/2000 Commercial versions now never expire. Fixed a minor cosmetic display issue when using the "-t1" option. 2.72.04 11/08/2000 Implemented the CFA internal filelist format. 2.72.05 15/08/2000 Fixed the filelist overrun glitch (occured in version 2.72.03+ but has its roots back in the earliest builds!). Fixed abnormal handling of "-*". Fixed damaged archives resulting from -m4. 2.72.06 18/08/2000 Added option checks when modifying an existing self-extracting archive. Modified ARJ version messages for compatibility with Winzip. Fixed multiple volume diskette updating to work properly when a work directory is specified. Fixed rare issue of ARJ building an empty archive as the last of a series of volumes. Fixed the ARJSFX self-extractor to detect and display an ARJ-SECURITY envelope. Fixed the "jc" extract count option to work with volume split files. Fixed a problem using "-js" in ARJ_SW/ARJ32_SW and on the command line. Changed the "l"ist command to show " 00" for year 2000 and "100" for year 2100. Added a "-2k1" switch for non-ambiguous date formatting. Added "-hy1" and "-hy2" options to force OEM/ANSI codepage settings. Fixed garbling to accept "-hg" when garbling an existing ungarbled archive. Modified help display not to display milestone indicators. ARJCRYPT has been updated to version 2.1. 2.72.07 18/08/2000 The same as 2.72.06 but real hot-fix GA. Fixed ARJSFX hash table and comment formatting bugs. 2.72.08 18/08/2000 Merged with 2.71.05...2.71.06 branch. 2.73.01 19/08/2000 Minor modifications of the message section. Added "-" symbol option to ARJ configuration file to work like "+" symbol except with prepending of its associated switch string. Fixed volume size handling during update of ARJ-PROTECTED volumes. Corrected total file count output on list command. Fixed the purging "k" of chapter volumes. Fixed volume series breakups. Fixed a problem with the "-vw" option when updating a volume. Fixed alignment on verbose list command. Corrected "-i3" and "-i6" total percentage counts for multiple volumes. Fixed the "-jc" extract count option to terminate prompting for unneeded volumes. Fixed looping when using "-va" on large partitions. 2.73.02 19/08/2000 The distribution version of 2.73.01 (contains mostly DOS-related fixes). 2.75.01 09/09/2000 Restored the C version of encode_f() (this finally frees us from RTL usage in ASM modules). Official release. 2.75.02 15/09/2000 Removed references to M_MALICIOUS_ARCV fix from the documentation. Slightly optimized the ARJ-SECURITY verification routine. Began rewriting the assembly routines in 32-bit compatible way. 2.75.03 30/09/2000 Low-level interface routines have been portabilized. 2.75.04 15/10/2000 Portabilized the encoding/decoding routines. 2.75.05 18/10/2000 Introduced the OS/2-32 version. Made the appropriate changes to various source and documentation files. 2.75.06 18/10/2000 DOS and Borland fixes. 2.75.07 20/10/2000 Fixed processing of volumes beyond 99 in ARJSFXV. 2.75.08 24/10/2000 Automation Release #1. Added the packaging tool. 2.75.09 27/10/2000 Automation Release #2. Clean-up and minor fixes. 2.75.10 28/10/2000 Automation Release #3. Concurrent compiles. 2.75.11 29/10/2000 Automation Release #4. Added IBM LIBC option. Fixed intermittent traps on startup of ARJSFXV. 2.75.12 03/11/2000 Automation Release #5. Multiplatform READMEs. 2.75.13 17/12/2000 Fixed a problem with the "-vw" whole file volume option looping. Fixed a "-i3"/"-i6" milestone percentage problem with the "-vw" option. Fixed the "Y" command to allow "-hk" and "-g" simultaneously. Changed "-q" option to NOT continue to query about extracting subsequent sections of a split file. 2.75.14 31/12/2000 Fixed LOCALE branches in ARJ_DATA.C. 2.75.15 09/01/2001 Added "-2f" option to avoid serialization of comments. 2.75.16 15/01/2001 Fixed volume size parsing when specified with "-vxxxK" or "-vxxxM". 2.75.17 05/02/2001 Fixed overwriting of existing EAs in 32-bit OS/2 version. 2.75.18 21/02/2001 Fixed crashes when loading the ARJCRYPT module. Fixed crashes in 32-bit OS/2 version if an incorrect date results from -odb. Added creation and packaging of debug symbols and map files. 2.75.19 07/04/2001 Improved debugging for header errors. [Merged with MetaWare branch up to arj-2_75_18_3]: Fixed displaying files with ARJ p -ja. Fixed possible errors on termination of ARJSFX/ARJSFXV. 2.75.20 11/05/2001 Fixed handling of /A option (with no archive types specified) by REARJ. 2.75.21 04/06/2001 Fixed volume size calculation. 2.76.01 25/01/2001 Raised the filelist limit in commercial versions. Changed the storage order of subdirectories to retain timestamps on extraction. 2.76.02 28/01/2001 Fixed matching for "[xxx]" wildcards when -h* is given. 2.76.03 19/06/2001 Merged with later 2.75 builds, yielding a separate post-2.76.02 sparse tree. 2.76.04 21/06/2001 Added a free memory check for DOS version. Fixed the "r" command to remove paths properly in dual-name archives. Fixed an error processing directories with very long filenames. Fixed ARJSFXV to NOT beep when using options to inhibit volume prompting. Fixed ARJSFXV to work with an archive that contains the encryption module. Fixed phantom EA records. 2.76.05 24/06/2001 Changed order of password prompt in the large self-extractors. 2.76.06 15/08/2001 Fixed launch of DOS archivers from REARJ. ARJSFX now automatically enables the VIO ANSI support for comments. Fixed error messages appearing when -hk is used with -va. Added a way to specify priority deltas. Made some performance enhancements to the -m4 extractor. 2.76.07 25/08/2001 Added handling of the new (revision 11) timestamp format. 2.77.01 01/09/2001 ARJDISP is now being called instead of ARJ$DISP as the display front-end. ARJ.CFG syntax was enhanced to allow comments ('#' as the first character on a line). Preliminary support for UNIX-like platforms. REARJ has been enhanced with a "T" modifier. Fixed the parsing of -t1g. Specifying -t0 on extraction will retain the 8th bit. 2.77.02 06/09/2001 Fixed file mode conversion to the DOS format. Fixed ARJCRYPT incompatibility. Fixed deletion of special files. Fixed "-2a" to work correctly with the ".*" files. 2.77.03 07/09/2001 Fixed DOS->UNIX timestamp conversions. 2.77.04 09/09/2001 Fixed -hk protection block size calculation. Fixed the updating of archives with extended headers. 2.77.05 15/09/2001 Fixed the display of archive dates in DOS and OS/2 versions of ARJ. Fixed some EXT_HDR regressions in 16-bit mode. 2.77.06 23/10/2001 Fixed handling of "-2f". Removed the dependence of /usr/bin path in UNIX platforms. Changed the names of configuration files in home directory to be prepended with '.'. 2.78.01 27/03/2002 Merged with German NLS branch. Fixed the "-i5" indicator to show correct percentage at the beginning of each file. 2.78.02 09/04/2002 Official Open Source release. 2.78.03 03/05/2002 Fixed modification timestamping in main archive header. 2.78.04 15/05/2002 Fixed handling of "+" and "-" in ARJ.CFG (regression from 2.73.01) 2.78.05 06/07/2002 Fixed timestamp handling. Fixed crash at startup with "ARJ Q" and no other arguments. Added "-d1" and "-d2" options. 2.78.06 14/12/2002 Fixed "Out of memory" type errors on UNIX-like platforms. 2.78.07 25/01/2003 Fixed ARJCRYPT key generation (regression from 2.77.02). Added preliminary support for Win32 platform. 2.78.08 07/02/2003 Install into /usr/local by default on UNIX-like platforms. Determine the number of lines on screen for -jp where possible (DOS, OS/2 VIO and Win32). Experimental color output in a JAR style: 1. "-*2" gets obsoleted. "-*1" designates a "silent" mode (all error msgs suppressed), "-*" stands for the "normal" mode (error msgs still displayed). 2. ARJ has "-2t" switch to set the colors. "-2t" alone will disable the color support; "- -2t" in ARJ.CFG is recommended to turn it off for all commands. 3. REARJ has a "COLORS " configuration parameter. REARJ updated to 2.43 - allow arbitrary positioning of parameters within the configuration file. Fixed looping on symlinked directories without "-a1". Added the "-2b" parameter to specify reference devices. German locale: "ge" -> "de". Fixed to display error messages properly under Win32. 2.78.09 31/03/2003 Prevent "ghost" progress indicator from appearing on the screen. Added hardlink to symlink conversion. Removed counter granularity (actually, it's 26624 now in the most cases instead of 40960). Added the "-2r" parameter to revert to the "standard" unarchiving order. 2.78.10 03/04/2003 Workaround for stack/near memory shortage in 16-bit versions. 2.78.11 06/04/2003 Fixed several options being disabled in REARJ. Fixed stack overrun during directory recursion in 32-bit OS/2 (except EMX). 2.78.12 12/04/2003 Fixed a possible incompatibility with mainstream ARJ when using the "-hg" or "-hg!" encryption. 2.78.13 11/05/2003 Revised build and packaging on GNU systems after a patch from Guillem Jover : * The build system honours DESTDIR, so our packaging is easier. * Updated configure.in. * The arjcrypt module is moved to its own dir under $libdir ($pkglibdir). * The join program now return proper exit codes. It was causing the autobuilders to fail on some architectures. * Man pages provided. * The rearj.cfg.example now supplies the correct bzip2 options. Changed the OS/2 version to use the same canonical wildcard matching logic as the Win32 one. Fixed "-jp" being inoperable (regression from 2.78.08). Fixed the unintentional fallback to ARJCRYPT V1 when ARJCRYPT V2 ought to be used. Displays the safety factor in ARJ-PROTECT notice. Fixed the "arj o" command (regression from 2.62.08). 2.78.14 14/05/2003 Fixed REARJ terminating with an error when the configuration file is padded with blank lines. 2.78.15 30/06/2003 Fixed the "-i" overall progress indicators to not count the skipped files. Fixed "double skip" with "-2b" when the first file to be skipped was surrounded by symlinks. Fixed to ignore symlink access attributes. Workaround for EA size query during extraction on OS/2-32. Fixed various problems with updating extended headers (regression from 2.77.01). 2.78.16 15/07/2003 Added "-2o2" to save a symbolic representation of both UID and GID when archiving. 2.78.17 14/09/2003 Skip changing the archive attributes under UNIX. Optimized the progress counter performance by avoiding unnecessary output. 2.78.18 16/10/2003 Re-fix the attributes patch for 2.78.17 to make the SFX attributes correspond to the current umask. 2.78.19 21/02/2004 Do not ask for pause when "arj -?" is redirected. "-t1g" replaces the non-trivial "-t1gf". Bell is handled correctly with the new console output. Corrected lookup for arjcrypt.so on UNIX-like platforms (regression from 2.78.13). Archiving with "-2l" on platforms without EA support would produce malformed filenames. Added the "-_" option to store/restore filenames in lowercase. 2.78.20 18/04/2004 Prevent the -jz comments from being automatically appended with newline. "-jb" failed to pick the requested chapters (regression from 2.62.08). 2.78.21 18/06/2004 Registration wizard reported error on many platforms (regression from 2.78.15). Fixed OEM/ANSI discrepancies that showed up in Win32 version when obtaining filenames from argv[]. Copying temporary files with "-jt" enabled might result in a "CRC error". Added "-2i". Introduced new modifiers (G/T/P/E) and hexadecimal prefix format to numeric parameters. Fixed the inability to sustain binary mode for "arj p" under OS/2-32. 2.78.22 23/06/2005 Redesigned the year 2038 workarond to fix wrong date/time in ARJ headers under OS/2 and Win32 (regression from 2.77.05). Fixed TAB character handling in display routines. Compiler/portability-related fixes. arj-3.10.22/doc/xlation.txt 666 0 0 2751 7450456730 11630 0ustar $Id: xlation.txt,v 1.1.1.1 2002/03/28 00:03:37 andrew_belov Exp $ ARJ TRANSLATION GUIDELINES "\n", "\r" and all other symbols prefixed with "\\" indicate special characters and should be retained. The list of files that should be attended by translators follows: * ARJDATA.C General locale information, date formats, etc. * PACKAGER.C Contains message resources used when creating distribution SFX archives. The items to be translated can be located by "#if LOCALE=" pattern.. * RESOURCE\H*.TXT These files are displayed when a help switch is invoked. The only rule is to stay within 80 columns. * RESOURCE\RESOURCE.TXT One-line ARJ messages are held here. The format may seem complicated but the common rule is that English text goes first in the quotes. A "{*}" marker instead of language list ("{en, fr, ...}") means that the message is language-independent so there's no need to translate it. Important note: where "%s", "%d" and "%lu" markers are met, the translated text must have them placed in same order as the original (e.g., if a message says "....%u bytes in %u files..." it may NOT be rewritten as "...%u files consume %u bytes..."). * RESOURCE\en\*.TXT * RESOURCE\en\FILE_ID.DIZ These are end-user README, help and description files. arj-3.10.22/ea_mgr.c 666 0 0 45365 10040213576 10276 0ustar /* * $Id: ea_mgr.c,v 1.4 2004/04/17 11:39:43 andrew_belov Exp $ * --------------------------------------------------------------------------- * This file provides basic routines for handling extended attributes. * */ #include "arj.h" DEBUGHDR(__FILE__) /* Debug information block */ /* OS/2 v 1.2 structure declarations for Win32 */ #if TARGET==WIN32 typedef struct _FEA { BYTE fEA; /* flags */ BYTE cbName; /* name length not including NULL */ WORD cbValue; /* value length */ } FEA; typedef FEA FAR *PFEA; /* flags for _FEA.fEA */ #define FEA_NEEDEA 0x80 /* need EA bit */ typedef struct _FEALIST { DWORD cbList; /* total bytes of structure inc full list */ FEA list[1]; /* variable length FEA structures */ } FEALIST; typedef FEALIST FAR * PFEALIST; #endif /* Local variables */ #if defined(HAVE_EAS) static char longname_ea[]=".LONGNAME"; static char forbidden_chars[]="\\/:?*<>|"; #endif /* Aligns any address to DWORD */ #if (TARGET==OS2&&defined(__32BIT__))||TARGET==WIN32 static char FAR *align_dword(char FAR *p) { unsigned int p_l; p_l=(unsigned int)p; if(p_l%4==0) return(p); else return(p+4-(p_l%4)); } #endif /* Returns 1 if the EA is to be included/processed */ #if SFX_LEVEL>=ARJ&&defined(HAVE_EAS) static int ea_filter(char FAR *name, int skip_ln) { char tmp_name[CCHMAXPATH]; far_strcpy((char FAR *)tmp_name, name); if(skip_ln&&!stricmp(tmp_name, longname_ea)) return(0); if(include_eas&&!flist_find(&flist_ea, tmp_name)) return(0); if(exclude_eas&&flist_find(&flist_xea, tmp_name)) return(0); return(1); } #endif /* Returns size of extended attributes attached to file */ unsigned int get_ea_size(char *name) { #if TARGET==OS2 #ifdef __32BIT__ FILESTATUS4 fs; #else FILESTATUS2 fs; #endif unsigned int rc; #ifdef __32BIT__ DosQueryPathInfo(name, FIL_QUERYEASIZE, (PVOID)&fs, sizeof(fs)); #else DosQPathInfo(name, FIL_QUERYEASIZE, (PVOID)&fs, sizeof(fs), 0L); #endif rc=(fs.cbList>=4)?fs.cbList-4:fs.cbList; #ifdef __32BIT__ rc>>=1; /* BUGBUG? */ #endif return(rc); #elif TARGET==WIN32 struct nt_sid *sid; unsigned long rc; if(!ea_supported||(sid=open_streams(name, 0))==NULL) return(0); rc=seek_stream_id(BACKUP_EA_DATA, sid); close_streams(sid); return((rc>0xFFFF)?0:rc); #else return(0); #endif } /* Returns EA block size */ unsigned int get_eablk_size(char FAR *blk) { unsigned int rc; unsigned int i, total, data_len; char FAR *blk_ptr; total=mget_word(blk); rc=2; blk_ptr=blk+2; for(i=0; iszName) consumes (pdena->cbValue) bytes */ #ifdef __32BIT__ eaop.fpFEA2List=pfeal; pfeal->list[0].oNextEntryOffset=0; #else eaop.fpFEAList=pfeal; #endif pfeal->list[0].fEA=0; pfeal->list[0].cbName=far_strlen(pdena->szName); pfeal->list[0].cbValue=0; #ifdef __32BIT__ far_strcpy((char FAR *)&(pfeal->list[0])+sizeof(FEA2)-1, pdena->szName); pfeal->cbList=(unsigned long)sizeof(FEA2LIST)+pfeal->list[0].cbName; if((rc=DosSetPathInfo(name, FIL_QUERYEASIZE, (PBYTE)&eaop, sizeof(eaop), 0))!=0) { rcode=-1; break; } #else far_strcpy((char FAR *)&(pfeal->list[0])+sizeof(FEA), pdena->szName); pfeal->cbList=(unsigned long)sizeof(FEALIST)+pfeal->list[0].cbName+1; if((rc=DosSetPathInfo(name, FIL_QUERYEASIZE, (PBYTE)&eaop, sizeof(eaop), 0, 0L))!=0) { rcode=-1; break; } #endif } farfree(pdena); #ifndef TILED farfree(real_pfeal); #endif return(rcode); #elif TARGET==WIN32 /* There seems to be no easy way to not purge EAs using the backup APIs! */ return(0); #else return(-1); #endif } /* Allocates memory for and stores extended attributes */ #if SFX_LEVEL>=ARJ int query_ea(char FAR **dest, char *name, int skip_ln) { #ifdef HAVE_EAS ULONG count, j; #if TARGET==OS2 #ifdef __32BIT__ EAOP2 eaop; PGEA2LIST pgeal; PFEA2LIST pfeal; APIRET rc; PDENA2 pdena; FILESTATUS4 fs; #else EAOP eaop; PGEALIST pgeal; PFEALIST pfeal; USHORT rc; PDENA1 pdena; FILESTATUS2 fs; #endif #elif TARGET==WIN32 struct nt_sid *sid; unsigned char *streambuf; unsigned long stream_len; PFEALIST pfeal; #endif int rcode=0; char FAR *dptr, FAR *nptr; #if TARGET==OS2 pdena=farmalloc_msg(sizeof(*pdena)+CCHMAXPATHCOMP); #ifdef __32BIT__ pgeal=(PGEA2LIST)farmalloc_msg(sizeof(GEA2LIST)+CCHMAXPATHCOMP); if(DosQueryPathInfo(name, FIL_QUERYEASIZE, (PVOID)&fs, sizeof(fs))) return(-1); #else pgeal=(PGEALIST)farmalloc_msg(sizeof(GEALIST)+CCHMAXPATHCOMP); if(DosQPathInfo(name, FIL_QUERYEASIZE, (PVOID)&fs, sizeof(fs), 0L)) return(-1); #endif if(fs.cbList<4) fs.cbList=4; /* Fix for Ext2FS */ /* Allocate enough space to hold EA block */ #ifdef __32BIT__ *dest=(char FAR *)farmalloc_msg((int)fs.cbList*2); /* SDK does recommend it */ #else *dest=(char FAR *)farmalloc_msg((int)fs.cbList-2); #endif #elif TARGET==WIN32 if((sid=open_streams(name, 0))==NULL) return(-1); stream_len=seek_stream_id(BACKUP_EA_DATA, sid); if(stream_len==0||stream_len>65535) { close_streams(sid); *dest=(char FAR *)farmalloc_msg(2); dptr=*dest; mput_word(0, dptr); return(0); } /* It's a plain FEALIST, so doesn't require much caution */ streambuf=(char FAR *)farmalloc_msg((int)stream_len); *dest=(char FAR *)farmalloc_msg((int)stream_len); if((stream_len=read_stream(streambuf, stream_len, sid))==0) { close_streams(sid); dptr=*dest; mput_word(0, dptr); free(streambuf); return(0); } #endif /* Initialize storage */ dptr=*dest; mput_word(0, dptr); dptr+=2; j=0L; while(1) { #if TARGET==OS2 count=1L; #ifdef __32BIT__ if(DosEnumAttribute(ENUMEA_REFTYPE_PATH, (PVOID)name, ++j, (PVOID)pdena, sizeof(*pdena)+CCHMAXPATHCOMP, &count, ENUMEA_LEVEL_NO_VALUE)) break; #else if(DosEnumAttribute(ENUMEA_REFTYPE_PATH, (PVOID)name, ++j, (PVOID)pdena, sizeof(*pdena)+CCHMAXPATHCOMP, &count, ENUMEA_LEVEL_NO_VALUE, 0L)) break; #endif if(count==0L) break; /* EA (pdena->szName) consumes (pdena->cbValue) bytes */ #ifdef __32BIT__ eaop.fpGEA2List=pgeal; #else eaop.fpGEAList=pgeal; #endif far_strcpy(pgeal->list[0].szName, pdena->szName); pgeal->list[0].cbName=pdena->cbName; #ifdef __32BIT__ pgeal->list[0].oNextEntryOffset=0; pgeal->cbList=sizeof(GEA2LIST)+pdena->cbName; eaop.fpGEA2List=pgeal; pfeal=(PFEA2LIST)farmalloc_msg(sizeof(FEA2LIST)+pdena->cbName+pdena->cbValue+1); pfeal->cbList=sizeof(FEA2LIST)+pdena->cbName+pdena->cbValue+1; eaop.fpFEA2List=pfeal; if((rc=DosQueryPathInfo(name, FIL_QUERYEASFROMLIST, (PBYTE)&eaop, sizeof(eaop)))!=0) { farfree(pfeal); rcode=-1; break; } nptr=(char FAR *)&(pfeal->list[0])+sizeof(FEA2)-1; #else pgeal->cbList=sizeof(GEALIST)+pdena->cbName; eaop.fpGEAList=pgeal; pfeal=(PFEALIST)farmalloc_msg(sizeof(FEALIST)+pdena->cbName+pdena->cbValue+1); pfeal->cbList=sizeof(FEALIST)+pdena->cbName+pdena->cbValue+1; eaop.fpFEAList=pfeal; if((rc=DosQPathInfo(name, FIL_QUERYEASFROMLIST, (PBYTE)&eaop, sizeof(eaop), 0L))!=0) { farfree(pfeal); rcode=-1; break; } nptr=(char FAR *)&(pfeal->list[0])+sizeof(FEA); #endif #elif TARGET==WIN32 /* Win32 provides us with a FEALIST at our disposal. */ pfeal=(PFEALIST)streambuf; nptr=(char FAR *)&(pfeal->list[0])+sizeof(FEA); #endif #if SFX_LEVEL>=ARJ if(ea_filter(nptr, skip_ln)&&((pfeal->list[0].fEA&FEA_NEEDEA)||!crit_eas)) #endif { mput_word(mget_word(*dest)+1, *dest); mput_byte(pfeal->list[0].fEA, dptr++); mput_byte(pfeal->list[0].cbName, dptr++); mput_word(pfeal->list[0].cbValue, dptr); dptr+=2; far_memmove(dptr, nptr, (int)pfeal->list[0].cbName); dptr+=pfeal->list[0].cbName; far_memmove(dptr, nptr+pfeal->list[0].cbName+1, pfeal->list[0].cbValue); dptr+=pfeal->list[0].cbValue; } #if TARGET==OS2 farfree(pfeal); #elif TARGET==WIN32 if(pfeal->cbList==0) /* Indicates the last EA */ break; streambuf+=pfeal->cbList; #endif } #if TARGET==OS2 farfree(pdena); farfree(pgeal); #endif #if TARGET==WIN32 close_streams(sid); #endif return(rcode); #else return(-1); #endif } #endif /* setea() routine */ int set_ea(char FAR *i_eas, char *name) { #ifdef HAVE_EAS int rc=0; char FAR *eas; unsigned int i, total; #if TARGET==OS2 #ifdef __32BIT__ FILESTATUS4 fs; EAOP2 eaop; char FAR *real_pfeal; PFEA2LIST pfeal; PFEA2 pf, opf; #else EAOP eaop; PFEALIST pfeal; PFEA pf; FILESTATUS2 fs; SEL selector; #endif #elif TARGET==WIN32 PFEALIST pfeal0, pfeal; PFEA pf; struct nt_sid *sid; unsigned char *pstreambuf, *streambuf; WIN32_STREAM_ID w32sid; unsigned long stream_len; #endif eas=i_eas; if(discard_ea(name)) return(-1); if((total=mget_word(eas))==0) return(0); #if TARGET==OS2 #ifdef __32BIT__ /* This takes the 4-byte prefixes into account (are the V1.2 EAs still valid if they flow beyond 64K when the oNextEntryOffset is applied?). Also, we ensure that it is aligned properly. In theory, there may be a way to crash this (72K doesn't consider the multitude of EAs) but we don't know/care about it -- ASR 17/10/2000 */ real_pfeal=(char FAR *)farmalloc_msg(73728); pfeal=(PFEA2LIST)align_dword(real_pfeal); eaop.fpFEA2List=pfeal; #else if(DosAllocSeg(65535U, &selector, SEG_NONSHARED)) return(-1); pfeal=(PFEALIST)MAKEP(selector, 0); eaop.fpFEAList=pfeal; #endif #elif TARGET==WIN32 pstreambuf=(char *)farmalloc_msg(65536+260*total); pfeal=pfeal0=(PFEALIST)(streambuf=align_dword(pstreambuf)); #endif eas+=2; pf=&pfeal->list[0]; for(i=0; ilist[0]; #endif pf->fEA=mget_byte(eas++); pf->cbName=mget_byte(eas++); pf->cbValue=mget_word(eas); eas+=2; #if TARGET==OS2&&defined(__32BIT__) far_memmove((char FAR *)pf+sizeof(FEA2)-1, eas, pf->cbName); *((char FAR *)pf+sizeof(FEA2)-1+pf->cbName)='\0'; #else /* Win32 or OS/2-16 */ far_memmove((char FAR *)pf+sizeof(FEA), eas, pf->cbName); *((char FAR *)pf+sizeof(FEA)+pf->cbName)='\0'; #endif eas+=pf->cbName; #if TARGET==OS2&&defined(__32BIT__) far_memmove((char FAR *)pf+sizeof(FEA2)+pf->cbName, eas, pf->cbValue); #else /* Win32 or OS/2-16 */ far_memmove((char FAR *)pf+sizeof(FEA)+pf->cbName+1, eas, pf->cbValue); #endif eas+=pf->cbValue; #if SFX_LEVEL>=ARJ #if TARGET==OS2&&defined(__32BIT__) if(ea_filter((char FAR *)pf+sizeof(FEA2), 0)&&((pf->fEA&FEA_NEEDEA)||!crit_eas)) #else /* Win32 or OS/2-16 */ if(ea_filter((char FAR *)pf+sizeof(FEA), 0)&&((pf->fEA&FEA_NEEDEA)||!crit_eas)) #endif #endif /* Update the offsets */ #if TARGET==OS2 #ifdef __32BIT__ pf=(PFEA2)((char FAR *)pf+sizeof(FEA2)+pf->cbName+pf->cbValue); #else pf=(PFEA)((char FAR *)pf+sizeof(FEA)+pf->cbName+1+pf->cbValue); #endif /* Align at DWORD boundary and issue the list fixups */ #ifdef __32BIT__ pf=(PFEA2)align_dword((char FAR *)pf); opf->oNextEntryOffset=(i+1==total)?0:(char FAR *)pf-(char FAR *)opf; #endif #elif TARGET==WIN32 pfeal=(PFEALIST)((char FAR *)pfeal+sizeof(FEALIST)+pf->cbName+1+pf->cbValue); if(icbList=(i==total-1)? 0: (((char FAR *)pfeal)-((char FAR *)pfeal0)); pfeal0=pfeal; #endif } #if TARGET==OS2 pfeal->cbList=(char FAR *)pf-(char FAR *)pfeal; #ifdef __32BIT__ rc=DosSetPathInfo((PSZ)name, FIL_QUERYEASIZE, (PBYTE)&eaop, sizeof(eaop), 0); farfree(real_pfeal); #else rc=DosSetPathInfo((PSZ)name, FIL_QUERYEASIZE, (PBYTE)&eaop, sizeof(eaop), 0, 0L); DosFreeSeg(selector); #endif if(!rc) { #ifdef __32BIT__ if(DosQueryPathInfo(name, FIL_QUERYEASIZE, (PVOID)&fs, sizeof(fs))) #else if(DosQPathInfo(name, FIL_QUERYEASIZE, (PVOID)&fs, sizeof(fs), 0L)) #endif rc=-1; else if(fs.cbList<=4) rc=-1; } #elif TARGET==WIN32 if((sid=open_streams(name, 1))==NULL) rc=-1; else { memset(&w32sid, 0, sizeof(w32sid)); w32sid.dwStreamId=BACKUP_EA_DATA; w32sid.Size.LowPart=stream_len=(((char FAR *)pfeal)-streambuf); if(create_stream(&w32sid, sid)||write_stream(streambuf, stream_len, sid)=ARJ int resolve_longname(char *dest, char *name) { #ifdef HAVE_EAS unsigned char *tmp_name; int entry, l_sel, rc; #if TARGET==OS2 #ifdef __32BIT__ EAOP2 eaop; PGEA2LIST pgeal; PFEA2LIST pfeal; #else EAOP eaop; PGEALIST pgeal; PFEALIST pfeal; #endif #elif TARGET==WIN32 struct nt_sid *sid=NULL; unsigned char *streambuf=NULL; unsigned long stream_len, rem_len, fetch; FEALIST feal; PFEALIST pfeal; #endif char FAR *valptr; unsigned int st_len; if(name[0]=='\0'||name[0]==PATHSEP_DEFAULT&&name[1]=='\0'||name[1]==':'&&name[2]=='\0') { strcpy(dest, name); return(0); } tmp_name=(char *)malloc_msg(FILENAME_MAX); l_sel=entry=split_name(name, tmp_name, NULL); if(entry>0) { tmp_name[entry-1]='\0'; resolve_longname(dest, tmp_name); entry=strlen(dest); dest[entry]=PATHSEP_DEFAULT; dest[entry+1]='\0'; } else dest[0]='\0'; #if TARGET==OS2 #ifdef __32BIT__ pgeal=(PGEA2LIST)farmalloc_msg(sizeof(GEA2LIST)+sizeof(longname_ea)); pfeal=(PFEA2LIST)farmalloc_msg(sizeof(FEA2LIST)+sizeof(longname_ea)+FILENAME_MAX); #else pgeal=(PGEALIST)farmalloc_msg(sizeof(GEALIST)+sizeof(longname_ea)); pfeal=(PFEALIST)farmalloc_msg(sizeof(FEALIST)+sizeof(longname_ea)+FILENAME_MAX); #endif far_strcpy(pgeal->list[0].szName, (char FAR *)longname_ea); #elif TARGET==WIN32 pfeal=(PFEALIST)farmalloc_msg(sizeof(FEALIST)+sizeof(longname_ea)+FILENAME_MAX); #endif #if TARGET==OS2 #ifdef __32BIT__ pgeal->list[0].oNextEntryOffset=0; #endif pgeal->list[0].cbName=sizeof(longname_ea)-1; #ifdef __32BIT__ pgeal->cbList=sizeof(GEA2LIST)+sizeof(longname_ea)-1; pfeal->cbList=sizeof(FEA2LIST)+sizeof(longname_ea)+FILENAME_MAX-1-entry; eaop.fpGEA2List=pgeal; eaop.fpFEA2List=pfeal; #else pgeal->cbList=sizeof(GEALIST)+sizeof(longname_ea)-1; pfeal->cbList=sizeof(FEALIST)+sizeof(longname_ea)+FILENAME_MAX-1-entry; eaop.fpGEAList=pgeal; eaop.fpFEAList=pfeal; #endif #ifdef __32BIT__ if(DosQueryPathInfo(name, FIL_QUERYEASFROMLIST, (PBYTE)&eaop, sizeof(eaop))) #else if(DosQPathInfo(name, FIL_QUERYEASFROMLIST, (PBYTE)&eaop, sizeof(eaop), 0L)) #endif rc=0; else { rc=1; #ifdef __32BIT__ valptr=(char FAR *)pfeal+sizeof(FEA2LIST)+pfeal->list[0].cbName; #else valptr=(char FAR *)pfeal+sizeof(FEALIST)+pfeal->list[0].cbName+1; #endif } #elif TARGET==WIN32 rc=0; if((sid=open_streams(name, 0))!=NULL&& (stream_len=seek_stream_id(BACKUP_EA_DATA, sid))>0) { valptr=streambuf=(char *)farmalloc_msg(256); pfeal=(PFEALIST)&feal; while(read_stream((char *)pfeal, sizeof(FEALIST), sid)==sizeof(FEALIST)&& read_stream(streambuf, pfeal->list[0].cbName+1, sid)==pfeal->list[0].cbName+1) { rem_len=pfeal->cbList-sizeof(FEALIST)-pfeal->list[0].cbName-1; if(!stricmp(streambuf, longname_ea)) { if(pfeal->list[0].cbValue<256) { read_stream(streambuf, pfeal->list[0].cbValue, sid); rc=1; break; } } else { if(pfeal->cbList==0) break; /* Advance to the next EA entry */ while(rem_len>0) { fetch=min(256, rem_len); read_stream(streambuf, fetch, sid); rem_len-=fetch; } } } } #endif if(rc) { if((st_len=pfeal->list[0].cbValue)==0) rc=0; else { far_memmove((char FAR *)tmp_name, valptr, st_len); tmp_name[st_len]='\0'; if(tmp_name[0]==0xFD&&tmp_name[1]==0xFF) { strcpy(tmp_name, (char *)tmp_name+4); st_len-=4; } if(st_len==0||st_len+entry>=FILENAME_MAX) rc=0; else { while(st_len-->0) { if(tmp_name[st_len]<' '||strchr(forbidden_chars, tmp_name[st_len])!=NULL) { rc=0; break; } } } } } if(!rc) { if(strlen(name)+entry+l_sel>=FILENAME_MAX) error(M_MAXPATH_EXCEEDED, FILENAME_MAX, name); strcat(dest, name+l_sel); } else strcat(dest, (char *)tmp_name); #if TARGET==OS2 farfree(pgeal); farfree(pfeal); #elif TARGET==WIN32 if(streambuf!=NULL) farfree(streambuf); if(sid!=NULL) close_streams(sid); #endif free(tmp_name); return(rc); #else return(0); #endif } #endif arj-3.10.22/ea_mgr.h 666 0 0 1140 7450456614 10237 0ustar /* * $Id: ea_mgr.h,v 1.1.1.1 2002/03/28 00:02:20 andrew_belov Exp $ * --------------------------------------------------------------------------- * Prototypes of the functions located in EA_MGR.C are declared here. * * */ #ifndef EA_MGR_INCLUDED #define EA_MGR_INCLUDED unsigned int get_ea_size(char *name); unsigned int get_eablk_size(char FAR *blk); unsigned int get_num_eas(char FAR *blk); int discard_ea(char *name); int query_ea(char FAR **dest, char *name, int skip_ln); int set_ea(char FAR *i_eas, char *name); int detect_ea(char *name); int resolve_longname(char *dest, char *name); #endif arj-3.10.22/encode.c 666 0 0 77343 10056654210 10303 0ustar /* * $Id: encode.c,v 1.7 2004/05/31 16:08:41 andrew_belov Exp $ * --------------------------------------------------------------------------- * The data compression procedures are located in this module. * */ #include "arj.h" #ifdef TILED #include /* Weird, eh? */ #endif DEBUGHDR(__FILE__) /* Debug information block */ static int st_n; unsigned short *c_freq; unsigned short FAR *c_code; unsigned short FAR *heap; unsigned short len_cnt[17]; unsigned short p_freq[2*NP-1]; unsigned short pt_code[NPT]; int depth; unsigned char FAR *buf; unsigned char output_mask; unsigned short output_pos; int dicbit; unsigned short t_freq[2*NT-1]; int heapsize; unsigned short FAR *sortptr; unsigned char *len; unsigned short *freq; unsigned short fpcount; short FAR *fpbuf; short FAR *dtree; unsigned short treesize; unsigned char *tree=NULL; unsigned short numchars; unsigned short dicsiz_cur; unsigned short dicpos; unsigned short tc_passes; short FAR *ftree; unsigned int dic_alloc; unsigned long encoded_bytes; /* Inline functions */ #define encode_c(c) \ putbits(c_len[c], c_code[c]) #define encode_p(p) \ { \ unsigned int qc, q; \ qc=0; \ q=p; \ while(q) \ { \ q>>=1; \ qc++; \ } \ putbits(pt_len[qc], pt_code[qc]); \ if(qc>1) \ putbits(qc-1, p); \ } /* Bitwise output routine */ void putbits(int n_c, unsigned short n_x) { #ifdef ASM8086 asm{ mov cl, byte ptr n_c mov dx, n_x mov ch, cl sub cl, 16 neg cl shl dx, cl mov cl, byte ptr bitcount mov ax, dx shr ax, cl or bitbuf, ax add cl, ch cmp cl, 8 jge chunk1 mov byte ptr bitcount, cl jmp procend } chunk1: asm{ push si mov si, out_bytes cmp si, out_avail jge flush } acc_loop: asm{ mov bx, out_buffer mov ah, byte ptr bitbuf+1 mov [bx+si], ah inc si sub cl, 8 cmp cl, 8 jge avail_chk #if TARGET==OS2 shl bitbuf, 8 #else mov ah, byte ptr bitbuf mov al, 0 mov bitbuf, ax #endif jmp endpoint } avail_chk: asm{ cmp si, out_avail jge r_flush } cpoint: asm{ mov al, byte ptr bitbuf mov [bx+si], al inc si sub cl, 8 sub ch, cl xchg cl, ch shl dx, cl mov bitbuf, dx mov cl, ch jmp endpoint } flush: asm{ push dx push cx } flush_compdata(); asm{ pop cx pop dx mov si, out_bytes jmp short acc_loop } r_flush: asm{ mov out_bytes, si push dx push cx push bx } flush_compdata(); asm{ pop bx pop cx pop dx mov si, out_bytes jmp short cpoint } endpoint: asm{ mov out_bytes, si pop si mov byte ptr bitcount, cl } procend:; #else int p_n; int bt; p_n=n_c; n_c=16-n_c; n_x<<=n_c; n_c=bitcount; bitbuf|=(n_x>>n_c); n_c+=p_n; if(n_c<8) { bitcount=n_c; return; } bt=out_bytes; if(bt>=out_avail) { flush_compdata(); bt=out_bytes; } out_buffer[bt++]=bitbuf>>8; n_c-=8; if(n_c<8) { bitbuf<<=8; out_bytes=bt; bitcount=n_c; return; } if(bt>=out_avail) { out_bytes=bt; flush_compdata(); bt=out_bytes; } out_buffer[bt++]=bitbuf; n_c-=8; p_n-=n_c; bitbuf=n_x<=ARJ int fetch_uncomp(char *dest, int n) { unsigned int fetch_size; if(file_packing) return(fread_crc(dest, n, encstream)); else { if(encmem_remain==0) return(0); fetch_size=min((unsigned int)n, encmem_remain); far_memmove((char FAR *)dest, encblock_ptr, fetch_size); crc32_for_block(dest, fetch_size); encmem_remain-=fetch_size; encblock_ptr+=fetch_size; return(fetch_size); } } #endif /* Fills the length table depending on the leaf depth (call with i==root) */ static void count_len(int i) { static int depth=0; if(i0; i--) cum+=len_cnt[i]<<(16-i); while(cum!=0) { if(debug_enabled&&strchr(debug_opt, 'f')!=NULL) msg_cprintf(0, M_HDF_FIX); len_cnt[16]--; for(i=15; i>0; i--) { if(len_cnt[i]!=0) { len_cnt[i]--; len_cnt[i+1]+=2; break; } } cum--; } for(i=16; i>0; i--) { k=len_cnt[i]; while(--k>=0) len[*sortptr++]=i; } } /* Sends i-th entry down the heap */ static void NEAR downheap(int i) { int j, k; k=heap[i]; while((j=2*i)<=heapsize) { if(jfreq[heap[j+1]]) j++; if(freq[k]<=freq[heap[j]]) break; heap[i]=heap[j]; i=j; } heap[i]=k; } /* Encodes a length table element */ static void NEAR make_code(int n, unsigned char *len, unsigned short FAR *code) { int i; unsigned short start[18]; start[1]=0; for(i=1; i<=16; i++) start[i+1]=(start[i]+len_cnt[i])<<1; for(i=0; i>1; i>=1; i--) downheap(i); /* Make priority queue */ sortptr=codeparm; /* While queue has at least two entries */ do { i=heap[1]; /* Take out least-freq entry */ if(i1); sortptr=codeparm; make_len(k); make_code(nparm, lenparm, codeparm); return(k); /* Return root */ } /* Counts the cumulative frequency */ void count_t_freq() { int i, k, n, count; for(i=0; i0&&c_len[n-1]==0) n--; i=0; while(i0&&pt_len[n-1]==0) n--; putbits(nbit, n); i=0; while(i0&&c_len[n-1]==0) n--; putbits(CBIT, n); i=0; while(i=NC) { count_t_freq(); root=make_tree(NT, t_freq, pt_len, (unsigned short FAR *)pt_code); if(root>=NT) write_pt_len(NT, TBIT, 3); else { putbits(TBIT, 0); putbits(TBIT, root); } write_c_len(); } else { putbits(TBIT, 0); putbits(TBIT, 0); putbits(CBIT, 0); putbits(CBIT, root); } root=make_tree(NP, p_freq, pt_len, (unsigned short FAR *)pt_code); if(root>=NP) write_pt_len(NP, PBIT, -1); else { putbits(PBIT, 0); putbits(PBIT, root); } pos=0; for(i=0; i=0) { tptr=tree+n_c; tdptr=tree+r_bx; r_ax=word_ptr(tptr); r_dx=numchars; if(--r_dx>=0) goto ut_loop; ut_fetch: r_ax=word_ptr(tptr+r_bp-1); select_pos: tdptr=tree+r_bp; do { if(--r_dx<0) goto upd_finish; r_bx=dptr[r_bx]; if(r_bx<0) goto upd_finish; } while(r_ax!=word_ptr(tdptr+r_bx-1)); tdptr+=r_bx-r_bp; ut_loop: #ifdef ALIGN_POINTERS if (_diff(tptr,tdptr)) #else if(word_ptr(tptr)!=word_ptr(tdptr)) #endif goto select_pos; prev_tptr=tptr; prev_tdptr=tdptr; tptr+=2; tdptr+=2; for(c=128; c>0; c--) { #ifdef ALIGN_POINTERS if (_diff(tptr,tdptr)) #else if(word_ptr(tptr)!=word_ptr(tdptr)) #endif break; tptr+=2; tdptr+=2; } diff=*(tdptr)-*(tptr); remainder=tdptr-prev_tdptr; if(diff==0) remainder+=1; tptr=prev_tptr; tdptr=prev_tdptr; if(remainder<=r_bp) goto ut_fetch; if(tptr-tdptr<=dicsiz_cur) { dicpos=tptr-tdptr-1; r_bp=remainder; if(r_bp<256) goto ut_fetch; } upd_finish: if(r_bp>256) r_bp=256; } return(tc_passes=r_bp); #endif } /* Optimized output routine */ static void output(int c, unsigned short p) { unsigned char FAR *bptr; unsigned char cy; unsigned short r_dx; unsigned short r_bx; bptr=buf; r_dx=cpos; cy=output_mask&1; output_mask=(cy?0x80:0)|((output_mask&0xFF)>>1); if(cy) { if(r_dx>=bufsiz) { send_block(); if(unpackable) { cpos=bptr-buf; return; } r_dx=0; } output_pos=r_dx; buf[r_dx]=0; r_dx++; } bptr+=r_dx; *bptr++=c; c_freq[c]++; if(c>=256) { buf[output_pos]|=output_mask; *bptr++=p&0xFF; *bptr++=(p>>8); for(r_bx=0; p!=0; p>>=1) r_bx++; p_freq[r_bx]++; } cpos=bptr-buf; } /* Unstubbed optimized output routine */ static void output_opt(unsigned char c) { unsigned char FAR *bptr, FAR *cptr; unsigned short r_dx; unsigned char cy; cptr=bptr=buf; r_dx=cpos; cy=output_mask&1; output_mask=(cy?0x80:0)|((output_mask&0xFF)>>1); if(cy) { if(r_dx>=bufsiz) { send_block(); r_dx=0; if(unpackable) { cpos=r_dx; return; } } output_pos=r_dx; cptr[r_dx]=0; r_dx++; } bptr+=r_dx; *bptr++=c; c_freq[c]++; cpos=bptr-cptr; } /* Initializes memory for encoding */ void allocate_memory() { int i; if((c_freq=calloc(NC*2-1, sizeof(*c_freq)))==NULL) error(M_OUT_OF_NEAR_MEMORY); if((c_code=farcalloc(NC, sizeof(*c_code)))==NULL) error(M_OUT_OF_MEMORY); if((heap=farcalloc(NC+1, sizeof(*heap)))==NULL) error(M_OUT_OF_MEMORY); for(i=0; i=MAX_BUFSIZ-BUFSIZ_INCREMENT) bufsiz=MAX_BUFSIZ-1; #ifdef FINETUNE_BUFSIZ i=1; #endif /* Adjust the buffer size if there's not enough memory for it */ while((buf=farmalloc(bufsiz))==NULL) { #ifndef FINETUNE_BUFSIZ bufsiz=bufsiz/10U*9U; #else if(i<2048) bufsiz-=i++; else bufsiz=bufsiz/16U*15U; #endif if(bufsiz>4), 0); #else ftree=dtree=farcalloc((unsigned long)treesize+16L, sizeof(*ftree)); #endif fpbuf=farcalloc((unsigned long)fpcount+4L, 2L); if(ftree==NULL||fpbuf==NULL) error(M_OUT_OF_MEMORY); } if(dic_alloc<1024) dic_alloc=1024; allocate_memory(); nchars=(UCHAR_MAX+THRESHOLD)*2; display_indicator(0L); encoded_bytes=0L; tc_passes=0; dicpos=0; i=j=0; while(!unpackable) { tree_el=0; k=0; if(j!=0) { tree_el=dic_alloc; if((k=j-tree_el)<=0) { k=0; tree_el=j; } else memmove(tree, tree+k, tree_el); } max_fetch=fetch=(unsigned int)(treesize-tree_el); if(multivolume_option) fetch=check_multivolume(fetch); if(max_fetch!=fetch) nchars=4; if((fetch=fetch_uncomp(tree+tree_el, fetch))==0) { if(tree_el==0||k==0) break; memmove(tree+k, tree, tree_el); dicsiz_cur=min(tree_el-i-1, dicsiz_cur); break; } j=fetch+tree_el; encoded_bytes+=(unsigned long)fetch; display_indicator(encoded_bytes); m=0; if(k<=0) fill_fpbuf(); else { fptr=fpbuf; for(l=fpcount>>2; l>0; l--) { *fptr=max(*fptr-k, -1); fptr++; *fptr=max(*fptr-k, -1); fptr++; *fptr=max(*fptr-k, -1); fptr++; *fptr=max(*fptr-k, -1); fptr++; } dtptr=dtree; for(l=tree_el>>3; l>0; l--) { *dtptr=max(dtptr[k]-k, -1); dtptr++; *dtptr=max(dtptr[k]-k, -1); dtptr++; *dtptr=max(dtptr[k]-k, -1); dtptr++; *dtptr=max(dtptr[k]-k, -1); dtptr++; *dtptr=max(dtptr[k]-k, -1); dtptr++; *dtptr=max(dtptr[k]-k, -1); dtptr++; *dtptr=max(dtptr[k]-k, -1); dtptr++; *dtptr=max(dtptr[k]-k, -1); dtptr++; } /* Store the remainder */ for(l=tree_el%8; l>0; l--) { *dtptr=max(dtptr[k]-k, -1); dtptr++; } m+=tree_el; if(m>=2) m-=2; } tptr=&tree[m]; r_dx=(unsigned short)*(tptr++); r_cx=(fp_max&0xFF00)|(hash_bits&0xFF); r_dx<<=(hash_bits&0xFF); r_dx^=(unsigned short)*(tptr++); r_dx&=(r_cx|0xFF); for(l=j-2; mnchars) { i--; pm=m; m++; n_passes=(unsigned int)tc_passes; f_dicpos=(int)dicpos; if((r_ax=upd_tree(m))>i) r_ax=tc_passes=i; if(n_passes16384)||--r_ax>n_passes||(r_ax==n_passes&&dicpos>>1i) tc_passes=i; } } } while(i>0) { i--; pm=m; m++; n_passes=tc_passes; f_dicpos=dicpos; if((r_ax=upd_tree(m))>i) r_ax=tc_passes=i; if(n_passes16384)||--r_ax>n_passes||(r_ax==n_passes&&dicpos>>1i) tc_passes=i; } } huf_encode_end(); #ifdef ASM8086 farfree_based(ftree); #else farfree(ftree); #endif farfree(fpbuf); free(tree); tree=NULL; } /* Encoding stub for -m3 */ static void NEAR huf_encode_m3() { int hash_bits; unsigned short fp_max; int i, j, m; unsigned short t; /* Exchange variable */ short k, l; int tree_el; unsigned int fetch; unsigned char *tptr; unsigned short r_cx, r_dx; short r_ax; hash_bits=(dicbit+2)/3; fpcount=1U<>4), 0); #else ftree=dtree=farcalloc((unsigned long)treesize+16L, sizeof(*ftree)); #endif fpbuf=farcalloc((unsigned long)fpcount+4L, 2L); if(ftree==NULL||fpbuf==NULL) error(M_OUT_OF_MEMORY); } allocate_memory(); display_indicator(encoded_bytes=0L); j=0; while(!unpackable) { tree_el=0; if(dic_alloc!=0&&j!=0) { tree_el=dic_alloc; if((k=j-tree_el)<=0) { k=0; tree_el=j; } else memmove(tree, tree+k, tree_el); } fetch=(unsigned int)(treesize-tree_el); if(multivolume_option) fetch=check_multivolume(fetch); if((fetch=fetch_uncomp(tree+tree_el, fetch))==0) break; else { j=fetch+tree_el; encoded_bytes+=(unsigned long)fetch; display_indicator(encoded_bytes); fill_fpbuf(); l=fetch; tptr=tree; r_dx=(unsigned short)*(tptr++); r_cx=(fp_max&0xFF00)|(hash_bits&0xFF); r_dx<<=(hash_bits&0xFF); r_dx^=(unsigned short)*(tptr++); r_dx&=(r_cx|0xFF); for(m=0; m0) { r_ax=upd_tree(m); if((r_ax=upd_tree(m))>i) r_ax=tc_passes=i; if(r_axDICSIZ_MAX) error(M_LARGE_DICTIONARY); if(dic_alloc>treesize) error(M_LARGE_GSIZE); if(method==3) huf_encode_m3(); else huf_encode(); } /* Fast search stub for method 4 */ static void enc4_pass1(int n_c) { #ifdef ASM8086 asm{ mov dx, n_c mov bx, 1 mov cx, 0 cmp dx, bx jl cease_search } binsearch: asm{ sub dx, bx inc cx shl bx, 1 cmp dx, bx jl cease_search sub dx, bx inc cx shl bx, 1 cmp dx, bx jl cease_search sub dx, bx inc cx shl bx, 1 cmp dx, bx jl cease_search sub dx, bx inc cx shl bx, 1 cmp dx, bx jl cease_search sub dx, bx inc cx shl bx, 1 cmp dx, bx jl cease_search jmp binsearch } cease_search: asm{ or cx, cx jz chk_ctr_bounds push dx push cx mov ax, 65535 push ax push cx call far ptr putbits add sp, 4 pop cx pop dx } chk_ctr_bounds: asm{ cmp cx, 7 jge p1exit inc cx } p1exit: asm{ push dx push cx call far ptr putbits add sp, 4 } #else short r_bx=1; int r_cx=0; while(n_c>=r_bx) { n_c-=r_bx; r_cx++; r_bx<<=1; } if(r_cx!=0) putbits(r_cx, -1); if(r_cx<7) r_cx++; putbits(r_cx, n_c); #endif } /* Dictionary position lookup */ static void enc4_pass2(int n_c) { #ifdef ASM8086 asm{ mov dx, n_c mov bx, 512 mov cx, 9 cmp dx, bx jl p2_cease_search } p2_bsearch: asm{ sub dx, bx inc cx shl bx, 1 cmp dx, bx jl p2_cease_search sub dx, bx inc cx shl bx, 1 cmp dx, bx jl p2_cease_search sub dx, bx inc cx shl bx, 1 cmp dx, bx jl p2_cease_search sub dx, bx inc cx shl bx, 1 cmp dx, bx jl p2_cease_search sub dx, bx inc cx shl bx, 1 cmp dx, bx jge p2_bsearch } p2_cease_search: asm{ mov ch, cl sub cl, 9 jz p2_chk_ctr push cx push dx mov ax, 65535 push ax push cx call far ptr putbits add sp, 4 pop dx pop cx } p2_chk_ctr: asm{ cmp ch, 13 jge p2exit inc ch } p2exit: asm{ mov cl, ch push dx push cx call far ptr putbits add sp, 4 } #else unsigned short r_bx=1<<9; int r_cx=9; while(n_c>=r_bx) { n_c-=r_bx; r_cx++; r_bx<<=1; } if(r_cx!=9) putbits(r_cx-9, -1); if(r_cx<13) r_cx++; putbits(r_cx, n_c); #endif } /* Encodes a single file, using method 4 */ void encode_f() { int fetch; int hash_bits; unsigned short fp_max; unsigned char *tptr; int i, m; unsigned short r_cx, r_dx, r_ax; unsigned short t; dicbit=14; numchars=32; dicsiz_cur=15800; treesize=30720; adjust_dicbit(); hash_bits=(dicbit+2)/3; fpcount=1U<>4), 0); #else ftree=dtree=farcalloc((unsigned long)treesize+16L, sizeof(*ftree)); #endif fpbuf=farcalloc((unsigned long)fpcount+4L, 2L); if(ftree==NULL||fpbuf==NULL) error(M_OUT_OF_MEMORY); } init_putbits(); cpos=0; display_indicator(encoded_bytes=0L); while(!unpackable) { fetch=treesize; if(multivolume_option) fetch=check_multivolume(fetch); if((fetch=fetch_uncomp(tree, fetch))==0) break; encoded_bytes+=(unsigned long)fetch; display_indicator(encoded_bytes); fill_fpbuf(); m=0; tptr=tree; r_dx=(unsigned short)*(tptr++); r_cx=(fp_max&0xFF00)|(hash_bits&0xFF); r_dx<<=(hash_bits&0xFF); r_dx^=(unsigned short)*(tptr++); r_dx&=(r_cx|0xFF); for(m=0; m0) { if((r_ax=upd_tree(m))>i) r_ax=tc_passes=i; if(r_ax #include #include #endif #include #if COMPILER==BCC #include #elif COMPILER==MSC||COMPILER==MSVC||COMPILER==ICC #include #endif #if TARGET!=UNIX #include #endif #if COMPILER==MSC||COMPILER==MSVC||COMPILER==ICC||COMPILER==HIGHC||defined(__EMX__)||(TARGET==OS2&&defined(LIBC)) #include #include #if COMPILER==HIGHC&&!defined(LIBC) #define SH_DENYRW _SH_DENYRW #define SH_DENYWR _SH_DENYWR #define SH_DENYNO _SH_DENYNO #endif #elif TARGET!=UNIX #include #endif #if COMPILER==BCC&&TARGET==DOS #include /* S_* only */ #endif #if TARGET==UNIX #ifdef SUNOS #include #include #endif #ifdef __sco__ #include #endif #include #include #include /* fork()+spawnvp() control */ #include #include /* LIBC high-resolution timing */ #include /* Priority control */ #if defined(linux) #include #include #include #elif defined(__FreeBSD__)||defined(__NetBSD__) #include #include #elif defined(__QNXNTO__) #include #else #include #endif #endif #ifdef TILED #include #endif #if TARGET==DOS #include "win95dos.h" #endif #if TARGET==WIN32&&!defined(F_OK) #define F_OK 0 /* For MSVCRT */ #endif /* IBM toolkit -> EMX wrapper */ #ifdef __EMX__ #define DosCaseMap DosMapCase #define DosQCurDisk DosQueryCurrentDisk #define DosQFileInfo DosQueryFileInfo #define DosQFSInfo DosQueryFSInfo #define DosSelectDisk DosSetDefaultDisk #define DosSetPrty DosSetPriority #endif DEBUGHDR(__FILE__) /* Debug information block */ /* * DOS legacy */ #if TARGET==DOS /* INT 24h */ #define INT24 0x24 #define INT24_IGNORE 0 #define INT24_RETRY 1 #define INT24_ABORT 2 #define INT24_FAIL 3 #define INT24_DPF_WRITING 0x0100 /* Device processing flag in AX */ #define INT24_IO_ERROR 0x8000 /* Character device IOCTL statements */ #define CHDI_STDOUT 0x0001 #define CHDI_STDIN 0x0002 #define CHDI_NUL 0x0004 #define CHDI_CLOCK 0x0008 #define CHDI_SPECIAL 0x0010 #define CHDI_BINARY 0x0020 #define CHDI_EOF_ON_INPUT 0x0040 #define CHDI_SET 0x0080 #define CHDI_OPENCLOSE 0x0800 #define CHDI_OUTPUT_TILL_BUSY 0x2000 #define CHDI_CAN_IOCTL 0x4000 /* File IOCTL statements */ #define CHDF_NOT_WRITTEN 0x0040 #define CHDF_NOT_FILE 0x0080 #define CHDF_EXT_INT24 0x0100 /* DOS 4.x only */ #define CHDF_NOT_REMOVABLE 0x0800 #define CHDF_NO_TIMESTAMPING 0x4000 #define CHDF_IS_REMOTE 0x8000 /* This macro checks if DOS version is less than 3.10 */ #define is_dos_31 (_osmajor<3||_osmajor==3&&_osminor<10) /* For MS C, a macro to query the current time */ #if COMPILER==MSC #define g_timer(t) t=*(long FAR *)0x0000046CL #endif #endif /* TARGET==DOS */ /* An OS/2 & Win32 macro to join timestamps */ #if TARGET==OS2||TARGET==WIN32 #define make_ftime(fd, ft) ((unsigned long)*(USHORT *)&fd<<16)+(unsigned long)*(USHORT *)&ft #endif /* Allowable DOS file attributes (HSRA) */ #if TARGET!=UNIX #define STD_FILE_ATTR (FATTR_ARCH|FATTR_SYSTEM|FATTR_HIDDEN|FATTR_RDONLY) #endif /* Attribute comparison for UNIX */ #if TARGET==UNIX #define match_unix_attrs(attr, pattern) (((pattern)==0)||(((attr)&(pattern))==(pattern))) #endif /* Command-line input limit */ #if TARGET==DOS #define INPUT_LIMIT 127 #endif /* UNIX file time requests */ #if TARGET==UNIX #define UFTREQ_FTIME 0 #define UFTREQ_ATIME 1 #define UFTREQ_CTIME 2 #endif /* * Exported variables */ /* Line feed string */ #if SFX_LEVEL>=ARJSFX||defined(REARJ) char simple_lf[]="\n"; #endif /* Carriage return */ #if SFX_LEVEL>=ARJ||TARGET==DOS&&(SFX_LEVEL>=ARJSFX||defined(REARJ)) char simple_cr[]="\r"; #endif /* The following systems are considered equal to host OS under which ARJ is run. The contents of this list greatly depend upon the host OS itself... */ #if SFX_LEVEL>=ARJSFX #if TARGET==DOS int friendly_systems[]={OS_DOS, OS_WIN95, OS_WINNT, -1}; #elif TARGET==OS2 int friendly_systems[]={OS_DOS, OS_OS2, OS_WIN95, OS_WINNT, -1}; #elif TARGET==WIN32 int friendly_systems[]={OS_DOS, OS_WIN95, OS_WINNT, -1}; #elif TARGET==UNIX int friendly_systems[]={OS_UNIX, OS_NEXT, -1}; #endif #endif /* Standard devices */ #if SFX_LEVEL>=ARJSFX #if TARGET==UNIX char dev_null[]="/dev/null"; /* NULL device */ char dev_con[]="/dev/tty"; /* Console device */ #else char dev_null[]="NUL"; /* NULL device */ char dev_con[]="CON"; /* Console device */ #endif #endif /* Wildcard used to select all files */ #if SFX_LEVEL>=ARJSFX||defined(REARJ) #if TARGET==DOS char all_wildcard[]="*.*"; #else char all_wildcard[]="*"; #endif #endif /* Win32 can't use setftime_on_stream - this is required for ARJSFXJR: */ #if SFX_LEVEL==ARJSFXJR&&TARGET==WIN32 #define NEED_SETFTIME_HACK #endif /* * Internal variables */ /* Attribute format */ #if SFX_LEVEL>=ARJSFX static char attrib_buf[]="---W"; /* ASHR if all set */ #endif /* Arbitrary disk drive for LFN testing */ #if SFX_LEVEL>=ARJSFX||defined(REARJ) static char drive_c[]="C:"; /* Although it's incorrect... */ #endif /* Directory specifiers for file search */ #if SFX_LEVEL>=ARJ||defined(REARJ) /* Subdirectory/root search wildcard */ #if TARGET==DOS char root_wildcard[]="\\*.*"; #elif TARGET==OS2||TARGET==WIN32 char root_wildcard[]="\\*"; #elif TARGET==UNIX char root_wildcard[]="/*"; #endif char up_dir_spec[]=".."; /* Parent directory specifier */ char pathsep_str[]={PATHSEP_DEFAULT, '\0'}; #endif #if SFX_LEVEL>=ARJ||defined(REARJ)||(SFX_LEVEL>=ARJSFXV&&TARGET==UNIX) char cur_dir_spec[]="."; /* Current directory specifier */ #endif /* FCB mask (used to fill in FCBs) */ #if SFX_LEVEL>=ARJSFXV&&TARGET==DOS static char fcb_mask[]="???????????"; #endif /* Queues for detecting child session shutdown */ #if TARGET==OS2&&defined(REARJ) static char rearj_q_fmt[]="\\QUEUES\\REARJ#%u"; #endif /* Name of file that is currently being opened */ #if COMPILER==MSC&&TARGET==DOS static char *f_file_ptr=NULL; #endif /* For the case if the environment doesn't allow to query EXE name, we'll store our own ones. */ #if TARGET==DOS #if SFX_LEVEL>=ARJ static char default_exe[]="arj" EXE_EXTENSION; #elif SFX_LEVEL>=ARJSFXJR static char default_exe[]="arjsfx" EXE_EXTENSION; #elif defined(REARJ) static char default_exe[]="rearj" EXE_EXTENSION; #endif #endif /* * Frequently used Borland routines */ /* Returns 0 for A:, 1 for B:, etc. */ #if defined(HAVE_DRIVES)&&((SFX_LEVEL>=ARJSFX||defined(REARJ))&&COMPILER!=BCC) int getdisk() { #if TARGET==DOS int rc; _dos_getdrive((unsigned int *)&rc); return(rc-1); #elif TARGET==OS2 #ifndef __32BIT__ USHORT rc; ULONG total; DosQCurDisk(&rc, &total); return(rc-1); #else ULONG rc, total; DosQCurDisk(&rc, &total); return(rc-1); #endif #elif TARGET==WIN32 char cur_dir[CCHMAXPATH]; if(GetCurrentDirectory(sizeof(cur_dir), cur_dir)&&cur_dir[1]==':') return(cur_dir[0]-'A'); else return(-1); #endif } #endif /* Performs heap checking if required */ #if SFX_LEVEL>=ARJ int verify_heap() { #if COMPILER==BCC return(heapcheck()==_HEAPCORRUPT); #elif COMPILER==MSC||COMPILER==MSVC int rc; rc=_heapchk(); return(rc!=_HEAPOK&&rc!=_HEAPEMPTY); #elif COMPILER==ICC&&defined(DEBUG) _heap_check(); return(0); #else return(0); /* Not implemented otherwise */ #endif } #endif /* Performs far heap verification (if there is any) */ #if SFX_LEVEL>=ARJ int verify_far_heap() { #if COMPILER==BCC return(farheapcheck()); #elif COMPILER==MSC return(_fheapchk()); #elif !defined(TILED) return(verify_heap()); #else return(0); /* Don't even bother of it */ #endif } #endif /* Returns the available stack space */ #if SFX_LEVEL>=ARJ static unsigned int get_stack_space() { #if defined(__BORLANDC__) return(stackavail()); #elif defined(__TURBOC__) return(_stklen+_SP); #elif COMPILER==MSC return(stackavail()); #else return(32767); #endif } #endif /* Changes the current drive to 0=A:, 1=B:, and so on... */ #if defined(HAVE_DRIVES)&&(defined(REARJ)&&COMPILER!=BCC) int setdisk(int drive) { #if TARGET==DOS int numdrives; _dos_setdrive(drive+1, &numdrives); return(numdrives); #elif TARGET==OS2 #ifdef __32BIT__ ULONG rc; #else USHORT rc; #endif ULONG total; rc=DosSelectDisk(drive+1); if(rc) return(0); DosQCurDisk(&rc, &total); return(total); #elif TARGET==WIN32 char t[4]; t[0]=drive+'A'; t[1]=':'; t[2]='\0'; SetCurrentDirectory(t); return(25); /* Dummy value */ #endif } #endif /* Returns the number of bytes available in the far heap (quite slow). This is an advisory function for legacy parts of ARJ. Avoid it by all means. */ #if SFX_LEVEL>=ARJSFXV&&COMPILER!=BCC long farcoreleft() { #if TARGET==DOS void _huge *hp; static long rc=736L; long s_rc; s_rc=rc; rc+=2L; do hp=halloc(rc-=2L, 1024); while(hp==NULL&&rc>0L); if(hp!=NULL) hfree(hp); if(rc=ARJSFXV||defined(REARJ)||defined(REGISTER))&&COMPILER!=BCC void arj_gettime(struct time *ts) { #if TARGET==DOS struct dostime_t dts; _dos_gettime(&dts); ts->ti_hour=dts.hour; ts->ti_min=dts.minute; ts->ti_sec=dts.second; ts->ti_hund=dts.hsecond; #elif TARGET==OS2 DATETIME dts; DosGetDateTime(&dts); ts->ti_hour=dts.hours; ts->ti_min=dts.minutes; ts->ti_sec=dts.seconds; ts->ti_hund=dts.hundredths; #elif TARGET==WIN32 SYSTEMTIME st; GetLocalTime(&st); ts->ti_hour=st.wHour; ts->ti_min=st.wMinute; ts->ti_sec=st.wSecond; ts->ti_hund=st.wMilliseconds/10; #else time_t t; struct timeval v; struct tm *tms; do { t=time(NULL); gettimeofday(&v, NULL); } while(time(NULL)!=t); tms=localtime(&t); ts->ti_hour=tms->tm_hour; ts->ti_min=tms->tm_min; ts->ti_sec=tms->tm_sec; ts->ti_hund=v.tv_usec/10000; #endif } #endif /* Returns the current date */ #if defined(REARJ)&&COMPILER!=BCC void arj_getdate(struct date *ds) { #if TARGET==DOS struct dosdate_t dds; _dos_getdate(&dds); ds->da_year=1980+dds.year; ds->da_day=dds.day; ds->da_mon=dds.month; #elif TARGET==OS2 DATETIME dts; DosGetDateTime(&dts); ds->da_year=dts.year; ds->da_day=dts.day; ds->da_mon=dts.month; #elif TARGET==WIN32 SYSTEMTIME st; GetLocalTime(&st); ds->da_year=st.wYear; ds->da_day=st.wDay; ds->da_mon=st.wMonth; #else time_t t; struct tm *tms; t=time(NULL); tms=localtime(&t); ds->da_year=tms->tm_year+1900; ds->da_day=tms->tm_mday; ds->da_mon=tms->tm_mon+1; #endif } #endif /* Gets address of DOS DTA */ #if SFX_LEVEL>=ARJSFXV&&COMPILER!=BCC&&TARGET==DOS static char FAR *getdta() { union REGS regs; struct SREGS sregs; regs.h.ah=0x2F; intdosx(®s, ®s, &sregs); return(MK_FP(sregs.es, regs.x.bx)); } #endif /* Sets address of DOS DTA */ #if SFX_LEVEL>=ARJSFXV&&COMPILER!=BCC&&TARGET==DOS static void setdta(char FAR *dta) { union REGS regs; struct SREGS sregs; regs.h.ah=0x1A; sregs.ds=FP_SEG(dta); regs.x.dx=FP_OFF(dta); intdosx(®s, ®s, &sregs); } #endif /* * OS/2 farcalloc()/farfree() routines */ #if TARGET==OS2&&defined(TILED) /* farcalloc() for 0-based segments */ #if SFX_LEVEL>=ARJ&&defined(ASM8086) void FAR *farcalloc_based(unsigned long num, unsigned long size) { USHORT total; SEL selector; void FAR *rc; total=(USHORT)num*size; if(DosAllocSeg(total, &selector, SEG_NONSHARED)) return(NULL); rc=(void FAR *)MAKEP(selector, 0); far_memset(rc, 0, total); return(rc); } #endif /* farfree() for 0-based segments */ #if SFX_LEVEL>=ARJ&&defined(ASM8086) void farfree_based(void FAR *ptr) { DosFreeSeg(SELECTOROF(ptr)); } #endif #endif /* Sets the process priority. */ #if TARGET!=DOS&&SFX_LEVEL>=ARJ void set_priority(struct priority *priority) { #if TARGET==OS2 DosSetPrty(PRTYS_THREAD, priority->class, priority->delta, 0); #elif TARGET==WIN32 static HANDLE ph=0, th=0; static DWORD w32_classes[4]={IDLE_PRIORITY_CLASS, NORMAL_PRIORITY_CLASS, HIGH_PRIORITY_CLASS, REALTIME_PRIORITY_CLASS}; if(!ph) ph=GetCurrentProcess(); if(!th) th=GetCurrentThread(); if(priority->class<=4) SetPriorityClass(ph, w32_classes[priority->class-1]); SetThreadPriority(th, priority->delta); #else #if defined(HAVE_SETPRIORITY) setpriority(PRIO_PROCESS, 0, 21-priority->class); #else #error Priority functions missing #endif #endif } #endif /* * This section is specific to Windows 95 LFN API. */ /* Just a customized interrupt call procedure */ #if (SFX_LEVEL>=ARJSFX||defined(REARJ))&&TARGET==DOS static int call_dos_int(unsigned int funcnum, union REGS *regs, struct SREGS *sregs) { regs->x.ax=funcnum; #ifdef ASM8086 asm{ pushf pop ax or ax, 1 push ax popf }; #else /* Provoke the carry flag */ regs->x.cflag=(regs->x.ax&0x7FFF)+0x8000; #endif intdosx(regs, regs, sregs); _doserrno=(regs->x.cflag!=0)?(regs->x.ax):0; return(regs->x.cflag); } #endif /* Test the specified volume for long filename support */ #if (SFX_LEVEL>=ARJSFX||defined(REARJ))&&TARGET==DOS static int w95_test_for_lfn(char *drive) { union REGS regs; struct SREGS sregs; char filesystem[40]; /* Ralf Brown says 32 */ char FAR *fsptr, FAR *dptr; fsptr=(char FAR *)filesystem; dptr=(char FAR *)drive; memset(&sregs, 0, sizeof(sregs)); sregs.es=FP_SEG(fsptr); regs.x.di=FP_OFF(fsptr); regs.x.cx=sizeof(filesystem); sregs.ds=FP_SEG(dptr); regs.x.dx=FP_OFF(dptr); return(call_dos_int(W95_GET_VOLUME_INFO, ®s, &sregs)==0&®s.x.bx&0x4000); } #endif /* Return equivalent canonical short filename for a long filename */ #if (SFX_LEVEL>=ARJSFX||defined(REARJ))&&TARGET==DOS static int w95_get_shortname(char *longname, char *shortname, int cb_shortname) { union REGS regs; struct SREGS sregs; char FAR *lnptr, FAR *snptr; memset(&sregs, 0, sizeof(sregs)); if(cb_shortname>=CCHMAXPATH_DOS) { lnptr=(char FAR *)longname; snptr=(char FAR *)shortname; shortname[0]='\0'; sregs.ds=FP_SEG(lnptr); regs.x.si=FP_OFF(lnptr); sregs.es=FP_SEG(snptr); regs.x.di=FP_OFF(snptr); regs.x.cx=W95_GET_SHORTNAME; /* No SUBST expansion, subfunc #1 */ if(!call_dos_int(W95_TRUENAME, ®s, &sregs)) return(strlen(shortname)); else return(0); } else return(0); } #endif /* Changes directory under Windows 95 */ #if defined(REARJ)&&TARGET==DOS static int w95_chdir(char *longname) { union REGS regs; struct SREGS sregs; char FAR *lnptr; memset(&sregs, 0, sizeof(sregs)); lnptr=(char FAR *)longname; sregs.ds=FP_SEG(lnptr); regs.x.dx=FP_OFF(lnptr); return(call_dos_int(W95_CHDIR, ®s, &sregs)?-1:0); } #endif /* Return equivalent canonical long filename for a short filename */ #if (SFX_LEVEL>=ARJ)&&TARGET==DOS static int w95_get_longname(char *shortname, char *longname, int cb_longname) { union REGS regs; struct SREGS sregs; char FAR *lnptr, FAR *snptr; memset(&sregs, 0, sizeof(sregs)); if(cb_longname>=CCHMAXPATH_W95) { longname[0]='\0'; lnptr=(char FAR *)longname; snptr=(char FAR *)shortname; sregs.ds=FP_SEG(snptr); regs.x.si=FP_OFF(snptr); sregs.es=FP_SEG(lnptr); regs.x.di=FP_OFF(lnptr); regs.x.cx=W95_GET_LONGNAME; /* No SUBST expansion, subfunc #2 */ if(!call_dos_int(W95_TRUENAME, ®s, &sregs)) return(strlen(longname)); else return(0); } else return(0); } #endif /* Returns 1 if the current OS is Windows NT, 0 if Windows 95 */ #if SFX_LEVEL>=ARJ&&TARGET==DOS int test_for_winnt() { return(0); /* Implemented in ARJ32 */ } #endif /* Returns the name of current directory */ #if defined(REARJ)&&TARGET==DOS static char *w95_cwd(char *dest) { union REGS regs; struct SREGS sregs; char FAR *dptr; dptr=(char FAR *)dest; memset(&sregs, 0, sizeof(sregs)); dest[0]=getdisk()+'A'; dest[1]=':'; dest[2]=PATHSEP_DEFAULT; regs.h.dl=0; sregs.ds=FP_SEG(dptr); regs.x.si=FP_OFF(dptr)+3; return(call_dos_int(W95_CWD, ®s, &sregs)?NULL:dest); } #endif /* Create a directory with longname. Return -1 if failed. */ #if (SFX_LEVEL>=ARJSFX||defined(REARJ))&&TARGET==DOS static int w95_mkdir(char *longname) { union REGS regs; struct SREGS sregs; char FAR *lnptr; lnptr=(char FAR *)longname; memset(&sregs, 0, sizeof(sregs)); /* BUG?! No register cleanup in ARJ */ sregs.ds=FP_SEG(lnptr); regs.x.dx=FP_OFF(lnptr); return(call_dos_int(W95_MKDIR, ®s, &sregs)?-1:0); } #endif /* Remove a directory with longname. Return -1 if failed. */ #if (SFX_LEVEL>=ARJ||defined(REARJ))&&TARGET==DOS static int w95_rmdir(char *longname) { union REGS regs; struct SREGS sregs; char FAR *lnptr; lnptr=(char FAR *)longname; memset(&sregs, 0, sizeof(sregs)); sregs.ds=FP_SEG(lnptr); regs.x.dx=FP_OFF(lnptr); return(call_dos_int(W95_RMDIR, ®s, &sregs)?-1:0); } #endif /* Delete a file */ #if (SFX_LEVEL>=ARJSFX||defined(REARJ))&&TARGET==DOS static int w95_unlink(char *longname) { union REGS regs; struct SREGS sregs; char FAR *lnptr; lnptr=(char FAR *)longname; memset(&sregs, 0, sizeof(sregs)); sregs.ds=FP_SEG(lnptr); regs.x.dx=FP_OFF(lnptr); #ifndef REARJ regs.x.cx=FATTR_ARCH|FATTR_SYSTEM|FATTR_RDONLY; #else regs.x.cx=0; #endif regs.x.si=W95_WILDCARDS_DISABLED; /* Forbid wildcard usage */ return(call_dos_int(W95_UNLINK, ®s, &sregs)?-1:0); } #endif /* Rename a file */ #if (SFX_LEVEL>=ARJ||defined(REARJ))&&TARGET==DOS static int w95_rename(char *longname1, char *longname2) { union REGS regs; struct SREGS sregs; char FAR *lnptr1, FAR *lnptr2; lnptr1=(char FAR *)longname1; lnptr2=(char FAR *)longname2; memset(&sregs, 0, sizeof(sregs)); sregs.ds=FP_SEG(lnptr1); regs.x.dx=FP_OFF(lnptr1); sregs.es=FP_SEG(lnptr2); regs.x.di=FP_OFF(lnptr2); return(call_dos_int(W95_RENAME, ®s, &sregs)?-1:0); } #endif /* Query or change attributes */ #if (SFX_LEVEL>=ARJSFX||defined(REARJ))&&TARGET==DOS static int w95_chmod(char *longname, int action, int pmode) { union REGS regs; struct SREGS sregs; char FAR *lnptr; lnptr=(char FAR *)longname; memset(&sregs, 0, sizeof(sregs)); regs.x.bx=action; regs.x.cx=pmode; sregs.ds=FP_SEG(lnptr); regs.x.dx=FP_OFF(lnptr); return(call_dos_int(W95_CHMOD, ®s, &sregs)?-1:regs.x.cx); } #endif /* access() function for LFNs - test if the file has the given access mode */ #if (SFX_LEVEL>=ARJSFX||defined(REARJ))&&TARGET==DOS static int w95_access(char *longname, int mode) { if((w95_chmod(longname, W95_GETATTR, 0))==-1) return(-1); else { if((!(mode&2))||!(mode&FATTR_RDONLY)) return(0); else { errno=EACCES; return(-1); } } } #endif /* findfirst() function as implemented in Borland Turbo C++ */ #if (SFX_LEVEL>=ARJSFXV||defined(REARJ))&&TARGET==DOS static int w95_findfirst(char *path, struct new_ffblk *new_ffblk, int attrib) { union REGS regs; struct SREGS sregs; struct W95_FFBLK w95_ffblk, FAR *fb_ptr; char FAR *p_ptr; memset(&sregs, 0, sizeof(sregs)); fb_ptr=(struct W95_FFBLK FAR *)&w95_ffblk; p_ptr=(char FAR *)path; sregs.ds=FP_SEG(p_ptr); regs.x.dx=FP_OFF(p_ptr); sregs.es=FP_SEG(fb_ptr); regs.x.di=FP_OFF(fb_ptr); regs.x.cx=attrib; regs.x.si=W95_DT_DOS; /* Use DOS date/time format */ if(!call_dos_int(W95_FINDFIRST, ®s, &sregs)) { #if SFX_LEVEL>=ARJ||defined(REARJ) new_ffblk->ff_handle=regs.x.ax; /* Preserve handle for findclose */ strcpy(new_ffblk->ff_name, w95_ffblk.ff_longname); new_ffblk->ff_atime=w95_ffblk.ff_atime; new_ffblk->ff_ctime=w95_ffblk.ff_ctime; #endif new_ffblk->ff_attrib=(char)w95_ffblk.ff_attrib; new_ffblk->ff_ftime=w95_ffblk.ff_ftime; new_ffblk->ff_fsize=w95_ffblk.ff_fsize; #if SFX_LEVEL==ARJSFXV memset(&sregs, 0, sizeof(sregs)); regs.x.bx=regs.x.ax; /* Transfer FF handle */ call_dos_int(W95_FINDCLOSE, ®s, &sregs); #endif return(0); } else return(-1); } #endif /* findnext() function as implemented in Borland Turbo C++ */ #if (SFX_LEVEL>=ARJ||defined(REARJ))&&TARGET==DOS static int w95_findnext(struct new_ffblk *new_ffblk) { union REGS regs; struct SREGS sregs; struct W95_FFBLK w95_ffblk, FAR *fb_ptr; memset(&sregs, 0, sizeof(sregs)); fb_ptr=(struct W95_FFBLK FAR *)&w95_ffblk; sregs.es=FP_SEG(fb_ptr); regs.x.di=FP_OFF(fb_ptr); regs.x.bx=new_ffblk->ff_handle; regs.x.si=W95_DT_DOS; /* Not present in original ARJ! */ if(!call_dos_int(W95_FINDNEXT, ®s, &sregs)) { new_ffblk->ff_attrib=(char)w95_ffblk.ff_attrib; strcpy(new_ffblk->ff_name, w95_ffblk.ff_longname); new_ffblk->ff_ftime=w95_ffblk.ff_ftime; new_ffblk->ff_atime=w95_ffblk.ff_atime; new_ffblk->ff_ctime=w95_ffblk.ff_ctime; new_ffblk->ff_fsize=w95_ffblk.ff_fsize; return(0); } else return(-1); } #endif /* Close search (specific to Windows 95) */ #if (SFX_LEVEL>=ARJSFXV||defined(REARJ))&&TARGET==DOS static void w95_findclose(struct new_ffblk *new_ffblk) { union REGS regs; struct SREGS sregs; memset(&sregs, 0, sizeof(sregs)); regs.x.bx=new_ffblk->ff_handle; call_dos_int(W95_FINDCLOSE, ®s, &sregs); } #endif /* Create a file with the same options as given for _open, return handle */ #if (SFX_LEVEL>=ARJSFX||defined(REARJ))&&TARGET==DOS static int w95_creat(char *longname, int access) { union REGS regs; struct SREGS sregs; char FAR *lnptr; lnptr=(char FAR *)longname; memset(&sregs, 0, sizeof(sregs)); sregs.ds=FP_SEG(lnptr); regs.x.si=FP_OFF(lnptr); regs.x.bx=access&(O_RDONLY|O_WRONLY); regs.x.cx=32; regs.x.dx=0; regs.x.di=1; /* Translate FCNTL actions into Win95 actions */ if(access&O_CREAT) regs.x.dx|=W95_A_CREAT; if(access&O_TRUNC) regs.x.dx|=W95_A_TRUNC; if(access&O_EXCL) regs.x.dx|=W95_A_EXCL; return(call_dos_int(W95_OPEN, ®s, &sregs)?-1:regs.x.ax); } #endif /* Stamp date/time of last access on handle. Note that Win95 does not support time of last access. */ #if (SFX_LEVEL>=ARJSFXV)&&TARGET==DOS static int w95_set_dta(int handle, unsigned long ftime) { union REGS regs; struct SREGS sregs; memset(&sregs, 0, sizeof(sregs)); regs.x.bx=handle; regs.x.cx=0; regs.x.dx=(unsigned short)ftime>>16; return(call_dos_int(W95_SET_DTA, ®s, &sregs)?-1:0); } #endif /* Stamp date/time of last access on handle. Note that Win95 does not support time of last access. */ #if (SFX_LEVEL>=ARJSFXV)&&TARGET==DOS static int w95_set_dtc(int handle, unsigned long ftime) { union REGS regs; struct SREGS sregs; memset(&sregs, 0, sizeof(sregs)); regs.x.bx=handle; regs.x.cx=(unsigned short)(ftime%65536L); regs.x.dx=(unsigned short)ftime>>16; regs.x.si=0; /* Number of 1/100ths */ return(call_dos_int(W95_SET_DTC, ®s, &sregs)?-1:0); } #endif /* * Now, some less OS-dependent routines. */ /* Return pointer to first character following a drivespec/relative pathspec so names like "\VIRUS.COM" will be transformed to safe "VIRUS.COM" */ #if SFX_LEVEL>=ARJSFX #if SFX_LEVEL>=ARJSFXV static char *validate_path(char *name, int action) #else static char *validate_path(char *name) #endif { #if SFX_LEVEL>=ARJSFXV if(action!=VALIDATE_NOTHING) { #endif #ifdef HAVE_DRIVES if(name[0]!='\0'&&name[1]==':') name+=2; /* Skip over drivespecs */ #endif #if SFX_LEVEL>=ARJSFXV if(action!=VALIDATE_DRIVESPEC) { #endif if(name[0]=='.') { if(name[1]=='.'&&(name[2]==PATHSEP_DEFAULT||name[2]==PATHSEP_UNIX)) name++; /* "..\\" relative path */ if(name[1]==PATHSEP_DEFAULT||name[1]==PATHSEP_UNIX) name++; /* ".\\" relative path */ } if(name[0]==PATHSEP_DEFAULT||name[0]==PATHSEP_UNIX) name++; /* "\\" - revert to root */ #if SFX_LEVEL>=ARJSFXV } } #endif return(name); } #endif /* Convert the extended finddata record to OS-independent internal storage format */ #if SFX_LEVEL>=ARJ static void finddata_to_properties(struct file_properties *properties, struct new_ffblk *new_ffblk) { #if TARGET==UNIX int u; #endif properties->ftime=new_ffblk->ff_ftime; properties->atime=new_ffblk->ff_atime; properties->ctime=new_ffblk->ff_ctime; properties->fsize=new_ffblk->ff_fsize; properties->attrib=(ATTRIB)new_ffblk->ff_attrib; #if TARGET!=UNIX properties->type=(new_ffblk->ff_attrib&FATTR_DIREC)?ARJT_DIR:ARJT_BINARY; properties->isarchive=(new_ffblk->ff_attrib&FATTR_ARCH)?1:0; #else u=uftype(new_ffblk->ff_attrib); if(u&FATTR_DT_DIR) properties->type=ARJT_DIR; else if(u&FATTR_DT_UXSPECIAL) properties->type=ARJT_UXSPECIAL; else properties->type=ARJT_BINARY; /* Can't check fot non-DT_REG since these may be requested by find_file() */ properties->isarchive=1; /* Hardlink data */ properties->l_search=new_ffblk->l_search; properties->l_search.ref=0; properties->islink=0; #endif } #endif /* Return pointer to the first path delimiter in given string, or NULL if nothing found */ #if SFX_LEVEL>=ARJSFX static char *find_delimiter(char *path, int datatype) { if(path[0]=='\0') return(NULL); while(path[0]!='\0') { if(path[0]==PATHSEP_DEFAULT||path[0]==PATHSEP_UNIX) return(path); path++; } if(datatype==ARJT_DIR) return(path); else return(NULL); } #endif /* * Secondary-level file management routines. Usually they must either be * redirected to Win95 LFN API, or serviced with the C RTL functions. */ /* chmod() - Borland's implementation */ #if SFX_LEVEL>=ARJSFX||defined(REARJ) int file_chmod(char *name, int action, int attrs) { #if TARGET==DOS if(lfn_supported!=LFN_NOT_SUPPORTED) return(w95_chmod(name, action, attrs)); else #if COMPILER==BCC return(_chmod(name, action, attrs)); #elif COMPILER==MSC { int rc; if(action) return(_dos_setfileattr(name, attrs)); else { rc=-1; _dos_getfileattr(name, &rc); return(rc); } } #endif #elif TARGET==OS2 #ifdef __32BIT__ FILESTATUS3 fstatus; int rc; rc=DosQueryPathInfo(name, FIL_STANDARD, (PBYTE)&fstatus, sizeof(fstatus)); if(action) { fstatus.attrFile=attrs; return(DosSetPathInfo(name, FIL_STANDARD, (PBYTE)&fstatus, sizeof(fstatus), 0)?-1:0); } else return(rc?-1:fstatus.attrFile); #else USHORT rc; if(action) return(DosSetFileMode(name, attrs, 0L)?-1:0); else return(DosQFileMode(name, &rc, 0L)?-1:rc); #endif #elif TARGET==WIN32 DWORD rc; if(!action) { rc=GetFileAttributes(name); if(rc==0xFFFFFFFF) return(-1); else return((int)rc); } else return(!SetFileAttributes(name, attrs)); #else struct stat st; if(action) { if(!lstat(name, &st)&&S_ISLNK(st.st_mode)) return(0); /* ASR fix 15/06/2003: don't touch symlinks anymore */ else return(chmod(name, attrs)); } else return(lstat(name, &st)?-1:st.st_mode); #endif } #endif /* Manages the access rights for a stream - required to handle the SFX archives properly */ #if SFX_LEVEL>=ARJ&&TARGET==UNIX int file_acc(FILE *stream) { struct stat st; return(fstat(fileno(stream), &st)?-1:st.st_mode); } /* Duplicates the "R" access bits into "X" for creating a SFX */ void make_executable(FILE *stream) { int stm; stm=file_acc(stream); fchmod(fileno(stream), stm|((stm>>2)&0111)); } #endif /* access() */ #if SFX_LEVEL>=ARJSFX||defined(REARJ)||defined(REGISTER) static int file_access(char *name, int mode) { #if TARGET==DOS #ifndef REGISTER if(lfn_supported!=LFN_NOT_SUPPORTED) return(w95_access(name, mode)); else #endif return(access(name, mode)); #elif TARGET==OS2||TARGET==WIN32||TARGET==UNIX return(access(name, mode)); #else #error No access() defined #endif } #endif #if TARGET==UNIX&&(SFX_LEVEL>=ARJSFXV||defined(REARJ)) /* Locates the first matching dirent, like findnext() but for the first dirent as well (the UNIX-way). May trash the new_ffblk structures without returning success, but who cares? */ static int roll_dirent(struct new_ffblk *new_ffblk) { struct dirent *ent; int a, l, m; struct stat st, resolved_st; int attrs; dev_t real_dev; ino_t real_inode; a=ufattr(attrs=new_ffblk->attrs); strcpy(new_ffblk->ff_name, new_ffblk->dir); if(!strcmp(new_ffblk->ff_name, cur_dir_spec)) new_ffblk->ff_name[l=0]='\0'; else { l=strlen(new_ffblk->ff_name); if(l==0||new_ffblk->ff_name[l-1]!=PATHSEP_DEFAULT) new_ffblk->ff_name[l++]=PATHSEP_DEFAULT; } /* Now, check all files until we find the matching one */ while((ent=readdir(new_ffblk->ff_handle))!=NULL) { strcpy(new_ffblk->ff_name+l, ent->d_name); if(a!=0) m=match_unix_attrs(file_chmod(new_ffblk->ff_name, 0, 0), a); else m=1; /* Wildcard matching and attribute check */ if(m&&match_wildcard(ent->d_name, new_ffblk->wildcard)) { if(lstat(new_ffblk->ff_name, &st)) return(-1); real_dev=st.st_dev; real_inode=st.st_ino; #if SFX_LEVEL>=ARJ /* Search in the device pool to see if the user forbids archiving for this device */ if(!is_dev_allowed(real_dev)) continue; #endif /* Redo stat if it's a link and we do not handle links (so need it to be resolved) */ if(!(attrs&FATTR_DT_UXSPECIAL)&&stat(new_ffblk->ff_name, &st)) continue; /* Sockets aren't supported, check for other types as well */ #if !defined(S_ISSOCK) #define S_ISSOCK(m) 0 #endif if(!S_ISSOCK(st.st_mode)&& (((uftype(attrs)==FATTR_DT_ANY||(uftype(attrs)&FATTR_DT_REG))&&S_ISREG(st.st_mode))|| ((attrs&FATTR_DT_DIR)&&S_ISDIR(st.st_mode))|| (attrs&FATTR_DT_UXSPECIAL))) { /* Reestablish the "unqualified" filename */ strcpy(new_ffblk->ff_name, ent->d_name); /* If it was a link, try to retrieve the mode of file which it points to. Otherwise, chmod() will trash the mode of original file upon restore */ if(S_ISLNK(st.st_mode)&&stat(new_ffblk->ff_name, &resolved_st)!=-1) { new_ffblk->ff_attrib=resolved_st.st_mode&FATTR_UFMASK; real_dev=resolved_st.st_dev; real_inode=resolved_st.st_ino; } else new_ffblk->ff_attrib=st.st_mode&FATTR_UFMASK; /* Convert the remaining structures to new_ffblk and leave the search */ new_ffblk->ff_ftype=st.st_mode; if(S_ISREG(st.st_mode)) new_ffblk->ff_attrib|=FATTR_DT_REG; else if(S_ISDIR(st.st_mode)) new_ffblk->ff_attrib|=FATTR_DT_DIR; else new_ffblk->ff_attrib|=FATTR_DT_UXSPECIAL; new_ffblk->ff_ftime=st.st_mtime; /* Prevent REARJ from complaining about directory size mismatch */ new_ffblk->ff_fsize=(S_ISREG(st.st_mode))?st.st_size:0; new_ffblk->ff_atime=st.st_atime; new_ffblk->ff_ctime=st.st_ctime; /* Special structures for hard links */ new_ffblk->l_search.dev=real_dev; new_ffblk->l_search.inode=real_inode; new_ffblk->l_search.refcount=S_ISDIR(st.st_mode)?1:st.st_nlink; break; } } } return(ent==NULL?-1:0); } #endif #if TARGET==WIN32 /* Strip NT timestamps -> DOS timestamps */ #if SFX_LEVEL>=ARJSFX||defined(REARJ) static unsigned long dosify_time(FILETIME *pft) { FILETIME lft; WORD dd=0x1111, dt=0x1111; FileTimeToLocalFileTime(pft, &lft); FileTimeToDosDateTime(&lft, &dd, &dt); return(make_ftime(dd, dt)); } #endif /* Expand DOS timestamps into NT UTC timestamps */ #if SFX_LEVEL>=ARJSFXJR||defined(REARJ) static void ntify_time(FILETIME *pft, unsigned long dft) { FILETIME lft; DosDateTimeToFileTime((WORD)(dft>>16), (WORD)(dft&0xFFFF), &lft); LocalFileTimeToFileTime(&lft, pft); } #endif #endif /* findfirst() - Borland's implementation */ #if SFX_LEVEL>=ARJSFXV||defined(REARJ) int lfn_findfirst(char *path, struct new_ffblk *new_ffblk, int attrib) { #if TARGET==DOS /* ASR fix 04/09/2001 for the R11 timestamp format */ new_ffblk->ff_atime=new_ffblk->ff_ctime=0; if(lfn_supported==LFN_SUPPORTED) return(w95_findfirst(path, new_ffblk, attrib)); else #if COMPILER==BCC return(findfirst(path, (struct ffblk *)new_ffblk, attrib)); #elif COMPILER==MSC return(_dos_findfirst(path, attrib, (struct find_t *)new_ffblk)); #endif #elif TARGET==OS2 HDIR handle=HDIR_CREATE; #ifdef __32BIT__ FILEFINDBUF3 findbuf; ULONG fcount=1L; #else FILEFINDBUF findbuf; USHORT fcount=1; #endif #ifdef __32BIT__ if(DosFindFirst(path, &handle, attrib, &findbuf, sizeof(findbuf), &fcount, FIL_STANDARD)) return(-1); #else if(DosFindFirst(path, &handle, attrib, &findbuf, sizeof(findbuf), &fcount, 0L)) return(-1); #endif /* Do the conversion */ new_ffblk->ff_attrib=findbuf.attrFile; new_ffblk->ff_ftime=make_ftime(findbuf.fdateLastWrite, findbuf.ftimeLastWrite); new_ffblk->ff_fsize=findbuf.cbFile; strcpy(new_ffblk->ff_name, findbuf.achName); new_ffblk->ff_atime=make_ftime(findbuf.fdateLastAccess, findbuf.ftimeLastAccess); new_ffblk->ff_ctime=make_ftime(findbuf.fdateCreation, findbuf.ftimeCreation); #if SFX_LEVEL<=ARJSFXV&&!defined(REARJ) DosFindClose(handle); #else new_ffblk->ff_handle=handle; #endif return(0); #elif TARGET==WIN32 WIN32_FIND_DATA wfd; HANDLE hf; if((hf=FindFirstFile(path, &wfd))==INVALID_HANDLE_VALUE) return(-1); if(wfd.nFileSizeHigh>0||(long)wfd.nFileSizeLow<0) return(-1); new_ffblk->ff_attrib=wfd.dwFileAttributes; new_ffblk->ff_ftime=dosify_time(&wfd.ftLastWriteTime); new_ffblk->ff_atime=dosify_time(&wfd.ftLastAccessTime); new_ffblk->ff_ctime=dosify_time(&wfd.ftCreationTime); new_ffblk->ff_fsize=wfd.nFileSizeLow; strcpy(new_ffblk->ff_name, wfd.cFileName); #if SFX_LEVEL<=ARJSFXV&&!defined(REARJ) FindClose(hf); #else new_ffblk->ff_handle=hf; #endif return(0); #elif TARGET==UNIX split_name(path, new_ffblk->dir, new_ffblk->wildcard); if(new_ffblk->wildcard[0]=='\0') strcpy(new_ffblk->wildcard, all_wildcard); if(new_ffblk->dir[0]=='\0') strcpy(new_ffblk->dir, cur_dir_spec); if((new_ffblk->ff_handle=opendir(new_ffblk->dir))==NULL) return(-1); new_ffblk->attrs=attrib; if(roll_dirent(new_ffblk)==-1) { closedir(new_ffblk->ff_handle); new_ffblk->ff_handle=NULL; /* Invalidate the new_ffblk */ return(-1); } #if SFX_LEVEL<=ARJSFXV&&!defined(REARJ) closedir(new_ffblk->ff_handle); #endif return(0); #endif } #endif /* findnext() - Borland's implementation */ #if SFX_LEVEL>=ARJ||defined(REARJ) int lfn_findnext(struct new_ffblk *new_ffblk) { #if TARGET==DOS if(lfn_supported==LFN_SUPPORTED) return(w95_findnext(new_ffblk)); else #if COMPILER==BCC return(findnext((struct ffblk *)new_ffblk)); #elif COMPILER==MSC return(_dos_findnext((struct find_t *)new_ffblk)); #endif #elif TARGET==OS2 HDIR handle; #ifdef __32BIT__ FILEFINDBUF3 findbuf; ULONG fcount=1L; #else FILEFINDBUF findbuf; USHORT fcount=1; #endif handle=new_ffblk->ff_handle; if(DosFindNext(handle, &findbuf, sizeof(findbuf), &fcount)) return(-1); /* Do the conversion */ new_ffblk->ff_attrib=findbuf.attrFile; new_ffblk->ff_ftime=make_ftime(findbuf.fdateLastWrite, findbuf.ftimeLastWrite); new_ffblk->ff_fsize=findbuf.cbFile; strcpy(new_ffblk->ff_name, findbuf.achName); new_ffblk->ff_atime=make_ftime(findbuf.fdateLastAccess, findbuf.ftimeLastAccess); new_ffblk->ff_ctime=make_ftime(findbuf.fdateCreation, findbuf.ftimeCreation); return(0); #elif TARGET==WIN32 WIN32_FIND_DATA wfd; if(!FindNextFile(new_ffblk->ff_handle, &wfd)) return(-1); if(wfd.nFileSizeHigh>0||(long)wfd.nFileSizeLow<0) return(-1); new_ffblk->ff_attrib=wfd.dwFileAttributes; new_ffblk->ff_ftime=dosify_time(&wfd.ftLastWriteTime); new_ffblk->ff_atime=dosify_time(&wfd.ftLastAccessTime); new_ffblk->ff_ctime=dosify_time(&wfd.ftCreationTime); new_ffblk->ff_fsize=wfd.nFileSizeLow; strcpy(new_ffblk->ff_name, wfd.cFileName); return(0); #elif TARGET==UNIX if(roll_dirent(new_ffblk)==-1) return(-1); return(0); #endif } #endif /* findclose() */ #if SFX_LEVEL>=ARJ||defined(REARJ) void lfn_findclose(struct new_ffblk *new_ffblk) { #if TARGET==DOS if(lfn_supported==LFN_SUPPORTED) w95_findclose(new_ffblk); #elif TARGET==OS2 DosFindClose(new_ffblk->ff_handle); #elif TARGET==WIN32 FindClose(new_ffblk->ff_handle); #elif TARGET==UNIX if(new_ffblk->ff_handle!=NULL) closedir(new_ffblk->ff_handle); new_ffblk->ff_handle=NULL; /* Invalidate it! */ #endif } #endif /* Convert the given symbols to upper case, depending on locale */ #if SFX_LEVEL>=ARJSFXV||defined(REARJ) void toupper_loc(unsigned char *ptr, int length) { #if TARGET==DOS&&defined(ASM8086) struct { int co_date; char co_curr[5]; char co_thsep[2]; char co_desep[2]; char co_dtsep[2]; char co_tmsep[2]; char co_currstyle; char co_digits; char co_time; long co_case; char co_dasep[2]; char co_fill[10]; } cty; static int cty_state=0; /* 0 if not queried yet */ static char((FAR *ctycnv)()); /* Case map routine */ union REGS regs; char c; if(cty_state==0) { cty_state=-1; if(_osmajor>=3) { regs.x.dx=(unsigned int)&cty; regs.x.ax=0x3800; intdos(®s, ®s); if(!regs.x.cflag) { cty_state=1; /* Accept any further calls */ ctycnv=(char (FAR *)())cty.co_case; } } } if(cty_state>0) { while(length>0) { if(ptr[0]>='a'&&ptr[0]<='z') ptr[0]-=0x20; /* Convert to upper case */ else if(ptr[0]>=0x80) { c=ptr[0]; asm mov al, c; ctycnv(); asm mov c, al; ptr[0]=c; } ptr++; length--; } } else { while(length>0) { if(ptr[0]>='a'&&ptr[0]<='z') ptr[0]-=('a'-'A'); /* Convert to upper case */ ptr++; length--; } } #elif TARGET==OS2 COUNTRYCODE cc; cc.country=cc.codepage=0; DosCaseMap(length, &cc, ptr); #else unsigned char x; /* ASR fix 10/04/2002: this fixes a GCC v 3.0 optimization bug */ while(length-->0) { x=*ptr; *ptr++=toupper(x); } #endif } #endif /* Sums two unixtime values (for systems with different implementation of time_t and for Year 2106 compliance) */ #if SFX_LEVEL>=ARJ time_t sum_time(time_t t1, time_t t2) { return(t1+t2); } #endif /* Subtracts two unixtime values (for systems with different implementation of time_t and for Year 2106 compliance) */ #ifdef REARJ time_t sub_time(time_t t1, time_t t2) { return(t1-t2); } #endif /* Depending of LFN support, converts the path specification to UPPERCASE */ #if SFX_LEVEL>=ARJSFX||defined(REARJ) void case_path(char *s) { #if TARGET==DOS if(lfn_supported==LFN_NOT_SUPPORTED) strupper(s); #else /* Case-preserving or case-sensitive systems have nothing to do here */ #endif } #endif /* Looks for duplicate drive specifications in the arguments, returns 1 if found one, or 0 if none were found. */ #if SFX_LEVEL>=ARJ&&TARGET!=UNIX int find_dupl_drivespecs(char **argtable, int args) { int cur_arg, cx_arg; if(args<=1) { if(listchars_allowed==0||argtable[0][0]!=listchar) return(0); else return(1); } else { for(cur_arg=0; cur_arg=ARJSFXV int file_test_access(char *name) { #if TARGET==DOS char tmp_name[CCHMAXPATH]; #endif int handle; #if TARGET==DOS if(_osmajor>=3&&!disable_sharing) { strcpy(tmp_name, name); if(lfn_supported!=LFN_NOT_SUPPORTED) w95_get_shortname(name, tmp_name, sizeof(tmp_name)); #if COMPILER==BCC if((handle=_open(tmp_name, O_BINARY|O_DENYALL|O_RDONLY))==-1) return(-1); #elif COMPILER==MSC if((handle=sopen(tmp_name, O_BINARY|O_RDONLY, SH_DENYRW))==-1) return(-1); #endif close(handle); } return(0); #elif TARGET==OS2||TARGET==WIN32 if((handle=sopen(name, O_BINARY|O_RDONLY, SH_DENYRW))==-1) return(-1); close(handle); return(0); #elif TARGET==UNIX struct flock flk; int rc; if((handle=open(name, O_RDONLY))==-1) return(-1); memset(&flk, 0, sizeof(flk)); rc=fcntl(handle, F_GETLK, &flk); close(handle); return(((rc==-1&&errno!=EINVAL)||(rc!=1&&flk.l_type==F_RDLCK))?-1:0); #endif } #endif /* Detect long filename support */ #if SFX_LEVEL>=ARJSFX||defined(REARJ) int detect_lfns() { #if TARGET==DOS if(_osmajor<7) return(lfn_supported=0); else return(lfn_supported=w95_test_for_lfn(drive_c)); #else return(lfn_supported=1); /* Setting to 0 will disable DTA/DTC handling! */ #endif } #endif /* Detect extended attribute support */ #if SFX_LEVEL>=ARJSFXV int detect_eas() { #if TARGET==OS2 ea_supported=1; #elif TARGET==WIN32 OSVERSIONINFO osvi; osvi.dwOSVersionInfoSize=sizeof(osvi); GetVersionEx(&osvi); return(ea_supported=(osvi.dwPlatformId==VER_PLATFORM_WIN32_NT)); #else ea_supported=0; #endif return(ea_supported); } #endif /* Null subroutine for compiler bugs */ void nullsub(int arg, ...) { } /* Delay */ #if SFX_LEVEL>=ARJSFX||defined(REARJ)||defined(REGISTER)||defined(ARJDISP) void arj_delay(unsigned int seconds) { #if TARGET==DOS #if COMPILER==MSC long c_time, e_time, t_time; /* This is inappropriate for some rare machines with non-standard timer arrangement, e.g. Tandy 2000 but at least it doesn't involve reprogramming the timer ports. */ e_time=(long)seconds*182L/10L; while(e_time--) { g_timer(t_time); c_time=t_time; do { g_timer(c_time); } while(c_time==t_time); } #else sleep(seconds); #endif #elif TARGET==OS2 DosSleep(seconds*1000L); #elif TARGET==WIN32 Sleep(seconds*1000L); #else sleep(seconds); #endif } #endif /* Collect memory statistics (for debugging purposes) */ #if SFX_LEVEL>=ARJSFXV void mem_stats() { if(debug_enabled&&strchr(debug_opt, 'v')!=NULL) { #if SFX_LEVEL>=ARJ msg_cprintf(0, M_MEMSTATS, coreleft(), verify_heap(), farcoreleft(), verify_far_heap(), get_stack_space()); #else msg_cprintf(0, M_MEMSTATS, coreleft(), farcoreleft()); #endif } } #endif /* Interrupt 24h handler */ #if SFX_LEVEL>=ARJSFXV&&TARGET==DOS #if COMPILER==BCC void interrupt int24_fatal_handler(unsigned int bp, unsigned int di, unsigned int si, unsigned int ds, unsigned int es, unsigned int dx, unsigned int cx, unsigned int bx, unsigned int ax) #elif COMPILER==MSC void _interrupt _far int24_fatal_handler( unsigned int es, unsigned int ds, unsigned int di, unsigned int si, unsigned int bp, unsigned int sp, unsigned int bx, unsigned int dx, unsigned int cx, unsigned int ax, unsigned int ip, unsigned int cs, unsigned int flags) #endif { ax=INT24_FAIL; } #endif /* Check for the existence of file given; INT 24h handler is reset to ensure that the FAIL action is automatically generated instead of prompting the user for action. */ #if SFX_LEVEL>=ARJSFX||defined(REARJ)||defined(REGISTER) int file_exists(char *name) { int rc; #if TARGET==DOS #if COMPILER==BCC void interrupt (*oldhdl)(); #elif COMPILER==MSC void (_interrupt _far *oldhdl)(); #endif #if SFX_LEVEL>=ARJSFXV if(is_dos_31) rc=file_access(name, 0); else { oldhdl=getvect(INT24); setvect(INT24, int24_fatal_handler); rc=file_access(name, 0); setvect(INT24, oldhdl); } #else rc=file_access(name, 0); #endif #elif TARGET==OS2 rc=file_access(name, 0); #else rc=file_access(name, F_OK); #endif return(!rc); } #endif /* An extended fopen that supports long filenames and uses sharing. */ #if SFX_LEVEL>=ARJSFX||defined(REARJ) FILE *file_open(char *name, char *mode) { #if TARGET==DOS char tmp_name[CCHMAXPATH]; #endif #if SFX_LEVEL>=ARJSFXV char tmp_mode[10]; #endif #if COMPILER!=BCC&&SFX_LEVEL>=ARJSFXV int shflag; #endif #if SFX_LEVEL>=ARJSFXV||TARGET==DOS int handle; #endif #if SFX_LEVEL>=ARJSFXV int oflag; #endif #if TARGET==DOS strcpy(tmp_name, name); if(lfn_supported!=LFN_NOT_SUPPORTED) { if(strchr(mode, 'a')!=NULL||strchr(mode, 'w')!=NULL) { if(w95_access(name, 0)) { /* If the file does not exist, continue here, otherwise get its short name and process with fopen. */ if((handle=w95_creat(name, O_CREAT|O_TRUNC|O_WRONLY))==-1) return(NULL); else close(handle); /* At this point, the file has been created but has a zero length. Now we can query its short name and use DOS functions to access it. */ } } w95_get_shortname(name, tmp_name, sizeof(tmp_name)); } #endif #if SFX_LEVEL>=ARJSFXV if(disable_sharing) return(fopen(name, mode)); else { strcpyn(tmp_mode, mode, 9); switch(tmp_mode[0]) { case 'r': oflag=0; break; case 'w': oflag=O_CREAT|O_TRUNC; break; case 'a': oflag=O_CREAT|O_APPEND; break; default: return(NULL); } if(tmp_mode[1]=='+'||(tmp_mode[1]!='\0'&&tmp_mode[2]=='+')) oflag|=O_RDWR; else oflag|=(tmp_mode[0]=='r')?O_RDONLY:O_WRONLY; #if TARGET!=UNIX if(tmp_mode[1]=='b'||tmp_mode[2]=='b') oflag|=O_BINARY; #endif #if TARGET==DOS if(_osmajor>=3) /* Sharing modes for DOS v 3.0+ */ { #if COMPILER==BCC if(tmp_mode[1]=='+'||tmp_mode[1]!='\0'&&tmp_mode[2]=='+') oflag|=O_DENYWRITE; else oflag|=O_DENYNONE; #else shflag=(tmp_mode[1]=='+'||tmp_mode[1]!='\0'&&tmp_mode[2]=='+')?SH_DENYWR:SH_DENYNO; #endif } #if COMPILER==BCC handle=open(tmp_name, oflag, S_IREAD|S_IWRITE); #elif COMPILER==MSC /* Advanced mode - designed for OS/2 */ if((handle=sopen(tmp_name, oflag, shflag, S_IREAD|S_IWRITE))==-1) { if(errno!=EACCES) return(NULL); /* Provoke INT 24h call */ f_file_ptr=name; handle=open(tmp_name, oflag, S_IREAD|S_IWRITE); f_file_ptr=NULL; if(handle==-1) /* User abort */ return(NULL); close(handle); /* Try to reopen the file in shared mode */ if((handle=sopen(tmp_name, oflag, shflag, S_IREAD|S_IWRITE))==-1) if((handle=open(tmp_name, oflag, S_IREAD|S_IWRITE))==-1) return(NULL); } #endif if(handle!=-1) return(fdopen(handle, tmp_mode)); else return(NULL); #elif TARGET==OS2||TARGET==WIN32 { shflag=(mode[1]=='+'||mode[1]!='\0'&&mode[2]=='+')?SH_DENYWR:SH_DENYNO; handle=sopen(name, oflag, shflag, S_IREAD|S_IWRITE); if(handle!=-1) return((FILE *)fdopen(handle, mode)); else return(NULL); } #elif TARGET==UNIX { struct flock flk; /* Disengage any links so we don't follow them */ if(mode[0]=='w') unlink(name); /* Deny write activities if mixed-mode access */ if(mode[1]=='+'||(mode[1]!='\0'&&mode[2]=='+')) { memset(&flk, 0, sizeof(flk)); flk.l_type=F_WRLCK; /* ASR fix 01/10/2003 -- re-fix to handle umask 022 correctly */ if((handle=open(name, oflag, 0644))==-1) return(NULL); if(fcntl(handle, F_SETLK, &flk)==-1&&errno!=EINVAL) { close(handle); return(NULL); } return(fdopen(handle, mode)); } else return(fopen(name, mode)); } #endif } #else #if TARGET==DOS return(fopen(tmp_name, mode)); #else return(fopen(name, mode)); #endif #endif } #endif /* Convert the given path to uppercase and validate it */ #if SFX_LEVEL>=ARJSFXV void default_case_path(char *dest, char *src) { case_path(strcpy(dest, validate_path(src, validate_style))); } #endif /* Checks stdin against EOF (for raw input mode) */ #if (SFX_LEVEL>=ARJSFXV||defined(ARJDISP))&&TARGET==DOS static void check_stdin() { int rc; union REGS regs; regs.x.ax=0x4400; /* IOCTL - query device */ regs.x.bx=0; /* STDIN */ intdos(®s, ®s); rc=regs.x.dx; #ifndef ARJDISP if(!(rc&CHDI_NUL)) { if(rc&CHDI_SET) return; if(!eof(0)) return; } error(M_CANTREAD); #endif } #endif /* Reads character from console */ #if SFX_LEVEL>=ARJSFXV||defined(ARJDISP) int uni_getch() { #if TARGET==DOS union REGS regs; check_stdin(); regs.h.ah=0x08; /* Read character without echo */ intdos(®s, ®s); return((int)(regs.h.al==0x0D?0x0A:regs.h.al)); #elif TARGET==OS2 KBDKEYINFO keyinfo; KbdCharIn(&keyinfo, IO_WAIT, 0); return(keyinfo.chChar); #elif TARGET==WIN32 return(getch()); #elif defined(SUNOS) static struct termio cookedmode,rawmode; static int cookedok; int key; if (!cookedok) { ioctl(0,TCGETA,&cookedmode); ioctl(0,TCGETA,&rawmode); rawmode.c_iflag=IXON|IXOFF; rawmode.c_oflag&=~OPOST; rawmode.c_lflag=0; rawmode.c_cc[VEOF]=1; cookedok=1; } ioctl(0,TCSETAW,&rawmode); key=getchar(); ioctl(0,TCSETAW,&cookedmode); return key; #else return(getchar()); #endif } #endif /* Returns current system time, in # of ticks since midnight */ #if SFX_LEVEL>=ARJSFXV||defined(REGISTER) unsigned long get_ticks() { struct time sttime; arj_gettime(&sttime); return(((unsigned long)sttime.ti_hour*3600L+(unsigned long)sttime.ti_min*60L+ (unsigned long)sttime.ti_sec)*100L+(unsigned long)sttime.ti_hund); } #endif /* Retrieves current directory */ #if SFX_LEVEL>=ARJSFX&&SFX_LEVEL<=ARJSFXV void file_getcwd(char *buf, int len) { getcwd(buf, len); } #elif defined(REARJ) char *file_getcwd(char *buf) { #if TARGET==DOS if(lfn_supported!=LFN_NOT_SUPPORTED) return(w95_cwd(buf)); else return(getcwd(buf, CCHMAXPATH_W95)); #else #if COMPILER==ICC return(_getcwd(buf, CCHMAXPATH)); #else return(getcwd(buf, CCHMAXPATH)); #endif #endif } #endif /* Returns switch character used by OS */ #ifdef REARJ char get_sw_char() { #if TARGET==DOS union REGS regs; regs.x.ax=0x3700; intdos(®s, ®s); return(regs.h.dl); #elif TARGET==OS2 return('/'); #else return('-'); #endif } #endif /* Returns the amount of free space for disk on which the given file is located. */ #if SFX_LEVEL>=ARJSFXV||defined(REARJ) unsigned long file_getfree(char *name) { #if TARGET==DOS #if COMPILER==BCC struct dfree dtable; #elif COMPILER==MSC struct diskfree_t dtable; #endif char drive=0; while(name[0]==' ') /* Skip over leading spaces, if any */ name++; if(name[1]==':') drive=toupper(name[0])-0x40; #if COMPILER==BCC getdfree(drive, &dtable); if(dtable.df_sclus==65535) return(MAXLONG); else { return((LONG_MAX/((long)dtable.df_bsec*dtable.df_sclus)=ARJSFXV int file_find(char *name, struct file_properties *properties) { struct new_ffblk new_ffblk; int attrib=STD_FI_ATTRS; #if TARGET==UNIX int u; #endif if(lfn_findfirst(name, &new_ffblk, attrib)!=0) return(-1); else { #if SFX_LEVEL>=ARJ lfn_findclose(&new_ffblk); finddata_to_properties(properties, &new_ffblk); #else properties->ftime=new_ffblk.ff_ftime; properties->fsize=new_ffblk.ff_fsize; properties->attrib=(ATTRIB)new_ffblk.ff_attrib; #if TARGET!=UNIX properties->type=(new_ffblk.ff_attrib&FATTR_DIREC)?ARJT_DIR:ARJT_BINARY; properties->isarchive=(new_ffblk.ff_attrib&FATTR_ARCH)?1:0; #else u=uftype(new_ffblk.ff_attrib); if(u&FATTR_DT_DIR) properties->type=ARJT_DIR; else if(u&FATTR_DT_UXSPECIAL) properties->type=ARJT_UXSPECIAL; else properties->type=ARJT_BINARY; properties->isarchive=1; properties->l_search=new_ffblk.l_search; properties->l_search.ref=0; properties->islink=0; #endif #endif return(0); } } #endif /* Returns the size of the given file */ #if SFX_LEVEL>=ARJ||defined(REARJ) long file_getfsize(char *name) { #if SFX_LEVEL>=ARJ struct new_ffblk new_ffblk; int attrib=STD_FI_ATTRS; if(lfn_findfirst(name, &new_ffblk, attrib)!=0) return(0L); else { lfn_findclose(&new_ffblk); return(new_ffblk.ff_fsize); } #else FILE *stream; long rc; if((stream=file_open(name, m_rb))==NULL) return(0); #if TARGET!=UNIX rc=filelength(fileno(stream)); #else fseek(stream, 0L, SEEK_END); rc=ftell(stream); #endif fclose(stream); return(rc); #endif } #endif /* Returns last modification time for the given file */ #if SFX_LEVEL>=ARJSFX||defined(REARJ) unsigned long file_getftime(char *name) { #if TARGET==DOS #if SFX_LEVEL>=ARJSFXV struct new_ffblk new_ffblk; int attrib=STD_FI_ATTRS; if(lfn_findfirst(name, &new_ffblk, attrib)!=0) return(0L); else { #if SFX_LEVEL>=ARJ lfn_findclose(&new_ffblk); /* Done automatically by ARJSFXV */ #endif return(new_ffblk.ff_ftime); } #else FILE *stream; unsigned long rc; if((stream=file_open(name, m_rb))==NULL) return(0L); #if COMPILER==BCC getftime(fileno(stream), (struct ftime *)&rc); #else _dos_getftime(fileno(stream), (unsigned int *)&rc+1, (unsigned int *)&rc); #endif fclose(stream); return(rc); #endif #elif TARGET==OS2 HFILE hf; #ifdef __32BIT__ ULONG action; #else USHORT action; #endif FILESTATUS fstatus; if(DosOpen(name, &hf, &action, 0L, 0, FILE_OPEN, OPEN_ACCESS_READONLY|OPEN_SHARE_DENYNONE, 0L)) return(0L); DosQFileInfo(hf, FIL_STANDARD, &fstatus, sizeof(fstatus)); DosClose(hf); return(make_ftime(fstatus.fdateLastWrite, fstatus.ftimeLastWrite)); #elif TARGET==WIN32 FILETIME ftime, atime, ctime; HANDLE hf; if((hf=CreateFile(name, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0))==INVALID_HANDLE_VALUE) return(0L); if(!GetFileTime(hf, &ctime, &atime, &ftime)) return(0L); CloseHandle(hf); return(dosify_time(&ftime)); #elif TARGET==UNIX struct stat st; if(lstat(name, &st)==-1) return(0L); return(st.st_mtime); #endif } #endif /* Queries the volume label for the specified drive. The destination buffer will contain "" if the volume label is missing. */ #if SFX_LEVEL>=ARJ&&defined(HAVE_VOL_LABELS) int file_getlabel(char *label, char drive, ATTRIB *attrib, unsigned long *ftime) { #if TARGET==DOS struct new_ffblk new_ffblk; char wildcard[10]; if(drive=='\0') wildcard[0]='\0'; else { wildcard[0]=drive; wildcard[1]=':'; wildcard[2]='\0'; } strcat(wildcard, root_wildcard); if(lfn_findfirst(wildcard, &new_ffblk, FATTR_LABEL)) return(0); /* Pretty incorrect but, if no files are present, it won't be called */ if(_osmajor>2) { while(!(new_ffblk.ff_attrib&FATTR_LABEL)) { if(!lfn_findnext(&new_ffblk)) return(0); } lfn_findclose(&new_ffblk); } strcpy(label, new_ffblk.ff_name); *attrib=(ATTRIB)new_ffblk.ff_attrib; *ftime=new_ffblk.ff_ftime; return(0); #elif TARGET==OS2 FSINFO fsinfo; USHORT rc; rc=DosQFSInfo(drive=='\0'?0:drive-0x40, FSIL_VOLSER, (PBYTE)&fsinfo, sizeof(fsinfo)); if(rc) return((rc==ERROR_NO_VOLUME_LABEL)?0:-1); strcpy(label, fsinfo.vol.szVolLabel); return(0); #elif TARGET==WIN32 DWORD dummy; return(!GetVolumeInformation(NULL, label, CCHMAXPATH, NULL, &dummy, &dummy, NULL, 0)); #endif } #endif /* Read a line from the stdin w/echo, returning the number of bytes read. */ #if SFX_LEVEL>=ARJSFX||defined(REARJ) int read_line(char *buf, int size) { #if TARGET==DOS union REGS regs; #if SFX_LEVEL>=ARJSFX||defined(REARJ) char tmp_buf[160]; /* Actually, DOS limit is 128 */ #endif unsigned int ioctl_set, ioctl_isbinary, ioctl_response; int chars_read; int cchar; regs.x.ax=0x4400; /* IOCTL - query device */ regs.x.bx=0; /* STDIN */ intdos(®s, ®s); ioctl_response=regs.x.dx; ioctl_set=(ioctl_response&CHDI_SET)?1:0; ioctl_isbinary=(ioctl_response&CHDI_BINARY)?1:0; #ifdef REARJ ioctl_isbinary=ioctl_set&ioctl_isbinary; #endif if(ioctl_set&&ioctl_isbinary||_osmajor<3) { #if SFX_LEVEL>=ARJSFXV tmp_buf[0]=min(size, INPUT_LIMIT); /* Number of input positions */ tmp_buf[1]=tmp_buf[0]-1; /* Number of recallable positions */ regs.h.ah=0x0A; regs.x.dx=(unsigned int)tmp_buf; intdos(®s, ®s); chars_read=(int)tmp_buf[1]; if(tmp_buf[chars_read+2]=='\x0D') tmp_buf[chars_read+2]='\0'; /* Convert to ASCIIZ */ strcpy(buf, tmp_buf+2); nputlf(); /* v 2.72+ fixup to live happily under Unices */ #elif defined(REARJ) tmp_buf[0]=min(size, INPUT_LIMIT); /* Number of input positions */ cgets(tmp_buf); chars_read=(int)tmp_buf[1]; strcpy(buf, tmp_buf+2); #else error(M_RAW_INPUT_REJECTED); #endif } else { for(chars_read=0; (cchar=fgetc(stdin))!=EOF&&cchar!=LF; chars_read++) { if(chars_read=ARJSFX void get_mode_str(char *str, unsigned int mode) { #if TARGET==UNIX int i; str[0]='-'; for(i=0; i<3; i++) { str[(2-i)*3+1]=(mode&4)?'r':'-'; str[(2-i)*3+2]=(mode&2)?'w':'-'; str[(2-i)*3+3]=(mode&1)?'x':'-'; mode>>=3; } str[10]=' '; str[11]=(mode&FATTR_SGID)?'G':'-'; str[12]=(mode&FATTR_SUID)?'U':'-'; str[13]=(mode&FATTR_SVTX)?'A':'-'; str[14]='\0'; #else strcpy(str, attrib_buf); if(mode&FATTR_ARCH) str[0]='A'; if(mode&FATTR_SYSTEM) str[1]='S'; if(mode&FATTR_HIDDEN) str[2]='H'; if(mode&FATTR_RDONLY) str[3]='R'; #endif } #endif /* Retrieves an environment string */ #if TARGET==OS2&&SFX_LEVEL>=ARJSFX static char FAR *get_env_str(char *t) { #ifdef __32BIT__ PSZ rc; if(DosScanEnv(t, &rc)) return(NULL); return((char FAR *)rc); #else USHORT selector; USHORT cmd_offset; char FAR *env_ptr; int i; DosGetEnv(&selector, &cmd_offset); env_ptr=MAKEP(selector, 0); while(*env_ptr!='\0') { for(i=0; t[i]!='\0'; i++) if(env_ptr[i]=='\0'||env_ptr[i]!=t[i]) break; if(t[i]=='\0'&&env_ptr[i]=='=') return(env_ptr+i+1); env_ptr+=i; while(*env_ptr++!='\0'); } return(NULL); #endif } #endif /* Reserves memory and gets an environment string */ #if TARGET==OS2&&SFX_LEVEL>=ARJSFX char *malloc_env_str(char *t) { char FAR *str, FAR *sptr; char *rc, *rptr; int i; if((str=get_env_str(t))==NULL) return(NULL); i=1; for(sptr=str; *sptr!='\0'; sptr++) i++; if((rc=(char *)malloc(i))==NULL) return(NULL); /* Env. string was too long */ rptr=rc; for(sptr=str; *sptr!='\0'; sptr++) *rptr++=*sptr; *rptr='\0'; return(rc); } #endif /* A small exported stub for C RTL to be happy */ #if TARGET==OS2&&COMPILER==MSC&&SFX_LEVEL>=ARJ char *getenv(const char *str) { return(NULL); /* No such a string */ } #endif /* Executes the given program directly, returning its RC */ #if defined(REARJ)||(SFX_LEVEL>=ARJSFX&&TARGET==OS2) int exec_pgm(char *cmdline) { char tmp_cmd[CMDLINE_LENGTH+CCHMAXPATH]; #if TARGET==OS2 /* && SFX_LEVEL>=ARJSFX */ char *params; int p_pos; #ifdef REARJ #ifdef __32BIT__ PPIB ppib=NULL; PTIB ptib=NULL; ULONG child_pid, session_pid; REQUESTDATA qr; ULONG qrc; ULONG cb_res; #else PID child_pid, session_pid; PIDINFO pidi; QUEUERESULT qr; USHORT qrc; USHORT cb_res; #endif STARTDATA sd; char qname[CCHMAXPATH]; HQUEUE queue; USHORT errcode; PUSHORT res; BYTE elem_priority; char *argv[PARAMS_MAX]; int arg; static char param_sep[]=" "; #else RESULTCODES rc; #endif #ifndef REARJ memset(tmp_cmd, 0, sizeof(tmp_cmd)); if((params=strchr(cmdline, ' '))!=NULL) { p_pos=params-cmdline; if(p_pos>0) memcpy(tmp_cmd, cmdline, p_pos); strcpy(tmp_cmd+p_pos+1, params); } else strcpy(tmp_cmd, cmdline); if(!DosExecPgm(NULL, 0, EXEC_SYNC, tmp_cmd, NULL, &rc, tmp_cmd)) return(rc.codeResult); else return(-1); #else strncpy(tmp_cmd, cmdline, sizeof(tmp_cmd)-1); tmp_cmd[sizeof(tmp_cmd)-1]='\0'; argv[0]=strtok(tmp_cmd, param_sep); if(argv[0]==NULL) return(-1); for(arg=1; arg=PARAMS_MAX) return(-1); if((errcode=spawnvp(P_WAIT, argv[0], argv))!=0xFFFF) return(errcode); else { /* Try running the program asynchronously using the SESMGR */ memset(tmp_cmd, 0, sizeof(tmp_cmd)); if((params=strchr(cmdline, ' '))!=NULL) { p_pos=params-cmdline; if(p_pos>0) memcpy(tmp_cmd, cmdline, p_pos); strcpy(tmp_cmd+p_pos+1, params); } else strcpy(tmp_cmd, cmdline); #ifdef __32BIT__ DosGetInfoBlocks(&ptib, &ppib); /* Fixed for PJ24109 */ sprintf(qname, rearj_q_fmt, ppib->pib_ulpid); #else DosGetPID(&pidi); sprintf(qname, rearj_q_fmt, pidi.pid); #endif if(DosCreateQueue(&queue, QUE_FIFO, qname)) return(-1); memset(&sd, 0, sizeof(sd)); sd.Length=sizeof(sd); sd.Related=TRUE; sd.FgBg=TRUE; /* Start in background */ sd.PgmName=tmp_cmd; sd.PgmInputs=params; sd.TermQ=qname; sd.InheritOpt=1; if(DosStartSession(&sd, &session_pid, &child_pid)) return(-1); while((qrc=DosReadQueue(queue, &qr, &cb_res, (PVOID FAR *)&res, 0, DCWW_WAIT, &elem_priority, 0))==0) { errcode=res[1]; #ifdef __32BIT__ DosFreeMem(res); if(qr.ulData==0) break; #else DosFreeSeg(SELECTOROF(res)); if(qr.usEventCode==0) break; #endif } DosCloseQueue(queue); return(errcode); } #endif #else char *argv[PARAMS_MAX]; int arg; static char param_sep[]=" "; #if TARGET==UNIX int pid, rc, status; struct sigaction ign_set, intr, quit; #endif strncpy(tmp_cmd, cmdline, sizeof(tmp_cmd)-1); tmp_cmd[sizeof(tmp_cmd)-1]='\0'; argv[0]=strtok(tmp_cmd, param_sep); if(argv[0]==NULL) return(-1); for(arg=1; arg=PARAMS_MAX) return(-1); #if TARGET!=UNIX return(spawnvp(P_WAIT, argv[0], argv)); #else if((pid=fork())==-1) return(-1); if(pid==0) { exit(execvp(argv[0], argv)); } else { /* Prevent signals from appearing */ ign_set.sa_handler=SIG_IGN; ign_set.sa_flags=0; sigemptyset(&ign_set.sa_mask); sigaction(SIGINT, &ign_set, &intr); sigaction(SIGQUIT, &ign_set, &quit); /* Wait for the child */ do rc=waitpid(pid, &status, 0); while(rc==-1&&errno==EINTR); /* Restore signals */ sigaction(SIGINT, &intr, NULL); sigaction(SIGQUIT, &quit, NULL); return(status); } #endif #endif } #endif /* Executes a program or a shell command */ #if SFX_LEVEL>=ARJSFX&&TARGET==OS2 int system_cmd(char *cmd) { char tmp_cmd[CMDLINE_LENGTH+CCHMAXPATH]; char *comspec; comspec=malloc_env_str("COMSPEC"); strcpy(tmp_cmd, (comspec==NULL)?"cmd" EXE_EXTENSION:comspec); free_env_str(comspec); strcat(tmp_cmd, " /C"); strcat(tmp_cmd, cmd); return((exec_pgm(tmp_cmd)==-1)?-1:0); } #endif /* Retrieves the name of executable */ #if (SFX_LEVEL>=ARJSFXJR||defined(REARJ)) #ifndef SKIP_GET_EXE_NAME void get_exe_name(char *dest) { #if TARGET==DOS char FAR *env_ptr; unsigned short s_seg; unsigned int i; unsigned short psp_seg; if(_osmajor<3) { if(_osmajor!=2||_osminor!=11) strcpy(dest, default_exe); else { #if COMPILER==BCC s_seg=*(unsigned short FAR *)MK_FP(_psp, 2)-56; #else /* Microsoft C changes the MCB order */ s_seg=(*(unsigned short FAR *)0x00400013<<6)-56; #endif env_ptr=MK_FP(s_seg, 9); /* Not actually ENV but it works! */ i=0; while(*env_ptr!='\0'&&ipib_hmte, CCHMAXPATH, dest); #else USHORT selector; USHORT cmd_offset; char FAR *sptr; DosGetEnv(&selector, &cmd_offset); sptr=MAKEP(selector, 0); while(*(SHORT FAR *)sptr!=0) sptr++; sptr+=2; while(*sptr!='\0') *dest++=*sptr++; *dest='\0'; #endif #elif TARGET==WIN32 GetModuleFileName(NULL, dest, CCHMAXPATH); #endif } #else /* SKIP_GET_EXE_NAME */ void get_exe_name(char *dest, char *arg) { char *ps, *pe; int l; int len; if(strchr(arg, PATHSEP_DEFAULT)!=NULL) { strcpy(dest, arg); return; } len=FILENAME_MAX-2-strlen(arg); ps=getenv("PATH"); do { pe=strchr(ps, ':'); if(pe==NULL) pe=ps+(l=strlen(ps)); else l=pe-ps; if(l>=len) l=len-1; memcpy(dest, ps, l); if(dest[l-1]!=PATHSEP_DEFAULT) dest[l++]=PATHSEP_DEFAULT; strcpy(dest+l, arg); if(!access(dest, F_OK)||errno==EINVAL) return; ps=pe+1; } while(*pe!='\0'); /* Notes to porters: below are the totally unlikely "last-chance" values. The DOS legacy parts of ARJ open its executable when looking for SFX modules and help screens. In most cases we are happy with argv[0] and PATH lookup. When that fails, we assume the locations below, and if they are missing altogether, the corresponding code will gracefully terminate. */ #if SFX_LEVEL==ARJ strcpy(dest, "/usr/local/bin/arj"); #elif SFX_LEVEL==ARJSFXV strcpy(dest, "./arjsfxv"); #elif SFX_LEVEL==ARJSFX strcpy(dest, "./arjsfx"); #elif SFX_LEVEL==ARJSFXJR strcpy(dest, "./arjsfxjr"); #elif defined(REARJ) strcpy(dest, "/usr/local/bin/rearj"); #else dest[0]='\0'; #endif } #endif #endif /* Read a line from console without echoing it (used only when prompting for passwords) */ #if SFX_LEVEL>=ARJSFXV int read_line_noecho(char *buf, int size) { int chars_read; int cchar; chars_read=0; cchar=uni_getch(); while(cchar!=LF&&cchar!=CR) { if(cchar=='\b') { if(chars_read!=0) chars_read--; } else if(chars_read=ARJSFXV||defined(REARJ) unsigned int get_bytes_per_cluster(char *name) { #if TARGET==DOS #if COMPILER==BCC struct dfree dtable; #elif COMPILER==MSC struct diskfree_t dtable; #endif char drive=0; while(name[0]==' ') /* Skip over leading spaces, if any */ name++; if(name[1]==':') drive=toupper(name[0])-0x40; #if COMPILER==BCC getdfree(drive, &dtable); if(dtable.df_sclus==65535) return(1024); else return(dtable.df_bsec*dtable.df_sclus); #elif COMPILER==MSC if(_dos_getdiskfree((unsigned int)drive, &dtable)) return(1024); else return(dtable.bytes_per_sector*dtable.sectors_per_cluster); #endif #elif TARGET==OS2 USHORT drive=0; FSALLOCATE fsinfo; unsigned long rc; while(name[0]==' ') name++; if(name[1]==':') drive=toupper(name[0])-0x40; if(DosQFSInfo(drive, FSIL_ALLOC, (PBYTE)&fsinfo, sizeof(fsinfo))) return(ULONG_MAX); rc=(unsigned long)fsinfo.cbSector*fsinfo.cSectorUnit; return(rc>UINT_MAX?UINT_MAX:rc); #elif TARGET==WIN32 char fpn[CCHMAXPATH]; LPTSTR fnc; DWORD bps, spclu, fclu, clu; if(!GetFullPathName(name, CCHMAXPATH, fpn, &fnc)||fpn[1]!=':') return(ULONG_MAX); fpn[3]='\0'; if(!GetDiskFreeSpace(fpn, &spclu, &bps, &fclu, &clu)) return(ULONG_MAX); else return(bps*spclu); #elif TARGET==UNIX #ifdef linux struct statvfs vfs; if(statvfs(name, &vfs)==-1) return(512); else return(vfs.f_bsize); #else return(512); #endif #endif } #endif /* Returns canonical Windows 95 longname for a given file */ #if SFX_LEVEL>=ARJ&&TARGET==DOS void get_canonical_longname(char *cname, char *name) { int name_ofs; /* Offset of LFN within name[] */ char *cname_ptr, *name_ptr; if(name[1]==':'||name[0]==PATHSEP_DEFAULT||name[0]==PATHSEP_UNIX||name[0]=='.') name_ofs=0; else { w95_get_longname(cur_dir_spec, cname, CCHMAXPATH); name_ofs=strlen(cname); } w95_get_longname(name, cname, CCHMAXPATH); if(name_ofs==0) return; cname_ptr=cname; name_ptr=name+name_ofs; if(name_ptr[0]==PATHSEP_DEFAULT||name_ptr[0]==PATHSEP_UNIX) name_ptr++; while(name_ptr[0]!='\0') { (cname_ptr++)[0]=(name_ptr++)[0]; } cname_ptr[0]='\0'; } #endif /* Returns canonical short name for a given Windows 95 long filename */ #if SFX_LEVEL>=ARJ&&TARGET==DOS void get_canonical_shortname(char *cname, char *name) { int name_ofs; /* Offset of LFN within name[] */ char *cname_ptr, *name_ptr; if(name[1]==':'||name[0]==PATHSEP_DEFAULT||name[0]==PATHSEP_UNIX||name[0]=='.') name_ofs=0; else { w95_get_shortname(cur_dir_spec, cname, CCHMAXPATH); name_ofs=strlen(cname); } w95_get_shortname(name, cname, CCHMAXPATH); if(name_ofs==0) return; cname_ptr=cname; name_ptr=name+name_ofs; if(name_ptr[0]==PATHSEP_DEFAULT||name_ptr[0]==PATHSEP_UNIX) name_ptr++; while(name_ptr[0]!='\0') { (cname_ptr++)[0]=(name_ptr++)[0]; } cname_ptr[0]='\0'; } #endif /* Displays a string pointed to by a FAR pointer on the stdout. Used only by internal functions of ENVIRON.C. */ #if SFX_LEVEL>=ARJSFXV&&TARGET==DOS static void far_ttyout(char FAR *str) { union REGS regs; char FAR *str_ptr; str_ptr=str; regs.h.ah=2; /* Jung does it in the loop but we don't. */ while(str_ptr[0]!='\0') { regs.h.dl=(str_ptr++)[0]; intdos(®s, ®s); } } #endif /* Reads one character from keyboard without echo. Used only by internal functions of ENVIRON.C */ #if SFX_LEVEL>=ARJSFXV&&TARGET==DOS static int flush_and_getch() { union REGS regs; regs.x.ax=0xC08; /* Clear buffer and then getch */ intdos(®s, ®s); return((int)regs.h.al); } #endif /* "Intelligent" interrupt 24h handler */ #if SFX_LEVEL>=ARJSFXV&&TARGET==DOS #if COMPILER==BCC static void interrupt int24_smart_handler(unsigned int bp, unsigned int di, unsigned int si, unsigned int ds, unsigned int es, unsigned int dx, unsigned int cx, unsigned int bx, unsigned int ax) #elif COMPILER==MSC void _interrupt _far int24_smart_handler( unsigned int es, unsigned int ds, unsigned int di, unsigned int si, unsigned int bp, unsigned int sp, unsigned int bx, unsigned int dx, unsigned int cx, unsigned int ax, unsigned int ip, unsigned int cs, unsigned int flags) #endif { char msg[40]; char query[64]; #if COMPILER==BCC struct DOSERROR exterr; #elif COMPILER==MSC union REGS regs; #endif char dev[12]; char *action; FMSG *final_response; int user_action; char response; char drive; int errcode; #if COMPILER==MSC int dos_errcode; #endif int dev_ctr; #if COMPILER==MSC _enable(); dos_errcode=errcode=di&0xFF; #endif action=malloc_fmsg(ax&INT24_DPF_WRITING?M_WRITING:M_READING); #if SFX_LEVEL>=ARJ if(errcode>0x12) errcode=0x12; /* Ignore DOS 4.x error codes */ if(_osmajor>=3) { #if COMPILER==BCC errcode=dosexterr(&exterr); #elif COMPILER==MSC regs.h.ah=0x59; regs.x.bx=0; intdos(®s, ®s); errcode=regs.x.ax; #endif if(errcode<0x13||errcode>0x25) errcode=0x25; /* Ignore DOS 2.x/4.x error codes */ errcode-=0x13; } msg_strcpyn((FMSG *)msg, DOS_MSGS[errcode], sizeof(msg)-1); #else if(errcode>0x0D) errcode=0x0D; #endif if(ax&INT24_IO_ERROR) { if(((char *)MK_FP(bp, si))[5]&0x80) far_ttyout((char FAR *)M_CRIT_ERROR); else { for(dev_ctr=0; dev_ctr<8; dev_ctr++) dev[dev_ctr]=((char *)MK_FP(bp, si))[10+dev_ctr]; dev[dev_ctr]='\0'; msg_sprintf(query, M_DEVICE, msg, action, dev); far_ttyout((char FAR *)query); } } else { #if COMPILER==MSC if(f_file_ptr!=NULL&&dos_errcode==0x0D||dos_errcode==0x0E) msg_sprintf(query, M_FOPEN, msg, f_file_ptr); else #endif { drive=(char)ax+'A'; msg_sprintf(query, M_DRIVE, msg, action, drive); } far_ttyout((char FAR *)query); } user_action=1; if(ignore_errors) { free_fmsg(action); ax=INT24_FAIL; } else { query[1]=CR; query[2]=LF; query[3]='\0'; do { far_ttyout((char FAR *)M_OK_TO_RETRY); query[0]=response=(char)flush_and_getch(); far_ttyout((char FAR *)query); } while((final_response=msg_strchr(M_REPLIES, (char)toupper(response)))==NULL|| (user_action=final_response-M_REPLIES)>2); free_fmsg(action); if(user_action==0) ax=INT24_RETRY; else if(user_action==2||is_dos_31) /* DOS 2.x/3.0 do not support FAIL */ ax=INT24_ABORT; else { ax=INT24_FAIL; user_wants_fail=-1; } } } #endif /* Installs the "smart" handler */ #if SFX_LEVEL>=ARJSFXV void install_smart_handler() { #if TARGET==DOS setvect(INT24, int24_smart_handler); #elif TARGET==OS2 if(ignore_errors) { #ifdef __32BIT__ DosError(FERR_DISABLEHARDERR|FERR_DISABLEEXCEPTION); #else DosError(HARDERROR_DISABLE); DosError(EXCEPTION_DISABLE); #endif } #elif TARGET==UNIX /* No hard error daemon here */ #endif } #endif /* Checks if the given file handle actually represents a file */ #if SFX_LEVEL>=ARJSFXV int is_file(FILE *stream) { #if TARGET==DOS #if COMPILER==BCC return(ioctl(fileno(stream), 0)&CHDF_NOT_FILE?1:0); #elif COMPILER==MSC union REGS regs; regs.x.ax=0x4400; regs.x.bx=fileno(stream); intdos(®s, ®s); return(regs.x.dx&CHDF_NOT_FILE?1:0); #endif #elif TARGET==OS2||TARGET==WIN32 return(fileno(stream)<2?1:0); /* Another dirty hack... */ #else struct stat st; fstat(fileno(stream), &st); /* ASR fix 02/05/2003: ineed, we shouldn't check for FATTR_DT_REG here! */ return(st.st_mode==S_IFREG); #endif } #endif /* Returns 1 if the given file is stored on removable media */ #if SFX_LEVEL>=ARJSFXV int file_is_removable(char *name) { #if TARGET!=UNIX char drive=0; while(name[0]==' ') name++; if(name[1]==':') drive=toupper(name[0])-0x40; else drive=getdisk()+1; #if TARGET==DOS if(_osmajor<3) /* DOS 2.x - A: and B: are removable */ return(drive==1||drive==2); else #if COMPILER==BCC return(ioctl(drive, 8)==0); #elif COMPILER==MSC { union REGS regs; regs.x.ax=0x4408; regs.x.bx=(unsigned int)drive; intdos(®s, ®s); return(regs.x.ax==0); } #endif #elif TARGET==OS2||TARGET==WIN32 return(drive==1||drive==2); #endif #else return(0); /* BUGBUG: fix for floppies! */ #endif } #endif /* Checks if the given file handle represends a terminal or console */ #if SFX_LEVEL>=ARJSFXV||defined(REARJ) int is_tty(FILE *stream) { return(isatty(fileno(stream))==0?0:1); } #endif /* mkdir() - Borland's implementation */ #if SFX_LEVEL>=ARJSFX||defined(REARJ) int file_mkdir(char *name) { #if TARGET==DOS if(lfn_supported!=LFN_NOT_SUPPORTED) return(w95_mkdir(name)); else return(mkdir(name)); #elif TARGET==OS2||TARGET==WIN32 #ifdef __EMX__ return(mkdir(name, 0)); #else return(mkdir(name)); #endif #else return(mkdir(name, 0755)); #endif } #endif #if (TARGET==OS2||TARGET==WIN32)&&!defined(TILED) /* The "workhorse" routine for wildcard matching */ static int wild_proc(char *wild, char *name, UINT32 *trail, unsigned int first, unsigned int nesting) { #define set_trail(w,r) trail[((w)*MAXWILDAST+(r))>>5]|=(1<<(((w)*MAXWILDAST+(r))&31)) #define check_trail(w,r) (trail[((w)*MAXWILDAST+(r))>>5]&(1<<(((w)*MAXWILDAST+(r))&31))) int rc=1; if(nesting>=MAXWILDAST) return(1); while(*wild) { switch(*wild) { case '?': if(*name=='\0') return(1); wild++; break; case '*': if(!check_trail(first, nesting)&&!wild_proc(wild+1, name, trail, first, nesting+1)) return(0); if(*name=='\0') return(1); set_trail(first, nesting); break; default: if(toupper(*name)!=toupper(*wild)) return(1); wild++; } name++; first++; } return(*name!=*wild); #undef set_trail #undef check_trail } #endif /* Returns non-zero if the given filename matches the given wildcard */ #if SFX_LEVEL>=ARJSFX||defined(REARJ) int match_wildcard(char *name, char *wcard) { #if TARGET==DOS if(!stricmp(wcard, all_wildcard)) return(1); while(wcard[0]!='\0') { switch(wcard[0]) { case '*': while(name[0]!='\0'&&name[0]!='.') name++; while(wcard[0]!='\0'&&wcard[0]!='.') wcard++; break; case '.': if(name[0]!='\0') { if(name[0]!=wcard[0]) return(0); name++; } wcard++; break; case '?': if(name[0]!='\0'&&name[0]!='.') name++; wcard++; break; default: if(toupper(name[0])!=toupper(wcard[0])) return(0); name++; wcard++; } } return(name[0]=='\0'?1:0); #elif TARGET==OS2&&defined(TILED) char dest[CCHMAXPATH]; /* This is a speedy and compact hack for 16-bit mode */ DosEditName(0x0001, name, wcard, dest, CCHMAXPATH); return(!stricmp(dest, name)); #elif TARGET==OS2||TARGET==WIN32 char tmp_wild[CCHMAXPATH]; /* Bit map: (maximum # of wildcards) x (maximum pattern length) */ UINT32 trail[(MAXWILDAST*CCHMAXPATHCOMP+31)>>5]; int l; memcpy(tmp_wild, wcard, (l=strlen(wcard))+1); memset(trail, 0, sizeof(trail)); if(tmp_wild[l-1]=='.') { if(strchr(name, '.')!=NULL) return(1); tmp_wild[l-1]='\0'; } return(!wild_proc(tmp_wild, name, trail, 0, 0)); #else int rc; rc=fnmatch(wcard, name, 0); #ifndef TOLERANT_FNMATCH if(rc) rc=strcmp_os(wcard, name); #endif return(!rc); #endif } #endif /* rmdir() */ #if SFX_LEVEL>=ARJ||defined(REARJ) int file_rmdir(char *name) { #if TARGET!=UNIX if(clear_archive_bit) dos_chmod(name, FATTR_NOARCH); #endif #if TARGET==DOS if(lfn_supported!=LFN_NOT_SUPPORTED) return(w95_rmdir(name)); else return(rmdir(name)); #else return(rmdir(name)); #endif } #endif /* unlink() */ #if SFX_LEVEL>=ARJSFX||defined(REARJ) int file_unlink(char *name) { #if SFX_LEVEL>=ARJSFXV&&TARGET!=UNIX if(file_test_access(name)) return(-1); #if SFX_LEVEL>=ARJ if(clear_archive_bit) dos_chmod(name, 0); #else if(overwrite_ro) dos_chmod(name, 0); #endif #endif #if TARGET==DOS if(lfn_supported!=LFN_NOT_SUPPORTED) return(w95_unlink(name)); else return(unlink(name)); #else return(unlink(name)); #endif } #endif /* rename() */ #if SFX_LEVEL>=ARJ||defined(REARJ) int file_rename(char *oldname, char *newname) { #if TARGET==DOS if(lfn_supported!=LFN_NOT_SUPPORTED) return(w95_rename(oldname, newname)); else return(rename(oldname, newname)); #else return(rename(oldname, newname)); #endif } #endif /* This INT 24h handler always forces the operation that causes it to fail */ #if SFX_LEVEL>=ARJ&&TARGET==DOS #if COMPILER==BCC static void interrupt int24_autofail_handler(unsigned int bp, unsigned int di, unsigned int si, unsigned int ds, unsigned int es, unsigned int dx, unsigned int cx, unsigned int bx, unsigned int ax) #elif COMPILER==MSC void _interrupt _far int24_autofail_handler(unsigned int es, unsigned int ds, unsigned int di, unsigned int si, unsigned int bp, unsigned int sp, unsigned int bx, unsigned int dx, unsigned int cx, unsigned int ax, unsigned int ip, unsigned int cs, unsigned int flags) #endif { char msg[40]; char query[64]; #if COMPILER==BCC struct DOSERROR exterr; #elif COMPILER==MSC union REGS regs; #endif char *action; char drive; int errcode; #if COMPILER==MSC _enable(); #endif action=malloc_fmsg(ax&INT24_DPF_WRITING?M_WRITING:M_READING); errcode=di&0xFF; if(errcode>0x12) errcode=0x12; /* Ignore DOS 4.x error codes */ if(_osmajor>=3) { #if COMPILER==BCC errcode=dosexterr(&exterr); #elif COMPILER==MSC regs.h.ah=0x59; regs.x.bx=0; intdos(®s, ®s); errcode=regs.x.ax; #endif if(errcode<0x13||errcode>0x25) errcode=0x25; /* Ignore DOS 2.x/4.x error codes */ errcode-=0x13; } msg_strcpyn((FMSG *)msg, DOS_MSGS[errcode], sizeof(msg)-1); drive=(char)(ax&0xFF)+'A'; msg_sprintf(query, M_DRIVE, msg, action, drive); far_ttyout(query); free_fmsg(action); ax=INT24_FAIL; } #endif /* Clears the archive attribute */ #if SFX_LEVEL>=ARJ int dos_clear_arch_attr(char *name) { #if TARGET!=UNIX int cur_attr, result; #if TARGET==DOS #if COMPILER==BCC void interrupt (*oldhdl)(); #elif COMPILER==MSC void (_interrupt _far *oldhdl)(); #endif #endif cur_attr=file_chmod(name, 0, 0)&STD_FILE_ATTR; if((cur_attr&~FATTR_ARCH)==cur_attr) return(0); cur_attr&=~FATTR_ARCH; #if TARGET==DOS if(is_dos_31) result=file_chmod(name, 1, cur_attr); else { oldhdl=getvect(INT24); setvect(INT24, int24_autofail_handler); result=file_chmod(name, 1, cur_attr); setvect(INT24, oldhdl); } #elif TARGET==OS2||TARGET==WIN32 result=file_chmod(name, 1, cur_attr); #endif return(result==-1?-1:0); #else return(0); #endif } #endif /* Flushes the disk cache and resets the drive (W95) */ #if SFX_LEVEL>=ARJ&&TARGET==DOS static int w95_resetdrive(int drive) { union REGS regs; struct SREGS sregs; memset(&sregs, 0, sizeof(sregs)); regs.x.cx=W95_FLUSH_CACHE; regs.x.dx=drive; return(call_dos_int(W95_RESETDRIVE, ®s, &sregs)?-1:0); } #endif /* Flushes the disk cache and resets the drive (W95) */ #if SFX_LEVEL>=ARJ int reset_drive(char *name) { #if TARGET==DOS int drive; while(name[0]==' ') name++; if(name[1]==':') drive=(int)(toupper(name[0]))-0x40; else drive=getdisk()+1; if(_osmajor<7) /* DOS 2.x - A: and B: are removable */ { bdos(0x0D, 0, 0); return(1); } else { if(w95_test_for_lfn(drive_c)) { w95_resetdrive(drive); return(1); } else return(0); } #elif TARGET==OS2 HFILE hf; #ifdef __32BIT__ ULONG action; #else USHORT action; #endif if(DosOpen(name, &hf, &action, 0L, 0, FILE_OPEN, OPEN_ACCESS_READONLY|OPEN_SHARE_DENYNONE, 0L)) return(0); #ifdef TILED DosBufReset(hf); #else DosResetBuffer(hf); #endif DosClose(hf); return(0); #elif TARGET==WIN32 return(0); #elif TARGET==UNIX sync(); return(0); #endif } #endif /* Checks for pending keystrokes and clears the keyboard buffer. */ #if SFX_LEVEL>=ARJSFXV||defined(REARJ) int fetch_keystrokes() { #if TARGET==DOS union REGS regs; int rc=0; while(kbhit()) { regs.h.ah=7; intdos(®s, ®s); rc=1; } return(rc); #elif TARGET==OS2 #if COMPILER==MSC int rc=0; KBDKEYINFO keyinfo; while(kbhit()) { rc=1; KbdCharIn(&keyinfo, IO_WAIT, 0); } return(rc); #else KBDKEYINFO keyinfo; int rc, pressed; int frc=0; do { rc=KbdPeek(&keyinfo, 0); pressed=rc?0:(keyinfo.fbStatus&KBDTRF_FINAL_CHAR_IN); if(pressed) { frc=1; KbdCharIn(&keyinfo, IO_WAIT, 0); } } while(pressed); return(frc); #endif #else return(0); /* Not implemented */ #endif } #endif /* Changes the current directory and/or drive */ #if SFX_LEVEL>=ARJSFX&&SFX_LEVEL<=ARJSFXV void file_chdir(char *dir) { #ifdef HAVE_DRIVES int l; char *tmp_dir; if((l=strlen(dir))>2) { if(dir[1]==':') if((dir[l-1]==PATHSEP_DOS||dir[l-1]==PATHSEP_UNIX)&&(dir[1]!=':'||l!=3)) { tmp_dir=malloc(l); if(tmp_dir==NULL) /* ASR fix 29/10/2000 */ return; strcpy(tmp_dir, dir); tmp_dir[l-1]='\0'; chdir(tmp_dir); free(tmp_dir); } } #else chdir(dir); #endif } #elif defined(REARJ) /* REARJ modification (LFN-capable) */ int file_chdir(char *dir) { #ifdef HAVE_DRIVES char dest_disk; if(dir[1]==':') { dest_disk=toupper(dir[0])-'A'; if(setdisk(dest_disk)=ARJSFX||defined(REARJ) int dos_chmod(char *name, int attrib) { #if TARGET!=UNIX return(file_chmod(name, 1, attrib&STD_FILE_ATTR)==-1?-1:0); #else return(file_chmod(name, 1, attrib)==-1?-1:0); #endif } #endif /* Changes the size of the file (Borland-specific implementation) */ #if SFX_LEVEL>=ARJ int file_chsize(FILE *stream, unsigned long size) { #if TARGET!=UNIX return(chsize(fileno(stream), size)); #else return(ftruncate(fileno(stream), size)); #endif } #endif /* Sets last modification date/time for a file specified by handle */ #if (SFX_LEVEL==ARJSFXJR||SFX_LEVEL>=ARJ)&&TARGET!=UNIX int file_setftime_on_hf(int hf, unsigned long ftime) { #if TARGET==DOS #if COMPILER==BCC return(setftime(hf, (struct ftime *)&ftime)); #elif COMPILER==MSC return(_dos_setftime(hf, *((unsigned int *)&ftime+1), *(unsigned int *)&ftime)); #endif #elif TARGET==OS2 HFILE hfc; FILESTATUS fstatus; hfc=(HFILE)hf; /* Dirty hack but it works */ DosQFileInfo(hfc, FIL_STANDARD, &fstatus, sizeof(fstatus)); *(USHORT *)&fstatus.fdateLastWrite=ftime>>16; *(USHORT *)&fstatus.ftimeLastWrite=ftime&0xFFFF; return(DosSetFileInfo(hfc, FIL_STANDARD, (PBYTE)&fstatus, sizeof(fstatus))); #elif TARGET==WIN32 return(-1); /* Nobody wants to play it under Win32 (fileno is NOT a HANDLE) */ #endif } #endif /* Updates the modification date/time field in the file's directory entry for a file that has been already open. */ #if SFX_LEVEL>=ARJ&&TARGET!=UNIX int file_setftime_on_stream(FILE *stream, unsigned long ftime) { return(file_setftime_on_hf(fileno(stream), ftime)); } #endif /* UNIX file time request router */ #if TARGET==UNIX&&(SFX_LEVEL>=ARJSFX||defined(REARJ)) static int ftime_router(char *name, int idx, unsigned long ftime) { struct stat st; struct utimbuf ut; int rc; #if SFX_LEVEL>=ARJ struct stat resolved_st; int res_cnt, protect_resolved=0; char resolved_name[CCHMAXPATH]; #endif if(lstat(name, &st)==-1) return(-1); /* If it is a symlink, protect the original file */ if(S_ISLNK(st.st_mode)) { #if SFX_LEVEL>=ARJ if(!symlink_accuracy) return(-1); res_cnt=readlink(name, resolved_name, sizeof(resolved_name)-1); if(res_cnt>0) { resolved_name[res_cnt]='\0'; if(stat(name, &resolved_st)!=-1) protect_resolved=1; } #else return(-1); #endif } ut.actime=(idx==UFTREQ_ATIME)?ftime:st.st_atime; ut.modtime=(idx==UFTREQ_FTIME)?ftime:st.st_mtime; rc=utime(name, &ut); #if SFX_LEVEL>=ARJ if(protect_resolved) { ut.actime=resolved_st.st_atime; ut.modtime=resolved_st.st_mtime; rc=utime(resolved_name, &ut); } #endif return(rc); } #endif /* Updates the last access date field in the file's directory entry (unlike file_setftime, standard parameters are passed). */ #if SFX_LEVEL>=ARJSFXV int file_setatime(char *name, unsigned long ftime) { #if TARGET==DOS FILE *stream; int result; if(lfn_supported!=LFN_NOT_SUPPORTED) { if((stream=fopen(name, m_rbp))==NULL) if((stream=fopen(name, m_rb))==NULL) return(-1); result=w95_set_dta(fileno(stream), ftime); fclose(stream); return(result); } else return(0); #elif TARGET==OS2 #ifdef __32BIT__ FILESTATUS3 fstatus; #else FILESTATUS fstatus; #endif #ifdef __32BIT__ DosQueryPathInfo(name, FIL_STANDARD, (PBYTE)&fstatus, sizeof(fstatus)); #else DosQPathInfo(name, FIL_STANDARD, (PBYTE)&fstatus, sizeof(fstatus), 0L); #endif *(USHORT *)&fstatus.fdateLastAccess=ftime>>16; *(USHORT *)&fstatus.ftimeLastAccess=ftime&0xFFFF; #ifdef __32BIT__ return(DosSetPathInfo(name, FIL_STANDARD, (PBYTE)&fstatus, sizeof(fstatus), 0)); #else return(DosSetPathInfo(name, FIL_STANDARD, (PBYTE)&fstatus, sizeof(fstatus), 0, 0L)); #endif #elif TARGET==WIN32 HANDLE hf; FILETIME satime, sftime, sctime; if((hf=CreateFile(name, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0))==INVALID_HANDLE_VALUE) return(-1); GetFileTime(hf, &sctime, &satime, &sftime); ntify_time(&satime, ftime); SetFileTime(hf, &sctime, &satime, &sftime); CloseHandle(hf); return(0); #elif TARGET==UNIX return(ftime_router(name, UFTREQ_ATIME, ftime)); #endif } #endif /* Updates the creation date/time field in the file's directory entry (unlike file_setftime, standard parameters are passed). */ #if SFX_LEVEL>=ARJSFXV int file_setctime(char *name, unsigned long ftime) { #if TARGET==DOS FILE *stream; int result; #endif #if TARGET==DOS if(lfn_supported!=LFN_NOT_SUPPORTED) { if((stream=fopen(name, m_rbp))==NULL) if((stream=fopen(name, m_rb))==NULL) return(-1); result=w95_set_dtc(fileno(stream), ftime); fclose(stream); return(result); } else return(0); #elif TARGET==OS2 #ifdef __32BIT__ FILESTATUS3 fstatus; #else FILESTATUS fstatus; #endif #ifdef __32BIT__ DosQueryPathInfo(name, FIL_STANDARD, (PBYTE)&fstatus, sizeof(fstatus)); #else DosQPathInfo(name, FIL_STANDARD, (PBYTE)&fstatus, sizeof(fstatus), 0L); #endif *(USHORT *)&fstatus.fdateCreation=ftime>>16; *(USHORT *)&fstatus.ftimeCreation=ftime&0xFFFF; #ifdef __32BIT__ return(DosSetPathInfo(name, FIL_STANDARD, (PBYTE)&fstatus, sizeof(fstatus), 0)); #else return(DosSetPathInfo(name, FIL_STANDARD, (PBYTE)&fstatus, sizeof(fstatus), 0, 0L)); #endif #elif TARGET==WIN32 HANDLE hf; FILETIME satime, sftime, sctime; if((hf=CreateFile(name, GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0))==INVALID_HANDLE_VALUE) return(-1); GetFileTime(hf, &sctime, &satime, &sftime); ntify_time(&sctime, ftime); SetFileTime(hf, &sctime, &satime, &sftime); CloseHandle(hf); return(0); #elif TARGET==UNIX return(ftime_router(name, UFTREQ_CTIME, ftime)); #endif } #endif /* Updates the modification date/time field in the file's directory entry */ #if SFX_LEVEL>=ARJSFX||defined(REARJ)||defined(NEED_SETFTIME_HACK) int file_setftime(char *name, unsigned long ftime) { #if TARGET==DOS FILE *stream; int result; if((stream=fopen(name, m_rbp))==NULL) #if SFX_LEVEL>=ARJSFXV if((stream=fopen(name, m_rb))==NULL) #endif return(-1); #if COMPILER==BCC result=setftime(fileno(stream), (struct ftime *)&ftime); #elif COMPILER==MSC result=_dos_setftime(fileno(stream), *((unsigned int *)&ftime+1), *(unsigned int *)&ftime); #endif fclose(stream); return(result); #elif TARGET==OS2 #ifdef __32BIT__ FILESTATUS3 fstatus; #else FILESTATUS fstatus; #endif #ifdef __32BIT__ DosQueryPathInfo(name, FIL_STANDARD, (PBYTE)&fstatus, sizeof(fstatus)); #else DosQPathInfo(name, FIL_STANDARD, (PBYTE)&fstatus, sizeof(fstatus), 0L); #endif *(USHORT *)&fstatus.fdateLastWrite=ftime>>16; *(USHORT *)&fstatus.ftimeLastWrite=ftime&0xFFFF; #ifdef __32BIT__ return(DosSetPathInfo(name, FIL_STANDARD, (PBYTE)&fstatus, sizeof(fstatus), 0)); #else return(DosSetPathInfo(name, FIL_STANDARD, (PBYTE)&fstatus, sizeof(fstatus), 0, 0L)); #endif #elif TARGET==WIN32 HANDLE hf; FILETIME satime, sftime, sctime; if((hf=CreateFile(name, GENERIC_WRITE, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0))==INVALID_HANDLE_VALUE) return(-1); GetFileTime(hf, &sctime, &satime, &sftime); ntify_time(&sftime, ftime); SetFileTime(hf, &sctime, &satime, &sftime); CloseHandle(hf); return(0); #elif TARGET==UNIX return(ftime_router(name, UFTREQ_FTIME, ftime)); #endif } #endif /* Sets the volume label */ #if SFX_LEVEL>=ARJSFXV&&defined(HAVE_DRIVES) int file_setlabel(char *label, char drive, ATTRIB attrib, unsigned long ftime) { #if TARGET==DOS union REGS regs; char fnm[64]; struct xfcb xfcb; char dta[64]; char FAR *saved_dta; int handle; if(_osmajor<2) return(-1); /* Set DTA so it'll point to an internal structure */ saved_dta=getdta(); setdta((char FAR *)dta); /* Fill the extended FCB structure */ xfcb.xfcb_flag=0xFF; xfcb.xfcb_attr=FATTR_LABEL; if(drive!='\0') xfcb.xfcb_fcb.fcb_drive=toupper(drive)-0x40; strcpy(xfcb.xfcb_fcb.fcb_name, fcb_mask); /* Find first matching file (i.e., volume label) using this FCB. Note that the current directory does not need to be root. */ regs.h.ah=0x11; /* findfirst() for FCB */ regs.x.dx=(unsigned int)&xfcb; intdos(®s, ®s); setdta(saved_dta); /* Temporarily restore the DTA */ if(_osmajor==2) { /* If there's a label, just rename it */ if(regs.h.al==0) { #if COMPILER==BCC parsfnm(label, (struct fcb *)(dta+0x17), 3); #elif COMPILER==MSC regs.x.ax=0x2903; regs.x.si=(unsigned int)label; regs.x.di=(unsigned int)(dta+0x17); intdos(®s, ®s); #endif regs.h.ah=0x17; /* rename() for FCB */ regs.x.dx=(unsigned int)dta; intdos(®s, ®s); } /* Otherwise, create a new file */ else { #if COMPILER==BCC parsfnm(label, &xfcb.xfcb_fcb, 3); #elif COMPILER==MSC regs.x.ax=0x2903; regs.x.si=(unsigned int)label; regs.x.di=(unsigned int)&xfcb.xfcb_fcb; intdos(®s, ®s); #endif regs.h.ah=0x16; /* create file using FCB */ regs.x.dx=(unsigned int)&xfcb; intdos(®s, ®s); /* Close file if it has been created successfully */ if(regs.h.al==0) { regs.h.ah=0x10; /* fclose() for FCB */ regs.x.dx=(unsigned int)&xfcb; intdos(®s, ®s); } } return((int)regs.h.al); } /* DOS 3.x */ else { if(regs.h.al==0) /* Check RC from findfirst() */ { regs.h.ah=0x13; /* unlink() for FCB */ regs.x.dx=(unsigned int)dta; intdos(®s, ®s); } if(drive!='\0') { fnm[0]=drive; fnm[1]=':'; fnm[2]='\0'; } else fnm[0]='\0'; strcat(fnm, label); if((handle=_creat(fnm, FATTR_LABEL))==EOF) return(-1); #if COMPILER==BCC setftime(handle, (struct ftime *)&ftime); #elif COMPILER==MSC return(_dos_setftime(handle, *((unsigned int *)&ftime+1), *(unsigned int *)&ftime)); #endif _close(handle); return(0); } #elif TARGET==OS2 VOLUMELABEL vl; strcpyn(vl.szVolLabel, label, 11); vl.cch=strlen(vl.szVolLabel); return(DosSetFSInfo(drive=='\0'?0:drive-0x40, FSIL_VOLSER, (PBYTE)&vl, sizeof(vl))); #elif TARGET==WIN32 char vn[4]; vn[0]=drive; vn[1]=':'; vn[2]='\\'; vn[3]='\0'; return(!SetVolumeLabel(vn, label)); #endif } #endif /* Sets the file type */ #if SFX_LEVEL>=ARJ int file_settype(FILE *stream, int istext) { #if TARGET!=UNIX fflush(stream); #if COMPILER==HIGHC&&!defined(LIBC) setmode(stream, istext?_O_TEXT:_O_BINARY); #else setmode(fileno(stream), istext?O_TEXT:O_BINARY); #endif #endif return(1); } #endif /* Sets the file API mode */ #if SFX_LEVEL>=ARJ void set_file_apis(int is_ansi) { #if TARGET==WIN32 if(is_ansi) SetFileApisToANSI(); else SetFileApisToOEM(); #endif } #endif /* Creates a subdirectory tree (qmode specifies if the user is to be asked). Returns 1 if an error occured */ #if SFX_LEVEL>=ARJSFX #if SFX_LEVEL>=ARJSFXV int create_subdir_tree(char *path, int qmode, int datatype) #else int create_subdir_tree(char *path, int datatype) #endif { char tmp_path[CCHMAXPATH]; /* Jung uses 256 but it's incorrect */ char *tmp_ptr; int access_status; int no_queries; /* 1 automatically forces "yes" */ #if SFX_LEVEL>=ARJSFXV tmp_ptr=validate_path(path, VALIDATE_ALL); no_queries=qmode||prompt_for_mkdir; #else tmp_ptr=validate_path(path); no_queries=yes_on_all_queries||make_directories; #endif while((tmp_ptr=find_delimiter(tmp_ptr, datatype))!=NULL) { strcpyn(tmp_path, path, tmp_ptr-path+1); if((access_status=file_chmod(tmp_path, 0, 0))==-1) { if(!no_queries) { #if SFX_LEVEL>=ARJSFXV msg_sprintf(misc_buf, M_QUERY_CREATE_DIR, path); /* If the user forbids creation, return 1 */ if((no_queries=query_action(0, QUERY_CREATE_DIR, misc_buf))==0) return(1); #else msg_cprintf(0, M_QUERY_CREATE_DIR, path); if((no_queries=query_action())==0) return(1); #endif } if(file_mkdir(tmp_path)&&errno!=ENOENT) { /* Creation failed, inform the user about it */ #if SFX_LEVEL>=ARJSFXV msg_cprintf(H_ERR, M_CANT_MKDIR, tmp_path); #else msg_cprintf(H_ERR, M_CANT_MKDIR, tmp_path); #endif #if SFX_LEVEL>=ARJ error_report(); #endif return(1); } } else { /* If a file with the same name exists, jerk off... */ #if TARGET!=UNIX if(!(access_status&FATTR_DIREC)) #else struct stat st; if((stat(tmp_path, &st)==-1)||!S_ISDIR(st.st_mode)) #endif { #if SFX_LEVEL>=ARJSFXV msg_cprintf(H_ERR, M_CANT_MKDIR, tmp_path); #else msg_cprintf(H_ERR, M_CANT_MKDIR, tmp_path); #endif return(1); } } if(*tmp_ptr!='\0') tmp_ptr++; } return(0); } #endif /* Returns 1 if the given filename is valid, 0 otherwise */ #if SFX_LEVEL>=ARJSFXV int is_filename_valid(char *name) { return(name[0]=='\0'?0:1); } #endif /* Returns 1 if the given file is a directory, 0 otherwise */ #if SFX_LEVEL>=ARJSFXV int is_directory(char *name) { int attrib; attrib=file_chmod(name, 0, 0); if(attrib==-1) return(0); else #if TARGET!=UNIX return(attrib&FATTR_DIREC?1:0); #else return(S_ISDIR(attrib)); #endif } #endif /* Allocate memory and create a wildcard that expands to all files of the subdirectory given. */ #if SFX_LEVEL>=ARJ char *malloc_subdir_wc(char *name) { char tmp_wc[WC_RESERVE]; char *wc_ptr; tmp_wc[0]=PATHSEP_DEFAULT; strcpy(tmp_wc+1, all_wildcard); wc_ptr=malloc_msg(strlen(tmp_wc)+strlen(name)+2); strcpy(wc_ptr, name); strcat(wc_ptr, tmp_wc); return(wc_ptr); } #endif /* Copies one file to another, performing a check if needed. Issues a native API if the target platform supports it (note: Win32 does not provide a way to verify the file so we avoid the CopyFile function under Win32) */ #if SFX_LEVEL>=ARJ int file_copy(char *dest, char *src, int chk) { #if TARGET==OS2 #ifdef __32BIT__ BOOL32 vf; APIRET rc; #else BOOL vf; USHORT rc; #endif if(chk) { #ifdef __32BIT__ DosQueryVerify(&vf); #else DosQVerify(&vf); #endif DosSetVerify(1); } #ifdef __32BIT__ rc=DosCopy(src, dest, DCPY_EXISTING); #else rc=DosCopy(src, dest, DCPY_EXISTING, 0); #endif if(chk) { msg_cprintf(0, M_TESTING, dest); DosSetVerify(vf); } switch(rc) { case NO_ERROR: break; case ERROR_FILE_NOT_FOUND: case ERROR_PATH_NOT_FOUND: case ERROR_ACCESS_DENIED: case ERROR_SHARING_VIOLATION: msg_cprintf(H_ERR, M_CANTOPEN, src); break; case ERROR_DISK_FULL: msg_cprintf(0, M_DISK_FULL); break; default: msg_cprintf(0, M_CRC_ERROR); break; } if(rc) { nputlf(); return(-1); } return(0); #else FILE *istream, *ostream; char *buf, *dbuf; unsigned int bytes_read; istream=file_open(src, m_rb); if(istream==NULL) { error_report(); msg_cprintf(H_ERR, M_CANTOPEN, src); nputlf(); return(-1); } ostream=file_open(dest, m_wb); if(ostream==NULL) { fclose(istream); error_report(); msg_cprintf(H_ERR, M_CANTOPEN, dest); nputlf(); return(-1); } buf=malloc_msg(PROC_BLOCK_SIZE); mem_stats(); while((bytes_read=fread(buf, 1, PROC_BLOCK_SIZE, istream))>0) { if(fwrite(buf, 1, bytes_read, ostream)!=bytes_read) { msg_cprintf(0, M_DISK_FULL); nputlf(); break; } } free(buf); if(fclose(ostream)) { fclose(istream); return(-1); } if(fclose(istream)) return(-1); if(file_is_removable(dest)) reset_drive(dest); if(bytes_read==0&&chk) { msg_cprintf(0, M_TESTING, dest); istream=file_open(src, m_rb); if(istream==NULL) { error_report(); msg_cprintf(H_ERR, M_CANTOPEN, src); nputlf(); return(-1); } ostream=file_open(dest, m_rb); if(ostream==NULL) { fclose(istream); error_report(); msg_cprintf(H_ERR, M_CANTOPEN, dest); nputlf(); return(-1); } buf=malloc_msg(PROC_BLOCK_SIZE/2); dbuf=malloc_msg(PROC_BLOCK_SIZE/2); while((bytes_read=fread(buf, 1, PROC_BLOCK_SIZE/2, istream))>0) { if(fread(dbuf, 1, PROC_BLOCK_SIZE/2, ostream)!=bytes_read) break; if(memcmp(buf, dbuf, bytes_read)) break; } free(buf); free(dbuf); fclose(ostream); fclose(istream); msg_cprintf(0, (FMSG *)vd_space); msg_cprintf(0, bytes_read==0?M_OK:M_CRC_ERROR); } return((bytes_read>0)?-1:0); #endif } #endif #if SFX_LEVEL>=ARJ||defined(REARJ) /* ASR fix 02/04/2003: Reduce memory consumption on 16-bit systems. */ #ifdef TILED static char *pack_fname(char *f) { char *rc; if((rc=(char *)realloc(f, strlen(f)+1))==NULL) return(f); return(rc); } #else #define pack_fname(f) (f) #endif /* Recursive subdirectory search helper */ #ifndef REARJ int wild_subdir(struct flist_root *root, struct flist_root *search_flist, char *name, int expand_wildcards, int recurse_subdirs, int file_type, FILE_COUNT *count) #else int wild_subdir(struct flist_root *root, char *name, int file_type, int expand_wildcards, int recurse_subdirs, FILE_COUNT *count) #endif { int attr_mask; /* Narrowing criteria */ struct new_ffblk *pnew_ffblk=NULL; /* OS-dependent data block */ char *subdir_spec=NULL; /* Subdirectory name */ char *tmp_name=NULL; int result=0, rc; char *subdir_wildcard=NULL; /* Subdirectory entries */ if(recurse_subdirs) { attr_mask=STD_DIR_ATTR; if(file_type!=FETCH_DEFAULT) #if TARGET!=UNIX attr_mask|=FATTR_HIDDEN|FATTR_SYSTEM|FATTR_RDONLY; #else attr_mask|=FATTR_DT_REG|FATTR_DT_UXSPECIAL; #endif #ifndef REARJ #if TARGET==UNIX if(filter_attrs) { if(file_attr_mask&TAG_SYSTEM) attr_mask|=FATTR_SYSTEM; if(file_attr_mask&TAG_HIDDEN) attr_mask|=FATTR_HIDDEN; if(file_attr_mask&TAG_RDONLY) attr_mask|=FATTR_RDONLY; #if TARGET==UNIX if(file_attr_mask&TAG_UXSPECIAL) attr_mask|=FATTR_DT_UXSPECIAL; if(file_attr_mask&TAG_DIREC) attr_mask|=FATTR_DT_DIR; #endif } #endif #endif if((subdir_spec=(char *)malloc(strlen(name)+WC_RESERVE))==NULL) { result=-1; goto l_error; } split_name(name, subdir_spec, NULL); strcat(subdir_spec, all_wildcard); case_path(subdir_spec); subdir_spec=pack_fname(subdir_spec); if((pnew_ffblk=(struct new_ffblk *)malloc(sizeof(struct new_ffblk)))==NULL) { result=-1; goto l_error; } rc=lfn_findfirst(subdir_spec, pnew_ffblk, attr_mask); while(rc==0) { if( /* Entries like "." and ".." are skipped */ pnew_ffblk->ff_attrib&STD_DIR_ATTR&&strcmp(pnew_ffblk->ff_name, cur_dir_spec)&&strcmp(pnew_ffblk->ff_name, up_dir_spec) #if TARGET==UNIX&&SFX_LEVEL>=ARJ /* Disallow circular symlinks - the symlink will be stored but will not be recursed into */ &&link_search(&sl_entries, &pnew_ffblk->l_search, NULL, 0)==FLS_NONE #endif ) { /* Reallocate these */ if((subdir_wildcard=(char *)realloc(subdir_wildcard, CCHMAXPATHCOMP))==NULL|| (tmp_name=(char *)realloc(tmp_name, CCHMAXPATH+20))==NULL) { result=-1; goto l_error; } split_name(name, tmp_name, subdir_wildcard); subdir_wildcard=pack_fname(subdir_wildcard); if(strlen(tmp_name)+strlen(pnew_ffblk->ff_name)+strlen(subdir_wildcard)+2>=CCHMAXPATHCOMP) msg_cprintf(H_ERR, M_MAXPATH_EXCEEDED, CCHMAXPATH, tmp_name); else { strcat(tmp_name, pnew_ffblk->ff_name); strcat(tmp_name, pathsep_str); strcat(tmp_name, subdir_wildcard); case_path(tmp_name); tmp_name=pack_fname(tmp_name); #ifdef REARJ if(wild_list(root, tmp_name, file_type, expand_wildcards, recurse_subdirs, count)) { result=-1; goto l_error; } #else if(wild_list(root, search_flist, tmp_name, expand_wildcards, recurse_subdirs, file_type, count)) { result=-1; goto l_error; } #endif } } rc=lfn_findnext(pnew_ffblk); } lfn_findclose(pnew_ffblk); } l_error: if(pnew_ffblk!=NULL) free(pnew_ffblk); if(subdir_spec!=NULL) free(subdir_spec); if(tmp_name!=NULL) free(tmp_name); if(subdir_wildcard!=NULL) free(subdir_wildcard); return(result); } /* Findfirst/findnext, wildcard expansion and so on... */ #ifndef REARJ int wild_list(struct flist_root *root, struct flist_root *search_flist, char *name, int expand_wildcards, int recurse_subdirs, int file_type, FILE_COUNT *count) #else int wild_list(struct flist_root *root, char *name, int file_type, int expand_wildcards, int recurse_subdirs, FILE_COUNT *count) #endif { int attr_mask; /* Narrowing criteria */ struct new_ffblk *pnew_ffblk=NULL; /* OS-dependent data block */ int result=0, rc; /* findfirst/findnext() result */ char *tmp_name=NULL; int pathspec_len; /* Maximum path length */ #ifndef REARJ struct file_properties properties; /* Universal block */ #endif pathspec_len=strlen(name); if(pathspec_lenff_attrib&STD_DIR_ATTR)||(strcmp(pnew_ffblk->ff_name, cur_dir_spec)&&strcmp(pnew_ffblk->ff_name, up_dir_spec)))) { split_name(name, tmp_name, NULL); /* ASR fix for 2.76.04 */ if(strlen(tmp_name)+strlen(pnew_ffblk->ff_name)>=CCHMAXPATH) msg_cprintf(H_ERR, M_MAXPATH_EXCEEDED, CCHMAXPATH, pnew_ffblk->ff_name); else { strcat(tmp_name, pnew_ffblk->ff_name); case_path(tmp_name); #ifdef REARJ if(add_entry(root, tmp_name, count)) { result=-1; goto l_error; } #else finddata_to_properties(&properties, pnew_ffblk); if(flist_add(root, search_flist, tmp_name, count, &properties)) { result=-1; goto l_error; } #endif } } rc=lfn_findnext(pnew_ffblk); } lfn_findclose(pnew_ffblk); /* BUG: Original REARJ v 2.28 didn't close the search -- fixed in 2.42 */ if(tmp_name!=NULL) { free(tmp_name); tmp_name=NULL; } if(pnew_ffblk!=NULL) { free(pnew_ffblk); pnew_ffblk=NULL; } /* Last, perform recursive subdirectory search if needed */ #ifndef REARJ if(recursion_order==RO_FIRST) result=wild_subdir(root, search_flist, name, expand_wildcards, recurse_subdirs, file_type, count); #else result=wild_subdir(root, name, file_type, expand_wildcards, recurse_subdirs, count); #endif } /* Return 0 if no errors occured */ l_error: if(tmp_name!=NULL) free(tmp_name); if(pnew_ffblk!=NULL) free(pnew_ffblk); return(result); } #endif arj-3.10.22/environ.h 666 0 0 65650 10256070052 10527 0ustar /* * $Id: environ.h,v 1.15 2005/06/21 19:53:14 andrew_belov Exp $ * --------------------------------------------------------------------------- * All environment-specific declarations are held here. * */ #ifndef ENVIRON_INCLUDED #define ENVIRON_INCLUDED /* First of all, let's try to guess what kind of compiler we're using. The COMPILER macro will lead us all the way */ #ifndef C_DEFS_INCLUDED /* All-time definitions */ #include "c_defs.h" #endif #define GENERIC 0 #define BCC 1 #define MSC 2 #define ICC 3 #define GCC 4 #define HIGHC 5 #define WCC 6 #define MSVC 7 #if defined(__TURBOC__)||defined(__BORLANDC__) #define COMPILER BCC #elif defined(_MSC_VER)||defined(_QC) #ifdef _WIN32 #define COMPILER MSVC #else #define COMPILER MSC #ifdef MSC_VER #error BUG #endif #if (defined(_MSC_VER)&&_MSC_VER<600)||(!defined(_MSC_VER)&&defined(_QC)) #define MSC_ANCIENT /* Old-style Microsoft compiler */ #endif #endif #elif defined(__IBMC__)||defined(__IBMCPP__) #define COMPILER ICC #elif defined(__GNUC__) #define COMPILER GCC #elif defined(__WATCOMC__) #define COMPILER WCC #ifdef M_I386 #define __32BIT__ #endif #elif defined(__HIGHC__)||defined(__HIGHC_ANSI__)||defined(_OS2) #define COMPILER HIGHC #define __32BIT__ #else #define COMPILER GENERIC #endif /* Now, make it clear about target OS */ #define DOS 1 #define OS2 2 /* OS/2-32 is OS2+__32BIT__ */ #ifdef UNIX #undef UNIX #endif #define UNIX 3 #define WIN32 4 #if defined(_OS2)||defined(__OS2__)||defined(__EMX__) #define TARGET OS2 #elif defined(_WIN32) #define TARGET WIN32 #elif defined(_UNIX) #define TARGET UNIX #else #define TARGET DOS #endif #if TARGET==DOS||TARGET==OS2&&!defined(__32BIT__) #define TILED #endif #if TARGET!=UNIX #define HAVE_DRIVES #define HAVE_VOL_LABELS #endif #if TARGET==OS2||TARGET==WIN32 #define HAVE_EAS #endif #include #if COMPILER==BCC #include #elif COMPILER==MSC||COMPILER==MSVC #include #endif #include #include #include #include #if COMPILER==ICC&&defined(DEBUG) #define __DEBUG_ALLOC__ /* For heap checking */ #endif #include #include #if COMPILER==BCC #include #else #include #endif #if TARGET!=UNIX #include #endif #if COMPILER==BCC #include #elif COMPILER!=GCC && !defined(SUNOS) #include #endif /* OS-dependent headers */ #if TARGET==DOS #include #elif TARGET==OS2 #define INCL_BASE #include #elif TARGET==WIN32 #include #elif TARGET==UNIX #include #include #include /* For dev_t, chmod(), etc. */ #endif /* Keywords remapping */ #if !defined(TILED) #ifndef _WIN32 #define FAR #define NEAR #endif #define S_NEAR #elif COMPILER==BCC #define FAR far #define NEAR near #define S_NEAR NEAR #elif COMPILER==MSC #if TARGET==DOS #ifdef MSC_ANCIENT #define FAR far #define NEAR near #else #define FAR _far #define NEAR _near #endif #endif #ifndef MSC_ANCIENT #define asm _asm #endif #define S_NEAR NEAR #else #error *** A FAR/NEAR translation must be defined for this compiler! #endif /* Special functions enablement */ #if COMPILER==MSC #define FINETUNE_BUFSIZ /* Alternate adjustment method */ #endif #if defined(TILED)&&!defined(MSC_ANCIENT) #define ASM8086 /* Enable assembly routines */ #endif /* Library functions/equates remapping */ #if !defined(TILED) #define farfree free #define farmalloc malloc #define farrealloc realloc #define farcalloc calloc #define coreleft() 1048576 /* Don't know/care about it */ #elif COMPILER==MSC #define farfree _ffree #define farmalloc(s) _fmalloc((size_t)s) #define farrealloc(p, s) _frealloc(p, (size_t)s) #define farcalloc(n, s) _fcalloc((size_t)(n), (size_t)(s)) #define coreleft _memmax /* Size of largest unallocated block */ #endif #if COMPILER==MSC #define findfirst _dos_findfirst #define findnext _dos_findnext #define getvect _dos_getvect #define setvect _dos_setvect #ifdef MSC_ANCIENT #define _far far #endif #if _MSC_VER>=0x0700 #define diskfree_t _diskfree_t #define dosdate_t _dosdate_t #define dostime_t _dostime_t #define _far __far #define find_t _find_t #define _interrupt __interrupt #define rccoord __rccoord #define stackavail _stackavail #define strlwr _strlwr #define strupr _strupr #define videoconfig __videoconfig #else #define _close close #define _chmod chmod #define _creat creat #define _open open #define _read read #define _write write #endif #if _MSC_VER<600 #define _fcalloc fcalloc #define _fmemcmp fmemcmp #define _fmemset fmemset #define _frealloc frealloc #define _fstrcat fstrcat #define _fstrchr fstrchr #define _fstrcmp fstrcmp #define _fstrcpy fstrcpy #define _fstrlen fstrlen #endif #endif #if (COMPILER==MSC&&_MSC_VER>=0x0700)||COMPILER==IBMC||COMPILER==HIGHC||TARGET==OS2&&defined(LIBC) #define filelength _filelength #define fcloseall _fcloseall #endif #if COMPILER==BCC||COMPILER==MSC #define _lseek lseek #endif #if COMPILER==ICC||COMPILER==HIGHC #define mkdir _mkdir #endif #if TARGET==UNIX #ifndef __QNXNTO__ #define O_BINARY 0 /* N/A under UNIX */ #endif /* __QNXNTO__ */ #define _lseek lseek #define _open open #define _write write #define _read read #define _close close #endif /* BSD 4.3 LIBC forwarders */ #ifdef HAVE_STRCASECMP #define stricmp strcasecmp #define strnicmp strncasecmp #endif /* Watcom variables remapping: the "-5r" convention requires this */ #if TARGET==OS2&&COMPILER==WCC&&defined(LIBC) #pragma aux stdin "*" #pragma aux stdout "*" #pragma aux stderr "*" #pragma aux stdaux "*" #pragma aux stdprn "*" #pragma aux _timezone "*" #pragma aux _daylight "*" #pragma aux errno "*" #endif /* MetaWare High C/C++, GCC, etc. add-ons */ #if !defined(HAVE_MIN)&&!defined(min) #define min(a, b) ((a)<(b)?(a):(b)) #endif #if !defined(HAVE_MAX)&&!defined(max) #define max(a, b) ((a)>(b)?(a):(b)) #endif /* Structures that are already present in Borland C but missing from MS C */ #if COMPILER!=BCC /* DOS FCB */ struct fcb { char fcb_drive; char fcb_name[8]; char fcb_ext[3]; short fcb_curblk; short fcb_recsize; long fcb_filsize; short fcb_date; char fcb_resv[10]; char fcb_currec; long fcb_random; }; /* DOS Extended FCB */ struct xfcb { char xfcb_flag; char xfcb_resv[5]; char xfcb_attr; struct fcb xfcb_fcb; }; /* Time structure */ struct time { unsigned char ti_min; unsigned char ti_hour; unsigned char ti_hund; unsigned char ti_sec; }; /* Date structure */ struct date { int da_year; char da_day; char da_mon; }; #endif /* Far pointer creation macro */ #ifndef MK_FP #define MK_FP(seg,ofs) ((void FAR *)(((unsigned long)seg<<16)+(unsigned long)ofs)) #endif /* Far memory comparison macro/function */ #if !defined(TILED) #define far_memcmp memcmp #elif COMPILER==BCC #include "fmemcmp.h" #elif COMPILER==MSC #define far_memcmp _fmemcmp #endif /* Error message output */ #if COMPILER==BCC #define error_report() msg_cprintf(H_ERR, M_ERROR_CODE, errno, strerror(errno)) #define error_freport() msg_cprintf(H_ERR, M_ERROR_CODE, errno, strerror(errno)) #else /* LIBCS.DLL complains about missing message resources */ #if defined(LIBC)&&TARGET==OS2 #define error_report() #else #define error_report() \ { \ msg_cprintf(H_ERR, M_ERROR_CODE, errno, strerror(errno)); \ msg_cprintf(H_ERR, (FMSG *)lf); \ } #endif #endif /* Signal handler parameter set */ #if COMPILER==BCC #define SIGHDLPARAMS #else #define SIGHDLPARAMS int sig #endif /* Host operating system. Note that OS codes are defined separately in DEFINES.H, so this macro has no effect until DEFINES.H is included. */ #if TARGET==DOS #define OS OS_DOS #elif TARGET==OS2 #define OS OS_OS2 #elif TARGET==UNIX #define OS OS_UNIX #elif TARGET==WIN32 #define OS OS_WIN32 #endif /* Fixed-bit quantities. Atomic integer types comprising no less than the designated number of bits */ #define UINT32 unsigned long #define INT32 unsigned long /* Case sensitivity (under OS/2, this actually depends on the IFS used!) */ #if TARGET!=UNIX #define CASE_INSENSITIVE #endif /* Maximum size of path/path component */ #if TARGET==OS2||defined(__TILED__) #define CCHMAXPATH 260 #define CCHMAXPATHCOMP 256 #else #define CCHMAXPATH 512 #define CCHMAXPATHCOMP CCHMAXPATH #endif #define MAXWILDAST 128 /* Maximum # of asterisks in wildcards */ /* Our own archive filename storage */ #ifdef FILENAME_MAX #undef FILENAME_MAX /* Already defined in some compilers */ #endif #if TARGET==DOS #define FILENAME_MAX 500 #else #define FILENAME_MAX 512 #endif /* Wildcard equates */ #define WC_RESERVE 10 /* Number of bytes to reserve for w/c */ /* Length of screen-wide strings */ #define INPUT_LENGTH 80 /* Used in various queries */ #define TXTD_LENGTH 78 /* Used when displaying found text */ /* Length of command lines */ #if TARGET==DOS #define CMDLINE_LENGTH 160 #elif TARGET==OS2 #define CMDLINE_LENGTH 264 #else #define CMDLINE_LENGTH 512 /* ASR fix: applies to Unices too! 15/01/2003 -- Win32 preparations */ #endif /* Number of command-line parameters. It must NOT be too high since some arrays are based on its value */ #if TARGET==DOS #define PARAMS_MAX 64 /* parameters+spaces: 64*2=128 */ #define SFLIST_MAX 64 /* ARJSFX filelist array limit */ #elif TARGET==OS2 #define PARAMS_MAX 131 /* ~262 */ #define SFLIST_MAX 131 #else #define PARAMS_MAX 1024 /* May be less on some platforms */ #define SFLIST_MAX 1024 #endif /* FAR memory block size limit */ #ifdef TILED #if COMPILER==BCC #define FAR_BLK_MAX 65535 #elif COMPILER==MSC #define FAR_BLK_MAX 65512 #else #define FAR_BLK_MAX 65535 #endif #define FLIST_ALLOC_MAX FAR_BLK_MAX #elif TARGET==OS2 #define FAR_BLK_MAX 469762048 /* Unless it's Aurora */ #define FLIST_ALLOC_MAX 65535 #else #define FAR_BLK_MAX 524288000 /* ASR fix 27/10/2002: larger values overflow the 2G limit in FILELIST.C, leading to ARJSFXV/Linux failure */ #define FLIST_ALLOC_MAX 65535 #endif /* CFA block increments. It will be wise to keep them proportional to the page size under OS/2, and memory-conserving under DOS. As a sidenote, this significantly reduces the memory requirements for ARJ under DOS. */ #if TARGET==OS2 #define CFA_BLOCK_SIZE 16384 #elif defined(TILED) #define CFA_BLOCK_SIZE 4096 #else #define CFA_BLOCK_SIZE 16384 /* Presume i386 paged RAM */ #endif /* Maximum # of files in the filelist. No longer an environment limit but a marketing logic! */ #define FILELIST_INCREMENT 256 /* Increment count for order blocks */ /* In original ARJ, there was a "commercial" filelist capacity (EXT LIC). The shareware/ordinary license limit was FLIST_ALLOC_MAX-1. */ #define EXT_FILELIST_CAPACITY ((unsigned long)FAR_BLK_MAX*4-5) #define FILELIST_CAPACITY (FLIST_ALLOC_MAX-1) #define FLIST_SPEC_BASE FILELIST_CAPACITY /* Special entries start here */ /* Implicit filelist limits */ #define FCLIM_DELETION FILELIST_CAPACITY /* Limit for deletion */ #define FCLIM_ARCHIVE EXT_FILELIST_CAPACITY /* Archive filelist size */ #define FCLIM_EXCLUSION FILELIST_CAPACITY /* Limit for exclusion */ #define FCLIM_EA FILELIST_CAPACITY /* Limit for EA [in/ex]clusion */ /* Console settings */ #ifdef CR #undef CR #endif #define CR 0x0D /* CR */ #ifdef LF #undef LF #endif #define LF 0x0A /* LF */ #ifdef BEL #undef BEL #endif #define BEL 0x07 /* Bell */ #ifdef TAB #undef TAB #endif #define TAB 0x09 /* Tab */ #define TAB_POS 8 /* Tab stops spacing */ #define CON_LBOUND 32 /* Lowest displayable character */ #define CON_UBOUND 126 /* Highest displayable character */ #if TARGET==UNIX||COMPILER==ICC||COMPILER==HIGHC||TARGET==OS2&&defined(LIBC) #define STDOUT_SETBUF_FIX /* XPG.4 libraries (namely, IBM LIBC and GLIBC) do excessive stdout buffering */ #endif #if TARGET==UNIX||TARGET==OS2 #define DIRECT_TO_ANSI /* Means to reimplement screen commands via ANSI */ #endif /* UNIX and DOS-style path separators */ #if TARGET==UNIX #define PATH_SEPARATORS "/" #else #define PATH_SEPARATORS "\\:/" /* Path separators allowed by target OS */ #endif #if TARGET==UNIX #define PATHSEP_DEFAULT '/' #define PATHSEP_DEFSTR "/" #else #define PATHSEP_DEFAULT '\\' #define PATHSEP_DEFSTR "\\" #endif /* File buffering equates (defining NO_CACHING will disable buffering) */ #define CACHE_SIZE 4096 /* Allocate this amount for buffer */ #define CACHE_SIZE_SFXJR 8192 /* ARJSFXJR incoming data cache size */ #define PROC_BLOCK_SIZE 27648 /* Size of sequential processing block */ #if TARGET==DOS #define VBUF_ADD 4096 /* Old archive stream */ #define VBUF_EXTRACT 8192 /* Input archive stream */ #define TBUF_ARJ 4096 /* Output archive stream */ #if COMPILER==BCC #define VBUF_SFX 4096 #else #define VBUF_SFX 2048 #endif #elif TARGET==OS2||TARGET==WIN32 /* Microsoft C constraints (fragmented heap, and so on...) */ #ifdef TILED #define VBUF_ADD 1024 #define VBUF_EXTRACT 1024 #define TBUF_ARJ 1024 #define VBUF_SFX 1024 #else #define VBUF_ADD 8192 #define VBUF_EXTRACT 16384 #define TBUF_ARJ 8192 #define VBUF_SFX 8192 #endif #elif TARGET==UNIX #define VBUF_ADD 8192 #define VBUF_EXTRACT 8192 #define VBUF_ARJ 8192 #define TBUF_ARJ 8192 #define VBUF_SFX 8192 #else #error *** Buffering limits must be defined for the target platform! #endif #define TBUF_MINFREE 42000U /* If less memory left, tbuf>>=1 */ #define VBUF_MINFREE 40000U /* If less memory left, vbuf>>=1 */ /* * Error handling capabilities: * * NO_TERM_HDL disables termination handler * NO_FATAL_ERROR_HDL disables fatal error handler * */ #if TARGET==DOS #define NO_TERM_HDL /* Disable termination handler */ #endif #if TARGET==WIN32 #define HAVE_BREAK_HANDLER #endif /* File attribute mapping */ /* DOS-way */ #define FATTR_HIDDEN 0x0002 #define FATTR_SYSTEM 0x0004 #define FATTR_RDONLY 0x0001 #define FATTR_ARCH 0x0020 #define FATTR_NOARCH 0x0000 #define FATTR_DIREC 0x0010 #define FATTR_LABEL 0x0008 /* UNIX-way */ #define FATTR_IROTH 0x0004 #define FATTR_IWOTH 0x0002 #define FATTR_IXOTH 0x0001 #define FATTR_IRGRP (FATTR_IROTH<<3) #define FATTR_IWGRP (FATTR_IWOTH<<3) #define FATTR_IXGRP (FATTR_IXOTH<<3) #define FATTR_IRUSR (FATTR_IRGRP<<3) #define FATTR_IWUSR (FATTR_IWGRP<<3) #define FATTR_IXUSR (FATTR_IXGRP<<3) #define FATTR_SVTX 0x0200 /* Sticky bit */ #define FATTR_SGID 0x0400 /* Set GID on exec */ #define FATTR_SUID 0x0800 /* Set UID on exec */ #define FATTR_UFMASK 0x0FFF /* UID/GID/VTX + rwxrwxrwx */ #define ufattr(a) ((a)&FATTR_UFMASK) /* Internal mapping for wild_list(), etc. */ #define FATTR_DT_ANY 0x0000 /* Default */ #define FATTR_DT_REG 0x1000 /* Regular files */ #define FATTR_DT_DIR 0x2000 /* Directories */ #define FATTR_DT_UXSPECIAL 0x4000 /* Links, pipes, etc. */ #define uftype(a) ((a)&~FATTR_UFMASK) /* Certain capabilities of non-UNIX operating systems aren't supported at all or are heavily modified */ #if TARGET==UNIX #define MAP_UNIX_ATTRS /* Convert to DOS representation */ #endif #if TARGET!=UNIX #define STD_ATTRS 0x27 /* Borland compatibility mask */ /* The following is for fileinfo searches */ #define STD_FI_ATTRS (FATTR_DIREC|FATTR_HIDDEN|FATTR_SYSTEM|FATTR_RDONLY) #define STD_DIR_ATTR FATTR_DIREC #define STD_FATTR_NOARCH FATTR_NOARCH #else #define STD_FI_ATTRS (FATTR_DT_REG|FATTR_DT_DIR|FATTR_DT_UXSPECIAL) #define STD_DIR_ATTR FATTR_DT_DIR #define STD_FATTR_NOARCH 0644 #endif /* Priority classes */ #if TARGET==OS2||TARGET==WIN32 #define PRIORITY_CLASSES 4 /* 1...4 */ #elif TARGET==UNIX #define PRIORITY_CLASSES 41 /* -20...20 -> 1...41 */ #else #define PRIORITY_CLASSES 100 /* For compatibility */ #endif /* OS-specific options */ #if TARGET==DOS||TARGET==OS2||TARGET==WIN32 #if TARGET==DOS #define EXE_EXTENSION ".EXE" #define MOD_EXTENSION ".COM" #else #define EXE_EXTENSION ".exe" #define MOD_EXTENSION ".dll" #endif #else #define EXE_EXTENSION "" #define NULL_EXE_EXTENSION /* For ARJ_USER to construct SFX names */ #define MOD_EXTENSION ".so" #endif /* OS-dependent types */ typedef unsigned short ATTRIB; /* Attributes in internal structures */ /* File count type */ #define FILE_COUNT unsigned long /* Hard link search structure in ffblks and properties */ #if TARGET==UNIX struct l_search { dev_t dev; ino_t inode; nlink_t refcount; FILE_COUNT ref; }; #endif /* lfn_findfirst/findnext customized structure */ struct new_ffblk { /* To stay compatible with findfirst/findnext functions that rely on DOS block format: */ #if TARGET==DOS char ff_reserved[21]; #endif #if TARGET!=UNIX char ff_attrib; #else int ff_attrib; int ff_ftype; /* Wild UNIX representation - for circular symlink treatment */ #endif unsigned long ff_ftime; unsigned long ff_fsize; char ff_name[CCHMAXPATH]; #if TARGET==DOS short ff_handle; #elif TARGET==OS2 HDIR ff_handle; #elif TARGET==WIN32 HANDLE ff_handle; #elif TARGET==UNIX DIR *ff_handle; char dir[CCHMAXPATH]; /* dirent doesn't hold it */ char wildcard[CCHMAXPATH]; /* dirent doesn't hold it */ int attrs; /* dirent doesn't hold it */ struct l_search l_search; #endif unsigned long ff_atime; unsigned long ff_ctime; }; /* File information structure (used in file_find and so on) */ struct file_properties { unsigned long fsize; unsigned long ftime; unsigned long atime; unsigned long ctime; ATTRIB attrib; char type; /* One of ARJT_* */ char isarchive; /* For hardlink detection */ #if TARGET==UNIX struct l_search l_search; char islink; #endif }; /* Priority structure */ struct priority { int class; int delta; }; /* After defining all OS-dependent types, we may include additional files */ #include "filelist.h" /* For flist_root structure */ /* Exported from ENVIRON.C */ extern int friendly_systems[]; extern char dev_null[]; extern char dev_con[]; extern char cur_dir_spec[]; extern char up_dir_spec[]; extern char pathsep_str[]; extern char all_wildcard[]; extern char root_wildcard[]; /* * Macro section */ /* A substitution of kbhit() */ #if COMPILER==BCC||COMPILER==MSC||COMPILER==MSVC #define flush_kbd() kbhit() #else #define flush_kbd() fetch_keystrokes() #endif /* OS-dependent strcmp() used for comparing filenames */ #ifdef HAVE_STRCASECMP #define stricmp strcasecmp #endif #ifdef CASE_INSENSITIVE #define strcmp_os(s1, s2) stricmp(s1, s2) #define strncmp_os(s1, s2, l) strnicmp(s1, s2, l) #else #define strcmp_os(s1, s2) strcmp(s1, s2) #define strncmp_os(s1, s2, l) strncmp(s1, s2, l) #endif /* "Year 2038" workaround. */ #if (defined(LIBC)&&TARGET==OS2)||TARGET==WIN32 /* Certain LIBC runtimes fail to do localtime() properly when the time argument exceeds 0x80000000 (a "year 2038" problem). So there is a workaround routine, arj_localtime(), to help with this. */ #define USE_TZSET /* Req'd at least by LIBC on OS/2 */ #define LOCALTIME_WORKAROUND /* Substitute our routine */ struct tm *arj_localtime(const time_t *tt); #else /* No workaround required */ #define arj_localtime localtime #endif /* fchmod() to make SFX'es executable and other archives non-executable */ #if TARGET==UNIX int file_acc(FILE *stream); void make_executable(FILE *stream); #define make_nonexecutable(stream) fchmod(fileno(stream), file_acc(stream)&~0111) #else #define make_executable(stream) #define make_nonexecutable(stream) #endif /* Block optimizers in insane compilers. __LINE__ is for the compiler to be unable to optimize the function arguments if called more than once. */ #if COMPILER==HIGHC||COMPILER==ICC #define stop_optimizer() nullsub(__LINE__) #else /* Others are considered sane */ #define stop_optimizer() #endif /* * Exported function prototypes - see ENVIRON.C for details */ #if TARGET==UNIX #define SKIP_GET_EXE_NAME void get_exe_name(char *dest, char *arg); #else void get_exe_name(char *dest); #endif #if TARGET==OS2&&SFX_LEVEL>=ARJSFX char *malloc_env_str(char *t); #define free_env_str(str) free(str) int system_cmd(char *cmd); #else #define malloc_env_str(t) getenv(t) #define free_env_str(str) #define system_cmd(cmd) system(cmd) #endif #if SFX_LEVEL!=ARJSFXJR int verify_heap(); int verify_far_heap(); #if SFX_LEVEL>=ARJSFXV&&COMPILER!=BCC long farcoreleft(); #endif #if COMPILER!=BCC #ifndef SUNOS int getdisk(); int setdisk(int drive); #endif void arj_gettime(struct time *ts); void arj_getdate(struct date *ds); #else #define arj_gettime(x) gettime(x) #define arj_getdate(x) getdate(x) #endif #if TARGET==OS2&&defined(TILED) void FAR *farcalloc_based(unsigned long num, unsigned long size); void farfree_based(void FAR *ptr); #else #define farcalloc_based farcalloc #define farfree_based farfree #endif void set_priority(struct priority *priority); int test_for_winnt(); int file_chmod(char *name, int action, int attrs); int lfn_findfirst(char *path, struct new_ffblk *new_ffblk, int attrib); int lfn_findnext(struct new_ffblk *new_ffblk); void lfn_findclose(struct new_ffblk *new_ffblk); void toupper_loc(unsigned char *ptr, int length); time_t sum_time(time_t t1, time_t t2); time_t sub_time(time_t t1, time_t t2); void case_path(char *s); int find_dupl_drivespecs(char **argtable, int args); int file_test_access(char *name); int detect_lfns(); int detect_eas(); void fix_ansi_name(char *name); void nullsub(int arg, ...); /* IN ARJ32, it fixes filename to comply with OEM/ANSI codepage issues */ #define fix_ansi_name(name) void arj_delay(unsigned int seconds); void mem_stats(); int file_exists(char *name); FILE *file_open(char *name, char *mode); void default_case_path(char *dest, char *src); int uni_getch(); unsigned long get_ticks(); unsigned long file_getfree(char *name); int file_find(char *name, struct file_properties *properties); #if SFX_LEVEL>=ARJ||defined(REARJ) long file_getfsize(char *name); #endif unsigned long file_getftime(char *name); int file_getlabel(char *label, char drive, ATTRIB *attrib, unsigned long *ftime); int read_line(char *buf, int size); void get_mode_str(char *str, unsigned int mode); int exec_pgm(char *cmdline); #if TARGET==OS2&&SFX_LEVEL>=ARJSFX char *malloc_env_str(char *t); #define free_env_str(str) free(str) int system_cmd(char *cmd); #else #define malloc_env_str(t) getenv(t) #define free_env_str(str) #define system_cmd(cmd) system(cmd) #endif int read_line_noecho(char *buf, int size); unsigned int get_bytes_per_cluster(char *name); void get_canonical_longname(char *cname, char *name); void get_canonical_shortname(char *cname, char *name); void install_smart_handler(); int is_file(FILE *stream); int file_is_removable(char *name); int is_tty(FILE *stream); int file_mkdir(char *name); int match_wildcard(char *name, char *wcard); int file_rmdir(char *name); int file_unlink(char *name); int file_rename(char *oldname, char *newname); int dos_clear_arch_attr(char *name); int reset_drive(char *name); int fetch_keystrokes(); int dos_chmod(char *name, int attrib); int file_chsize(FILE *stream, unsigned long size); int file_setftime_on_stream(FILE *stream, unsigned long ftime); int file_setatime(char *name, unsigned long ftime); int file_setctime(char *name, unsigned long ftime); int file_setftime(char *name, unsigned long ftime); int file_setlabel(char *label, char drive, ATTRIB attrib, unsigned long ftime); int file_settype(FILE *stream, int istext); void set_file_apis(int is_ansi); #if SFX_LEVEL>=ARJSFXV int create_subdir_tree(char *path, int qmode, int datatype); #else int create_subdir_tree(char *path, int datatype); #endif int is_filename_valid(char *name); int is_directory(char *name); char *malloc_subdir_wc(char *name); int file_copy(char *dest, char *src, int chk); #ifndef REARJ int wild_list(struct flist_root *root, struct flist_root *search_flist, char *name, int expand_wildcards, int recurse_subdirs, int file_type, FILE_COUNT *count); #else int wild_list(struct flist_root *root, char *name, int file_type, int expand_wildcards, int recurse_subdirs, FILE_COUNT *count); #endif #if SFX_LEVEL>=ARJSFX&&SFX_LEVEL<=ARJSFXV void file_getcwd(char *buf, int len); void file_chdir(char *dir); #endif #ifdef REARJ char *file_getcwd(char *buf); int file_chdir(char *dir); char get_sw_char(); #endif #endif /* !ARJSFXJR */ int file_setftime_on_hf(int hf, unsigned long ftime); #endif arj-3.10.22/exe_sear.c 666 0 0 13341 7743471716 10626 0ustar /* * $Id: exe_sear.c,v 1.3 2003/10/16 10:32:46 andrew_belov Exp $ * --------------------------------------------------------------------------- * Routines that fetch overlay data are located in this file. * */ #include "arj.h" #ifdef ELF_EXECUTABLES #ifdef __QNXNTO__ #include #else #include #endif /* __QNXNTO__ */ #endif DEBUGHDR(__FILE__) /* Debug information block */ /* ARJSFX module order */ #define MN_SFXJR 1 #define MN_SFX 2 #define MN_SFXV 3 #define MN_SFXSTUB 4 /* Define the ELF magic numbers if not defined yet */ #if defined(ELF_EXECUTABLES)&&!defined(ELFMAG) static char elfmag[4]={'E', 'L', 'F', 0x7F}; #define ELFMAG elfmag #define SELFMAG 4 #endif #if SFX_LEVEL>=ARJ /* Local variables */ static char overlay_sig[]="RJ_SFX"; /* Looks for ARJ_SFX signature */ static void browse(FILE *stream) { char buf[256]; unsigned long cur_pos, sig_pos; int bytes_read; int i; char *buf_ptr; while(1) { cur_pos=ftell(stream); bytes_read=fread(buf, 1, sizeof(buf), stream); if(bytes_read<=0) error(M_CANTREAD); buf_ptr=buf; i=0; while(i0) { if(fputc((int)*(block++), stream)==EOF) error(M_DISK_FULL); } #else file_write(block, 1, len, stream); #endif } #endif /* Reads the EXE size from the header */ static unsigned long get_exe_size(FILE *stream) { #if SFX_LEVEL>=ARJ unsigned long result=EXESIZE_ARJ; #elif SFX_LEVEL==ARJSFXV unsigned long result=EXESIZE_ARJSFXV; #else unsigned long result=EXESIZE_ARJSFX; #endif #ifndef ELF_EXECUTABLES unsigned int remainder, blocks; #else Elf32_Ehdr ehdr; Elf32_Shdr shdr; unsigned long ref_point; unsigned long cur_pos; unsigned int i; #endif #ifndef ELF_EXECUTABLES /* Presume standard DOS or OS/2 EXE */ fseek(stream, 2L, SEEK_SET); remainder=fget_word(stream); blocks=fget_word(stream); result=(unsigned long)(blocks-1)*512L+(unsigned long)remainder; return(result); #else /* ELF (Linux, OS/2 PPC, Solaris...) */ fread(&ehdr, 1, sizeof(ehdr), stream); if(memcmp(ehdr.e_ident, ELFMAG, SELFMAG)) return(0); result=ehdr.e_shoff+(unsigned long)ehdr.e_shentsize*ehdr.e_shnum; fseek(stream, ehdr.e_shoff, SEEK_SET); for(i=0; iresult&&shdr.sh_type!=SHT_NOBITS) result=ref_point; } return(result); #endif } #if SFX_LEVEL>=ARJ /* Performs all actions related to picking a block */ static void fetch_block(int num) { FILE *stream; unsigned long exe_size; int t_num; unsigned long t_pos; char buf[256]; int block_len; int bytes_read; unsigned int desc_word; stream=file_open_noarch(exe_name, m_rb); exe_size=get_exe_size(stream); fseek(stream, exe_size, SEEK_SET); t_pos=0L; for(t_num=0; t_num0) { bytes_read=fread(buf, 1, block_len, stream); if(bytes_read<=0) break; crc32_for_block(buf, bytes_read); farblock_output(aostream, (char FAR *)buf, (unsigned long)bytes_read); t_pos-=(unsigned long)bytes_read; block_len=(int)min(sizeof(buf), t_pos); } fclose(stream); desc_word=SFXDESC_NONSFX; if(create_sfx==SFXCRT_SFX&&multivolume_option) desc_word=SFXDESC_SFXV; else if(create_sfx==SFXCRT_SFX) desc_word=SFXDESC_SFX; else if(create_sfx==SFXCRT_SFXJR) desc_word=SFXDESC_SFXJR; fput_word(desc_word, aostream); if(is_registered) desc_word=REG_ID; fput_word(desc_word, aostream); crc32term^=CRC_MASK; fput_dword(crc32term, aostream); } /* Picks the ARJSFX and stores ARJSFX run-time data */ void fetch_sfx() { fetch_block(MN_SFX); } /* Picks the ARJSFXJR and stores ARJSFXJR run-time data */ void fetch_sfxjr() { fetch_block(MN_SFXJR); } /* Picks the ARJSFXV and stores ARJSFXV run-time data */ void fetch_sfxv() { fetch_block(MN_SFXV); } /* Picks the SFXSTUB */ void fetch_sfxstub() { fetch_block(MN_SFXSTUB); } #endif #if SFX_LEVEL<=ARJSFXV /* SFX seek routine */ void sfx_seek() { unsigned long exe_size; unsigned long fcrc; unsigned int block_size, bytes_read; char buf[256]; exe_size=get_exe_size(aistream); fseek(aistream, exe_size, SEEK_SET); main_hdr_offset=find_header(0, aistream); fseek(aistream, -8L, SEEK_CUR); exe_size=ftell(aistream); reg_id=fget_word(aistream); /* Descriptive word */ reg_id=fget_word(aistream); fcrc=fget_longword(aistream); if(reg_id!=REG_ID) reg_id=0; fseek(aistream, 0L, SEEK_SET); crc32term=CRC_MASK; block_size=min((unsigned long)sizeof(buf), exe_size); while(exe_size>0L) { bytes_read=fread(buf, 1, block_size, aistream); if(bytes_read==0) break; crc32_for_block(buf, bytes_read); exe_size-=(unsigned long)bytes_read; block_size=min((unsigned long)block_size, exe_size); } if((crc32term^CRC_MASK)!=fcrc&&!skip_integrity_test) error(M_DAMAGED_SFX); fseek(aistream, main_hdr_offset, SEEK_SET); } #endif arj-3.10.22/exe_sear.h 666 0 0 667 7450456642 10576 0ustar /* * $Id: exe_sear.h,v 1.1.1.1 2002/03/28 00:02:43 andrew_belov Exp $ * --------------------------------------------------------------------------- * Prototypes of the functions located in EXE_SEAR.C are declared here. * * */ #ifndef EXE_SEAR_INCLUDED #define EXE_SEAR_INCLUDED /* Prototypes */ void fetch_sfx(); void fetch_sfxjr(); void fetch_sfxv(); void fetch_sfxstub(); #if SFX_LEVEL<=ARJSFXV void sfx_seek(); #endif #endif arj-3.10.22/externs.c 666 0 0 110653 10064613030 10540 0ustar /* * $Id: externs.c,v 1.7 2004/06/18 16:19:37 andrew_belov Exp $ * --------------------------------------------------------------------------- * All uninitialized and initialized variables that are used by two or more * modules are defined here. Note that no separation is done for those used by * ARJ, ARJSFXV and so on... * */ #include "arj.h" DEBUGHDR(__FILE__) /* Debug information block */ /* Auto-initializing variables */ #if SFX_LEVEL>=ARJSFXV #define AUTOINIT #else #define AUTOINIT =0 #endif /* Shared data, mostly the duplicate strings */ char nullstr[]=""; /* Used instead of "" */ char strform[]="%s"; /* printf(strform, str) */ char path_separators[]=PATH_SEPARATORS; #if TARGET!=UNIX char switch_chars[]="-/"; #else char switch_chars[]="-"; #endif #if SFX_LEVEL>=ARJ char cmd_ac[]="AC"; /* Chapter commands */ char cmd_cc[]="CC"; char cmd_dc[]="DC"; char arjtemp_spec[]="ARJTEMP.$%02d"; /* For all temporary files created */ char le_prompt[]="%02d> "; /* String entry prompt */ #endif #if SFX_LEVEL>=ARJSFXV char vd_space[]=" "; /* ...after the filename */ #endif /* Exported data */ #if SFX_LEVEL>=ARJ||defined(REARJ) unsigned char regdata[]={'a', 'R', 'j', ' ', 's', 'O', 'f', 'T', 'w', 'A', 'r', 'E', 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, '[', '/', '.', ',', ']', '$', '*', '(', '#', '@', '^', '&', '*', '%', '#', '(', ')', 0}; #endif #if SFX_LEVEL>=ARJSFXV struct flist_root flist_order; /* Order of files */ struct flist_root flist_archive; /* Archives to be processed */ #endif #if SFX_LEVEL>=ARJSFXV||defined(REARJ) struct flist_root flist_main; /* Files to be processed */ struct flist_root flist_exclusion; /* Files to be excluded */ #endif #if SFX_LEVEL>=ARJ&&defined(HAVE_EAS) struct flist_root flist_ea; /* EAs to include */ struct flist_root flist_xea; /* EAs to exclude */ #endif #if SFX_LEVEL>=ARJ&&TARGET==UNIX struct l_entries l_entries; struct l_entries sl_entries; #endif int win32_platform; /* 1 if the archiver has been compiled for Win32 */ int display_totals; /* 1 if the total archive statistics can be shown in display_indicator() */ int switch_char AUTOINIT; /* 1st switch character */ unsigned int file_attr_mask; /* For optimization */ int pattern_found; /* 1 once the search pattern was found (m_w command) */ #if SFX_LEVEL>=ARJSFXV||defined(REARJ) int is_registered; /* 1 if the archiver is registered (this switch is inverted at the beginning to disallow hacking) */ int in_key; /* 1 = use the stored key */ #endif #if SFX_LEVEL>=ARJ int is_commercial; /* 1 if commercial version (in open-source world, means nothing) */ #endif int lfn_supported AUTOINIT; /* 1 if yes; set by detect_lfns */ int ext_hdr_flags; /* Extended flags, used in main ARJ archive header */ int file_garbled; /* 1 if the GARBLED_FLAG is set */ int arch_wildcard_allowed; /* 1 if multiple archives can be processed */ int file_args AUTOINIT; /* Number of file arguments */ int volume_flag_set; /* 1 if the VOLUME_FLAG is set in the header */ #if SFX_LEVEL>=ARJ int tmp_archive_used; /* Indicates that a temporary archive file was built */ int method_specifier; /* Number of the custom method */ int primary_file_type; /* Default type */ int identical_filedata; /* 1 if the files in archive are identical with the disk files */ #endif #if SFX_LEVEL>=ARJSFXV int ctrlc_not_busy; /* Ctrl+C handler can proceed */ int ignore_errors; /* 1 if everything is ignored (-hr) */ int ctrlc_processing; /* Ctrl+C is raised */ int supply_comment_file; /* Supply file for comment (-jz) */ #endif #if SFX_LEVEL>=ARJ int use_comment; /* Supply archive comment (-z) */ #endif int assume_yes; /* -jy option presence flag */ int extract_to_file; /* Extract to a single file (-jw) */ #if SFX_LEVEL>=ARJ int assign_work_directory; /* Set temporary directory (-w) */ #endif int multivolume_option; /* 1 if the "-v" switch is issued */ #if SFX_LEVEL>=ARJ int allow_mv_update; /* Allow update of multivolume archives */ int beep_between_volumes; /* Beep between volumes (-vv) */ int chk_arj_version; /* -hv */ #endif int verbose_display AUTOINIT; /* State of verbose display (-jv) */ int update_criteria AUTOINIT; /* Update option (-u), one of UC_* */ #if SFX_LEVEL>=ARJ int translate_unix_paths; /* Translate "/" path separators */ int type_override; /* File type override (-t) */ int timestamp_override; /* Archive time override (-s, ATO_*) */ int test_archive_crc; /* Test CRC (-jt, one of TC_*) */ int store_by_suffix; /* Store *.ZIP, *.ARJ, etc. */ #endif int skip_ts_check AUTOINIT; /* Skip timestamp check (-c) */ #if SFX_LEVEL>=ARJ int comment_display; /* Comment display settings */ int lfn_mode; /* LFN handling mode (-hf) */ int create_sfx; /* !0 if the output file will be a SFX (the SFXCRT_* constants define the type of SFX) */ int filter_attrs; /* 1 if file are selected depending on their attributes (-hb) */ int select_backup_files; /* Select backup files (-jg) */ int search_mode; /* File search logging level (-hw) */ #endif int keep_tmp_file; /* Keep unprocessed file */ #if SFX_LEVEL>=ARJ int hollow_mode; /* Create "hollow" archives (-j#) */ int restart_at_filename; /* Restart volumes on filename (-jn) */ #endif int quiet_mode AUTOINIT; /* 1 or 2 if prompting is suppressed (registered ARJ only) */ int recurse_subdirs; /* Recurse thru subdirectories (-r) */ int ignore_crc_errors; /* One of ICE_* (-jr) */ #if SFX_LEVEL>=ARJ int set_string_parameter; /* Set command-line parameters */ int query_for_each_file; /* 1 if yes (-q) */ int protfile_option; /* 1 if .XRJ file must be built (-hk) */ int arjprot_tail; /* Indicates presence of recovery record */ int prot_blocks; /* # of ARJ-PROTECT blocks */ #endif int arjdisp_enabled AUTOINIT; /* 1 if the ARJ$DISP interface is enabled (-hp) */ int prompt_for_more; /* 1 if the user is to be prompted when scrolling */ #if SFX_LEVEL>=ARJ int marksym_expansion; /* Toggles expansion (see MISC.C) */ #endif int fnm_matching AUTOINIT; /* Filename matching mode, (FMM_*) */ int rsp_per_line; /* Set per-line RSP mode (-@) */ int gost_cipher; /* Garble via GOST 28147-89 (v 2.55+) */ int filter_older; /* Same and newer files are thrown away */ int filter_same_or_newer; /* Older files are thrown away */ int new_files_only AUTOINIT; /* Only the nonexistent files are OK */ int nonexist_filespec; /* Specify non-existing file (-hn) */ int skip_switch_processing AUTOINIT; /* Set after "--" option */ int disable_sharing; /* 1 if SAA extended subs are used */ int yes_on_all_queries AUTOINIT; /* 1 if all queries are skipped */ int indicator_style AUTOINIT; /* -i indicator style (no enums) */ int disable_arj_sw; /* Disable ARJ_SW (-+) */ int skip_time_attrs; /* 1 to skip DTA/DTC handling (-j$) */ int custom_method; /* The value of -m, or 0 */ int max_compression; /* Maximal compression mode (-jm) */ int filelist_storage; /* Desired filelist storage method */ int create_list_file; /* -l */ int listfile_err_opt; /* Return error for list file error (-hhl) */ int listchars_allowed; /* 1 if yes */ int handle_labels; /* Should the labels be [re]stored (-$) */ int sign_with_arjsec; /* 1 if the archive must be sealed */ int keep_tmp_archive; /* Keep ARJTEMP on error (-jk) */ int keep_bak; /* Keep backup file (-k) */ int create_index; /* 1 if yes (-ji) */ int detailed_index; /* 1 if detailed index is to be built (-hi) */ int ignore_archive_errors; /* 1 if an error like "Bad header" will not cause a termination */ int ignore_open_errors; /* Should the archive open errors on add operation be ignored? (-hq) */ int clear_archive_bit; /* 1 if chmod operations are used and all bits of file are set to 0 */ int jh_enabled; /* Nonzero if the "-jh" is used */ int help_issued AUTOINIT; /* Help (-?) is issued by the user */ int garble_enabled; /* Garble with password */ int lowercase_names AUTOINIT; /* Convert filenames being added or extracted to lower case */ int validate_style; /* VALIDATE_ALL, VALIDATE_NOTHING, or VALIDATE_DRIVESPEC */ int freshen_criteria AUTOINIT; /* Freshen option (-f), one of FC_* */ int chk_free_space; /* Check space before extraction */ int force_lfn; /* Force LFN support (-h$) */ int select_by_number; /* Select files by number (-#) */ int show_filenames_only; /* (-jl) Simplified display */ int override_archive_exts; /* Set default archive extensions */ int extm_mode; /* Extract files w/matches (-ho) */ int exit_after_count; /* Exit after N files (-jc) */ int start_at_ext_pos; /* 1 if the -jx option was issued */ #if SFX_LEVEL>=ARJ int start_with_seek; /* 1 if the -2i option was issued */ #endif int exclude_paths; /* Exclude paths from filenames (-e) */ int exclude_files; /* Exclude selected files (-x) */ int arjsec_opt; /* -he options */ int run_cmd_at_start; /* Execute command on start (-hc) */ int delete_processed; /* Delete processed files (-d) */ int debug_enabled; /* 1 if yes */ int install_errhdl; /* Install critical error handler (-&) */ int chapter_mode; /* 0 - do not create chapters 1 - create/process a chapter archive 2 - dismiss chapter archive */ int set_target_directory; /* Set target directory (-ht) */ int serialize_exts; /* Serialize extensions (-jo/-jo1) */ int allow_any_attrs; /* Allow any file attributes (-a) */ int filter_fa_arch; /* Store only files with 0x20 bit set */ int append_curtime; /* Append current date/time to archive filename (-h#) */ char *time_str; /* Time string to append */ int use_ansi_cp; /* Use ANSI codepage (-hy) */ #if SFX_LEVEL>=ARJ int queries_assume_no[TOTAL_QUERIES]; /* 1 if NO is assumed as reply */ int queries_assume_yes[TOTAL_QUERIES]; /* 1 if YES is assumed as reply */ #endif int accept_shortcut_keys; /* Never used and defaults to 0 */ int skip_next_vol_query; /* Skip "next volume...?" query */ int skip_scanned_query; /* Skip "scanned enough?" (-jys) */ int overwrite_existing AUTOINIT; /* 1 if no prompt for overwriting an existing file is to be displayed */ int skip_rename_prompt; /* Skip "New name...?" prompt */ int skip_space_query; /* Skip free disk space query */ int query_delete; /* 1 if the user is to be queried when a set of files is to be deleted */ #if SFX_LEVEL>=ARJSFXV int prompt_for_mkdir; /* 1 if yes (overrides -y) */ int skip_append_query; /* Skip "Append @ position..." query */ int kbd_cleanup_on_input; /* Defaults to 0 */ #endif #if SFX_LEVEL>=ARJSFXV int use_sfxstub; /* Create multivolume stubbed packages */ #endif #if SFX_LEVEL>=ARJ int whole_files_in_mv; /* Store whole files in volumes (-vw) */ int pause_between_volumes; /* Pause after completing volume (-vp) */ int inhibit_change_test; /* Inhibit diskette change test (-vi) */ int mv_cmd_state; /* -vs/vz/vd commands -> MVC_* */ int ignore_pcase; /* Ignore case of search pattern */ #endif #if SFX_LEVEL>=ARJ||defined(REARJ) int no_file_activity; /* 1 if file writes can be ignored (-hdn in ARJ, -z in REARJ) */ #endif int std_list_cmd AUTOINIT; /* 1 if the standard (non-verbose) list is requested */ int print_with_more; /* Set to 1 if the ARJ P was called and the "more?" prompt is enabled */ int subdir_extraction; /* 1 if the ARJ x command was issued */ int execute_cmd; /* ARJ B sets this flag */ int change_vol_delay; /* Delay specified with -p */ unsigned int left_trim; /* Number of chars to remove from the beginning of filename during the extraction */ char listchar; /* Defaults to '!' */ int errorlevel; /* DOS errorlevel */ unsigned int errors AUTOINIT; /* Number of errors */ int lines_per_page; /* Lines per screen for using "more" */ int lines_scrolled; /* Lines scrolled */ int secondary_file_type; /* Type specified with a list */ unsigned int file_type; /* See DT_* equates */ int unpackable; /* 1 if the compressed file becomes greated than the original one */ int fdisp_lines; /* Lines to display in m_w command */ int reserve_size; /* Size of reserved buffer */ int bitcount; /* Temporary counter */ FILE_COUNT av_total_files; /* Total # of files on all volumes */ FILE_COUNT av_total_longnames; /* Total # of LFNs on all volumes */ FILE_COUNT exit_count; /* Number of files to exit after */ #if SFX_LEVEL>=ARJ FILE_COUNT split_files; /* Number of files that span across volumes */ #endif #if SFX_LEVEL>=ARJ FILE_COUNT FAR *order; /* Order of files */ int params_max; char **f_arg_array; #else int order[PARAMS_MAX]; int params_max=PARAMS_MAX; char *f_arg_array[PARAMS_MAX]; /* Array of filename arguments */ #endif char *comment_file; /* Global comment file */ char *archive_cmt_name; /* Archive comment (-z) filename */ char *yes_query_list; /* List of -jy parameters */ char *extraction_filename; /* Filename specified by -jw */ char *swptr_hv; /* -hv parameter */ char *search_reserve; /* For strings that span across block boundaries */ #if SFX_LEVEL>=ARJ char *search_str[SEARCH_STR_MAX]; /* Search patterns */ #endif char *filename_to_restart; /* Filename specified with -jn */ char *string_parameter; /* -jq string parameter */ char *arjdisp_ptr; /* -hp (ARJ$DISP switch) */ char *arjcrypt_name; /* ARJCRYPT.COM override (-hg) */ char *nonexist_name; /* Nonexistent filespec (-hn) */ unsigned long garble_ftime; /* Used as a random seed when garbling files */ char *index_name; /* Index (-ji) filename */ char *list_file; /* -L list file */ char *swptr_t; /* -t (secondary file type list) */ char *cmd_to_exec; /* Text of command to be run */ char *archive_suffixes; /* A list of packed file extensions */ char *mv_cmd; /* Executed between volumes */ #ifndef REARJ char *timestr_older; /* "-ob", "-oab", "-ocb" */ char *timestr_newer; /* "-o", "-ob", "-oc" */ #endif char *arj_env_name; /* "ARJ_SW" or "ARJ32_SW" */ char *swptr_hm; /* -hm (file list management) */ char *work_directory; /* -w (work directory) override */ char *target_dir; /* Target directory, -ht overrides it */ char *tmp_archive_name; /* Back-up archive */ char *rsp_name; /* Response (@) filename */ /* Temporary filename storage */ #if SFX_LEVEL>=ARJSFXV char *tmp_tmp_filename; #else char tmp_tmp_filename[FILENAME_MAX]; #endif /* Archive filename with the extension added. */ #if SFX_LEVEL>=ARJSFXV char *archive_name; #else char archive_name[FILENAME_MAX]; #endif char *arjsec_env_name; /* ARJ-SECURITY envelope filename (-hz) Unused in noncommercial version */ char password_modifier; /* Garble password modifier */ char *garble_password; /* Pointer to garble password */ char *archive_ext_list; /* -hx extension list */ char *debug_opt; /* -hd (debug) */ char *start_cmd; /* Command to run at start */ char *misc_buf; /* allocated at main(). General-purpose buffer. */ char label_drive; /* Drive letter (-$A, -$B, etc.) */ char *strcpy_buf; /* allocated at main() */ unsigned char host_os; /* Host operating system of archive and source files within it. */ char *out_buffer; /* Temporary storage of encoded data */ /* ARJ header storage area */ #if SFX_LEVEL>=ARJSFXV char *header; #else char header[HEADERSIZE_MAX]; #endif unsigned char byte_buf; /* Used for preserving the data read */ unsigned char subbitbuf; /* Backup storage */ int user_wants_fail; /* -1 if the user has manually cancelled the operation */ int resume_volume_num; /* -jn volume number */ unsigned int ext_voldata; /* Size of additional (non-ARJ) data in multivolume archives */ int out_avail; /* Number of available bytes in out_buffer */ int out_bytes; /* Number of bytes pending */ int total_chapters; /* Number of chapters in the file */ int chapter_to_process; /* Number of chapter to be processed */ int current_chapter; /* Chapter number of current file */ FILE_COUNT max_filenames; /* Initialized with 65000 by default */ unsigned int user_bufsiz; /* The "-jh" value */ unsigned int current_bufsiz; /* Size of the buffer, picked every time when the compressor starts */ unsigned short bitbuf; /* Used directly in the decoding */ FILE *new_stderr; /* Indicates presence of STDERR re-route */ FILE *tstream; /* Any disk file */ #if SFX_LEVEL>=ARJ FILE *idxstream; /* Index file */ #endif #if SFX_LEVEL>=ARJSFXV FILE *new_stdout; /* stdout or stderr */ #endif FILE *atstream=NULL; /* Temporary handle */ #if SFX_LEVEL>=ARJ FILE *aostream; /* Archive output file handle */ FILE *encstream; /* The file being encoded */ #endif FILE *aistream; /* Archive input file handle */ #if SFX_LEVEL>=ARJSFXV unsigned long FAR *arch_hdr_index; /* Contains offsets of archive files */ #endif unsigned long last_hdr_offset; /* Offset of last archive header */ #if SFX_LEVEL>=ARJ long search_occurences[SEARCH_STR_MAX]; /* Number of occurences of each search pattern from search_str[] */ #endif unsigned long ext_pos; /* Offset specified by -jx */ #if SFX_LEVEL>=ARJSFXV unsigned long arcv_ext_pos; /* Offset specified by -2i */ #endif long uncompsize; /* Size of the file on the disk */ unsigned long compsize; /* Size of compressed data */ unsigned long origsize; /* Size of the source file */ unsigned long av_uncompressed; /* Size of uncompressed data on all volumes */ unsigned long av_compressed; /* Size of compressed data on all volumes */ unsigned long total_size; /* Total size of all files to be archived */ unsigned long total_written; /* Total size of all files that are archived, excluding the current. */ unsigned long minfree; /* Minimal disk space for operation (-jdxxx) */ struct timestamp tested_ftime_older; /* Time attribute for filtering (<) */ struct timestamp tested_ftime_newer; /* Time attribute for filtering (>=) */ unsigned long t_volume_offset; /* Offset of multivolume data */ unsigned long mv_reserve_space; /* Number of bytes to reserve on the first volume */ unsigned long volume_limit; /* Maximum volume size in bytes */ struct timestamp secondary_ftime; /* Used in rare occasions */ struct timestamp ftime_max; /* Most recent timestamp of files contained within archive */ unsigned long disk_space_used; /* Space allocated for the files */ unsigned long total_compressed AUTOINIT;/* Total size of compressed data */ /* Total size of uncompressed data */ unsigned long total_uncompressed AUTOINIT; unsigned long arjsec_offset; /* Offset of ARJ-security envelope */ unsigned long secured_size; /* Original size of ARJ-secured file */ unsigned long cur_header_pos; /* Offset of currently processed header within the archive */ long main_hdr_offset; /* Offset of main archive header (nonzero in SFX) */ #if SFX_LEVEL>=ARJSFXV char FAR *tmp_filename; /* Backup copy of current filename */ #endif unsigned long volume_crc; /* CRC kept for multivolume files */ struct timestamp volume_ftime; /* Multivolume ftime storage */ FILE *ofstream; /* -jw output file */ int recent_chapter; /* Chapter to be added, if any */ unsigned int alloc_unit_size; /* Size of allocation unit */ FILE_COUNT split_longnames; /* Number of cross-volume longnames */ FILE_COUNT total_longnames; /* Number of processed files with LFN */ FILE_COUNT total_files AUTOINIT; /* Number of processed files */ FILE_COUNT comment_entries; /* Number of filenames acting as comment (e.g., chapter separators) */ int max_chapter; /* Maximum number of chapter found so far */ #if SFX_LEVEL>=ARJ int force_volume_flag; /* 1 if the file will be marked with VOLUME_FLAG even if it is not multi-volume */ int sfx_desc_word; /* Descriptive word of SFX */ int add_command; /* 1 if the current operation adds any external files to the archive */ int order_command; /* An order command was issued */ #endif int no_inarch; /* 1 if there's no input archive */ int modify_command; /* 1 if the current operation modifies the archive contents */ unsigned int volume_number; /* .A0x, .Axx volume number */ int continued_nextvolume; /* 1 if the file continues on the next volume (the VOLUME_FLAG is set ) */ int first_vol_passed; /* 1 once the first archive volume has been fully processed */ int mvfile_type; /* Types of multi-volume files */ int continued_prevvolume; /* 1 if the resume_position must be taken into account (indicates that the file is split from a previous volume) */ #if SFX_LEVEL>=ARJSFXV int encryption_applied; /* Encryption operation will occur */ #endif int cmd_verb; /* ASCII code of the command issued (uppercase) */ int security_state AUTOINIT; /* ARJSEC_* constants may be here */ int ansi_codepage; /* 1 if the archive filename is in the ANSI codepage. */ int dual_name AUTOINIT; /* 1 if dual-name mode (long filename is stored in the comment field, see help on "-hf1" for details) */ unsigned long archive_size; /* Size of the whole archive, excluding the two terminating 0's */ unsigned long resume_position; /* For multi-volume files, the number of bytes to skip. */ unsigned long header_crc; /* CRC of current archive header */ unsigned long file_crc; /* CRC-32 of uncompressed file */ unsigned char chapter_number; /* Chapter number, 1 to 250. */ unsigned char ext_flags; /* Used for chapter number or extended header flags storage */ unsigned short host_data; /* Used for chapter information */ unsigned short entry_pos; /* Entryname position in filename */ struct timestamp ctime_stamp; /* v 2.62+ - creation date/time */ struct timestamp atime_stamp; /* v 2.62+ - last access date/time */ struct timestamp ftime_stamp; /* Last modification date/time */ struct file_mode file_mode; /* File access mode bit-map */ unsigned int method; /* Packing method */ unsigned char arj_flags; /* Archive flags */ unsigned char arj_x_nbr; /* Minimum version to extract */ unsigned char arj_nbr; /* Archiver version number */ unsigned char first_hdr_size; /* Size of fixed-length header (30) */ unsigned int basic_hdr_size; /* Size of the basic (not extended) header */ char *hdr_comment; /* Comment stored in the header */ char *hdr_filename; /* Filename stored in the header */ /* Preallocated comment storage area */ #if SFX_LEVEL>=ARJSFXV char FAR *comment; #else char comment[COMMENT_MAX]; #endif int use_comment; /* Supply archive comment (-z) */ char filename[FILENAME_MAX]; /* Filename storage buffer */ struct file_properties properties; /* Properties of the current file */ int restart_at_filename; /* Restart volumes on filename (-jn) */ #ifndef REARJ unsigned char pt_len[NPT]; /* Prefix table length */ unsigned short left[2*NC-1]; /* Huffman tree */ unsigned short right[2*NC-1]; /* Huffman tree */ unsigned char c_len[NC]; /* Character length */ unsigned short cpos; /* Position in out_buffer */ unsigned int bufsiz; /* Size of the Huffman buffer, specified by "-jh" and adjusted afterwards */ #endif #if SFX_LEVEL>=ARJSFXV unsigned char *dec_text; #elif !defined(REARJ) unsigned char dec_text[DICSIZ]; #endif /* The following is an ASR fix -- performance enhancement to 2.76.06 */ #if SFX_LEVEL>=ARJ unsigned char *ntext; /* decode_f() non-volatile dictionary */ #endif /* Missing or obsolete in original ARJ 2.62c */ #if SFX_LEVEL>=ARJSFXV int error_occured; /* 1 if an error happened and ARJ must exit. */ #endif int file_packing; /* 1 if uncompressed data is a file */ char FAR *encblock_ptr; /* Uncompressed data pointer */ char FAR *packblock_ptr; /* Compressed data pointer */ unsigned int encmem_remain; /* Amount of uncompressed data */ unsigned int packmem_remain; /* Amount of compressed data */ unsigned int encmem_limit; /* To prevent overruns */ #if SFX_LEVEL>=ARJSFXV int ea_supported; /* Extended attributes support flag */ long ext_hdr_capacity; /* Number of RAW bytes to flush when writing the extended header on the current file portion. Must be SIGNED! */ struct ext_hdr FAR *eh; /* Extended header */ unsigned int ea_size; /* Size of unpacked EAs */ #endif int valid_ext_hdr; /* Specifies that the extended header data can be processed */ char *exe_name; /* Name of executable invoked */ #if SFX_LEVEL>=ARJ int arcmail_sw; /* ARCmail non-overwrite mode */ int dos_host; /* Use DOS as host OS under OS/2 */ struct priority priority; /* Selectable process priority */ int include_eas; /* EA inclusion filelist is present */ int exclude_eas; /* EA exclusion filelist is present */ int disable_comment_series; /* Apply comment to the 1st volume, strip it for all others */ int skip_century; /* Skip centuries in list commands */ int fix_longnames; /* 1 if .LONGNAME EAs should be resolved to filenames in headers */ int crit_eas; /* 1 if only critical EAs should be packed/restored */ int symlink_accuracy; /* Restore symlink properties */ int do_chown; /* Query / set the file owner */ int suppress_hardlinks; /* Store the whole copies */ int recursion_order; /* Directory recursion order */ int encryption_id; /* Identifies encryption in header */ jmp_buf main_proc; /* Entry point of archive processing loop */ #endif /* ARJSFX data */ #if SFX_LEVEL<=ARJSFXV int valid_envelope AUTOINIT; /* 1 if the archive has a valid ARJ-SECURITY envelope */ int skip_integrity_test AUTOINIT; /* Skip virus/security check (-a) */ int prompt_for_directory AUTOINIT; /* Prompt for directory (-b) */ int extract_expath AUTOINIT; /* Extract excluding paths (-e) */ int process_lfn_archive AUTOINIT; /* Process a Windows LFN archive (-j) */ int skip_preset_options; /* Skip preset SFX options (-k) */ int list_sfx_cmd AUTOINIT; /* List SFX contents (-l) */ int overwrite_ro; /* Overwrite read-only files */ int test_sfx_cmd AUTOINIT; /* Test archive (-t) */ int verbose_list AUTOINIT; /* Verbose list command (-v) */ int extract_cmd AUTOINIT; /* Default extract command (-x) */ #if SFX_LEVEL>=ARJSFXV int skip_volumes; /* Skip over first volumes (-#) */ int first_volume_number; /* First volume to process */ #endif int execute_extr_cmd AUTOINIT; /* Execute command upon extraction */ int skip_extract_query AUTOINIT; /* Skip file extraction query (-ym) */ char *extr_cmd_text; /* Command to be run */ unsigned short reg_id AUTOINIT; /* SFX registration signature */ int licensed_sfx AUTOINIT; /* Indicates a licensed (secured) SFX */ int logo_shown AUTOINIT; /* 1 once the ARJSFX logo is shown */ #endif #if SFX_LEVEL<=ARJSFX int make_directories AUTOINIT; /* 1 if directory creation is allowed */ int show_ansi_comments AUTOINIT; /* Display ANSI comments */ char *list_adapted_name; /* Filename used in listing */ int test_mode AUTOINIT; /* 1 if test_sfx_cmd was issued */ int sflist_args AUTOINIT; /* Simplified filelist -- # of args */ char *sflist[SFLIST_MAX]; /* Simplified filelist itself */ #endif #ifdef COLOR_OUTPUT int redirected; /* 1 if STDOUT was redirected */ int no_colors; /* 1 if color output was disabled */ struct color_hl color_table[]={ {7, 'n'}, {10, 'o'}, {2, 'h'}, {15, 's'}, {12, 'a'}, {3, 'p'}, {0, 0} }; #endif arj-3.10.22/externs.h 666 0 0 27732 10064613030 10532 0ustar /* * $Id: externs.h,v 1.5 2004/06/18 16:19:37 andrew_belov Exp $ * --------------------------------------------------------------------------- * Each public variable defined in EXTERNS.C is declared here, so all modules * that include this file will have access to all public variables. * */ #ifndef EXTERNS_INCLUDED #define EXTERNS_INCLUDED #include /* Obsolete/shared data */ extern char nullstr[]; extern char strform[]; extern char path_separators[]; extern char switch_chars[]; extern char arjtemp_spec[]; extern int error_occured; extern char cmd_ac[]; extern char cmd_cc[]; extern char cmd_dc[]; extern char le_prompt[]; extern char vd_space[]; extern int file_packing; extern char FAR *encblock_ptr; extern char FAR *packblock_ptr; extern unsigned int encmem_remain; extern unsigned int packmem_remain; extern unsigned int encmem_limit; extern int ea_supported; extern long ext_hdr_capacity; extern struct ext_hdr FAR *eh; extern int valid_ext_hdr; extern unsigned int ea_size; extern char *exe_name; /* Exported data */ #if SFX_LEVEL>=ARJ||defined(REARJ) extern unsigned char regdata[]; #endif extern struct flist_root flist_order; extern struct flist_root flist_archive; extern struct flist_root flist_main; extern struct flist_root flist_exclusion; extern struct flist_root flist_ea; extern struct flist_root flist_xea; #if TARGET==UNIX extern struct l_entries l_entries; extern struct l_entries sl_entries; #endif extern int win32_platform; extern int switch_char; extern int display_totals; extern unsigned int file_attr_mask; extern int pattern_found; extern int is_registered; extern int in_key; extern int is_commercial; extern int lfn_supported; extern int ext_hdr_flags; extern int file_garbled; extern int arch_wildcard_allowed; extern int file_args; extern int volume_flag_set; extern int tmp_archive_used; extern int method_specifier; extern int primary_file_type; extern int identical_filedata; extern int ctrlc_not_busy; extern int ignore_errors; extern int ctrlc_processing; extern int supply_comment_file; extern int use_comment; extern int assume_yes; extern int extract_to_file; extern int assign_work_directory; extern int multivolume_option; extern int allow_mv_update; extern int beep_between_volumes; extern int chk_arj_version; extern int verbose_display; extern int update_criteria; extern int translate_unix_paths; extern int type_override; extern int timestamp_override; extern int test_archive_crc; extern int store_by_suffix; extern int skip_ts_check; extern int comment_display; extern int lfn_mode; extern int create_sfx; extern int filter_attrs; extern int select_backup_files; extern int search_mode; extern int keep_tmp_file; extern int hollow_mode; extern int restart_at_filename; extern int quiet_mode; extern int recurse_subdirs; extern int ignore_crc_errors; extern int set_string_parameter; extern int query_for_each_file; extern int protfile_option; extern int arjprot_tail; extern int prot_blocks; extern int arjdisp_enabled; extern int prompt_for_more; extern int marksym_expansion; extern int fnm_matching; extern int rsp_per_line; extern int gost_cipher; extern int filter_older; extern int filter_same_or_newer; extern int new_files_only; extern int nonexist_filespec; extern int skip_switch_processing; extern int disable_sharing; extern int yes_on_all_queries; extern int indicator_style; extern int disable_arj_sw; extern int skip_time_attrs; extern int custom_method; extern int max_compression; extern int filelist_storage; extern int create_list_file; extern int listfile_err_opt; extern int listchars_allowed; extern int handle_labels; extern int sign_with_arjsec; extern int keep_tmp_archive; extern int keep_bak; extern int create_index; extern int detailed_index; extern int ignore_archive_errors; extern int ignore_open_errors; extern int clear_archive_bit; extern int jh_enabled; extern int help_issued; extern int garble_enabled; extern int lowercase_names; extern int validate_style; extern int freshen_criteria; extern int chk_free_space; extern int force_lfn; extern int select_by_number; extern int show_filenames_only; extern int override_archive_exts; extern int extm_mode; extern int exit_after_count; extern int start_at_ext_pos; extern int start_with_seek; extern int exclude_paths; extern int exclude_files; extern int arjsec_opt; extern int run_cmd_at_start; extern int delete_processed; extern int debug_enabled; extern int install_errhdl; extern int chapter_mode; extern int set_target_directory; extern int serialize_exts; extern int allow_any_attrs; extern int filter_fa_arch; extern int append_curtime; extern char *time_str; extern int use_ansi_cp; extern int queries_assume_no[TOTAL_QUERIES]; extern int queries_assume_yes[TOTAL_QUERIES]; extern int accept_shortcut_keys; extern int skip_next_vol_query; extern int skip_scanned_query; extern int overwrite_existing; extern int skip_rename_prompt; extern int skip_space_query; extern int query_delete; extern int prompt_for_mkdir; extern int skip_append_query; extern int kbd_cleanup_on_input; extern int use_sfxstub; extern int whole_files_in_mv; extern int pause_between_volumes; extern int inhibit_change_test; extern int mv_cmd_state; extern int ignore_pcase; extern int no_file_activity; extern int std_list_cmd; extern int print_with_more; extern int subdir_extraction; extern int execute_cmd; extern int change_vol_delay; extern unsigned int left_trim; extern char listchar; extern int errorlevel; extern unsigned int errors; extern int lines_per_page; extern int lines_scrolled; extern int secondary_file_type; extern unsigned int file_type; extern int unpackable; extern int fdisp_lines; extern int reserve_size; extern int bitcount; extern FILE_COUNT av_total_files; extern FILE_COUNT av_total_longnames; extern FILE_COUNT exit_count; extern FILE_COUNT split_files; #if SFX_LEVEL>=ARJ extern FILE_COUNT FAR *order; extern char **f_arg_array; #else extern int order[PARAMS_MAX]; extern char *f_arg_array[PARAMS_MAX]; #endif extern int params_max; extern char *comment_file; extern char *archive_cmt_name; extern char *yes_query_list; extern char *extraction_filename; extern char *swptr_hv; extern char *search_reserve; extern char *search_str[SEARCH_STR_MAX]; extern char *filename_to_restart; extern char *string_parameter; extern char *arjdisp_ptr; extern char *arjcrypt_name; extern char *nonexist_name; extern unsigned long garble_ftime; extern char *index_name; extern char *list_file; extern char *swptr_t; extern char *cmd_to_exec; extern char *archive_suffixes; extern char *mv_cmd; #ifndef REARJ extern char *timestr_older; extern char *timestr_newer; #endif extern char *arj_env_name; extern char *swptr_hm; extern char *work_directory; extern char *target_dir; extern char *tmp_archive_name; extern char *rsp_name; #if SFX_LEVEL>=ARJSFXV extern char *tmp_tmp_filename; extern char *archive_name; #else extern char tmp_tmp_filename[FILENAME_MAX]; extern char archive_name[FILENAME_MAX]; #endif extern char *arjsec_env_name; extern char password_modifier; extern char *garble_password; extern char *archive_ext_list; extern char *debug_opt; extern char *start_cmd; extern char *misc_buf; extern char label_drive; extern char *strcpy_buf; extern unsigned char host_os; extern char *out_buffer; #if SFX_LEVEL>=ARJSFXV extern char *header; #else extern char header[HEADERSIZE_MAX]; #endif extern unsigned char byte_buf; extern unsigned char subbitbuf; extern FILE *new_stderr; extern int user_wants_fail; extern int resume_volume_num; extern unsigned int ext_voldata; extern int out_avail; extern int out_bytes; extern int total_chapters; extern int chapter_to_process; extern int current_chapter; extern FILE_COUNT max_filenames; extern unsigned int user_bufsiz; extern unsigned int current_bufsiz; extern unsigned short bitbuf; extern FILE *tstream; extern FILE *idxstream; extern FILE *new_stdout; extern FILE *atstream; extern FILE *aostream; extern FILE *encstream; extern FILE *aistream; extern unsigned long FAR *arch_hdr_index; extern unsigned long last_hdr_offset; extern long search_occurences[SEARCH_STR_MAX]; extern unsigned long ext_pos; extern unsigned long arcv_ext_pos; extern long uncompsize; extern unsigned long compsize; extern unsigned long origsize; extern unsigned long av_uncompressed; extern unsigned long av_compressed; extern unsigned long total_size; extern unsigned long total_written; extern unsigned long minfree; extern struct timestamp tested_ftime_older; extern struct timestamp tested_ftime_newer; extern unsigned long t_volume_offset; extern unsigned long mv_reserve_space; extern unsigned long volume_limit; extern struct timestamp secondary_ftime; extern struct timestamp ftime_max; extern unsigned long disk_space_used; extern unsigned long total_compressed; extern unsigned long total_uncompressed; extern unsigned long arjsec_offset; extern unsigned long secured_size; extern unsigned long cur_header_pos; extern long main_hdr_offset; extern char FAR *tmp_filename; extern unsigned long volume_crc; extern struct timestamp volume_ftime; extern FILE *ofstream; extern int recent_chapter; extern unsigned int alloc_unit_size; extern FILE_COUNT split_longnames; extern FILE_COUNT total_longnames; extern FILE_COUNT total_files; extern FILE_COUNT comment_entries; extern int max_chapter; extern int force_volume_flag; extern int sfx_desc_word; extern int add_command; extern int order_command; extern int no_inarch; extern int modify_command; extern int continued_nextvolume; extern int first_vol_passed; extern int mvfile_type; extern unsigned int volume_number; extern int continued_prevvolume; extern int encryption_applied; extern int cmd_verb; extern int security_state; extern int ansi_codepage; extern int dual_name; extern unsigned long archive_size; extern unsigned long resume_position; extern unsigned long header_crc; extern unsigned long file_crc; extern unsigned char chapter_number; extern unsigned char ext_flags; extern unsigned short host_data; extern unsigned short entry_pos; extern struct timestamp ctime_stamp; extern struct timestamp atime_stamp; extern struct timestamp ftime_stamp; extern struct file_mode file_mode; extern unsigned int method; extern unsigned char arj_flags; extern unsigned char arj_x_nbr; extern unsigned char arj_nbr; extern unsigned char first_hdr_size; extern unsigned int basic_hdr_size; extern char *hdr_comment; extern char *hdr_filename; #if SFX_LEVEL>=ARJSFXV extern char FAR *comment; #else extern char comment[COMMENT_MAX]; #endif extern char filename[FILENAME_MAX]; extern struct file_properties properties; extern unsigned char pt_len[NPT]; extern unsigned short left[2*NC-1]; extern unsigned short right[2*NC-1]; extern unsigned char c_len[NC]; extern unsigned short cpos; extern unsigned int bufsiz; #if SFX_LEVEL>=ARJSFXV extern unsigned char *dec_text; #elif (!defined(REARJ)) extern unsigned char dec_text[DICSIZ]; #endif #if SFX_LEVEL>=ARJ extern unsigned char *ntext; #endif #if SFX_LEVEL>=ARJ extern int arcmail_sw; extern int dos_host; extern struct priority priority; extern int include_eas; extern int exclude_eas; extern int disable_comment_series; extern int skip_century; extern int fix_longnames; extern int crit_eas; extern int symlink_accuracy; extern int do_chown; extern int suppress_hardlinks; extern int recursion_order; extern int encryption_id; extern jmp_buf main_proc; #endif #if SFX_LEVEL<=ARJSFXV extern int valid_envelope; extern int skip_integrity_test; extern int prompt_for_directory; extern int extract_expath; extern int process_lfn_archive; extern int skip_preset_options; extern int list_sfx_cmd; extern int overwrite_ro; extern int test_sfx_cmd; extern int verbose_list; extern int extract_cmd; extern int skip_volumes; extern int first_volume_number; extern int execute_extr_cmd; extern int skip_extract_query; extern char *extr_cmd_text; extern unsigned short reg_id; extern int licensed_sfx; extern int logo_shown; #endif #if SFX_LEVEL<=ARJSFX extern int make_directories; extern int show_ansi_comments; extern char *list_adapted_name; extern int test_mode; extern int sflist_args; extern char *sflist[SFLIST_MAX]; #endif #ifdef COLOR_OUTPUT extern int redirected; extern int no_colors; extern struct color_hl color_table[]; #endif #endif arj-3.10.22/ext_hdr.c 666 0 0 3430 7450456654 10445 0ustar /* * $Id: ext_hdr.c,v 1.1.1.1 2002/03/28 00:02:52 andrew_belov Exp $ * --------------------------------------------------------------------------- * Handy functions for dealing with extended headers. * */ #include "arj.h" DEBUGHDR(__FILE__) /* Debug information block */ /* Allocates a per-file extended header structure */ struct ext_hdr FAR *eh_alloc() { struct ext_hdr FAR *rc; rc=(struct ext_hdr FAR *)farmalloc_msg(sizeof(struct ext_hdr)); far_memset((char FAR *)rc, 0, sizeof(struct ext_hdr)); return(rc); } /* Locates a block with the specified tag, returning pointer to it */ struct ext_hdr FAR *eh_lookup(struct ext_hdr FAR *eh, char tag) { while(eh->next!=NULL) { if(eh->tag==tag) return(eh); eh=eh->next; } return(NULL); } /* Locates an unfinalized block */ struct ext_hdr FAR *eh_find_pending(struct ext_hdr FAR *eh) { if(eh==NULL) return(NULL); while(eh->next!=NULL) { if(EH_STATUS(eh)!=EH_FINALIZED) return(eh); eh=eh->next; } return(NULL); } /* Inserts a new block into an instantiated extended header structure. If the block is given as NULL, performs reallocation only */ struct ext_hdr FAR *eh_append(struct ext_hdr FAR *eh, char tag, char FAR *block, unsigned int size) { struct ext_hdr FAR *p_eh; if((p_eh=eh_lookup(eh, tag))==NULL) { for(p_eh=eh; p_eh->next!=NULL; p_eh=p_eh->next); p_eh->tag=tag; p_eh->next=eh_alloc(); } p_eh->raw=(char FAR *)farrealloc_msg(p_eh->raw, p_eh->size+size); if(block!=NULL) far_memmove(p_eh->raw+p_eh->size, block, size); p_eh->size+=size; return(p_eh); } /* Releases the extended header structure */ void eh_release(struct ext_hdr FAR *eh) { struct ext_hdr FAR *p_eh; while((p_eh=eh->next)!=NULL) { if(eh->raw!=NULL) farfree(eh->raw); farfree(eh); eh=p_eh; } } arj-3.10.22/ext_hdr.h 666 0 0 3101 7450456654 10445 0ustar /* * $Id: ext_hdr.h,v 1.1.1.1 2002/03/28 00:02:52 andrew_belov Exp $ * --------------------------------------------------------------------------- * This file is an interface to the extended header manager, EXT_HDR.C. * */ #ifndef EXT_HDR_INCLUDED #define EXT_HDR_INCLUDED /* Common definitions */ #define EXT_HDR_OVERHEAD 8 /* Number of bytes that each EH takes away besides its data */ /* Block processing flags: bits 0...1 = processing status bits 2...N = bit flags Processed status: when compressing, transition occurs from EH_UNPROCESSED to EH_FINALIZED via EH_PROCESSING. when extracting, transition occurs from EH_PROCESSING to EH_UNPROCESSED. */ #define EH_UNPROCESSED 0x0000 /* Not yet stored */ #define EH_PROCESSING 0x0001 /* Currently being processed */ #define EH_FINALIZED 0x0002 /* Processing complete */ /* Extended header management structure */ struct ext_hdr { char tag; char FAR *raw; unsigned int size; struct ext_hdr FAR *next; /* These are initialized from the outside */ char flags; unsigned int cur_offset; }; #define EH_STATUS(eh) (eh->flags&3) /* Prototypes */ struct ext_hdr FAR *eh_alloc(); struct ext_hdr FAR *eh_lookup(struct ext_hdr FAR *eh, char tag); struct ext_hdr FAR *eh_find_pending(struct ext_hdr FAR *eh); struct ext_hdr FAR *eh_append(struct ext_hdr FAR *eh, char tag, char FAR *block, unsigned int size); void eh_release(struct ext_hdr FAR *eh); #endif arj-3.10.22/fardata.c 666 0 0 37250 10040213576 10440 0ustar /* * $Id: fardata.c,v 1.6 2004/04/17 11:39:43 andrew_belov Exp $ * --------------------------------------------------------------------------- * This file contains routines dealing with far data segment and CRC. * */ #include "arj.h" #ifdef TILED #include /* Weird, eh? */ #endif /* ASR fix 02/05/2003: need that regardless of COLOR_OUTPUT to support -jp correctly */ #if SFX_LEVEL>=ARJ #define CUSTOM_PRINTF #define CHUNK_SIZE 512 /* Size of the output block */ #define CHUNK_THRESHOLD (CHUNK_SIZE-256) /* Safety bound */ #endif DEBUGHDR(__FILE__) /* Debug information block */ #ifdef CUSTOM_PRINTF /* Forward Declaration */ int vcprintf(int ccode, FMSG *fmt, va_list args); #endif #if SFX_LEVEL>=ARJ /* Checks if the error can have an error code or not */ static int is_std_error(FMSG *errmsg) { return(errmsg==M_DISK_FULL||errmsg==M_CANT_DELETE||errmsg==M_CANTOPEN|| errmsg==M_CANTRENAME||errmsg==M_CANTREAD||errmsg==M_CANT_DELETE|| errmsg==M_CANT_COPY_TEMP)?1:0; } #endif /* Makes various cleanup depending on the error message received and quits. */ int error_proc(FMSG *errmsg, ...) { char *tmp_errmsg; va_list marker; #if SFX_LEVEL>=ARJ /* Check if the message could have a standard error code */ if(errno!=0&&is_std_error(errmsg)) { msg_cprintf(0, lf); error_report(); } #endif #if SFX_LEVEL>=ARJSFXV if(quiet_mode==ARJ_SILENT) freopen(dev_con, m_w, stdout); #endif #if SFX_LEVEL>=ARJ file_settype(stdout, ARJT_TEXT); #endif /* For SFX archives, don't forget to display our logo */ #if SFX_LEVEL==ARJSFXV show_sfx_logo(); #elif SFX_LEVEL==ARJSFX if(!logo_shown) { msg_cprintf(0, M_ARJSFX_BANNER, exe_name); msg_cprintf(0, M_PROCESSING_ARCHIVE, archive_name); } #endif #if SFX_LEVEL>=ARJ nputlf(); #elif SFX_LEVEL>=ARJSFXV fputc(LF, new_stdout); #else fputc(LF, stdout); #endif /* Format and print the error message */ va_start(marker, errmsg); #ifdef CUSTOM_PRINTF vcprintf(H_ERR, errmsg, marker); #else tmp_errmsg=malloc_fmsg(errmsg); #if SFX_LEVEL>=ARJSFXV vfprintf(new_stdout, (FMSG *)tmp_errmsg, marker); #else vprintf(tmp_errmsg, marker); #endif free_fmsg(tmp_errmsg); #endif va_end(marker); #if SFX_LEVEL>=ARJ nputlf(); #elif SFX_LEVEL>=ARJSFXV fputc(LF, new_stdout); #else fputc(LF, stdout); #endif /* Terminate the execution with a specific errorlevel */ #if SFX_LEVEL>=ARJSFXV /* If there's no errorlevel yet, select errorlevel by message class */ if(errorlevel==0) errorlevel=subclass_errors(errmsg); /* If the error was the lack of memory, display final memory statistics to find memory leaks */ #if SFX_LEVEL>=ARJ if(errorlevel==ARJ_ERL_NO_MEMORY) mem_stats(); #endif error_occured=1; exit(errorlevel); #elif defined(REARJ) exit(REARJ_ERL_WARNING); #elif defined(REGISTER) exit(REGISTER_ERL_ERROR); #elif SFX_LEVEL>=ARJSFX exit(ARJSFX_ERL_ERROR); #else exit(1); #endif return(0); } #ifdef FMSG_ST /* A printf() function for far strings */ int msg_printf(FMSG *fmt, ...) { va_list marker; char *storage; int result; storage=malloc_far_str(fmt); va_start(marker, fmt); result=vfprintf(new_stdout, (FMSG *)storage, marker); va_end(marker); free(storage); return(result); } /* A fprintf() function for far strings */ int msg_fprintf(FILE *stream, FMSG *fmt, ...) { va_list marker; char *storage; int result; storage=malloc_far_str(fmt); va_start(marker, fmt); result=vfprintf(stream, storage, marker); va_end(marker); free(storage); return(result); } /* A sprintf() function for far strings */ int msg_sprintf(char *str, FMSG *fmt, ...) { va_list marker; char *storage; int result; storage=malloc_far_str(fmt); va_start(marker, fmt); result=vsprintf(str, storage, marker); va_end(marker); free(storage); return(result); } #endif #ifdef CUSTOM_PRINTF /* * A Q&D custom printf() implementation. Derived from: * * vsprintf.c -- Lars Wirzenius & Linus Torvalds. * Wirzenius wrote this portably, Torvalds f*cked it up :-) * */ /* Length-limited strlen() */ static int strnlen(const char FAR *s, int count) { const char FAR *sc; for(sc=s; *sc!='\0'&&count--; ++sc) ; return(sc-s); } /* Hex representation of digits */ static char adigit(unsigned long n, int is_uc) { if(n<10) return('0'+n); n-=10; return((is_uc?'A':'a')+n); } /* Q'n'D strtoul() implementation */ unsigned long simple_strtoul(const FMSG *cp, FMSG **endp, unsigned int base) { unsigned long result=0, value; if(!base) { base=10; if(*cp=='0') { base=8; cp++; if((*cp=='x')&&isxdigit(cp[1])) { cp++; base=16; } } } while(isxdigit(*cp)&&(value=isdigit(*cp)? *cp-'0': (islower(*cp)?toupper(*cp):*cp)-'A'+10)36) return(0); c=(type&ZEROPAD)?'0':' '; sign=0; if(type&SIGN) { if(num<0) { sign='-'; num=-num; size--; } else if(type&PLUS) { sign='+'; size--; } else if(type&SPACE) { sign=' '; size--; } } if(type&SPECIAL) { if(base==16) size-=2; else if(base==8) size--; } i=0; if(num==0) tmp[i++]='0'; else while (num!=0) { unsigned long __res; __res=((unsigned long)num)%(unsigned long)base; num=((unsigned long)num)/(unsigned long)base; tmp[i++]=adigit(__res, ucase_dig); } if(i>precision) precision=i; size-=precision; if(!(type&(ZEROPAD+LEFT))) { while(size-->0) *str++=' '; } if(sign) *str++=sign; if(type&SPECIAL) { if(base==8) *str++='0'; else if(base==16) { *str++='0'; *str++=ucase_dig?'X':'x'; } } if(!(type&LEFT)) { while(size-->0) *str++=c; } while(i0) *str++=tmp[i]; while(size-->0) *str++=' '; return(str-istr); } /* Flushes the output buffer downstream. The buffer gets clobbered. */ static void flush_cbuf(int ccode, char *text) { char *n_text, *t_text; int need_pause, rc; char c; if(quiet_mode==ARJ_SILENT||(quiet_mode==ARJ_QUIET&&!(ccode&H_FORCE))) return; CLOBBER_SENTRY(); need_pause=(prompt_for_more&&!yes_on_all_queries&&!print_with_more); n_text=t_text=text; #ifdef COLOR_OUTPUT if(!redirected&&!no_colors) textcolor(color_table[ccode&H_COLORMASK].color); #endif while((c=*t_text)!='\0') { if(c==LF) { *t_text='\0'; #ifdef COLOR_OUTPUT if(redirected) { #if SFX_LEVEL>=ARJSFXV fprintf(new_stdout, strform, n_text); fprintf(new_stdout, lf); #else printf(strform, n_text); printf(lf); #endif } else { scr_out(n_text); if(!no_colors) textcolor(7); #ifdef NEED_CRLF scr_out("\r"); #endif scr_out(lf); } if(!no_colors) textcolor(color_table[ccode&H_COLORMASK].color); #else printf(strform, n_text); printf(lf); #endif n_text=t_text+1; #if SFX_LEVEL>=ARJ lines_scrolled++; if(lines_scrolled>=lines_per_page-1) { lines_scrolled=0; if(need_pause) { rc=pause(); #ifdef COLOR_OUTPUT /* Restore the color after implicit recursion to msg_cprintf() */ if(!no_colors) textcolor(color_table[ccode&H_COLORMASK].color); #endif if(!rc&&(ccode&H_WEAK)) longjmp(main_proc, 1); } } #endif } t_text++; } #ifdef COLOR_OUTPUT if(redirected) #if SFX_LEVEL>=ARJSFXV fprintf(new_stdout, strform, n_text); #else printf(strform, n_text); #endif else scr_out(n_text); #else printf(strform, n_text); #endif } /* vcprintf() implementation */ int vcprintf(int ccode, FMSG *fmt, va_list args) { int len; unsigned long num; int i, base; char FAR *s; int flags; /* flags to number() */ int field_width; /* width of output field */ int precision; /* min. # of digits for integers; max number of chars for from string */ int qualifier; /* 'h', 'l', or 'L' for integer fields */ int far_str; /* Far string qualifier */ char buf[CHUNK_SIZE]; /* Output buffer */ int p_buf; int rc=0; int ocode; /* Output color code for formatted fields (that's what the whole routine is about!) */ long *ipl; int *ipi; int last_fmt=0; ocode=(ccode&H_NFMT)?H_STD:ccode; for(p_buf=0; *fmt; ++fmt) { if(last_fmt&&ccode&H_NFMT) { last_fmt=0; buf[p_buf]='\0'; rc+=p_buf; p_buf=0; flush_cbuf(ocode, buf); } if(*fmt!='%'||*(fmt+1)=='%') { if(p_buf>=CHUNK_SIZE-1) { buf[p_buf]='\0'; rc+=p_buf; p_buf=0; flush_cbuf(ccode, buf); } buf[p_buf++]=*fmt; if(*fmt=='%') ++fmt; /* Skip over the 2nd percent - we've handled it here */ continue; } /* A format symbol is found - flush the buffer if: 1. It's H_NFMT, so we need to change the brush, OR 2. CHUNK_THRESHOLD has been exceeded (for numeric) */ if(ccode&H_NFMT||p_buf>=CHUNK_THRESHOLD) { buf[p_buf]='\0'; rc+=p_buf; p_buf=0; flush_cbuf(ccode, buf); } last_fmt=1; /* Process flags */ flags=0; repeat: ++fmt; /* This also skips first '%' */ switch(*fmt) { case '-': flags|=LEFT; goto repeat; case '+': flags|=PLUS; goto repeat; case ' ': flags|=SPACE; goto repeat; case '#': flags|=SPECIAL; goto repeat; case '0': flags|=ZEROPAD; goto repeat; case 'F': flags|=FAR_STR; goto repeat; } /* Get field width */ field_width=-1; if(isdigit(*fmt)) field_width=skip_atoi((FMSG **)&fmt); else if(*fmt=='*') { ++fmt; /* It's the next argument */ field_width=va_arg(args, int); if(field_width<0) { field_width=-field_width; flags|=LEFT; } } /* Get the precision */ precision=-1; if(*fmt=='.') { ++fmt; if(isdigit(*fmt)) precision=skip_atoi((FMSG **)&fmt); else if(*fmt=='*') { ++fmt; /* It's the next argument */ precision=va_arg(args, int); } if(precision<0) precision=0; } /* Get the conversion qualifier */ qualifier=-1; if(*fmt=='h'||*fmt=='l'||*fmt=='L') { qualifier=*fmt; ++fmt; } /* Default base */ base=10; switch(*fmt) { case 'c': if(!(flags&LEFT)) while(--field_width>0) buf[p_buf++]=' '; buf[p_buf++]=(unsigned char)va_arg(args, int); while(--field_width>0) buf[p_buf++]=' '; continue; case 's': if(!(flags&FAR_STR)) s=(char FAR *)va_arg(args, char NEAR *); else s=va_arg(args, char FAR *); #ifdef DEBUG if(!s) s="(null)"; #endif len=strnlen(s, precision); if(!(flags&LEFT)) { while(len=CHUNK_SIZE-1) { buf[p_buf]='\0'; rc+=p_buf; p_buf=0; flush_cbuf(ocode, buf); } buf[p_buf++]=' '; } } for(i=0; i=CHUNK_SIZE-1) { buf[p_buf]='\0'; rc+=p_buf; p_buf=0; flush_cbuf(ocode, buf); } buf[p_buf++]=*s++; } while(len=CHUNK_SIZE-1) { buf[p_buf]='\0'; rc+=p_buf; p_buf=0; flush_cbuf(ocode, buf); } buf[p_buf++]=' '; } continue; case 'p': if(field_width==-1) { field_width=2*sizeof(void *); flags|=ZEROPAD; } p_buf+=number(buf+p_buf, (unsigned long)va_arg(args, void *), 16, field_width, precision, flags); continue; case 'n': if(qualifier=='l') { ipl=va_arg(args, long *); *ipl=p_buf; } else { ipi=va_arg(args, int *); *ipi=p_buf; } continue; /* Integer number formats - set up the flags and "break" */ case 'o': base=8; break; case 'X': flags|=LARGE; case 'x': base=16; break; case 'd': case 'i': flags|=SIGN; case 'u': break; default: if(*fmt!='%') buf[p_buf++]='%'; if(*fmt) buf[p_buf++]=*fmt; else --fmt; continue; } if(qualifier=='l') num=va_arg(args, unsigned long); else if(qualifier=='h') { #ifdef __linux__ if (flags&SIGN) num=va_arg(args, int); /* num=va_arg(args, short); */ else num=va_arg(args, int); /* num=va_arg(args, unsigned short);*/ #else if(flags&SIGN) num=va_arg(args, short); else num=va_arg(args, unsigned short); #endif } else if(flags&SIGN) num=va_arg(args, int); else num=va_arg(args, unsigned int); p_buf+=number(buf+p_buf, num, base, field_width, precision, flags); } if(p_buf>0) { buf[p_buf]='\0'; rc+=p_buf; flush_cbuf(last_fmt?ocode:ccode, buf); } return(rc); } #endif /* CUSTOM_PRINTF */ #if SFX_LEVEL>=ARJSFX||defined(REARJ) /* Helper routine for scrprintf() */ int msg_cprintf(int ccode, FMSG *fmt, ...) { #ifndef CUSTOM_PRINTF char *storage; #endif va_list marker; int result; #ifndef CUSTOM_PRINTF #ifdef FMSG_ST storage=malloc_far_str(fmt); #else storage=fmt; #endif #endif va_start(marker, fmt); #if defined(CUSTOM_PRINTF) result=vcprintf(ccode, fmt, marker); #elif SFX_LEVEL>=ARJSFXV result=vfprintf(new_stdout, (FMSG *)storage, marker); #else result=vprintf(storage, marker); #endif va_end(marker); #if defined(FMSG_ST)&&!defined(CUSTOM_PRINTF) free(storage); #endif return(result); } #endif #if SFX_LEVEL>=ARJSFX&&defined(TILED) /* A model-independent movedata() function (it must go to ENVIRON.C) */ void far_memmove(char FAR *dest, char FAR *src, int length) { movedata(FP_SEG(src), FP_OFF(src), FP_SEG(dest), FP_OFF(dest), length); } #endif #if SFX_LEVEL>=ARJ /* Initializes CRC32 subsystem (only used by main()) */ void init_crc() { build_crc32_table(); } /* Returns CRC32 for the given block */ void crc_for_block(char *block, unsigned int length) { crc32_for_block(block, length); } /* Returns CRC32 for the given string */ void crc_for_string(char *str) { crc32_for_string(str); } #endif #ifdef COLOR_OUTPUT /* Parse the color table */ int parse_colors(char *opt) { int i, c; char *p; int rc=0; if(*opt=='\0') { no_colors=1; textcolor(7); /* HACK */ return(0); } while(*opt!='\0') { for(p=opt; !isdigit(*p); p++) { if(*p=='\0') { opt=p; goto next_opt; } } c=atoi(p); if(c>=32) rc++; else { for(i=0; color_table[i].arg!='\0'||!(++rc); i++) { if(color_table[i].arg==tolower(*opt)) { color_table[i].color=(char)c; break; } } } next_opt: while(*opt!='\0'&&!isdigit(*opt)) opt++; while(*opt!='\0'&&(isdigit(*opt)||!isalpha(*opt))) opt++; } return(rc); } #endif arj-3.10.22/fardata.h 666 0 0 3130 7620765410 10404 0ustar /* * $Id: fardata.h,v 1.2 2003/02/07 17:21:12 andrew_belov Exp $ * --------------------------------------------------------------------------- * Prototypes of the functions located in FARDATA.C are declared here. * */ #ifndef FARDATA_INCLUDED #define FARDATA_INCLUDED /* Prototypes */ int error_proc(FMSG *errmsg, ...); #ifdef DEBUG #define error dbg_dummy=debug_report(dbg_cur_file, __LINE__, 'E')||error_proc #else #define error error_proc #endif #ifndef TILED #define far_memmove memmove #endif int msg_cprintf(int ccode, FMSG *fmt, ...); #ifdef COLOR_OUTPUT int parse_colors(char *opt); #endif #ifdef FMSG_ST int msg_printf(FMSG *fmt, ...); int msg_fprintf(FILE *stream, FMSG *fmt, ...); int msg_sprintf(char *str, FMSG *fmt, ...); #ifdef TILED void far_memmove(char FAR *dest, char FAR *src, int length); #endif void init_crc(); void crc_for_block(char *block, unsigned int length); void crc_for_string(char *str); #define msg_strcpy(dest, src) far_strcpy((char FAR *)dest, src) #define msg_strcpyn far_strcpyn #define msg_strchr far_strchr #define msg_strcmp far_strcmp #define msg_strcat(dest, src) far_strcat((char FAR *)dest, src) #define malloc_fmsg(msg) malloc_far_str(msg) #define free_fmsg free #else #define msg_printf printf #if SFX_LEVEL>=ARJSFXV #define msg_fprintf fprintf #endif #define msg_sprintf sprintf #define msg_strcpy strcpy #define msg_strcpyn strcpyn #define msg_strchr strchr #define msg_strcat strcat #define msg_strcmp strcmp #define malloc_fmsg(msg) msg #define free_fmsg(ptr) #define crc_for_block crc32_for_block #define crc_for_string crc32_for_string #endif #endif arj-3.10.22/filelist.c 666 0 0 70242 10037322374 10652 0ustar /* * $Id: filelist.c,v 1.4 2004/04/14 20:54:21 andrew_belov Exp $ * --------------------------------------------------------------------------- * XMS routines and functions for dealing with file lists are located here. * Note: the current caching algorithm implies that the filelist is first * sequentially composed, then sequentially read. No random access. * */ #include "arj.h" #ifndef SIMPLE_FLIST #include "arj_xms.h" #endif DEBUGHDR(__FILE__) /* Debug information block */ /* This file actually consists of two completely different code groups, one for ARJ full-featured filelists, and another one for simplified filelists created by ARJSFX. */ #ifndef SIMPLE_FLIST #define FLIST_BLOCK_INCREMENT 16 /* Number of blocks to preallocate when a new block is allocated */ #define L_ENTRIES_INCREMENT 512 /* # of entries to reserve at once */ #if TARGET==DOS #define XMS_BLOCK_PREALLOC 2 /* Number of preallocated XMS blocks */ #define XMS_MULTIPLIER (FLIST_BLOCK_SIZE/1024) #endif /* Local far heap constants */ #define FAR_PROBE 32000L /* Amount of memory allocated to check if we're still alive */ #define FAR_HEAP_LOWBOUND 150000 /* If the amount of free memory goes below this, the heap needs to be relocated to XMS */ #else /* ARJSFX constants */ #define FILES_PER_BLOCK 8 #ifdef REARJ #define BLOCKS_LIMIT 512 #else #define BLOCKS_LIMIT 1024 #endif #endif /* Private CRC union - used for hash table calculation in ARJ. In SFX, we'll use simple checksums instead. */ #ifndef SIMPLE_FLIST struct crc_words { unsigned short lo; unsigned short hi; }; union crc32 { unsigned long crc32; struct crc_words x; char low; }; #endif #ifndef SIMPLE_FLIST /* Private data. Again, it has effect in ARJ only. */ static FILE_COUNT flist_capacity; /* Filelist capacity (=const) */ static unsigned long crc_matches, hash_matches; #endif /* From this point onward, #define REARJ means #define SIMPLE_FLIST (although REARJ filelist model is far from SIMPLE) */ #ifdef REARJ /* REARJ service routine - checks if a file is present in the exclusion list */ static int is_excluded(char *name) { char tmp_name[CCHMAXPATH]; int tmp_entry, e_entry; FILE_COUNT i; tmp_entry=split_name(name, NULL, NULL); for(i=0; itable->xms_handle) /* Allocates a block of extended memory and stores its handle in the hash table entry given. */ #if TARGET==DOS static int xms_malloc(unsigned long size, struct flist_root *root) { unsigned short xmsize; /* Size of allocated XMS in blocks */ short handle; xmsize=(unsigned short)(size/(unsigned long)FLIST_BLOCK_SIZE); if(size%(unsigned long)FLIST_BLOCK_SIZE!=0L) xmsize++; if(!allocate_xms(xmsize*XMS_MULTIPLIER, &handle)) return(0); root->table->xms_handle=handle; return(1); } #endif /* Reallocates a block of extended memory that belongs to the current hash structure */ #if TARGET==DOS static int xms_realloc(unsigned long size, struct flist_root *root) { struct xms_move xms_move; unsigned short xmsize; /* Size of allocated RAM in blocks */ short handle, old_handle; xmsize=(unsigned short)(size/(unsigned long)FLIST_BLOCK_SIZE); if(size%(unsigned long)FLIST_BLOCK_SIZE!=0L) xmsize++; if(!allocate_xms(xmsize*XMS_MULTIPLIER, &handle)) return(0); xms_move.src_handle=old_handle=root->table->xms_handle; xms_move.src_offset=0L; xms_move.dest_handle=handle; xms_move.dest_offset=0L; xms_move.length=(unsigned long)root->table->xms_mem_blocks*(unsigned long)FLIST_BLOCK_SIZE; if(!move_xms(&xms_move)) return(0); /* Potential extended memory leak! */ free_xms(old_handle); root->table->xms_handle=handle; return(1); } #endif /* Creates a temporary swap file for holding file lists */ static void create_swapfile(struct flist_root *root) { char *sf_name; sf_name=(char *)malloc_msg(CCHMAXPATH); sf_name[0]='\0'; if(swptr_hm[0]!='\0') add_pathsep(strcpy(sf_name, swptr_hm)); strcat(sf_name, arjtemp_spec); find_tmp_filename(sf_name); root->table->sf_name=(char *)malloc_msg(strlen(sf_name)+2); strcpy(root->table->sf_name, sf_name); if((root->table->sf_stream=file_open(root->table->sf_name, m_wbp))==NULL) error(M_CANTOPEN, root->table->sf_name); free(sf_name); } /* Reads the block given, moving it into the cache area */ static void get_heap_block(unsigned int block, struct flist_root *root) { #if TARGET==DOS struct xms_move xms_move; #endif char *tmp_block; /* For transfers from far RAM */ if(root->table->block!=block) { if(root->storage==BST_FAR) far_memmove((char FAR *)root->table->cache, (char FAR *)root->table->far_ptrs[block], FLIST_BLOCK_SIZE); else if(root->storage==BST_DISK) { fseek(root->table->sf_stream, (unsigned long)block*FLIST_BLOCK_SIZE, SEEK_SET); tmp_block=(char *)malloc_msg(FLIST_BLOCK_SIZE); if(fread(tmp_block, 1, FLIST_BLOCK_SIZE, root->table->sf_stream)!=FLIST_BLOCK_SIZE) error(M_CANTREAD); far_memmove((char FAR *)root->table->cache, (char FAR *)tmp_block, FLIST_BLOCK_SIZE); free(tmp_block); } #if TARGET==DOS else if(root->storage==BST_XMS) { xms_move.src_handle=root->table->xms_handle; xms_move.src_offset=(unsigned long)block*FLIST_BLOCK_SIZE; xms_move.dest_handle=0; xms_move.dest_offset=(unsigned long)(char FAR *)root->table->cache; xms_move.length=FLIST_BLOCK_SIZE; if(!move_xms(&xms_move)) error(M_LISTING_XMS_ERROR, M_XMS_READ); } #endif root->table->block=block; } } /* Saves a cached block in the heap if it's necessary */ static void save_heap_block(struct flist_root *root, char FAR *data) { #if TARGET==DOS struct xms_move xms_move; #endif unsigned int block; /* Block number */ char *tmp_block; /* Temporary transfer area */ if(root->table->not_flushed) { block=root->table->block_to_flush; if(root->storage==BST_FAR) { if(root->table->far_ptrs[block]==NULL) root->table->far_ptrs[block]=farmalloc_msg(FLIST_BLOCK_SIZE); far_memmove(root->table->far_ptrs[block], data, FLIST_BLOCK_SIZE); } else if(root->storage==BST_DISK) { if(root->table->sf_stream==NULL) create_swapfile(root); fseek(root->table->sf_stream, (unsigned long)block*FLIST_BLOCK_SIZE, SEEK_SET); tmp_block=malloc_msg(FLIST_BLOCK_SIZE); far_memmove((char FAR *)tmp_block, data, FLIST_BLOCK_SIZE); file_write(tmp_block, 1, FLIST_BLOCK_SIZE, root->table->sf_stream); free(tmp_block); } #if TARGET==DOS else if(root->storage==BST_XMS) { /* If the block number exceeds the quantity of allocated XMS blocks, resize XMS buffer */ if(block>=root->table->xms_mem_blocks) { if(!xms_realloc((unsigned long)(block+FLIST_BLOCK_INCREMENT)*FLIST_BLOCK_SIZE, root)) error(M_LISTING_XMS_ERROR, M_XMS_WRITE); root->table->xms_mem_blocks=block+FLIST_BLOCK_INCREMENT; } xms_move.src_handle=0; xms_move.src_offset=(unsigned long)data; xms_move.dest_handle=root->table->xms_handle; xms_move.dest_offset=(unsigned long)block*FLIST_BLOCK_SIZE; xms_move.length=(unsigned long)FLIST_BLOCK_SIZE; if(!move_xms(&xms_move)) error(M_LISTING_XMS_ERROR, M_XMS_WRITE); } #endif root->table->not_flushed=0; } } /* Swaps all members of the given heap to disk */ static void relocate_heap(struct flist_root *root) { unsigned int hiblock, curblock; hiblock=root->table->hiblock; root->table->sf_stream=NULL; for(curblock=0; curblock<=hiblock; curblock++) { root->storage=BST_FAR; get_heap_block(curblock, root); root->storage=BST_DISK; root->table->block_to_flush=curblock; root->table->not_flushed=1; save_heap_block(root, (char FAR *)root->table->cache); farfree(root->table->far_ptrs[curblock]); } farfree(root->table->far_ptrs); root->storage=BST_DISK; } /* Updates header CRCs */ static void update_hcrc(struct flist_root *root, unsigned long crc) { unsigned short hr; union crc32 crc32; char h; crc32.crc32=crc; hr=65535-flist_capacity+1; hr=(hr<=crc32.x.lo)?crc32.x.lo-hr:crc32.x.lo; h=crc32.crc32>>29; root->table->hcrc[hr]|=(1<>29; return((unsigned int)root->table->hcrc[hr]&((unsigned char)1<d_files)>0L) { do { cur_file--; if(!far_strccmp((char FAR *)name, root->d_names[cur_file])) return(cur_file+1); } while(cur_file!=0); } return(0); } #endif /* Finds if a filename is present in the given filelist */ #ifndef REARJ static int find_match(struct flist_root *root, char *name) #else static int find_match(struct flist_root *root, char *name, FILE_COUNT instance) #endif { #ifndef SIMPLE_FLIST int cur_entry; struct idblock FAR *idblock_ptr; char FAR *fnm_ptr; /* Pointer to filename in ID block */ struct disk_file_info FAR *dptr; union crc32 crc_term; unsigned int crc_seed; int curblock; char *tmp_name; #else FILE_COUNT cur_entry; char c; #endif #ifndef SIMPLE_FLIST crc32term=CRC_MASK; tmp_name=malloc_str(name); crc32_for_block(tmp_name, strlen(tmp_name)); free(tmp_name); if(!revert_hcrc(root, crc_term.crc32=crc32term)) return(0); hash_matches++; crc_seed=crc_term.x.lo; idblock_ptr=root->table->cache; for(curblock=root->table->low_block; curblock<=root->table->hiblock; curblock++) { if(curblock!=root->table->block_to_flush) { get_heap_block(curblock, root); for(cur_entry=0; cur_entrytotal_entries; cur_entry++) { if(idblock_ptr->crc[cur_entry]==crc_seed) { crc_matches++; dptr=(struct disk_file_info FAR *)&idblock_ptr->filler[idblock_ptr->sub_offset[cur_entry]]; fnm_ptr=dptr->name; if(!far_strccmp(fnm_ptr, (char FAR *)name)) { root->table->low_block=curblock; return(1); /* Matched */ } } } } } for(curblock=0; curblocktable->low_block; curblock++) { if(curblock!=root->table->block_to_flush) { get_heap_block(curblock, root); for(cur_entry=0; cur_entrytotal_entries; cur_entry++) { if(idblock_ptr->crc[cur_entry]==crc_seed) { crc_matches++; dptr=(struct disk_file_info FAR *)&idblock_ptr->filler[idblock_ptr->sub_offset[cur_entry]]; fnm_ptr=dptr->name; if(!far_strccmp(fnm_ptr, (char FAR *)name)) { root->table->low_block=curblock; return(1); /* Matched */ } } } } } idblock_ptr=(struct idblock FAR *)root->table->sec_cache; for(cur_entry=0; cur_entrytotal_entries; cur_entry++) { if(idblock_ptr->crc[cur_entry]==crc_seed) { dptr=(struct disk_file_info FAR *)&idblock_ptr->filler[idblock_ptr->sub_offset[cur_entry]]; fnm_ptr=dptr->name; if(!far_strccmp(fnm_ptr, (char FAR *)name)) { root->table->low_block=curblock; return(1); /* Matched */ } } } #else c=checksum(name); for(cur_entry=0; cur_entryfiles; cur_entry++) { /* Return # of file + 1 if everything matched */ #ifndef REARJ if(root->checksums[cur_entry]==c&&!far_strccmp(root->names[cur_entry], (char FAR *)name)) return(cur_entry+1); #else if(root->checksums[cur_entry]==c&&root->instances[cur_entry]==instance&&!far_strccmp(root->names[cur_entry], (char FAR *)name)) return(cur_entry+1); #endif } #endif return(0); } #ifndef SIMPLE_FLIST /* Frees memory structures associated with filelist search */ static void cache_cleanup(struct flist_root *root) { if(!root->table->not_allocated) { if(root->table->hiblock>0||root->table->block_to_flush>0) { save_heap_block(root, (char FAR *)root->table->sec_cache); if(root->table->sec_cache!=NULL&&root->table->sec_cache!=root->table->cache) farfree(root->table->sec_cache); root->table->sec_cache=NULL; } if(root->table->hcrc!=NULL) farfree(root->table->hcrc); root->table->hcrc=NULL; root->table->not_allocated=1; } } /* Invalidates and releases the filelist root */ void flist_cleanup_proc(struct flist_root *root) { int block; if(root->table==NULL) return; if(debug_enabled&&strchr(debug_opt, 'v')!=NULL) { msg_cprintf(0, M_XLIST_BLOCKS, root->table->xlist_blocks); if(root==&flist_main) msg_cprintf(0, M_HASH_MATCHES, hash_matches, crc_matches); } if(root->storage==BST_FAR) { for(block=0; blocktable->xlist_blocks; block++) { if(root->table->far_ptrs[block]!=NULL) farfree(root->table->far_ptrs[block]); } farfree(root->table->far_ptrs); } else if(root->storage==BST_DISK&&root->table->sf_stream!=NULL) { fclose(root->table->sf_stream); file_unlink(root->table->sf_name); free(root->table->sf_name); } #if TARGET==DOS else if(root->storage==BST_XMS) xms_free(root); #endif if(root->storage!=BST_NONE) { if(root->table->enumerators!=NULL) farfree(root->table->enumerators); if(root->table->hcrc!=NULL) farfree(root->table->hcrc); if(root->table->sec_cache!=NULL&&root->table->sec_cache!=root->table->cache) farfree(root->table->sec_cache); if(root->table->cache!=NULL) farfree(root->table->cache); free(root->table); if(root->fsptr!=NULL) free(root->fsptr); } root->storage=BST_NONE; } #elif defined(REARJ) /* REARJ-only version of cleanup proc. */ void flist_cleanup_proc(struct flist_root *root) { FILE_COUNT i; if(root->files>0) { for(i=0; ifiles; i++) farfree(root->names[i]); for(i=0; id_files; i++) farfree(root->d_names[i]); farfree(root->names); farfree(root->instances); if(root->d_names!=NULL) farfree(root->d_names); if(root->checksums!=NULL) farfree(root->checksums); root->files=0; } } #endif /* Retrieves a filename with given entry code from the list. Two implemenations follow... */ #ifndef SIMPLE_FLIST void retrieve_entry(char *dest, struct file_properties *properties, struct flist_root *root, FILE_COUNT entry) { struct idblock FAR *idblock_ptr; /* Temporary cache pointer */ struct disk_file_info FAR *dptr; int idx; /* Temporary idblock index */ int curblock; idblock_ptr=root->table->cache; /* If there are unfreed locations, do neccessary cleanup */ if(!root->table->not_allocated) cache_cleanup(root); if(root->table->hiblock<=0) { curblock=0; idblock_ptr=root->table->sec_cache; } else { for(curblock=0; curblock<=root->table->hiblock; curblock++) { if(root->table->enumerators[curblock]>entry) break; } if(curblock>0) curblock--; get_heap_block(curblock, root); } idx=idblock_ptr->sub_offset[entry-root->table->enumerators[curblock]]; dptr=(struct disk_file_info FAR *)&idblock_ptr->filler[idx]; /* Allow NULL destinations for hardlink search -- ASR fix 24/08/2001 */ if(dest!=NULL) far_strcpy((char FAR *)dest, (char FAR *)dptr->name); if(properties!=NULL) far_memmove((char FAR *)properties, (char FAR *)&dptr->file_properties, sizeof(struct file_properties)); } #else /* Retrieves a filelist entry */ void retrieve_entry(char *dest, struct flist_root *root, FILE_COUNT num) { #ifdef REARJ FILE_COUNT instance; #endif #ifdef REARJ instance=root->instances[num]; far_strcpy((char FAR *)dest, root->d_names[instance-1]); far_strcat((char FAR *)dest, root->names[num]); #else far_strcpy((char FAR *)dest, root->names[num]); #endif } #endif /* Adds an entry to the hash. Returns -1 if there was an error. There are two implementations of it. */ #ifndef SIMPLE_FLIST int add_entry(struct flist_root *root, char *name, FILE_COUNT *count, struct file_properties *properties) { struct idblock FAR *idblock_ptr; struct disk_file_info FAR *dptr; #ifdef TILED void FAR *tmp_ptr; /* Used for heap allocation test */ #endif unsigned long tmp_crc; long tmp_offset; /* Offset to fileinfo in blocks */ int new_blocks; /* New qty of XList blocks */ int old_blocks; /* Old qty of XList blocks */ int curblock; /* Cleanup loop variable */ int index; /* Index in ID block */ FILE_COUNT tmp_files; int tmp_hiblock; int extend_len; /* Number of bytes to reserve */ if(root->files>=root->maxfiles) { #if SFX_LEVEL>=ARJSFXV msg_cprintf(0, M_NAMES_LIMIT, root->maxfiles, name); #else msg_cprintf(0, M_NAMES_LIMIT, root->maxfiles, name); #endif return(-1); } if((idblock_ptr=root->table->sec_cache)==NULL) { if(root->type!=FL_STANDARD) root->table->sec_cache=farmalloc_msg(FLIST_BLOCK_SIZE); else root->table->sec_cache=root->table->cache; idblock_ptr=root->table->sec_cache; idblock_ptr->total_entries=0; idblock_ptr->size=0; } /* ASR fix -- debug enhancement 03/10/2001 */ if(debug_enabled&&strchr(debug_opt, '.')!=NULL) msg_cprintf(0, M_TOKEN, name); if(root->type!=FL_STANDARD&&root->no_dupl) { if(find_match(root, name)) { if(count!=NULL) (*count)++; return(0); } } tmp_hiblock=root->table->hiblock; extend_len=strlen(name)+sizeof(struct file_properties); tmp_files=root->files; tmp_offset=(long)idblock_ptr->size; /* Check against limits */ if(idblock_ptr->total_entries+1>ENTRIES_PER_BLOCK||(tmp_offset+(long)extend_len+1>(long)(FLIST_BLOCK_SIZE-sizeof(struct idblock)-2))) { save_heap_block(root, (char FAR *)root->table->sec_cache); /* WARNING: compiler-dependent... */ #ifdef TILED if((tmp_ptr=farmalloc(FAR_PROBE))==NULL) { msg_cprintf(0, M_HASH_MEM_LACK, name); return(-1); } farfree(tmp_ptr); #endif /* If the far heap has overgrown its limits, relocate it to XMS ASAP */ if(root->storage==BST_FAR&&filelist_storage!=BST_NONE) { if(root->files>max_filenames||farcoreleft()table->block_to_flush++; tmp_hiblock++; /* Reallocate the block if it's needed */ if(tmp_hiblock+1>=root->table->xlist_blocks) { old_blocks=root->table->xlist_blocks; root->table->xlist_blocks=new_blocks=old_blocks+FLIST_BLOCK_INCREMENT; root->table->enumerators=farrealloc_msg(root->table->enumerators, (unsigned long)new_blocks*sizeof(unsigned long)); if(root->storage==BST_FAR) { root->table->far_ptrs=farrealloc_msg(root->table->far_ptrs, (unsigned long)new_blocks*sizeof(char FAR *)); /* Reset the newly created pointers to NULL */ for(curblock=old_blocks; curblocktable->far_ptrs[curblock]=NULL; } } /* New block starts, with no file entries yet */ idblock_ptr->total_entries=0; idblock_ptr->size=0; tmp_offset=0L; root->table->hiblock=tmp_hiblock; root->table->enumerators[tmp_hiblock]=tmp_files; root->table->enumerators[tmp_hiblock+1]=FLS_END; } root->table->not_flushed=1; dptr=(struct disk_file_info FAR *)&idblock_ptr->filler[tmp_offset]; far_strcpy(dptr->name, (char FAR *)name); if(properties!=NULL) far_memmove((char FAR *)&dptr->file_properties, (char FAR *)properties, sizeof(struct file_properties)); index=tmp_files-root->table->enumerators[tmp_hiblock]; idblock_ptr->sub_offset[index]=(int)tmp_offset; idblock_ptr->size=tmp_offset+extend_len+1; idblock_ptr->total_entries++; root->files++; if(root->type!=FL_STANDARD) { crc32term=CRC_MASK; crc32_for_block(name, strlen(name)); tmp_crc=crc32term; update_hcrc(root, tmp_crc); idblock_ptr->crc[index]=(char)tmp_crc; } if(count!=NULL) (*count)++; return(0); } #else #ifdef REARJ int add_entry(struct flist_root *root, char *name, FILE_COUNT *count) #else int add_entry(struct flist_root *root, struct flist_root *search_flist, char *name, FILE_COUNT *count) #endif { long diff; char FAR * FAR *names_ptr; int nl; char FAR *nptr; unsigned int nblocks; char FAR *checksums_ptr; FILE_COUNT nfiles; #ifdef REARJ char tmp_name[CCHMAXPATH]; char pathname[CCHMAXPATH]; int tmp_entry; FILE_COUNT dir_num; FILE_COUNT FAR *instances_ptr; #endif if(root->files>=root->maxfiles) { #if SFX_LEVEL>=ARJSFXV msg_cprintf(0, M_NAMES_LIMIT, root->maxfiles, name); #else msg_cprintf(0, M_NAMES_LIMIT, root->maxfiles, name); #endif return(-1); } #ifdef REARJ if(root->check_excl&&is_excluded(name)) return(0); tmp_entry=split_name(name, NULL, tmp_name); if(tmp_entry>0) strncpy(pathname, name, tmp_entry); pathname[tmp_entry]='\0'; dir_num=find_d_match(root, pathname); if(root->no_dupl&&dir_num!=0&&find_match(root, tmp_name, dir_num)) return(0); #else if(root->no_dupl&&find_match(root, name)) { if(count!=NULL) (*count)++; return(0); } #endif /* Separate directory storage is available in (and required by) REARJ only */ #ifdef REARJ if(dir_num==0) { if(root->d_files>=root->d_boundary) { diff=(long)root->maxfiles-root->d_files; diff=max(diff, 64L); diff+=(long)root->d_files; if((names_ptr=(char FAR * FAR *)farrealloc(root->d_names, diff*sizeof(char FAR *)))==NULL) { #if SFX_LEVEL>=ARJSFXV msg_cprintf(0, M_HASH_MEM_LACK, name); #else msg_cprintf(0, M_HASH_MEM_LACK, name); #endif return(-1); } root->d_names=names_ptr; root->d_boundary=(FILE_COUNT)diff; } nl=strlen(pathname); if((nptr=(char FAR *)farmalloc(nl+1))==NULL) { #if SFX_LEVEL>=ARJSFXV msg_cprintf(0, M_HASH_MEM_LACK, name); #else msg_cprintf(0, M_HASH_MEM_LACK, name); #endif return(-1); } root->d_names[root->d_files]=nptr; far_strcpy(nptr, (char FAR *)pathname); dir_num=++root->d_files; } #endif if(root->files>=root->boundary) { nblocks=root->maxfiles/FILES_PER_BLOCK; if(nblocks>BLOCKS_LIMIT) nblocks=BLOCKS_LIMIT; diff=(long)root->maxfiles-root->files; if((long)nblocksfiles; if((names_ptr=(char FAR * FAR *)farrealloc(root->names, diff*sizeof(char FAR *)))==NULL) { #if SFX_LEVEL>=ARJSFXV msg_cprintf(0, M_HASH_MEM_LACK, name); #else msg_cprintf(0, M_HASH_MEM_LACK, name); #endif return(-1); } checksums_ptr=NULL; if(root->no_dupl) { if((checksums_ptr=(char FAR *)farrealloc(root->checksums, diff*sizeof(FILE_COUNT)))==NULL) { #if SFX_LEVEL>=ARJSFXV msg_cprintf(0, M_HASH_MEM_LACK, name); #else msg_cprintf(0, M_HASH_MEM_LACK, name); #endif return(-1); } } #ifdef REARJ if((instances_ptr=(FILE_COUNT FAR *)farrealloc(root->instances, diff*sizeof(FILE_COUNT)))==NULL) { #if SFX_LEVEL>=ARJSFXV msg_cprintf(0, M_HASH_MEM_LACK, name); #else msg_cprintf(0, M_HASH_MEM_LACK, name); #endif return(-1); } #endif root->names=names_ptr; root->checksums=checksums_ptr; #ifdef REARJ root->instances=instances_ptr; #endif root->boundary=(FILE_COUNT)diff; } #ifdef REARJ nl=strlen(tmp_name); #else nl=strlen(name); #endif if((nptr=(char FAR *)farmalloc(nl+1))==NULL) { #if SFX_LEVEL>=ARJSFXV msg_cprintf(0, M_HASH_MEM_LACK, name); #else msg_cprintf(0, M_HASH_MEM_LACK, name); #endif return(-1); } nfiles=root->files; root->names[nfiles]=nptr; #ifdef REARJ far_strcpy(nptr, (char FAR *)tmp_name); #else far_strcpy(nptr, (char FAR *)name); #endif #ifdef REARJ root->instances[nfiles]=dir_num; if(root->no_dupl) root->checksums[nfiles]=checksum(tmp_name); #else if(root->no_dupl) root->checksums[nfiles]=checksum(name); #endif root->files++; if(count!=NULL) (*count)++; return(0); } #endif /* Initializes the filelist storage */ #if SFX_LEVEL>=ARJ void flist_init_proc(struct flist_root *root, FILE_COUNT maxfiles, char type) #elif defined(REARJ) void flist_init(struct flist_root *root, FILE_COUNT maxfiles, int no_dupl, int check_excl) #else void flist_init(struct flist_root *root, FILE_COUNT maxfiles, char no_dupl) #endif { #ifndef SIMPLE_FLIST int curblock, cur_entry; char *cptr; root->storage=BST_NONE; root->maxfiles=maxfiles; root->type=type; root->files=0L; root->no_dupl=0; root->fsptr=NULL; root->table=NULL; if(maxfiles==0L) return; if(root==&flist_main) hash_matches=crc_matches=0; if(debug_enabled&&strchr(debug_opt, 'v')!=NULL) msg_cprintf(0, M_SEARCH_FLAG, type); root->table=malloc_msg(sizeof(struct flist_table)); #if TARGET==DOS if(detect_xms()&&filelist_storage==BST_XMS) { root->storage=BST_XMS; get_xms_entry(); if(!xms_malloc(XMS_BLOCK_PREALLOC*FLIST_BLOCK_SIZE, root)) error(M_LISTING_XMS_ERROR, M_XMS_INIT); root->table->xms_mem_blocks=XMS_BLOCK_PREALLOC; } else #endif if(filelist_storage!=BST_NONE&&max_filenames<50) { root->storage=BST_DISK; root->table->sf_stream=NULL; } else { root->storage=BST_FAR; root->table->far_ptrs=farmalloc_msg((unsigned long)FLIST_BLOCK_INCREMENT*sizeof(void FAR *)); for(curblock=0; curblocktable->far_ptrs[curblock]=NULL; } root->table->cache=farmalloc_msg(FLIST_BLOCK_SIZE); root->table->sec_cache=NULL; root->table->block=-1; root->table->block_to_flush=0; root->table->low_block=0; root->table->not_flushed=0; root->table->not_allocated=0; root->table->xlist_blocks=FLIST_BLOCK_INCREMENT; root->table->enumerators=farmalloc_msg((unsigned long)FLIST_BLOCK_INCREMENT*sizeof(FILE_COUNT)); root->table->enumerators[0]=0; root->table->enumerators[1]=FLS_END; root->table->hiblock=0; root->table->hcrc=NULL; flist_capacity=FILELIST_CAPACITY; if(debug_enabled&&(cptr=strchr(debug_opt, 'z'))!=NULL) flist_capacity=(FILE_COUNT)strtol(cptr, &cptr, 10); if(root->type!=FL_STANDARD) { root->table->hcrc=farmalloc_msg((FILE_COUNT)flist_capacity); for(cur_entry=0; cur_entrytable->hcrc[cur_entry]=0; } #else root->maxfiles=maxfiles; root->no_dupl=(int)no_dupl; root->files=0; root->boundary=0; root->checksums=NULL; root->names=NULL; #ifdef REARJ root->check_excl=check_excl; root->d_files=0; root->d_boundary=0; root->d_names=NULL; root->instances=NULL; #endif #endif } #if SFX_LEVEL>=ARJ&&TARGET==UNIX /* [Hard]link search routine. Either returns a pointer to an existing entry in l_search structure, or creates a new entry. May operate with symlinks too (e.g. elimination of circular links) */ FILE_COUNT link_search(struct l_entries *entries, struct l_search *l_search, struct file_properties *properties, FILE_COUNT ref) { FILE_COUNT i; for(i=0; itotal; i++) { /* The refcount values are not compared, since these may vary */ if(!far_memcmp(&l_search->dev, (void FAR *)&entries->list[i].dev, sizeof(dev_t))&& l_search->inode==entries->list[i].inode) { if(properties!=NULL) { properties->islink=1; properties->l_search.ref=entries->list[i].ref; properties->type=ARJT_UXSPECIAL; properties->fsize=0L; } return(i); } } if(entries->total>=entries->alloc) { entries->alloc+=L_ENTRIES_INCREMENT; entries->list=(struct l_search FAR *)farrealloc_msg(entries->list, entries->alloc*sizeof(struct l_search)); } entries->list[i]=*l_search; entries->list[i].ref=ref; entries->total++; return(FLS_NONE); } #endif arj-3.10.22/filelist.h 666 0 0 11763 7620765410 10650 0ustar /* * $Id: filelist.h,v 1.2 2003/02/07 17:21:13 andrew_belov Exp $ * --------------------------------------------------------------------------- * Prototypes of the functions located in FILELIST.C are declared here. * */ #ifndef FILELIST_INCLUDED #define FILELIST_INCLUDED /* The filelist models in ARJ and ARJSFX are completely different, however, the naming, purpose, and sometimes the parameters of routines are the same, hence we insist on keeping the code parts together. The SIMPLE_FLIST constant controls the way of compile. */ #if SFX_LEVEL<=ARJSFXV #define SIMPLE_FLIST #endif #ifndef SIMPLE_FLIST /* Block defines */ #define FLIST_BLOCK_SIZE 2048 /* Minimum granularity of blocks */ #define ENTRIES_PER_BLOCK 85 /* May be increased */ #endif /* File list types */ #define FL_STANDARD 0 /* For smaller lists */ #define FL_HASH 1 /* Hash table with CRC matching */ /* Special return codes */ #define FLS_END (FLIST_SPEC_BASE+0) /* Indicates end of enumerator list */ #define FLS_NONE (FLIST_SPEC_BASE+1) /* Link search failure */ /* Advanced filelist structures */ #ifndef SIMPLE_FLIST /* ID block in hash tables. This structure is never used as a variable, its members are referenced with pointers. */ struct idblock { unsigned int total_entries; /* # of entries */ unsigned int size; unsigned int crc[64]; /* 2-byte CRCs (v 2.72+) */ /* Don't know/care about the padding that must go here. It may be intended to compensate the (ENTRIES_PER_BLOCK-64) number of CRC units, e.g. it must be unsigned int pad[21] but we omit it for memory conservation reasons. -- ASR fix for v 2.72.03 */ int sub_offset[ENTRIES_PER_BLOCK]; /* Subpointers */ char filler[1]; /* Beginning of raw data */ }; /* Filelist data table (pointed to by a root entry) */ struct flist_table { int xlist_blocks; /* Initialized with 8 */ unsigned long FAR *enumerators; /* Entry enumerators */ int hiblock; /* Highest # of block */ unsigned int block; /* ID of block that was recently fetched */ unsigned int block_to_flush; /* ID of block to be flushed */ int low_block; /* Lowest block number */ char not_flushed; /* 0 if cache is saved */ char not_allocated; /* 0 if cache is initialized */ struct idblock FAR *cache; /* Caching area */ struct idblock FAR *sec_cache; /* Secondary caching area */ char FAR *hcrc; /* Internal CRC? */ short xms_handle; /* One per table */ int xms_mem_blocks; /* Blocks in XMS */ char FAR * FAR *far_ptrs; /* Pointers to FAR blocks */ FILE *sf_stream; /* Temporary file */ char *sf_name; /* Temporary file name */ }; #endif #if TARGET==UNIX /* Hardlink candidates */ struct l_entries { struct l_search FAR *list; FILE_COUNT total; FILE_COUNT alloc; }; #endif /* Filelist root */ #ifndef SIMPLE_FLIST struct flist_root { char storage; /* char unk_01; */ /* It was here in original ARJ but we omitted it to lower the memory requirements -- ASR fix for v 2.72.03 */ char type; char no_dupl; FILE_COUNT maxfiles; FILE_COUNT files; char *fsptr; struct flist_table *table; }; #else struct flist_root { FILE_COUNT maxfiles; /* Initialized */ FILE_COUNT boundary; /* Next unsafe value */ FILE_COUNT files; /* Count of file entries */ int no_dupl; #ifdef REARJ int check_excl; #endif char FAR *checksums; /* Simplified hash table */ char FAR * FAR *names; /* Filename array */ #ifdef REARJ FILE_COUNT FAR *instances; FILE_COUNT d_files; FILE_COUNT d_boundary; char FAR * FAR *d_names; #endif }; #endif /* Prototypes */ void flist_cleanup_proc(struct flist_root *root); #ifndef SIMPLE_FLIST void retrieve_entry(char *dest, struct file_properties *properties, struct flist_root *root, FILE_COUNT entry); int add_entry(struct flist_root *root, char *name, FILE_COUNT *count, struct file_properties *properties); void flist_init_proc(struct flist_root *root, FILE_COUNT maxfiles, char type); #else void retrieve_entry(char *dest, struct flist_root *root, FILE_COUNT num); #ifdef REARJ int add_entry(struct flist_root *root, char *name, FILE_COUNT *count); #else int add_entry(struct flist_root *root, struct flist_root *search_flist, char *name, FILE_COUNT *count); #endif #ifdef REARJ void flist_init(struct flist_root *root, FILE_COUNT maxfiles, int no_dupl, int check_excl); #else void flist_init(struct flist_root *root, FILE_COUNT maxfiles, char no_dupl); #endif #endif #if SFX_LEVEL>=ARJ&&TARGET==UNIX FILE_COUNT link_search(struct l_entries *entries, struct l_search *l_search, struct file_properties *properties, FILE_COUNT ref); #endif #endif arj-3.10.22/filemode.c 666 0 0 1655 7450456656 10605 0ustar /* * $Id: filemode.c,v 1.1.1.1 2002/03/28 00:02:55 andrew_belov Exp $ * --------------------------------------------------------------------------- * This module contains nothing more than a set of "r", "rb", "rb+" and other * file access modes, to conserve space in DGROUP. * */ #include "bindings.h" /* File modes */ #if defined(ARJUTIL)||SFX_LEVEL>=ARJSFXV||defined(REARJ)||defined(REGISTER) char m_r[]="r"; #endif #if defined(ARJUTIL)||SFX_LEVEL>=ARJSFX char m_w[]="w"; #endif #if defined(ARJUTIL)||SFX_LEVEL>=ARJSFX||defined(REARJ) char m_rb[]="rb"; #endif #if defined(ARJUTIL)||SFX_LEVEL>=ARJSFX||defined(REGISTER)||defined(REARJ) char m_rbp[]="rb+"; #endif #if SFX_LEVEL>=ARJSFXV char m_rp[]="r+"; #endif #if SFX_LEVEL>=ARJSFX||defined(REARJ) char m_wb[]="wb"; #endif #if SFX_LEVEL>=ARJ char m_wbp[]="wb+"; #endif #if SFX_LEVEL>=ARJ||defined(REARJ) char m_a[]="a"; #endif #ifdef ARJUTIL char m_abp[]="ab+"; #endif arj-3.10.22/filemode.h 666 0 0 706 7450456656 10566 0ustar /* * $Id: filemode.h,v 1.1.1.1 2002/03/28 00:02:55 andrew_belov Exp $ * --------------------------------------------------------------------------- * This file declares references on data in FILEMODE.C * */ #ifndef FILEMODE_INCLUDED #define FILEMODE_INCLUDED extern char m_r[]; extern char m_rb[]; extern char m_rbp[]; extern char m_rp[]; extern char m_w[]; extern char m_wb[]; extern char m_wbp[]; extern char m_a[]; extern char m_abp[]; #endif arj-3.10.22/file_reg.c 666 0 0 4460 7655040106 10554 0ustar /* * $Id: file_reg.c,v 1.2 2003/05/03 22:18:47 andrew_belov Exp $ * --------------------------------------------------------------------------- * This file contains registration-related helper procedures. * */ #include "arj.h" DEBUGHDR(__FILE__) /* Debug information block */ /* Local variables */ static char special_key[]="Y2K"; #if TARGET==DOS static char default_key_name[]="C:ARJX"; static char key_name[]="ARJ.KEY"; #else static char key_name[]="arj.key"; #endif /* Validates registration information */ int reg_validation(char *key1, char *key2, char *name, char *validation) { return(verify_reg_name(key1, key2, name, validation)); } /* Hot-fix registration procedure */ void hot_reg(char *block) { char *nptr; int i; strip_lf(block); nptr=block; if(!stricmp(block, special_key)) in_key=0; for(i=0; i<8; i++) { nptr=ltrim(nptr); mput_dword(strtoul(nptr, &nptr, 10), (char*)®data[REG_HDR_SHIFT+(i<<2)]); } nptr=ltrim(nptr); for(i=0; *nptr!=' '&&*nptr!='\0'&&i #include "arj.h" #include "arjcrypt.h" #ifdef TILED #include #endif #if TARGET==UNIX #include #endif DEBUGHDR(__FILE__) /* Debug information block */ /* DOS constants */ #if TARGET==DOS #define COM_ENTRY 0x100 /* Entry point of COM file within PSP */ #define ARJCRYPT_STACK_SIZE 0x500 /* Number of bytes to add in tail */ #define ARJCRYPT_RESERVE 0x20 /* Size of exchange buffer */ #endif /* Skip ARJCRYPT executable lookup if not advised to */ #ifdef SKIP_GET_EXE_NAME #define NO_ARJCRYPT_LOOKUP #endif /* Local variables */ #if SFX_LEVEL>=ARJSFXV static int arjcrypt_loaded=0; /* 1 if the ARJCRYPT has been loaded */ struct arjcrypt_exblock exblock; /* Exchange block storage */ #if TARGET==DOS static char FAR *arjcrypt_mem; /* Memory for ARJCRYPT module */ static unsigned char FAR *arjcrypt_body;/* PSP-relative ARJCRYPT storage */ static unsigned int arjcrypt_psp; /* PSP segment of ARJCRYPT.COM */ static int arjcrypt_entry; /* Entry point within ARJCRYPT PSP */ static char *arjcrypt_stack; /* Address of stack */ static char arjcrypt_sig[]=ARJCRYPT_SIG;/* ARJCRYPT signature */ static jmp_buf arjcrypt_proc; /* Address of ARJCRYPT invocation */ static unsigned short ret_sp; #elif TARGET==OS2 HMODULE arjcrypt_hmod; /* OS/2 DLL handle */ #ifdef __32BIT__ int (* EXPENTRY arjcrypt_entry) (struct arjcrypt_exblock FAR *exblock_ptr); #else VOID (FAR PASCAL *arjcrypt_entry) (struct arjcrypt_exblock FAR *exblock_ptr); #endif #elif TARGET==WIN32 HINSTANCE arjcrypt_hmod; /* Win32 DLL handle */ VOID (*arjcrypt_entry) (struct arjcrypt_exblock FAR *exblock_ptr); #elif TARGET==UNIX void *arjcrypt_hmod; int (*arjcrypt_entry) (struct arjcrypt_exblock *exblock_ptr); #endif #endif static char *tmp_pwd_ptr; /* Active pointer to the password */ #if SFX_LEVEL>=ARJSFXV /* Moves the ARJCRYPT module to an area suitable for COM file storage */ #if TARGET==DOS static void relocate_arjcrypt(char FAR *dest, char FAR *src, int len) { while((len--)>0) *(dest++)=*(src++); } #endif /* Minimizes the offset portion of FAR pointer given */ #if TARGET==DOS static char FAR *adjust_segment(char FAR *long_addr) { return((char FAR *)((unsigned long)((FP_OFF(long_addr)>>4)+((unsigned long)FP_SEG(long_addr))<<16)+(unsigned long)(FP_SEG(long_addr)%16))); } #endif /* Unloads ARJCRYPT module upon exit */ #if TARGET==OS2||TARGET==WIN32||TARGET==UNIX static void remove_arjcrypt() { if(arjcrypt_loaded) { #if TARGET==OS2 DosFreeModule(arjcrypt_hmod); #elif TARGET==WIN32 FreeLibrary(arjcrypt_hmod); #elif TARGET==UNIX dlclose(arjcrypt_hmod); #endif } arjcrypt_loaded=0; } #endif /* Initializes the ARJCRYPT interface. Returns a non-zero value if something went wrong. */ static int arjcrypt_init(char *name) { FILE *stream; int arjcrypt_size; /* Size of ARJCRYPT module */ char *tmp_cryptmem; /* Temporary storage for ARJCRYPT */ #if TARGET==DOS int cur_pos; /* Current position within PSP */ int i; #endif #ifndef NO_ARJCRYPT_LOOKUP stream=file_open_noarch(name, m_rb); fclose(stream); if(!check_integrity(name)) msg_cprintf(0, M_NONSTD_GARBLE); stream=file_open_noarch(name, m_rb); fseek(stream, 0L, SEEK_END); arjcrypt_size=(int)ftell(stream); rewind(stream); tmp_cryptmem=malloc_msg(arjcrypt_size+2); fread(tmp_cryptmem, 1, arjcrypt_size, stream); fclose(stream); #if TARGET==DOS arjcrypt_mem=farmalloc_msg(arjcrypt_size+ARJCRYPT_STACK_SIZE+0x10); arjcrypt_body=adjust_segment(arjcrypt_mem); arjcrypt_psp=FP_SEG(arjcrypt_body)+1; /* Workaround for MS C v 7.0 macro */ arjcrypt_body=(char FAR *)((unsigned long)arjcrypt_psp<<16); relocate_arjcrypt(arjcrypt_body+COM_ENTRY, (char FAR *)tmp_cryptmem, arjcrypt_size); #endif free(tmp_cryptmem); #endif #if TARGET==DOS arjcrypt_entry=-1; for(cur_pos=COM_ENTRY; cur_pos<=arjcrypt_size+COM_ENTRY; cur_pos++) { for(i=0; arjcrypt_sig[i]!='\0'; i++) { if(arjcrypt_sig[i]!=arjcrypt_body[cur_pos+i]) break; } /* If the signature matched */ if(arjcrypt_sig[i]=='\0') { arjcrypt_entry=((int)arjcrypt_body[cur_pos+i+2]<<8)+(int)arjcrypt_body[cur_pos+i+1]; break; } } if(arjcrypt_entry==-1) error(M_NO_ARJCRYPT_ENTRY); /* Calculate exchange buffer address (DWORD-aligned) */ arjcrypt_stack=(char *)((arjcrypt_size+ARJCRYPT_STACK_SIZE-ARJCRYPT_RESERVE)&~3); #elif TARGET==OS2 if(DosLoadModule(NULL, 0, name, &arjcrypt_hmod)) error(M_ARJCRYPT_ERROR); atexit(remove_arjcrypt); #ifdef __32BIT__ if(DosQueryProcAddr(arjcrypt_hmod, 1L, NULL, (PFN *)&arjcrypt_entry)) error(M_NO_ARJCRYPT_ENTRY); #else if(DosGetProcAddr(arjcrypt_hmod, (PSZ)1L, &arjcrypt_entry)) error(M_NO_ARJCRYPT_ENTRY); #endif #elif TARGET==WIN32 if((arjcrypt_hmod=LoadLibrary(name))==NULL) error(M_ARJCRYPT_ERROR); atexit(remove_arjcrypt); if((arjcrypt_entry=(VOID *)GetProcAddress(arjcrypt_hmod, (LPCSTR)1L))==NULL) error(M_NO_ARJCRYPT_ENTRY); #elif TARGET==UNIX if((arjcrypt_hmod=dlopen(name, RTLD_NOW))==NULL) { #ifdef DEBUG fputs(dlerror(), new_stdout); #endif error(M_ARJCRYPT_ERROR); } if((arjcrypt_entry=dlsym(arjcrypt_hmod, "entry"))==NULL) error(M_NO_ARJCRYPT_ENTRY); #endif return(0); } /* Transfers control to the ARJCRYPT invocation point. Never returns. */ #if TARGET==DOS static int FAR return_from_arjcrypt() { /* Restore our DS after being trashed by ARJCRYPT. longjmp() will do the rest. */ #if COMPILER==BCC #ifdef __BORLANDC__ asm{ mov ax, seg arjcrypt_proc } #else asm{ mov ax, seg _DATA } #endif #elif COMPILER==MSC asm{ cli mov ax, SEG arjcrypt_proc mov ss, ax mov sp, word ptr ss:ret_sp sti } #endif asm{ mov ds, ax } longjmp(arjcrypt_proc, 1); return(0); } #endif /* Invokes ARJCRYPT */ static int invoke_arjcrypt() { struct arjcrypt_exblock FAR *exblock_ptr; exblock.rc=ARJCRYPT_RC_OK; #if TARGET==DOS exblock.ret_addr=&return_from_arjcrypt; #endif exblock_ptr=(struct arjcrypt_exblock FAR *)&exblock; #if TARGET==DOS if(!setjmp(arjcrypt_proc)) { asm{ mov word ptr ret_sp, sp mov cx, word ptr exblock_ptr+2 mov dx, word ptr exblock_ptr mov ax, arjcrypt_psp mov bx, arjcrypt_stack mov si, arjcrypt_entry mov es, ax mov ds, ax cli mov ss, ax mov sp, bx sti push ax push si retf } } #elif TARGET==OS2||TARGET==WIN32 arjcrypt_entry(exblock_ptr); #elif TARGET==UNIX (*arjcrypt_entry)(exblock_ptr); #endif return(exblock.rc); } #endif /* Initializes the encryption subsystem */ int garble_init(char modifier) { #if SFX_LEVEL>=ARJSFXV char tmp_arjcrypt_name[CCHMAXPATH]; #endif #if SFX_LEVEL>=ARJSFXV if(ext_hdr_flags==ENCRYPT_STD||ext_hdr_flags==ENCRYPT_OLD) { password_modifier=modifier; tmp_pwd_ptr=garble_password; return(ENCRYPT_STD); } /* 40-bit encryption is not supported by SFX */ #if SFX_LEVEL>=ARJ else if(ext_hdr_flags==ENCRYPT_GOST40) { gost40_init(modifier); return(ENCRYPT_GOST40); } #endif else /* Assume that ARJCRYPT is needed */ { if(!arjcrypt_loaded) { tmp_arjcrypt_name[0]='\0'; if(arjcrypt_name!=NULL&&split_name(arjcrypt_name, NULL, NULL)>0) strcpy(tmp_arjcrypt_name, arjcrypt_name); else { /* Get pathname of executable */ #if !defined(SKIP_GET_EXE_NAME) split_name(exe_name, tmp_arjcrypt_name, NULL); #elif defined(PKGLIBDIR) /* if !defined(PKGLIBDIR), we'll let the dynamic loader perform the search */ strcpy(tmp_arjcrypt_name, PKGLIBDIR); strcat(tmp_arjcrypt_name, "/"); #endif if(arjcrypt_name==NULL||arjcrypt_name[0]=='\0') msg_strcat(tmp_arjcrypt_name, M_ARJCRYPT_COM); else strcat(tmp_arjcrypt_name, arjcrypt_name); #if TARGET==UNIX strcat(tmp_arjcrypt_name, MOD_EXTENSION); #endif } msg_cprintf(0, M_LOADING, tmp_arjcrypt_name); arjcrypt_init(tmp_arjcrypt_name); } arjcrypt_loaded=1; exblock.mode=ARJCRYPT_V2_INIT; exblock.inq_type=ARJCRYPT_INQ_INIT; exblock.flags=ext_hdr_flags; exblock.password=(char FAR *)garble_password; exblock.l_modifier[0]=garble_ftime; exblock.l_modifier[1]=(long)(signed char)modifier; return(invoke_arjcrypt()); } #else password_modifier=modifier; tmp_pwd_ptr=garble_password; return(ENCRYPT_STD); #endif } #if SFX_LEVEL>=ARJ /* Encodes a block of data */ void garble_encode(char *data, int len) { int i; char *tmp_dptr; tmp_dptr=data; /* Standard encryption */ if(ext_hdr_flags==ENCRYPT_STD||ext_hdr_flags==0) { for(i=0; i=ARJ /* GOST 40-bit encryption (v 2.61+) */ else if(ext_hdr_flags==ENCRYPT_GOST40) gost40_decode_stub(data, len); #endif /* GOST 256-bit encryption (v 2.55+) */ #if SFX_LEVEL>=ARJSFXV else { if(!arjcrypt_loaded) error(M_ARJCRYPT_ERROR); exblock.mode=ARJCRYPT_DECODE; exblock.len=len; exblock.data=(char FAR *)data; invoke_arjcrypt(); } #endif } arj-3.10.22/garble.h 666 0 0 640 7450456656 10233 0ustar /* * $Id: garble.h,v 1.1.1.1 2002/03/28 00:02:55 andrew_belov Exp $ * --------------------------------------------------------------------------- * Prototypes of the functions located in GARBLE.C are declared here. * */ #ifndef GARBLE_INCLUDED #define GARBLE_INCLUDED /* Prototypes */ int garble_init(char modifier); void garble_encode(char *data, int len); void garble_decode(char *data, int len); #endif arj-3.10.22/gnu/ 777 0 0 0 10256535570 7366 5ustar arj-3.10.22/gnu/arj.qpg 666 0 0 15726 10040214030 10736 0ustar QNX.ORG.RU Community QNX.ORG.RU Team Mike Gorchak mike@malva.ua Application ARJ32 1 http://mike.qnx.org.ru/repository 2.0 ARJ32 arj32 andrew_belov@newmail.ru ARJ Software Russia public http://arj.sf.net andrew_belov@newmail.ru Andrew Belov http://arj.sf.net andrew_belov@newmail.ru ARJ32 is a free and portable clone of the ARJ archiver for DOS and Windows. ARJ32 is a free and portable clone of the ARJ archiver for DOS and Windows. It can be used to create and extract archives and uses the save format as the proprietary version. Install the arj package if you need to uncompress and create .arj format archives. http://arj.sf.net 3.10 High Stable 1 GNU General Public License System/File Utilities/Archiving ARJ, ARJ32, Archiver, Packer, UnArchiver, UnPacker, UnARJ Console User repdata://LicenseUrl/COPYING arj-3.10.22/gnu/arj.spec 666 0 0 2341 10040214036 11054 0ustar Summary: Free and portable clone of the ARJ archiver Name: arj Version: 3.10 Release: 1 Copyright: GPL Group: Applications/Archiving Source: http://unc.dl.sourceforge.net/sourceforge/arj/%{name}-%{version}.tar.gz BuildRoot: %{_tmppath}/%{name}-%{version}-root BuildRequires: autoconf %description The arj program is a free clone of the ARJ archiver for DOS and Windows. It can be used to create and extract archives and uses the save format as the proprietary version. Install the arj package if you need to uncompress and create .arj format archives. %prep %setup -q -n arj %build cd gnu autoconf ./configure cd .. make prepare RPM_OPT_FLAGS="$RPM_OPT_FLAGS" make RPM_OPT_FLAGS="$RPM_OPT_FLAGS" %install rm -rf $RPM_BUILD_ROOT mkdir -p $RPM_BUILD_ROOT/usr/bin install -m 755 linux-gnu/en/rs/arj/arj $RPM_BUILD_ROOT/usr/bin/arj install -m 755 linux-gnu/en/rs/arjdisp/arjdisp $RPM_BUILD_ROOT/usr/bin/arjdisp install -m 755 linux-gnu/en/rs/rearj/rearj $RPM_BUILD_ROOT/usr/bin/rearj %clean rm -rf $RPM_BUILD_ROOT %files %defattr(-,root,root) %doc doc/* /usr/bin/* %changelog * Sun Dec 15 2002 Andrew Belov - Adapted for the previous naming changes * Sat Dec 14 2002 Pavel Roskin - Initial version arj-3.10.22/gnu/arjcrypt.def 666 0 0 324 7450242204 11712 0ustar LIBRARY ARJCRYPT INITGLOBAL EXETYPE OS2 DESCRIPTION '32-bit GOST 28147-89 encryption plug-in for ARJ/EMX' PROTMODE DATA MULTIPLE CODE LOADONCALL EXPORTS entry @1 arj-3.10.22/gnu/ChangeLog 666 0 0 6660 10256056010 11213 0ustar 2005-06-18 Andrew Belov * configure.in: Fix build failure on GNU/kFreeBSD and GNU/kNetBSD - from Aurelien Jarno 2005-01-21 Andrew Belov * configure.in: Interix patch from Todd Vierling 2004-04-17 Andrew Belov * arj.qpg, arj.spec: The gamma cycle is now over, removing gamma version markers * configure.in, makefile.in: Corrections to allow CFLAGS be overriden by user, after a patch from Guillem Jover 2004-03-21 Andrew Belov * configure.in, makefile.in: Rearranged DLL_CFLAGS to prevent unconditional use of -fPIC for EMX * config.h.in, configure.in: Workaround for parital patterns passed to fnmatch() 2004-03-17 Andrew Belov * configure.in: Guess-hack for Solaris 8 2004-01-25 Andrew Belov * configure.in, makefile.in, config.h.in: Patches from NetBSD codeline to enable NetBSD/x86-64 support 2003-10-27 Andrew Belov * configure.in: Drop -fPIC for ARJCRYPT on QNX (now enforced in the makefile). Declare pointer alignment to support additional architectures - patch by Guillem Jover * makefile.in: Enforce -fPIC for ARJCRYPT. Patch by Randolph Chung 2003-10-16 Andrew Belov * makefile.in, stripgcc.lnk, arj.qpg, configure.in: Incorporating QNX build patches by Mike Gorchak 2003-05-14 Andrew Belov * makefile.in: Link REGISTER with integr.* as a temporary workaround for POSTPROC regressions 2003-05-07 Andrew Belov * makefile.in: Updates for SPARC from Etienne Joarlette 2003-05-05 Andrew Belov * config.h.in, configure.in: Determine if the CPU requires pointer alignment 2003-04-24 Andrew Belov * config.sub: QNX patch from Samuli Tuomola 2003-04-18 Andrew Belov * makefile.in: More packaging patches * configure.in, makefile.in: Build/packaging patches and man pages from Guillem Jover 2003-04-15 Andrew Belov * config.h.in, configure.in: Preliminary SPARC/SunOS patches from Etienne Joarlette 2003-04-15 Andrew Belov * config.h.in, configure.in: Check for big-endian 2003-04-06 Andrew Belov * arj.spec: Version 2.78.11 - gamma stage 2003-02-07 Andrew Belov * config.h.in, configure.in, makefile.in: Merged with TCO branch up to 2.78.08 (colorstyle support and internal cleanup) 2002-12-14 Andrew Belov * arj.spec, config.h.in, configure.in, makefile.in: Miscellaneous changes to facilitate compiling with GNU make as proposed by Pavel Roskin . 2002-04-08 Andrew Belov * config.h.in, makefile.in: Official Open Source release. 2002-03-28 Andrew Belov * install-sh, makefile.in, mkinstalldirs, stripgcc.lnk, config.guess, config.h.in, config.sub, configure.in, arjcrypt.def: Imported the first public release of open-source ARJ. arj-3.10.22/gnu/config.guess 666 0 0 47713 7450242234 11771 0ustar #! /bin/sh # Attempt to guess a canonical system name. # Copyright (C) 1992, 93, 94, 95, 1996 Free Software Foundation, Inc. # # This file is free software; you can redistribute it and/or modify it # under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, but # WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU # General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. # # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Written by Per Bothner . # The master version of this file is at the FSF in /home/gd/gnu/lib. # # This script attempts to guess a canonical system name similar to # config.sub. If it succeeds, it prints the system name on stdout, and # exits with 0. Otherwise, it exits with 1. # # The plan is that this can be called by configure scripts if you # don't specify an explicit system type (host/target name). # # Only a few systems have been added to this list; please add others # (but try to keep the structure clean). # # This is needed to find uname on a Pyramid OSx when run in the BSD universe. # (ghazi@noc.rutgers.edu 8/24/94.) if (test -f /.attbin/uname) >/dev/null 2>&1 ; then PATH=$PATH:/.attbin ; export PATH fi UNAME_MACHINE=`(uname -m) 2>/dev/null` || UNAME_MACHINE=unknown UNAME_RELEASE=`(uname -r) 2>/dev/null` || UNAME_RELEASE=unknown UNAME_SYSTEM=`(uname -s) 2>/dev/null` || UNAME_SYSTEM=unknown UNAME_VERSION=`(uname -v) 2>/dev/null` || UNAME_VERSION=unknown trap 'rm -f dummy.c dummy.o dummy; exit 1' 1 2 15 # Note: order is significant - the case branches are not exclusive. case "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" in *:OS/2:*:*) echo "i386-pc-os2_emx" exit 0;; alpha:OSF1:*:*) # A Vn.n version is a released version. # A Tn.n version is a released field test version. # A Xn.n version is an unreleased experimental baselevel. # 1.2 uses "1.2" for uname -r. echo alpha-dec-osf`echo ${UNAME_RELEASE} | sed -e 's/^[VTX]//'` exit 0 ;; 21064:Windows_NT:50:3) echo alpha-dec-winnt3.5 exit 0 ;; Amiga*:UNIX_System_V:4.0:*) echo m68k-cbm-sysv4 exit 0;; amiga:NetBSD:*:*) echo m68k-cbm-netbsd${UNAME_RELEASE} exit 0 ;; amiga:OpenBSD:*:*) echo m68k-cbm-openbsd${UNAME_RELEASE} exit 0 ;; arm:RISC*:1.[012]*:*|arm:riscix:1.[012]*:*) echo arm-acorn-riscix${UNAME_RELEASE} exit 0;; Pyramid*:OSx*:*:*|MIS*:OSx*:*:*) # akee@wpdis03.wpafb.af.mil (Earle F. Ake) contributed MIS and NILE. if test "`(/bin/universe) 2>/dev/null`" = att ; then echo pyramid-pyramid-sysv3 else echo pyramid-pyramid-bsd fi exit 0 ;; NILE:*:*:dcosx) echo pyramid-pyramid-svr4 exit 0 ;; sun4*:SunOS:5.*:* | tadpole*:SunOS:5.*:*) echo sparc-sun-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; i86pc:SunOS:5.*:*) echo i386-pc-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:6*:*) # According to config.sub, this is the proper way to canonicalize # SunOS6. Hard to guess exactly what SunOS6 will be like, but # it's likely to be more like Solaris than SunOS4. echo sparc-sun-solaris3`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; sun4*:SunOS:*:*) case "`/usr/bin/arch -k`" in Series*|S4*) UNAME_RELEASE=`uname -v` ;; esac # Japanese Language versions have a version number like `4.1.3-JL'. echo sparc-sun-sunos`echo ${UNAME_RELEASE}|sed -e 's/-/_/'` exit 0 ;; sun3*:SunOS:*:*) echo m68k-sun-sunos${UNAME_RELEASE} exit 0 ;; aushp:SunOS:*:*) echo sparc-auspex-sunos${UNAME_RELEASE} exit 0 ;; atari*:NetBSD:*:*) echo m68k-atari-netbsd${UNAME_RELEASE} exit 0 ;; atari*:OpenBSD:*:*) echo m68k-atari-openbsd${UNAME_RELEASE} exit 0 ;; sun3*:NetBSD:*:*) echo m68k-sun-netbsd${UNAME_RELEASE} exit 0 ;; sun3*:OpenBSD:*:*) echo m68k-sun-openbsd${UNAME_RELEASE} exit 0 ;; mac68k:NetBSD:*:*) echo m68k-apple-netbsd${UNAME_RELEASE} exit 0 ;; mac68k:OpenBSD:*:*) echo m68k-apple-openbsd${UNAME_RELEASE} exit 0 ;; powerpc:machten:*:*) echo powerpc-apple-machten${UNAME_RELEASE} exit 0 ;; RISC*:Mach:*:*) echo mips-dec-mach_bsd4.3 exit 0 ;; RISC*:ULTRIX:*:*) echo mips-dec-ultrix${UNAME_RELEASE} exit 0 ;; VAX*:ULTRIX*:*:*) echo vax-dec-ultrix${UNAME_RELEASE} exit 0 ;; mips:*:*:UMIPS | mips:*:*:RISCos) sed 's/^ //' << EOF >dummy.c int main (argc, argv) int argc; char **argv; { #if defined (host_mips) && defined (MIPSEB) #if defined (SYSTYPE_SYSV) printf ("mips-mips-riscos%ssysv\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_SVR4) printf ("mips-mips-riscos%ssvr4\n", argv[1]); exit (0); #endif #if defined (SYSTYPE_BSD43) || defined(SYSTYPE_BSD) printf ("mips-mips-riscos%sbsd\n", argv[1]); exit (0); #endif #endif exit (-1); } EOF ${CC-cc} dummy.c -o dummy \ && ./dummy `echo "${UNAME_RELEASE}" | sed -n 's/\([0-9]*\).*/\1/p'` \ && rm dummy.c dummy && exit 0 rm -f dummy.c dummy echo mips-mips-riscos${UNAME_RELEASE} exit 0 ;; Night_Hawk:Power_UNIX:*:*) echo powerpc-harris-powerunix exit 0 ;; m88k:CX/UX:7*:*) echo m88k-harris-cxux7 exit 0 ;; m88k:*:4*:R4*) echo m88k-motorola-sysv4 exit 0 ;; m88k:*:3*:R3*) echo m88k-motorola-sysv3 exit 0 ;; AViiON:dgux:*:*) # DG/UX returns AViiON for all architectures UNAME_PROCESSOR=`/usr/bin/uname -p` if [ $UNAME_PROCESSOR = mc88100 -o $UNAME_PROCESSOR = mc88110 ] ; then if [ ${TARGET_BINARY_INTERFACE}x = m88kdguxelfx \ -o ${TARGET_BINARY_INTERFACE}x = x ] ; then echo m88k-dg-dgux${UNAME_RELEASE} else echo m88k-dg-dguxbcs${UNAME_RELEASE} fi else echo i586-dg-dgux${UNAME_RELEASE} fi exit 0 ;; M88*:DolphinOS:*:*) # DolphinOS (SVR3) echo m88k-dolphin-sysv3 exit 0 ;; M88*:*:R3*:*) # Delta 88k system running SVR3 echo m88k-motorola-sysv3 exit 0 ;; XD88*:*:*:*) # Tektronix XD88 system running UTekV (SVR3) echo m88k-tektronix-sysv3 exit 0 ;; Tek43[0-9][0-9]:UTek:*:*) # Tektronix 4300 system running UTek (BSD) echo m68k-tektronix-bsd exit 0 ;; *:IRIX*:*:*) echo mips-sgi-irix`echo ${UNAME_RELEASE}|sed -e 's/-/_/g'` exit 0 ;; ????????:AIX?:[12].1:2) # AIX 2.2.1 or AIX 2.1.1 is RT/PC AIX. echo romp-ibm-aix # uname -m gives an 8 hex-code CPU id exit 0 ;; # Note that: echo "'`uname -s`'" gives 'AIX ' i?86:AIX:*:*) echo i386-ibm-aix exit 0 ;; *:AIX:2:3) if grep bos325 /usr/include/stdio.h >/dev/null 2>&1; then sed 's/^ //' << EOF >dummy.c #include main() { if (!__power_pc()) exit(1); puts("powerpc-ibm-aix3.2.5"); exit(0); } EOF ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 rm -f dummy.c dummy echo rs6000-ibm-aix3.2.5 elif grep bos324 /usr/include/stdio.h >/dev/null 2>&1; then echo rs6000-ibm-aix3.2.4 else echo rs6000-ibm-aix3.2 fi exit 0 ;; *:AIX:*:4) if /usr/sbin/lsattr -EHl proc0 | grep POWER >/dev/null 2>&1; then IBM_ARCH=rs6000 else IBM_ARCH=powerpc fi if [ -x /usr/bin/oslevel ] ; then IBM_REV=`/usr/bin/oslevel` else IBM_REV=4.${UNAME_RELEASE} fi echo ${IBM_ARCH}-ibm-aix${IBM_REV} exit 0 ;; *:AIX:*:*) echo rs6000-ibm-aix exit 0 ;; ibmrt:4.4BSD:*|romp-ibm:BSD:*) echo romp-ibm-bsd4.4 exit 0 ;; ibmrt:*BSD:*|romp-ibm:BSD:*) # covers RT/PC NetBSD and echo romp-ibm-bsd${UNAME_RELEASE} # 4.3 with uname added to exit 0 ;; # report: romp-ibm BSD 4.3 *:BOSX:*:*) echo rs6000-bull-bosx exit 0 ;; DPX/2?00:B.O.S.:*:*) echo m68k-bull-sysv3 exit 0 ;; 9000/[34]??:4.3bsd:1.*:*) echo m68k-hp-bsd exit 0 ;; hp300:4.4BSD:*:* | 9000/[34]??:4.3bsd:2.*:*) echo m68k-hp-bsd4.4 exit 0 ;; 9000/[3478]??:HP-UX:*:*) case "${UNAME_MACHINE}" in 9000/31? ) HP_ARCH=m68000 ;; 9000/[34]?? ) HP_ARCH=m68k ;; 9000/7?? | 9000/8?[1679] ) HP_ARCH=hppa1.1 ;; 9000/8?? ) HP_ARCH=hppa1.0 ;; esac HPUX_REV=`echo ${UNAME_RELEASE}|sed -e 's/[^.]*.[0B]*//'` echo ${HP_ARCH}-hp-hpux${HPUX_REV} exit 0 ;; 3050*:HI-UX:*:*) sed 's/^ //' << EOF >dummy.c #include int main () { long cpu = sysconf (_SC_CPU_VERSION); /* The order matters, because CPU_IS_HP_MC68K erroneously returns true for CPU_PA_RISC1_0. CPU_IS_PA_RISC returns correct results, however. */ if (CPU_IS_PA_RISC (cpu)) { switch (cpu) { case CPU_PA_RISC1_0: puts ("hppa1.0-hitachi-hiuxwe2"); break; case CPU_PA_RISC1_1: puts ("hppa1.1-hitachi-hiuxwe2"); break; case CPU_PA_RISC2_0: puts ("hppa2.0-hitachi-hiuxwe2"); break; default: puts ("hppa-hitachi-hiuxwe2"); break; } } else if (CPU_IS_HP_MC68K (cpu)) puts ("m68k-hitachi-hiuxwe2"); else puts ("unknown-hitachi-hiuxwe2"); exit (0); } EOF ${CC-cc} dummy.c -o dummy && ./dummy && rm dummy.c dummy && exit 0 rm -f dummy.c dummy echo unknown-hitachi-hiuxwe2 exit 0 ;; 9000/7??:4.3bsd:*:* | 9000/8?[79]:4.3bsd:*:* ) echo hppa1.1-hp-bsd exit 0 ;; 9000/8??:4.3bsd:*:*) echo hppa1.0-hp-bsd exit 0 ;; hp7??:OSF1:*:* | hp8?[79]:OSF1:*:* ) echo hppa1.1-hp-osf exit 0 ;; hp8??:OSF1:*:*) echo hppa1.0-hp-osf exit 0 ;; i?86:OSF1:*:*) if [ -x /usr/sbin/sysversion ] ; then echo ${UNAME_MACHINE}-unknown-osf1mk else echo ${UNAME_MACHINE}-unknown-osf1 fi exit 0 ;; parisc*:Lites*:*:*) echo hppa1.1-hp-lites exit 0 ;; C1*:ConvexOS:*:* | convex:ConvexOS:C1*:*) echo c1-convex-bsd exit 0 ;; C2*:ConvexOS:*:* | convex:ConvexOS:C2*:*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; C34*:ConvexOS:*:* | convex:ConvexOS:C34*:*) echo c34-convex-bsd exit 0 ;; C38*:ConvexOS:*:* | convex:ConvexOS:C38*:*) echo c38-convex-bsd exit 0 ;; C4*:ConvexOS:*:* | convex:ConvexOS:C4*:*) echo c4-convex-bsd exit 0 ;; CRAY*X-MP:*:*:*) echo xmp-cray-unicos exit 0 ;; CRAY*Y-MP:*:*:*) echo ymp-cray-unicos${UNAME_RELEASE} exit 0 ;; CRAY*[A-Z]90:*:*:*) echo ${UNAME_MACHINE}-cray-unicos${UNAME_RELEASE} \ | sed -e 's/CRAY.*\([A-Z]90\)/\1/' \ -e y/ABCDEFGHIJKLMNOPQRSTUVWXYZ/abcdefghijklmnopqrstuvwxyz/ exit 0 ;; CRAY*TS:*:*:*) echo t90-cray-unicos${UNAME_RELEASE} exit 0 ;; CRAY-2:*:*:*) echo cray2-cray-unicos exit 0 ;; F300:UNIX_System_V:*:*) FUJITSU_SYS=`uname -p | tr [A-Z] [a-z] | sed -e 's/\///'` FUJITSU_REL=`echo ${UNAME_RELEASE} | sed -e 's/ /_/'` echo "f300-fujitsu-${FUJITSU_SYS}${FUJITSU_REL}" exit 0 ;; F301:UNIX_System_V:*:*) echo f301-fujitsu-uxpv`echo $UNAME_RELEASE | sed 's/ .*//'` exit 0 ;; hp3[0-9][05]:NetBSD:*:*) echo m68k-hp-netbsd${UNAME_RELEASE} exit 0 ;; hp3[0-9][05]:OpenBSD:*:*) echo m68k-hp-openbsd${UNAME_RELEASE} exit 0 ;; i?86:BSD/386:*:* | *:BSD/OS:*:*) echo ${UNAME_MACHINE}-pc-bsdi${UNAME_RELEASE} exit 0 ;; *:FreeBSD:*:*) echo ${UNAME_MACHINE}-unknown-freebsd`echo ${UNAME_RELEASE}|sed -e 's/[-(].*//'` exit 0 ;; *:NetBSD:*:*) echo ${UNAME_MACHINE}-unknown-netbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` exit 0 ;; *:OpenBSD:*:*) echo ${UNAME_MACHINE}-unknown-openbsd`echo ${UNAME_RELEASE}|sed -e 's/[-_].*/\./'` exit 0 ;; i*:CYGWIN*:*) echo i386-pc-cygwin32 exit 0 ;; p*:CYGWIN*:*) echo powerpcle-unknown-cygwin32 exit 0 ;; prep*:SunOS:5.*:*) echo powerpcle-unknown-solaris2`echo ${UNAME_RELEASE}|sed -e 's/[^.]*//'` exit 0 ;; *:GNU:*:*) echo `echo ${UNAME_MACHINE}|sed -e 's,/.*$,,'`-unknown-gnu`echo ${UNAME_RELEASE}|sed -e 's,/.*$,,'` exit 0 ;; *:Linux:*:*) # The BFD linker knows what the default object file format is, so # first see if it will tell us. ld_help_string=`ld --help 2>&1` if echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: elf_i.86"; then echo "${UNAME_MACHINE}-pc-linux-gnu" ; exit 0 elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: i.86linux"; then echo "${UNAME_MACHINE}-pc-linux-gnuaout" ; exit 0 elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: i.86coff"; then echo "${UNAME_MACHINE}-pc-linux-gnucoff" ; exit 0 elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: m68kelf"; then echo "${UNAME_MACHINE}-unknown-linux-gnu" ; exit 0 elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: m68klinux"; then echo "${UNAME_MACHINE}-unknown-linux-gnuaout" ; exit 0 elif echo "$ld_help_string" | grep >/dev/null 2>&1 "supported emulations: elf32ppc"; then echo "powerpc-unknown-linux-gnu" ; exit 0 elif test "${UNAME_MACHINE}" = "alpha" ; then echo alpha-unknown-linux-gnu ; exit 0 elif test "${UNAME_MACHINE}" = "sparc" ; then echo sparc-unknown-linux-gnu ; exit 0 else # Either a pre-BFD a.out linker (linux-gnuoldld) or one that does not give us # useful --help. Gcc wants to distinguish between linux-gnuoldld and linux-gnuaout. test ! -d /usr/lib/ldscripts/. \ && echo "${UNAME_MACHINE}-pc-linux-gnuoldld" && exit 0 # Determine whether the default compiler is a.out or elf cat >dummy.c </dev/null && ./dummy "${UNAME_MACHINE}" && rm dummy.c dummy && exit 0 rm -f dummy.c dummy fi ;; # ptx 4.0 does uname -s correctly, with DYNIX/ptx in there. earlier versions # are messed up and put the nodename in both sysname and nodename. i?86:DYNIX/ptx:4*:*) echo i386-sequent-sysv4 exit 0 ;; i?86:*:4.*:* | i?86:SYSTEM_V:4.*:*) if grep Novell /usr/include/link.h >/dev/null 2>/dev/null; then echo ${UNAME_MACHINE}-univel-sysv${UNAME_RELEASE} else echo ${UNAME_MACHINE}-pc-sysv${UNAME_RELEASE} fi exit 0 ;; i?86:*:3.2:*) if test -f /usr/options/cb.name; then UNAME_REL=`sed -n 's/.*Version //p' /dev/null >/dev/null ; then UNAME_REL=`(/bin/uname -X|egrep Release|sed -e 's/.*= //')` (/bin/uname -X|egrep i80486 >/dev/null) && UNAME_MACHINE=i486 (/bin/uname -X|egrep '^Machine.*Pentium' >/dev/null) \ && UNAME_MACHINE=i586 echo ${UNAME_MACHINE}-pc-sco$UNAME_REL else echo ${UNAME_MACHINE}-pc-sysv32 fi exit 0 ;; Intel:Mach:3*:*) echo i386-pc-mach3 exit 0 ;; paragon:*:*:*) echo i860-intel-osf1 exit 0 ;; i860:*:4.*:*) # i860-SVR4 if grep Stardent /usr/include/sys/uadmin.h >/dev/null 2>&1 ; then echo i860-stardent-sysv${UNAME_RELEASE} # Stardent Vistra i860-SVR4 else # Add other i860-SVR4 vendors below as they are discovered. echo i860-unknown-sysv${UNAME_RELEASE} # Unknown i860-SVR4 fi exit 0 ;; mini*:CTIX:SYS*5:*) # "miniframe" echo m68010-convergent-sysv exit 0 ;; M68*:*:R3V[567]*:*) test -r /sysV68 && echo 'm68k-motorola-sysv' && exit 0 ;; 3[34]??:*:4.0:3.0 | 3[34]??,*:*:4.0:3.0 | 4850:*:4.0:3.0) OS_REL='' test -r /etc/.relid \ && OS_REL=.`sed -n 's/[^ ]* [^ ]* \([0-9][0-9]\).*/\1/p' < /etc/.relid` /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4.3${OS_REL} && exit 0 /bin/uname -p 2>/dev/null | /bin/grep entium >/dev/null \ && echo i586-ncr-sysv4.3${OS_REL} && exit 0 ;; 3[34]??:*:4.0:* | 3[34]??,*:*:4.0:*) /bin/uname -p 2>/dev/null | grep 86 >/dev/null \ && echo i486-ncr-sysv4 && exit 0 ;; m68*:LynxOS:2.*:*) echo m68k-unknown-lynxos${UNAME_RELEASE} exit 0 ;; mc68030:UNIX_System_V:4.*:*) echo m68k-atari-sysv4 exit 0 ;; i?86:LynxOS:2.*:*) echo i386-unknown-lynxos${UNAME_RELEASE} exit 0 ;; TSUNAMI:LynxOS:2.*:*) echo sparc-unknown-lynxos${UNAME_RELEASE} exit 0 ;; rs6000:LynxOS:2.*:* | PowerPC:LynxOS:2.*:*) echo rs6000-unknown-lynxos${UNAME_RELEASE} exit 0 ;; SM[BE]S:UNIX_SV:*:*) echo mips-dde-sysv${UNAME_RELEASE} exit 0 ;; RM*:SINIX-*:*:*) echo mips-sni-sysv4 exit 0 ;; *:SINIX-*:*:*) if uname -p 2>/dev/null >/dev/null ; then UNAME_MACHINE=`(uname -p) 2>/dev/null` echo ${UNAME_MACHINE}-sni-sysv4 else echo ns32k-sni-sysv fi exit 0 ;; *:UNIX_System_V:4*:FTX*) # From Gerald Hewes . # How about differentiating between stratus architectures? -djm echo hppa1.1-stratus-sysv4 exit 0 ;; *:*:*:FTX*) # From seanf@swdc.stratus.com. echo i860-stratus-sysv4 exit 0 ;; mc68*:A/UX:*:*) echo m68k-apple-aux${UNAME_RELEASE} exit 0 ;; R3000:*System_V*:*:* | R4000:UNIX_SYSV:*:*) if [ -d /usr/nec ]; then echo mips-nec-sysv${UNAME_RELEASE} else echo mips-unknown-sysv${UNAME_RELEASE} fi exit 0 ;; PENTIUM:CPunix:4.0*:*) # Unisys `ClearPath HMP IX 4000' SVR4/MP effort # says echo i586-unisys-sysv4 exit 0 ;; esac #echo '(No uname command or uname output not recognized.)' 1>&2 #echo "${UNAME_MACHINE}:${UNAME_SYSTEM}:${UNAME_RELEASE}:${UNAME_VERSION}" 1>&2 cat >dummy.c < # include #endif main () { #if defined (sony) #if defined (MIPSEB) /* BFD wants "bsd" instead of "newsos". Perhaps BFD should be changed, I don't know.... */ printf ("mips-sony-bsd\n"); exit (0); #else #include printf ("m68k-sony-newsos%s\n", #ifdef NEWSOS4 "4" #else "" #endif ); exit (0); #endif #endif #if defined (__arm) && defined (__acorn) && defined (__unix) printf ("arm-acorn-riscix"); exit (0); #endif #if defined (hp300) && !defined (hpux) printf ("m68k-hp-bsd\n"); exit (0); #endif #if defined (NeXT) #if !defined (__ARCHITECTURE__) #define __ARCHITECTURE__ "m68k" #endif int version; version=`(hostinfo | sed -n 's/.*NeXT Mach \([0-9]*\).*/\1/p') 2>/dev/null`; printf ("%s-next-nextstep%d\n", __ARCHITECTURE__, version); exit (0); #endif #if defined (MULTIMAX) || defined (n16) #if defined (UMAXV) printf ("ns32k-encore-sysv\n"); exit (0); #else #if defined (CMU) printf ("ns32k-encore-mach\n"); exit (0); #else printf ("ns32k-encore-bsd\n"); exit (0); #endif #endif #endif #if defined (__386BSD__) printf ("i386-pc-bsd\n"); exit (0); #endif #if defined (sequent) #if defined (i386) printf ("i386-sequent-dynix\n"); exit (0); #endif #if defined (ns32000) printf ("ns32k-sequent-dynix\n"); exit (0); #endif #endif #if defined (_SEQUENT_) struct utsname un; uname(&un); if (strncmp(un.version, "V2", 2) == 0) { printf ("i386-sequent-ptx2\n"); exit (0); } if (strncmp(un.version, "V1", 2) == 0) { /* XXX is V1 correct? */ printf ("i386-sequent-ptx1\n"); exit (0); } printf ("i386-sequent-ptx\n"); exit (0); #endif #if defined (vax) #if !defined (ultrix) printf ("vax-dec-bsd\n"); exit (0); #else printf ("vax-dec-ultrix\n"); exit (0); #endif #endif #if defined (alliant) && defined (i860) printf ("i860-alliant-bsd\n"); exit (0); #endif exit (1); } EOF ${CC-cc} dummy.c -o dummy 2>/dev/null && ./dummy && rm dummy.c dummy && exit 0 rm -f dummy.c dummy # Apollos put the system type in the environment. test -d /usr/apollo && { echo ${ISP}-apollo-${SYSTYPE}; exit 0; } # Convex versions that predate uname can use getsysinfo(1) if [ -x /usr/convex/getsysinfo ] then case `getsysinfo -f cpu_type` in c1*) echo c1-convex-bsd exit 0 ;; c2*) if getsysinfo -f scalar_acc then echo c32-convex-bsd else echo c2-convex-bsd fi exit 0 ;; c34*) echo c34-convex-bsd exit 0 ;; c38*) echo c38-convex-bsd exit 0 ;; c4*) echo c4-convex-bsd exit 0 ;; esac fi #echo '(Unable to guess system type)' 1>&2 exit 1 arj-3.10.22/gnu/config.h.in 666 0 0 514 10040204002 11417 0ustar /* Consider renaming this one into c_defs.h.in */ #undef COMMERCIAL #undef LIBC #undef NP_SFX #undef ELF_EXECUTABLES #undef HAVE_MKDTEMP #undef HAVE_FCLOSEALL #undef HAVE_SETPRIORITY #undef HAVE_STRCASECMP #undef HAVE_STRUPR #undef HAVE_STRLWR #undef USE_COLORS #undef WORDS_BIGENDIAN #undef ALIGN_POINTERS #undef TOLERANT_FNMATCH arj-3.10.22/gnu/config.sub 666 0 0 46135 7651527060 11437 0ustar #! /bin/sh # Configuration validation subroutine script, version 1.1. # Copyright (C) 1991, 92, 93, 94, 95, 1996 Free Software Foundation, Inc. # This file is (in principle) common to ALL GNU software. # The presence of a machine in this file suggests that SOME GNU software # can handle that machine. It does not imply ALL GNU software can. # # This file is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place - Suite 330, # Boston, MA 02111-1307, USA. # As a special exception to the GNU General Public License, if you # distribute this file as part of a program that contains a # configuration script generated by Autoconf, you may include it under # the same distribution terms that you use for the rest of that program. # Configuration subroutine to validate and canonicalize a configuration type. # Supply the specified configuration type as an argument. # If it is invalid, we print an error message on stderr and exit with code 1. # Otherwise, we print the canonical config type on stdout and succeed. # This file is supposed to be the same for all GNU packages # and recognize all the CPU types, system types and aliases # that are meaningful with *any* GNU software. # Each package is responsible for reporting which valid configurations # it does not support. The user should be able to distinguish # a failure to support a valid configuration from a meaningless # configuration. # The goal of this file is to map all the various variations of a given # machine specification into a single specification in the form: # CPU_TYPE-MANUFACTURER-OPERATING_SYSTEM # or in some cases, the newer four-part form: # CPU_TYPE-MANUFACTURER-KERNEL-OPERATING_SYSTEM # It is wrong to echo any other type of specification. if [ x$1 = x ] then echo Configuration name missing. 1>&2 echo "Usage: $0 CPU-MFR-OPSYS" 1>&2 echo "or $0 ALIAS" 1>&2 echo where ALIAS is a recognized configuration type. 1>&2 exit 1 fi # First pass through any local machine types. case $1 in *local*) echo $1 exit 0 ;; *) ;; esac # Separate what the user gave into CPU-COMPANY and OS or KERNEL-OS (if any). # Here we must recognize all the valid KERNEL-OS combinations. maybe_os=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\2/'` case $maybe_os in nto-qnx* | linux-gnu*) os=-$maybe_os basic_machine=`echo $1 | sed 's/^\(.*\)-\([^-]*-[^-]*\)$/\1/'` ;; *) basic_machine=`echo $1 | sed 's/-[^-]*$//'` if [ $basic_machine != $1 ] then os=`echo $1 | sed 's/.*-/-/'` else os=; fi ;; esac ### Let's recognize common machines as not being operating systems so ### that things like config.sub decstation-3100 work. We also ### recognize some manufacturers as not being operating systems, so we ### can provide default operating systems below. case $os in -sun*os*) # Prevent following clause from handling this invalid input. ;; -dec* | -mips* | -sequent* | -encore* | -pc532* | -sgi* | -sony* | \ -att* | -7300* | -3300* | -delta* | -motorola* | -sun[234]* | \ -unicom* | -ibm* | -next | -hp | -isi* | -apollo | -altos* | \ -convergent* | -ncr* | -news | -32* | -3600* | -3100* | -hitachi* |\ -c[123]* | -convex* | -sun | -crds | -omron* | -dg | -ultra | -tti* | \ -harris | -dolphin | -highlevel | -gould | -cbm | -ns | -masscomp | \ -apple) os= basic_machine=$1 ;; -hiux*) os=-hiuxwe2 ;; -sco5) os=sco3.2v5 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco4) os=-sco3.2v4 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2.[4-9]*) os=`echo $os | sed -e 's/sco3.2./sco3.2v/'` basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco3.2v[4-9]*) # Don't forget version if it is 3.2v4 or newer. basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -sco*) os=-sco3.2v2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -isc) os=-isc2.2 basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -clix*) basic_machine=clipper-intergraph ;; -isc*) basic_machine=`echo $1 | sed -e 's/86-.*/86-pc/'` ;; -lynx*) os=-lynxos ;; -ptx*) basic_machine=`echo $1 | sed -e 's/86-.*/86-sequent/'` ;; -windowsnt*) os=`echo $os | sed -e 's/windowsnt/winnt/'` ;; -psos*) os=-psos ;; esac # Decode aliases for certain CPU-COMPANY combinations. case $basic_machine in # Recognize the basic CPU types without company name. # Some are omitted here because they have special meanings below. tahoe | i860 | m68k | m68000 | m88k | ns32k | arm \ | arme[lb] | pyramid \ | tron | a29k | 580 | i960 | h8300 | hppa | hppa1.0 | hppa1.1 \ | alpha | we32k | ns16k | clipper | i370 | sh \ | powerpc | powerpcle | 1750a | dsp16xx | mips64 | mipsel \ | pdp11 | mips64el | mips64orion | mips64orionel \ | sparc | sparclet | sparclite | sparc64) basic_machine=$basic_machine-unknown ;; # We use `pc' rather than `unknown' # because (1) that's what they normally are, and # (2) the word "unknown" tends to confuse beginning users. i[3456]86) basic_machine=$basic_machine-pc ;; # Object if more than one company name word. *-*-*) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; # Recognize the basic CPU types with company name. vax-* | tahoe-* | i[3456]86-* | i860-* | m68k-* | m68000-* | m88k-* \ | sparc-* | ns32k-* | fx80-* | arm-* | c[123]* \ | mips-* | pyramid-* | tron-* | a29k-* | romp-* | rs6000-* | power-* \ | none-* | 580-* | cray2-* | h8300-* | i960-* | xmp-* | ymp-* \ | hppa-* | hppa1.0-* | hppa1.1-* | alpha-* | we32k-* | cydra-* | ns16k-* \ | pn-* | np1-* | xps100-* | clipper-* | orion-* | sparclite-* \ | pdp11-* | sh-* | powerpc-* | powerpcle-* | sparc64-* | mips64-* | mipsel-* \ | mips64el-* | mips64orion-* | mips64orionel-* | f301-*) ;; # Recognize the various machine names and aliases which stand # for a CPU type and a company and sometimes even an OS. 3b1 | 7300 | 7300-att | att-7300 | pc7300 | safari | unixpc) basic_machine=m68000-att ;; 3b*) basic_machine=we32k-att ;; alliant | fx80) basic_machine=fx80-alliant ;; altos | altos3068) basic_machine=m68k-altos ;; am29k) basic_machine=a29k-none os=-bsd ;; amdahl) basic_machine=580-amdahl os=-sysv ;; amiga | amiga-*) basic_machine=m68k-cbm ;; amigados) basic_machine=m68k-cbm os=-amigados ;; amigaunix | amix) basic_machine=m68k-cbm os=-sysv4 ;; apollo68) basic_machine=m68k-apollo os=-sysv ;; aux) basic_machine=m68k-apple os=-aux ;; balance) basic_machine=ns32k-sequent os=-dynix ;; convex-c1) basic_machine=c1-convex os=-bsd ;; convex-c2) basic_machine=c2-convex os=-bsd ;; convex-c32) basic_machine=c32-convex os=-bsd ;; convex-c34) basic_machine=c34-convex os=-bsd ;; convex-c38) basic_machine=c38-convex os=-bsd ;; cray | ymp) basic_machine=ymp-cray os=-unicos ;; cray2) basic_machine=cray2-cray os=-unicos ;; [ctj]90-cray) basic_machine=c90-cray os=-unicos ;; crds | unos) basic_machine=m68k-crds ;; da30 | da30-*) basic_machine=m68k-da30 ;; decstation | decstation-3100 | pmax | pmax-* | pmin | dec3100 | decstatn) basic_machine=mips-dec ;; delta | 3300 | motorola-3300 | motorola-delta \ | 3300-motorola | delta-motorola) basic_machine=m68k-motorola ;; delta88) basic_machine=m88k-motorola os=-sysv3 ;; dpx20 | dpx20-*) basic_machine=rs6000-bull os=-bosx ;; dpx2* | dpx2*-bull) basic_machine=m68k-bull os=-sysv3 ;; ebmon29k) basic_machine=a29k-amd os=-ebmon ;; elxsi) basic_machine=elxsi-elxsi os=-bsd ;; encore | umax | mmax) basic_machine=ns32k-encore ;; fx2800) basic_machine=i860-alliant ;; genix) basic_machine=ns32k-ns ;; gmicro) basic_machine=tron-gmicro os=-sysv ;; h3050r* | hiux*) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; h8300hms) basic_machine=h8300-hitachi os=-hms ;; harris) basic_machine=m88k-harris os=-sysv3 ;; hp300-*) basic_machine=m68k-hp ;; hp300bsd) basic_machine=m68k-hp os=-bsd ;; hp300hpux) basic_machine=m68k-hp os=-hpux ;; hp9k2[0-9][0-9] | hp9k31[0-9]) basic_machine=m68000-hp ;; hp9k3[2-9][0-9]) basic_machine=m68k-hp ;; hp9k7[0-9][0-9] | hp7[0-9][0-9] | hp9k8[0-9]7 | hp8[0-9]7) basic_machine=hppa1.1-hp ;; hp9k8[0-9][0-9] | hp8[0-9][0-9]) basic_machine=hppa1.0-hp ;; hppa-next) os=-nextstep3 ;; i370-ibm* | ibm*) basic_machine=i370-ibm os=-mvs ;; # I'm not sure what "Sysv32" means. Should this be sysv3.2? i[3456]86v32) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv32 ;; i[3456]86v4*) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv4 ;; i[3456]86v) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-sysv ;; i[3456]86sol2) basic_machine=`echo $1 | sed -e 's/86.*/86-pc/'` os=-solaris2 ;; iris | iris4d) basic_machine=mips-sgi case $os in -irix*) ;; *) os=-irix4 ;; esac ;; isi68 | isi) basic_machine=m68k-isi os=-sysv ;; m88k-omron*) basic_machine=m88k-omron ;; magnum | m3230) basic_machine=mips-mips os=-sysv ;; merlin) basic_machine=ns32k-utek os=-sysv ;; miniframe) basic_machine=m68000-convergent ;; mips3*-*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'` ;; mips3*) basic_machine=`echo $basic_machine | sed -e 's/mips3/mips64/'`-unknown ;; ncr3000) basic_machine=i486-ncr os=-sysv4 ;; news | news700 | news800 | news900) basic_machine=m68k-sony os=-newsos ;; news1000) basic_machine=m68030-sony os=-newsos ;; news-3600 | risc-news) basic_machine=mips-sony os=-newsos ;; next | m*-next ) basic_machine=m68k-next case $os in -nextstep* ) ;; -ns2*) os=-nextstep2 ;; *) os=-nextstep3 ;; esac ;; nh3000) basic_machine=m68k-harris os=-cxux ;; nh[45]000) basic_machine=m88k-harris os=-cxux ;; nindy960) basic_machine=i960-intel os=-nindy ;; np1) basic_machine=np1-gould ;; pa-hitachi) basic_machine=hppa1.1-hitachi os=-hiuxwe2 ;; paragon) basic_machine=i860-intel os=-osf ;; pbd) basic_machine=sparc-tti ;; pbb) basic_machine=m68k-tti ;; pc532 | pc532-*) basic_machine=ns32k-pc532 ;; pentium | p5) basic_machine=i586-intel ;; pentiumpro | p6) basic_machine=i686-intel ;; pentium-* | p5-*) basic_machine=i586-`echo $basic_machine | sed 's/^[^-]*-//'` ;; pentiumpro-* | p6-*) basic_machine=i686-`echo $basic_machine | sed 's/^[^-]*-//'` ;; k5) # We don't have specific support for AMD's K5 yet, so just call it a Pentium basic_machine=i586-amd ;; nexen) # We don't have specific support for Nexgen yet, so just call it a Pentium basic_machine=i586-nexgen ;; pn) basic_machine=pn-gould ;; power) basic_machine=rs6000-ibm ;; ppc) basic_machine=powerpc-unknown ;; ppc-*) basic_machine=powerpc-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ppcle | powerpclittle | ppc-le | powerpc-little) basic_machine=powerpcle-unknown ;; ppcle-* | powerpclittle-*) basic_machine=powerpcle-`echo $basic_machine | sed 's/^[^-]*-//'` ;; ps2) basic_machine=i386-ibm ;; rm[46]00) basic_machine=mips-siemens ;; rtpc | rtpc-*) basic_machine=romp-ibm ;; sequent) basic_machine=i386-sequent ;; sh) basic_machine=sh-hitachi os=-hms ;; sps7) basic_machine=m68k-bull os=-sysv2 ;; spur) basic_machine=spur-unknown ;; sun2) basic_machine=m68000-sun ;; sun2os3) basic_machine=m68000-sun os=-sunos3 ;; sun2os4) basic_machine=m68000-sun os=-sunos4 ;; sun3os3) basic_machine=m68k-sun os=-sunos3 ;; sun3os4) basic_machine=m68k-sun os=-sunos4 ;; sun4os3) basic_machine=sparc-sun os=-sunos3 ;; sun4os4) basic_machine=sparc-sun os=-sunos4 ;; sun4sol2) basic_machine=sparc-sun os=-solaris2 ;; sun3 | sun3-*) basic_machine=m68k-sun ;; sun4) basic_machine=sparc-sun ;; sun386 | sun386i | roadrunner) basic_machine=i386-sun ;; symmetry) basic_machine=i386-sequent os=-dynix ;; tower | tower-32) basic_machine=m68k-ncr ;; udi29k) basic_machine=a29k-amd os=-udi ;; ultra3) basic_machine=a29k-nyu os=-sym1 ;; vaxv) basic_machine=vax-dec os=-sysv ;; vms) basic_machine=vax-dec os=-vms ;; vpp*|vx|vx-*) basic_machine=f301-fujitsu ;; vxworks960) basic_machine=i960-wrs os=-vxworks ;; vxworks68) basic_machine=m68k-wrs os=-vxworks ;; vxworks29k) basic_machine=a29k-wrs os=-vxworks ;; xmp) basic_machine=xmp-cray os=-unicos ;; xps | xps100) basic_machine=xps100-honeywell ;; none) basic_machine=none-none os=-none ;; # Here we handle the default manufacturer of certain CPU types. It is in # some cases the only manufacturer, in others, it is the most popular. mips) basic_machine=mips-mips ;; romp) basic_machine=romp-ibm ;; rs6000) basic_machine=rs6000-ibm ;; vax) basic_machine=vax-dec ;; pdp11) basic_machine=pdp11-dec ;; we32k) basic_machine=we32k-att ;; sparc) basic_machine=sparc-sun ;; cydra) basic_machine=cydra-cydrome ;; orion) basic_machine=orion-highlevel ;; orion105) basic_machine=clipper-highlevel ;; *) echo Invalid configuration \`$1\': machine \`$basic_machine\' not recognized 1>&2 exit 1 ;; esac # Here we canonicalize certain aliases for manufacturers. case $basic_machine in *-digital*) basic_machine=`echo $basic_machine | sed 's/digital.*/dec/'` ;; *-commodore*) basic_machine=`echo $basic_machine | sed 's/commodore.*/cbm/'` ;; *) ;; esac # Decode manufacturer-specific aliases for certain operating systems. if [ x"$os" != x"" ] then case $os in # First match some system type aliases # that might get confused with valid system types. # -solaris* is a basic system type, with this one exception. -solaris1 | -solaris1.*) os=`echo $os | sed -e 's|solaris1|sunos4|'` ;; -solaris) os=-solaris2 ;; -unixware* | svr4*) os=-sysv4 ;; -gnu/linux*) os=`echo $os | sed -e 's|gnu/linux|linux-gnu|'` ;; -os2_emx) ;; # First accept the basic system types. # The portable systems comes first. # Each alternative MUST END IN A *, to match a version number. # -sysv* is not here because it comes later, after sysvr4. -gnu* | -bsd* | -mach* | -minix* | -genix* | -ultrix* | -irix* \ | -*vms* | -sco* | -esix* | -isc* | -aix* | -sunos | -sunos[34]*\ | -hpux* | -unos* | -osf* | -luna* | -dgux* | -solaris* | -sym* \ | -amigados* | -msdos* | -newsos* | -unicos* | -aof* | -aos* \ | -nindy* | -vxsim* | -vxworks* | -ebmon* | -hms* | -mvs* \ | -clix* | -riscos* | -uniplus* | -iris* | -rtu* | -xenix* \ | -hiux* | -386bsd* | -netbsd* | -openbsd* | -freebsd* | -riscix* \ | -lynxos* | -bosx* | -nextstep* | -cxux* | -aout* | -elf* \ | -ptx* | -coff* | -ecoff* | -winnt* | -domain* | -vsta* \ | -udi* | -eabi* | -lites* | -ieee* | -go32* | -aux* \ | -cygwin32* | -pe* | -psos* | -moss* | -proelf* | -rtems* \ | -linux-gnu* | -uxpv*) # Remember, each alternative MUST END IN *, to match a version number. ;; -qnx*) case $basic_machine in x86-* | i[34567]86-*) ;; *) os=-nto$os ;; esac ;; -nto*) os=-nto-qnx ;; -linux*) os=`echo $os | sed -e 's|linux|linux-gnu|'` ;; -sunos5*) os=`echo $os | sed -e 's|sunos5|solaris2|'` ;; -sunos6*) os=`echo $os | sed -e 's|sunos6|solaris3|'` ;; -osfrose*) os=-osfrose ;; -osf*) os=-osf ;; -utek*) os=-bsd ;; -dynix*) os=-bsd ;; -acis*) os=-aos ;; -ctix* | -uts*) os=-sysv ;; -ns2 ) os=-nextstep2 ;; # Preserve the version number of sinix5. -sinix5.*) os=`echo $os | sed -e 's|sinix|sysv|'` ;; -sinix*) os=-sysv4 ;; -triton*) os=-sysv3 ;; -oss*) os=-sysv3 ;; -svr4) os=-sysv4 ;; -svr3) os=-sysv3 ;; -sysvr4) os=-sysv4 ;; # This must come after -sysvr4. -sysv*) ;; -xenix) os=-xenix ;; -none) ;; *) # Get rid of the `-' at the beginning of $os. os=`echo $os | sed 's/[^-]*-//'` echo Invalid configuration \`$1\': system \`$os\' not recognized 1>&2 exit 1 ;; esac else # Here we handle the default operating systems that come with various machines. # The value should be what the vendor currently ships out the door with their # machine or put another way, the most popular os provided with the machine. # Note that if you're going to try to match "-MANUFACTURER" here (say, # "-sun"), then you have to tell the case statement up towards the top # that MANUFACTURER isn't an operating system. Otherwise, code above # will signal an error saying that MANUFACTURER isn't an operating # system, and we'll never get to this point. case $basic_machine in *-acorn) os=-riscix1.2 ;; arm*-semi) os=-aout ;; pdp11-*) os=-none ;; *-dec | vax-*) os=-ultrix4.2 ;; m68*-apollo) os=-domain ;; i386-sun) os=-sunos4.0.2 ;; m68000-sun) os=-sunos3 # This also exists in the configure program, but was not the # default. # os=-sunos4 ;; *-tti) # must be before sparc entry or we get the wrong os. os=-sysv3 ;; sparc-* | *-sun) os=-sunos4.1.1 ;; *-ibm) os=-aix ;; *-hp) os=-hpux ;; *-hitachi) os=-hiux ;; i860-* | *-att | *-ncr | *-altos | *-motorola | *-convergent) os=-sysv ;; *-cbm) os=-amigados ;; *-dg) os=-dgux ;; *-dolphin) os=-sysv3 ;; m68k-ccur) os=-rtu ;; m88k-omron*) os=-luna ;; *-next ) os=-nextstep ;; *-sequent) os=-ptx ;; *-crds) os=-unos ;; *-ns) os=-genix ;; i370-*) os=-mvs ;; *-next) os=-nextstep3 ;; *-gould) os=-sysv ;; *-highlevel) os=-bsd ;; *-encore) os=-bsd ;; *-sgi) os=-irix ;; *-siemens) os=-sysv4 ;; *-masscomp) os=-rtu ;; f301-fujitsu) os=-uxpv ;; *) os=-none ;; esac fi # Here we handle the case where we know the os, and the CPU type, but not the # manufacturer. We pick the logical manufacturer. vendor=unknown case $basic_machine in *-unknown) case $os in -riscix*) vendor=acorn ;; -sunos*) vendor=sun ;; -aix*) vendor=ibm ;; -hpux*) vendor=hp ;; -hiux*) vendor=hitachi ;; -unos*) vendor=crds ;; -dgux*) vendor=dg ;; -luna*) vendor=omron ;; -genix*) vendor=ns ;; -mvs*) vendor=ibm ;; -ptx*) vendor=sequent ;; -vxsim* | -vxworks*) vendor=wrs ;; -aux*) vendor=apple ;; esac basic_machine=`echo $basic_machine | sed "s/unknown/$vendor/"` ;; esac echo $basic_machine$os arj-3.10.22/gnu/configure.in 666 0 0 11101 10256056010 11754 0ustar dnl dnl $Id: configure.in,v 1.16 2005/06/18 19:41:05 andrew_belov Exp $ dnl -------------------------------------------------------------------------- dnl This file performs setup of GNU-style makefiles. dnl AC_INIT([arj]) AC_PREREQ(2.53) AC_CONFIG_SRCDIR([../arj.c]) dnl Installation script (let it be, temporarily...) AC_PROG_INSTALL([e:/os2apps/autoconf/install-sh]) dnl Configuration parameters AC_CONFIG_HEADER([../c_defs.h:config.h.in]) dnl Checks for the canonical system name AC_CANONICAL_HOST dnl Checks for programs. AC_PROG_CC dnl Checks for header files. AC_HEADER_STDC AC_CHECK_HEADERS([fcntl.h limits.h malloc.h]) dnl Checks for typedefs, structures, and compiler characteristics. AC_C_CONST AC_STRUCT_TM AC_C_BIGENDIAN dnl Checks for library functions. AC_PROG_GCC_TRADITIONAL AC_FUNC_MEMCMP AC_FUNC_SETVBUF_REVERSED AC_TYPE_SIGNAL AC_FUNC_VPRINTF AC_CHECK_FUNCS([getcwd min max mkdir mkdtemp rmdir fcloseall strcasecmp setpriority strdup strerror strstr strupr strlwr strtol strtoul]) dnl Platform-specific tuning PROG_EXT= DLL_EXT=".so" DLL_FLAGS="-shared" REQUIRES_DEF= OS_ID="UNIX" OS_DEF="-D_UNIX" DLL_CFLAGS="-fPIC" case $host_os in linux*) AC_DEFINE(ELF_EXECUTABLES, 1, [Define if executables use ELF format]) DYN_LIBS="-ldl" LD_STRIP="gnu/stripgcc.lnk" ;; k*bsd*) AC_DEFINE(ELF_EXECUTABLES) DYN_LIBS="-ldl" LD_STRIP="gnu/stripgcc.lnk" ;; *bsd*) AC_DEFINE(ELF_EXECUTABLES) DLL_FLAGS="-shared -export-dynamic" LD_STRIP="gnu/stripgcc.lnk" ;; interix3*) # not ELF DLL_FLAGS="-shared" DLL_CFLAGS="" ;; *qnx*) AC_DEFINE(ELF_EXECUTABLES) DLL_FLAGS="-shared -fPIC" DLL_CFLAGS="-shared -fPIC" LD_STRIP="gnu/stripgcc.lnk" ;; *solaris*) AC_DEFINE(ELF_EXECUTABLES) CFLAGS="-DSUNOS -D_UNIX" DLL_FLAGS="-shared -fPIC" DLL_CFLAGS="-shared -fPIC" LD_STRIP="gnu/stripgcc.lnk" ;; os2*) PROG_EXT=".exe" DLL_EXT=".dll" LDFLAGS="-s" DLL_FLAGS="-Zdll -s" DLL_CFLAGS="" REQUIRES_DEF=1 OS_ID="OS2" OS_DEF="-D_OS2" ;; esac case $host_cpu in alpha*) AC_DEFINE(ALIGN_POINTERS) ;; sparc*) AC_DEFINE(ALIGN_POINTERS) ;; ia64*) AC_DEFINE(ALIGN_POINTERS) ;; arm*) AC_DEFINE(ALIGN_POINTERS) ;; hppa*) AC_DEFINE(ALIGN_POINTERS) ;; esac dnl Registration wizard is named "arj-register" under UNIX-like platforms, to dnl give it a unique name case $host_os in os2*) REGISTER=register ;; *) REGISTER=arj-register esac dnl Initial setup test -z "$CONFIG_SHELL" && CONFIG_SHELL=/bin/sh AC_SUBST(CONFIG_SHELL) AC_MSG_CHECKING([if dynamic C library may be used]) AC_ARG_ENABLE(libc, [ --disable-libc Disable linking with dynamic C library], [enable_libc=no], [enable_libc=yes case $host_os in os2*) LDFLAGS="-Zcrtdll $LDFLAGS" DLL_FLAGS="-Zcrtdll $DLL_FLAGS" esac ]) AC_MSG_RESULT($enable_libc) test "$enable_libc" != "no" && AC_DEFINE(LIBC, 1, [Define if dynamic C library may be used]) AC_MSG_CHECKING([if SFX executables may be packed]) AC_ARG_ENABLE(packsfx, [ --disable-packsfx Force disable packing of SFX modules], [packsfx=no], [packsfx=yes]) AC_MSG_RESULT($packsfx) test "$packsfx" != "yes" && AC_DEFINE(NP_SFX, 1, [Define if SFX executables may be packed]) AC_MSG_CHECKING([what to use as a dedicated output directory]) AC_ARG_ENABLE(outdir, [ --enable-outdir Specify a dedicated output directory], [OUT_DIR=$enableval], [OUT_DIR=$host_os]) AC_MSG_RESULT($OUT_DIR) AC_SUBST(OUT_DIR) AC_MSG_CHECKING([fnmatch() tolerance to incomplete patterns acting as filenames]) AC_RUN_IFELSE([ #include int main() { return(fnmatch("@<:@", "@<:@", 0)); /* Must return 0 for a valid match */ } ], [TOLERANT_FNMATCH=yes], [TOLERANT_FNMATCH=no], [TOLERANT_FNMATCH=cross]) if test x$TOLERANT_FNMATCH = xyes ; then AC_DEFINE(TOLERANT_FNMATCH, 1, [Trust fnmatch() when supplying incomplete patterns]) fi AC_MSG_RESULT([$TOLERANT_FNMATCH]) dnl Experimental feature(s) AC_MSG_CHECKING([if color output is demanded]) AC_ARG_ENABLE(color-output, [ --enable-color-output Enable JAR-style color output (EXPERIMENTAL)], [color_output=yes], [color_output=no]) AC_MSG_RESULT($color_output) test "$color_output" = "yes" && AC_DEFINE(USE_COLORS) AC_SUBST(HAVE_MKDTEMP) AC_SUBST(HAVE_FCLOSEALL) AC_SUBST(HAVE_STRCASECMP) AC_SUBST(HAVE_SETPRIORITY) AC_SUBST(HAVE_STRUPR) AC_SUBST(HAVE_STRLWR) AC_SUBST(PROG_EXT) AC_SUBST(DLL_EXT) AC_SUBST(DLL_FLAGS) AC_SUBST(DLL_CFLAGS) AC_SUBST(REQUIRES_DEF) AC_SUBST(OS_ID) AC_SUBST(OS_DEF) AC_SUBST(LIBS) AC_SUBST(DYN_LIBS) AC_SUBST(LD_STRIP) AC_SUBST(REGISTER) AC_SUBST(TOLERANT_FNMATCH) AC_CONFIG_FILES([../GNUmakefile:makefile.in]) AC_OUTPUT arj-3.10.22/gnu/install-sh 666 0 0 12721 7450242244 11445 0ustar #! /bin/sh # # install - install a program, script, or datafile # This comes from X11R5 (mit/util/scripts/install.sh). # # Copyright 1991 by the Massachusetts Institute of Technology # # Permission to use, copy, modify, distribute, and sell this software and its # documentation for any purpose is hereby granted without fee, provided that # the above copyright notice appear in all copies and that both that # copyright notice and this permission notice appear in supporting # documentation, and that the name of M.I.T. not be used in advertising or # publicity pertaining to distribution of the software without specific, # written prior permission. M.I.T. makes no representations about the # suitability of this software for any purpose. It is provided "as is" # without express or implied warranty. # # Calling this script install-sh is preferred over install.sh, to prevent # `make' implicit rules from creating a file called install from it # when there is no Makefile. # # This script is compatible with the BSD install script, but was written # from scratch. It can only install one file at a time, a restriction # shared with many OS's install programs. # set DOITPROG to echo to test this script # Don't use :- since 4.3BSD and earlier shells don't like it. doit="${DOITPROG-}" # put in absolute paths if you don't have them in your path; or use env. vars. mvprog="${MVPROG-mv}" cpprog="${CPPROG-cp}" chmodprog="${CHMODPROG-chmod}" chownprog="${CHOWNPROG-chown}" chgrpprog="${CHGRPPROG-chgrp}" stripprog="${STRIPPROG-strip}" rmprog="${RMPROG-rm}" mkdirprog="${MKDIRPROG-mkdir}" transformbasename="" transform_arg="" instcmd="$mvprog" chmodcmd="$chmodprog 0755" chowncmd="" chgrpcmd="" stripcmd="" rmcmd="$rmprog -f" mvcmd="$mvprog" src="" dst="" dir_arg="" while [ x"$1" != x ]; do case $1 in -c) instcmd="$cpprog" shift continue;; -d) dir_arg=true shift continue;; -m) chmodcmd="$chmodprog $2" shift shift continue;; -o) chowncmd="$chownprog $2" shift shift continue;; -g) chgrpcmd="$chgrpprog $2" shift shift continue;; -s) stripcmd="$stripprog" shift continue;; -t=*) transformarg=`echo $1 | sed 's/-t=//'` shift continue;; -b=*) transformbasename=`echo $1 | sed 's/-b=//'` shift continue;; *) if [ x"$src" = x ] then src=$1 else # this colon is to work around a 386BSD /bin/sh bug : dst=$1 fi shift continue;; esac done if [ x"$src" = x ] then echo "install: no input file specified" exit 1 else true fi if [ x"$dir_arg" != x ]; then dst=$src src="" if [ -d $dst ]; then instcmd=: else instcmd=mkdir fi else # Waiting for this to be detected by the "$instcmd $src $dsttmp" command # might cause directories to be created, which would be especially bad # if $src (and thus $dsttmp) contains '*'. if [ -f $src -o -d $src ] then true else echo "install: $src does not exist" exit 1 fi if [ x"$dst" = x ] then echo "install: no destination specified" exit 1 else true fi # If destination is a directory, append the input filename; if your system # does not like double slashes in filenames, you may need to add some logic if [ -d $dst ] then dst="$dst"/`basename $src` else true fi fi ## this sed command emulates the dirname command dstdir=`echo $dst | sed -e 's,[^/]*$,,;s,/$,,;s,^$,.,'` # Make sure that the destination directory exists. # this part is taken from Noah Friedman's mkinstalldirs script # Skip lots of stat calls in the usual case. if [ ! -d "$dstdir" ]; then defaultIFS=' ' IFS="${IFS-${defaultIFS}}" oIFS="${IFS}" # Some sh's can't handle IFS=/ for some reason. IFS='%' set - `echo ${dstdir} | sed -e 's@/@%@g' -e 's@^%@/@'` IFS="${oIFS}" pathcomp='' while [ $# -ne 0 ] ; do pathcomp="${pathcomp}${1}" shift if [ ! -d "${pathcomp}" ] ; then $mkdirprog "${pathcomp}" else true fi pathcomp="${pathcomp}/" done fi if [ x"$dir_arg" != x ] then $doit $instcmd $dst && if [ x"$chowncmd" != x ]; then $doit $chowncmd $dst; else true ; fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dst; else true ; fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dst; else true ; fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dst; else true ; fi else # If we're going to rename the final executable, determine the name now. if [ x"$transformarg" = x ] then dstfile=`basename $dst` else dstfile=`basename $dst $transformbasename | sed $transformarg`$transformbasename fi # don't allow the sed command to completely eliminate the filename if [ x"$dstfile" = x ] then dstfile=`basename $dst` else true fi # Make a temp file name in the proper directory. dsttmp=$dstdir/#inst.$$# # Move or copy the file name to the temp name $doit $instcmd $src $dsttmp && trap "rm -f ${dsttmp}" 0 && # and set any options; do chmod last to preserve setuid bits # If any of these fail, we abort the whole thing. If we want to # ignore errors from any of these, just make sure not to ignore # errors from the above "$doit $instcmd $src $dsttmp" command. if [ x"$chowncmd" != x ]; then $doit $chowncmd $dsttmp; else true;fi && if [ x"$chgrpcmd" != x ]; then $doit $chgrpcmd $dsttmp; else true;fi && if [ x"$stripcmd" != x ]; then $doit $stripcmd $dsttmp; else true;fi && if [ x"$chmodcmd" != x ]; then $doit $chmodcmd $dsttmp; else true;fi && # Now rename the file to the real destination. $doit $rmcmd -f $dstdir/$dstfile && $doit $mvcmd $dsttmp $dstdir/$dstfile fi && exit 0 arj-3.10.22/gnu/makefile.in 666 0 0 31503 10040212306 11551 0ustar # # $Id: makefile.in,v 1.14 2004/04/17 11:28:07 andrew_belov Exp $ # ---------------------------------------------------------------------------- # This file is for using the GNU ways to compile ARJ. # # Environment x = @PROG_EXT@ d = @DLL_EXT@ OS_ID = @OS_ID@ SHELL = @CONFIG_SHELL@ DYN_LIBS = @DYN_LIBS@ LIBS = @LIBS@ REGISTER = @REGISTER@ # Programs INSTALL = @INSTALL@ INSTALL_DIR = @INSTALL@ -d -m 755 INSTALL_DATA = @INSTALL_DATA@ INSTALL_PROGRAM = @INSTALL_PROGRAM@ # Installation Paths prefix = @prefix@ exec_prefix = @exec_prefix@ bindir = @bindir@ datadir = @datadir@ mandir = @mandir@ libdir = @libdir@ pkglibdir = $(libdir)/arj # Defaults ifndef LOCALE LOCALE = en endif ALL_CFLAGS = -DLOCALE=LANG_$(LOCALE) -DLOCALE_DESC="\"$(LOCALE)\"" \ -DPKGLIBDIR="\"$(pkglibdir)\"" @OS_DEF@ ifndef COMMERCIAL PACKAGE = s else PACKAGE = c ALL_CFLAGS += -DCOMMERCIAL endif ifdef DEBUG DEBUG_SM = d ALL_CFLAGS += -g -DDEBUG else DEBUG_SM = r ADD_LDFLAGS = -s @LD_STRIP@ endif ALL_CFLAGS += $(CFLAGS) # Build Installation paths SRC_DIR = . BASEDIR = $(SRC_DIR)/@OUT_DIR@/$(LOCALE)/$(DEBUG_SM)$(PACKAGE) BASEDIR_C = $(SRC_DIR)/@OUT_DIR@/$(LOCALE)/$(DEBUG_SM)c RES_DIR = $(SRC_DIR)/resource RESFILE = $(RES_DIR)/resource.txt TOOLS_DIR = $(BASEDIR)/tools ARJ_DIR = $(BASEDIR)/arj ARJSFXV_DIR = $(BASEDIR)/arjsfxv ARJSFX_DIR = $(BASEDIR)/arjsfx ARJSFXJR_DIR = $(BASEDIR)/arjsfxjr REARJ_DIR = $(BASEDIR)/rearj ARJCRYPT_DIR = $(BASEDIR)/arjcrypt REGISTER_DIR = $(BASEDIR)/register ARJDISP_DIR = $(BASEDIR)/arjdisp SFXSTUB_DIR = $(BASEDIR)/sfxstub # Definitions for compiling submodules LDFLAGS = @LDFLAGS@ $(ADD_LDFLAGS) DLL_FLAGS = @DLL_FLAGS@ $(ADD_LDFLAGS) DLL_CFLAGS = @DLL_CFLAGS@ REQUIRES_DEF = @REQUIRES_DEF@ COPT = -c -I@OUT_DIR@ -I$(BASEDIR) -I$(SRC_DIR) @CFLAGS@ $(ALL_CFLAGS) STD_COPT = -DARJUTIL $(COPT) ARJ_COPT = -DSFL=4 $(COPT) ARJSFXV_COPT = -DSFL=3 $(COPT) ARJSFX_COPT = -DSFL=2 $(COPT) ARJSFXJR_COPT = -DSFL=1 $(COPT) REARJ_COPT = -DREARJ $(COPT) REGISTER_COPT = -DREGISTER $(COPT) ARJDISP_COPT = -DARJDISP $(COPT) ARJCRYPT_COPT = $(DLL_CFLAGS) $(COPT) SFXSTUB_COPT = -DSFXSTUB $(COPT) # Linkage $(ARJ_DIR)/%.o: $(BASEDIR)/%.c $(CC) $(COPT) -o$@ $< $(ARJSFX_DIR)/%.o: $(BASEDIR)/%.c $(CC) $(COPT) -o$@ $< $(ARJSFXV_DIR)/%.o: $(BASEDIR)/%.c $(CC) $(COPT) -o$@ $< $(ARJSFXJR_DIR)/%.o: $(BASEDIR)/%.c $(CC) $(COPT) -o$@ $< $(ARJCRYPT_DIR)/%.o: $(BASEDIR)/%.c $(CC) $(ARJCRYPT_COPT) -o$@ $< $(SFXSTUB_DIR)/%.o: $(BASEDIR)/%.c $(CC) $(COPT) -o$@ $< $(REARJ_DIR)/%.o: $(BASEDIR)/%.c $(CC) $(COPT) -o$@ $< $(REGISTER_DIR)/%.o: $(BASEDIR)/%.c $(CC) $(COPT) -o$@ $< $(ARJDISP_DIR)/%.o: $(BASEDIR)/%.c $(CC) $(COPT) -o$@ $< $(TOOLS_DIR)/%.o: $(SRC_DIR)/%.c $(CC) $(STD_COPT) -o$@ $< $(ARJ_DIR)/%.o: $(SRC_DIR)/%.c $(CC) $(ARJ_COPT) -o$@ $< $(ARJSFXV_DIR)/%.o: $(SRC_DIR)/%.c $(CC) $(ARJSFXV_COPT) -o$@ $< $(ARJSFX_DIR)/%.o: $(SRC_DIR)/%.c $(CC) $(ARJSFX_COPT) -o$@ $< $(ARJSFXJR_DIR)/%.o: $(SRC_DIR)/%.c $(CC) $(ARJSFXJR_COPT) -o$@ $< $(ARJCRYPT_DIR)/%.o: $(SRC_DIR)/%.c $(CC) $(ARJCRYPT_COPT) -o$@ $< $(REARJ_DIR)/%.o: $(SRC_DIR)/%.c $(CC) $(REARJ_COPT) -o$@ $< $(REGISTER_DIR)/%.o: $(SRC_DIR)/%.c $(CC) $(REGISTER_COPT) -o$@ $< $(ARJDISP_DIR)/%.o: $(SRC_DIR)/%.c $(CC) $(ARJDISP_COPT) -o$@ $< $(SFXSTUB_DIR)/%.o: $(SRC_DIR)/%.c $(CC) $(SFXSTUB_COPT) -o$@ $< # # Main dependency tree # .PHONY: timestamp prepare cleanup package help ifdef COMMERCIAL MAKE_KEY=$(TOOLS_DIR)/make_key$x endif all: prepare timestamp $(MAKE) do-all do-all: \ $(ARJ_DIR)/arj$x \ $(ARJCRYPT_DIR)/arjcrypt$d \ $(REARJ_DIR)/rearj$x \ $(REGISTER_DIR)/$(REGISTER)$x \ $(ARJDISP_DIR)/arjdisp$x \ $(TOOLS_DIR)/packager$x \ $(MAKE_KEY) \ dispose # # Update timestamp file # timestamp: $(TOOLS_DIR)/today$x $(TOOLS_DIR)/today$x $(LOCALE) $(BASEDIR) # # Final cleanup # dispose: # # The tools # MSGBIND_OBJS = $(patsubst %,$(TOOLS_DIR)/%, \ filemode.o msgbind.o arjdata.o crc32.o) TODAY_OBJS = $(patsubst %,$(TOOLS_DIR)/%, \ filemode.o today.o) MAKE_KEY_OBJS = $(patsubst %,$(TOOLS_DIR)/%, \ make_key.o crc32.o misc.o arj_proc.o arjsec_h.o arjsec_l.o) POSTPROC_OBJS = $(patsubst %,$(TOOLS_DIR)/%, \ filemode.o postproc.o crc32.o) JOIN_OBJS = $(patsubst %,$(TOOLS_DIR)/%, \ filemode.o join.o) PACKAGER_OBJS = $(patsubst %,$(TOOLS_DIR)/%, \ filemode.o packager.o arjdata.o) $(TOOLS_DIR)/msgbind$x: $(MSGBIND_OBJS) $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(MSGBIND_OBJS) $(LIBS) $(TOOLS_DIR)/today$x: $(TODAY_OBJS) $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(TODAY_OBJS) $(LIBS) $(TOOLS_DIR)/make_key$x: $(MAKE_KEY_OBJS) $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(MAKE_KEY_OBJS) $(LIBS) $(TOOLS_DIR)/postproc$x: $(POSTPROC_OBJS) $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(POSTPROC_OBJS) $(LIBS) $(TOOLS_DIR)/join$x: $(JOIN_OBJS) $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(JOIN_OBJS) $(LIBS) $(TOOLS_DIR)/packager$x: $(PACKAGER_OBJS) $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(PACKAGER_OBJS) $(LIBS) # This rule tells that timestamping badly needs date_sig.c (it may bail out # otherwise when the timestamps are being created for the first time) $(BASEDIR)/date_sig.c: timestamp # And this one explicitly specifies that chk_fmsg depends on individual files $(ARJ_DIR)/chk_fmsg.o: $(SRC_DIR)/chk_fmsg.c $(BASEDIR)/fmsg_arj.c $(ARJSFX_DIR)/chk_fmsg.o: $(SRC_DIR)/chk_fmsg.c $(BASEDIR)/fmsg_sfx.c $(ARJSFXV_DIR)/chk_fmsg.o: $(SRC_DIR)/chk_fmsg.c $(BASEDIR)/fmsg_sfv.c # # ARJCRYPT utility # ifdef REQUIRES_DEF ARJCRYPT_DEF = $(SRC_DIR)/gnu/arjcrypt.def endif ARJCRYPT_OBJS = $(patsubst %,$(ARJCRYPT_DIR)/%, \ integr.o gost.o gost_t.o nmsg_crp.o arjcrypt.o) $(ARJCRYPT_DIR)/arjcrypt$d: $(ARJCRYPT_OBJS) $(TOOLS_DIR)/postproc$x $(CC) $(ALL_CFLAGS) $(DLL_FLAGS) -o $@ $(ARJCRYPT_OBJS) $(ARJCRYPT_DEF) $(LIBS) $(TOOLS_DIR)/postproc $@ $(BASEDIR)/nmsg_crp.c: $(TOOLS_DIR)/msgbind$x $(RESFILE) $(TOOLS_DIR)/msgbind $(RESFILE) msg_crp $(OS_ID) $(PACKAGE) $(LOCALE) $(BASEDIR) # # SFX stub # SFXSTUB_OBJS = $(patsubst %,$(SFXSTUB_DIR)/%, \ nmsg_stb.o sfxstub.o) $(SFXSTUB_DIR)/sfxstub$x: $(SFXSTUB_OBJS) $(TOOLS_DIR)/postproc$x $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(SFXSTUB_OBJS) $(LIBS) $(TOOLS_DIR)/postproc$x $@ -sfx $(BASEDIR)/nmsg_stb.c: $(TOOLS_DIR)/msgbind$x $(RESFILE) $(TOOLS_DIR)/msgbind $(RESFILE) msg_stb $(OS_ID) $(PACKAGE) $(LOCALE) $(BASEDIR) # # ARJSFXV module # ARJSFXV_OBJS = $(patsubst %,$(ARJSFXV_DIR)/%, \ sfx_id.o filemode.o date_sig.o fmsg_sfv.o imsg_sfv.o nmsg_sfv.o \ decode.o arjsfx.o fardata.o arj_user.o arj_arcv.o arj_file.o \ crc32.o misc.o debug.o arj_proc.o environ.o ea_mgr.o ntstream.o \ uxspec.o ext_hdr.o arjtypes.o exe_sear.o chk_fmsg.o filelist.o \ arjsec_h.o arjsec_l.o garble.o scrnio.o ansi.o externs.o) $(ARJSFXV_DIR)/arjsfxv$x: $(ARJSFXV_OBJS) $(TOOLS_DIR)/postproc$x $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(ARJSFXV_OBJS) $(LIBS) $(DYN_LIBS) $(TOOLS_DIR)/postproc$x $@ -sfx $(BASEDIR)/fmsg_sfv.c $(BASEDIR)/imsg_sfv.c $(BASEDIR)/nmsg_sfv.c: $(TOOLS_DIR)/msgbind$x $(RESFILE) $(TOOLS_DIR)/msgbind $(RESFILE) msg_sfv $(OS_ID) $(PACKAGE) $(LOCALE) $(BASEDIR) # # ARJSFX module # ARJSFX_OBJS = $(patsubst %,$(ARJSFX_DIR)/%, \ sfx_id.o filemode.o fmsg_sfx.o imsg_sfx.o nmsg_sfx.o decode.o \ arjsfx.o fardata.o arj_user.o arj_arcv.o arj_file.o crc32.o \ misc.o debug.o arj_proc.o environ.o arjtypes.o exe_sear.o \ chk_fmsg.o arjsec_h.o arjsec_l.o garble.o externs.o) $(ARJSFX_DIR)/arjsfx$x: $(ARJSFX_OBJS) $(TOOLS_DIR)/postproc$x $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(ARJSFX_OBJS) $(LIBS) $(TOOLS_DIR)/postproc$x $@ -sfx $(BASEDIR)/fmsg_sfx.c $(BASEDIR)/imsg_sfx.c $(BASEDIR)/nmsg_sfx.c: $(TOOLS_DIR)/msgbind$x $(RESFILE) $(TOOLS_DIR)/msgbind $(RESFILE) msg_sfx $(OS_ID) $(PACKAGE) $(LOCALE) $(BASEDIR) # # ARJSFXJR module # ARJSFXJR_OBJS = $(patsubst %,$(ARJSFXJR_DIR)/%, \ sfx_id.o fmsg_sfj.o nmsg_sfj.o arjsfxjr.o debug.o \ crc32.o environ.o) $(ARJSFXJR_DIR)/arjsfxjr$x: $(ARJSFXJR_OBJS) $(TOOLS_DIR)/postproc$x $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(ARJSFXJR_OBJS) $(LIBS) $(TOOLS_DIR)/postproc$x $@ -sfx $(BASEDIR)/fmsg_sfj.c $(BASEDIR)/imsg_sfj.c $(BASEDIR)/nmsg_sfj.c: $(TOOLS_DIR)/msgbind$x $(RESFILE) $(TOOLS_DIR)/msgbind $(RESFILE) msg_sfj $(OS_ID) $(PACKAGE) $(LOCALE) $(BASEDIR) # # ARJ itself # ARJ_OBJS = $(patsubst %,$(ARJ_DIR)/%, \ filemode.o date_sig.o fmsg_arj.o imsg_arj.o \ nmsg_arj.o integr.o file_reg.o decode.o encode.o \ arj.o enc_gwy.o fardata.o arj_user.o arj_arcv.o \ arj_file.o crc32.o misc.o debug.o arj_proc.o \ environ.o ea_mgr.o uxspec.o ext_hdr.o arjtypes.o exe_sear.o chk_fmsg.o \ filelist.o arjsec_h.o arjsec_l.o garble.o scrnio.o ansi.o \ crc16tab.o recovery.o gost.o gost40.o gost_t.o \ externs.o) $(ARJ_DIR)/arj$x: $(ARJ_OBJS) \ $(RES_DIR)/$(LOCALE)/arjl.txt $(RES_DIR)/$(LOCALE)/arjs.txt \ $(TOOLS_DIR)/join$x \ $(TOOLS_DIR)/postproc$x \ $(SFXSTUB_DIR)/sfxstub$x \ $(ARJSFXV_DIR)/arjsfxv$x \ $(ARJSFX_DIR)/arjsfx$x \ $(ARJSFXJR_DIR)/arjsfxjr$x $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(ARJ_OBJS) $(LIBS) $(DYN_LIBS) $(TOOLS_DIR)/join $(ARJ_DIR)/arj$x $(ARJSFXJR_DIR)/arjsfxjr$x $(TOOLS_DIR)/join $(ARJ_DIR)/arj$x $(ARJSFX_DIR)/arjsfx$x $(TOOLS_DIR)/join $(ARJ_DIR)/arj$x $(ARJSFXV_DIR)/arjsfxv$x $(TOOLS_DIR)/join $(ARJ_DIR)/arj$x $(SFXSTUB_DIR)/sfxstub$x rm -f $(BASEDIR)/help.arj $(ARJ_DIR)/arj$x a $(BASEDIR)/help.arj -+ -t1f -2e -e -jm -jh65535 -jt $(RES_DIR)/$(LOCALE)/arj?.txt $(TOOLS_DIR)/join $(ARJ_DIR)/arj$x $(BASEDIR)/help.arj $(TOOLS_DIR)/postproc $@ $(BASEDIR)/fmsg_arj.c $(BASEDIR)/imsg_arj.c $(BASEDIR)/nmsg_arj.c: $(TOOLS_DIR)/msgbind$x $(RESFILE) $(TOOLS_DIR)/msgbind $(RESFILE) msg_arj $(OS_ID) $(PACKAGE) $(LOCALE) $(BASEDIR) # # REARJ utility # REARJ_OBJS = $(patsubst %,$(REARJ_DIR)/%, \ integr.o filemode.o date_sig.o fmsg_rej.o nmsg_rej.o file_reg.o \ rearj.o fardata.o arj_file.o crc32.o misc.o debug.o arj_proc.o \ environ.o arjtypes.o filelist.o scrnio.o arjsec_h.o arjsec_l.o \ externs.o) $(REARJ_DIR)/rearj$x: $(REARJ_OBJS) \ $(TOOLS_DIR)/postproc$x $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(REARJ_OBJS) $(LIBS) $(TOOLS_DIR)/postproc $@ $(BASEDIR)/fmsg_rej.c $(BASEDIR)/imsg_rej.c $(BASEDIR)/nmsg_rej.c: $(TOOLS_DIR)/msgbind$x $(RESFILE) $(TOOLS_DIR)/msgbind $(RESFILE) msg_rej $(OS_ID) $(PACKAGE) $(LOCALE) $(BASEDIR) # # Registration wizard # REGISTER_OBJS = $(patsubst %,$(REGISTER_DIR)/%, \ filemode.o integr.o fmsg_reg.o nmsg_reg.o register.o fardata.o crc32.o \ debug.o arj_proc.o environ.o) $(REGISTER_DIR)/$(REGISTER)$x: $(REGISTER_OBJS) \ $(TOOLS_DIR)/postproc$x $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(REGISTER_OBJS) $(LIBS) $(TOOLS_DIR)/postproc $@ -sfx $(BASEDIR)/fmsg_reg.c $(BASEDIR)/imsg_reg.c $(BASEDIR)/nmsg_reg.c: $(TOOLS_DIR)/msgbind$x $(RESFILE) $(TOOLS_DIR)/msgbind $(RESFILE) msg_reg $(OS_ID) $(PACKAGE) $(LOCALE) $(BASEDIR) # # Demonstration display program # ARJDISP_OBJS = $(patsubst %,$(ARJDISP_DIR)/%, \ nmsg_adi.o arjdisp.o fardata.o debug.o arj_proc.o environ.o \ scrnio.o) $(ARJDISP_DIR)/arjdisp$x: $(ARJDISP_OBJS) $(CC) $(ALL_CFLAGS) $(LDFLAGS) -o $@ $(ARJDISP_OBJS) $(LIBS) $(BASEDIR)/fmsg_adi.c $(BASEDIR)/imsg_adi.c $(BASEDIR)/nmsg_adi.c: $(TOOLS_DIR)/msgbind$x $(RESFILE) $(TOOLS_DIR)/msgbind $(RESFILE) msg_adi $(OS_ID) $(PACKAGE) $(LOCALE) $(BASEDIR) # # Pre-compilation actions # prepare: -mkdir -p $(BASEDIR) -mkdir -p $(TOOLS_DIR) -mkdir -p $(ARJCRYPT_DIR) -mkdir -p $(SFXSTUB_DIR) -mkdir -p $(ARJSFXV_DIR) -mkdir -p $(ARJSFX_DIR) -mkdir -p $(ARJSFXJR_DIR) -mkdir -p $(ARJ_DIR) -mkdir -p $(REARJ_DIR) -mkdir -p $(REGISTER_DIR) -mkdir -p $(ARJDISP_DIR) # # Cleanup # clean: -rm -f $(BASEDIR)/* -rm -f $(TOOLS_DIR)/* -rm -f $(ARJCRYPT_DIR)/* -rm -f $(SFXSTUB_DIR)/* -rm -f $(ARJSFXV_DIR)/* -rm -f $(ARJSFX_DIR)/* -rm -f $(ARJSFXJR_DIR)/* -rm -f $(ARJ_DIR)/* -rm -f $(REARJ_DIR)/* -rm -f $(REGISTER_DIR)/* -rm -f $(ARJDISP_DIR)/* -rm -f arj.core # # Local installation # install: all $(INSTALL_DIR) $(DESTDIR)$(bindir) $(INSTALL_DIR) $(DESTDIR)$(mandir)/man1 $(INSTALL_DIR) $(DESTDIR)$(pkglibdir) $(INSTALL_PROGRAM) $(ARJ_DIR)/arj$x $(DESTDIR)$(bindir) $(INSTALL_PROGRAM) $(ARJCRYPT_DIR)/arjcrypt$d $(DESTDIR)$(pkglibdir) $(INSTALL_PROGRAM) $(REARJ_DIR)/rearj$x $(DESTDIR)$(bindir) $(INSTALL_PROGRAM) $(ARJDISP_DIR)/arjdisp$x $(DESTDIR)$(bindir) $(INSTALL_PROGRAM) $(REGISTER_DIR)/$(REGISTER)$x $(DESTDIR)$(bindir) $(INSTALL_DATA) $(RES_DIR)/en/*.1 $(DESTDIR)$(mandir)/man1 # # Packaging (was: packager$x $(BASEDIR_C) $(BASEDIR)) # package: all -@mkdir retail $(TOOLS_DIR)/packager$x $(BASEDIR) $(BASEDIR) # # Traditional help # help: @echo @echo "Quick start:" @echo "all -- standard compile" @echo "package -- all + packaging (requires a commercial version of the same kind)" @echo "clean -- removes all '.o' and 'core' files" @echo "install -- local installation" @echo @echo "Don't panic, the legacy compatibility is retained." @echo arj-3.10.22/gnu/mkinstalldirs 666 0 0 1365 7450242244 12231 0ustar #! /bin/sh # mkinstalldirs --- make directory hierarchy # Author: Noah Friedman # Created: 1993-05-16 # Public domain # $Id: mkinstalldirs,v 1.1.1.2 2002/03/28 00:03:45 andrew_belov Exp $ errstatus=0 for file do set fnord `echo "$file" | sed -ne 's,//,/,g;s,^/,:,;s,:/,::,;s,/, ,g;s,::,:/,;s,^:,/,;p'` shift pathcomp= for d do pathcomp="$pathcomp$d" case "$pathcomp" in -* ) pathcomp=./$pathcomp ;; esac if test ! -d "$pathcomp"; then echo "mkdir $pathcomp" 1>&2 mkdir "$pathcomp" || lasterr=$? if test ! -d "$pathcomp"; then errstatus=$lasterr fi fi pathcomp="$pathcomp/" done done exit $errstatus # mkinstalldirs ends here arj-3.10.22/gnu/stripgcc.lnk 666 0 0 110 7743255230 11721 0ustar SECTIONS { /DISCARD/ : { *(.comment) *(.note) *(.stab) *(.stabstr) } } arj-3.10.22/gost.c 666 0 0 2232 7653041622 7751 0ustar /* * $Id: gost.c,v 1.2 2003/04/27 20:54:42 andrew_belov Exp $ * --------------------------------------------------------------------------- * This file contains basic GOST encryption-related initialization data and * code. * */ #include "arj.h" DEBUGHDR(__FILE__) /* Debug information block */ /* Makes a 1024-byte pattern for encryption */ void calc_gost_pattern() { int i; for(i=0; i<256; i++) { pattern[0][i]=(seed[0][i>>4]<<4)|(seed[1][i&0x0F]); pattern[1][i]=(seed[2][i>>4]<<4)|(seed[3][i&0x0F]); pattern[2][i]=(seed[4][i>>4]<<4)|(seed[5][i&0x0F]); pattern[3][i]=(seed[6][i>>4]<<4)|(seed[7][i&0x0F]); } } /* Basic step of GOST encoding */ #ifdef WORDS_BIGENDIAN #define _dptr(i) (dptr[3-(i)]) #else #define _dptr(i) (dptr[ (i)]) #endif unsigned long gost_term(unsigned long data) { unsigned char *dptr; unsigned short p1, p2; unsigned short hi, lo; dptr=(unsigned char *)&data; p1=(pattern[0][_dptr(3)]<<8)+pattern[1][_dptr(2)]; p2=(pattern[2][_dptr(1)]<<8)+pattern[3][_dptr(0)]; hi=(p1<>(16-GSH_BITS)); lo=(p2<>(16-GSH_BITS)); return(((unsigned long)hi<<16)+(unsigned long)lo); } arj-3.10.22/gost.h 666 0 0 1255 7450456656 7776 0ustar /* * $Id: gost.h,v 1.1.1.1 2002/03/28 00:02:55 andrew_belov Exp $ * --------------------------------------------------------------------------- * Prototypes of the functions and declarations of data structures located in * GOST.C are stored here. * */ #ifndef GOST_INCLUDED #define GOST_INCLUDED /* Encryption-related constants */ #define GSH_BITS 11 /* Used in bit shifts */ #define KEYGEN_ITERATIONS 2048 /* Number of key generation cycles */ /* Predefined patterns */ #define GOST_I_PAT_LO 0x01010101 #define GOST_I_PAT_HI 0x01010104 /* Prototypes */ void calc_gost_pattern(); unsigned long gost_term(unsigned long data); #endif arj-3.10.22/gost40.c 666 0 0 13153 7653041622 10141 0ustar /* * $Id: gost40.c,v 1.3 2003/04/27 20:54:42 andrew_belov Exp $ * --------------------------------------------------------------------------- * This file contains the routines that provide 40-bit GOST encryption with * dependence on previously encrypted data. * */ #include "arj.h" DEBUGHDR(__FILE__) /* Debug information block */ /* Local variables */ static unsigned long default_key[8]={3, 10, 6, 12, 5, 9, 0, 7}; static int last_bytes=0; /* Number of significant bytes in the last block */ static unsigned long back_code[2]={0L}; /* Recently encrypted data */ static unsigned long gost40_key[8]={0L};/* Automatically generated key */ #ifdef WORDS_BIGENDIAN static const int ord[8]={3,2,1,0,7,6,5,4}; #define bf(x) ord[x] static void adjust_byte_order(char *p,const int len) { int l4; for (l4=len>>2;l4;l4--) { char tmp,*p1,*p2; p1 = p +1; p2 = p1+1; tmp = *p2; *p2++ = *p1; *p1-- = tmp; tmp = *p1; *p1 = *p2; *p2 = tmp; p = p2+1; } } #else #define bf(x) (x) #endif void codec(void (*fct)(unsigned char*, unsigned char*, int), unsigned char *buf, int len) { #ifdef WORDS_BIGENDIAN if (!(len&7) && !last_bytes) adjust_byte_order(buf,len); #endif (*fct)(buf,buf,len); #ifdef WORDS_BIGENDIAN if (!(len&7) && !last_bytes) adjust_byte_order(buf,len); #endif } /* GOST encoding/decoding loop */ static void gost40_loop(unsigned long *src, unsigned long *dest, unsigned long *key) { unsigned long mod1, mod2; int i; mod1=src[0]; mod2=src[1]; for(i=0; i<3; i++) { mod2^=gost_term(mod1+key[0]); mod1^=gost_term(mod2+key[1]); mod2^=gost_term(mod1+key[2]); mod1^=gost_term(mod2+key[3]); mod2^=gost_term(mod1+key[4]); mod1^=gost_term(mod2+key[5]); mod2^=gost_term(mod1+key[6]); mod1^=gost_term(mod2+key[7]); } mod2^=gost_term(mod1+key[7]); mod1^=gost_term(mod2+key[6]); mod2^=gost_term(mod1+key[5]); mod1^=gost_term(mod2+key[4]); mod2^=gost_term(mod1+key[3]); mod1^=gost_term(mod2+key[2]); mod2^=gost_term(mod1+key[1]); mod1^=gost_term(mod2+key[0]); dest[0]=mod2; dest[1]=mod1; } /* Encoding sequence */ static void gost40_encode(unsigned char *src, unsigned char *dest, int len) { unsigned long *tmp_sptr; /* Pointer to source area */ unsigned long *tmp_dptr; /* Pointer to target area */ int remainder; /* Number of bytes in the last block */ unsigned char *bc_offset; /* Offset within back_code */ remainder=len%8; if(remainder==0&&last_bytes==0) { tmp_sptr=(unsigned long *)src; tmp_dptr=(unsigned long *)dest; len>>=3; while(len--!=0) { gost40_loop(back_code, back_code, gost40_key); back_code[0]=tmp_dptr[0]=tmp_sptr[0]^back_code[0]; back_code[1]=tmp_dptr[1]=tmp_sptr[1]^back_code[1]; tmp_sptr+=2; tmp_dptr+=2; } } else { bc_offset=(unsigned char *)back_code; while(len--!=0) { if(last_bytes==0) gost40_loop(back_code, back_code, gost40_key); bc_offset[bf(last_bytes)]=*(dest++)=*(src++)^bc_offset[bf(last_bytes)]; last_bytes++; last_bytes%=8; } } } /* Decoding sequence */ static void gost40_decode(unsigned char *src, unsigned char *dest, int len) { unsigned long *tmp_sptr; unsigned long *tmp_dptr; int remainder; unsigned long d_data; /* Decoded data collector */ unsigned char *bc_offset; /* Offset within back_code */ unsigned char dec_sym; /* Currently processed symbol */ remainder=len%8; if(remainder==0&&last_bytes==0) { tmp_sptr=(unsigned long *)src; tmp_dptr=(unsigned long *)dest; len>>=3; while(len--!=0) { gost40_loop(back_code, back_code, gost40_key); d_data=tmp_sptr[0]; tmp_dptr[0]=d_data^back_code[0]; back_code[0]=d_data; d_data=tmp_sptr[1]; tmp_dptr[1]=d_data^back_code[1]; back_code[1]=d_data; tmp_sptr+=2; tmp_dptr+=2; } } else { bc_offset=(unsigned char *)back_code; while(len--!=0) { if(last_bytes==0) gost40_loop(back_code, back_code, gost40_key); dec_sym=*(src++); *(dest++)=dec_sym^bc_offset[bf(last_bytes)]; bc_offset[bf(last_bytes++)]=dec_sym; last_bytes%=8; } } } /* Creates an unique encoding key from the given seed */ static void gost40_crtkey(unsigned long *seed) { unsigned long tmp_key[8]; int i; memcpy(tmp_key, gost40_key, sizeof(tmp_key)); gost40_loop(seed, back_code, default_key); for(i=0; i>8 ,stream); fputc(l>>16,stream); fputc(l>>24,stream); #else fwrite(&l,4,1,stream); #endif } int main(int argc, char **argv) { FILE *V1, *V2; unsigned long b; int i, rc=0; printf("JOIN v 1.30 [26/04/2003] Not a part of any binary package!\r\n\r\n"); if(argc>=3) { if((V1=fopen(argv[1], m_abp))!=NULL) { if((V2=fopen(argv[2], m_rb))!=NULL) { fseek(V1, 0, SEEK_END); b=ftell(V1); fgetc(V1); fwrite("ARJ_SFX", 1, 8, V1); _fput_dword(b, V1); fseek(V2, 0, SEEK_END); b=ftell(V2); fseek(V2, 0, SEEK_SET); _fput_dword(b, V1); /* Now simply copy the file */ printf("Copying "); while((i=fread(buffer, 1, sizeof(buffer), V2))!=0) { fwrite(buffer, 1, i, V1); printf("."); } printf(" done!\r\n"); fclose(V2); } else { printf("Can't open %s\r\n", argv[1]); rc=3; } fclose(V1); } else { printf("Can't open ARJ.EXE\r\n"); return 0; rc=2; } } else { printf("Usage: JOIN ,\r\n" " e.g, to append HELP.ARJ to ARJ.EXE, type JOIN ARJ.EXE HELP.ARJ\r\n"); rc=1; } return rc; } arj-3.10.22/makefile 666 0 0 146376 10064613030 10417 0ustar # # $Id: makefile,v 1.11 2004/06/18 16:19:37 andrew_belov Exp $ # ---------------------------------------------------------------------------- # This file is intended for building ARJ on/for platforms where the NMAKE # syntax is supported. If you are using a GCC/EMX build, refer to scripts in # the "gnu" directory. # # It's essential that the following versions of NMAKE are used: # # DOS Microsoft NMAKE v 1.36 or higher # OS/2, WinNT Microsoft NMAKE/2 v 1.21 or NMAKE/Win32 v 1.40+ # # Parameters: # NP_SFX disables executable packing # COMMERCIAL produces commercial package (where available) # DEBUG includes debug information and extra data # # FORCE_MSGRAPH with Microsoft C for DOS, enables GRAPHICS.LIB # LIBC in 32-bit OS/2, enables LIBCS.LIB, req. LIBCPATH # (e.g. LIBC=1 LIBCPATH=E:\OS2TK45\H\LIBC) # with Visual C++, enables MSVCRT.LIB (/MD) # USE_COLORS enable colored output # # IMPORTANT: Due to DOS path size limitations, the subdirectory names must be # as short as possible. # !ifndef MODE MODE = OS232 !endif !ifndef LOCALE LOCALE = en !endif !ifndef RESFILE RESFILE = resource\resource.txt !endif !ifndef C_DEFS C_DEFS = $(BASEDIR_T)c_defs.h !endif !ifndef ASM_DEFS ASM_DEFS = $(BASEDIR_T)asm_defs.inc !endif !ifdef COMMERCIAL PACKAGE = c !else PACKAGE = s !endif !ifdef DEBUG DEBUG_SM = d !else DEBUG_SM = r !endif ## ## DOS realmode section ## !if "$(MODE)" == "DOS16" OS_ID = DOS LZEXE = lzexe.exe CRP_OBJS_E = $(BASEDIR)\arjcrypt\det_x86.obj $(BASEDIR)\arjcrypt\gost_asm.obj ARJ_OBJS_E = $(BASEDIR)\arj\arj_xms.obj !ifndef COMPILER COMPILER = MSC7 !endif # # Assembly language options are the same - we'll use MASM everywhere # ASM = ml.exe ASMOPT = /I$(BASEDIR) /c /Fo$@ %s STD_ASMOPT = /DMODL=MEDIUM /DARJUTIL $(ASMOPT) STB_ASMOPT = /DMODL=SMALL /DSFXSTUB $(ASMOPT) !if "$(COMPILER)" == "BC40" SFV_ASMOPT = /DMODL=MEDIUM /DARJSFX $(ASMOPT) !else SFV_ASMOPT = /DMODL=SMALL /DARJSFX $(ASMOPT) !endif SFX_ASMOPT = /DMODL=SMALL /DARJSFX /DNO_FAR $(ASMOPT) SFJ_ASMOPT = /DMODL=SMALL /DARJSFXJR /DNO_FAR $(ASMOPT) REJ_ASMOPT = /DMODL=SMALL /DREARJ /DNO_FAR $(ASMOPT) REG_ASMOPT = /DMODL=SMALL /DREGISTER /DNO_FAR $(ASMOPT) ADI_ASMOPT = /DMODL=SMALL /DARJDISP /DNO_FAR $(ASMOPT) CRP_ASMOPT = /DMODL=SMALL $(ASMOPT) # # Borland C compilers section # !if "$(COMPILER)" == "TC10" CC_CODE = $(COMPILER) CC = tcc.exe COPT = -I$(BASEDIR) -o$@ @settings\$(CC_CODE).sts %s LINKER = tlink.exe LINKLIB = E:\LANG\TCC10\LIB^\ LINKOPT = !else if "$(COMPILER)" == "BC31" CC_CODE = $(COMPILER) CC = bcc.exe LINKER = tlink.exe COPT = -I$(BASEDIR) -o$@ @settings\$(CC_CODE).sts %s LINKLIB = LINKOPT = !else if "$(COMPILER)" == "BC40" CC_CODE = $(COMPILER) CC = bcc.exe LINKER = tlink.exe COPT = -I$(BASEDIR) -o$@ @settings\$(CC_CODE).sts %s LINKLIB = LINKOPT = !endif !if "$(COMPILER)" == "TC10"||"$(COMPILER)" == "BC31"||"$(COMPILER)" == "BC40" # Executables ARJ = arj.exe ARJSFXV = arjsfxv.exe ARJSFX = arjsfx.exe ARJSFXJR = arjsfxjr.exe ARJCRYPT = arjcrypt.com REARJ = rearj.exe REGISTER = register.exe ARJDISP = arjdisp.exe POSTPROC = postproc.exe JOIN = join.exe MSGBIND = msgbind.exe TODAY = today.exe MAKE_KEY = make_key.exe PACKAGER = packager.exe MAKESTUB = makestub.exe SFXSTUB = sfxstub.exe # C options STD_COPT = -mm -DARJUTIL $(COPT) ARJ_COPT = -mm -DSFL=4 $(COPT) !if "$(COMPILER)" == "BC40" SFV_COPT = -mm -DSFL=3 $(COPT) REJ_COPT = -mm -DREARJ $(COPT) !else SFV_COPT = -ms -DSFL=3 $(COPT) REJ_COPT = -ms -DREARJ $(COPT) !endif SFX_COPT = -ms -DSFL=2 $(COPT) SFJ_COPT = -ms -DSFL=1 $(COPT) REG_COPT = -ms -DREGISTER $(COPT) ADI_COPT = -ms -DARJDISP $(COPT) FAR_COPT = -zRA -zSA -zTFAR_DATA $(ARJ_COPT) FDS_COPT = -zRF -zSF -zTFAR_DATA $(ARJ_COPT) NEAR_COPT = -zC_TEXT $(ARJ_COPT) CRP_COPT = -mt $(COPT) # Linkup objects STD_OBJ = $(LINKLIB)c0m ARJ_OBJ = $(LINKLIB)c0m STB_OBJ = !if "$(COMPILER)" == "BC40" SFV_OBJ = $(LINKLIB)c0m REJ_OBJ = $(LINKLIB)c0m !else SFV_OBJ = $(LINKLIB)c0s REJ_OBJ = $(LINKLIB)c0s !endif SFX_OBJ = $(LINKLIB)c0s SFJ_OBJ = $(LINKLIB)c0s REG_OBJ = $(LINKLIB)c0s ADI_OBJ = $(LINKLIB)c0s CRP_OBJ = /t $(LINKLIB)c0t # Supplemental objects ARJ_OBJS_S = $(BASEDIR)\arj\fmemcmp.obj # Libraries STD_LIB = $(LINKLIB)cm ARJ_LIB = $(LINKLIB)cm STB_LIB = !if "$(COMPILER)" == "BC40" SFV_LIB = $(LINKLIB)cm REJ_LIB = $(LINKLIB)cm !else SFV_LIB = $(LINKLIB)cs REJ_LIB = $(LINKLIB)cs !endif SFX_LIB = $(LINKLIB)cs SFJ_LIB = $(LINKLIB)cs REG_LIB = $(LINKLIB)cs ADI_LIB = $(LINKLIB)cs CRP_LIB = $(LINKLIB)cs !endif LRF = echo > NUL # # Microsoft C compilers section # !if "$(COMPILER)" == "MSC6" CC_CODE = $(COMPILER) CC = cl.exe COPT = /I$(BASEDIR) /Fo$@ %s NEARPOPT = LINKER = link.exe LINKLIB = LINKOPT = /NOE !else if "$(COMPILER)" == "MSC7"||"$(COMPILER)" == "MSVC10"||"$(COMPILER)" == "MSVC15" CC_CODE = $(COMPILER) CC = cl.exe LINKER = link.exe COPT = /I$(BASEDIR) /Fo$@ @settings\$(CC_CODE).sts %s NEARPOPT = /Gx LINKLIB = LINKOPT = /NOE !else if "$(COMPILER)" == "QC25" CC_CODE = $(COMPILER) !if "$(COMPILER)" == "QC25" CC = _qcl.exe LINKER = qlink.exe !else CC = cl.exe LINKER = link.exe !endif COPT = /I$(BASEDIR) /I. /Fo$@ /Gs /Zp /c %s MSC_OPT = /Olrg LINKLIB = LINKOPT = /NOE !endif !if "$(COMPILER)" == "MSC6"||"$(COMPILER)" == "MSC7"||"$(COMPILER)" == "MSVC10"||"$(COMPILER)" == "MSVC15"||"$(COMPILER)" == "QC25" # Executables ARJ = arj.exe ARJSFXV = arjsfxv.exe ARJSFX = arjsfx.exe ARJSFXJR = arjsfxjr.exe ARJCRYPT = arjcrypt.com REARJ = rearj.exe REGISTER = register.exe ARJDISP = arjdisp.exe POSTPROC = postproc.exe JOIN = join.exe MSGBIND = msgbind.exe TODAY = today.exe MAKE_KEY = make_key.exe PACKAGER = packager.exe MAKESTUB = makestub.exe SFXSTUB = sfxstub.exe # C options !if "$(COMPILER)" == "QC25"||"$(FORCE_MSGRAPH)" != "" MEM_MARGINAL = /AM !else MEM_MARGINAL = /AS !endif STD_COPT = $(MSC_OPT) /AM /DARJUTIL $(COPT) ARJ_COPT = $(MSC_OPT) /AM /DSFL=4 $(COPT) SFV_COPT = $(MSC_OPT) $(MEM_MARGINAL) /DSFL=3 $(COPT) SFX_COPT = $(MSC_OPT) /AS /DSFL=2 $(COPT) SFJ_COPT = $(MSC_OPT) /AS /DSFL=1 $(COPT) REJ_COPT = $(MSC_OPT) $(MEM_MARGINAL) /DREARJ $(COPT) REG_COPT = $(MSC_OPT) /AS /DREGISTER $(COPT) ADI_COPT = $(MSC_OPT) /AS /DARJDISP $(COPT) FAR_COPT = /NDARJ_MSG $(NEARP_OPT) $(ARJ_COPT) FDS_COPT = /NDFARD_SEG $(ARJ_COPT) NEAR_COPT = /NT_TEXT $(ARJ_COPT) CRP_COPT = /Ot /AT $(COPT) # Linkup objects STD_OBJ = /STACK:8192 ARJ_OBJ = /STACK:6144 $(LINKLIB)VARSTCK STB_OBJ = SFV_OBJ = /STACK:8192 $(LINKLIB)VARSTCK SFX_OBJ = /STACK:4096 $(LINKLIB)VARSTCK SFJ_OBJ = /STACK:2048 $(LINKLIB)VARSTCK REJ_OBJ = /STACK:8192 $(LINKLIB)VARSTCK REG_OBJ = ADI_OBJ = CRP_OBJ = /TINY $(LINKLIB)CRTCOM.LIB # Supplemental objects # Libraries STD_LIB = $(LINKLIB) !ifdef FORCE_MSGRAPH ARJ_LIB = $(LINKLIB)+$(LINKLIB)graphics SFV_LIB = $(LINKLIB)+$(LINKLIB)graphics ADI_LIB = $(LINKLIB)+$(LINKLIB)graphics REJ_LIB = $(LINKLIB)+$(LINKLIB)graphics !else ARJ_LIB = $(LINKLIB) SFV_LIB = $(LINKLIB) ADI_LIB = $(LINKLIB) REJ_LIB = $(LINKLIB) !endif STB_LIB = SFX_LIB = $(LINKLIB) SFJ_LIB = $(LINKLIB) REG_LIB = $(LINKLIB) CRP_LIB = $(LINKLIB) !endif LRF = echo > NUL !endif ## ## OS/2 protected mode section ## !if "$(MODE)" == "OS216" OS_ID = OS2 !ifndef COMPILER COMPILER = MSC6 !endif # # Assembly language options are the same - we'll use MASM everywhere # ASM = ml.exe ASMOPT = /I$(BASEDIR) /c /Fo$@ %s STD_ASMOPT = /DMODL=MEDIUM /DARJUTIL $(ASMOPT) STB_ASMOPT = /DMODL=SMALL /DSFXSTUB $(ASMOPT) SFV_ASMOPT = /DMODL=SMALL /DARJSFX $(ASMOPT) SFX_ASMOPT = /DMODL=SMALL /DARJSFX /DNO_FAR $(ASMOPT) SFJ_ASMOPT = /DMODL=SMALL /DARJSFXJR /DNO_FAR $(ASMOPT) REJ_ASMOPT = /DMODL=SMALL /DREARJ /DNO_FAR $(ASMOPT) REG_ASMOPT = /DMODL=SMALL /DREGISTER /DNO_FAR $(ASMOPT) ADI_ASMOPT = /DMODL=SMALL /DARJDISP /DNO_FAR $(ASMOPT) CRP_ASMOPT = /DMODL=SMALL $(ASMOPT) # # Microsoft C v 6.0 compiler # !if "$(COMPILER)" == "MSC6" CC_CODE = $(COMPILER)_OS2 CC = cl.exe !ifdef DEBUG MSCDBG = /Zd MSLINKDBG = /CODEVIEW /MAP:full MAKESYM = 1 !endif COPT = /I$(BASEDIR) /I. /Fo$@ $(MSCDBG) %s NEARPOPT = LINKER = link.exe LINKLIB = LINKOPT = /NOE /PMTYPE:VIO # Executables ARJ = arj.exe ARJSFXV = arjsfxv.exe ARJSFX = arjsfx.exe ARJSFXJR = arjsfxjr.exe ARJCRYPT = arjcrypt.dll REARJ = rearj.exe REGISTER = register.exe ARJDISP = arjdisp.exe POSTPROC = postproc.exe JOIN = join.exe MSGBIND = msgbind.exe TODAY = today.exe MAKE_KEY = make_key.exe PACKAGER = packager.exe MAKESTUB = makestub.exe SFXSTUB = sfxstub.exe # C options STD_COPT = /Olrg /AM /DARJUTIL $(COPT) ARJ_COPT = /Olrg /AM /DSFL=4 $(COPT) SFV_COPT = /Olrg /AS /DSFL=3 $(COPT) SFX_COPT = /Olrg /AS /DSFL=2 $(COPT) SFJ_COPT = /Olrg /AS /DSFL=1 $(COPT) REJ_COPT = /Olrg /AS /DREARJ $(COPT) REG_COPT = /Olrg /AS /DREGISTER $(COPT) ADI_COPT = /Olrg /AS /DARJDISP $(COPT) FAR_COPT = /Olrg /NDARJ_MSG $(NEARP_OPT) $(ARJ_COPT) FDS_COPT = /NDFARD_SEG $(ARJ_COPT) NEAR_COPT = /NT_TEXT $(ARJ_COPT) CRP_COPT = /Ot /ALw /Zl $(COPT) # Linkup objects STD_OBJ = $(MSLINKDBG) /STACK:8192 ARJ_OBJ = $(MSLINKDBG) /STACK:6144 $(LINKLIB)VARSTCK STB_OBJ = $(MSLINKDBG) SFV_OBJ = $(MSLINKDBG) /EXEPACK /STACK:6144 $(LINKLIB)VARSTCK SFX_OBJ = $(MSLINKDBG) /EXEPACK /STACK:6144 $(LINKLIB)VARSTCK SFJ_OBJ = $(MSLINKDBG) /EXEPACK /STACK:2048 $(LINKLIB)VARSTCK REJ_OBJ = $(MSLINKDBG) /STACK:10240 $(LINKLIB)VARSTCK REG_OBJ = $(MSLINKDBG) ADI_OBJ = $(MSLINKDBG) /EXEPACK $(APILMR) CRP_OBJ = $(MSLINKDBG) /STACK:2048 # Supplemental objects # Libraries STD_LIB = $(LINKLIB)OS2+$(LINKLIB)MLIBCEP ARJ_LIB = $(LINKLIB)OS2+$(LINKLIB)MLIBEEP STB_LIB = $(LINKLIB)OS2 SFV_LIB = $(LINKLIB)OS2+$(LINKLIB)SLIBEEP SFX_LIB = $(LINKLIB)OS2+$(LINKLIB)SLIBEEP SFJ_LIB = $(LINKLIB)OS2+$(LINKLIB)SLIBEEP REJ_LIB = $(LINKLIB)OS2+$(LINKLIB)SLIBCEP REG_LIB = $(LINKLIB)OS2+$(LINKLIB)SLIBEEP ADI_LIB = $(LINKLIB)OS2+$(LINKLIB)SLIBCEP CRP_LIB = $(LINKLIB)OS2+$(LINKLIB)LLIBCDLL # New executable definitions STD_DEF = $(CC_CODE)\default.def ARJ_DEF = $(CC_CODE)\arj.def STB_DEF = $(CC_CODE)\sfxstub.def SFV_DEF = $(CC_CODE)\arjsfxv.def SFX_DEF = $(CC_CODE)\arjsfx.def SFJ_DEF = $(CC_CODE)\arjsfxjr.def REJ_DEF = $(CC_CODE)\rearj.def REG_DEF = $(CC_CODE)\register.def ADI_DEF = $(CC_CODE)\arjdisp.def CRP_DEF = $(CC_CODE)\arjcrypt.def !endif LRF = echo > NUL !endif ## ## OS/2 protected mode LX section ## !if "$(MODE)" == "OS232" OS_ID = OS2 !ifndef COMPILER COMPILER = VACPP !endif # # Assembly language options are the same - we'll use MASM everywhere # ASM = ml.exe ASMOPT = /I$(BASEDIR) /c /Fo$@ %s STD_ASMOPT = /DMODL=FLAT /DARJUTIL $(ASMOPT) STB_ASMOPT = /DMODL=FLAT /DSFXSTUB $(ASMOPT) SFV_ASMOPT = /DMODL=FLAT /DARJSFX $(ASMOPT) SFX_ASMOPT = /DMODL=FLAT /DARJSFX $(ASMOPT) SFJ_ASMOPT = /DMODL=FLAT /DARJSFXJR /DNO_FAR $(ASMOPT) REJ_ASMOPT = /DMODL=FLAT /DREARJ /DNO_FAR $(ASMOPT) REG_ASMOPT = /DMODL=FLAT /DREGISTER /DNO_FAR $(ASMOPT) ADI_ASMOPT = /DMODL=FLAT /DARJDISP /DNO_FAR $(ASMOPT) CRP_ASMOPT = /DMODL=FLAT $(ASMOPT) # # IBM C Set/2 v 2.xx or 3.65 # !if "$(COMPILER)" == "CSET2" || "$(COMPILER)" == "VACPP" CC_CODE = $(COMPILER) CC = icc.exe !ifdef LIBC LIBCKLUDGE = /Rn /Gp /Gn- /I$(LIBCPATH) !else LIBCKLUDGE = !endif !ifdef DEBUG CSETDBG = /Ti+ CLNKDBG = /DE /MAP:full NP_SFX = 1 MAKESYM = 1 !else !if "$(COMPILER)" == "CSET2" CSETSTK = /Gs- CSETDBG = /Gi /O /Oi- !else CSETDBG = /Gi VAC_SPEED = /O /Oi- VAC_SIZE = /Oc !endif !endif !if "$(COMPILER)" == "VACPP" VACPP_COPT = /Gs /qarch=x86 /qnoro /qtune=pentium2 /Wpro- /Wcnd- !else VACPP_COPT = /G4 !endif COPT = /I$(BASEDIR) /Fo$@ /c /Sp /I. $(LIBCKLUDGE) $(CSETDBG) $(VACPP_COPT) /Tl5 %s NEARPOPT = !if "$(COMPILER)" == "VACPP" LINKER = ilink.exe /NOFREE !else LINKER = link386.exe !endif # C options STD_COPT = $(VAC_SIZE) $(CSETSTK) /DARJUTIL $(COPT) ARJ_COPT = $(VAC_SPEED) $(CSETSTK) /DSFL=4 $(COPT) ARJ_RECOPT = $(VAC_SIZE) $(CSETSTK) /DSFL=4 $(COPT) SFV_COPT = $(VAC_SIZE) $(CSETSTK) /DSFL=3 $(COPT) SFX_COPT = $(VAC_SIZE) $(CSETSTK) /DSFL=2 $(COPT) SFJ_COPT = $(VAC_SIZE) $(CSETSTK) /DSFL=1 $(COPT) REJ_COPT = /Gs+ /DREARJ $(COPT) REG_COPT = $(VAC_SIZE) $(CSETSTK) /DREGISTER $(COPT) ADI_COPT = $(VAC_SIZE) $(CSETSTK) /DARJDISP $(COPT) FAR_COPT = $(NEARP_OPT) $(ARJ_COPT) FDS_COPT = /NDFARD_SEG $(ARJ_COPT) NEAR_COPT = $(CSETSTK) $(ARJ_COPT) CRP_COPT = /Ge- $(COPT) # LIBC hack for linking !ifdef LIBC !if "$(COMPILER)" == "VACPP" LINKLIB = LIBCSI+OS2386+VACPP\VACPP365 !else LINKLIB = LIBCS+OS2386 !endif LINKOPT = /NOD /NOE /PMTYPE:VIO WARPPACK = /EXEPACK:2 !else LINKLIB = LINKOPT = /NOE /PMTYPE:VIO WARPPACK = /EXEPACK !endif # Executables ARJ = arj.exe ARJSFXV = arjsfxv.exe ARJSFX = arjsfx.exe ARJSFXJR = arjsfxjr.exe ARJCRYPT = arjcrypt.dll REARJ = rearj.exe REGISTER = register.exe ARJDISP = arjdisp.exe POSTPROC = postproc.exe JOIN = join.exe MSGBIND = msgbind.exe TODAY = today.exe MAKE_KEY = make_key.exe PACKAGER = packager.exe MAKESTUB = makestub.exe SFXSTUB = sfxstub.exe # Linkup objects STD_OBJ = $(WARPPACK) /STACK:18432 ARJ_OBJ = /STACK:73728 STB_OBJ = $(WARPPACK) SFV_OBJ = $(WARPPACK) /STACK:16384 SFX_OBJ = $(WARPPACK) /STACK:16384 SFJ_OBJ = $(WARPPACK) /STACK:8192 REJ_OBJ = /STACK:73728 REG_OBJ = $(WARPPACK) ADI_OBJ = $(WARPPACK) CRP_OBJ = /STACK:2048 # Supplemental objects # Libraries STD_LIB = $(LINKLIB) ARJ_LIB = $(LINKLIB) STB_LIB = $(LINKLIB) SFV_LIB = $(LINKLIB) SFX_LIB = $(LINKLIB) SFJ_LIB = $(LINKLIB) REJ_LIB = $(LINKLIB) REG_LIB = $(LINKLIB) ADI_LIB = $(LINKLIB) CRP_LIB = $(LINKLIB) # New executable definitions STD_DEF = CSET2\default.def ARJ_DEF = CSET2\arj.def STB_DEF = CSET2\sfxstub.def SFV_DEF = CSET2\arjsfxv.def SFX_DEF = CSET2\arjsfx.def SFJ_DEF = CSET2\arjsfxjr.def REJ_DEF = CSET2\rearj.def REG_DEF = CSET2\register.def ADI_DEF = CSET2\arjdisp.def CRP_DEF = CSET2\arjcrypt.def # # MetaWare High C/C++ v 3.xx # !elseif "$(COMPILER)" == "HIGHC" CC_CODE = $(COMPILER) CC = hc.exe !ifdef DEBUG HCDBG = -g -on=Emit_names CLNKDBG = /DE /MAP:full NP_SFX = 1 MAKESYM = 1 !else HCDBG = HCOPTIM = -O7 -Hpentium -Hon=Optimize_FP -Hoff=BEHAVED !endif !ifdef LIBC HCLIBC = -I$(LIBCPATH) -D__EXTENDED__ !endif COPT = -I$(BASEDIR) -o $@ -c -I. $(HCDBG) $(HCLIBC) -Hpragma=Offwarn(553) %s NEARPOPT = LINKER = link386.exe # C options STD_COPT = -DARJUTIL $(HCOPTIM) $(COPT) ARJ_COPT = -DSFL=4 $(HCOPTIM) $(COPT) SFV_COPT = -DSFL=3 $(HCOPTIM) $(COPT) SFX_COPT = -DSFL=2 $(HCOPTIM) $(COPT) SFJ_COPT = -DSFL=1 $(HCOPTIM) $(COPT) REJ_COPT = -Hon=Check_stack -DREARJ $(HCOPTIM) $(COPT) REG_COPT = -DREGISTER $(HCOPTIM) $(COPT) ADI_COPT = -DARJDISP $(HCOPTIM) $(COPT) FAR_COPT = $(NEARP_OPT) $(HCOPTIM) $(ARJ_COPT) FDS_COPT = $(HCOPTIM) $(ARJ_COPT) NEAR_COPT = $(HCOPTIM) $(ARJ_COPT) CRP_COPT = $(COPT) # LIBC hack for linking !ifdef LIBC LINKLIB = HIGHC\HCD_OMF+OS2386+LIBCSS+HC LINKOPT = /NOD /NOE /PMTYPE:VIO WARPPACK = /EXEPACK:2 !else LINKLIB = HC+HCNA+OS2386 LINKOPT = /NOE /PMTYPE:VIO WARPPACK = /EXEPACK !endif # # OpenWatcom C/C++ # !elseif "$(COMPILER)" == "WATCOM" CC_CODE = WCC2_32 CC = wcc386.exe !ifdef DEBUG WCCDBG = -d2 -en CLNKDBG = /DE NP_SFX = 1 MAKESYM = 1 !else WCCDBG = -5 WCCSIZE = -os # This yields top speed but is pretty unsafe. See below. WCCSPD = -otx !endif !ifdef LIBC WCCLIBC = -i=$(LIBCPATH) -D__EXTENDED__ -zl -D_LNK_CONV=_System !endif COPT = -i=$(BASEDIR) -wcd=107 -fo=$@ -s -i=. $(WCCDBG) $(WCCLIBC) -ze %s NEARPOPT = LINKER = link386.exe # C options STD_COPT = -DARJUTIL $(WCCSIZE) $(COPT) ARJ_COPT = -DSFL=4 $(WCCSIZE) $(COPT) # This is a Watcom speed freak. Now we just have to set it by default. ARJ_COPTS = -DSFL=4 $(WCCSPD) $(COPT) SFV_COPT = -DSFL=3 $(WCCSIZE) $(COPT) SFX_COPT = -DSFL=2 $(WCCSIZE) $(COPT) SFJ_COPT = -DSFL=1 $(WCCSIZE) $(COPT) REJ_COPT = -DREARJ $(WCCSIZE) $(COPT) REG_COPT = -DREGISTER $(WCCSIZE) $(COPT) ADI_COPT = -DARJDISP $(WCCSIZE) $(COPT) FAR_COPT = $(NEARP_OPT) $(ARJ_COPT) FDS_COPT = $(ARJ_COPT) # One more fix for Watcom. NEAR_COPT = $(ARJ_COPTS) CRP_COPT = $(WCCSIZE) $(COPT) # LIBC hack for linking !ifdef LIBC LINKLIB = WCC2_32\OWATCOMR+OS2386+LIBCSS LINKOPT = /MAP:full /NOE /PMTYPE:VIO WARPPACK = /EXEPACK:2 !else !error Not supported! LINKLIB = WCC2_32\OWATCOMC+OS2386+clib3r LINKOPT = /MAP:full /NOD /NOE /PMTYPE:VIO WARPPACK = /EXEPACK !endif !endif # Linkup objects STD_OBJ = $(CLNKDBG) $(WARPPACK) /STACK:18432 ARJ_OBJ = $(CLNKDBG) /STACK:73728 STB_OBJ = $(CLNKDBG) $(WARPPACK) SFV_OBJ = $(CLNKDBG) $(WARPPACK) /STACK:16384 SFX_OBJ = $(CLNKDBG) $(WARPPACK) /STACK:16384 SFJ_OBJ = $(CLNKDBG) $(WARPPACK) /STACK:8192 REJ_OBJ = $(CLNKDBG) /STACK:73728 REG_OBJ = $(CLNKDBG) $(WARPPACK) /STACK:8192 ADI_OBJ = $(CLNKDBG) $(WARPPACK) /STACK:16384 CRP_OBJ = $(CLNKDBG) /STACK:2048 # Supplemental objects # Libraries STD_LIB = $(LINKLIB) ARJ_LIB = $(LINKLIB) STB_LIB = $(LINKLIB) SFV_LIB = $(LINKLIB) SFX_LIB = $(LINKLIB) SFJ_LIB = $(LINKLIB) REJ_LIB = $(LINKLIB) REG_LIB = $(LINKLIB) ADI_LIB = $(LINKLIB) CRP_LIB = $(LINKLIB) # New executable definitions STD_DEF = CSET2\default.def ARJ_DEF = CSET2\arj.def STB_DEF = CSET2\sfxstub.def SFV_DEF = CSET2\arjsfxv.def SFX_DEF = CSET2\arjsfx.def SFJ_DEF = CSET2\arjsfxjr.def REJ_DEF = CSET2\rearj.def REG_DEF = CSET2\register.def ADI_DEF = CSET2\arjdisp.def CRP_DEF = CSET2\arjcrypt.def # Executables ARJ = arj.exe ARJSFXV = arjsfxv.exe ARJSFX = arjsfx.exe ARJSFXJR = arjsfxjr.exe ARJCRYPT = arjcrypt.dll REARJ = rearj.exe REGISTER = register.exe ARJDISP = arjdisp.exe POSTPROC = postproc.exe JOIN = join.exe MSGBIND = msgbind.exe TODAY = today.exe MAKE_KEY = make_key.exe PACKAGER = packager.exe MAKESTUB = makestub.exe SFXSTUB = sfxstub.exe LRF = echo > NUL !endif ## ## Win32 PE section ## !if "$(MODE)" == "WIN32" OS_ID = WIN32 !ifndef COMPILER COMPILER = MSVC !endif # No assembler inlays anymore (use portable C snippets as in EMX) NO_ASM = 1 # For the free-form COFF MS Linker: NEWLINK = 1 # # Visual C++ v 2.20 (9.10) # !if "$(COMPILER)" == "MSVC" CC_CODE = $(COMPILER) CC = cl.exe !ifdef DEBUG ADD_COPT = /Ge /Zi /Od ADD_LINKOPT = /DEBUG !else MSVC_SIZE = /Os MSVC_SPEED = /Ot ADD_COPT = /G4 /Oy ADD_LINKOPT = /RELEASE /DEFAULTLIB:NTDLL !endif !ifdef LIBC LIBC_COPT = /MD !else LIBC_COPT = /ML !endif COPT = /c /I$(BASEDIR) /W2 /GX $(LIBC_COPT) $(ADD_COPT) /I. /Fo$@ %s LINKER = link.exe # C options STD_COPT = $(MSVC_SIZE) $(CSETSTK) /DARJUTIL $(COPT) ARJ_COPT = $(MSVC_SPEED) $(CSETSTK) /DSFL=4 $(COPT) ARJ_RECOPT = $(MSVC_SIZE) $(CSETSTK) /DSFL=4 $(COPT) SFV_COPT = $(MSVC_SIZE) $(CSETSTK) /DSFL=3 $(COPT) SFX_COPT = $(MSVC_SIZE) $(CSETSTK) /DSFL=2 $(COPT) SFJ_COPT = $(MSVC_SIZE) $(CSETSTK) /DSFL=1 $(COPT) REJ_COPT = /Ge /DREARJ $(COPT) REG_COPT = $(MSVC_SIZE) $(CSETSTK) /DREGISTER $(COPT) ADI_COPT = $(MSVC_SIZE) $(CSETSTK) /DARJDISP $(COPT) FAR_COPT = $(NEARP_OPT) $(ARJ_COPT) FDS_COPT = $(ARJ_COPT) NEAR_COPT = $(CSETSTK) $(ARJ_COPT) CRP_COPT = /LD /DDLL $(COPT) LINKLIB = largeint.lib LINKOPT = $(ADD_LINKOPT) # Executables ARJ = arj.exe ARJSFXV = arjsfxv.exe ARJSFX = arjsfx.exe ARJSFXJR = arjsfxjr.exe ARJCRYPT = arjcrypt.dll REARJ = rearj.exe REGISTER = register.exe ARJDISP = arjdisp.exe POSTPROC = postproc.exe JOIN = join.exe MSGBIND = msgbind.exe TODAY = today.exe MAKE_KEY = make_key.exe PACKAGER = packager.exe MAKESTUB = makestub.exe SFXSTUB = sfxstub.exe # Linkup objects STD_OBJ = /SUBSYSTEM:CONSOLE,3.10 /STACK:65536,32768 ARJ_OBJ = /SUBSYSTEM:CONSOLE,3.10 /STACK:73728,16384 STB_OBJ = /SUBSYSTEM:CONSOLE,3.10 SFV_OBJ = /SUBSYSTEM:CONSOLE,3.10 /STACK:65536,16384 SFX_OBJ = /SUBSYSTEM:CONSOLE,3.10 /STACK:65536,16384 SFJ_OBJ = /SUBSYSTEM:CONSOLE,3.10 /STACK:65536,8192 REJ_OBJ = /SUBSYSTEM:CONSOLE,3.10 /STACK:73728,24576 REG_OBJ = /SUBSYSTEM:CONSOLE,3.10 ADI_OBJ = /SUBSYSTEM:CONSOLE,3.10 CRP_OBJ = /SUBSYSTEM:WINDOWS,3.10 /DLL # Supplemental objects # Libraries STD_LIB = $(LINKLIB) ARJ_LIB = $(LINKLIB) STB_LIB = $(LINKLIB) SFV_LIB = $(LINKLIB) SFX_LIB = $(LINKLIB) SFJ_LIB = $(LINKLIB) REJ_LIB = $(LINKLIB) REG_LIB = $(LINKLIB) ADI_LIB = $(LINKLIB) CRP_LIB = $(LINKLIB) # Only declare some exports for the DLL CRP_DEF = /DEF:WIN32\arjcrypt.def !endif !endif !ifndef NEWLINK LAST_LINKOPT = ; !else MAP_LINKOPT = /MAP: OUT_LINKOPT = /OUT: LRF = echo !endif # Buggy optimizer treatment section: # # + Options for RECOVERY.C (the VisualAge C++ optimizer fails here) !ifndef ARJ_RECOPT ARJ_RECOPT = $(ARJ_COPT) !endif # + ARJ speed-optimized modules (encoding/decoding/security). !ifndef ARJ_COPTS ARJ_COPTS = $(ARJ_COPT) !endif # Base directory macros (one in UNIX format, for preprocessors to be happy) BASEDIR = $(CC_CODE)\$(LOCALE)\$(DEBUG_SM)$(PACKAGE) BASEDIR_T = $(CC_CODE)\$(LOCALE)\$(DEBUG_SM)$(PACKAGE)^\ BASEDIR_P = $(CC_CODE)\$(LOCALE)\$(DEBUG_SM)c BASEDIR_U = $(CC_CODE)/$(LOCALE)/$(DEBUG_SM)$(PACKAGE)/ .SUFFIXES: .c .asm .obj .exe # # Main dependency tree # all: init \ timestamp \ $(BASEDIR)\arj\$(ARJ) \ $(BASEDIR)\arjcrypt\$(ARJCRYPT) \ $(BASEDIR)\rearj\$(REARJ) \ $(BASEDIR)\register\$(REGISTER) \ $(BASEDIR)\arjdisp\$(ARJDISP) \ $(BASEDIR)\tools\$(PACKAGER) \ !ifdef COMMERCIAL $(BASEDIR)\tools\$(MAKE_KEY) \ !endif dispose # # Pre-compile initialization # init: @if exist $(BASEDIR_T)stubincl.inc del $(BASEDIR_T)stubincl.inc # Create C defines file @echo /* This is an automatically generated file */ >$(C_DEFS) !ifdef COMMERCIAL @echo #define COMMERCIAL >>$(C_DEFS) !endif !ifdef LIBC @echo #define LIBC >>$(C_DEFS) !endif !ifdef MAKESYM @echo #define MAKESYM >>$(C_DEFS) !endif !ifdef NP_SFX @echo #define NP_SFX >>$(C_DEFS) !endif !ifdef DEBUG @echo #define DEBUG >>$(C_DEFS) !endif !ifdef FORCE_MSGRAPH @echo #define FORCE_MSGRAPH >>$(C_DEFS) !endif !ifdef USE_COLORS @echo #define USE_COLORS >>$(C_DEFS) !endif @echo #define LOCALE LANG_$(LOCALE) >>$(C_DEFS) @echo #define LOCALE_DESC "$(LOCALE)" >>$(C_DEFS) !if "$(COMPILER)" != "HIGHC" @echo #define HAVE_MIN >>$(C_DEFS) @echo #define HAVE_MAX >>$(C_DEFS) !endif @echo #define HAVE_STRLWR >>$(C_DEFS) @echo #define HAVE_STRUPR >>$(C_DEFS) # Create ASM defines file @echo ; This is an automatically generated file >$(ASM_DEFS) !ifndef COMMERCIAL @echo NC_CRC EQU 1>>$(ASM_DEFS) !endif !ifdef DEBUG @echo DEBUG EQU 1>>$(ASM_DEFS) !endif !if "$(MODE)" == "OS232" @echo FLATMODE EQU 1>>$(ASM_DEFS) !endif !if "$(COMPILER)" == "MSC6"||"$(COMPILER)" == "MSC7"||"$(COMPILER)" == "MSVC10"||"$(COMPILER)" == "MSVC15"||"$(COMPILER)" == "QC25" @echo MSC EQU 1>>$(ASM_DEFS) !endif # Environment-specific preparations !if "$(MODE)" == "OS216"||"$(MODE)" == "OS232" !if "$(COMPILER)" != "HIGHC" @echo #define _OS2 >>$(C_DEFS) !endif @echo _OS2 EQU 1 >>$(ASM_DEFS) !endif !if "$(COMPILER)" == "MSC6" !if "$(MODE)" == "DOS16" @SET CL=/B1C1L /I. /c /Zp /Gs !else if "$(MODE)" == "OS216" @SET CL=/B2C2L /c /G2 /Zp /Gs /Lp /Zl !endif !endif # # Update timestamp file # timestamp: $(BASEDIR)\tools\$(TODAY) $(BASEDIR)\tools\$(TODAY) $(LOCALE) $(BASEDIR) # # Final cleanup # dispose: @if exist $(BASEDIR_T)stubincl.inc del $(BASEDIR_T)stubincl.inc @if exist $(C_DEFS) del $(C_DEFS) @if exist $(ASM_DEFS) del $(ASM_DEFS) !if "$(COMPILER)" == "MSC6" @SET CL= !endif # # Message resource compiler (must be the FIRST program to compile) # Timestamp utility # Comment creation utility # Postprocessing utility # Join utility # Stub message section converter # Packaging tool # $(BASEDIR)\tools\$(MSGBIND): \ $(BASEDIR)\tools\msgbind.obj \ $(BASEDIR)\tools\filemode.obj \ $(BASEDIR)\tools\arjdata.obj \ $(BASEDIR)\tools\crc32.obj $(LRF) @<<$(BASEDIR_T)msgbind.lrf !ifdef NEWLINK $(LINKOPT) $(STD_OBJ) $(**: = ^ ) !else $(LINKOPT) $(STD_OBJ) $(**: = +^ ) !endif $(OUT_LINKOPT)$@ $(MAP_LINKOPT)$(@R).map $(STD_LIB) << $(LINKER) @$(BASEDIR_T)msgbind.lrf$(LAST_LINKOPT) if exist $(BASEDIR_T)msgbind.lrf del $(BASEDIR_T)msgbind.lrf $(BASEDIR)\tools\$(TODAY): \ $(BASEDIR)\tools\today.obj \ $(BASEDIR)\tools\filemode.obj $(LRF) @<<$(BASEDIR_T)today.lrf !ifdef NEWLINK $(LINKOPT) $(STD_OBJ) $(**: = ^ ) !else $(LINKOPT) $(STD_OBJ) $(**: = +^ ) !endif $(OUT_LINKOPT)$@ $(MAP_LINKOPT)$(@R).map $(STD_LIB) << $(LINKER) @$(BASEDIR_T)today.lrf$(LAST_LINKOPT) if exist $(BASEDIR_T)today.lrf del $(BASEDIR_T)today.lrf $(BASEDIR)\tools\$(MAKE_KEY): \ $(BASEDIR)\tools\make_key.obj \ $(BASEDIR)\tools\crc32.obj \ $(BASEDIR)\tools\misc.obj \ $(BASEDIR)\tools\arj_proc.obj \ $(BASEDIR)\tools\arjsec_h.obj \ $(BASEDIR)\tools\arjsec_l.obj $(LRF) @<<$(BASEDIR_T)make_key.lrf !ifdef NEWLINK $(LINKOPT) $(STD_OBJ) $(**: = ^ ) !else $(LINKOPT) $(STD_OBJ) $(**: = +^ ) !endif $(OUT_LINKOPT)$@ $(MAP_LINKOPT)$(@R).map $(STD_LIB) << $(LINKER) @$(BASEDIR_T)make_key.lrf$(LAST_LINKOPT) if exist $(BASEDIR_T)make_key.lrf del $(BASEDIR_T)make_key.lrf $(BASEDIR)\tools\$(POSTPROC): \ $(BASEDIR)\tools\postproc.obj \ $(BASEDIR)\tools\filemode.obj \ $(BASEDIR)\tools\crc32.obj $(LRF) @<<$(BASEDIR_T)postproc.lrf !ifdef NEWLINK $(LINKOPT) $(STD_OBJ) $(**: = ^ ) !else $(LINKOPT) $(STD_OBJ) $(**: = +^ ) !endif $(OUT_LINKOPT)$@ $(MAP_LINKOPT)$(@R).map $(STD_LIB) $(STD_DEF) << $(LINKER) @$(BASEDIR_T)postproc.lrf$(LAST_LINKOPT) if exist $(BASEDIR_T)postproc.lrf del $(BASEDIR_T)postproc.lrf $(BASEDIR)\tools\$(JOIN): \ $(BASEDIR)\tools\join.obj \ $(BASEDIR)\tools\filemode.obj $(LRF) @<<$(BASEDIR_T)join.lrf !ifdef NEWLINK $(LINKOPT) $(STD_OBJ) $(**: = ^ ) !else $(LINKOPT) $(STD_OBJ) $(**: = +^ ) !endif $(OUT_LINKOPT)$@ $(MAP_LINKOPT)$(@R).map $(STD_LIB) $(STD_DEF) << $(LINKER) @$(BASEDIR_T)join.lrf$(LAST_LINKOPT) if exist $(BASEDIR_T)join.lrf del $(BASEDIR_T)join.lrf $(BASEDIR)\tools\$(MAKESTUB): \ $(BASEDIR)\tools\makestub.obj \ $(BASEDIR)\tools\filemode.obj \ $(BASEDIR)\tools\nmsg_stb.obj $(LRF) @<<$(BASEDIR_T)makestub.lrf !ifdef NEWLINK $(LINKOPT) $(STD_OBJ) $(**: = ^ ) !else $(LINKOPT) $(STD_OBJ) $(**: = +^ ) !endif $(OUT_LINKOPT)$@ $(MAP_LINKOPT)$(@R).map $(STD_LIB) $(STD_DEF) << $(LINKER) @$(BASEDIR_T)makestub.lrf$(LAST_LINKOPT) if exist $(BASEDIR_T)makestub.lrf del $(BASEDIR_T)makestub.lrf $(BASEDIR)\tools\$(PACKAGER): \ $(BASEDIR)\tools\packager.obj \ $(BASEDIR)\tools\filemode.obj \ $(BASEDIR)\tools\arjdata.obj $(LRF) @<<$(BASEDIR_T)packager.lrf !ifdef NEWLINK $(LINKOPT) $(STD_OBJ) $(**: = ^ ) !else $(LINKOPT) $(STD_OBJ) $(**: = +^ ) !endif $(OUT_LINKOPT)$@ $(MAP_LINKOPT)$(@R).map $(STD_LIB) << $(LINKER) @$(BASEDIR_T)packager.lrf$(LAST_LINKOPT) if exist $(BASEDIR_T)packager.lrf del $(BASEDIR_T)packager.lrf $(BASEDIR)\tools\msgbind.obj: msgbind.c $(CC) $(STD_COPT) $(BASEDIR)\tools\today.obj: today.c $(CC) $(STD_COPT) $(BASEDIR)\tools\make_key.obj: make_key.c $(CC) $(STD_COPT) $(BASEDIR)\tools\postproc.obj: postproc.c $(CC) $(STD_COPT) $(BASEDIR)\tools\join.obj: join.c $(CC) $(STD_COPT) $(BASEDIR)\tools\makestub.obj: makestub.c $(BASEDIR)\nmsg_stb.c $(CC) $(STD_COPT) $(BASEDIR)\tools\packager.obj: packager.c $(CC) $(STD_COPT) $(BASEDIR)\tools\arjdata.obj: arjdata.c $(CC) $(STD_COPT) $(BASEDIR)\tools\filemode.obj: filemode.c $(CC) $(STD_COPT) $(BASEDIR)\tools\crc32.obj: crc32.c $(CC) $(STD_COPT) $(BASEDIR)\tools\misc.obj: misc.c $(CC) $(STD_COPT) $(BASEDIR)\tools\arjsec_h.obj: arjsec_h.c $(CC) $(STD_COPT) $(BASEDIR)\tools\arjsec_l.obj: arjsec_l.c $(CC) $(STD_COPT) $(BASEDIR)\tools\nmsg_stb.obj: $(BASEDIR)\nmsg_stb.c $(CC) $(STD_COPT) $(BASEDIR)\nmsg_stb.c: $(BASEDIR)\tools\$(MSGBIND) $(RESFILE) $(BASEDIR)\tools\msgbind $(RESFILE) msg_stb $(OS_ID) $(PACKAGE) $(LOCALE) $(BASEDIR) # # ARJCRYPT utility # CRP_OBJS = $(BASEDIR)\arjcrypt\arjcrypt.obj \ $(BASEDIR)\arjcrypt\integr.obj \ $(BASEDIR)\arjcrypt\gost.obj \ $(BASEDIR)\arjcrypt\gost_t.obj \ $(BASEDIR)\arjcrypt\nmsg_crp.obj \ $(CRP_OBJS_E) $(BASEDIR)\arjcrypt\$(ARJCRYPT): $(CRP_OBJS) \ $(BASEDIR)\tools\$(POSTPROC) $(LRF) @<<$(BASEDIR_T)arjcrypt.lrf !ifdef NEWLINK $(LINKOPT) $(CRP_OBJ) $(CRP_OBJS: = ^ ) !else $(LINKOPT) $(CRP_OBJ) $(CRP_OBJS: = +^ ) !endif $(OUT_LINKOPT)$@ $(MAP_LINKOPT)$(@R).map $(CRP_LIB) $(CRP_DEF) << $(LINKER) @$(BASEDIR_T)arjcrypt.lrf$(LAST_LINKOPT) if exist $(BASEDIR_T)arjcrypt.lrf del $(BASEDIR_T)arjcrypt.lrf $(BASEDIR)\tools\postproc $(BASEDIR)\arjcrypt\$(ARJCRYPT) !ifndef NO_ASM $(BASEDIR)\arjcrypt\integr.obj: integr.asm $(ASM) $(CRP_ASMOPT) !else $(BASEDIR)\arjcrypt\integr.obj: integr.c $(CC) $(CRP_COPT) !endif $(BASEDIR)\arjcrypt\gost.obj: gost.c $(CC) $(CRP_COPT) $(BASEDIR)\arjcrypt\gost_t.obj: gost_t.c $(CC) $(CRP_COPT) $(BASEDIR)\arjcrypt\arjcrypt.obj: arjcrypt.c $(BASEDIR)\nmsg_crp.c $(CC) $(CRP_COPT) !if "$(MODE)"=="DOS16" $(BASEDIR)\arjcrypt\det_x86.obj: det_x86.asm $(ASM) $(CRP_ASMOPT) !endif $(BASEDIR)\arjcrypt\nmsg_crp.obj: $(BASEDIR)\nmsg_crp.c $(CC) $(CRP_COPT) !if "$(MODE)"=="DOS16" $(BASEDIR)\arjcrypt\gost_asm.obj: gost_asm.asm $(ASM) $(CRP_ASMOPT) !endif arjcrypt.c: $(BASEDIR)\nmsg_crp.c $(BASEDIR)\nmsg_crp.c: $(BASEDIR)\tools\$(MSGBIND) $(RESFILE) $(BASEDIR)\tools\msgbind $(RESFILE) msg_crp $(OS_ID) $(PACKAGE) $(LOCALE) $(BASEDIR) # # SFX stub # STB_OBJS = $(BASEDIR)\sfxstub\sfxstub.obj \ !ifdef NO_ASM $(BASEDIR)\tools\nmsg_stb.obj !endif $(BASEDIR)\sfxstub\$(SFXSTUB): $(STB_OBJS) $(LRF) @<<$(BASEDIR_T)sfxstub.lrf !ifdef NEWLINK $(LINKOPT) $(STB_OBJ) $(STB_OBJS: = ^ ) !else $(LINKOPT) $(STB_OBJ) $(STB_OBJS: = +^ ) !endif $(OUT_LINKOPT)$@ $(MAP_LINKOPT)$(@R).map $(STB_LIB) $(STB_DEF) << $(LINKER) @$(BASEDIR_T)sfxstub.lrf$(LAST_LINKOPT) if exist $(BASEDIR_T)sfxstub.lrf del $(BASEDIR_T)sfxstub.lrf $(BASEDIR)\tools\postproc $(BASEDIR)\sfxstub\$(SFXSTUB) -sfx !ifndef NO_ASM $(BASEDIR)\sfxstub\sfxstub.obj: sfxstub.asm $(BASEDIR)\tools\$(MAKESTUB) $(BASEDIR)\tools\$(MAKESTUB) $(BASEDIR_T)stubincl.inc $(ASM) $(STB_ASMOPT) !else $(BASEDIR)\sfxstub\sfxstub.obj: sfxstub.c $(BASEDIR)\tools\nmsg_stb.obj $(BASEDIR)\tools\$(POSTPROC) $(CC) -I$(BASEDIR) -DSFXSTUB $(COPT) !endif # # ARJSFXV module # SFV_OBJS = $(BASEDIR)\arjsfxv\arjsfxv.obj \ $(BASEDIR)\arjsfxv\sfx_id.obj \ $(BASEDIR)\arjsfxv\filemode.obj \ $(BASEDIR)\arjsfxv\date_sig.obj \ $(BASEDIR)\arjsfxv\fmsg_sfv.obj \ $(BASEDIR)\arjsfxv\imsg_sfv.obj \ $(BASEDIR)\arjsfxv\nmsg_sfv.obj \ $(BASEDIR)\arjsfxv\decode.obj \ $(BASEDIR)\arjsfxv\fardata.obj \ $(BASEDIR)\arjsfxv\arj_user.obj \ $(BASEDIR)\arjsfxv\arj_arcv.obj \ $(BASEDIR)\arjsfxv\arj_file.obj \ $(BASEDIR)\arjsfxv\crc32.obj \ $(BASEDIR)\arjsfxv\misc.obj \ $(BASEDIR)\arjsfxv\debug.obj \ $(BASEDIR)\arjsfxv\arj_proc.obj \ $(BASEDIR)\arjsfxv\environ.obj \ $(BASEDIR)\arjsfxv\ntstream.obj \ $(BASEDIR)\arjsfxv\ea_mgr.obj \ $(BASEDIR)\arjsfxv\uxspec.obj \ $(BASEDIR)\arjsfxv\ext_hdr.obj \ $(BASEDIR)\arjsfxv\arjtypes.obj \ $(BASEDIR)\arjsfxv\exe_sear.obj \ $(BASEDIR)\arjsfxv\chk_fmsg.obj \ $(BASEDIR)\arjsfxv\filelist.obj \ $(BASEDIR)\arjsfxv\arjsec_h.obj \ !ifdef COMMERCIAL $(BASEDIR)\arjsfxv\arjsec_l.obj \ !endif $(BASEDIR)\arjsfxv\garble.obj \ $(BASEDIR)\arjsfxv\scrnio.obj \ $(BASEDIR)\arjsfxv\ansi.obj \ $(BASEDIR)\arjsfxv\externs.obj $(BASEDIR)\arjsfxv\$(ARJSFXV): $(SFV_OBJS) \ $(BASEDIR)\tools\$(POSTPROC) $(LRF) @<<$(BASEDIR_T)arjsfxv.lrf !ifdef NEWLINK $(LINKOPT) $(SFV_OBJ) $(SFV_OBJS: = ^ ) !else $(LINKOPT) $(SFV_OBJ) $(SFV_OBJS: = +^ ) !endif $(OUT_LINKOPT)$@ $(MAP_LINKOPT)$(@R).map $(SFV_LIB) $(SFV_DEF) << $(LINKER) @$(BASEDIR_T)arjsfxv.lrf$(LAST_LINKOPT) if exist $(BASEDIR_T)arjsfxv.lrf del $(BASEDIR_T)arjsfxv.lrf $(BASEDIR)\tools\postproc $(BASEDIR)\arjsfxv\$(ARJSFXV) -sfx !ifndef NO_ASM $(BASEDIR)\arjsfxv\sfx_id.obj: sfx_id.asm $(ASM) $(SFV_ASMOPT) !else $(BASEDIR)\arjsfxv\sfx_id.obj: sfx_id.c $(CC) $(SFV_COPT) !endif $(BASEDIR)\arjsfxv\filemode.obj: filemode.c $(CC) $(SFV_COPT) $(BASEDIR)\arjsfxv\date_sig.obj: $(BASEDIR)\date_sig.c $(CC) $(SFV_COPT) $(BASEDIR)\arjsfxv\fmsg_sfv.obj: $(BASEDIR)\fmsg_sfv.c $(CC) $(SFV_COPT) $(BASEDIR)\arjsfxv\imsg_sfv.obj: $(BASEDIR)\imsg_sfv.c $(CC) $(SFV_COPT) $(BASEDIR)\arjsfxv\nmsg_sfv.obj: $(BASEDIR)\nmsg_sfv.c $(CC) $(SFV_COPT) $(BASEDIR)\arjsfxv\decode.obj: decode.c $(CC) $(SFV_COPT) $(BASEDIR)\arjsfxv\arjsfxv.obj: arjsfx.c $(BASEDIR)\fmsg_sfv.c $(CC) $(SFV_COPT) $(BASEDIR)\arjsfxv\fardata.obj: fardata.c $(CC) $(SFV_COPT) $(BASEDIR)\arjsfxv\arj_user.obj: arj_user.c $(CC) $(SFV_COPT) $(BASEDIR)\arjsfxv\arj_arcv.obj: arj_arcv.c $(CC) $(SFV_COPT) $(BASEDIR)\arjsfxv\arj_file.obj: arj_file.c $(CC) $(SFV_COPT) $(BASEDIR)\arjsfxv\crc32.obj: crc32.c $(CC) $(SFV_COPT) $(BASEDIR)\arjsfxv\misc.obj: misc.c $(CC) $(SFV_COPT) $(BASEDIR)\arjsfxv\debug.obj: debug.c $(CC) $(SFV_COPT) $(BASEDIR)\arjsfxv\arj_proc.obj: arj_proc.c $(CC) $(SFV_COPT) $(BASEDIR)\arjsfxv\environ.obj: environ.c $(CC) $(SFV_COPT) $(BASEDIR)\arjsfxv\ntstream.obj: ntstream.c $(CC) $(SFV_COPT) $(BASEDIR)\arjsfxv\ea_mgr.obj: ea_mgr.c $(CC) $(SFV_COPT) $(BASEDIR)\arjsfxv\uxspec.obj: uxspec.c $(CC) $(SFV_COPT) $(BASEDIR)\arjsfxv\ext_hdr.obj: ext_hdr.c $(CC) $(SFV_COPT) $(BASEDIR)\arjsfxv\arjtypes.obj: arjtypes.c $(CC) $(SFV_COPT) $(BASEDIR)\arjsfxv\exe_sear.obj: exe_sear.c $(CC) $(SFV_COPT) $(BASEDIR)\arjsfxv\chk_fmsg.obj: chk_fmsg.c $(BASEDIR)\msg_sfv.h $(CC) $(SFV_COPT) $(BASEDIR)\arjsfxv\filelist.obj: filelist.c $(CC) $(SFV_COPT) $(BASEDIR)\arjsfxv\arjsec_h.obj: arjsec_h.c $(CC) $(SFV_COPT) $(BASEDIR)\arjsfxv\arjsec_l.obj: arjsec_l.c $(CC) $(SFV_COPT) $(BASEDIR)\arjsfxv\garble.obj: garble.c $(CC) $(SFV_COPT) $(BASEDIR)\arjsfxv\scrnio.obj: scrnio.c $(CC) $(SFV_COPT) $(BASEDIR)\arjsfxv\ansi.obj: ansi.c $(CC) $(SFV_COPT) $(BASEDIR)\arjsfxv\externs.obj: externs.c $(CC) $(SFV_COPT) $(BASEDIR)\fmsg_sfv.c $(BASEDIR)\imsg_sfv.c $(BASEDIR)\nmsg_sfv.c: $(BASEDIR)\tools\$(MSGBIND) $(RESFILE) $(BASEDIR)\tools\msgbind $(RESFILE) msg_sfv $(OS_ID) $(PACKAGE) $(LOCALE) $(BASEDIR) # # ARJSFX module # SFX_OBJS = $(BASEDIR)\arjsfx\arjsfx.obj \ $(BASEDIR)\arjsfx\sfx_id.obj \ $(BASEDIR)\arjsfx\filemode.obj \ $(BASEDIR)\arjsfx\fmsg_sfx.obj \ $(BASEDIR)\arjsfx\imsg_sfx.obj \ $(BASEDIR)\arjsfx\nmsg_sfx.obj \ $(BASEDIR)\arjsfx\decode.obj \ $(BASEDIR)\arjsfx\fardata.obj \ $(BASEDIR)\arjsfx\arj_user.obj \ $(BASEDIR)\arjsfx\arj_arcv.obj \ $(BASEDIR)\arjsfx\arj_file.obj \ $(BASEDIR)\arjsfx\crc32.obj \ $(BASEDIR)\arjsfx\misc.obj \ $(BASEDIR)\arjsfx\debug.obj \ $(BASEDIR)\arjsfx\arj_proc.obj \ $(BASEDIR)\arjsfx\environ.obj \ $(BASEDIR)\arjsfx\arjtypes.obj \ $(BASEDIR)\arjsfx\exe_sear.obj \ $(BASEDIR)\arjsfx\chk_fmsg.obj \ $(BASEDIR)\arjsfx\arjsec_h.obj \ !ifdef COMMERCIAL $(BASEDIR)\arjsfx\arjsec_l.obj \ !endif $(BASEDIR)\arjsfx\garble.obj \ $(BASEDIR)\arjsfx\externs.obj $(BASEDIR)\arjsfx\$(ARJSFX): $(SFX_OBJS) \ $(BASEDIR)\tools\$(POSTPROC) $(LRF) @<<$(BASEDIR_T)arjsfx.lrf !ifdef NEWLINK $(LINKOPT) $(SFX_OBJ) $(SFX_OBJS: = ^ ) !else $(LINKOPT) $(SFX_OBJ) $(SFX_OBJS: = +^ ) !endif $(OUT_LINKOPT)$@ $(MAP_LINKOPT)$(@R).map $(SFX_LIB) $(SFX_DEF) << $(LINKER) @$(BASEDIR_T)arjsfx.lrf$(LAST_LINKOPT) if exist $(BASEDIR_T)arjsfx.lrf del $(BASEDIR_T)arjsfx.lrf $(BASEDIR)\tools\postproc $(BASEDIR)\arjsfx\$(ARJSFX) -sfx !ifndef NO_ASM $(BASEDIR)\arjsfx\sfx_id.obj: sfx_id.asm $(ASM) $(SFX_ASMOPT) !else $(BASEDIR)\arjsfx\sfx_id.obj: sfx_id.c $(CC) $(SFX_COPT) !endif $(BASEDIR)\arjsfx\filemode.obj: filemode.c $(CC) $(SFX_COPT) $(BASEDIR)\arjsfx\fmsg_sfx.obj: $(BASEDIR)\fmsg_sfx.c $(CC) $(SFX_COPT) $(BASEDIR)\arjsfx\imsg_sfx.obj: $(BASEDIR)\imsg_sfx.c $(CC) $(SFX_COPT) $(BASEDIR)\arjsfx\nmsg_sfx.obj: $(BASEDIR)\nmsg_sfx.c $(CC) $(SFX_COPT) $(BASEDIR)\arjsfx\decode.obj: decode.c $(CC) $(SFX_COPT) $(BASEDIR)\arjsfx\arjsfx.obj: arjsfx.c $(BASEDIR)\fmsg_sfx.c $(CC) $(SFX_COPT) $(BASEDIR)\arjsfx\fardata.obj: fardata.c $(CC) $(SFX_COPT) $(BASEDIR)\arjsfx\arj_user.obj: arj_user.c $(CC) $(SFX_COPT) $(BASEDIR)\arjsfx\arj_arcv.obj: arj_arcv.c $(CC) $(SFX_COPT) $(BASEDIR)\arjsfx\arj_file.obj: arj_file.c $(CC) $(SFX_COPT) $(BASEDIR)\arjsfx\crc32.obj: crc32.c $(CC) $(SFX_COPT) $(BASEDIR)\arjsfx\misc.obj: misc.c $(CC) $(SFX_COPT) $(BASEDIR)\arjsfx\debug.obj: debug.c $(CC) $(SFX_COPT) $(BASEDIR)\arjsfx\arj_proc.obj: arj_proc.c $(CC) $(SFX_COPT) $(BASEDIR)\arjsfx\environ.obj: environ.c $(CC) $(SFX_COPT) $(BASEDIR)\arjsfx\arjtypes.obj: arjtypes.c $(CC) $(SFX_COPT) $(BASEDIR)\arjsfx\exe_sear.obj: exe_sear.c $(CC) $(SFX_COPT) $(BASEDIR)\arjsfx\chk_fmsg.obj: chk_fmsg.c $(BASEDIR)\msg_sfx.h $(CC) $(SFX_COPT) $(BASEDIR)\arjsfx\arjsec_h.obj: arjsec_h.c $(CC) $(SFX_COPT) $(BASEDIR)\arjsfx\arjsec_l.obj: arjsec_l.c $(CC) $(SFX_COPT) $(BASEDIR)\arjsfx\garble.obj: garble.c $(CC) $(SFX_COPT) $(BASEDIR)\arjsfx\externs.obj: externs.c $(CC) $(SFX_COPT) $(BASEDIR)\fmsg_sfx.c $(BASEDIR)\imsg_sfx.c $(BASEDIR)\nmsg_sfx.c: $(BASEDIR)\tools\$(MSGBIND) $(RESFILE) $(BASEDIR)\tools\msgbind $(RESFILE) msg_sfx $(OS_ID) $(PACKAGE) $(LOCALE) $(BASEDIR) # # ARJSFXJR module # SFJ_OBJS = $(BASEDIR)\arjsfxjr\arjsfxjr.obj \ $(BASEDIR)\arjsfxjr\sfx_id.obj \ $(BASEDIR)\arjsfxjr\fmsg_sfj.obj \ $(BASEDIR)\arjsfxjr\nmsg_sfj.obj \ $(BASEDIR)\arjsfxjr\debug.obj \ $(BASEDIR)\arjsfxjr\crc32.obj \ $(BASEDIR)\arjsfxjr\environ.obj $(BASEDIR)\arjsfxjr\$(ARJSFXJR): $(SFJ_OBJS) \ $(BASEDIR)\tools\$(POSTPROC) $(LRF) @<<$(BASEDIR_T)arjsfxjr.lrf !ifdef NEWLINK $(LINKOPT) $(SFJ_OBJ) $(SFJ_OBJS: = ^ ) !else $(LINKOPT) $(SFJ_OBJ) $(SFJ_OBJS: = +^ ) !endif $(OUT_LINKOPT)$@ $(MAP_LINKOPT)$(@R).map $(SFJ_LIB) $(SFJ_DEF) << $(LINKER) @$(BASEDIR_T)arjsfxjr.lrf$(LAST_LINKOPT) if exist $(BASEDIR_T)arjsfxjr.lrf del $(BASEDIR_T)arjsfxjr.lrf $(BASEDIR)\tools\postproc $(BASEDIR)\arjsfxjr\$(ARJSFXJR) -sfx !ifndef NO_ASM $(BASEDIR)\arjsfxjr\sfx_id.obj: sfx_id.asm $(ASM) $(SFJ_ASMOPT) !else $(BASEDIR)\arjsfxjr\sfx_id.obj: sfx_id.c $(CC) $(SFJ_COPT) !endif $(BASEDIR)\arjsfxjr\fmsg_sfj.obj: $(BASEDIR)\fmsg_sfj.c $(CC) $(SFJ_COPT) $(BASEDIR)\arjsfxjr\nmsg_sfj.obj: $(BASEDIR)\nmsg_sfj.c $(CC) $(SFJ_COPT) $(BASEDIR)\arjsfxjr\arjsfxjr.obj: arjsfxjr.c $(BASEDIR)\nmsg_sfj.c $(CC) $(SFJ_COPT) $(BASEDIR)\arjsfxjr\crc32.obj: crc32.c $(CC) $(SFJ_COPT) $(BASEDIR)\arjsfxjr\debug.obj: debug.c $(CC) $(SFJ_COPT) $(BASEDIR)\arjsfxjr\environ.obj: environ.c $(CC) $(SFJ_COPT) $(BASEDIR)\fmsg_sfj.c $(BASEDIR)\nmsg_sfj.c: $(BASEDIR)\tools\$(MSGBIND) $(RESFILE) $(BASEDIR)\tools\msgbind $(RESFILE) msg_sfj $(OS_ID) $(PACKAGE) $(LOCALE) $(BASEDIR) # # ARJ itself # ARJ_OBJS = $(BASEDIR)\arj\arj.obj \ $(BASEDIR)\arj\filemode.obj \ $(BASEDIR)\arj\date_sig.obj \ $(BASEDIR)\arj\fmsg_arj.obj \ $(BASEDIR)\arj\imsg_arj.obj \ $(BASEDIR)\arj\nmsg_arj.obj \ $(BASEDIR)\arj\integr.obj \ $(BASEDIR)\arj\file_reg.obj \ $(BASEDIR)\arj\decode.obj \ $(BASEDIR)\arj\encode.obj \ $(BASEDIR)\arj\enc_gwy.obj \ $(BASEDIR)\arj\fardata.obj \ $(BASEDIR)\arj\arj_user.obj \ $(BASEDIR)\arj\arj_arcv.obj \ $(BASEDIR)\arj\arj_file.obj \ $(BASEDIR)\arj\crc32.obj \ $(BASEDIR)\arj\misc.obj \ $(BASEDIR)\arj\debug.obj \ $(BASEDIR)\arj\arj_proc.obj \ $(BASEDIR)\arj\environ.obj \ $(BASEDIR)\arj\ntstream.obj \ $(BASEDIR)\arj\ea_mgr.obj \ $(BASEDIR)\arj\uxspec.obj \ $(BASEDIR)\arj\ext_hdr.obj \ $(BASEDIR)\arj\arjtypes.obj \ $(BASEDIR)\arj\exe_sear.obj \ $(BASEDIR)\arj\chk_fmsg.obj \ $(BASEDIR)\arj\filelist.obj \ $(BASEDIR)\arj\arjsec_h.obj \ $(BASEDIR)\arj\arjsec_l.obj \ $(BASEDIR)\arj\garble.obj \ $(BASEDIR)\arj\scrnio.obj \ $(BASEDIR)\arj\ansi.obj \ $(BASEDIR)\arj\crc16tab.obj \ $(BASEDIR)\arj\recovery.obj \ $(BASEDIR)\arj\gost.obj \ $(BASEDIR)\arj\gost40.obj \ $(BASEDIR)\arj\gost_t.obj \ $(BASEDIR)\arj\externs.obj \ $(ARJ_OBJS_S) \ $(ARJ_OBJS_E) $(BASEDIR)\arj\$(ARJ): $(ARJ_OBJS) \ $(BASEDIR)\tools\$(JOIN) \ $(BASEDIR)\tools\$(POSTPROC) \ $(BASEDIR)\sfxstub\$(SFXSTUB) \ $(BASEDIR)\arjsfxv\$(ARJSFXV) \ $(BASEDIR)\arjsfx\$(ARJSFX) \ $(BASEDIR)\arjsfxjr\$(ARJSFXJR) \ resource\$(LOCALE)\arjl.txt \ resource\$(LOCALE)\arjs.txt $(LRF) @<<$(BASEDIR_T)arj.lrf !ifdef NEWLINK $(LINKOPT) $(ARJ_OBJ) $(ARJ_OBJS: = ^ ) !else $(LINKOPT) $(ARJ_OBJ) $(ARJ_OBJS: = +^ ) !endif $(OUT_LINKOPT)$@ $(MAP_LINKOPT)$(@R).map $(ARJ_LIB) $(ARJ_DEF) << $(LINKER) @$(BASEDIR_T)arj.lrf$(LAST_LINKOPT) if exist $(BASEDIR_T)arj.lrf del $(BASEDIR_T)arj.lrf $(BASEDIR)\tools\join $(BASEDIR)\arj\$(ARJ) $(BASEDIR)\arjsfxjr\$(ARJSFXJR) $(BASEDIR)\tools\join $(BASEDIR)\arj\$(ARJ) $(BASEDIR)\arjsfx\$(ARJSFX) $(BASEDIR)\tools\join $(BASEDIR)\arj\$(ARJ) $(BASEDIR)\arjsfxv\$(ARJSFXV) $(BASEDIR)\tools\join $(BASEDIR)\arj\$(ARJ) $(BASEDIR)\sfxstub\$(SFXSTUB) if exist $(BASEDIR_T)help.arj del $(BASEDIR_T)help.arj $(BASEDIR)\arj\$(ARJ) a $(BASEDIR_T)help.arj -+ -2e -e -jm -jh65535 -jt -t1g resource\$(LOCALE)\arj?.txt $(BASEDIR)\tools\join $(BASEDIR)\arj\$(ARJ) $(BASEDIR_T)help.arj if exist $(BASEDIR_T)help.arj del $(BASEDIR_T)help.arj $(BASEDIR)\tools\postproc $(BASEDIR)\arj\$(ARJ) !ifndef NO_ASM $(BASEDIR)\arj\integr.obj: integr.asm $(ASM) $(STD_ASMOPT) !else $(BASEDIR)\arj\integr.obj: integr.c $(CC) $(STD_COPT) !endif $(BASEDIR)\arj\file_reg.obj: file_reg.c $(CC) $(ARJ_COPT) $(BASEDIR)\arj\decode.obj: decode.c $(CC) $(NEAR_COPT) !ifndef NO_ASM $(BASEDIR)\arj\fmemcmp.obj: fmemcmp.asm $(ASM) $(STD_ASMOPT) !endif $(BASEDIR)\arj\encode.obj: encode.c $(CC) $(NEAR_COPT) $(BASEDIR)\arj\date_sig.obj: $(BASEDIR)\date_sig.c $(CC) $(ARJ_COPT) $(BASEDIR)\arj\arj.obj: arj.c $(BASEDIR)\nmsg_arj.c $(CC) $(ARJ_COPT) $(BASEDIR)\arj\enc_gwy.obj: enc_gwy.c $(CC) $(ARJ_COPT) $(BASEDIR)\arj\fardata.obj: fardata.c $(CC) $(ARJ_COPT) $(BASEDIR)\arj\arj_user.obj: arj_user.c $(CC) $(ARJ_COPT) $(BASEDIR)\arj\arj_arcv.obj: arj_arcv.c $(CC) $(ARJ_COPT) $(BASEDIR)\arj\arj_file.obj: arj_file.c $(CC) $(ARJ_COPT) $(BASEDIR)\arj\crc32.obj: crc32.c $(CC) $(ARJ_COPTS) $(BASEDIR)\arj\misc.obj: misc.c $(CC) $(ARJ_COPT) $(BASEDIR)\arj\debug.obj: debug.c $(CC) $(ARJ_COPT) $(BASEDIR)\arj\arj_proc.obj: arj_proc.c $(CC) $(ARJ_COPT) $(BASEDIR)\arj\environ.obj: environ.c $(CC) $(ARJ_COPT) $(BASEDIR)\arj\ntstream.obj: ntstream.c $(CC) $(ARJ_COPT) $(BASEDIR)\arj\ea_mgr.obj: ea_mgr.c $(CC) $(ARJ_COPT) $(BASEDIR)\arj\uxspec.obj: uxspec.c $(CC) $(ARJ_COPT) $(BASEDIR)\arj\ext_hdr.obj: ext_hdr.c $(CC) $(ARJ_COPT) $(BASEDIR)\arj\arjtypes.obj: arjtypes.c $(CC) $(ARJ_COPT) $(BASEDIR)\arj\exe_sear.obj: exe_sear.c $(CC) $(ARJ_COPT) $(BASEDIR)\arj\chk_fmsg.obj: chk_fmsg.c $(BASEDIR)\msg_arj.h $(CC) $(ARJ_COPT) !ifndef NO_ASM $(BASEDIR)\arj\arj_xms.obj: arj_xms.asm $(ASM) $(STD_ASMOPT) !endif $(BASEDIR)\arj\filelist.obj: filelist.c $(CC) $(ARJ_COPT) $(BASEDIR)\arj\arjsec_h.obj: arjsec_h.c $(CC) $(ARJ_COPT) $(BASEDIR)\arj\arjsec_l.obj: arjsec_l.c $(CC) $(ARJ_COPTS) $(BASEDIR)\arj\garble.obj: garble.c $(CC) $(ARJ_COPT) $(BASEDIR)\arj\scrnio.obj: scrnio.c $(CC) $(ARJ_COPT) $(BASEDIR)\arj\ansi.obj: ansi.c $(CC) $(ARJ_COPT) $(BASEDIR)\arj\recovery.obj: recovery.c $(CC) $(ARJ_RECOPT) $(BASEDIR)\arj\crc16tab.obj: crc16tab.c $(CC) $(FDS_COPT) $(BASEDIR)\arj\gost.obj: gost.c $(CC) $(ARJ_COPT) $(BASEDIR)\arj\gost_t.obj: gost_t.c $(CC) $(FDS_COPT) $(BASEDIR)\arj\gost40.obj: gost40.c $(CC) $(ARJ_COPTS) $(BASEDIR)\arj\filemode.obj: filemode.c $(CC) $(ARJ_COPT) $(BASEDIR)\arj\fmsg_arj.obj: $(BASEDIR)\fmsg_arj.c $(CC) $(FAR_COPT) $(BASEDIR)\arj\imsg_arj.obj: $(BASEDIR)\imsg_arj.c $(CC) $(FAR_COPT) $(BASEDIR)\arj\nmsg_arj.obj: $(BASEDIR)\nmsg_arj.c $(CC) $(ARJ_COPT) $(BASEDIR)\arj\externs.obj: externs.c $(CC) $(ARJ_COPT) $(BASEDIR)\fmsg_arj.c $(BASEDIR)\imsg_arj.c $(BASEDIR)\nmsg_arj.c: $(BASEDIR)\tools\$(MSGBIND) $(RESFILE) $(BASEDIR)\tools\msgbind $(RESFILE) msg_arj $(OS_ID) $(PACKAGE) $(LOCALE) $(BASEDIR) # # REARJ utility # REJ_OBJS = $(BASEDIR)\rearj\rearj.obj \ $(BASEDIR)\rearj\integr.obj \ $(BASEDIR)\rearj\filemode.obj \ $(BASEDIR)\rearj\date_sig.obj \ $(BASEDIR)\rearj\fmsg_rej.obj \ $(BASEDIR)\rearj\nmsg_rej.obj \ $(BASEDIR)\rearj\file_reg.obj \ $(BASEDIR)\rearj\fardata.obj \ $(BASEDIR)\rearj\arj_file.obj \ $(BASEDIR)\rearj\crc32.obj \ $(BASEDIR)\rearj\misc.obj \ $(BASEDIR)\rearj\debug.obj \ $(BASEDIR)\rearj\arj_proc.obj \ $(BASEDIR)\rearj\environ.obj \ $(BASEDIR)\rearj\arjtypes.obj \ $(BASEDIR)\rearj\filelist.obj \ $(BASEDIR)\rearj\scrnio.obj \ $(BASEDIR)\rearj\arjsec_h.obj \ $(BASEDIR)\rearj\arjsec_l.obj \ $(BASEDIR)\rearj\externs.obj $(BASEDIR)\rearj\$(REARJ): $(REJ_OBJS) \ $(BASEDIR)\tools\$(POSTPROC) $(LRF) @<<$(BASEDIR_T)rearj.lrf !ifdef NEWLINK $(LINKOPT) $(REJ_OBJ) $(REJ_OBJS: = ^ ) !else $(LINKOPT) $(REJ_OBJ) $(REJ_OBJS: = +^ ) !endif $(OUT_LINKOPT)$@ $(MAP_LINKOPT)$(@R).map $(REJ_LIB) $(REJ_DEF) << $(LINKER) @$(BASEDIR_T)rearj.lrf$(LAST_LINKOPT) if exist $(BASEDIR_T)rearj.lrf del $(BASEDIR_T)rearj.lrf $(BASEDIR)\tools\postproc $(BASEDIR)\rearj\$(REARJ) !ifndef NO_ASM $(BASEDIR)\rearj\integr.obj: integr.asm $(ASM) $(REJ_ASMOPT) !else $(BASEDIR)\rearj\integr.obj: integr.c $(CC) $(REJ_COPT) !endif $(BASEDIR)\rearj\filemode.obj: filemode.c $(CC) $(REJ_COPT) $(BASEDIR)\rearj\date_sig.obj: $(BASEDIR)\date_sig.c $(CC) $(REJ_COPT) $(BASEDIR)\rearj\fmsg_rej.obj: $(BASEDIR)\fmsg_rej.c $(CC) $(REJ_COPT) $(BASEDIR)\rearj\nmsg_rej.obj: $(BASEDIR)\nmsg_rej.c $(CC) $(REJ_COPT) $(BASEDIR)\rearj\file_reg.obj: file_reg.c $(CC) $(REJ_COPT) $(BASEDIR)\rearj\rearj.obj: rearj.c $(BASEDIR)\fmsg_rej.c $(CC) $(REJ_COPT) $(BASEDIR)\rearj\fardata.obj: fardata.c $(CC) $(REJ_COPT) $(BASEDIR)\rearj\arj_file.obj: arj_file.c $(CC) $(REJ_COPT) $(BASEDIR)\rearj\crc32.obj: crc32.c $(CC) $(REJ_COPT) $(BASEDIR)\rearj\misc.obj: misc.c $(CC) $(REJ_COPT) $(BASEDIR)\rearj\debug.obj: debug.c $(CC) $(REJ_COPT) $(BASEDIR)\rearj\arj_proc.obj: arj_proc.c $(CC) $(REJ_COPT) $(BASEDIR)\rearj\environ.obj: environ.c $(CC) $(REJ_COPT) $(BASEDIR)\rearj\arjtypes.obj: arjtypes.c $(CC) $(REJ_COPT) $(BASEDIR)\rearj\filelist.obj: filelist.c $(CC) $(REJ_COPT) $(BASEDIR)\rearj\scrnio.obj: scrnio.c $(CC) $(REJ_COPT) $(BASEDIR)\rearj\arjsec_h.obj: arjsec_h.c $(CC) $(REJ_COPT) $(BASEDIR)\rearj\arjsec_l.obj: arjsec_l.c $(CC) $(REJ_COPT) $(BASEDIR)\rearj\externs.obj: externs.c $(CC) $(REJ_COPT) $(BASEDIR)\fmsg_rej.c $(BASEDIR)\nmsg_rej.c: $(BASEDIR)\tools\$(MSGBIND) $(RESFILE) $(BASEDIR)\tools\msgbind $(RESFILE) msg_rej $(OS_ID) $(PACKAGE) $(LOCALE) $(BASEDIR) # # Registration wizard # REG_OBJS = $(BASEDIR)\register\register.obj \ $(BASEDIR)\register\integr.obj \ $(BASEDIR)\register\filemode.obj \ $(BASEDIR)\register\fmsg_reg.obj \ $(BASEDIR)\register\nmsg_reg.obj \ $(BASEDIR)\register\fardata.obj \ $(BASEDIR)\register\crc32.obj \ $(BASEDIR)\register\debug.obj \ $(BASEDIR)\register\arj_proc.obj \ $(BASEDIR)\register\environ.obj $(BASEDIR)\register\$(REGISTER): $(REG_OBJS) \ $(BASEDIR)\tools\$(POSTPROC) $(LRF) @<<$(BASEDIR_T)register.lrf !ifdef NEWLINK $(LINKOPT) $(REG_OBJ) $(REG_OBJS: = ^ ) !else $(LINKOPT) $(REG_OBJ) $(REG_OBJS: = +^ ) !endif $(OUT_LINKOPT)$@ $(MAP_LINKOPT)$(@R).map $(REG_LIB) $(REG_DEF) << $(LINKER) @$(BASEDIR_T)register.lrf$(LAST_LINKOPT) if exist $(BASEDIR_T)register.lrf del $(BASEDIR_T)register.lrf $(BASEDIR)\tools\postproc $(BASEDIR)\register\$(REGISTER) -sfx !ifndef NO_ASM $(BASEDIR)\register\integr.obj: integr.asm $(ASM) $(REG_ASMOPT) !else $(BASEDIR)\register\integr.obj: integr.c $(CC) $(REG_COPT) !endif $(BASEDIR)\register\filemode.obj: filemode.c $(CC) $(REG_COPT) $(BASEDIR)\register\fmsg_reg.obj: $(BASEDIR)\fmsg_reg.c $(CC) $(REG_COPT) $(BASEDIR)\register\nmsg_reg.obj: $(BASEDIR)\nmsg_reg.c $(CC) $(REG_COPT) $(BASEDIR)\register\register.obj: register.c $(BASEDIR)\nmsg_reg.c $(CC) $(REG_COPT) $(BASEDIR)\register\fardata.obj: fardata.c $(CC) $(REG_COPT) $(BASEDIR)\register\crc32.obj: crc32.c $(CC) $(REG_COPT) $(BASEDIR)\register\debug.obj: debug.c $(CC) $(REG_COPT) $(BASEDIR)\register\arj_proc.obj: arj_proc.c $(CC) $(REG_COPT) $(BASEDIR)\register\environ.obj: environ.c $(CC) $(REG_COPT) $(BASEDIR)\fmsg_reg.c $(BASEDIR)\nmsg_reg.c: $(BASEDIR)\tools\$(MSGBIND) $(RESFILE) $(BASEDIR)\tools\msgbind $(RESFILE) msg_reg $(OS_ID) $(PACKAGE) $(LOCALE) $(BASEDIR) # # Demonstration display program # ADI_OBJS = $(BASEDIR)\arjdisp\arjdisp.obj \ $(BASEDIR)\arjdisp\nmsg_adi.obj \ $(BASEDIR)\arjdisp\fardata.obj \ $(BASEDIR)\arjdisp\debug.obj \ $(BASEDIR)\arjdisp\arj_proc.obj \ $(BASEDIR)\arjdisp\environ.obj \ $(BASEDIR)\arjdisp\scrnio.obj $(BASEDIR)\arjdisp\$(ARJDISP): $(ADI_OBJS) $(LRF) @<<$(BASEDIR_T)arjdisp.lrf !ifdef NEWLINK $(LINKOPT) $(ADI_OBJ) $(ADI_OBJS: = ^ ) !else $(LINKOPT) $(ADI_OBJ) $(ADI_OBJS: = +^ ) !endif $(OUT_LINKOPT)$@ $(MAP_LINKOPT)$(@R).map $(ADI_LIB) $(ADI_DEF) << $(LINKER) @$(BASEDIR_T)arjdisp.lrf$(LAST_LINKOPT) if exist $(BASEDIR_T)arjdisp.lrf del $(BASEDIR_T)arjdisp.lrf $(BASEDIR)\arjdisp\nmsg_adi.obj: $(BASEDIR)\nmsg_adi.c $(CC) $(ADI_COPT) $(BASEDIR)\arjdisp\arjdisp.obj: arjdisp.c $(BASEDIR)\nmsg_adi.c $(CC) $(ADI_COPT) $(BASEDIR)\arjdisp\fardata.obj: fardata.c $(CC) $(ADI_COPT) $(BASEDIR)\arjdisp\debug.obj: debug.c $(CC) $(ADI_COPT) $(BASEDIR)\arjdisp\arj_proc.obj: arj_proc.c $(CC) $(ADI_COPT) $(BASEDIR)\arjdisp\environ.obj: environ.c $(CC) $(ADI_COPT) $(BASEDIR)\arjdisp\scrnio.obj: scrnio.c $(CC) $(ADI_COPT) $(BASEDIR)\nmsg_adi.c: $(BASEDIR)\tools\$(MSGBIND) $(RESFILE) $(BASEDIR)\tools\msgbind $(RESFILE) msg_adi $(OS_ID) $(PACKAGE) $(LOCALE) $(BASEDIR) # # Pre-compilation actions # prepare: -md $(CC_CODE) -md $(CC_CODE)\$(LOCALE) -md $(BASEDIR) -md $(BASEDIR)\tools -md $(BASEDIR)\arjcrypt -md $(BASEDIR)\sfxstub -md $(BASEDIR)\arjsfxv -md $(BASEDIR)\arjsfx -md $(BASEDIR)\arjsfxjr -md $(BASEDIR)\arj -md $(BASEDIR)\rearj -md $(BASEDIR)\register -md $(BASEDIR)\arjdisp # # Cleanup # cleanup: echo y|del $(CC_CODE)\$(LOCALE)\*.* echo y|del $(BASEDIR)\*.* echo y|del $(BASEDIR)\tools\*.* echo y|del $(BASEDIR)\arjcrypt\*.* echo y|del $(BASEDIR)\sfxstub\*.* echo y|del $(BASEDIR)\arjsfxv\*.* echo y|del $(BASEDIR)\arjsfx\*.* echo y|del $(BASEDIR)\arjsfxjr\*.* echo y|del $(BASEDIR)\arj\*.* echo y|del $(BASEDIR)\rearj\*.* echo y|del $(BASEDIR)\register\*.* echo y|del $(BASEDIR)\arjdisp\*.* # # Packaging # package: all -md retail # Was: $(BASEDIR_P) $(BASEDIR) $(BASEDIR)\tools\packager $(BASEDIR) $(BASEDIR) arj-3.10.22/makestub.c 666 0 0 3007 7675307434 10623 0ustar /* * $Id: makestub.c,v 1.2 2003/06/22 11:12:28 andrew_belov Exp $ * --------------------------------------------------------------------------- * This program compiles SFX-STUB locale-dependent files. * */ #include #include #include "arj.h" #include "msg_stb.h" DEBUGHDR(__FILE__) /* Debug information block */ /* Translation routine */ void store_xlat(FILE *ostream, char *banner, unsigned char *msg) { int i, j=0; fprintf(ostream, "%s db ", banner); if(msg[0]=='\0') fprintf(ostream, "63"); for(i=0; msg[i]!='\0'; i++) { if(msg[i]==10) { fprintf(ostream, "13,"); j++; } fprintf(ostream, "%d", (int)msg[i]); j++; if(msg[i+1]!='\0') { if(i%20==19) fprintf(ostream, "\ndb "); else fprintf(ostream, ","); } } #if TARGET==DOS fprintf(ostream, "\ndb 36"); #endif fprintf(ostream, "\nL_%s EQU %d\n", banner, j); } /* Main routine */ int main(int argc, char **argv) { FILE *stream; printf("MAKESTUB v 1.11 [30/11/2001] Not a part of any binary package!\n\n"); if(argc<2) { printf("Usage: MAKESTUB \n"); exit(1); } if((stream=fopen(argv[1], m_w))==NULL) { printf("Failed to open include file\n"); exit(1); } fprintf(stream, "; DO NOT MODIFY! This file has been automatically generated with MAKESTUB\n\n"); store_xlat(stream, "M_SFXSTUB_BANNER", M_SFXSTUB_BANNER); store_xlat(stream, "M_SFXSTUB_BLURB_1", M_SFXSTUB_BLURB_1); store_xlat(stream, "M_SFXSTUB_BLURB_2", M_SFXSTUB_BLURB_2); fclose(stream); return(0); } arj-3.10.22/make_key.c 666 0 0 4465 7745045112 10574 0ustar /* * $Id: make_key.c,v 1.3 2003/10/20 20:49:15 andrew_belov Exp $ * --------------------------------------------------------------------------- * This is a key generation utility. * */ #include "arj.h" #include DEBUGHDR(__FILE__) /* Debug information block */ /* Main routine */ int main(int argc, char **argv) { FILE *stream; int i, rc; unsigned long validation[8]; printf("MAKE_KEY v 1.13 [16/12/2000] Not a part of any binary package!\n\n"); if(argc<5) { printf("Usage: MAKE_KEY \"\" \n" "Where: is the quoted \" [] [|]\n" " is a free-form string\n" " is \"(EXT LIC)\" if extended license\n" " is \"R#nnnn\", zero-padded\n" " is \"SDN#0xnnnn\", where x is:\n" " 1 is for SDN-originated packages\n" " 2 is for SDN-distributed packages\n" " is the license code (e.g., ARJR#1)\n" " ARJR#1 is a private license\n" " ARJR#2 is a public license\n" " is a product version number: \n" " is product series (\"A\" for ARJ)\n" " is product version (\"3\" for v 3.x)\n" " is the name of file which accepts the registration data\n" "\n" "Example: MAKE_KEY \"John Doe (EXT LIC) R#0843\" ARJR#2 A2 arj.key\n"); exit(1); } printf("Initializing...\n"); build_crc32_table(); printf("Creating key signature...\n"); create_reg_key(argv[2], argv[3], argv[1], (char *)validation); rc=verify_reg_name(argv[2], argv[3], argv[1], (char *)validation); printf("Verifying key... RC = %d\n", rc); if(rc==0) { if((stream=fopen(argv[4], "w"))!=NULL) { for(i=0; i<8; i++) fprintf(stream, "%10lu ", validation[i]); fprintf(stream, "%s %s %s", argv[2], argv[3], argv[1]); fclose(stream); } printf("ARJ-SECURITY calculation completed.\n"); return(0); } else { printf("Key creation error!\n"); return(1); } } arj-3.10.22/misc.c 666 0 0 45602 10056654210 7772 0ustar /* * $Id: misc.c,v 1.5 2004/05/31 16:08:41 andrew_belov Exp $ * --------------------------------------------------------------------------- * Various system-independent routines are kept here. This module is needed if * the ENVIRON.C is linked, since both of them cross-reference each other. * */ #include "arj.h" DEBUGHDR(__FILE__) /* Debug information block */ /* Compact filelist array */ #if SFX_LEVEL>=ARJSFXV static unsigned char FAR * FAR *flist_array=NULL; static FILE_COUNT cfa_allocated; /* # of allocated blocks */ #endif /* Extended wildcard specifiers */ static char xwild_symbols[]="?*[]^"; /* Forward references */ static int xwild_propagate(char *wcstr, char *str); #if SFX_LEVEL>=ARJ /* Dumb extended wildcard lookup routine */ static int xwild_lookup(char *str) { char *p; char c; for(p=str; *p!='\0'; p++) { c=*p; if(c=='*'||c=='?'||c=='['||c=='^') return(XW_OK); } return(XW_NONE); } /* An extended wildcard parser */ static int xwild_parser(char *wcstr, int *rc) { char *p; char c; *rc=XWP_NONE; for(p=wcstr; *p!='\0'; p++) { c=*p; if(c=='^') { p++; if(*p=='\0') { *rc=XWP_TERM; return(XW_NONE); } } else if(c=='[') { p++; if((c=*p)==']') { *rc=XWP_NBRACKET; return(XW_NONE); } if(c=='\0') { *rc=XWP_OBRACKET; return(XW_NONE); } while(*p!=']') { if(*p=='^') { p++; if((c=*p)=='\0') { *rc=XWP_TERM; return(XW_NONE); } } else p++; if((c=*p)=='\0') { *rc=XWP_OBRACKET; return(XW_NONE); } if(*p=='-') { c=*++p; if(c=='\0'||c==']') { *rc=XWP_MDASH; return(XW_NONE); } if(*p=='^') p++; if((c=*p++)=='\0') { *rc=XWP_TERM; return(XW_NONE); } } } } else p++; } return(XW_OK); } /* Extended wildcard expansion and matching routine */ static int xwild_match(char *wcstr, char *str) { char *wptr; char *sptr; char c, sc; char fchar; int xchar; int pflag; int unproc; char xc, xpc; /* Wildcard processed characters */ wptr=wcstr; sptr=str; while(*wptr!='\0') { if((c=*sptr)=='\0') return((*wptr=='*'&&*++wptr=='\0')?XW_OK:XW_OWC); fchar=*wptr; switch(fchar) { case '*': return(xwild_propagate(wptr, sptr)); case '[': xchar=0; wptr++; if(*wptr=='!') { xchar=1; wptr++; } unproc=0; pflag=1; while(pflag!=0) { if(*wptr!=']') { c=(*wptr=='^')?*++wptr:*wptr; /* Escape character */ xpc=xc=toupper(c); if(c=='\0') return(XW_TERM); wptr++; if(*wptr=='-') { c=*++wptr; if(c=='\0'&&c!=']') return(XW_TERM); xc=toupper(c); if(xc=='^') { c=*++wptr; xc=toupper(c); if(xc=='\0') return(XW_TERM); } wptr++; } sc=toupper(*sptr); if((xpc>=xc&&sc>=xc&&sc<=xpc)||(sc>=xpc&&sc<=xc)) { unproc=1; pflag=0; } } else pflag=0; } if((xchar!=0&&unproc)||(xchar==0&&!unproc)) return(XW_UNPROC); if(!unproc) break; /* Skip the rest, applying usual check-ups */ while(*wptr!=']') { if(*wptr=='\0') return(XW_TERM); if(*wptr=='^') { if(*++wptr=='\0') return(XW_TERM); } wptr++; } break; case '?': break; /* Skip the comparison */ case '^': wptr++; if(*wptr=='\0') return(XW_TERM); default: /* fallthru */ if(toupper(*wptr)!=toupper(*sptr)) return(XW_MISMATCH); break; } wptr++; sptr++; } return((*sptr=='\0')?XW_OK:XW_PREM_END); } /* Propagates (expands) wildcard markers */ static int xwild_propagate(char *wcstr, char *str) { int rc=0; char c; while(*wcstr=='?'||*wcstr=='*') { if(*wcstr=='?') { if(*++str=='\0') return(XW_OWC); } wcstr++; } if(*wcstr=='\0') return(XW_OK); if((c=*wcstr)=='^') { if((c=*++wcstr)=='\0') return(XW_TERM); } do { if(toupper(c)==toupper(*str)||c=='[') rc=xwild_match(wcstr, str); if(*str++=='\0') rc=XW_OWC; } while(rc!=XW_OK&&rc!=XW_OWC&&rc!=XW_TERM); return(rc); } /* Wildcard matching routine wrapper (provides boolean RCs) */ static int xwild_compare(char *wcstr, char *str) { int xrc; xrc=xwild_match(wcstr, str); return((xrc==XW_OK)?XW_OK:XW_NONE); } /* Change all UNIX-style path specifiers to DOS-style ones in a given string */ void unix_path_to_dos(char *path) { int i=0; if(translate_unix_paths) { while(path[i]!='\0') { if(path[i]==PATHSEP_UNIX) path[i]=PATHSEP_DEFAULT; i++; } } } #endif #if SFX_LEVEL>=ARJSFXV /* Allocate a block of memory that will exactly fit the length of string, and copy the string into this newly-created block. */ void *malloc_str(char *str) { return(strcpy((char *)malloc_msg(strlen(str)+1), str)); } #endif #if SFX_LEVEL>=ARJ /* The same as malloc_str, but it allocates near memory for far strings */ void *malloc_far_str(char FAR *str) { char *k; k=malloc_msg(far_strlen(str)+1); far_strcpy((char FAR *)k, str); return(k); } #endif #if SFX_LEVEL>=ARJ /* Converts current time to a standard timestamp */ void cur_time_stamp(struct timestamp *dest) { time_t cur_unixtime; cur_unixtime=time(NULL); ts_store(dest, OS_UNIX, cur_unixtime); } /* A strchr() function for far strings */ #if COMPILER!=MSC&&defined(TILED) char FAR *far_strchr(char FAR *str, char chr) { while(str[0]!=chr) { if(str[0]=='\0') return(NULL); str++; } return(str); } #endif #endif #if SFX_LEVEL>=ARJSFXV||defined(REARJ) /* A strcmp() function for far strings */ #if COMPILER!=MSC&&defined(TILED) int far_strcmp(char FAR *str1, char FAR *str2) { unsigned int k; for(k=0; str1[k]!='\0'&&str2[k]!='\0'; k++); return((int)(str1[k]-str2[k])); } #endif /* A stricmp() function for far strings */ #if COMPILER!=MSC&&defined(TILED) int far_stricmp(char FAR *str1, char FAR *str2) { unsigned int k; for(k=0; toupper(str1[k]!='\0')&&toupper(str2[k]!='\0'); k++); return(toupper(str1[k])-toupper(str2[k])); } #endif #endif #if SFX_LEVEL>=ARJ||defined(REARJ) /* A strcat() function for far strings */ #if COMPILER!=MSC&&defined(TILED) char FAR *far_strcat(char FAR *dest, char FAR *src) { char FAR *tmp_dest; tmp_dest=dest; while(tmp_dest[0]!='\0') tmp_dest++; do (tmp_dest++)[0]=src[0]; while((src++)[0]!='\0'); return(dest); } #endif #endif #if SFX_LEVEL>=ARJSFXV||defined(REARJ) /* A strcpy() function for far strings */ #if COMPILER!=MSC&&defined(TILED) char FAR *far_strcpy(char FAR *dest, char FAR *src) { int k; for(k=0; src[k]!='\0'; k++) dest[k]=src[k]; dest[k]='\0'; return(dest); } #endif #endif #if SFX_LEVEL>=ARJ /* A strlen() function for far strings */ #if COMPILER!=MSC&&defined(TILED) unsigned int far_strlen(char FAR *str) { unsigned int k=0; while(str[k]!='\0') k++; return(k); } #endif #endif #if SFX_LEVEL>=ARJSFXV /* Fills a buffer with the specified value */ #if COMPILER!=MSC&&defined(TILED) void FAR *far_memset(void FAR *buf, int filler, unsigned int size) { char FAR *p; unsigned int l; p=(char FAR *)buf; for(l=0; l=ARJSFXV /* Copies at most n characters */ char FAR *far_strcpyn(char FAR *dest, char FAR *src, int limit) { int k; for(k=1; k0) dest[0]='\0'; return(dest); } #endif #if SFX_LEVEL>=ARJSFX /* Converts the given string to 7-bit */ void to_7bit(char *str) { while(*str!='\0') *str++&=0x7F; } #endif #if SFX_LEVEL>=ARJSFX||defined(REARJ) /* Convert a string to uppercase, depending on locale */ void strupper(char *s) { #if SFX_LEVEL>=ARJSFXV||defined(REARJ) toupper_loc(s, strlen(s)); #else while(*s!='\0') { *s=toupper(*s); s++; } #endif } #endif #if SFX_LEVEL>=ARJSFXV /* Convert a string to lowercase (note: no locale hack here - the one in strupper() was made exclusively for filename matching under DOS) */ void strlower(char *s) { while(*s!='\0') { *s=tolower(*s); s++; } } #endif #if SFX_LEVEL>=ARJ /* Finds an entry in the filelist, returns 1 if matched. Wildcards allowed. */ int flist_find(struct flist_root *root, char *name) { char tmp_name[FILENAME_MAX]; /* Hash filename storage */ char n_path[FILENAME_MAX], f_path[FILENAME_MAX]; FILE_COUNT entry; int pathname_length; int tmp_pathname_length; if(root==NULL) return(0); pathname_length=split_name(name, n_path, NULL); for(entry=0; entryfiles; entry++) { flist_retrieve(tmp_name, NULL, root, entry); tmp_pathname_length=split_name(tmp_name, f_path, NULL); if(marksym_expansion) { if(tmp_pathname_length!=0&&strlen(tmp_name)==tmp_pathname_length&&xwild_compare(f_path, n_path)==XW_OK) return(1); if(tmp_pathname_length==0||xwild_compare(f_path, n_path)==XW_OK) { if(xwild_compare(tmp_name+tmp_pathname_length, name+pathname_length)==XW_OK) return(1); } } else { /* If it was a directory specification, return OK */ if(tmp_pathname_length!=0&&strlen(tmp_name)==tmp_pathname_length&&!strncmp_os(tmp_name, name, tmp_pathname_length)) return(1); /* For filename specifications, proceed with compare */ if(tmp_pathname_length==0||(tmp_pathname_length==pathname_length&&!strncmp_os(tmp_name, name, tmp_pathname_length))) if(match_wildcard(&name[pathname_length], &tmp_name[tmp_pathname_length])) return(1); } } return(0); } /* Checks if a file already exists in the archive */ int flist_is_in_archive(struct flist_root *root, char *name) { char tmp_name[CCHMAXPATHCOMP]; /* For names retrieved from the hash */ char case_name[CCHMAXPATHCOMP]; /* and for converting them to u-case */ FILE_COUNT entry; for(entry=0; entryfiles; entry++) { if(cfa_get(entry)==FLFLAG_PROCESSED) { flist_retrieve(tmp_name, NULL, root, entry); default_case_path(case_name, tmp_name); if(!stricmp(name, case_name)) return(1); } } return(0); } /* Returns 1 if the file properties given match the current search narrowing criteria (such as "same or newer", and so on) */ int match_attrib(struct file_properties *properties) { int matched; /* First, check if the attributes match */ if(filter_attrs) { matched=0; if(file_attr_mask&TAG_DIREC&&properties->type==ARJT_DIR) matched=1; if(file_attr_mask&TAG_UXSPECIAL&&properties->type==ARJT_UXSPECIAL) matched=1; if(file_attr_mask&TAG_NORMAL&& !(properties->attrib&FATTR_DIREC)&& !(properties->attrib&FATTR_RDONLY)&& !(properties->attrib&FATTR_SYSTEM)&& !(properties->attrib&FATTR_HIDDEN)&& properties->type!=ARJT_UXSPECIAL) matched=1; if(file_attr_mask&TAG_RDONLY&&properties->attrib&FATTR_RDONLY) matched=1; if(file_attr_mask&TAG_HIDDEN&&properties->attrib&FATTR_HIDDEN) matched=1; if(file_attr_mask&TAG_SYSTEM&&properties->attrib&FATTR_SYSTEM) matched=1; if(file_attr_mask&TAG_ARCH&&!(properties->attrib&FATTR_ARCH)) return(0); if(file_attr_mask&TAG_NOT_ARCH&&properties->attrib&FATTR_ARCH) return(0); if(!matched) return(0); } if(filter_fa_arch==FAA_BACKUP||filter_fa_arch==FAA_BACKUP_CLEAR) { if(!properties->isarchive) return(0); } /* Now, check the file against the time limits for it */ /* ftime */ if(ts_valid(tested_ftime_newer)&&(filter_same_or_newer==TCHECK_NDAYS||filter_same_or_newer==TCHECK_FTIME)) { if(properties->ftimeftime>=ts_native(&tested_ftime_older, OS)) return(0); } /* ctime */ if(ts_valid(tested_ftime_newer)&&filter_same_or_newer==TCHECK_CTIME) { if(properties->ctimectime>=ts_native(&tested_ftime_older, OS)) return(0); } /* atime */ if(ts_valid(tested_ftime_newer)&&filter_same_or_newer==TCHECK_ATIME) { if(properties->atimeatime>=ts_native(&tested_ftime_older, OS)) return(0); } return(1); } /* Frees memory allocated for the hash table */ void flist_cleanup(struct flist_root *root) { flist_cleanup_proc(root); } /* Adds an entry to the filelist if it does not already exist. Returns -1 if an error occured. */ int flist_add(struct flist_root *root, struct flist_root *search_flist, char *name, FILE_COUNT *count, struct file_properties *properties) { FILE_COUNT i; if(search_flist!=NULL) { /* If an existing entry has been found, don't add anything */ if(flist_find(search_flist, name)) { if(count!=NULL) (*count)++; return(0); } } if(root!=NULL&&root->fsptr!=NULL&&!xwild_compare(root->fsptr, name)) { if(count!=NULL) (*count)++; return(0); } if(properties!=NULL&&root==&flist_main&&!match_attrib(properties)) { if(count!=NULL) (*count)++; return(0); } #if TARGET==UNIX /* Resolve hard links if there are any */ if(properties!=NULL&& properties->l_search.refcount>1&& !suppress_hardlinks) link_search(&l_entries, &properties->l_search, properties, root->files); #endif return(add_entry(root, name, count, properties)); } /* Initializes the filelist storage structures */ void flist_init(struct flist_root *root, FILE_COUNT maxfiles, char type) { flist_init_proc(root, maxfiles, type); } /* Retrieves an entry from the filelist */ void flist_retrieve(char *dest, struct file_properties *properties, struct flist_root *root, FILE_COUNT entry) { retrieve_entry(dest, properties, root, entry); } /* Converts an extended wildcard to canonical wildcard */ static void xwild_to_canonical(char *name) { char *tmp_name; char *xwptr; int entry; tmp_name=malloc_str(name); xwptr=strpbrk(tmp_name, xwild_symbols); if(xwptr!=NULL) { *(xwptr+1)='\0'; entry=split_name(tmp_name, NULL, NULL); if(entry>0) { tmp_name[entry-1]='\0'; sprintf(name, "%s%c%s", tmp_name, PATHSEP_DEFAULT, all_wildcard); } else strcpy(name, all_wildcard); } free(tmp_name); } #endif #if SFX_LEVEL>=ARJSFXV /* Expands wildcards and prepares a file list */ int flist_add_files(struct flist_root *root, struct flist_root *search_flist, char *name, int expand_wildcards, int recurse_subdirs, int file_type, FILE_COUNT *count) { int result; char *tmp_name; #if SFX_LEVEL>=ARJ int parse_rc; #endif #if SFX_LEVEL>=ARJ if(expand_wildcards&&marksym_expansion&&xwild_lookup(name)==XW_OK&& xwild_parser(name, &parse_rc)==XW_OK) { /* ASR fix for variable all_wildcard length follows: */ tmp_name=(char *)malloc_msg(strlen(name)+strlen(all_wildcard)+1); strcpy(tmp_name, name); root->fsptr=malloc_str(tmp_name); xwild_to_canonical(tmp_name); result=wild_list(root, search_flist, tmp_name, expand_wildcards, recurse_subdirs, file_type, count); root->no_dupl=1; free(tmp_name); } else { result=wild_list(root, search_flist, name, expand_wildcards, recurse_subdirs, file_type, count); root->no_dupl=1; } #else if((tmp_name=(char *)malloc(strlen(name)+1))==NULL) { msg_cprintf(0, M_HASH_MEM_LACK, name); result=-1; } else { result=0; strcpy(tmp_name, name); case_path(tmp_name); if(add_entry(root, search_flist, tmp_name, count)) result=-1; free(tmp_name); } #endif return(result); } #if SFX_LEVEL>=ARJSFXV /* Returns pointer to the idx-th element, enlarging the CFA if required */ static unsigned char FAR *cfa_get_index(FILE_COUNT idx) { FILE_COUNT fblock; if(flist_array==NULL) cfa_allocated=0L; fblock=idx/CFA_BLOCK_SIZE; /* Enlarge the CFA */ if(fblock>=cfa_allocated) { flist_array=(unsigned char FAR * FAR *) farrealloc_msg( flist_array, (fblock+1)*sizeof(char FAR *) ); while(cfa_allocated<=fblock) flist_array[cfa_allocated++]=NULL; } /* Allocate a new block if it has been empty before */ if(flist_array[fblock]==NULL) flist_array[fblock]=(char FAR *)farmalloc_msg((CFA_BLOCK_SIZE+3)>>2); return(flist_array[fblock]+((idx%CFA_BLOCK_SIZE)>>2)); } /* Releases the CFA structure */ void cfa_shutdown() { unsigned long i; if(flist_array!=NULL) { for(i=0; i>pos_num); } /* Stores an element in the CFA */ void cfa_store(FILE_COUNT num, int value) { int pos_num; unsigned char bit_mask, value_bits; unsigned char FAR *p; pos_num=(int)(num%4)<<1; bit_mask=(unsigned char)3<>2; flist_array=farmalloc_msg(bytes+1); for(i=0; i=ARJSFXV||defined(ARJUTIL) /* Allocates a block of far memory, executes error stub if failed. Implementation-dependent (farmalloc for Borland, _fmalloc for MS C) */ void FAR *farmalloc_msg(unsigned long size) { void FAR *tmp; #if defined(DEBUG)&&!defined(ARJUTIL) if(debug_enabled&&strchr(debug_opt, 'm')!=NULL) printf("(Fm%u", size); #endif if((tmp=farmalloc(size))==NULL) #ifdef ARJUTIL { printf("Failed to farmalloc(%lu)\n", size); exit(1); } #else error(M_OUT_OF_MEMORY); #endif #if defined(DEBUG)&&!defined(ARJUTIL) if(debug_enabled&&strchr(debug_opt, 'm')!=NULL) printf(")"); #endif return(tmp); } #endif #if SFX_LEVEL>=ARJSFX /* Reallocates a block of far memory, executes error stub if failed. Implementation-dependent (farrealloc for Borland, _frealloc for MS C) */ void FAR *farrealloc_msg(void FAR *memblock, unsigned long size) { void FAR *tmp; if((tmp=farrealloc(memblock, size))==NULL) error(M_OUT_OF_MEMORY); return(tmp); } #endif #ifdef REARJ /* Replaces all LF characters with 0's, returning the end of string */ char *tokenize_lf(char *str) { while(*str!='\0') { if(*str=='\n') *str='\0'; str++; } return(str); } #endif arj-3.10.22/misc.h 666 0 0 6626 10015512742 7760 0ustar /* * $Id: misc.h,v 1.2 2004/02/20 23:18:59 andrew_belov Exp $ * --------------------------------------------------------------------------- * Prototypes of the functions located in MISC.C are declared here. * */ #ifndef MISC_INCLUDED #define MISC_INCLUDED #include "arjtypes.h" #include "filelist.h" /* ASCIIZ string copy macro */ #define strcpyn(dest, src, n) \ { \ strncpy(dest, src, n-1); \ (dest)[n-1]='\0'; \ } /* Numerical variables exchange macro */ #define swap(a, b) b^=a^=b^=a /* Prototypes */ void unix_path_to_dos(char *path); void *malloc_str(char *str); void *malloc_far_str(char FAR *str); void cur_time_stamp(struct timestamp *dest); #if !defined(TILED) #define far_strchr(str, chr) strchr(str, chr) #define far_strcmp(str1, str2) strcmp(str1, str2) #define far_stricmp(str1, str2) stricmp(str1, str2) #define far_strcat(dest, src) strcat(dest, src) #define far_strcpy(dest, src) strcpy(dest, src) #define far_strlen(str) strlen(str) #define far_memset(buf, filler, size) memset(buf, filler, size) #elif COMPILER==MSC #define far_strchr(str, chr) _fstrchr(str, chr) #define far_strcmp(str1, str2) _fstrcmp(str1, str2) #define far_stricmp(str1, str2) _fstricmp(str1, str2) #define far_strcat(dest, src) _fstrcat(dest, src) #define far_strcpy(dest, src) _fstrcpy(dest, src) #define far_strlen(str) _fstrlen(str) #define far_memset(buf, filler, size) _fmemset(buf, filler, size) #else char FAR *far_strchr(char FAR *str, char chr); int far_strcmp(char FAR *str1, char FAR *str2); int far_stricmp(char FAR *str1, char FAR *str2); char FAR *far_strcat(char FAR *dest, char FAR *src); char FAR *far_strcpy(char FAR *dest, char FAR *src); unsigned int far_strlen(char FAR *str); void FAR *far_memset(void FAR *buf, int filler, unsigned int size); #endif char FAR *far_strcpyn(char FAR *dest, char FAR *src, int limit); void to_7bit(char *str); void strupper(char *s); void strlower(char *s); #if SFX_LEVEL>=ARJ int flist_find(struct flist_root *root, char *name); int flist_is_in_archive(struct flist_root *root, char *name); int match_attrib(struct file_properties *properties); void flist_cleanup(struct flist_root *root); int flist_add(struct flist_root *root, struct flist_root *search_flist, char *name, FILE_COUNT *count, struct file_properties *properties); void flist_init(struct flist_root *root, FILE_COUNT maxfiles, char type); void flist_retrieve(char *dest, struct file_properties *properties, struct flist_root *root, FILE_COUNT entry); #endif #if SFX_LEVEL>=ARJSFXV int flist_add_files(struct flist_root *root, struct flist_root *search_flist, char *name, int expand_wildcards, int recurse_subdirs, int file_type, FILE_COUNT *count); #endif /* Compact/tradidional internal filelists. For some reason, the compact filelist feature is not used in ARJSFXV v 2.72. This hasn't been verified since then and is now being dropped -- ASR 17/01/2001 */ void cfa_shutdown(); int cfa_get(FILE_COUNT num); void cfa_store(FILE_COUNT num, int value); int cfa_init(FILE_COUNT capacity); void *malloc_msg(unsigned int size); void FAR *farmalloc_msg(unsigned long size); void FAR *farrealloc_msg(void FAR *memblock, unsigned long size); #ifdef REARJ char *tokenize_lf(char *str); #endif /* A platform-neutral far_strcmp substitution */ #ifdef CASE_SENSITIVE #define far_strccmp far_stricmp #else #define far_strccmp far_strcmp #endif #endif arj-3.10.22/msc6_os2/ 777 0 0 0 10256535570 10230 5ustar arj-3.10.22/msc6_os2/arj.def 666 0 0 152 7450452566 11507 0ustar NAME ARJ/2 WINDOWCOMPAT LONGNAMES EXETYPE OS2 DESCRIPTION 'ARJ for OS/2' PROTMODE arj-3.10.22/msc6_os2/arjcrypt.def 666 0 0 313 7450456740 12566 0ustar LIBRARY ARJCRYPT INITGLOBAL EXETYPE OS2 DESCRIPTION 'GOST 28147-89 encryption plug-in for ARJ/2' PROTMODE DATA MULTIPLE CODE LOADONCALL EXPORTS entry @1 arj-3.10.22/msc6_os2/arjdisp.def 666 0 0 161 7450452566 12367 0ustar NAME ARJ$DISP WINDOWCOMPAT LONGNAMES EXETYPE OS2 DESCRIPTION 'ARJDISP for OS/2' PROTMODE arj-3.10.22/msc6_os2/arjsfx.def 666 0 0 156 7450452566 12234 0ustar NAME ARJSFX WINDOWCOMPAT LONGNAMES EXETYPE OS2 DESCRIPTION 'ARJSFX for OS/2' PROTMODE arj-3.10.22/msc6_os2/arjsfxjr.def 666 0 0 162 7450452566 12565 0ustar NAME ARJSFXJR WINDOWCOMPAT LONGNAMES EXETYPE OS2 DESCRIPTION 'ARJSFXJR for OS/2' PROTMODE arj-3.10.22/msc6_os2/arjsfxv.def 666 0 0 160 7450452566 12415 0ustar NAME ARJSFXV WINDOWCOMPAT LONGNAMES EXETYPE OS2 DESCRIPTION 'ARJSFXV for OS/2' PROTMODE arj-3.10.22/msc6_os2/default.def 666 0 0 116 7450452566 12357 0ustar NAME DEFAULT WINDOWCOMPAT LONGNAMES EXETYPE OS2 PROTMODE arj-3.10.22/msc6_os2/rearj.def 666 0 0 154 7450452566 12040 0ustar NAME REARJ WINDOWCOMPAT LONGNAMES EXETYPE OS2 DESCRIPTION 'REARJ for OS/2' PROTMODE arj-3.10.22/msc6_os2/register.def 666 0 0 201 7450456740 12550 0ustar NAME REGISTER WINDOWCOMPAT LONGNAMES EXETYPE OS2 DESCRIPTION 'ARJ Registration Wizard for OS/2' PROTMODE arj-3.10.22/msc6_os2/sfxstub.def 666 0 0 156 7450452566 12435 0ustar NAME SFXSTUB WINDOWCOMPAT LONGNAMES EXETYPE OS2 DESCRIPTION 'ARJ/2 SFX-STUB' PROTMODE arj-3.10.22/msgbind.c 666 0 0 35703 10040213576 10462 0ustar /* * $Id: msgbind.c,v 1.6 2004/04/17 11:39:43 andrew_belov Exp $ * --------------------------------------------------------------------------- * This file creates the message files for all ARJ modules. It is essential * that it does not make use of any ARJ modules (MISC.C and so on) because it * is the first file of the project. * */ /* We need to manually include the needed files because ARJ.H may contain references to missing message header files */ #include "environ.h" #include "defines.h" #include "filemode.h" #include "misc.h" #include "crc32.h" #include "arjdata.h" #include #include #include #define MSG_SIZE 32752 /* Constant msg buffer size */ #define POOL_SIZE 51200 /* Maximum size of variable-len buf */ #define POOL_R_INC 1024 /* Realloc incrementation */ #define COLUMNS 79 /* Columns per line in I*.* */ static char msgpool[32]; /* {MSGPOOL} or {HARDERR} */ static char msgname[40]; /* {MSG_OUT_OF_MEM} */ static char targets[128]; /* {ARJ, ARJSFXV, ARJSFXJR} */ static char systems[128]; /* {DOS, OS2, WIN32, UNIX} */ static char bindings[16]; /* {S, C, or none (means ANY} */ static char locales[32]; /* {en, ru} */ static char msgtype[8]; /* {N} or {F}, for NMSG/FMSG, respectively */ static char rdir[FILENAME_MAX];/* Resource directory */ static char M_FMSG[]="FMSG"; static char M_NMSG[]="char"; static char INCL[]="#include \"bindings.h\"\n#include \"environ.h\"\n#include \"arjtypes.h\"\n\n"; static char SKIP[]="NULL"; struct pool { char name[32]; unsigned int msgs; char *data; char st_class; unsigned int safesize; unsigned int columns; unsigned int indent; unsigned long crc32; }; /* A Q&D emulation of the strupr() and strlwr() for those who don't have it */ #ifndef HAVE_STRLWR static char *strlwr(char *str) { char *p; for(p=str; *p!='\0'; p++) *p=tolower(*p); return(str); } #endif #ifndef HAVE_STRUPR static char *strupr(char *str) { char *p; for(p=str; *p!='\0'; p++) *p=toupper(*p); return(str); } #endif /* Remove given characters */ char *compress(char *i, char f) { int c, d; for(c=d=0; i[c]!='\0'; c++) { if(i[c]!=f) i[d++]=i[c]; } i[d]='\0'; return(i); } /* Strip all leading spaces */ char *ltrim(char *i) { if (i!=NULL) { unsigned int c, j; for (c=0; i[c]==' '||i[c]=='\x9'; c++); if (i[c]!=(char)0) { for (j=0; i[c]!='\0'; j++) { i[j]=i[c]; c++; } i[j]=(char)0; } } return i; } /* Strip all trailing spaces */ char *rtrim(char *i) { if (i!=NULL) { unsigned int c, j; j=0; for (c=0; i[c]!='\0'; c++) if (i[c]!=' '&&i[c]!='\x9') j=c+1; i[j]='\0'; } return i; } /* Transform "\n", "\r", "\a" and "\b" characters to the corresponding ASCII equivalents */ void patch_string(char *i) { int c, j; if (i!=NULL) { for(c=0; i[c]!='\0'; c++) { if(i[c]=='\\') { switch(i[c+1]) { case 'a': i[c]='\a'; break; case 'b': i[c]='\b'; break; case 'f': i[c]='\f'; break; case 'n': i[c]='\n'; break; case 'r': i[c]='\r'; break; case 't': i[c]='\t'; break; case 'v': i[c]='\v'; break; case '\"': i[c]='\"'; break; case '\\': i[c]='\\'; break; } for(j=c+1; i[j]!='\0'; j++) i[j]=i[j+1]; } } } } /* Get one phrase in brackets */ char *read_brackets(FILE *file, char *buf, int size, int keep) { int c, offset; /* Until the left one has been met... */ while((c=fgetc(file))!=(int)'{') if(c==-1) return(NULL); /* Now fill the buffer */ if(keep) { offset=1; buf[0]='{'; } else offset=0; while((c=fgetc(file))!=(int)'}') { if(c==-1) return(NULL); if(offset the parameter was not found. */ int is_in_brackets(char *brackets, char *param) { const char *delimiters="{, ;}"; int j, firstpos=1, inspace=0, count=0; int invert=0; for(j=1; brackets[j]!='\0'; j++) { while(brackets[firstpos]=='!') { invert=!invert; firstpos++; } if(strchr(delimiters, brackets[j])!=NULL&&!inspace) { count++; inspace=1; if(memcmp(brackets+firstpos, param, j-firstpos)==0||brackets[firstpos]=='*') return(invert?0:count); } else if(strchr(delimiters, brackets[j])==NULL&&inspace) { inspace=0; firstpos=j; } } return(invert); } /* Fetch a quoted message from the brackets. The index given varies from 1 to 32767. */ char *fetch_quotes(FILE *resfile, int index, char *buf, int size) { int c, tc, offset, qcount=0, quoted=0; FILE *tstream; char t_name[FILENAME_MAX]; int t_offset; /* Until the left one has been met... */ while((c=fgetc(resfile))!=(int)'{') if(c==EOF) return(NULL); /* Now wait until we come to the closing bracket, or... */ offset=0; while((c=fgetc(resfile))!=(int)'}') { if(c==EOF) return(NULL); /* Reference to external file (v 1.30+) */ else if(c=='@'&&!quoted&&qcount%2==0) { qcount+=2; if(qcount==index*2) { strcpy(t_name, rdir); t_offset=strlen(t_name); while((tc=fgetc(resfile))!=EOF&&(isalnum(tc)||tc=='.'||tc=='_'||tc=='\\'||tc=='/')) t_name[t_offset++]=tc; t_name[t_offset]='\0'; if((tstream=fopen(t_name, m_r))==NULL) printf("Malformed declaration: <%s>\n", t_name); else { buf[offset++]='\"'; while((tc=fgetc(tstream))!=EOF) { switch(tc) { case '\n': buf[offset++]='\\'; buf[offset++]='n'; break; case '\a': buf[offset++]='\\'; buf[offset++]='a'; break; case '\b': buf[offset++]='\\'; buf[offset++]='b'; break; case '\"': buf[offset++]='\\'; buf[offset++]='\"'; break; case '\\': buf[offset++]='\\'; buf[offset++]='\\'; break; default: buf[offset++]=tc; } } buf[offset++]='\"'; buf[offset]='\0'; fclose(tstream); return(buf); } } } else if(c=='\"'&&!quoted) { if(++qcount==index*2) { buf[offset++]='\"'; buf[offset]='\0'; return(buf); } } quoted=c=='\\'; if(offsettm_year+1900, stm->tm_mon+1, stm->tm_mday, strupr(src)); } /* And so we begin... */ int main(int argc, char **argv) { char source[FILENAME_MAX]; /* ReSource filename */ char target_i[FILENAME_MAX]; /* .C-file containing pointers */ char target_n[FILENAME_MAX]; /* All NMSGs */ char target_f[FILENAME_MAX]; /* All FMSGs */ char target_h[FILENAME_MAX]; /* Include file - all NMSGs/FMSGs */ char target[FILENAME_MAX], locale[15]; char c_system[32]; char binding; char *msg_buffer; /* Messages may be large enough... */ struct pool pool[32]; /* Up to 32 separate msg arrays */ int tpool, cur_pool=0, i; int buf_len; FILE *resfile, *ifile, *nfile, *ffile, *hfile; char pathsep[2]; printf("MSGBIND v 1.65 [14/12/2002] Not a part of any binary package!\n\n"); if(argc<6) { printf("Usage: MSGBIND [target directory],\n" " e.g, to build MSG_SFXV.*, type MSGBIND MSG.RES MSG_SFXV DOS en\n" "\n" "The target directory is optional. If specified (e.g., BINARIES\\ENGLISH), all\n" "compiled .C files will be placed there.\n"); exit(1); } msg_buffer=(char *)malloc_msg(MSG_SIZE); build_crc32_table(); pathsep[0]=PATHSEP_DEFAULT; pathsep[1]='\0'; strcpyn(source, argv[1], sizeof(source)-8); /* Fix for GCC/EMX: convert UNIX-like representations to DOS */ #if PATHSEP_UNIX!=PATHSEP_DEFAULT for(i=0; source[i]!='\0'; i++) if(source[i]==PATHSEP_UNIX) source[i]=PATHSEP_DEFAULT; #endif if(strrchr(source, PATHSEP_DEFAULT)==NULL) rdir[0]='\0'; else { strcpy(rdir, source); strrchr(rdir, PATHSEP_DEFAULT)[1]='\0'; } strcpyn(target, argv[2], sizeof(target)-8); strcpyn(c_system, argv[3], sizeof(c_system)); binding=tolower(argv[4][0]); /* Beginning with v 1.21, target directory may be also specified */ if(argc==7) { strcpyn(target_i, argv[6], sizeof(target_i)-8); strcpyn(target_n, argv[6], sizeof(target_n)-8); strcpyn(target_f, argv[6], sizeof(target_f)-8); strcpyn(target_h, argv[6], sizeof(target_f)-8); /* v 1.41+ */ if(argv[6][strlen(argv[6])-1]!=PATHSEP_DEFAULT); { strcat(target_i, pathsep); strcat(target_n, pathsep); strcat(target_f, pathsep); strcat(target_h, pathsep); } } else { target_i[0]='\0'; target_n[0]='\0'; target_f[0]='\0'; target_h[0]='\0'; } strcat(target_i, "i"); strcat(target_n, "n"); strcat(target_f, "f"); strcat(target_i, argv[2]); strcat(target_n, argv[2]); strcat(target_f, argv[2]); strcat(target_h, argv[2]); /* The source has the extension .MSG, the targets are .H and .C */ if(strchr(source, '.')==NULL) strcat(source, ".msg"); strcat(target_i, ".c"); strcat(target_n, ".c"); strcat(target_f, ".c"); strcat(target_h, ".h"); strcpyn(locale, argv[5], sizeof(locale)); strlwr(target); strlwr(c_system); strlwr(locale); /* Block out all signals, since this transaction is mission-critical */ signal(SIGINT, SIG_IGN); #ifndef NO_TERM_HDL signal(SIGTERM, SIG_IGN); #endif if((resfile=fopen(source, m_r))==NULL) { printf("Can't open source file!\n"); exit(2); } if((ifile=fopen(target_i, m_w))==NULL) { printf("Can't open index file!\n"); exit(3); } if((nfile=fopen(target_n, m_w))==NULL) { printf("Can't open NMSG output file!\n"); exit(3); } if((ffile=fopen(target_f, m_w))==NULL) { printf("Can't open FMSG output file!\n"); exit(3); } if((hfile=fopen(target_h, m_w))==NULL) { printf("Can't open .h output file!\n"); exit(3); } put_hdr(ifile, target_i, source); put_hdr(nfile, target_n, source); put_hdr(ffile, target_f, source); put_hdr(hfile, target_h, source); fputs(INCL, ifile); fputs(INCL, nfile); fputs(INCL, ffile); fprintf(ifile, "#include \""); for(i=0; target_h[i]!='\0'; i++) fputc(target_h[i]=='\\'?'/':target_h[i], ifile); fprintf(ifile, "\"\n\n"); /* Ack. Now process the source file line by line... */ while(get_msg(resfile, target, c_system, binding, locale, msg_buffer, MSG_SIZE)!=NULL) { expand_tags(msg_buffer, MSG_SIZE); fprintf(toupper(msgtype[0])=='N'?nfile:ffile, "char %s[]=%s;\n", msgname, msg_buffer); fprintf(hfile, "extern %s %s[];\n", toupper(msgtype[0])=='N'?M_NMSG:M_FMSG, msgname); /* Check if the message belongs to a pre-defined message pool */ if(strcmp(msgpool, SKIP)) { /* Pick a message heap */ for(tpool=0; tpool=sizeof(pool)) { printf("Too many message groups!\n"); exit(4); } strcpy(pool[tpool].name, msgpool); pool[tpool].msgs=0; pool[tpool].crc32=CRC_MASK; pool[tpool].safesize=POOL_R_INC; pool[tpool].data=(char *)malloc_msg(POOL_R_INC); pool[tpool].st_class=toupper(msgtype[0])=='N'?'N':'F'; sprintf(pool[tpool].data, "%cMSGP %s []={", pool[tpool].st_class, msgpool); pool[tpool].columns=pool[tpool].indent=strlen(pool[tpool].data); cur_pool++; } pool[tpool].msgs++; if(strlen(pool[tpool].data)+strlen(msgname)+pool[tpool].indent+16>pool[tpool].safesize) { if((pool[tpool].safesize+=POOL_R_INC)>POOL_SIZE) { printf("Message pool for %s exceeded %u bytes, exiting\n", msgpool, POOL_SIZE); } if((pool[tpool].data=realloc(pool[tpool].data, pool[tpool].safesize))==NULL) { printf("Unexpected lack of memory!r\n"); exit(5); } } if((pool[tpool].columns+=strlen(msgname))>COLUMNS) { strcat(pool[tpool].data, "\n"); pool[tpool].columns=pool[tpool].indent; pool[tpool].data[strlen(pool[tpool].data)+pool[tpool].indent]='\0'; memset(pool[tpool].data+strlen(pool[tpool].data), 32, pool[tpool].indent); } strcat(pool[tpool].data, msgname); strcat(pool[tpool].data, ", "); strcpy(msg_buffer, msg_buffer+1); buf_len=strlen(msg_buffer); msg_buffer[--buf_len]='\0'; patch_string(msg_buffer); crc32term=pool[tpool].crc32; crc32_for_string(msg_buffer); pool[tpool].crc32=crc32term; } } fputs("\n", hfile); /* First, flush the message pools... */ for(tpool=0; tpoolhf=CreateFile(name, is_write?GENERIC_WRITE:GENERIC_READ, FILE_SHARE_READ|FILE_SHARE_WRITE, NULL, OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, 0))==INVALID_HANDLE_VALUE) { free(rc); return(NULL); } rc->is_write=is_write; rc->lpcontext=NULL; rc->rem.LowPart=rc->rem.HighPart=0; return(rc); } /* Finalize a backup operation before closing the stream */ static void finalize_backup(struct nt_sid *sid) { DWORD dummy; if(sid->lpcontext!=NULL) { if(sid->is_write) BackupWrite(sid->hf, NULL, 0, &dummy, TRUE, FALSE, &sid->lpcontext); #if SFX_LEVEL>=ARJ else BackupRead(sid->hf, NULL, 0, &dummy, TRUE, FALSE, &sid->lpcontext); #endif sid->lpcontext=NULL; } } /* Close a stream operations handle */ void close_streams(struct nt_sid *sid) { finalize_backup(sid); CloseHandle(sid->hf); } /* Skip to the next stream */ int next_stream(WIN32_STREAM_ID *dest, struct nt_sid *sid) { DWORD lo, hi, b; if(sid->is_write) return(-1); if(sid->rem.LowPart!=0||sid->rem.HighPart!=0) { if(!BackupSeek(sid->hf, sid->rem.LowPart, sid->rem.HighPart, &lo, &hi, &sid->lpcontext)) return(-1); if(lo!=sid->rem.LowPart||hi!=sid->rem.HighPart) return(-1); sid->rem.LowPart=sid->rem.HighPart=0; } if(!BackupRead(sid->hf, (unsigned char *)dest, W32_SID_HEADER_SIZE, &b, FALSE, TRUE, &sid->lpcontext)) return(-1); if(b!=W32_SID_HEADER_SIZE) return(-1); sid->rem=dest->Size; return(0); } /* Looks for a specific stream ID. Returns stream size. */ unsigned long seek_stream_id(DWORD id, struct nt_sid *sid) { int tampered; WIN32_STREAM_ID winsid; /* Perform 1st iteration for "virgin" streams (that haven't yet been operated with). Redo the lookup in a second operation if the streams were in use. */ tampered=(sid->lpcontext!=NULL)?1:0; do { while(!next_stream(&winsid, sid)) { if(winsid.dwStreamId==id) return((winsid.Size.HighPart>0)?0xFFFFFFFF:winsid.Size.LowPart); } finalize_backup(sid); } while(tampered--); return(0); } #if SFX_LEVEL>=ARJ /* Read from a stream */ unsigned long read_stream(unsigned char *dest, unsigned long bytes, struct nt_sid *sid) { unsigned long br, rc; if(sid->is_write) return(0); br=(sid->rem.HighPart==0&&sid->rem.LowPartrem.LowPart:bytes; if(br==0) return(0); if(!BackupRead(sid->hf, dest, br, &rc, FALSE, TRUE, &sid->lpcontext)) return(0); sid->rem=LargeIntegerSubtract(sid->rem, ConvertUlongToLargeInteger(rc)); return(rc); } #endif /* Initialize a new stream before writing */ int create_stream(WIN32_STREAM_ID *src, struct nt_sid *sid) { DWORD lo, hi, b; if(!sid->is_write) return(-1); if(sid->rem.LowPart!=0&&sid->rem.HighPart!=0) { if(!BackupSeek(sid->hf, sid->rem.LowPart, sid->rem.HighPart, &lo, &hi, &sid->lpcontext)) return(-1); if(lo!=sid->rem.LowPart||hi!=sid->rem.HighPart) return(-1); sid->rem.LowPart=sid->rem.HighPart=0; } if(!BackupWrite(sid->hf, (unsigned char *)src, W32_SID_HEADER_SIZE, &b, FALSE, TRUE, &sid->lpcontext)) return(-1); if(b!=W32_SID_HEADER_SIZE) return(-1); sid->rem=src->Size; return(0); } /* Write to a stream */ unsigned long write_stream(unsigned char *src, unsigned long bytes, struct nt_sid *sid) { unsigned long bw, rc; if(!sid->is_write) return(0); /* This is crucial to prevent overflow */ bw=(sid->rem.HighPart==0&&sid->rem.LowPartrem.LowPart:bytes; if(bw==0) return(0); if(!BackupWrite(sid->hf, src, bw, &rc, FALSE, TRUE, &sid->lpcontext)) return(0); sid->rem=LargeIntegerSubtract(sid->rem, ConvertUlongToLargeInteger(rc)); return(rc); } #endif arj-3.10.22/ntstream.h 666 0 0 2367 7614524314 10651 0ustar /* * $Id: ntstream.h,v 1.1 2003/01/25 15:10:04 andrew_belov Exp $ * --------------------------------------------------------------------------- * Prototypes of the functions located in NTSTREAM.C are declared here. * * */ #ifndef NTSTREAM_INCLUDED #define NTSTREAM_INCLUDED #if TARGET==WIN32 #include /* Read/write (backup/restore) modes */ #define NTSTREAMS_READ 0 #define NTSTREAMS_WRITE 1 /* NT stream operations structure */ struct nt_sid { HANDLE hf; /* Win32 file handle */ LARGE_INTEGER rem; /* Bytes remaining in xaction */ int is_write; /* 1 = write */ LPVOID lpcontext; /* !NULL = need to finalize */ }; /* Prototypes */ struct nt_sid *open_streams(char *name, int is_write); void close_streams(struct nt_sid *sid); int next_stream(WIN32_STREAM_ID *dest, struct nt_sid *sid); unsigned long seek_stream_id(DWORD id, struct nt_sid *sid); unsigned long read_stream(unsigned char *dest, unsigned long bytes, struct nt_sid *sid); int create_stream(WIN32_STREAM_ID *src, struct nt_sid *sid); unsigned long write_stream(unsigned char *src, unsigned long bytes, struct nt_sid *sid); #endif /* TARGET==WIN32 */ #endif arj-3.10.22/packager.c 666 0 0 32313 10040213576 10606 0ustar /* * $Id: packager.c,v 1.10 2004/04/17 11:39:43 andrew_belov Exp $ * --------------------------------------------------------------------------- * ARJ distribution packaging tool. * */ #include "arj.h" #include "arjdata.h" #if TARGET==UNIX #include #endif #define P PATHSEP_DEFSTR /* Dirty hack for compaction */ #if TARGET==UNIX #define REGWIZ "arj-register" #else #define REGWIZ "register" #endif /* mkdir() macro */ #if TARGET==UNIX||defined(__EMX__) #define md(p) mkdir(p, 0755) #else #define md(p) mkdir(p) #endif static char strform[]="%s"; static char sfx_name[16]; static char buf[2048]; static char l_nullstr[]=""; /* Q&D tolower() */ static void arj_strlwr(char *str) { char p; while((p=*str)!='\0') { if(p>='A'&&p<='Z') { p+=32; *str=p; } str++; } } /* A smart fopen() */ static FILE *s_fopen(char *name, char *mode) { FILE *rc; if((rc=fopen(name, mode))==NULL) { printf("Can't open %s\n", name); exit(2); } return(rc); } /* Line-by-line output routine. Involves macro expansion. */ static void out_line(FILE *stream, char *str) { strcpyn(buf, str, sizeof(buf)); expand_tags(buf, sizeof(buf)); fprintf(stream, strform, buf); } /* Transfer a file, expanding the tags */ static void transfer_file(char *dest, char *src) { FILE *istream; FILE *ostream; istream=s_fopen(src, "r"); ostream=s_fopen(dest, "w"); while(fgets(buf, sizeof(buf), istream)) { expand_tags(buf, sizeof(buf)); fputs(buf, ostream); } fclose(istream); fclose(ostream); } /* Packages a binary or other file, transforming to a UNIX-style path */ #if TARGET==UNIX static void package_unix(FILE *stream, char *name, char *trunk, char *realpath, char *unixpath) { char realname[CCHMAXPATH], unixname[CCHMAXPATH]; /* Compose the trunk path, e.g. "freebsd3.4/en/rc/" */ strcpy(realname, trunk); strcpy(unixname, trunk); strcat(realname, P); strcat(unixname, P); /* Now, make "freebsd3.4/en/rc/arj" and "freebsd3.4/en/rc/u/bin" */ strcat(realname, realpath); /* arj */ if(realpath[0]!='\0') strcat(realname, P); strcat(unixname, "u"); /* u */ md(unixname); strcat(unixname, P); strcat(unixname, unixpath); /* u/bin */ md(unixname); strcat(unixname, P); /* Append the names */ strcat(realname, name); strcat(unixname, name); unlink(unixname); if(link(realname, unixname)) { printf("Failed to link <%s> to <%s>\n", realname, unixname); exit(1); } fprintf(stream, "%s" P "%s\n", unixpath, name); } #endif /* Arranges text file packaging (realpath -> resource, trunk -> compiler/en/rc/...) */ static void package_txt(FILE *stream, char *name, char *trunk, char *realpath, char *unixpath) { char tmp_name[CCHMAXPATH], realname[CCHMAXPATH]; char *p; strcpy(tmp_name, trunk); strcat(tmp_name, P); strcat(tmp_name, name); strcpy(realname, realpath); strcat(realname, P); strcat(realname, name); transfer_file(tmp_name, realname); #if TARGET==UNIX package_unix(stream, name, trunk, "", unixpath); #else fprintf(stream, "%s\n", tmp_name); #endif } /* Arranges binary file packaging (realpath -> arj, trunk -> compiler/en/rc/...) */ static void package_bin(FILE *stream, char *name, char *trunk, char *realpath, char *unixpath) { #if TARGET==UNIX package_unix(stream, name, trunk, realpath, unixpath); #else fprintf(stream, "%s" P "%s" P "%s\n", trunk, realpath, name); #endif } /* Comment creation routine */ static void create_cmt(char *dest) { FILE *stream; /* Output path tricks */ #if TARGET==UNIX char subdir[]="/usr/local/"; #elif TARGET==OS2 char subdir[]="C:" P "ARJ" P "OS2" P; /* Historical (since ARJ/2 v 2.61) */ #elif TARGET==DOS||TARGET==WIN32 char subdir[]="C:" P "ARJ" P; #endif char tmp_str[128], out_str[128]; int i, l; stream=s_fopen(dest, "w"); fprintf(stream, ")) %s -m -b -x\n\n", subdir); /* Version string */ sprintf(tmp_str, "%s", #if LOCALE==LANG_en #if TARGET==DOS "ARJ v @VERSION manufacturing refresh by ARJ Software Russia All rights reserved" #else "@PRODUCT v @VERSION, (c) 1998-@{y}, ARJ Software Russia. All rights reserved." #endif #elif LOCALE==LANG_de #if TARGET==DOS "ARJ @VERSION Produktionsauffrischung, ARJ Software Russia Alle Rechte vorbehalten" #else "ARJ fr @PLATFORM @VERSION (c) 1998-@{y}, ARJ Software Russia. Alle Rechte vorbehalten." #endif #elif LOCALE==LANG_ru "ARJ v @VERSION, (c) 1998-@{y}, ARJ Software Russia." #endif ); expand_tags(tmp_str, sizeof(tmp_str)); sprintf(out_str, "@{c40}%s@{_}\n", tmp_str); out_line(stream, out_str); l=strlen(tmp_str); for(i=0; i ,\n" " e.g, PACKAGER msc6_os2/en/rc/arj msc6_os2/en/ds/arj\n" "\n" "This program finalizes the resources and performs packaging of the given brach.\n"); exit(1); } strcpy(buf, "@VERSION"); expand_tags(buf, sizeof(buf)-1); if((p=strchr(buf, '.'))!=NULL) { strcpy(p, p+1); if((p=strchr(buf, '.'))!=NULL) *p='\0'; } memset(version_tag, 0, sizeof(version_tag)); memcpy(version_tag, buf, 3); sprintf(pkg_rsp_draft, "%s" P "pkg_dft.rsp", argv[2]); sprintf(pkg_rsp, "%s" P "pkg.rsp", argv[2]); sprintf(tmp_name, "%s" P "cmt.txt", argv[2]); create_cmt(tmp_name); ostream=s_fopen(pkg_rsp_draft, "w"); sprintf(sfx_name, "%s%c%c%s", family_tag, os_tag, lang_tag, version_tag); /* Flush the main line */ #ifdef DEBUG #if defined(linux) strcpy(buf, ".lnx"); #elif defined(__FreeBSD__) strcpy(buf, ".bsd"); #elif defined(__QNXNTO__) strcpy(buf, ".qnx"); #else buf[0]='\0'; #endif strcat(buf, " -h#YYYYMMDD"); /* The classic debug by-date format */ #else strcpy(buf, sfx_name); #endif #if TARGET==UNIX sprintf(platform_specific, "-e1 %s" P "u" P, argv[2]); #else strcpy(platform_specific, "-e"); #endif /* Dispose of previous package */ sprintf(arj_cmds, "retail" P "%s" EXE_EXTENSION, buf); unlink(arj_cmds); /* "-hz" removed - no commercial versions */ sprintf(arj_cmds, "a -2e.*TYPE -jm -z%s -y -je -va retail" P "%s %s", tmp_name, buf, platform_specific); /* Create doc repository */ #if TARGET==UNIX sprintf(platform_specific, "%s" P "u", argv[2]); md(platform_specific); strcat(platform_specific, P "doc"); md(platform_specific); #endif /* Proceed with the files */ package_bin(ostream, "arj" EXE_EXTENSION, argv[2], "arj", "bin"); #if LOCALE==LANG_ru package_bin(ostream, "arjcrypt" MOD_EXTENSION, argv[2], "arjcrypt", "lib"); #endif package_bin(ostream, "rearj" EXE_EXTENSION, argv[2], "rearj", "bin"); package_bin(ostream, REGWIZ EXE_EXTENSION, argv[2], "register", "bin"); package_bin(ostream, "arjdisp" EXE_EXTENSION, argv[2], "arjdisp", "bin"); #if TARGET==DOS /* ASR 20/02/2001 -- we were supposed to divert it for various platforms but it remains DOS-specific as for now */ package_txt(ostream, "rearj.cfg", argv[2], "resource", "doc"); #elif TARGET==UNIX /* Provide an InfoZIP and .tar.gz-capable configuration */ package_txt(ostream, "rearj.cfg.example", argv[2], "resource", "doc" P "arj"); #endif package_txt(ostream, "readme.txt", argv[2], "resource" P LOCALE_DESC, "doc" P "arj"); package_txt(ostream, "history.txt", argv[2], "resource" P LOCALE_DESC, "doc" P "arj"); strcpy(tmp_name, "@PLATFORM_FN.txt"); expand_tags(tmp_name, sizeof(tmp_name)); arj_strlwr(tmp_name); package_txt(ostream, tmp_name, argv[2], "resource" P LOCALE_DESC, "doc" P "arj"); package_txt(ostream, "COPYING", argv[2], "doc", "doc" P "arj"); package_txt(ostream, "file_id.diz", argv[2], "resource" P LOCALE_DESC, "doc" P "arj"); /* Share our secrets with the debugging team */ #ifdef DEBUG package_txt(ostream, "rev_hist.txt", argv[2], "doc", "doc" P "arj"); package_txt(ostream, "debug.txt", argv[2], "doc", "doc" P "arj"); package_txt(ostream, "glossary.txt", argv[2], "doc", "doc" P "arj"); #endif fclose(ostream); istream=s_fopen(pkg_rsp_draft, "r"); ostream=s_fopen(pkg_rsp, "w"); fprintf(ostream, "%s\n", arj_cmds); while(fgets(buf, sizeof(buf), istream)!=NULL) { fputs(buf, ostream); #ifdef MAKESYM if((p=strstr(buf, EXE_EXTENSION))!=NULL|| (p=strstr(buf, MOD_EXTENSION))!=NULL) { pname=strrchr(buf, PATHSEP_DEFAULT); if(pname!=NULL) { *pname++='\0'; ppath=buf; } else { pname=buf; ppath=l_nullstr; } *p='\0'; chdir(ppath); strcat(pname, ".map"); if(!access(pname, 0)) { fprintf(ostream, "%s" P "%s\n", ppath, pname); sprintf(cmdline, "mapsym %s", pname); system(cmdline); strcpy(p, ".sym"); if(!access(pname, 0)) fprintf(ostream, "%s" P "%s\n", ppath, pname); } if(*ppath!='\0') { p=ppath; do { chdir(".."); p=strchr(p+1, PATHSEP_DEFAULT); } while(p!=NULL); } } #endif } fclose(istream); fclose(ostream); unlink(pkg_rsp_draft); /* Pack the files. */ sprintf(cmdline, "%s" P "arj" P "arj @%s -+", argv[1], pkg_rsp); system(cmdline); unlink(pkg_rsp); return(0); } arj-3.10.22/postproc.c 666 0 0 16534 7675307434 10712 0ustar /* * $Id: postproc.c,v 1.5 2003/06/22 11:12:28 andrew_belov Exp $ * --------------------------------------------------------------------------- * This program stores the CRC and file size of ARJ.EXE in it, so an * integrity check may be performed with ARJ i. * */ #include "arj.h" /* Operations */ #define PP_NONE 0 /* No action */ #define PP_DEFAULT 1 /* Calculate and store the CRC */ #define PP_ARJSFX 2 /* Remove LZEXE signature */ /* Errorlevels/return codes. If something went wrong, look here */ #define POSTPROC_ERL_SUCCESS 0 #define POSTPROC_ERL_WARNING 1 /* Non-fatal error */ #define POSTPROC_ERL_CANTOPEN 2 /* Can't open file */ #define POSTPROC_ERL_BAD_EXE 3 /* Malformed EXE file */ #define POSTPROC_ERL_NO_INTEGR 4 /* Integrity pattern not found */ #define POSTPROC_ERL_CANT_WRITE 5 /* Data was not written */ /* Patterns in EXE files */ static unsigned char reg_crc_pattern[]={0xB0, 0x01, 0xB0, 0x02, 0xB0, 0x03, 0xB0, 0x04, 0xB0, 0x05, 0}; static unsigned char encryption_pattern[]={0xB0, 0x02, 0xB0, 0x02, 0xB0, 0x03, 0xB0, 0x04, 0xB0, 0x05, 0}; static unsigned char integrity_pattern[]={0xB0, 0x03, 0xB0, 0x02, 0xB0, 0x03, 0xB0, 0x04, 0xB0, 0x05, 0}; static unsigned short self_check[]={0x9090, 0x9090, 0x138, 0x9090, 0x9090}; /* Processing buffer */ static char buf[PROC_BLOCK_SIZE]; static void _fput_dword(const unsigned long l, FILE *stream) { #ifdef WORDS_BIGENDIAN fputc(l ,stream); fputc(l>>8 ,stream); fputc(l>>16,stream); fputc(l>>24,stream); #else fwrite(&l,4,1,stream); #endif } /* Standard postprocessing for ARJ and REARJ */ static int pp_default(FILE *stream) { int rp_len; long cur_pos, wr_pos; int bytes_read, byte_ctr; char *pb_ptr; long fsize; int c; fseek(stream, 0L, SEEK_END); fsize=ftell(stream); fseek(stream, 0L, SEEK_SET); rp_len=strlen((char *)integrity_pattern); cur_pos=0L; while(1) { fseek(stream, cur_pos, SEEK_SET); if((bytes_read=fread(buf, 1, PROC_BLOCK_SIZE, stream))==0) { printf("Patch not found\n"); return(POSTPROC_ERL_BAD_EXE); } bytes_read-=rp_len; pb_ptr=buf; byte_ctr=0; while(byte_ctr=0; p_len--) ; if(p_len>0) printf("Slack area is clogged (%u byte(s) remaining) - can't stamp the ARJSFX signature!\n", p_len+1); else { strcpy(buf+0x79, "aRJsfX"); fseek(stream, 0L, SEEK_SET); fwrite(buf, 1, 128, stream); printf("ARJSFX signature installed at offset 0x79\n"); } } #elif defined(SUNOS) /* Some "free" space in the ELF header ... Reliable? For Linux as well? Info: */ p_len=16; sig_found=0; if(fread(buf, 1, p_len, stream) [-sfx],\n" "Where: is the EXE name to patch,\n" " -sfx does ARJSFX postprocessing (packing and signing)\n" " e.g, to patch ARJ.EXE, type POSTPROC ARJ.EXE\n"); exit(POSTPROC_ERL_WARNING); } build_crc32_table(); /* Determine the type of post-processing */ if(argc==2) pp_type=PP_DEFAULT; else if(!strcmp(argv[2], "-sfx")) pp_type=PP_ARJSFX; /* Pack the SFX */ #ifndef NP_SFX if(pp_type==PP_ARJSFX) pack_sfx(argv[1]); #endif if((stream=fopen(argv[1], m_rbp))==NULL) { printf("Can't open %s\n", argv[1]); exit(POSTPROC_ERL_CANTOPEN); } /* Run the corresponding routine */ switch(pp_type) { case PP_DEFAULT: rc=pp_default(stream); break; case PP_ARJSFX: rc=pp_arjsfx(stream); break; default: printf("No postprocessing action specified\n"); rc=POSTPROC_ERL_WARNING; } fclose(stream); return(rc); } arj-3.10.22/rearj.c 666 0 0 122065 10256070052 10157 0ustar /* * $Id: rearj.c,v 1.11 2005/06/21 19:53:14 andrew_belov Exp $ * --------------------------------------------------------------------------- * This is the main file of the REARJ utility. * */ #include #include #include #include "arj.h" #if COMPILER==BCC #include #elif COMPILER==MSC #include #endif #if TARGET==UNIX #include #endif DEBUGHDR(__FILE__) /* Debug information block */ /* Limits for "*.*"-alike processing */ #ifdef TILED #define LARGE_FLIST_SIZE 20000 #define EXCL_FLIST_SIZE 10000 #else #define LARGE_FLIST_SIZE FILELIST_CAPACITY #define EXCL_FLIST_SIZE FILELIST_CAPACITY #endif #define MAX_SUFFIXES 25 /* Number of supported suffixes */ #if TARGET!=UNIX #define MAX_SUFFIX 3 /* Consider increasing... */ #else #define MAX_SUFFIX 32 #endif #define MAX_ARGS 100 /* Maximum # of command-line args */ #if TARGET==UNIX #define REARJ_SWITCHAR "-" #else #define REARJ_SWITCHAR "/" #endif /* Time output sequence */ #define timeseq (int)log_ts.ti_hour, (int)log_ts.ti_min, (int)log_ts.ti_sec /* Configuration entry structure */ struct archiver_entry { char *suffix; char *pack_cmd; char *unpack_cmd; int hidden_supported; /* Consider making them chars */ int subdirs_supported; /* The following is an ASR fix for REARJ v 2.42.05 (.tar.gz) */ int manual_deletion; /* Can't delete errorneous archives */ }; /* Local variables */ static int logging_enabled; /* 1 if actions are to be logged */ static struct time log_ts; /* Current time (for logging) */ static int total_suffixes; /* Number of suffixes in REARJ.CFG */ static struct archiver_entry archivers[MAX_SUFFIXES]; static int target_type; /* Target archive type */ static FILE *logstream; /* Log file */ static int ctrlc_busy; /* 1 if Ctrl+C can't be processed */ static int cnv_diskette_archives; /* Convert diskette archives (-f) */ static int internal_archives_only; /* Process only internal archive files (-e) */ static int update_with_backups; /* Allow updates of archives with backup (-u) */ static int conversion_query; /* Query for conversion (-q) */ static int skip_size_check; /* Do not check total size and count */ static int run_preunpack_cmd; /* Run a cmd. before unpacking */ static int run_precount_cmd; /* 1 if a command must be run before counting files */ static int run_extract_cmd; /* Run a command when all files have been extracted */ static int testing_mode; /* /Y testing mode */ static char *backup_extension; /* "BAK" (without a preceding dot) */ static char dot[]="."; /* Widely-used symbol */ static char work_dir[CCHMAXPATH]; /* Working directory */ static char name_fetch[CCHMAXPATH]; /* For parsing list files */ static int default_suffix; /* For non-standard extensions */ static char *tmp_dir; static char *preunpack_cmd_text; static char *precount_cmd_text; static char *extract_cmd_text; static struct timestamp ts_newer; static struct timestamp ts_older; static int limit; static int cleanup_initiated; static int ctrlc_initiated; static int skip_packing; static int skip_rearj_sw; static int skip_larger_output; static int skip_timestamping; static int pick_older; /* Pick older archives (/m) */ static int pick_newer; /* Pick newer archives (/n) */ static int exclusion_assigned; /* Never used but implemented (/x) */ static int convert_nested_archives; static char *acc_nested_suffixes; /* Filter for nested archives */ static int delete_original_archives; static unsigned long total_old_fsize, total_new_fsize; static int skip_lfn; static int chk_integrity; static char *suffix_override; static char *log_name; static char *target_suffix; static char *testing_marker; /* Text to write (/Y****) */ static char *timestr_older; static char *timestr_newer; static FILE *liststream; static struct date x_date; static int work_directory_assigned; static int skip_count; static int clear_tmp_dir; /* 1 if files in tmp. dir must be removed upon shutdown */ static char *arg_ptr[MAX_ARGS]; /* Argument table */ static char u_strform[]="%S"; static char single_spc[]=" "; static int n_args; static int tmpdir_malloced; static char rearj_sw[]="REARJ_SW"; /* Filenames/extensions */ static char backup_ext[]="bak"; static char cfg_name[]="rearj.cfg"; static char rearj_log[]="rearj.log"; /* Pauses the execution and displays an error */ void pause_error(FMSG *msg) { arj_delay(5); msg_cprintf(H_ERR, msg); exit(REARJ_ERL_WARNING); } /* Resets the attributes of all files in the current directory */ static void reset_attrs() { char tmp_name[CCHMAXPATH]; struct flist_root tmp_flist; FILE_COUNT i; strcpy(tmp_name, all_wildcard); flist_init(&tmp_flist, LARGE_FLIST_SIZE, 0, 0); wild_list(&tmp_flist, tmp_name, FETCH_DIRS, 1, 1, NULL); for(i=0; i0)?-1:0); } /* Returns total number of the files located in the current directory */ static FILE_COUNT count_files() { char tmp_name[CCHMAXPATH]; struct flist_root tmp_flist; FILE_COUNT rc; strcpy(tmp_name, all_wildcard); flist_init(&tmp_flist, LARGE_FLIST_SIZE, 0, 0); wild_list(&tmp_flist, tmp_name, FETCH_DIRS, 1, 1, NULL); rc=tmp_flist.files; flist_cleanup_proc(&tmp_flist); return(rc); } /* Recursively removes files and subdirectories */ static void recursive_unlink(char *name) { struct new_ffblk new_ffblk; char tmp_name[CCHMAXPATH]; char subdir_wildcard[20]; int attr_mask; int result; attr_mask=STD_FI_ATTRS; result=lfn_findfirst(name, &new_ffblk, attr_mask); while(result==0) { if(new_ffblk.ff_attrib&STD_DIR_ATTR) { if(strcmp(new_ffblk.ff_name, cur_dir_spec)&&strcmp(new_ffblk.ff_name, up_dir_spec)) { split_name(name, tmp_name, subdir_wildcard); if(strlen(new_ffblk.ff_name)+strlen(tmp_name)+strlen(subdir_wildcard)+2>=CCHMAXPATH) error(M_MAXDIR_EXCEEDED, tmp_name); strcat(tmp_name, new_ffblk.ff_name); strcat(tmp_name, pathsep_str); strcat(tmp_name, subdir_wildcard); case_path(tmp_name); recursive_unlink(tmp_name); /* Remove the directory itself */ split_name(name, tmp_name, NULL); strcat(tmp_name, new_ffblk.ff_name); flush_kbd(); file_chmod(tmp_name, 1, 0); if(file_rmdir(tmp_name)) error(M_CANT_RMDIR, tmp_name); } } else { split_name(name, tmp_name, NULL); strcat(tmp_name, new_ffblk.ff_name); case_path(tmp_name); flush_kbd(); file_chmod(tmp_name, 1, 0); if(file_unlink(tmp_name)) error(M_CANT_UNLINK, tmp_name); } result=lfn_findnext(&new_ffblk); } lfn_findclose(&new_ffblk); } /* Releases the working directory -- ASR fix 14/11/2000 */ static void release_dir(char *dir) { char tmp_name[4]; #ifdef HAVE_DRIVES if(dir[0]!='\0'&&dir[1]==':') { memcpy(tmp_name, dir, 2); strcpy(tmp_name+2, pathsep_str); } else strcpy(tmp_name, pathsep_str); #else strcpy(tmp_name, pathsep_str); #endif file_chdir(tmp_name); } /* Removes all files on the specified drive/path */ static void unlink_all(char *path) { char tmp_path[CCHMAXPATH]; char c; strcpy(tmp_path, path); case_path(tmp_path); c=tmp_path[strlen(tmp_path)-1]; #ifdef HAVE_DRIVES strcat(tmp_path, (c==PATHSEP_DEFAULT||c==':')?all_wildcard:root_wildcard); #else strcat(tmp_path, (c==PATHSEP_DEFAULT)?all_wildcard:root_wildcard); #endif if(no_file_activity) msg_cprintf(H_HL|H_NFMT, M_DELETING, tmp_path); recursive_unlink(tmp_path); } /* Writes a "SKIPPED" log entry */ static void log_as_skipped(char *name, int reason) { if(logging_enabled) { arj_gettime(&log_ts); if(fprintf(logstream, M_LOGENTRY_SKIP, timeseq, archivers[target_type].suffix, reason, name)<=0) error(M_CANT_WRITE_LOG); } } /* Checks if any subdirectories are present in the current directory */ static int check_for_dirs() { char tmp_name[CCHMAXPATH]; struct new_ffblk new_ffblk; int attr_mask; int result; strcpy(tmp_name, all_wildcard); attr_mask=STD_FI_ATTRS; result=lfn_findfirst(tmp_name, &new_ffblk, attr_mask); while(result==0) { if(new_ffblk.ff_attrib&STD_DIR_ATTR&&strcmp(new_ffblk.ff_name, cur_dir_spec)&&strcmp(new_ffblk.ff_name, up_dir_spec)) { lfn_findclose(&new_ffblk); return(1); } result=lfn_findnext(&new_ffblk); } lfn_findclose(&new_ffblk); return(0); } /* Checks if any files and/or subdirectories are present in the current directory */ static int check_for_entries() { char tmp_name[CCHMAXPATH]; struct new_ffblk new_ffblk; int attr_mask; int result; strcpy(tmp_name, all_wildcard); attr_mask=STD_FI_ATTRS; result=lfn_findfirst(tmp_name, &new_ffblk, attr_mask); while(result==0) { if(!(new_ffblk.ff_attrib&STD_DIR_ATTR)) { lfn_findclose(&new_ffblk); return(1); } else if(strcmp(new_ffblk.ff_name, cur_dir_spec)&&strcmp(new_ffblk.ff_name, up_dir_spec)) { lfn_findclose(&new_ffblk); return(1); } result=lfn_findnext(&new_ffblk); } lfn_findclose(&new_ffblk); return(0); } /* Returns a fully-qualified filename */ static int truename(char *dest, char *name) { char tmp_name[CCHMAXPATH], cur_dir[CCHMAXPATH]; int tmp_entry; #ifdef HAVE_DRIVES int dsk; #endif tmp_entry=split_name(name, dest, tmp_name); /* Verify if it's a root directory path or file path */ if( #ifdef HAVE_DRIVES (dest[1]!=':'||dest[2]!='\0')&& (dest[1]!=':'||dest[2]!=PATHSEP_DEFAULT||dest[3]!='\0')&& #endif (dest[0]!=PATHSEP_DEFAULT||dest[1]!='\0')&& (tmp_entry>0)) dest[tmp_entry-1]='\0'; #ifdef HAVE_DRIVES dsk=getdisk(); if(dest[1]==':') setdisk(toupper(dest[0])-'A'); #endif if(file_getcwd(cur_dir)==NULL) { msg_cprintf(0, M_GETCWD_FAILED); return(1); } if( #ifdef HAVE_DRIVES (dest[1]!=':'||dest[2]!='\0')&& #endif dest[0]!='\0') { if(file_chdir(dest)) { msg_cprintf(H_HL|H_NFMT, M_PATH_NOT_FOUND, dest); termination: if(file_chdir(cur_dir)) error(M_CANT_CHDIR, cur_dir); #ifdef HAVE_DRIVES setdisk(dsk); #endif return(1); } } if(file_getcwd(dest)==NULL) { msg_cprintf(0, M_GETCWD_FAILED); goto termination; } if(tmp_name[0]!='\0'&&dest[strlen(dest)-1]!=PATHSEP_DEFAULT) strcat(dest, pathsep_str); strcat(dest, tmp_name); if(file_chdir(cur_dir)) error(M_CANT_CHDIR, cur_dir); #ifdef HAVE_DRIVES setdisk(dsk); #endif return(0); } /* Runs an external command */ static int exec_cmd(char *cmd) { int rc; if(no_file_activity) return(1); flush_kbd(); ctrlc_busy=1; rc=system_cmd(cmd); ctrlc_busy=0; flush_kbd(); return(rc); } /* Runs an external executable */ static int exec_exe(char *cmd) { int rc; if(no_file_activity) return(1); flush_kbd(); ctrlc_busy=1; rc=exec_pgm(cmd); ctrlc_busy=0; flush_kbd(); return(rc); } /* Archive conversion procedure */ static int convert_archive(char *name) { long old_fsize, new_fsize; int exec_rc=0; char full_name[CCHMAXPATH], target_name[CCHMAXPATH]; char bak_name[CCHMAXPATH]; char cnv_name[CCHMAXPATH]; /* Converted file in the work dir. */ char filespec[40]; int entry; char *dot_pos; int repack; char *tmp_name; int i; int src_type; struct timestamp old_ftime; char cmd_buffer[400]; FILE_COUNT old_count=0, new_count; char *nst_suf_wildcard; unsigned long old_size=0, new_size; long gain; #if TARGET==UNIX int match, fspec_len, pattern_len; #else char extension[64]; #endif if(truename(full_name, name)) { msg_cprintf(H_HL|H_NFMT, M_SKIP_CANT_FIND, name); return(REARJ_ERL_WARNING); } entry=split_name(full_name, NULL, filespec); #if TARGET==UNIX fspec_len=strlen(filespec); #endif dot_pos=strrchr(filespec, '.'); if(dot_pos==NULL) { #if TARGET!=UNIX extension[0]='\0'; #endif strcpy(target_name, full_name); strcat(target_name, dot); strcat(target_name, archivers[target_type].suffix); strcpy(bak_name, full_name); } else { #if TARGET!=UNIX *dot_pos++='\0'; strcpy(extension, dot_pos); #endif strncpy(target_name, full_name, entry); target_name[entry]='\0'; strcpy(bak_name, target_name); #if TARGET!=UNIX strcat(target_name, filespec); strcat(target_name, dot); strcat(target_name, archivers[target_type].suffix); #endif strcat(bak_name, filespec); } strcat(bak_name, dot); strcat(bak_name, backup_extension); strcpy(cnv_name, work_dir); strcat(cnv_name, pathsep_str); strcat(cnv_name, filespec); strcat(cnv_name, dot); strcat(cnv_name, archivers[target_type].suffix); repack=!strcmp_os(target_name, full_name); tmp_name=cnv_diskette_archives?cnv_name:target_name; src_type=-1; for(i=0; ipattern_len&& filespec[fspec_len-pattern_len-1]=='.'&& !strcmp_os(filespec+fspec_len-pattern_len, archivers[i].suffix)) { match=1; strcat(target_name, filespec); target_name[strlen(target_name)-pattern_len]='\0'; strcat(target_name, archivers[target_type].suffix); } } if(match) src_type=i; #else if(!strcmp_os(extension, archivers[i].suffix)) src_type=i; #endif } if(src_type==-1) src_type=default_suffix; if(src_type==-1) { msg_cprintf(H_HL|H_NFMT, M_SKIP_UNKNOWN_TYPE, full_name); return(REARJ_ERL_UNCONFIGURED); } old_fsize=file_getfsize(full_name); if((!overwrite_existing&&!repack&&file_exists(target_name))|| (cnv_diskette_archives&&!overwrite_existing&&file_exists(cnv_name))) { msg_cprintf(H_HL|H_NFMT, M_SKIP_TGT_EXISTS, full_name); return(REARJ_ERL_TGT_EXISTS); } if(!update_with_backups&&repack) { msg_cprintf(H_HL|H_NFMT, M_SKIP_REPACK, full_name); return(REARJ_ERL_UPD_SKIPPED); } msg_cprintf(H_HL|H_NFMT, M_CONVERTING_ARCHIVE, full_name, archivers[src_type].suffix, archivers[target_type].suffix); if(conversion_query) { msg_cprintf(0, M_QUERY_CONVERT); if(!query_action()) { msg_cprintf(H_HL|H_NFMT, M_SKIPPING, full_name); return(REARJ_ERL_UPD_SKIPPED); } } if(overwrite_existing&&!repack&&file_exists(target_name)&&!no_file_activity) if(file_unlink(target_name)) error(M_CANT_UNLINK, target_name); if(cnv_diskette_archives&&overwrite_existing&&file_exists(cnv_name)&&!no_file_activity) if(file_unlink(cnv_name)) error(M_CANT_UNLINK, cnv_name); ts_store(&old_ftime, OS, file_getftime(full_name)); unlink_all(tmp_dir); if(file_chdir(tmp_dir)) error(M_CANT_CHDIR, tmp_dir); if(run_preunpack_cmd) { sprintf(cmd_buffer, "%s %s", preunpack_cmd_text, full_name); msg_cprintf(H_HL|H_NFMT, M_EXECUTING_PRE, cmd_buffer); exec_cmd(cmd_buffer); } sprintf(cmd_buffer, archivers[src_type].unpack_cmd, full_name); msg_cprintf(H_HL|H_NFMT, M_EXECUTING, cmd_buffer); exec_rc=exec_exe(cmd_buffer); if(exec_rc!=0) { if(exec_rc==-1) msg_cprintf(H_HL|H_NFMT, M_SKIP_EXE_MISSING, full_name); else msg_cprintf(H_HL|H_NFMT, M_SKIP_UNPACK_ERR, full_name, exec_rc); return(REARJ_ERL_UNPACK); } if(!archivers[target_type].subdirs_supported&&check_for_dirs()) { msg_cprintf(H_HL|H_NFMT, M_SKIP_UNSUPP_DIR, full_name); return(REARJ_ERL_DIRECTORIES); } if(!check_for_entries()) { msg_cprintf(H_HL|H_NFMT, M_SKIP_NO_FILES, full_name); return(REARJ_ERL_UNPACK); } if(run_precount_cmd) { sprintf(cmd_buffer, "%s %s", precount_cmd_text, full_name); msg_cprintf(H_HL|H_NFMT, M_EXECUTING_CNT, cmd_buffer); exec_cmd(cmd_buffer); } if(!skip_size_check) old_count=count_files(); if(run_extract_cmd) { msg_cprintf(H_HL|H_NFMT, M_EXECUTING_EXTR, extract_cmd_text); exec_rc=exec_exe(extract_cmd_text); if(exec_rc!=0) { if(exec_rc==-1) msg_cprintf(H_HL|H_NFMT, M_SKIP_V_EXE_MISSING, full_name); else msg_cprintf(H_HL|H_NFMT, M_SKIP_V_ERR, full_name, exec_rc); return(REARJ_ERL_VIRUS); } } if(convert_nested_archives) { nst_suf_wildcard=(acc_nested_suffixes!=NULL)?acc_nested_suffixes:archivers[src_type].suffix; /* ASR FIX 30/12/1999: only 6 additional (%s) params in original REARJ v 2.42 */ sprintf(cmd_buffer, "%s *.%s " REARJ_SWITCHAR "t%s " REARJ_SWITCHAR "d " REARJ_SWITCHAR "r " REARJ_SWITCHAR "a%s " REARJ_SWITCHAR "e%s%s%s%s%s%s%s", exe_name, nst_suf_wildcard, archivers[target_type].suffix, nst_suf_wildcard, skip_size_check?" " REARJ_SWITCHAR "s":nullstr, no_file_activity?" " REARJ_SWITCHAR "z":nullstr, update_with_backups?" " REARJ_SWITCHAR "u":nullstr, overwrite_existing?" " REARJ_SWITCHAR "o":nullstr, run_extract_cmd?" " REARJ_SWITCHAR "v":nullstr, skip_rearj_sw?" " REARJ_SWITCHAR "+":nullstr, skip_packing?" " REARJ_SWITCHAR "g":nullstr); msg_cprintf(H_HL|H_NFMT, M_EXECUTING, cmd_buffer); exec_rc=exec_exe(cmd_buffer); if(exec_rc!=0) { if(exec_rc==-1) msg_cprintf(H_HL|H_NFMT, M_SKIP_REARJ_MISSING, full_name); else msg_cprintf(H_HL|H_NFMT, M_SKIP_REARJ_FAILED, full_name, exec_rc); return(REARJ_ERL_INTERNAL); } } if(skip_packing) { if(logging_enabled) { arj_gettime(&log_ts); if(fprintf(logstream, M_LOGENTRY_CONV, timeseq, archivers[target_type].suffix, old_fsize, 0L, 0L, full_name)<=0) error(M_CANT_WRITE_LOG); } return(0); } if(!skip_size_check) old_size=count_total_size(); if(!archivers[target_type].hidden_supported) reset_attrs(); if(update_with_backups&&repack) { if(file_exists(bak_name)&&!no_file_activity) if(file_unlink(bak_name)) error(M_CANT_UNLINK, bak_name); if(!no_file_activity) if(rename_with_check(full_name, bak_name)) { msg_cprintf(H_HL|H_NFMT, M_SKIP_CANT_RENAME, full_name, bak_name); return(REARJ_ERL_RENAME); } if(!no_file_activity) msg_cprintf(H_HL|H_NFMT, M_BACKED_UP, full_name, bak_name); } sprintf(cmd_buffer, archivers[target_type].pack_cmd, tmp_name); msg_cprintf(H_HL|H_NFMT, M_EXECUTING, cmd_buffer); exec_rc=exec_exe(cmd_buffer); if(exec_rc!=0) { if(update_with_backups&&repack) { if(file_exists(full_name)&&!no_file_activity) if(file_unlink(full_name)) error(M_CANT_UNLINK, full_name); if(!no_file_activity) if(rename_with_check(bak_name, full_name)) error(M_CANTRENAME, bak_name, full_name); } if(exec_rc==-1) msg_cprintf(H_HL|H_NFMT, M_SKIP_P_EXE_MISSING, full_name); else { /* ASR fix for 2.42.05 -- unlink empty .tar.gz archives */ if(archivers[target_type].manual_deletion) unlink(tmp_name); msg_cprintf(H_HL|H_NFMT, M_SKIP_PACK_ERR, full_name, exec_rc); } return(REARJ_ERL_PACK); } if(file_chdir(work_dir)) error(M_CANT_CHDIR, work_dir); if(!file_exists(tmp_name)) { if(update_with_backups&&repack) { if(file_exists(full_name)&&!no_file_activity) if(file_unlink(full_name)) error(M_CANT_UNLINK, full_name); if(!no_file_activity) if(rename_with_check(bak_name, full_name)) error(M_CANTRENAME, bak_name, full_name); } msg_cprintf(H_HL|H_NFMT, M_SKIP_NOT_PACKED, full_name); return(REARJ_ERL_PACK); } new_fsize=file_getfsize(tmp_name); if(skip_larger_output&&old_fsizeMAX_SUFFIX) error(M_INVALID_SUFFIX, tmp_line); if((archivers[i].suffix=strdup(tmp_line))==NULL) error(M_OUT_OF_MEMORY); /* Pack command */ if(fgets(tmp_line, sizeof(tmp_line), stream)==NULL) error(M_MISSING_PACK_CMD, archivers[i].suffix); tokenize_lf(tmp_line); alltrim(tmp_line); if(strlen(tmp_line)==0) error(M_INVALID_PACK_CMD, tmp_line); if(strstr(tmp_line, strform)==NULL&&strstr(tmp_line, u_strform)==NULL) error(M_NO_PACK_STRFORM, tmp_line); if((archivers[i].pack_cmd=strdup(tmp_line))==NULL) error(M_OUT_OF_MEMORY); /* Unpack command */ if(fgets(tmp_line, sizeof(tmp_line), stream)==NULL) error(M_MISSING_UNPACK_CMD, archivers[i].suffix); tokenize_lf(tmp_line); alltrim(tmp_line); if(strlen(tmp_line)==0) error(M_INVALID_UNPACK_CMD, tmp_line); if(strstr(tmp_line, strform)==NULL&&strstr(tmp_line, u_strform)==NULL) error(M_NO_UNPACK_STRFORM, tmp_line); if((archivers[i].unpack_cmd=strdup(tmp_line))==NULL) error(M_OUT_OF_MEMORY); /* Option record */ if(fgets(tmp_line, sizeof(tmp_line), stream)==NULL) error(M_MISSING_OPTIONS, archivers[i].suffix); tokenize_lf(tmp_line); alltrim(tmp_line); if(strpbrk(tmp_line, "Aa")!=NULL) archivers[i].hidden_supported=1; if(strpbrk(tmp_line, "Dd")!=NULL) archivers[i].subdirs_supported=1; /* ASR fix for v 2.42.05 (.tar.gz): */ if(strpbrk(tmp_line, "Tt")!=NULL) archivers[i].manual_deletion=1; } no_more_exts: total_suffixes=i; } fclose(stream); } /* atexit routine */ static void final_cleanup(void) { if(!cleanup_initiated) { cleanup_initiated=1; if(tmpdir_malloced) release_dir(tmp_dir); /* ASR fix 14/11/2000 */ if(work_dir[0]!='\0') file_chdir(work_dir); if(tmp_dir!=NULL) { if(clear_tmp_dir) unlink_all(tmp_dir); if(!work_directory_assigned) file_rmdir(tmp_dir); if(tmpdir_malloced) { free(tmp_dir); /* malloc'ed */ tmpdir_malloced=0; } } } #ifdef COLOR_OUTPUT scrn_reset(); #endif } /* Ctrl+C handler */ static void ctrlc_handler(SIGHDLPARAMS) { /* Check if we are able to honor the request. If we aren't, raise the signal again and make a speedy getaway. */ if(ctrlc_busy) raise(SIGINT); else { ctrlc_initiated=1; signal(SIGINT, NULL); /* Restore default Ctrl+C handler */ msg_cprintf(H_SIG, M_BREAK_SIGNALED); exit(REARJ_ERL_WARNING); } } /* Main routine */ int main(int argc, char **argv) { int cnv_rc, exit_code; static char rearj_exe[CCHMAXPATH]; int switchar; int arg; char *aptr=NULL; unsigned int i; FILE_COUNT cur_file; char tmp_name[CCHMAXPATH], src_name[CCHMAXPATH]; char *fullpath; long total_gain; char *env_ptr, *env_dup, *env_tail; struct timestamp timestamp; time_t start_time, end_time; unsigned long time_diff; #ifdef COLOR_OUTPUT no_colors=redirected=!is_tty(stdout); #endif msg_cprintf(0, M_REARJ_BANNER, build_date); #ifdef USE_TZSET tzset(); #endif build_crc32_table(); ctrlc_busy=0; lfn_supported=LFN_NOT_SUPPORTED; convert_nested_archives=0; run_precount_cmd=0; run_preunpack_cmd=0; recurse_subdirs=0; help_issued=0; no_file_activity=0; delete_original_archives=0; skip_larger_output=0; cnv_diskette_archives=0; run_extract_cmd=0; skip_rearj_sw=0; logging_enabled=0; internal_archives_only=0; pick_older=0; pick_newer=0; conversion_query=0; chk_integrity=0; overwrite_existing=0; skip_lfn=0; skip_packing=0; skip_timestamping=0; skip_size_check=0; work_directory_assigned=0; testing_mode=0; update_with_backups=0; clear_tmp_dir=0; skip_count=0; target_type=0; total_old_fsize=total_new_fsize=0L; total_files=0; ts_store(&ts_older, OS_SPECIAL, 0L); ts_newer=ts_older; ctrlc_initiated=0; is_registered=0; exit_code=REARJ_ERL_SUCCESS; log_name=rearj_log; default_suffix=-1; backup_extension=backup_ext; #ifndef SKIP_GET_EXE_NAME get_exe_name(rearj_exe); #else get_exe_name(rearj_exe, argv[0]); #endif exe_name=rearj_exe; target_suffix=NULL; suffix_override=NULL; extract_cmd_text=NULL; precount_cmd_text=NULL; preunpack_cmd_text=NULL; tmp_dir=NULL; testing_marker=NULL; acc_nested_suffixes=NULL; work_dir[0]='\0'; timestr_older=timestr_newer=nullstr; flist_init(&flist_exclusion, EXCL_FLIST_SIZE, 0, 0); atexit(final_cleanup); parse_reg_key(); detect_lfns(); is_registered=reg_validation(regdata+REG_KEY1_SHIFT, regdata+REG_KEY2_SHIFT, regdata+REG_NAME_SHIFT, regdata+REG_HDR_SHIFT); if(!is_registered&&!msg_strcmp((FMSG *)regdata+REG_KEY2_SHIFT, M_REG_TYPE)) msg_cprintf(0, M_REGISTERED_TO, regdata+REG_NAME_SHIFT); limit=20; total_suffixes=0; if(signal(SIGINT, ctrlc_handler)==SIG_ERR) error(M_SIGNAL_FAILED); limit=0; if(regdata[REG_NAME_SHIFT]=='\0') is_registered=1; if(!reg_validation(single_spc, single_spc, single_spc, regdata+REG_HDR_SHIFT)) is_registered=2; n_args=0; switchar=get_sw_char(); for(arg=1; arg=MAX_ARGS) error(M_ARGTABLE_OVERFLOW); arg_ptr[n_args++]=aptr; } } if(skip_lfn) lfn_supported=LFN_NOT_SUPPORTED; if(chk_integrity) exit(check_integrity(rearj_exe)); if(help_issued||n_args==0) { msg_cprintf(0, strform, M_REARJ_COMMANDS); msg_cprintf(0, strform, M_REARJ_RCODES); exit(REARJ_ERL_SUCCESS); } if(delete_original_archives&&testing_mode) error(M_YD_CMD_CONFLICT); if(testing_mode&&testing_marker!=NULL&&!logging_enabled) error(M_LY_CMD); parse_rearj_cfg(); if(run_extract_cmd&&extract_cmd_text==NULL) error(M_NO_V_CMD, cfg_name); if(suffix_override!=NULL) { default_suffix=-1; for(i=0; i1, 1); for(i=limit; i0) msg_cprintf(0, M_CWD_MUST_BE_EMPTY); if(tmp_dir==NULL) { /* BUGBUG: this comes from a NetBSD patch. Originally a check for NO_MKDTEMP was suggested, but where are we expected to define it under DOS? -- ASR fix 25/01/2004 */ #ifdef HAVE_MKDTEMP tmp_dir=mkdtemp("/tmp/arj.XXXXXX"); /* BUGBUG: hardcoded location? */ #else tmp_dir=tmpnam(NULL); if(file_mkdir(tmp_dir)) error(M_CANT_MKDIR, tmp_dir); #endif } else { if(file_chdir(tmp_dir)) error(M_CANT_CHDIR, tmp_dir); if(count_files()>0) error(M_WORK_DIR_NOT_EMPTY, tmp_dir); if(file_chdir(work_dir)) error(M_CANT_CHDIR, work_dir); } if((fullpath=(char *)malloc(CCHMAXPATH))==NULL) error(M_OUT_OF_MEMORY); if(truename(fullpath, tmp_dir)) error(M_CANT_GET_FULL_PATH); tmp_dir=fullpath; clear_tmp_dir=1; tmpdir_malloced=1; /* Introduced by ASR */ for(cur_file=0; cur_file=0)&& (!pick_older||!ts_valid(ts_older)||ts_cmp(×tamp, &ts_older)<0)) { cnv_rc=convert_archive(src_name); if(cnv_rc!=REARJ_ERL_SUCCESS) { skip_count++; log_as_skipped(src_name, cnv_rc); if(exit_code==REARJ_ERL_SUCCESS&&(!internal_archives_only||cnv_rc!=REARJ_ERL_UNCONFIGURED)) exit_code=cnv_rc; } release_dir(tmp_dir); /* ASR fix 14/11/2000 */ if(file_chdir(work_dir)) error(M_CANT_CHDIR, work_dir); unlink_all(tmp_dir); if(file_rmdir(tmp_dir)) msg_cprintf(H_ERR, M_CANT_RMDIR, tmp_dir); if(file_mkdir(tmp_dir)) error(M_CANT_MKDIR, tmp_dir); } } if(!work_directory_assigned) { if(file_rmdir(tmp_dir)) msg_cprintf(H_ERR, M_CANT_RMDIR, tmp_dir); } if(tmpdir_malloced) { free(tmp_dir); tmpdir_malloced=0; } tmp_dir=NULL; time(&end_time); time_diff=sub_time(end_time, start_time); total_gain=(long)(total_old_fsize-total_new_fsize); msg_cprintf(H_HL|H_NFMT, M_TOTAL_SECONDS, time_diff); msg_cprintf(H_HL|H_NFMT, M_TOTAL_CONVERTED, total_files); msg_cprintf(H_HL|H_NFMT, M_TOTAL_SKIPPED, skip_count); msg_cprintf(H_HL|H_NFMT, M_OLD_SIZE, total_old_fsize); msg_cprintf(H_HL|H_NFMT, M_NEW_SIZE, total_new_fsize); msg_cprintf(H_HL|H_NFMT, M_SAVINGS_SIZE, total_gain); if(logging_enabled) { arj_gettime(&log_ts); if(fprintf(logstream, M_LOGENTRY_FOOTER, timeseq, archivers[target_type].suffix, total_old_fsize, total_new_fsize, total_gain, time_diff)<=0) error(M_CANT_WRITE_LOG); fclose(logstream); } flist_cleanup_proc(&flist_main); flist_cleanup_proc(&flist_exclusion); return((skip_count>0)?exit_code:REARJ_ERL_SUCCESS); } arj-3.10.22/rearj.h 666 0 0 506 7450456706 10077 0ustar /* * $Id: rearj.h,v 1.1.1.2 2002/03/28 00:03:19 andrew_belov Exp $ * --------------------------------------------------------------------------- * This file contains declarations of functions exported from REARJ. * */ #ifndef REARJ_INCLUDED #define REARJ_INCLUDED /* Prototypes */ void pause_error(FMSG *msg); #endif arj-3.10.22/recovery.c 666 0 0 77105 7655040110 10657 0ustar /* * $Id: recovery.c,v 1.5 2003/05/03 22:18:48 andrew_belov Exp $ * --------------------------------------------------------------------------- * This module contains a set of procedures to create and use special recovery * records (XRJ files) introduced with ARJ v 2.55. * */ #include "arj.h" DEBUGHDR(__FILE__) /* Debug information block */ #define DEFAULT_PROTPAD_SIZE 1024 /* Protection data granularity */ #define MAX_BLOCK_SIZE 4096 /* Maximum size of temporary block */ #define DIVISOR_BITS 10 /* Depends on data granularity */ #define PROTBLOCK_HDR_SIZE 14 /* Header of protection block */ #define PROT_SIG_SIZE 6 /* Signature size */ /* Local variables */ static char prot_sig[]="PSigx"; /* Protection block signature */ static char blocks_numstr[]="%3dx "; /* Number of blocks to process */ static char prot_ticker[]="."; /* Block counter */ static unsigned long prot_blk_size=0L; /* Size of std. protection block */ /* Calculates CRC-16 of the given block. The result differs from the one given by CCITT V.41 CRC-16. */ static unsigned short crc16_for_block(char *data, int len) { int remain; unsigned char *tmp_dptr; unsigned short crc16term; tmp_dptr=(unsigned char *)data; crc16term=0; for(remain=len; remain>0; remain--) { crc16term=crc16tab[crc16term>>8]^((crc16term<<8)|(unsigned short)(*(tmp_dptr++))); } return(crc16term^0xAAAA); } /* Returns number of bytes needed to hold the temporary block */ static int calc_protpad_size(int len) { long tmp_len, divisor; tmp_len=(long)len+1; while(1) { divisor=2L; while(divisor*divisor<=tmp_len) { if(tmp_len%divisor==0L) break; else divisor++; } if(tmp_len%divisor!=0L) break; tmp_len++; } return((int)tmp_len); } /* Returns the proportion of protection data size to archive size, per mille */ static long calc_protdata_pct(unsigned long protsize, unsigned long archsize) { int dec; for(dec=0; dec<3; dec++) { if(protsize<=0x19999999) protsize*=10L; else archsize/=10L; } if(archsize==0) return(0); else return(protsize/archsize); } /* Relocates the protection data */ static void relocate_protdata(char *dest, char *src, int len) { int i; for(i=0; i>1; if(prot_blk_size>16384L) prot_blk_size=16384L; } ct=0; while(prot_blk_size>MAX_BLOCK_SIZE) { prot_blk_size>>=1; ct++; } prot_blk_size*=DEFAULT_PROTPAD_SIZE; prot_blk_size>>=(DIVISOR_BITS-ct); return((((limit>>(DIVISOR_BITS-ct))/prot_blk_size+1L)* threshold*DEFAULT_PROTPAD_SIZE)<<2); } /* Creates a protection file for the given archive */ int create_protfile(FILE *stream, unsigned long offset, int state) { int protpad_size; int pad1_size, pad2_size; int block_size; char *pad_array[4]; char *protpad, *protpad_r; char *single_pad, *single_pad_r; char *protpad_bck; unsigned long ifile_size; /* Input file size */ unsigned long block_offset; int block_divisor; int total_blocks; /* Total number of MAX_BLOCK_SIZE-byte blocks in the recovery file. */ int cur_block; /* 0-relative */ int pad_ctr; int section_size; /* Number of bytes read */ unsigned long crc32_tmp; long per_mille; unsigned long data_offset; protpad_size=calc_protpad_size(DEFAULT_PROTPAD_SIZE); pad1_size=protpad_size+4-DEFAULT_PROTPAD_SIZE; pad2_size=(pad1_size<<1)+PROTBLOCK_HDR_SIZE; block_size=(DEFAULT_PROTPAD_SIZE-pad2_size)>>1; #ifndef __32BIT__ if(block_size>MAX_BLOCK_SIZE) block_size=MAX_BLOCK_SIZE; #else if(block_size>16384) block_size=16384; #endif protpad=malloc_msg(protpad_size+2); protpad_r=malloc_msg(protpad_size+2); single_pad=malloc_msg(DEFAULT_PROTPAD_SIZE+2); single_pad_r=malloc_msg(DEFAULT_PROTPAD_SIZE+2); protpad_bck=malloc_msg(protpad_size+2); pad_array[0]=single_pad; pad_array[1]=protpad; pad_array[2]=protpad_r; pad_array[3]=single_pad_r; fseek(stream, 0L, SEEK_END); ifile_size=ftell(stream); fseek(stream, 0L, SEEK_END); file_write(prot_sig, 1, PROT_SIG_SIZE, stream); fseek(stream, 0L, SEEK_END); data_offset=ftell(stream); block_offset=(unsigned long)block_size; for(block_divisor=0; block_offset>MAX_BLOCK_SIZE; block_divisor++) block_offset>>=1; block_offset*=(unsigned long)DEFAULT_PROTPAD_SIZE; block_offset>>=(DIVISOR_BITS-block_divisor); total_blocks=((ifile_size>>(DIVISOR_BITS-block_divisor))/block_offset+1); total_blocks=state?offset:offset*total_blocks; msg_cprintf(0, M_WORKING); msg_cprintf(0, (FMSG *)blocks_numstr, total_blocks); for(cur_block=0; cur_block>1)+DIVISOR_BITS; if(pad_ctr+1>=DEFAULT_PROTPAD_SIZE) error(M_PROTECT_BUG); mput_word(crc32_tmp, &single_pad [pad_ctr]); mput_word(crc32_tmp>>16, &single_pad_r[pad_ctr]); block_offset+=(unsigned long)total_blocks* (unsigned long)DEFAULT_PROTPAD_SIZE; block_divisor++; } for(pad_ctr=0; pad_ctr=fsize) break; if(fread(pad, 1, PROT_SIG_SIZE-2, stream)!=PROT_SIG_SIZE-2) break; if(!strcmp(prot_sig+2, pad)) { sig_offset=ftell(stream); if(rp_ofs!=0) break; } rp_ofs++; } return(sig_offset); } /* Verifies and/or repairs a damaged archive */ int recover_file(char *name, char *protname, char *rec_name, int test_mode, unsigned long sig_offset) { unsigned int cur_stream; unsigned int cur_section; unsigned long block_offset; unsigned long ifile_size; unsigned long orig_ifile_size; /* Size of undamaged input file (stored in the protection file) */ unsigned long dest_file_size; /* Size of output file (number of bytes to write) */ int errors; /* Total number of damaged sections */ int protpad_size; int pad1_size; int section_size; /* Number of bytes read */ int total_blocks; int data_damage; /* Data damage flag */ int damage_level; /* 0, 1 or 2 (highest) */ int damage_flag, pad_damage_flag; int pad_flag, bck_pad_flag; /* Section damage flag */ int rec_size=0, bck_rec_size=0; /* Recovered sections size */ char *protpad, *protpad_r; char *single_pad, *single_pad_r; char *protpad_bck; FILE *astream, *xstream; /* ARJ and XRJ files */ FILE *ostream; /* Destination file */ int pad_ctr; unsigned long rd_offset; /* Offset of recovery data within xstream */ int ins_lf=0; errors=0; protpad_size=calc_protpad_size(DEFAULT_PROTPAD_SIZE); /* -> EBX */ pad1_size=protpad_size+4-DEFAULT_PROTPAD_SIZE; protpad=malloc_msg(protpad_size+2); protpad_r=malloc_msg(protpad_size+2); single_pad=malloc_msg(DEFAULT_PROTPAD_SIZE+2); single_pad_r=malloc_msg(DEFAULT_PROTPAD_SIZE+2); protpad_bck=malloc_msg(protpad_size+2); astream=file_open_noarch(name, m_rb); if(file_exists(protname)) { xstream=file_open_noarch(protname, m_rb); rd_offset=0L; } else { xstream=astream; rd_offset=chk_prot_sig(xstream, sig_offset); if(rd_offset==0L) { if(test_mode) { msg_cprintf(0, M_NO_PROT_DATA); nputlf(); return(0); } else error(M_NO_PROT_DATA); } } fseek(astream, 0L, SEEK_END); ifile_size=ftell(astream); if(rd_offset!=0L) ifile_size=rd_offset-6L; fseek(xstream, rd_offset, SEEK_SET); fread(single_pad, 1, DEFAULT_PROTPAD_SIZE, xstream); crc32term=CRC_MASK; crc32_for_block(single_pad+4, DEFAULT_PROTPAD_SIZE-4); /* Possible XRJ damage */ if(mget_dword(&single_pad[0])!=crc32term|| mget_word (&single_pad[4])!=0x1111) { fseek(xstream, (long)DEFAULT_PROTPAD_SIZE*3+rd_offset, SEEK_SET); fread(single_pad, 1, DEFAULT_PROTPAD_SIZE, xstream); crc32term=CRC_MASK; crc32_for_block(single_pad+4, DEFAULT_PROTPAD_SIZE-4); if(mget_dword(&single_pad[0])!=crc32term|| mget_word (&single_pad[4])!=0x1111) error(M_RECOVERY_CRC_DAMAGED); } fseek(xstream, rd_offset, SEEK_SET); total_blocks=mget_word(&single_pad[6]); orig_ifile_size=mget_dword(&single_pad[10]); if(ifile_size==orig_ifile_size) { fseek(astream, 0L, SEEK_SET); msg_cprintf(0, M_WORKING); for(cur_stream=0; cur_stream>1)])!= (unsigned short)(crc32term%65536L)) goto recovery; } if(damage_level==0||damage_level==2) { if(mget_word (&single_pad_r[(pad1_size<<1)+((cur_section<<2)>>1)])!= (unsigned short)(crc32term>>16)) goto recovery; } block_offset+=(unsigned long) DEFAULT_PROTPAD_SIZE*(unsigned long)total_blocks; cur_section++; } } if(test_mode==2) goto recovery; } else { recovery: nputlf(); if(test_mode!=1) { atstream=ostream=file_open_noarch(rec_name, m_wbp); fseek(astream, 0L, SEEK_SET); errors=0; for(dest_file_size=min(ifile_size, orig_ifile_size); dest_file_size>0; dest_file_size-=(unsigned long)section_size) { section_size=min(DEFAULT_PROTPAD_SIZE, dest_file_size); if(fread(single_pad, 1, section_size, astream)!=section_size) break; if(fwrite(single_pad, 1, section_size, ostream)!=section_size) break; } for(dest_file_size= (ifile_size>=orig_ifile_size)?0:orig_ifile_size-ifile_size; dest_file_size>0; dest_file_size-=(unsigned long)section_size) { section_size=min(DEFAULT_PROTPAD_SIZE, dest_file_size); if(fwrite(single_pad, 1, section_size, ostream)!=section_size) break; } fseek(ostream, 0L, SEEK_END); if(ftell(ostream)!=orig_ifile_size) error(M_DISK_FULL); ifile_size=orig_ifile_size; for(cur_stream=0; cur_stream>1)])!= (unsigned short)(crc32term%65536L)) data_damage=1; } if(damage_level==0||damage_level==2) { if (mget_word (&single_pad_r[(pad1_size<<1)+((cur_section<<2)>>1)])!= (unsigned short)(crc32term>>16)) data_damage=1; } if(data_damage) { errors++; if(ins_lf) { nputlf(); ins_lf=0; } msg_cprintf(0, M_SECTION_DAMAGED, cur_stream, cur_section); if(bck_pad_flag==-1) { bck_pad_flag=cur_section; rec_size=section_size; } else if(pad_flag==-1) { pad_flag=cur_section; bck_rec_size=section_size; } else abort_recovery(); } else { for(pad_ctr=0; pad_ctr>1)])!= (unsigned short)(crc32term%65536L)) data_damage=1; } if(damage_level==0||damage_level==2) { if(mget_word (&single_pad_r[(pad1_size<<1)+((cur_section<<2)>>1)])!= (unsigned short)(crc32term>>16)) data_damage=1; } if(data_damage) { errors++; if(ins_lf) { nputlf(); ins_lf=0; } msg_cprintf(0, M_SECTION_DAMAGED, cur_stream, cur_section); if(bck_pad_flag==-1) { bck_pad_flag=cur_section; rec_size=section_size; } else if(pad_flag==-1) { pad_flag=cur_section; bck_rec_size=section_size; } else abort_recovery(); } else { for(pad_ctr=0; pad_ctr /* Local definitions */ #define REG_BLOCK_SIZE 8192 /* Sequental processing block */ /* Global registration types */ #define REG_TYPE_DEFAULT 0 /* Registers a single user-specified file */ #define REG_TYPE_ARJ 1 /* Registers ARJ or ARJ/2 package */ #define REG_TYPE_ARJ32 2 /* Registers ARJ32 package */ DEBUGHDR(__FILE__) /* Debug information block */ /* Local variables */ static char reg_fname[]="register.dat"; /* User registration data */ static char end_marker[]=""; static char *reg_list[]={"arj" EXE_EXTENSION, "arjs" EXE_EXTENSION, "dearj" EXE_EXTENSION, "rearj" EXE_EXTENSION, end_marker}; static char *reg_list_32[]={"arj32" EXE_EXTENSION, "arjs32" EXE_EXTENSION, "rearj32" EXE_EXTENSION, end_marker}; static char integrity_pattern[]={0xB1, 0x03, 0xB0, 0x02, 0xB0, 0x03, 0xB0, 0x04, 0xB0, 0x05, 0}; static char reg_pattern[]="aRj sOfTwArE"; static char reg_pad[STD_REG_LEN]; static char proc_block[REG_BLOCK_SIZE]; static unsigned int file_ctr; /* Writes four bytes to the file */ static int _fput_dword(unsigned long l, FILE *stream) { #ifdef WORDS_BIGENDIAN fputc(l&0xFF, stream); fputc(l>>8, stream); fputc(l>>16, stream); return fputc(l>>24, stream)==EOF; #else return fwrite(&l,4,1,stream)!=4; #endif } static void _mput_dword(unsigned long d, char *p) { #ifdef WORDS_BIGENDIAN #define _mput_byte(b,p) (*(p)=(b)&0xFF) _mput_byte(d , p ); _mput_byte(d>>8, p+1); _mput_byte(d>>16, p+2); _mput_byte(d>>24, p+3); #undef _mput_byte #else *(unsigned long *)p=d; #endif } /* Writes registration data to the given file */ static void write_reg_data(char *name) { FILE *stream; int rp_len; long cur_pos, wr_pos; int bytes_read, byte_ctr; char *pb_ptr; long fsize; int c; if((stream=fopen(name, m_rbp))==NULL) error(M_CANTOPEN, name); rp_len=strlen(reg_pattern); cur_pos=0L; while(1) { fseek(stream, cur_pos, SEEK_SET); if((bytes_read=fread(proc_block, 1, REG_BLOCK_SIZE, stream))==0) error(M_PATCH_NOT_FOUND); bytes_read-=rp_len; pb_ptr=proc_block; byte_ctr=0; while(byte_ctr1) printf(M_REG_TOTALS, file_ctr); return(REGISTER_ERL_SUCCESS); } arj-3.10.22/register.h 666 0 0 514 7450456714 10616 0ustar /* * $Id: register.h,v 1.1.1.1 2002/03/28 00:03:24 andrew_belov Exp $ * --------------------------------------------------------------------------- * REGISTER exported stubs are declared here. * */ #ifndef REGISTER_INCLUDED #define REGISTER_INCLUDED /* Prototypes */ void decrypt_regproc(); void encrypt_regproc(); #endif arj-3.10.22/resource/ 777 0 0 0 10256535570 10424 5ustar arj-3.10.22/resource/de/ 777 0 0 0 10256066336 11013 5ustar arj-3.10.22/resource/de/arjl.txt 666 0 0 40630 7620765552 12576 0ustar Beispielhafte ARJ-Befehle: Hinzufgen v.Dateien o.Verzeichnisstruktur: ARJ a -e archive *.* Hinzufgen zweier Dateien zum Archiv: ARJ a archive name1 name2 Hinzufgen von Dateien mit šberprfung: ARJ a -jt archive *.* Hinzuf. von Dateien mit max. Komprimierung: ARJ a -jm archive *.* Hinzufgen von Verzeichnissen mit Dateien: ARJ a archive ... dir1 dir2 dir3 Hinzufgen tausender Dateien zu e. Archiv: ARJ a -hm1 -r archive *.* Hinzufgen eines Kapitels zu einem Archiv: ARJ ac archive c:\dir\*.* -r Kommentiere Archiv-Kopf: ARJ c archive -zcmt.fil Konv.Standard-Archiv in ein Kapitel-Format: ARJ cc archive Konv.Kapitel-Archiv ins Standard-Format: ARJ y archive -jb0 L”sche das letzte Kapitel eines Archivs: ARJ dc archive *.* L”sche nur den Archiv-Kommentar: ARJ c archive -zNUL Entpacke Dateien aus einem Archiv: ARJ e archive Entpacke Archiv mit Verzeichnis-Struktur: ARJ x archive Entpacke neuere Dateien ohne Rckfrage: ARJ e archive -u -y Entpacke Unterverzeichnis aus Archiv: ARJ e archive subdir\*.* -p1 Entpacke Dateien in Verzeichnis: ARJ x archive destdir\ *.* Entpacke Dateien in Verzeichnis: ARJ x archive *.* -htdestdir Entp. Dateien in Verzeichn.mit Leerzeichen: ARJ x archive "Program Files\ " Entp. Dateien in Verzeichn.mit Leerzeichen: ARJ x archive -ht"Program Files" Entpacke ein Win95-Archiv unter DOS: ARJ x archive -hf2 Zeige Dateien im Archiv: ARJ l archive Bewege Dateien in Archiv: ARJ m archive *.doc Bewege Dateien aus Archiv: ARJ e -d archive *.doc Wiederherst.von Dateien e.kaputten Archivs: ARJ x archive -jr Prfe Integrit„t der Dateien eines Archivs: ARJ t archive Prfe mehrere ARJ-Archive: ARJ t *.ARJ -hr Hinzuf.v. Dateien zu e.mehrteiligen Archiv: ARJ a -va a:archive *.* Erstelle bis zu 999 Archiv-Teile: ARJ a -va a:archive.001 Entpacke aus einem mehrteiligen Archiv: ARJ x -v a:archive Erst.Selbst-Entpacker fr mehrteil. Archiv: ARJ a -va -je a:archive *.* Konv.Archiv in selbst-entpackendes Archiv: ARJ y -je1 archive Sichere Laufwerk C auf Laufwerk A: ARJ a A:\backup C:\ -a1 -b2 -r -vvas -wC:\ -js -jt -hk Restauriere Sicherung von Laufwerk A nach LW C: ARJ x A:\backup C:\ -vv -y Ausfhrlichere Information zu ARJ: Aufruf: ARJ [{/|-}[-|+|