Main Page | Class List | File List | Class Members | File Members

share_hash.h

Go to the documentation of this file.
00001 /* 00002 * $Id: share_hash.h,v 1.9 2003/11/10 09:47:39 jasta Exp $ 00003 * 00004 * Copyright (C) 2001-2003 giFT project (gift.sourceforge.net) 00005 * 00006 * This program is free software; you can redistribute it and/or modify it 00007 * under the terms of the GNU General Public License as published by the 00008 * Free Software Foundation; either version 2, or (at your option) any 00009 * later version. 00010 * 00011 * This program is distributed in the hope that it will be useful, but 00012 * WITHOUT ANY WARRANTY; without even the implied warranty of 00013 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 * General Public License for more details. 00015 */ 00016 00017 #ifndef __SHARE_HASH_H 00018 #define __SHARE_HASH_H 00019 00020 /*****************************************************************************/ 00021 00032 /*****************************************************************************/ 00033 00034 struct protocol; /* plugin/protocol.h:Protocol */ 00035 struct file_share; /* plugin/share.h: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 /* __SHARE_HASH_H */

Generated on Sun Aug 22 08:08:53 2004 by doxygen 1.3.7