diff 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
line diff
     1.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     1.2 +++ b/src/gt_search.h	Sat Feb 20 21:18:28 2010 -0800
     1.3 @@ -0,0 +1,120 @@
     1.4 +/*
     1.5 + * $Id: gt_search.h,v 1.19 2004/01/18 05:43:13 hipnod Exp $
     1.6 + *
     1.7 + * Copyright (C) 2001-2003 giFT project (gift.sourceforge.net)
     1.8 + *
     1.9 + * This program is free software; you can redistribute it and/or modify it
    1.10 + * under the terms of the GNU General Public License as published by the
    1.11 + * Free Software Foundation; either version 2, or (at your option) any
    1.12 + * later version.
    1.13 + *
    1.14 + * This program is distributed in the hope that it will be useful, but
    1.15 + * WITHOUT ANY WARRANTY; without even the implied warranty of
    1.16 + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
    1.17 + * General Public License for more details.
    1.18 + */
    1.19 +
    1.20 +#ifndef GIFT_GT_SEARCH_H_
    1.21 +#define GIFT_GT_SEARCH_H_
    1.22 +
    1.23 +/******************************************************************************/
    1.24 +
    1.25 +struct tcp_conn;
    1.26 +struct file_share;
    1.27 +
    1.28 +typedef enum
    1.29 +{
    1.30 +	GT_SEARCH_HASH,
    1.31 +	GT_SEARCH_KEYWORD,
    1.32 +} gt_search_type_t;
    1.33 +
    1.34 +/*
    1.35 + * These flags exist in what used to be the MinSpeed field of
    1.36 + * queries. The documentation for this field is arranged as two
    1.37 + * bytes in big-endian order, but this uses it in little-endian
    1.38 + * order so as to be consistent with the rest of the protocol.
    1.39 + */
    1.40 +typedef enum gt_query_flags
    1.41 +{
    1.42 +	QF_WANTS_XML     = 0x0020,    /* servent wants XML metadata */
    1.43 +	QF_ONLY_NON_FW   = 0x0040,    /* source desires non-firewalled hits only */
    1.44 +	QF_HAS_FLAGS     = 0x0080,    /* this query has this interpretation */
    1.45 +} gt_query_flags_t;
    1.46 +
    1.47 +typedef struct gt_search
    1.48 +{
    1.49 +	/* giFT event */
    1.50 +	IFEvent        *event;
    1.51 +
    1.52 +	/* what kind of search this is */
    1.53 +	gt_search_type_t type;
    1.54 +
    1.55 +	/* the guid used to identify the search */
    1.56 +	char           *guid;
    1.57 +
    1.58 +	/* the query used for the search */
    1.59 +	char           *query;
    1.60 +
    1.61 +	/* the hash to look for this search if a URN query XXX should use gt_urn_t
    1.62 +	 * here, but the interface is just too borked */
    1.63 +	char           *hash;
    1.64 +
    1.65 +	/* the realm used for this query, if any */
    1.66 +	char           *realm;
    1.67 +
    1.68 +	/* expires the search according to critieria: see 
    1.69 +	 * gt_search.c:search_timeout */
    1.70 +	timer_id        timeout_timer;
    1.71 +
    1.72 +	/* when the search was started */
    1.73 +	time_t          start;
    1.74 +
    1.75 +	/* how many nodes this search has been submitted to */
    1.76 +	size_t          submitted;
    1.77 +
    1.78 +	/* the last time we submitted to a node */
    1.79 +	time_t          last_submit;
    1.80 +
    1.81 +	/* time the last result for this search was seen */
    1.82 +	time_t          last_result;
    1.83 +
    1.84 +	/* results count */
    1.85 +	size_t          results;
    1.86 +} GtSearch;
    1.87 +
    1.88 +/* the default ttl for searches */
    1.89 +#define GT_SEARCH_TTL          (5)
    1.90 +
    1.91 +/******************************************************************************/
    1.92 +
    1.93 +GtSearch    *gt_search_new     (IFEvent *event, char *query,
    1.94 +                                gt_search_type_t type);
    1.95 +void         gt_search_free    (GtSearch *search);
    1.96 +void         gt_search_disable (IFEvent *event);
    1.97 +void         gt_search_reply   (GtSearch *search, struct tcp_conn *c,
    1.98 +                                in_addr_t ip, in_port_t gt_port,
    1.99 +                                gt_guid_t *client_guid, int availability,
   1.100 +                                BOOL firewalled, struct file_share *file);
   1.101 +GtSearch    *gt_search_find    (gt_guid_t *guid);
   1.102 +
   1.103 +/* submit active searches to a node after a timeout */
   1.104 +void  gt_searches_submit (struct tcp_conn *c, time_t delay);
   1.105 +
   1.106 +/******************************************************************************/
   1.107 +
   1.108 +BOOL gnutella_search        (Protocol *p, IFEvent *event, char *query,
   1.109 +                             char *exclude, char *realm, Dataset *meta);
   1.110 +
   1.111 +BOOL gnutella_locate        (Protocol *p, IFEvent *event, char *htype,
   1.112 +                             char *hash);
   1.113 +
   1.114 +void gnutella_search_cancel (Protocol *p, IFEvent *event);
   1.115 +
   1.116 +/******************************************************************************/
   1.117 +
   1.118 +void gt_search_init         (void);
   1.119 +void gt_search_cleanup      (void);
   1.120 +
   1.121 +/******************************************************************************/
   1.122 +
   1.123 +#endif /* GIFT_GT_SEARCH_H_ */