version 1.1, 2016/07/19 21:31:55 |
version 1.5, 2016/08/30 21:37:24 |
|
|
* of the mandoc database, for read-only access. |
* of the mandoc database, for read-only access. |
* The interface is defined in "dbm_map.h". |
* The interface is defined in "dbm_map.h". |
*/ |
*/ |
|
#include "config.h" |
|
|
#include <sys/mman.h> |
#include <sys/mman.h> |
#include <sys/stat.h> |
#include <sys/stat.h> |
#include <sys/types.h> |
#include <sys/types.h> |
|
|
|
#if HAVE_ENDIAN |
#include <endian.h> |
#include <endian.h> |
|
#elif HAVE_SYS_ENDIAN |
|
#include <sys/endian.h> |
|
#elif HAVE_NTOHL |
|
#include <arpa/inet.h> |
|
#endif |
|
#if HAVE_ERR |
#include <err.h> |
#include <err.h> |
|
#endif |
#include <errno.h> |
#include <errno.h> |
#include <fcntl.h> |
#include <fcntl.h> |
#include <regex.h> |
#include <regex.h> |
Line 70 dbm_map(const char *fname) |
|
Line 80 dbm_map(const char *fname) |
|
goto fail; |
goto fail; |
magic = dbm_getint(0); |
magic = dbm_getint(0); |
if (be32toh(*magic) != MANDOCDB_MAGIC) { |
if (be32toh(*magic) != MANDOCDB_MAGIC) { |
warnx("dbm_map(%s): Bad initial magic %x (expected %x)", |
if (strncmp(dbm_base, "SQLite format 3", 15)) |
fname, be32toh(*magic), MANDOCDB_MAGIC); |
warnx("dbm_map(%s): " |
|
"Bad initial magic %x (expected %x)", |
|
fname, be32toh(*magic), MANDOCDB_MAGIC); |
|
else |
|
warnx("dbm_map(%s): " |
|
"Obsolete format based on SQLite 3", |
|
fname); |
errno = EFTYPE; |
errno = EFTYPE; |
goto fail; |
goto fail; |
} |
} |
|
|
dbm_get(int32_t offset) |
dbm_get(int32_t offset) |
{ |
{ |
offset = be32toh(offset); |
offset = be32toh(offset); |
if (offset < 0 || offset >= max_offset) { |
if (offset < 0) { |
|
warnx("dbm_get: Database corrupt: offset %d", offset); |
|
return NULL; |
|
} |
|
if (offset >= max_offset) { |
warnx("dbm_get: Database corrupt: offset %d > %d", |
warnx("dbm_get: Database corrupt: offset %d > %d", |
offset, max_offset); |
offset, max_offset); |
return NULL; |
return NULL; |