-static void buildnames(struct manpage *, sqlite3 *,
- sqlite3_stmt *, uint64_t,
- const char *, int form);
-static char *buildoutput(sqlite3 *, sqlite3_stmt *,
- uint64_t, uint64_t);
-static void *hash_alloc(size_t, void *);
-static void hash_free(void *, size_t, void *);
-static void *hash_halloc(size_t, void *);
-static struct expr *exprcomp(const struct mansearch *,
- int, char *[]);
-static void exprfree(struct expr *);
-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));