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

qrp.h

Go to the documentation of this file.
00001 /*
00002  * $Id: qrp.h,v 1.6 2005/09/14 17:59:51 rmanfredi Exp $
00003  *
00004  * Copyright (c) 2002-2003, Raphael Manfredi
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_qrp_h_
00037 #define _core_qrp_h_
00038 
00039 #include <glib.h>
00040 
00041 #include "matching.h"       /* For char_map_t */
00042 
00043 #define QRP_MIN_WORD_LENGTH     3   
00045 /*
00046  * Query routing: structures to keep track of all the query hashes,
00047  * and where they come from..
00048  */
00049 
00050 enum query_hsrc {
00051     QUERY_H_WORD = 0,       
00052     QUERY_H_URN             
00053 };
00054 
00055 struct query_hash {
00056     guint32 hashcode;
00057     enum query_hsrc source;
00058 };
00059 
00060 typedef struct query_hashvec {
00061     gint count;             
00062     gint size;              
00063     gboolean has_urn;       
00064     struct query_hash *vec; 
00065 } query_hashvec_t;
00066 
00067 #define qhvec_has_urn(x)    ((x)->has_urn)
00068 
00069 typedef struct qrt_info {
00070     gint slots;             
00071     gint generation;        
00072     gint fill_ratio;        
00073     gint pass_throw;        
00074 } qrt_info_t;
00075 
00076 
00077 typedef void (*qrp_callback_t)(gpointer arg, gboolean cancelled);
00078 
00079 /*
00080  * Public interface.
00081  */
00082 
00083 struct gnutella_node;
00084 
00085 void qrp_init(char_map_t map);
00086 void qrp_close(void);
00087 
00088 void qrp_leaf_changed(void);
00089 void qrp_peermode_changed(void);
00090 
00091 void qrp_prepare_computation(void);
00092 void qrp_add_file(struct shared_file *sf);
00093 void qrp_finalize_computation(void);
00094 
00095 gpointer qrt_update_create(struct gnutella_node *n, gpointer query_table);
00096 void qrt_update_free(gpointer handle);
00097 gboolean qrt_update_send_next(gpointer handle);
00098 gboolean qrt_update_was_ok(gpointer handle);
00099 
00100 gpointer qrt_receive_create(struct gnutella_node *n, gpointer query_table);
00101 void qrt_receive_free(gpointer handle);
00102 gboolean qrt_receive_next(gpointer handle, gboolean *done);
00103 
00104 gpointer qrt_get_table(void);
00105 gpointer qrt_ref(gpointer obj);
00106 void qrt_unref(gpointer obj);
00107 void qrt_get_info(gpointer obj, qrt_info_t *qi);
00108 
00109 struct query_hashvec *qhvec_alloc(gint size);
00110 void qhvec_free(struct query_hashvec *qhvec);
00111 void qhvec_reset(struct query_hashvec *qhvec);
00112 query_hashvec_t * qhvec_clone(const query_hashvec_t *qsrc);
00113 void qhvec_add(struct query_hashvec *qhvec, const gchar *word,
00114     enum query_hsrc src);
00115 
00116 GSList *qrt_build_query_target(
00117     query_hashvec_t *qhvec, gint hops, gint ttl, struct gnutella_node *source);
00118 void qrt_route_query(struct gnutella_node *n, query_hashvec_t *qhvec);
00119 gboolean qrp_node_can_route(struct gnutella_node *n, query_hashvec_t *qhv);
00120 
00121 #endif  /* _core_qrp_h_ */
00122 
00123 /* vi: set ts=4 sw=4 cindent: */

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