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_dmesh_h_
00037 #define _core_dmesh_h_
00038
00039 #include "common.h"
00040 #include "downloads.h"
00041
00053 typedef struct {
00054 const gchar *name;
00055 host_addr_t addr;
00056 guint idx;
00057 guint16 port;
00058 } dmesh_urlinfo_t;
00059
00064 typedef enum {
00065 DMESH_URL_OK = 0,
00066 DMESH_URL_HTTP_PARSER,
00067 DMESH_URL_BAD_FILE_PREFIX,
00068 DMESH_URL_RESERVED_INDEX,
00069 DMESH_URL_NO_FILENAME,
00070 DMESH_URL_BAD_ENCODING,
00071 DMESH_URL_BAD_URI_RES
00072 } dmesh_url_error_t;
00073
00074 extern dmesh_url_error_t dmesh_url_errno;
00075
00076
00077
00078
00079
00080 void dmesh_init(void);
00081 void dmesh_close(void);
00082
00083 const gchar *dmesh_url_strerror(dmesh_url_error_t errnum);
00084 gboolean dmesh_url_parse(const gchar *url, dmesh_urlinfo_t *info);
00085
00086 gboolean dmesh_add(
00087 const struct sha1 *sha1, const host_addr_t addr, guint16 port, guint idx,
00088 const gchar *name, time_t stamp);
00089
00090 gboolean dmesh_remove(
00091 const struct sha1 *sha1, const host_addr_t addr, guint16 port, guint idx,
00092 const gchar *name);
00093
00094 void dmesh_add_alternate(const struct sha1 *sha1,
00095 host_addr_t addr, guint16 port);
00096 void dmesh_add_good_alternate(const struct sha1 *sha1,
00097 host_addr_t addr, guint16 port);
00098 void dmesh_remove_alternate(const struct sha1 *sha1,
00099 host_addr_t addr, guint16 port);
00100 void dmesh_add_alternates(const struct sha1 *sha1, const gnet_host_vec_t *vec);
00101
00102 void dmesh_negative_alt(const struct sha1 *sha1,
00103 host_addr_t reporter, host_addr_t addr, guint16 port);
00104 void dmesh_good_mark(const struct sha1 *sha1,
00105 host_addr_t addr, guint16 port, gboolean good);
00106
00107 gint dmesh_count(const struct sha1 *sha1);
00108
00109 gboolean dmesh_collect_sha1(const gchar *value, struct sha1 *sha1);
00110 void dmesh_collect_locations(const struct sha1 *sha1, const gchar *value);
00111 void dmesh_collect_compact_locations(const struct sha1 *sha1,
00112 const gchar *value);
00113 void dmesh_collect_negative_locations(const struct sha1 *sha1,
00114 const gchar *value, host_addr_t reporter);
00115 gint dmesh_fill_alternate(const struct sha1 *sha1,
00116 gnet_host_t *hvec, gint hcnt);
00117
00118 gint dmesh_alternate_location(
00119 const struct sha1 *sha1, gchar * buf, size_t size, const host_addr_t addr,
00120 time_t last_sent, const gchar *vendor, fileinfo_t *fi,
00121 gboolean request);
00122
00123 void dmesh_multiple_downloads(
00124 const struct sha1 *sha1, filesize_t size, fileinfo_t *fi);
00125
00126 void dmesh_check_results_set(gnet_results_set_t *rs);
00127
00128 void dmesh_store(void);
00129 void dmesh_ban_store(void);
00130
00131 #endif
00132
00133