summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorKristaps Dzonsons <kristaps@bsd.lv>2011-12-01 23:55:58 +0000
committerKristaps Dzonsons <kristaps@bsd.lv>2011-12-01 23:55:58 +0000
commita6c0706435e0555aa583406662a52bc89aa8c926 (patch)
tree8354174d00ae6f669e835e6d8f1a8f9f2e356a9d
parentb5a2d4f1d9120dceef2ae2f4a15c51f742aa5b13 (diff)
downloadmandoc-a6c0706435e0555aa583406662a52bc89aa8c926.tar.gz
Use OpenBSD's endian functions. Make btree type also be endian-neutral.
-rw-r--r--apropos_db.c6
-rw-r--r--mandocdb.c8
2 files changed, 5 insertions, 9 deletions
diff --git a/apropos_db.c b/apropos_db.c
index 41311ca6..6621a1a1 100644
--- a/apropos_db.c
+++ b/apropos_db.c
@@ -24,8 +24,6 @@
#include <string.h>
#include <unistd.h>
-#include <arpa/inet.h>
-
#ifdef __linux__
# include <db_185.h>
#else
@@ -177,8 +175,8 @@ btree_read(const DBT *k, const DBT *v,
vp = v->data;
norm_string((const char *)k->data, mc, buf);
- dbv->rec = ntohl(vp->rec);
- dbv->mask = vp->mask;
+ dbv->rec = betoh32(vp->rec);
+ dbv->mask = betoh64(vp->mask);
return(1);
}
diff --git a/mandocdb.c b/mandocdb.c
index 99b6aadc..66703f23 100644
--- a/mandocdb.c
+++ b/mandocdb.c
@@ -33,8 +33,6 @@
#include <string.h>
#include <unistd.h>
-#include <arpa/inet.h>
-
#ifdef __linux__
# include <db_185.h>
#else
@@ -628,11 +626,11 @@ index_merge(const struct of *of, struct mparse *mp,
* into the database.
*/
- vbuf.rec = htonl(rec);
+ vbuf.rec = htobe32(rec);
seq = R_FIRST;
while (0 == (ch = (*hash->seq)(hash, &key, &val, seq))) {
seq = R_NEXT;
- vbuf.mask = *(uint64_t *)val.data;
+ vbuf.mask = htobe64(*(uint64_t *)val.data);
val.size = sizeof(struct db_val);
val.data = &vbuf;
dbt_put(db, dbf, &key, &val);
@@ -732,7 +730,7 @@ index_prune(const struct of *ofile, DB *db, const char *dbf,
break;
vbuf = val.data;
- if (*maxrec != ntohl(vbuf->rec))
+ if (*maxrec != betoh32(vbuf->rec))
continue;
if ((ch = (*db->del)(db, &key, R_CURSOR)) < 0)