HL_PRIM int hl_bytes_find( vbyte *where, int pos, int len, vbyte *which, int wpos, int wlen ) { size_t searchbuf [256]; bool repeat_find = false; vbyte *found = (vbyte*)memfind_rb(where + pos,len,which+wpos,wlen,searchbuf,&repeat_find); if( found == NULL ) return -1; return (int)(size_t)(found - where); }
char * strfind (const char *string, /* String containing data */ const char *pattern, /* Pattern to search for */ Bool repeat_find) /* Same pattern as last time */ { static size_t searchbuf [256]; /* Fixed search buffer */ ASSERT (string); /* Expect non-NULL pointers, but */ ASSERT (pattern); /* fall through if not debugging */ return (char *) memfind_rb (string, strlen (string), pattern, strlen (pattern), searchbuf, &repeat_find); }
char * strfind_rb (const char *string, /* String containing data */ const char *pattern, /* Pattern to search for */ size_t *shift, /* Working buffer between searches */ Bool *repeat_find) /* Flag for first/later search */ { ASSERT (string); /* Expect non-NULL pointers, but */ ASSERT (pattern); /* fall through if not debugging */ ASSERT (shift); ASSERT (repeat_find); return (char *) memfind_rb (string, strlen (string), pattern, strlen (pattern), shift, repeat_find); }
char * strfind_r (const char *string, /* String containing data */ const char *pattern) /* Pattern to search for */ { size_t searchbuf [256]; /* One-time search buffer */ Bool secondtime = FALSE; /* Search buffer init needed */ ASSERT (string); /* Expect non-NULL pointers, but */ ASSERT (pattern); /* fall through if not debugging */ return (char *) memfind_rb (string, strlen (string), pattern, strlen (pattern), searchbuf, &secondtime); }
void * memfind (const void *block, /* Block containing data */ size_t block_size, /* Size of block in bytes */ const void *pattern, /* Pattern to search for */ size_t pattern_size, /* Size of pattern block */ Bool repeat_find) /* Same pattern as last time */ { static size_t searchbuf [256]; /* Static shared search buffer */ ASSERT (block); /* Expect non-NULL pointers, but */ ASSERT (pattern); /* full through if not debugging */ return memfind_rb (block, block_size, pattern, pattern_size, searchbuf, &repeat_find); }
void * memfind_r (const void *block, /* Block containing data */ size_t block_size, /* Size of block in bytes */ const void *pattern, /* Pattern to search for */ size_t pattern_size) /* Size of pattern block */ { size_t searchbuf [256]; /* One-time search buffer */ Bool secondtime = FALSE; ASSERT (block); /* Expect non-NULL pointers, but */ ASSERT (pattern); /* full through if not debugging */ return memfind_rb (block, block_size, pattern, pattern_size, searchbuf, &secondtime); }