static rs_result rdiff_patch(poptContext opcon) { /* patch BASIS [DELTA [NEWFILE]] */ FILE *basis_file, *delta_file, *new_file; char const *basis_name; rs_stats_t stats; rs_result result; if (!(basis_name = poptGetArg(opcon))) { rdiff_usage("Usage for patch: " "rdiff [OPTIONS] patch BASIS [DELTA [NEW]]"); return RS_SYNTAX_ERROR; } basis_file = rs_file_open(basis_name, "rb"); delta_file = rs_file_open(poptGetArg(opcon), "rb"); new_file = rs_file_open(poptGetArg(opcon), "wb"); rdiff_no_more_args(opcon); result = rs_patch_file(basis_file, delta_file, new_file, &stats); rs_file_close(new_file); rs_file_close(delta_file); rs_file_close(basis_file); if (show_stats) rs_log_stats(&stats); return result; }
static rs_result rdiff_delta(poptContext opcon) { FILE *sig_file, *new_file, *delta_file; char const *sig_name; rs_result result; rs_signature_t *sumset; rs_stats_t stats; if (!(sig_name = poptGetArg(opcon))) { rdiff_usage("Usage for delta: " "rdiff [OPTIONS] delta SIGNATURE [NEWFILE [DELTA]]"); return RS_SYNTAX_ERROR; } sig_file = rs_file_open(sig_name, "rb"); new_file = rs_file_open(poptGetArg(opcon), "rb"); delta_file = rs_file_open(poptGetArg(opcon), "wb"); rdiff_no_more_args(opcon); result = rs_loadsig_file(sig_file, &sumset, &stats); if (result != RS_DONE) return result; if (show_stats) rs_log_stats(&stats); if ((result = rs_build_hash_table(sumset)) != RS_DONE) return result; result = rs_delta_file(sumset, new_file, delta_file, &stats); rs_free_sumset(sumset); rs_file_close(delta_file); rs_file_close(new_file); rs_file_close(sig_file); if (show_stats) rs_log_stats(&stats); return result; }
/** * Generate signature from remaining command line arguments. */ static rs_result rdiff_sig(poptContext opcon) { FILE *basis_file, *sig_file; rs_stats_t stats; rs_result result; basis_file = rs_file_open(poptGetArg(opcon), "rb"); sig_file = rs_file_open(poptGetArg(opcon), "wb"); rdiff_no_more_args(opcon); result = rs_sig_file(basis_file, sig_file, block_len, strong_len, &stats); if (result != RS_DONE) return result; if (show_stats) rs_log_stats(&stats); return result; }