-static struct expr *exprspec(struct expr *, uint64_t,
- const char *, const char *);
-static struct expr *exprterm(const struct mansearch *, char *, int);
-static void sql_append(char **sql, size_t *sz,
- const char *newstr, int count);
-static void sql_match(sqlite3_context *context,
- int argc, sqlite3_value **argv);
-static void sql_regexp(sqlite3_context *context,
- int argc, sqlite3_value **argv);
-static char *sql_statement(const struct expr *);
-
-
-int
-mansearch_setup(int start)
-{
- static void *pagecache;
- int c;
-
-#define PC_PAGESIZE 1280
-#define PC_NUMPAGES 256
-
- if (start) {
- if (NULL != pagecache) {
- fprintf(stderr, "pagecache already enabled\n");
- return((int)MANDOCLEVEL_BADARG);
- }
-
- pagecache = mmap(NULL, PC_PAGESIZE * PC_NUMPAGES,
- PROT_READ | PROT_WRITE, MAP_ANON, -1, 0);
-
- if (MAP_FAILED == pagecache) {
- perror("mmap");
- pagecache = NULL;
- return((int)MANDOCLEVEL_SYSERR);
- }
-
- c = sqlite3_config(SQLITE_CONFIG_PAGECACHE,
- pagecache, PC_PAGESIZE, PC_NUMPAGES);
-
- if (SQLITE_OK == c)
- return((int)MANDOCLEVEL_OK);
-
- fprintf(stderr, "pagecache: %s\n", sqlite3_errstr(c));
-
- } else if (NULL == pagecache) {
- fprintf(stderr, "pagecache missing\n");
- return((int)MANDOCLEVEL_BADARG);
- }
-
- if (-1 == munmap(pagecache, PC_PAGESIZE * PC_NUMPAGES)) {
- perror("munmap");
- pagecache = NULL;
- return((int)MANDOCLEVEL_SYSERR);
- }