Mercurial > hg > index.fcgi > gift-gnutella > gift-gnutella-0.0.11-1pba
comparison src/gt_search.h @ 0:d39e1d0d75b6
initial add
author | paulo@hit-nxdomain.opendns.com |
---|---|
date | Sat, 20 Feb 2010 21:18:28 -0800 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:32c45f3a159f |
---|---|
1 /* | |
2 * $Id: gt_search.h,v 1.19 2004/01/18 05:43:13 hipnod Exp $ | |
3 * | |
4 * Copyright (C) 2001-2003 giFT project (gift.sourceforge.net) | |
5 * | |
6 * This program is free software; you can redistribute it and/or modify it | |
7 * under the terms of the GNU General Public License as published by the | |
8 * Free Software Foundation; either version 2, or (at your option) any | |
9 * later version. | |
10 * | |
11 * This program is distributed in the hope that it will be useful, but | |
12 * WITHOUT ANY WARRANTY; without even the implied warranty of | |
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
14 * General Public License for more details. | |
15 */ | |
16 | |
17 #ifndef GIFT_GT_SEARCH_H_ | |
18 #define GIFT_GT_SEARCH_H_ | |
19 | |
20 /******************************************************************************/ | |
21 | |
22 struct tcp_conn; | |
23 struct file_share; | |
24 | |
25 typedef enum | |
26 { | |
27 GT_SEARCH_HASH, | |
28 GT_SEARCH_KEYWORD, | |
29 } gt_search_type_t; | |
30 | |
31 /* | |
32 * These flags exist in what used to be the MinSpeed field of | |
33 * queries. The documentation for this field is arranged as two | |
34 * bytes in big-endian order, but this uses it in little-endian | |
35 * order so as to be consistent with the rest of the protocol. | |
36 */ | |
37 typedef enum gt_query_flags | |
38 { | |
39 QF_WANTS_XML = 0x0020, /* servent wants XML metadata */ | |
40 QF_ONLY_NON_FW = 0x0040, /* source desires non-firewalled hits only */ | |
41 QF_HAS_FLAGS = 0x0080, /* this query has this interpretation */ | |
42 } gt_query_flags_t; | |
43 | |
44 typedef struct gt_search | |
45 { | |
46 /* giFT event */ | |
47 IFEvent *event; | |
48 | |
49 /* what kind of search this is */ | |
50 gt_search_type_t type; | |
51 | |
52 /* the guid used to identify the search */ | |
53 char *guid; | |
54 | |
55 /* the query used for the search */ | |
56 char *query; | |
57 | |
58 /* the hash to look for this search if a URN query XXX should use gt_urn_t | |
59 * here, but the interface is just too borked */ | |
60 char *hash; | |
61 | |
62 /* the realm used for this query, if any */ | |
63 char *realm; | |
64 | |
65 /* expires the search according to critieria: see | |
66 * gt_search.c:search_timeout */ | |
67 timer_id timeout_timer; | |
68 | |
69 /* when the search was started */ | |
70 time_t start; | |
71 | |
72 /* how many nodes this search has been submitted to */ | |
73 size_t submitted; | |
74 | |
75 /* the last time we submitted to a node */ | |
76 time_t last_submit; | |
77 | |
78 /* time the last result for this search was seen */ | |
79 time_t last_result; | |
80 | |
81 /* results count */ | |
82 size_t results; | |
83 } GtSearch; | |
84 | |
85 /* the default ttl for searches */ | |
86 #define GT_SEARCH_TTL (5) | |
87 | |
88 /******************************************************************************/ | |
89 | |
90 GtSearch *gt_search_new (IFEvent *event, char *query, | |
91 gt_search_type_t type); | |
92 void gt_search_free (GtSearch *search); | |
93 void gt_search_disable (IFEvent *event); | |
94 void gt_search_reply (GtSearch *search, struct tcp_conn *c, | |
95 in_addr_t ip, in_port_t gt_port, | |
96 gt_guid_t *client_guid, int availability, | |
97 BOOL firewalled, struct file_share *file); | |
98 GtSearch *gt_search_find (gt_guid_t *guid); | |
99 | |
100 /* submit active searches to a node after a timeout */ | |
101 void gt_searches_submit (struct tcp_conn *c, time_t delay); | |
102 | |
103 /******************************************************************************/ | |
104 | |
105 BOOL gnutella_search (Protocol *p, IFEvent *event, char *query, | |
106 char *exclude, char *realm, Dataset *meta); | |
107 | |
108 BOOL gnutella_locate (Protocol *p, IFEvent *event, char *htype, | |
109 char *hash); | |
110 | |
111 void gnutella_search_cancel (Protocol *p, IFEvent *event); | |
112 | |
113 /******************************************************************************/ | |
114 | |
115 void gt_search_init (void); | |
116 void gt_search_cleanup (void); | |
117 | |
118 /******************************************************************************/ | |
119 | |
120 #endif /* GIFT_GT_SEARCH_H_ */ |