summaryrefslogtreecommitdiff
path: root/src/hdb/hdbcvt.cc
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@euromail.se>2011-10-08 20:30:28 +0200
committerHenrik Rydberg <rydberg@euromail.se>2011-10-08 20:30:28 +0200
commit5df79c53745fde5d6c3340a2979b1429cd5892c1 (patch)
tree1a81af141708b826e9c61e8a04019994fcca8298 /src/hdb/hdbcvt.cc
Initial import of htcd system 1.0
Signed-off-by: Henrik Rydberg <rydberg@euromail.se>
Diffstat (limited to 'src/hdb/hdbcvt.cc')
-rw-r--r--src/hdb/hdbcvt.cc50
1 files changed, 50 insertions, 0 deletions
diff --git a/src/hdb/hdbcvt.cc b/src/hdb/hdbcvt.cc
new file mode 100644
index 0000000..ece70f0
--- /dev/null
+++ b/src/hdb/hdbcvt.cc
@@ -0,0 +1,50 @@
1/*************************************************************************
2 *
3 * HTCd - Copyright (C) 1998-2006 Henrik Rydberg
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License
16 * along with this program; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
18 */
19
20#include <hdb/db.h>
21#include <mt/lock.h>
22
23static fp_stream mout(stdout),merr(stderr);
24
25main(int argc,char* argv[]) throw(merror_t) try
26{
27 if(argc<2) {
28 merr<<"Usage: "<<argv[0]<<" <db> [<index> <cp>]\n";
29 return -1;
30 }
31 mstring newfile=argv[1];
32 mstring oldfile=newfile+sref(".bak");
33 rename(newfile.c_str(),oldfile.c_str());
34 dbmap db;
35 try {
36 db.Open(oldfile);
37 if(argc>3) db.Sort(sref(argv[2]),sref(argv[3]));
38 db.Saveas(newfile);
39 }
40 catch(const merror_t& e) {
41 merr<<"Opened as newfile, old version\n";
42 db.Open(newfile,1);
43 Convert(db,oldfile.c_str());
44 }
45 return 0;
46}
47catch(const merror_t& e) {
48 merr<<e.desc<<"\n";
49 return -1;
50}