chiark / gitweb /
cdb-map: New program to construct CDB files.
authormdw <mdw>
Mon, 6 Feb 2006 18:28:12 +0000 (18:28 +0000)
committermdw <mdw>
Mon, 6 Feb 2006 18:28:12 +0000 (18:28 +0000)
Makefile
cdb-map [new file with mode: 0644]
cdb-map.1 [new file with mode: 0644]
debian/inst

index 8137f868c1261a63545c6581d396e8b67d0ea1d3..30921f5811908bf7014b93a6a53cb0619fc7389d 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -6,7 +6,7 @@ PACKAGE = nsict-utils
 VERSION = 1.1.1
 
 BINSCRIPTS = \
-       cdb-assign cdb-list check-sender unfwd \
+       cdb-assign cdb-map cdb-list check-sender unfwd \
        splitconf z buf create inplace
 SBINSCRIPTS = shadowfix
 SCRIPTS = $(BINSCRIPTS) $(SBINSCRIPTS)
@@ -16,7 +16,8 @@ PROGS = $(BINPROGS) $(SBINPROGS)
 PERLLIBS = MdwOpt.pm
 LIBS = xtitle.so
 DISTMAN1 = \
-       not.1 z.1 cdb-assign.1 cdb-list.1 cdb-probe.1 cdb-check-domain.1 \
+       not.1 z.1 cdb-assign.1 cdb-map.1 cdb-list.1 cdb-probe.1 \
+               cdb-check-domain.1 \
        gorp.1 unfwd.1 splitconf.1 locking.1 if-mtu.1 pause.1 \
        buf.1 create.1 inplace.1
 MAN1 = $(DISTMAN1)
diff --git a/cdb-map b/cdb-map
new file mode 100644 (file)
index 0000000..71cdde0
--- /dev/null
+++ b/cdb-map
@@ -0,0 +1,14 @@
+#! /usr/bin/perl
+
+use CDB_File;
+
+@ARGV >= 1 or die "usage: $0 CDB [INPUT ...]\n";
+$f = shift;
+$c = CDB_File->new($f, "$f.new") or die "CDB_File->new: $!\n";
+while (<>) {
+  chomp;
+  m'^([^:]*):(.*)$' or die "bad assignment `$_'\n";
+  $c->insert($1, $2);
+}
+$c->finish() or die "CDB_File->finish: $!\n";
+exit 0;
diff --git a/cdb-map.1 b/cdb-map.1
new file mode 100644 (file)
index 0000000..41a9f58
--- /dev/null
+++ b/cdb-map.1
@@ -0,0 +1,30 @@
+.\" -*-nroff-*-
+.TH cdb-assign 1 "9 October 2003" "Straylight/Edgeware"
+.SH SYNOPSIS
+.B cdb-assign
+.I cdb
+.RI [ input ...]
+.SH DESCRIPTION
+Constructs a CDB file (see
+.BR cdbmake (1),
+.BR cdbget (1))
+from mappings in the
+.I input
+files (or stdin if there are none).
+.PP
+No comments or blank lines are allowed.  Lines must have the form
+.RI ` key \c
+.BR : \c
+.IR value '.
+Whitespace is preserved.  This is intended to be used with autogenerated
+files rather than human-written ones.
+.PP
+The CDB file is written to
+.IB cdb .new
+and renamed to
+.I cdb
+when it's finished.
+.SH BUGS
+None known.
+.SH AUTHOR
+Mark Wooding, <mdw@nsict.org>
index 92293231460b45fbf9bd22e93a1824eb89d47ff7..bbdbbe44f91a7c0b06e755cbf92a8fd4d337686d 100644 (file)
@@ -3,6 +3,8 @@ buf buf /usr/bin
 buf.1 buf /usr/share/man/man1
 cdb-assign nsict-cdb /usr/bin
 cdb-assign.1 nsict-cdb /usr/share/man/man1
+cdb-map nsict-cdb /usr/bin
+cdb-map.1 nsict-cdb /usr/share/man/man1
 cdb-check-domain nsict-cdb /usr/bin
 cdb-check-domain.1 nsict-cdb /usr/share/man/man1
 cdb-list nsict-cdb /usr/bin