195 char *maxbuf = 0, *trybuf = 0, *key = 0, quitflag = 0;
196 signed char retval = 0;
197 SW_s32 headoff, tailoff, tryoff = 0, maxoff = 0;
200 bool awayFromSubstrCheck =
false;
209 int keylen = (int)strlen(key);
214 while (headoff < tailoff) {
220 if (!*trybuf && tryoff) {
226 diff = strcmp(key, trybuf);
231 if (!strncmp(trybuf, key, keylen)) substr =
true;
234 tailoff = (tryoff == headoff) ? headoff : tryoff;
235 else headoff = tryoff;
244 if (headoff >= tailoff) {
246 if (!substr && ((tryoff != maxoff)||(strncmp(key, maxbuf, keylen)<0))) {
247 awayFromSubstrCheck =
true;
262 retval = (
idxfd->
read(&start, 4) == 4) ? retval : -1;
263 retval = (
idxfd->
read(&size, 4) == 4) ? retval : -1;
277 if (((
long)(tryoff + (away*
IDXENTRYSIZE)) < -IDXENTRYSIZE) || (tryoff + (away*
IDXENTRYSIZE) > (maxoff+IDXENTRYSIZE)))
282 if(!awayFromSubstrCheck)
300 if (((laststart != start) || (lastsize != size)) && size)
301 away += (away < 0) ? 1 : -1;
long seek(long offset, int whence)
void getKeyFromIdxOffset(long ioffset, char **buf) const
char * toupperstr_utf8(char *t, unsigned int max=0)
SWORD_NAMESPACE_START char * stdstr(char **ipstr, const char *istr, unsigned int memPadFactor=1)
static const int IDXENTRYSIZE
long read(void *buf, long count)