version 1.1, 2016/07/19 21:31:55 |
version 1.6, 2023/04/28 19:11:03 |
|
|
/* $Id$ */ |
/* $Id$ */ |
/* |
/* |
* Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> |
* Copyright (c) 2016 Ingo Schwarze <schwarze@openbsd.org> |
* |
* |
|
|
* Function to read the mandoc database from disk into RAM, |
* Function to read the mandoc database from disk into RAM, |
* such that data can be added or removed. |
* such that data can be added or removed. |
* The interface is defined in "dba.h". |
* The interface is defined in "dba.h". |
* This file is seperate from dba.c because this also uses "dbm.h". |
* This file is separate from dba.c because this also uses "dbm.h". |
*/ |
*/ |
|
#include "config.h" |
|
|
#include <regex.h> |
#include <regex.h> |
#include <stdint.h> |
#include <stdint.h> |
#include <stdlib.h> |
#include <stdlib.h> |
Line 45 dba_read(const char *fname) |
|
Line 47 dba_read(const char *fname) |
|
if (dbm_open(fname) == -1) |
if (dbm_open(fname) == -1) |
return NULL; |
return NULL; |
npages = dbm_page_count(); |
npages = dbm_page_count(); |
dba = dba_new(npages); |
dba = dba_new(npages < 128 ? 128 : npages); |
for (ip = 0; ip < npages; ip++) { |
for (ip = 0; ip < npages; ip++) { |
pdata = dbm_page_get(ip); |
pdata = dbm_page_get(ip); |
page = dba_page_new(dba->pages, pdata->name, pdata->sect, |
page = dba_page_new(dba->pages, pdata->arch, |
pdata->arch, pdata->desc, pdata->file + 1, *pdata->file); |
pdata->desc, pdata->file + 1, *pdata->file); |
cp = pdata->name; |
for (cp = pdata->name; *cp != '\0'; cp = strchr(cp, '\0') + 1) |
while (*(cp = strchr(cp, '\0') + 1) != '\0') |
|
dba_page_add(page, DBP_NAME, cp); |
dba_page_add(page, DBP_NAME, cp); |
cp = pdata->sect; |
for (cp = pdata->sect; *cp != '\0'; cp = strchr(cp, '\0') + 1) |
while (*(cp = strchr(cp, '\0') + 1) != '\0') |
|
dba_page_add(page, DBP_SECT, cp); |
dba_page_add(page, DBP_SECT, cp); |
if ((cp = pdata->arch) != NULL) |
if ((cp = pdata->arch) != NULL) |
while (*(cp = strchr(cp, '\0') + 1) != '\0') |
while (*(cp = strchr(cp, '\0') + 1) != '\0') |