00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
#ifndef __SHARE_HASH_H
00018
#define __SHARE_HASH_H
00019
00020
00021
00032
00033
00034
struct protocol;
00035
struct file_share;
00036
00037
00038
00039
typedef unsigned char* (*HashFn) (
const char *path, size_t *len);
00040
typedef char* (*HashDspFn) (
unsigned char *hash, size_t len);
00041
00042
00043
00050 typedef struct
00051
{
00052 unsigned char ref;
00053 int opt;
00054 const char *type;
00056 HashFn algofn;
00057 HashDspFn dspfn;
00058 }
HashAlgo;
00059
00063 typedef struct
00064
{
00065 HashAlgo *algo;
00067 unsigned char *data;
00070 BOOL copy;
00071 size_t len;
00072 }
Hash;
00073
00074
00075
00076 EXTERN_C_BEGIN
00077
00078
00079
00094 LIBGIFTPROTO_EXPORT
00095
Hash *hash_new (
HashAlgo *algo,
unsigned char *data, size_t len, BOOL copy);
00096
00101 LIBGIFTPROTO_EXPORT
00102
void hash_free (
Hash *hash);
00103
00108 LIBGIFTPROTO_EXPORT
00109
Hash *hash_dup (
Hash *hash);
00110
00116 LIBGIFTPROTO_EXPORT
00117
Hash *hash_calc (
HashAlgo *algo,
const char *path);
00118
00125 LIBGIFTPROTO_EXPORT
00126
char *hash_dsp (
Hash *hash);
00127
00128
00129
00137 LIBGIFTPROTO_EXPORT
00138
unsigned int hash_algo_register (
struct protocol *p,
const char *type,
00139
int opt, HashFn algofn, HashDspFn dspfn);
00140
00149 LIBGIFTPROTO_EXPORT
00150
unsigned int hash_algo_unregister (
struct protocol *p,
const char *type);
00151
00155 LIBGIFTPROTO_EXPORT
00156
HashAlgo *hash_algo_lookup (
const char *type);
00157
00158
00159
00181 LIBGIFTPROTO_EXPORT
00182 BOOL
share_set_hash (
struct file_share *file,
const char *type,
00183
unsigned char *data, size_t len, BOOL copy);
00184
00188 LIBGIFTPROTO_EXPORT
00189
Hash *
share_get_hash (
struct file_share *file,
const char *type);
00190
00196 LIBGIFTPROTO_EXPORT
00197
void share_clear_hash (
struct file_share *file);
00198
00203 LIBGIFTPROTO_EXPORT
00204
void share_foreach_hash (
struct file_share *file, DatasetForeachFn func,
00205
void *udata);
00206
00214 LIBGIFTPROTO_EXPORT
00215
unsigned int share_run_hash (
struct file_share *file);
00216
00227 LIBGIFTPROTO_EXPORT
00228
char *
share_dsp_hash (
struct file_share *file,
const char *type);
00229
00230
00231
00242 LIBGIFTPROTO_EXPORT
00243
char *hashstr_algo (
const char *hashstr);
00244
00250 LIBGIFTPROTO_EXPORT
00251
char *hashstr_data (
const char *hashstr);
00252
00253
00254
00255 EXTERN_C_END
00256
00257
00258
00259
#endif