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

matching.h

Go to the documentation of this file.
00001 /*
00002  * $Id: matching.h,v 1.6 2005/06/29 14:24:23 daichik Exp $
00003  *
00004  * Copyright (c) 2001-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 
00064 #ifndef _core_matching_h_
00065 #define _core_matching_h_
00066 
00067 struct shared_file;
00068 
00069 struct st_entry {
00070     gchar *string;
00071     struct shared_file *data;
00072     guint32 mask;
00073 };
00074 
00075 struct st_bin {
00076     gint nslots, nvals;
00077     struct st_entry **vals;
00078 };
00079 
00080 typedef guint8 char_map_t[256];     
00082 typedef struct _search_table {
00083     gint nentries, nchars, nbins;
00084     struct st_bin **bins;
00085     struct st_bin all_entries;
00086     char_map_t index_map, fold_map;
00087 } search_table_t;
00088 
00089 
00090 struct query_hashvec;
00091 
00092 size_t match_map_string(char_map_t map, gchar *string);
00093 
00094 void st_initialize(search_table_t *, char_map_t);
00095 void st_create(search_table_t *table);
00096 void st_destroy(search_table_t *);
00097 void st_insert_item(search_table_t *, const gchar *, struct shared_file *);
00098 void st_compact(search_table_t *);
00099 
00100 struct shared_file;
00101 
00108 typedef void (*st_search_callback)(gpointer ctx, struct shared_file *sf);
00109 
00110 void st_search(
00111     search_table_t *table,
00112     gchar *search,
00113     st_search_callback callback,
00114     gpointer ctx,
00115     gint max_res,
00116     struct query_hashvec *qhv);
00117 
00118 #endif  /* _core_matching_h_ */
00119 
00120 /* vi: set ts=4 sw=4 cindent: */

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