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

fileinfo.h

Go to the documentation of this file.
00001 /*
00002  * $Id: fileinfo.h,v 1.13 2005/11/29 22:41:33 rmanfredi Exp $
00003  *
00004  * Copyright (c) 2002, Vidar Madsen
00005  *
00006  *----------------------------------------------------------------------
00007  * This file is part of gtk-gnutella.
00008  *
00009  *  gtk-gnutella is free software; you can redistribute it and/or modify
00010  *  it under the terms of the GNU General Public License as published by
00011  *  the Free Software Foundation; either version 2 of the License, or
00012  *  (at your option) any later version.
00013  *
00014  *  gtk-gnutella is distributed in the hope that it will be useful,
00015  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00017  *  GNU General Public License for more details.
00018  *
00019  *  You should have received a copy of the GNU General Public License
00020  *  along with gtk-gnutella; if not, write to the Free Software
00021  *  Foundation, Inc.:
00022  *      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *----------------------------------------------------------------------
00024  */
00025 
00036 #ifndef _core_fileinfo_h_
00037 #define _core_fileinfo_h_
00038 
00039 #include "share.h"                      /* For shared_file_t */
00040 #include "if/core/fileinfo.h"
00041 
00042 /*
00043  * Shared core constants
00044  */
00045 
00046 #define FI_LOW_SRC_COUNT    5           
00048 /*
00049  * Operating flags.
00050  */
00051 
00052 #define FI_F_SUSPEND        0x00000001U 
00053 #define FI_F_DISCARD        0x00000002U 
00054 #define FI_F_TRANSIENT      0x40000000U 
00055 #define FI_F_MARK           0x80000000U 
00057 /*
00058  * Public interface.
00059  */
00060 
00061 void file_info_init(void);
00062 void file_info_init_post(void);
00063 void file_info_scandir(const gchar *dir);
00064 gboolean file_info_has_trailer(const gchar *path);
00065 void file_info_retrieve(void);
00066 void file_info_store(void);
00067 void file_info_store_binary(fileinfo_t *fi);
00068 void file_info_store_if_dirty(void);
00069 void file_info_set_discard(fileinfo_t *fi, gboolean state);
00070 enum dl_chunk_status file_info_find_hole(
00071     struct download *d, filesize_t *from, filesize_t *to);
00072 gboolean file_info_find_available_hole(struct download *d,
00073     GSList *ranges, filesize_t *from, filesize_t *to);
00074 void file_info_merge_adjacent(fileinfo_t *fi);
00075 void file_info_clear_download(struct download *d, gboolean lifecount);
00076 enum dl_chunk_status file_info_chunk_status(
00077     fileinfo_t *fi, filesize_t from, filesize_t to);
00078 void file_info_reset(fileinfo_t *fi);
00079 void file_info_recreate(struct download *d);
00080 fileinfo_t *file_info_get(
00081     gchar *file, const gchar *path, filesize_t size, gchar *sha1,
00082     gboolean file_size_known);
00083 void file_info_strip_binary(fileinfo_t *fi);
00084 void file_info_strip_binary_from_file(fileinfo_t *fi, const gchar *file);
00085 gboolean file_info_got_sha1(fileinfo_t *fi, const gchar *sha1);
00086 void file_info_size_known(struct download *d, filesize_t size);
00087 void file_info_update(struct download *d, filesize_t from, filesize_t to,
00088     enum dl_chunk_status status);
00089 enum dl_chunk_status file_info_pos_status(fileinfo_t *fi,
00090     filesize_t pos /*, filesize_t *start, filesize_t *end */);
00091 void file_info_close(void);
00092 void file_info_close_pre(void);
00093 void file_info_try_to_swarm_with(
00094     gchar *file_name, guint32 idx, const host_addr_t addr,
00095     guint16 port, gchar *sha1);
00096 void file_info_spot_completed_orphans(void);
00097 void file_info_add_source(fileinfo_t *fi, struct download *dl);
00098 void file_info_add_new_source(fileinfo_t *fi, struct download *dl);
00099 void file_info_remove_source(
00100     fileinfo_t *fi, struct download *dl, gboolean discard);
00101 void file_info_timer(void);
00102 void file_info_unlink(fileinfo_t *fi);
00103 void file_info_upload_stop(fileinfo_t *fi, const gchar *reason);
00104 void file_info_changed(fileinfo_t *fi);
00105 
00106 shared_file_t *file_info_shared_sha1(const gchar *sha1);
00107 gint file_info_available_ranges(fileinfo_t *fi, gchar *buf, gint size);
00108 gboolean file_info_restrict_range(
00109     fileinfo_t *fi, filesize_t start, filesize_t *end);
00110 
00111 fileinfo_t *file_info_has_identical(
00112     gchar *file, filesize_t size, gchar *sha1);
00113 
00114 fileinfo_t *file_info_get_browse(const gchar *name);
00115 void file_info_remove(fileinfo_t *fi);
00116 
00117 /***
00118  *** Inlined routines.
00119  ***/
00120 
00124 static inline G_GNUC_CONST WARN_UNUSED_RESULT guint32
00125 fi_alive_count(fileinfo_t *fi)
00126 {
00127     return fi->aqueued_count + fi->pqueued_count + fi->recvcount;
00128 }
00129 
00130 #endif /* _core_fileinfo_h_ */
00131 
00132 /* vi: set ts=4 sw=4 cindent: */

Generated on Sun Feb 12 10:49:56 2006 for Gtk-Gnutella by doxygen 1.3.6