Main Page | Class List | File List | Class Members | File Members | Related Pages

gi_share_hash.h

Go to the documentation of this file.
00001 /* 00002 * $Id: gi_share_hash.h,v 1.1.2.5 2004/07/07 09:34:11 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 __GI_SHARE_HASH_H 00018 #define __GI_SHARE_HASH_H 00019 00020 /*****************************************************************************/ 00021 00032 /*****************************************************************************/ 00033 00034 struct gi_protocol; /* plugin/protocol.h:GiProtocol */ 00035 struct gi_file_share; /* plugin/share.h:Share */ 00036 00037 /*****************************************************************************/ 00038 00042 enum gi_hash_opts 00043 { 00044 GI_HASH_PRIMARY = 0x01, 00045 GI_HASH_SECONDARY = 0x02, 00046 GI_HASH_LOCAL = 0x04 00047 }; 00048 00052 struct gi_hash_handler 00053 { 00054 const char *name; 00055 enum gi_hash_opts opt; 00056 void * (*init) (off_t size); 00057 bool (*update) (void *ctx, unsigned char *buf, size_t siz); 00058 bool (*finish) (void *ctx, unsigned char **buf, size_t *siz); 00059 char * (*ascii) (unsigned char *buf, size_t siz); 00060 }; 00061 00062 /*****************************************************************************/ 00063 00067 typedef struct 00068 { 00069 char *type; 00071 unsigned char *data; 00074 size_t len; 00075 } GiHash; 00076 00077 /*****************************************************************************/ 00078 00079 EXTERN_C_BEGIN 00080 00081 /*****************************************************************************/ 00082 00097 LIBGIFTPROTO_EXPORT 00098 GiHash *gi_hash_new (const char *type, unsigned char *data, size_t len); 00099 00104 LIBGIFTPROTO_EXPORT 00105 void gi_hash_free (GiHash *hash); 00106 00111 LIBGIFTPROTO_EXPORT 00112 GiHash *gi_hash_dup (GiHash *hash); 00113 00114 /*****************************************************************************/ 00115 00136 LIBGIFTPROTO_EXPORT 00137 bool gi_share_set_hash (struct gi_file_share *file, const char *type, 00138 unsigned char *data, size_t len); 00139 00143 LIBGIFTPROTO_EXPORT 00144 GiHash *gi_share_get_hash (struct gi_file_share *file, const char *type); 00145 00151 LIBGIFTPROTO_EXPORT 00152 void gi_share_clear_hash (struct gi_file_share *file); 00153 00158 LIBGIFTPROTO_EXPORT 00159 void gi_share_foreach_hash (struct gi_file_share *file, 00160 GiDatasetForeachFn func, void *udata); 00161 00162 /*****************************************************************************/ 00163 00175 LIBGIFTPROTO_EXPORT 00176 char *gi_hashstr_algo (const char *hashstr); 00177 00183 LIBGIFTPROTO_EXPORT 00184 char *gi_hashstr_data (const char *hashstr); 00185 00186 /*****************************************************************************/ 00187 00188 EXTERN_C_END 00189 00190 /*****************************************************************************/ 00191 00192 #endif /* __GI_SHARE_HASH_H */

Generated on Sun Aug 22 08:11:13 2004 by doxygen 1.3.7