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
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
00119
00120