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

share.h

Go to the documentation of this file.
00001 /*
00002  * $Id: share.h,v 1.15 2005/10/30 09:48:57 cbiere Exp $
00003  *
00004  * Copyright (c) 2001-2005, Raphael Manfredi
00005  * Copyright (c) 2000 Daniel Walker (dwalker@cats.ucsc.edu)
00006  *
00007  *----------------------------------------------------------------------
00008  * This file is part of gtk-gnutella.
00009  *
00010  *  gtk-gnutella is free software; you can redistribute it and/or modify
00011  *  it under the terms of the GNU General Public License as published by
00012  *  the Free Software Foundation; either version 2 of the License, or
00013  *  (at your option) any later version.
00014  *
00015  *  gtk-gnutella is distributed in the hope that it will be useful,
00016  *  but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  *  GNU General Public License for more details.
00019  *
00020  *  You should have received a copy of the GNU General Public License
00021  *  along with gtk-gnutella; if not, write to the Free Software
00022  *  Foundation, Inc.:
00023  *      59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00024  *----------------------------------------------------------------------
00025  */
00026 
00039 #ifndef _core_share_h_
00040 #define _core_share_h_
00041 
00042 #include "common.h"
00043 #include "if/core/share.h"
00044 
00045 struct extension {
00046     gchar *str;                 
00047     size_t len;                 
00048 };
00049 
00050 typedef struct shared_file {
00051     const gchar *file_path;     
00052     const gchar *name_nfc;      
00053     const gchar *name_canonic;  
00054     const gchar *content_type;  
00056     struct dl_file_info *fi;    
00058     filesize_t file_size;       
00059     guint32 file_index;         
00061     gint refcnt;                
00062     guint32 flags;              
00064     size_t name_nfc_len;        
00065     size_t name_canonic_len;    
00067     time_t mtime;               
00068     gchar sha1_digest[SHA1_RAW_SIZE];   
00069 } shared_file_t;
00070 
00075 #define SHARE_F_HAS_DIGEST  0x00000001      
00076 #define SHARE_F_RECOMPUTING 0x00000002      
00082 enum share_mime_type {
00083     SHARE_M_APPLICATION_BINARY = 0,
00084     SHARE_M_IMAGE_PNG,
00085     SHARE_M_TEXT_PLAIN,
00086 };
00087 
00088 struct gnutella_search_results_out {
00089     guchar num_recs;
00090     guchar host_port[2];
00091     guchar host_ip[4];
00092     guchar host_speed[4];
00093 
00094     /* record data follows */
00095 
00096     /* Last 16 bytes = client_id */
00097 };
00098 
00099 #define SHARE_REBUILDING    ((struct shared_file *) 0x1)
00100 
00101 struct gnutella_node;
00102 struct query_hashvec;
00103 
00108 extern GSList *extensions, *shared_dirs;
00109 
00110 /*
00111  * Special return value from shared_file() during library rebuild time.
00112  * This is needed because we no longer block the GUI whilst scanning.
00113  */
00114 
00115 /*
00116  * Global Functions
00117  */
00118 
00119 void share_init(void);
00120 void share_close(void);
00121 
00122 const gchar *share_mime_type(enum share_mime_type type);
00123 
00124 shared_file_t *shared_file(guint idx);
00125 shared_file_t *shared_file_by_name(const gchar *basename);
00126 shared_file_t * shared_file_ref(shared_file_t *sf);
00127 shared_file_t *shared_file_by_sha1(gchar *sha1_digest);
00128 shared_file_t *shared_special(const gchar *path);
00129 void shared_file_unref(shared_file_t *sf);
00130 
00131 gboolean search_request(struct gnutella_node *n, struct query_hashvec *qhv);
00132 void parse_extensions(const gchar *);
00133 gchar *get_file_path(gint);
00134 void shared_dirs_update_prop(void);
00135 gboolean shared_dirs_parse(const gchar *);
00136 
00137 size_t compact_query(gchar *search);
00138 void query_strip_oob_flag(struct gnutella_node *n, gchar *data);
00139 void query_set_oob_flag(struct gnutella_node *n, gchar *data);
00140 
00141 void set_sha1(struct shared_file *, const gchar *sha1_digest);
00142 gboolean sha1_hash_available(const struct shared_file *);
00143 gboolean sha1_hash_is_uptodate(struct shared_file *sf);
00144 
00145 void use_map_on_query(gchar *query, int len);
00146 
00147 #endif /* _core_share_h_ */
00148 
00149 /* vi: set ts=4 sw=4 cindent: */

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