From: mdw Date: Mon, 6 Feb 2006 18:28:12 +0000 (+0000) Subject: cdb-map: New program to construct CDB files. X-Git-Tag: 1.2.0~16 X-Git-Url: http://www.chiark.greenend.org.uk/ucgi/~mdw/git/misc/commitdiff_plain/45c67ac4941a3c662428776c6ff4407bace5bc2e cdb-map: New program to construct CDB files. --- diff --git a/Makefile b/Makefile index 8137f86..30921f5 100644 --- 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 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 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, diff --git a/debian/inst b/debian/inst index 9229323..bbdbbe4 100644 --- a/debian/inst +++ b/debian/inst @@ -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