00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00026
00027
00028
00029
00030
00031 #ifndef __filter_h__
00032 #define __filter_h__
00033
00034 #include <stdio.h>
00035
00036 #include "rdd.h"
00037 #include "writer.h"
00038
00056 struct _RDD_FILTER;
00057 struct _RDD_FILTER_OPS;
00058
00059 typedef int
00060 (*rdd_fltr_input_fun)(struct _RDD_FILTER *f, const unsigned char *buf, unsigned nbyte);
00061
00062 typedef int
00063 (*rdd_fltr_block_fun)(struct _RDD_FILTER *f, unsigned nbyte);
00064
00065 typedef int
00066 (*rdd_fltr_close_fun)(struct _RDD_FILTER *f);
00067
00068 typedef int
00069 (*rdd_fltr_rslt_fun)(struct _RDD_FILTER *f, unsigned char *buf, unsigned pos);
00070
00071 typedef int
00072 (*rdd_fltr_free_fun)(struct _RDD_FILTER *f);
00073
00074 typedef struct _RDD_FILTER_OPS
00075 {
00076 rdd_fltr_input_fun input;
00077 rdd_fltr_block_fun block;
00078 rdd_fltr_close_fun close;
00079 rdd_fltr_rslt_fun get_result;
00080 rdd_fltr_free_fun free;
00081 } RDD_FILTER_OPS;
00082
00083 typedef struct _RDD_FILTER
00084 {
00085 void *state;
00086 RDD_FILTER_OPS *ops;
00087 unsigned blocksize;
00088 unsigned pos;
00089 } RDD_FILTER;
00090
00091 typedef void
00092 (*rdd_fltr_error_fun)(rdd_count_t pos, rdd_checksum_t expected, rdd_checksum_t computed, void *env);
00093
00094
00095
00096 int
00097 rdd_new_filter(RDD_FILTER **f, RDD_FILTER_OPS *ops, unsigned statesize, unsigned blocksize);
00098
00099 int
00100 rdd_new_md5_streamfilter(RDD_FILTER **f);
00101
00102 int
00103 rdd_new_sha1_streamfilter(RDD_FILTER **f);
00104
00105 int
00106 rdd_new_sha256_streamfilter(RDD_FILTER **f);
00107
00108 int
00109 rdd_new_sha384_streamfilter(RDD_FILTER **f);
00110
00111 int
00112 rdd_new_sha512_streamfilter(RDD_FILTER **f);
00113
00114 int
00115 rdd_new_write_streamfilter(RDD_FILTER **f, RDD_WRITER *writer);
00116
00117 int
00118 rdd_new_md5_blockfilter(RDD_FILTER **f, unsigned blocksize, const char *outpath, int overwrite);
00119
00120 int
00121 rdd_new_stats_blockfilter(RDD_FILTER **f, unsigned blocksize, const char *outpath, int overwrite);
00122
00123 int
00124 rdd_new_adler32_blockfilter(RDD_FILTER **f, unsigned blocksize, const char *outpath, int overwrite);
00125
00126 int
00127 rdd_new_crc32_blockfilter(RDD_FILTER **f, unsigned blocksize, const char *outpath, int overwrite);
00128
00129 int
00130 rdd_new_verify_adler32_blockfilter(RDD_FILTER **f, FILE *fp, unsigned blocksize, int swap,
00131 rdd_fltr_error_fun err, void *env);
00132
00133 int
00134 rdd_new_verify_crc32_blockfilter(RDD_FILTER **f, FILE *fp, unsigned blocksize, int swap,
00135 rdd_fltr_error_fun err, void *env);
00136
00137
00138
00149 int
00150 rdd_filter_push(RDD_FILTER *f, const unsigned char *buf, unsigned nbyte);
00151
00159 int
00160 rdd_filter_close(RDD_FILTER *f);
00161
00172 int
00173 rdd_filter_get_result(RDD_FILTER *f, unsigned char *buf, unsigned nbyte);
00174
00182 int
00183 rdd_filter_free(RDD_FILTER *f);
00184
00185 #endif