89 int mid = (top + bot) / 2;
90 uschar *entry = nametable + entrysize*mid;
91 int c = strcmp(stringname, (
char *)(entry + 2));
92 if (c == 0)
return (entry[0] << 8) + entry[1];
93 if (c > 0) bot = mid + 1;
else top = mid;
120 char **firstptr,
char **lastptr)
125 uschar *nametable, *lastentry;
136 lastentry = nametable + entrysize * (top - 1);
140 int mid = (top + bot) / 2;
141 uschar *entry = nametable + entrysize*mid;
142 int c = strcmp(stringname, (
char *)(entry + 2));
147 while (first > nametable)
149 if (strcmp(stringname, (
char *)(first - entrysize + 2)) != 0)
break;
152 while (last < lastentry)
154 if (strcmp(stringname, (
char *)(last + entrysize + 2)) != 0)
break;
157 *firstptr = (
char *)first;
158 *lastptr = (
char *)last;
161 if (c > 0) bot = mid + 1;
else top = mid;
187 get_first_set(
const pcre *code,
const char *stringname,
int *ovector)
196 if (entrysize <= 0)
return entrysize;
197 for (entry = (
uschar *)first; entry <= (
uschar *)last; entry += entrysize)
199 int n = (entry[0] << 8) + entry[1];
200 if (ovector[n*2] >= 0)
return n;
202 return (first[0] << 8) + first[1];
237 int stringnumber,
char *buffer,
int size)
240 if (stringnumber < 0 || stringnumber >= stringcount)
243 yield = ovector[stringnumber+1] - ovector[stringnumber];
245 memcpy(buffer, subject + ovector[stringnumber], yield);
282 int stringcount,
const char *stringname,
char *buffer,
int size)
284 int n = get_first_set(code, stringname, ovector);
285 if (n <= 0)
return n;
314 const char ***listptr)
317 int size =
sizeof(
char *);
318 int double_count = stringcount * 2;
322 for (i = 0; i < double_count; i += 2)
323 size +=
sizeof(
char *) + ovector[i+1] - ovector[i] + 1;
328 *listptr = (
const char **)stringlist;
329 p = (
char *)(stringlist + stringcount + 1);
331 for (i = 0; i < double_count; i += 2)
333 int len = ovector[i+1] - ovector[i];
334 memcpy(p, subject + ovector[i], len);
392 int stringnumber,
const char **stringptr)
396 if (stringnumber < 0 || stringnumber >= stringcount)
399 yield = ovector[stringnumber+1] - ovector[stringnumber];
402 memcpy(substring, subject + ovector[stringnumber], yield);
403 substring[yield] = 0;
404 *stringptr = substring;
439 int stringcount,
const char *stringname,
const char **stringptr)
441 int n = get_first_set(code, stringname, ovector);
442 if (n <= 0)
return n;