Main Page | Modules | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

share.h File Reference


Detailed Description

Handle sharing of our own files and answers to remote queries.

Author:
Raphael Manfredi
Date:
2001-2005
Author:
Daniel Walker (dwalker@cats.ucsc.edu)
Date:
2000

#include "common.h"
#include "if/core/share.h"

Go to the source code of this file.

Data Structures

struct  extension
struct  shared_file
struct  gnutella_search_results_out

Defines

#define SHARE_F_HAS_DIGEST   0x00000001 /**< Digest is set */
 Digest is set.

#define SHARE_F_RECOMPUTING   0x00000002 /**< Digest being recomputed */
 Digest being recomputed.

#define SHARE_REBUILDING   ((struct shared_file *) 0x1)

Typedefs

typedef shared_file shared_file_t

Enumerations

enum  share_mime_type { SHARE_M_APPLICATION_BINARY = 0, SHARE_M_IMAGE_PNG, SHARE_M_TEXT_PLAIN }
 Known MIME content types. More...


Functions

void share_init (void)
 Initialization of the sharing library.

void share_close (void)
 Shutdown cleanup.

const gchar * share_mime_type (enum share_mime_type type)
 Returns the MIME content type string.

shared_file_tshared_file (guint idx)
 Given a valid index, returns the `struct shared_file' entry describing the shared file bearing that index if found, NULL if not found (invalid index) and SHARE_REBUILDING when we're rebuilding the library.

shared_file_tshared_file_by_name (const gchar *basename)
 Given a file basename, returns the `struct shared_file' entry describing the shared file bearing that basename, provided it is unique, NULL if we either don't have a unique filename or SHARE_REBUILDING if the library is being rebuilt.

shared_file_tshared_file_ref (shared_file_t *sf)
 Add one more reference to a shared_file_t.

shared_file_tshared_file_by_sha1 (gchar *sha1_digest)
 Take a given binary SHA1 digest, and return the corresponding shared_file if we have it.

shared_file_tshared_special (const gchar *path)
 Look up a possibly shared special file, updating the entry with current file size and modification time.

void shared_file_unref (shared_file_t *sf)
 Remove one reference to a shared_file_t, freeing entry if there are no reference left.

gboolean search_request (struct gnutella_node *n, struct query_hashvec *qhv)
void parse_extensions (const gchar *)
 Get the file extensions to scan.

gchar * get_file_path (gint)
void shared_dirs_update_prop (void)
 Update the property holding the shared directories.

gboolean shared_dirs_parse (const gchar *)
 Parses the given string and updated the internal list of shared dirs.

size_t compact_query (gchar *search)
 Remove unnecessary ballast from a query string, in-place.

void query_strip_oob_flag (struct gnutella_node *n, gchar *data)
void query_set_oob_flag (struct gnutella_node *n, gchar *data)
void set_sha1 (struct shared_file *, const gchar *sha1_digest)
gboolean sha1_hash_available (const struct shared_file *)
 Predicate returning TRUE if the SHA1 hash is available for a given shared_file, FALSE otherwise.

gboolean sha1_hash_is_uptodate (struct shared_file *sf)
 Predicate returning TRUE if the SHA1 hash is available AND is up to date for the shared file.

void use_map_on_query (gchar *query, int len)
 Apply the proper charset mapping on the query, depending on their locale, so that the query has no accent.


Variables

GSList * extensions
 Global Data.

GSList * shared_dirs
 Global Data.


Define Documentation

#define SHARE_F_HAS_DIGEST   0x00000001 /**< Digest is set */
 

Digest is set.

#define SHARE_F_RECOMPUTING   0x00000002 /**< Digest being recomputed */
 

Digest being recomputed.

#define SHARE_REBUILDING   ((struct shared_file *) 0x1)
 


Typedef Documentation

typedef struct shared_file shared_file_t
 


Enumeration Type Documentation

enum share_mime_type
 

Known MIME content types.

Enumeration values:
SHARE_M_APPLICATION_BINARY 
SHARE_M_IMAGE_PNG 
SHARE_M_TEXT_PLAIN 


Function Documentation

size_t compact_query gchar *  search  ) 
 

Remove unnecessary ballast from a query string, in-place.

Returns:
new query string length.

gchar* get_file_path gint   ) 
 

void parse_extensions const gchar *   ) 
 

Get the file extensions to scan.

void query_set_oob_flag struct gnutella_node n,
gchar *  data
 

void query_strip_oob_flag struct gnutella_node n,
gchar *  data
 

gboolean search_request struct gnutella_node n,
struct query_hashvec qhv
 

void set_sha1 struct shared_file ,
const gchar *  sha1_digest
 

gboolean sha1_hash_available const struct shared_file sf  ) 
 

Predicate returning TRUE if the SHA1 hash is available for a given shared_file, FALSE otherwise.

Use sha1_hash_is_uptodate() to check for availability and accurateness.

gboolean sha1_hash_is_uptodate struct shared_file sf  ) 
 

Predicate returning TRUE if the SHA1 hash is available AND is up to date for the shared file.

NB: if the file is found to have changed, the background computation of the SHA1 is requested.

void share_close void   ) 
 

Shutdown cleanup.

void share_init void   ) 
 

Initialization of the sharing library.

We allocate an empty search_table, which will be de-allocated when we call share_scan(). Why do we do this? Because it ensures the table is correctly setup empty, until we do call share_scan() for the first time (the call is delayed until the GUI is up).

Since we will start processing network packets, we will have a race condition window if we get a Query message before having started the share_scan(). Creating the table right now prevents adding an extra test at the top of st_search(). --RAM, 15/08/2002.

const gchar* share_mime_type enum share_mime_type  type  ) 
 

Returns the MIME content type string.

gboolean shared_dirs_parse const gchar *  str  ) 
 

Parses the given string and updated the internal list of shared dirs.

The given string was completely parsed, it returns TRUE, otherwise it returns FALSE.

void shared_dirs_update_prop void   ) 
 

Update the property holding the shared directories.

shared_file_t* shared_file guint  idx  ) 
 

Given a valid index, returns the `struct shared_file' entry describing the shared file bearing that index if found, NULL if not found (invalid index) and SHARE_REBUILDING when we're rebuilding the library.

shared_file_t* shared_file_by_name const gchar *  basename  ) 
 

Given a file basename, returns the `struct shared_file' entry describing the shared file bearing that basename, provided it is unique, NULL if we either don't have a unique filename or SHARE_REBUILDING if the library is being rebuilt.

shared_file_t* shared_file_by_sha1 gchar *  sha1_digest  ) 
 

Take a given binary SHA1 digest, and return the corresponding shared_file if we have it.

Attention:
NB: if the returned "shared_file" structure holds a non-NULL `fi', then it means it is a partially shared file.

shared_file_t* shared_file_ref shared_file_t sf  ) 
 

Add one more reference to a shared_file_t.

Returns:
its argument, for convenience.

void shared_file_unref shared_file_t sf  ) 
 

Remove one reference to a shared_file_t, freeing entry if there are no reference left.

shared_file_t* shared_special const gchar *  path  ) 
 

Look up a possibly shared special file, updating the entry with current file size and modification time.

Parameters:
path the URL path on the server (case sensitive, of course)
Returns:
the shared file information if there is something shared at path, or NULL if the path is invalid.

void use_map_on_query gchar *  query,
int  len
 

Apply the proper charset mapping on the query, depending on their locale, so that the query has no accent.


Variable Documentation

GSList* extensions
 

Global Data.

GSList * shared_dirs
 

Global Data.


Generated on Sun Feb 12 10:50:08 2006 for Gtk-Gnutella by doxygen 1.3.6