📄 arj_user.c
字号:
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>=ARJSFXVstatic#endifvoid 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<file_args; i++) { strcpy(tmp_name, f_arg_array[i]); case_path(tmp_name); add_f_arg(tmp_name); } if(cmd_verb==ARJ_CMD_EXTR_NP&&!yes_on_all_queries&&!skip_extract_query) { msg_cprintf(0, M_CONTINUE_EXTRACTION); if(!query_action()) exit(ARJSFX_ERL_ERROR); } #endif #if SFX_LEVEL>=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))
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -