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

gi_share_hash.h File Reference

Manage hashing algorithms provided by protocol plugins and applied to locally shared files. More...

Go to the source code of this file.

Classes

struct  gi_hash_handler
struct  GiHash

Enumerations

enum  gi_hash_opts { GI_HASH_PRIMARY = 0x01, GI_HASH_SECONDARY = 0x02, GI_HASH_LOCAL = 0x04 }

Functions

EXTERN_C_BEGIN LIBGIFTPROTO_EXPORT
GiHash
gi_hash_new (const char *type, unsigned char *data, size_t len)
LIBGIFTPROTO_EXPORT void gi_hash_free (GiHash *hash)
LIBGIFTPROTO_EXPORT GiHashgi_hash_dup (GiHash *hash)
LIBGIFTPROTO_EXPORT bool gi_share_set_hash (struct gi_file_share *file, const char *type, unsigned char *data, size_t len)
LIBGIFTPROTO_EXPORT GiHashgi_share_get_hash (struct gi_file_share *file, const char *type)
LIBGIFTPROTO_EXPORT void gi_share_clear_hash (struct gi_file_share *file)
LIBGIFTPROTO_EXPORT void gi_share_foreach_hash (struct gi_file_share *file, GiDatasetForeachFn func, void *udata)
LIBGIFTPROTO_EXPORT char * gi_hashstr_algo (const char *hashstr)
LIBGIFTPROTO_EXPORT char * gi_hashstr_data (const char *hashstr)


Detailed Description

Manage hashing algorithms provided by protocol plugins and applied to locally shared files.

There are really multiple interfaces defined here. The supplementary share interface should be moved into share.[ch] at some time.


Enumeration Type Documentation

enum gi_hash_opts
 

Todo:
DOCME!


Function Documentation

LIBGIFTPROTO_EXPORT GiHash* gi_hash_dup GiHash hash  ) 
 

Duplicate all entries in a hash object. This includes the original data argument.

LIBGIFTPROTO_EXPORT void gi_hash_free GiHash hash  ) 
 

Destroy the result from ::hash_new. Please note that this will free the original data argument.

EXTERN_C_BEGIN LIBGIFTPROTO_EXPORT GiHash* gi_hash_new const char *  type,
unsigned char *  data,
size_t  len
 

Raw interface to allocate a new hash object. Please avoid using this directly at all costs.

Parameters:
type 
data Pointer to the beginning of a hash at least `len' bytes long. This data must be allocated, and will not be copied by this function call.
len Length of `data'.
Returns:
Dynamically allocated hash object.

LIBGIFTPROTO_EXPORT char* gi_hashstr_algo const char *  hashstr  ) 
 

Given a giFT-specific hash string return a static reference to ALGOTYPE. The protocol has no awareness of this hack, and it is only used to serialize hashes over the interface protocol.

Parameters:
hashstr Serialized hash string in the form ALGOTYPE:ASCIIDATA
Returns:
Pointer to a static NUL-terminated string representation of the algorithm name or NULL on error.

LIBGIFTPROTO_EXPORT char* gi_hashstr_data const char *  hashstr  ) 
 

Access the data portion of the hash string. See ::hashstr_algo.

Returns:
Pointer into the supplied hashstr object.

LIBGIFTPROTO_EXPORT void gi_share_clear_hash struct gi_file_share file  ) 
 

Clear all hashes associated with the given file. Management of the internal hash memory is dependent on the parameters given to ::share_set_hash.

LIBGIFTPROTO_EXPORT void gi_share_foreach_hash struct gi_file_share file,
GiDatasetForeachFn  func,
void *  udata
 

Iterate through all hashes currently associated with this file. Internally uses ::gi_dataset_foreach.

LIBGIFTPROTO_EXPORT GiHash* gi_share_get_hash struct gi_file_share file,
const char *  type
 

Access the previously set hash. See ::share_hash_set.

LIBGIFTPROTO_EXPORT bool gi_share_set_hash struct gi_file_share file,
const char *  type,
unsigned char *  data,
size_t  len
 

Associate a predetermined hashed value with a share object.

Parameters:
file Share object.
type Hashing algorithm's formal name as registered by the plugin.
data Hash data. Memory management within the share object is conditionally dependent on `copy'.
len Length of `data'.
Returns:
Boolean success or failure. Successful completion of this operation is defined by the final placement of the specified hash parameter in the internal share object's hash, regardless of whether or not this required an overwrite of the previous data. Use ::share_get_hash if you need to know if there is already an associated hash.


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