Add -b and -l options to generate big- or little-endian databases

regardless of host byte order.
This commit is contained in:
simonb 1999-06-27 05:49:02 +00:00
parent 3365b567da
commit a1997f6cbe
2 changed files with 28 additions and 6 deletions

View File

@ -1,4 +1,4 @@
.\" $NetBSD: cap_mkdb.1,v 1.7 1997/10/18 12:31:01 lukem Exp $
.\" $NetBSD: cap_mkdb.1,v 1.8 1999/06/27 05:49:02 simonb Exp $
.\"
.\" Copyright (c) 1992, 1993
.\" The Regents of the University of California. All rights reserved.
@ -42,6 +42,7 @@
.Pp
.Sh SYNOPSIS
.Nm
.Op Fl b | Fl l
.Op Fl v
.Op Fl f Ar outfile
.Ar file1
@ -67,12 +68,23 @@ record is stored into the database.
.Pp
The options as as follows:
.Bl -tag -width XXXXXX -indent
.It Fl b
Use big-endian byte order for database metadata.
.It Fl f Ar outfile
Specify a different database basename.
.It Fl l
Use little-endian byte order for database metadata.
.It Fl v
Print out the number of capability records in the database.
.El
.Pp
The
.Fl b
and the
.Fl l
flags are mutually exclusive. The default byte ordering is
the current host order.
.Pp
.Sh FORMAT
Each record is stored in the database using two different types of keys.
.Pp

View File

@ -1,4 +1,4 @@
/* $NetBSD: cap_mkdb.c,v 1.9 1998/07/28 19:27:00 mycroft Exp $ */
/* $NetBSD: cap_mkdb.c,v 1.10 1999/06/27 05:49:02 simonb Exp $ */
/*-
* Copyright (c) 1992, 1993
@ -43,7 +43,7 @@ __COPYRIGHT("@(#) Copyright (c) 1992, 1993\n\
#if 0
static char sccsid[] = "@(#)cap_mkdb.c 8.2 (Berkeley) 4/27/95";
#endif
__RCSID("$NetBSD: cap_mkdb.c,v 1.9 1998/07/28 19:27:00 mycroft Exp $");
__RCSID("$NetBSD: cap_mkdb.c,v 1.10 1999/06/27 05:49:02 simonb Exp $");
#endif /* not lint */
#include <sys/param.h>
@ -89,11 +89,18 @@ main(argc, argv)
int argc;
char *argv[];
{
int c;
int c, byteorder;
capname = NULL;
while ((c = getopt(argc, argv, "f:v")) != -1) {
byteorder = 0;
while ((c = getopt(argc, argv, "bf:lv")) != -1) {
switch(c) {
case 'b':
case 'l':
if (byteorder != 0)
usage();
byteorder = c == 'b' ? 4321 : 1234;
break;
case 'f':
capname = optarg;
break;
@ -111,6 +118,9 @@ main(argc, argv)
if (*argv == NULL)
usage();
/* Set byte order */
openinfo.lorder = byteorder;
/*
* The database file is the first argument if no name is specified.
* Make arrangements to unlink it if exit badly.
@ -260,6 +270,6 @@ void
usage()
{
(void)fprintf(stderr,
"usage: cap_mkdb [-v] [-f outfile] file1 [file2 ...]\n");
"usage: cap_mkdb [-b|-l] [-v] [-f outfile] file1 [file2 ...]\n");
exit(1);
}