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

ignore.c File Reference


Detailed Description

Management of download ignoring list.

Author:
Raphael Manfredi
Date:
2002-2003

#include "common.h"
#include "ignore.h"
#include "huge.h"
#include "share.h"
#include "settings.h"
#include "namesize.h"
#include "lib/atoms.h"
#include "lib/base32.h"
#include "lib/file.h"
#include "lib/misc.h"
#include "lib/tm.h"
#include "if/gnet_property_priv.h"
#include "lib/override.h"

Functions

 RCSID ("$Id:ignore.c, v 1.15 2005/12/27 16:34:49 cbiere Exp $")
void ignore_sha1_load (const gchar *file, time_t *stamp)
 Load new SHA1 from `file'.

void ignore_namesize_load (const gchar *file, time_t *stamp)
 Load new name/size tuples from `file'.

FILE * open_read_stamp (const gchar *file, time_t *stamp)
 Open `file' for reading if it exists.

FILE * open_append (const gchar *file)
 Open `file' for appending.

void ignore_init (void)
 Initialize the ignore tables.

void sha1_parse (FILE *f, const gchar *file)
 Parse opened file `f' containing SHA1s to ignore.

void namesize_parse (FILE *f, const gchar *file)
 Parse opened `f' containing size/filenames to ignore.

gchar * ignore_sha1_filename (const gchar *sha1)
enum ignore_val ignore_is_requested (const gchar *file, filesize_t size, gchar *sha1)
 Is ignoring requested for `file' of size `size' and SHA1 `sha1'? Priority is given to the SHA1, if supplied.

void ignore_add_sha1 (const gchar *file, const gchar *sha1)
 Add `sha1' to the set of ignored entries.

void ignore_add_filesize (const gchar *file, filesize_t size)
 Add `file', `size' to the set of ignored entries.

void ignore_timer (time_t unused_now)
 Called periodically to check the file timestamps.

gboolean free_sha1_kv (gpointer key, gpointer value, gpointer unused_udata)
 Remove iterator callback.

gboolean free_namesize_kv (gpointer key, gpointer unused_value, gpointer unused_udata)
 Remove iterator callback.

void ignore_close (void)
 Called during servent shutdown to free up resources.


Variables

GHashTable * by_sha1
 SHA1s to ignore.

GHashTable * by_namesize
 By filename + filesize.

const gchar ignore_sha1 [] = "ignore.sha1"
const gchar ignore_namesize [] = "ignore.namesize"
const gchar done_sha1 [] = "done.sha1"
const gchar done_namesize [] = "done.namesize"
time_t ignore_sha1_mtime
time_t ignore_namesize_mtime
FILE * sha1_out = NULL
FILE * namesize_out = NULL
gchar ign_tmp [1024]


Function Documentation

gboolean free_namesize_kv gpointer  key,
gpointer  unused_value,
gpointer  unused_udata
[static]
 

Remove iterator callback.

Free a key/value pair from the by_namesize hash.

gboolean free_sha1_kv gpointer  key,
gpointer  value,
gpointer  unused_udata
[static]
 

Remove iterator callback.

Free a key/value pair from the by_sha1 hash.

void ignore_add_filesize const gchar *  file,
filesize_t  size
 

Add `file', `size' to the set of ignored entries.

void ignore_add_sha1 const gchar *  file,
const gchar *  sha1
 

Add `sha1' to the set of ignored entries.

void ignore_close void   ) 
 

Called during servent shutdown to free up resources.

void ignore_init void   ) 
 

Initialize the ignore tables.

enum ignore_val ignore_is_requested const gchar *  file,
filesize_t  size,
gchar *  sha1
 

Is ignoring requested for `file' of size `size' and SHA1 `sha1'? Priority is given to the SHA1, if supplied.

Parameters:
file Must be a basename, without any directory separator
size the filesize
sha1 must point to a SHA1 (binary) or NULL

void ignore_namesize_load const gchar *  file,
time_t *  stamp
[static]
 

Load new name/size tuples from `file'.

If `stamp' is non-NULL, fill it with the mtime of the file, or the current time if the file does not exist.

gchar* ignore_sha1_filename const gchar *  sha1  ) 
 

Returns:
the filename associated with the digest if known, NULL otherwise.

void ignore_sha1_load const gchar *  file,
time_t *  stamp
[static]
 

Load new SHA1 from `file'.

If `stamp' is non-NULL, fill it with the mtime of the file, or the current time if the file does not exist.

void ignore_timer time_t  unused_now  ) 
 

Called periodically to check the file timestamps.

If files are newer, they are reloaded, but the previously recorded ignores are NOT forgotten. Therefore, we can ONLY append new ignores.

void namesize_parse FILE *  f,
const gchar *  file
[static]
 

Parse opened `f' containing size/filenames to ignore.

FILE* open_append const gchar *  file  )  [static]
 

Open `file' for appending.

FILE* open_read_stamp const gchar *  file,
time_t *  stamp
[static]
 

Open `file' for reading if it exists.

If `stamp' is non-NULL, fill it with the mtime of the file, or the current time if the file does not exist.

Returns:
FILE* of the opened file on success, NULL on failure.

RCSID "$Id:ignore.  c,
v 1.15 2005/12/27 16:34:49 cbiere Exp $" 
 

void sha1_parse FILE *  f,
const gchar *  file
[static]
 

Parse opened file `f' containing SHA1s to ignore.


Variable Documentation

GHashTable* by_namesize [static]
 

By filename + filesize.

GHashTable* by_sha1 [static]
 

SHA1s to ignore.

const gchar done_namesize[] = "done.namesize" [static]
 

const gchar done_sha1[] = "done.sha1" [static]
 

gchar ign_tmp[1024] [static]
 

const gchar ignore_namesize[] = "ignore.namesize" [static]
 

time_t ignore_namesize_mtime [static]
 

const gchar ignore_sha1[] = "ignore.sha1" [static]
 

time_t ignore_sha1_mtime [static]
 

FILE* namesize_out = NULL [static]
 

FILE* sha1_out = NULL [static]
 


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