Main Page | Class List | Directories | File List | Class Members | File Members

pike_search.h

Go to the documentation of this file.
00001 /*
00002 || This file is part of Pike. For copyright information see COPYRIGHT.
00003 || Pike is distributed under GPL, LGPL and MPL. See the file COPYING
00004 || for more information.
00005 || $Id: pike_search.h,v 1.9 2004/09/18 20:19:15 per Exp $
00006 */
00007 
00008 #ifndef PIKE_SEARCH_H
00009 #define PIKE_SEARCH_H
00010 
00011 #define MEMSEARCH_LINKS 512
00012 #define BMLEN 768
00013 #define CHARS 256
00014 #define TUNAFISH
00015 
00016 struct hubbe_search_link
00017 {
00018   struct hubbe_search_link *next;
00019   ptrdiff_t offset;
00020   INT32 key;
00021 };
00022 
00023 struct hubbe_searcher
00024 {
00025   struct object *o; /* must be first */
00026   void *needle;
00027   ptrdiff_t needlelen;
00028 
00029   size_t hsize, max;
00030   struct hubbe_search_link links[MEMSEARCH_LINKS];
00031   struct hubbe_search_link *set[MEMSEARCH_LINKS];
00032 };
00033 
00034 struct boyer_moore_hubbe_searcher
00035 {
00036   struct object *o; /* must be first */
00037   void *needle;
00038   ptrdiff_t needlelen;
00039 
00040   ptrdiff_t plen;
00041   ptrdiff_t d1[CHARS+1];
00042   ptrdiff_t d2[BMLEN];
00043 };
00044 
00045 struct SearchMojtS;
00046 
00047 #define FNORD(N,C) \
00048 typedef C (* PIKE_CONCAT(SearchMojtFunc,N) )(void*, C, size_t)
00049 
00050 
00051 FNORD(0,p_wchar0 *);
00052 FNORD(1,p_wchar1 *);
00053 FNORD(2,p_wchar2 *);
00054 FNORD(N,PCHARP);
00055 
00056 struct SearchMojtVtable
00057 {
00058   SearchMojtFunc0 func0;
00059   SearchMojtFunc1 func1;
00060   SearchMojtFunc2 func2;
00061   SearchMojtFuncN funcN;
00062   void (*freeme)(void *);
00063 };
00064 
00065 typedef struct SearchMojt
00066 {
00067   const struct SearchMojtVtable *vtab;
00068   void *data;
00069 } SearchMojt;
00070 
00071 struct pike_mem_searcher
00072 {
00073   SearchMojt mojt;
00074   struct pike_string *s; /* search string */
00075   union memsearcher_data
00076   {
00077     struct hubbe_searcher hubbe;
00078     struct boyer_moore_hubbe_searcher bm;
00079   } data;
00080 };
00081 
00082 
00083 /* Prototypes begin here */
00084 PMOD_EXPORT void pike_init_memsearch(struct pike_mem_searcher *s,
00085                                      PCHARP needle,
00086                                      ptrdiff_t needlelen,
00087                                      ptrdiff_t max_haystacklen);
00088 PMOD_EXPORT SearchMojt compile_memsearcher(PCHARP needle,
00089                                ptrdiff_t needlelen,
00090                                int max_haystacklen,
00091                                struct pike_string *hashkey);
00092 PMOD_EXPORT SearchMojt simple_compile_memsearcher(struct pike_string *str);
00093 PMOD_EXPORT char *my_memmem(char *needle,
00094                             size_t needlelen,
00095                             char *haystack,
00096                             size_t haystacklen);
00097 void init_pike_searching(void);
00098 void exit_pike_searching(void);
00099 /* Prototypes end here */
00100 
00101 #endif

Generated on Fri Jul 22 23:44:26 2005 for Pike by  doxygen 1.3.9.1