e576bb2002-10-11Martin Nilsson /* || This file is part of Pike. For copyright information see COPYRIGHT. || Pike is distributed under GPL, LGPL and MPL. See the file COPYING || for more information.
ab6f442011-04-25Martin Stjernholm || $Id$
e576bb2002-10-11Martin Nilsson */
1b10db2002-10-08Martin Nilsson 
9b1f032000-10-09Fredrik Hübinette (Hubbe) #ifndef PIKE_SEARCH_H #define PIKE_SEARCH_H #define MEMSEARCH_LINKS 512 #define BMLEN 768 #define CHARS 256 #define TUNAFISH struct hubbe_search_link { struct hubbe_search_link *next;
ae0ca82000-10-10Henrik Grubbström (Grubba)  ptrdiff_t offset; INT32 key;
9b1f032000-10-09Fredrik Hübinette (Hubbe) }; struct hubbe_searcher { void *needle; ptrdiff_t needlelen;
ae0ca82000-10-10Henrik Grubbström (Grubba)  size_t hsize, max;
9b1f032000-10-09Fredrik Hübinette (Hubbe)  struct hubbe_search_link links[MEMSEARCH_LINKS]; struct hubbe_search_link *set[MEMSEARCH_LINKS]; }; struct boyer_moore_hubbe_searcher { void *needle; ptrdiff_t needlelen; ptrdiff_t plen; ptrdiff_t d1[CHARS+1]; ptrdiff_t d2[BMLEN]; }; struct SearchMojtS; #define FNORD(N,C) \ typedef C (* PIKE_CONCAT(SearchMojtFunc,N) )(void*, C, size_t) FNORD(0,p_wchar0 *); FNORD(1,p_wchar1 *); FNORD(2,p_wchar2 *); FNORD(N,PCHARP); struct SearchMojtVtable { SearchMojtFunc0 func0; SearchMojtFunc1 func1; SearchMojtFunc2 func2; SearchMojtFuncN funcN; }; typedef struct SearchMojt {
a630c22004-09-18Per Hedbor  const struct SearchMojtVtable *vtab;
9b1f032000-10-09Fredrik Hübinette (Hubbe)  void *data;
b6b7ee2008-06-23Martin Stjernholm  struct object *container; /* Refcounted if non-NULL. */
9b1f032000-10-09Fredrik Hübinette (Hubbe) } SearchMojt; struct pike_mem_searcher {
b6b7ee2008-06-23Martin Stjernholm  SearchMojt mojt; /* Exception: mojt.container not refcounted here. */
9b1f032000-10-09Fredrik Hübinette (Hubbe)  struct pike_string *s; /* search string */ union memsearcher_data { struct hubbe_searcher hubbe; struct boyer_moore_hubbe_searcher bm; } data; }; /* Prototypes begin here */ PMOD_EXPORT void pike_init_memsearch(struct pike_mem_searcher *s, PCHARP needle, ptrdiff_t needlelen, ptrdiff_t max_haystacklen);
4ee9222000-12-13Fredrik Hübinette (Hubbe) PMOD_EXPORT SearchMojt compile_memsearcher(PCHARP needle,
9b1f032000-10-09Fredrik Hübinette (Hubbe)  ptrdiff_t needlelen, int max_haystacklen, struct pike_string *hashkey);
4ee9222000-12-13Fredrik Hübinette (Hubbe) PMOD_EXPORT SearchMojt simple_compile_memsearcher(struct pike_string *str);
444ed22000-11-29Fredrik Hübinette (Hubbe) PMOD_EXPORT char *my_memmem(char *needle, size_t needlelen, char *haystack, size_t haystacklen);
9b1f032000-10-09Fredrik Hübinette (Hubbe) void init_pike_searching(void); void exit_pike_searching(void); /* Prototypes end here */ #endif