Re: Make and Edit database
[email protected] (Paul Jarc) Thu, 10 Jul 2003 17:53:06 -0400
| Newsgroups | gmane.comp.djb.cdb |
|---|---|
| Organization | What did you have in mind? A short, blunt, human pyramid? |
| Message-ID | <[email protected]> |
Ben Ferderer <[email protected]> wrote: > However it is all going over my head on how to simple make a database > and edit and existing one. Strictly speaking, you can't edit an existing database (the "c" is for "constant"); instead, you replace the database with a new one. If you want to write your own C code using the cdb library, read <URL:http://cr.yp.to/cdb/reading.html>. If you want to use the standard cdb programs from a script, read <URL:http://cr.yp.to/cdb/cdbmake.html> and <URL:http://cr.yp.to/cdb/cdbget.html>. Example: $ cat passwd.in +4,8:b1ff->p455w0rd $ cdbmake < passwd.in passwd.cdb passwd.cdb.tmp $ cdbget b1ff < passwd.cdb; echo p455w0rd $ cdbdump < passwd.cdb +4,8:b1ff->p455w0rd $ Edit passwd.in however you like, and then run cdbmake when you're ready to update the database. The input format is a bit hard to edit by hand, since you have to get the lengths right. You may find it more convenient to edit a file containing lines like "b1ff:p455w0rd", and then use a Perl script or whatever to produce "+4,8:b1ff->p455w0rd" from that. Remember that cdbmake's input must end with an empty line. paul