version 1.2, 2016/07/20 00:23:14 |
version 1.7, 2019/07/01 22:56:24 |
|
|
#include "config.h" |
#include "config.h" |
|
|
#include <assert.h> |
#include <assert.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 |
#if HAVE_ERR |
#include <err.h> |
#include <err.h> |
#endif |
#endif |
Line 144 dbm_page_get(int32_t ip) |
|
Line 150 dbm_page_get(int32_t ip) |
|
assert(ip >= 0); |
assert(ip >= 0); |
assert(ip < npages); |
assert(ip < npages); |
res.name = dbm_get(pages[ip].name); |
res.name = dbm_get(pages[ip].name); |
|
if (res.name == NULL) |
|
res.name = "(NULL)\0"; |
res.sect = dbm_get(pages[ip].sect); |
res.sect = dbm_get(pages[ip].sect); |
|
if (res.sect == NULL) |
|
res.sect = "(NULL)\0"; |
res.arch = pages[ip].arch ? dbm_get(pages[ip].arch) : NULL; |
res.arch = pages[ip].arch ? dbm_get(pages[ip].arch) : NULL; |
res.desc = dbm_get(pages[ip].desc); |
res.desc = dbm_get(pages[ip].desc); |
|
if (res.desc == NULL) |
|
res.desc = "(NULL)"; |
res.file = dbm_get(pages[ip].file); |
res.file = dbm_get(pages[ip].file); |
|
if (res.file == NULL) |
|
res.file = " (NULL)\0"; |
res.addr = dbm_addr(pages + ip); |
res.addr = dbm_addr(pages + ip); |
return &res; |
return &res; |
} |
} |
Line 219 static struct dbm_res |
|
Line 233 static struct dbm_res |
|
page_bytitle(enum iter arg_iter, const struct dbm_match *arg_match) |
page_bytitle(enum iter arg_iter, const struct dbm_match *arg_match) |
{ |
{ |
static const struct dbm_match *match; |
static const struct dbm_match *match; |
static const char *cp; |
static const char *cp; |
static int32_t ip; |
static int32_t ip; |
struct dbm_res res = {-1, 0}; |
struct dbm_res res = {-1, 0}; |
|
|
Line 244 page_bytitle(enum iter arg_iter, const struct dbm_matc |
|
Line 258 page_bytitle(enum iter arg_iter, const struct dbm_matc |
|
default: |
default: |
abort(); |
abort(); |
} |
} |
ip = 0; |
if (cp == NULL) { |
|
iteration = ITER_NONE; |
|
match = NULL; |
|
cp = NULL; |
|
ip = npages; |
|
} else |
|
ip = 0; |
return res; |
return res; |
} |
} |
|
|
Line 295 page_byarch(const struct dbm_match *arg_match) |
|
Line 315 page_byarch(const struct dbm_match *arg_match) |
|
static const struct dbm_match *match; |
static const struct dbm_match *match; |
struct dbm_res res = {-1, 0}; |
struct dbm_res res = {-1, 0}; |
static int32_t ip; |
static int32_t ip; |
const char *cp; |
const char *cp; |
|
|
/* Initialize for a new iteration. */ |
/* Initialize for a new iteration. */ |
|
|
Line 326 page_byarch(const struct dbm_match *arg_match) |
|
Line 346 page_byarch(const struct dbm_match *arg_match) |
|
} |
} |
|
|
static struct dbm_res |
static struct dbm_res |
page_bymacro(int32_t im, const struct dbm_match *match) |
page_bymacro(int32_t arg_im, const struct dbm_match *arg_match) |
{ |
{ |
static const int32_t *pp; |
static const struct dbm_match *match; |
struct dbm_res res = {-1, 0}; |
static const int32_t *pp; |
const char *cp; |
static const char *cp; |
int32_t iv; |
static int32_t im, iv; |
|
struct dbm_res res = {-1, 0}; |
|
|
assert(im >= 0); |
assert(im >= 0); |
assert(im < MACRO_MAX); |
assert(im < MACRO_MAX); |
|
|
/* Initialize for a new iteration. */ |
/* Initialize for a new iteration. */ |
|
|
if (match != NULL) { |
if (arg_match != NULL) { |
iteration = ITER_MACRO; |
iteration = ITER_MACRO; |
|
match = arg_match; |
|
im = arg_im; |
cp = nvals[im] ? dbm_get(macros[im]->value) : NULL; |
cp = nvals[im] ? dbm_get(macros[im]->value) : NULL; |
for (iv = 0; iv < nvals[im]; iv++) { |
pp = NULL; |
if (dbm_match(match, cp)) |
iv = -1; |
break; |
|
cp = strchr(cp, '\0') + 1; |
|
} |
|
pp = iv == nvals[im] ? NULL : dbm_get(macros[im][iv].pages); |
|
return res; |
return res; |
} |
} |
if (iteration != ITER_MACRO) |
if (iteration != ITER_MACRO) |
return res; |
return res; |
|
|
/* No more matches. */ |
/* Find the next matching macro value. */ |
|
|
if (pp == NULL || *pp == 0) { |
while (pp == NULL || *pp == 0) { |
iteration = ITER_NONE; |
if (++iv == nvals[im]) { |
pp = NULL; |
iteration = ITER_NONE; |
return res; |
return res; |
|
} |
|
if (iv) |
|
cp = strchr(cp, '\0') + 1; |
|
if (dbm_match(match, cp)) |
|
pp = dbm_get(macros[im][iv].pages); |
} |
} |
|
|
/* Found a match. */ |
/* Found a matching page. */ |
|
|
res.page = (struct page *)dbm_get(*pp++) - pages; |
res.page = (struct page *)dbm_get(*pp++) - pages; |
return res; |
return res; |