00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
00023
00024
00025
00036 #ifndef _core_qrp_h_
00037 #define _core_qrp_h_
00038
00039 #include <glib.h>
00040
00041 #include "matching.h"
00042
00043 #define QRP_MIN_WORD_LENGTH 3
00045
00046
00047
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
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
00122
00123