$treeview $search $mathjax $extrastylesheet
librsync
2.3.0
$projectbrief
|
$projectbrief
|
$searchbox |
00001 /*= -*- c-basic-offset: 4; indent-tabs-mode: nil; -*- 00002 * 00003 * librsync -- the library for network deltas 00004 * 00005 * Copyright (C) 2000, 2001, 2014 by Martin Pool <mbp@sourcefrog.net> 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public License 00009 * as published by the Free Software Foundation; either version 2.1 of 00010 * the License, or (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, but 00013 * WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this program; if not, write to the Free Software 00019 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. 00020 */ 00021 00022 #include "mdfour.h" 00023 #include "checksum.h" 00024 00025 /** The contents of this structure are private. */ 00026 struct rs_job { 00027 int dogtag; 00028 00029 /** Human-readable job operation name. */ 00030 const char *job_name; 00031 00032 rs_buffers_t *stream; 00033 00034 /** Callback for each processing step. */ 00035 rs_result (*statefn)(rs_job_t *); 00036 00037 /** Final result of processing job. Used by rs_job_s_failed(). */ 00038 rs_result final_result; 00039 00040 /* Arguments for initializing the signature used by mksum.c and readsums.c. 00041 */ 00042 int sig_magic; 00043 int sig_block_len; 00044 int sig_strong_len; 00045 00046 /** The size of the signature file if available. Used by loadsums.c when 00047 * initializing the signature to preallocate memory. */ 00048 rs_long_t sig_fsize; 00049 00050 /** Pointer to the signature that's being used by the operation. */ 00051 rs_signature_t *signature; 00052 00053 /** Flag indicating signature should be destroyed with the job. */ 00054 int job_owns_sig; 00055 00056 /** Command byte currently being processed, if any. */ 00057 unsigned char op; 00058 00059 /** The weak signature digest used by readsums.c */ 00060 rs_weak_sum_t weak_sig; 00061 00062 /** The rollsum weak signature accumulator used by delta.c */ 00063 weaksum_t weak_sum; 00064 00065 /** Lengths of expected parameters. */ 00066 rs_long_t param1, param2; 00067 00068 struct rs_prototab_ent const *cmd; 00069 rs_mdfour_t output_md4; 00070 00071 /** Encoding statistics. */ 00072 rs_stats_t stats; 00073 00074 /** Buffer of data in the scoop. Allocation is scoop_buf[0..scoop_alloc], 00075 * and scoop_next[0..scoop_avail] contains data yet to be processed. 00076 * scoop_next[scoop_pos..scoop_avail] is the data yet to be scanned. */ 00077 rs_byte_t *scoop_buf; /* the allocation pointer */ 00078 rs_byte_t *scoop_next; /* the data pointer */ 00079 size_t scoop_alloc; /* the allocation size */ 00080 size_t scoop_avail; /* the data size */ 00081 size_t scoop_pos; /* the scan position */ 00082 00083 /** If USED is >0, then buf contains that much write data to be sent out. */ 00084 rs_byte_t write_buf[36]; 00085 int write_len; 00086 00087 /** If \p copy_len is >0, then that much data should be copied through 00088 * from the input. */ 00089 rs_long_t copy_len; 00090 00091 /** Copy from the basis position. */ 00092 rs_long_t basis_pos, basis_len; 00093 00094 /** Callback used to copy data from the basis into the output. */ 00095 rs_copy_cb *copy_cb; 00096 void *copy_arg; 00097 00098 }; 00099 00100 rs_job_t *rs_job_new(const char *, rs_result (*statefn)(rs_job_t *)); 00101 00102 int rs_job_input_is_ending(rs_job_t *job); 00103 00104 /** Magic job tag number for checking jobs have been initialized. */ 00105 #define RS_JOB_TAG 20010225 00106 00107 /** Assert that a job is valid. 00108 * 00109 * We don't use a static inline function here so that assert failure output 00110 * points at where rs_job_check() was called from. */ 00111 #define rs_job_check(job) do {\ 00112 assert(job->dogtag == RS_JOB_TAG);\ 00113 } while (0)