| 316 | */ |
| 317 | |
| 318 | int /* O - Number of matches */ |
| 319 | cgiDoSearch(void *search, /* I - Search context */ |
| 320 | const char *text) /* I - Text to search */ |
| 321 | { |
| 322 | int i; /* Looping var */ |
| 323 | regmatch_t matches[100]; /* RE matches */ |
| 324 | |
| 325 | |
| 326 | /* |
| 327 | * Range check... |
| 328 | */ |
| 329 | |
| 330 | if (!search || !text) |
| 331 | return (0); |
| 332 | |
| 333 | /* |
| 334 | * Do a lookup... |
| 335 | */ |
| 336 | |
| 337 | if (!regexec((regex_t *)search, text, sizeof(matches) / sizeof(matches[0]), |
| 338 | matches, 0)) |
| 339 | { |
| 340 | /* |
| 341 | * Figure out the number of matches in the string... |
| 342 | */ |
| 343 | |
| 344 | for (i = 0; i < (int)(sizeof(matches) / sizeof(matches[0])); i ++) |
| 345 | if (matches[i].rm_so < 0) |
| 346 | break; |
| 347 | |
| 348 | return (i); |
| 349 | } |
| 350 | else |
| 351 | return (0); |
| 352 | } |
| 353 | |
| 354 | |
| 355 | /* |
no test coverage detected