source: gsdl/trunk/src/recpt/argdb.cpp@ 15653

Last change on this file since 15653 was 15653, checked in by mdewsnip, 16 years ago

Ooops, accidently committed a change I shouldn't have.

  • Property svn:keywords set to Author Date Id Revision
File size: 2.3 KB
Line 
1/**********************************************************************
2 *
3 * argdb.cpp --
4 * Copyright (C) 2001 The New Zealand Digital Library Project
5 *
6 * A component of the Greenstone digital library software
7 * from the New Zealand Digital Library Project at the
8 * University of Waikato, New Zealand.
9 *
10 * This program is free software; you can redistribute it and/or modify
11 * it under the terms of the GNU General Public License as published by
12 * the Free Software Foundation; either version 2 of the License, or
13 * (at your option) any later version.
14 *
15 * This program is distributed in the hope that it will be useful,
16 * but WITHOUT ANY WARRANTY; without even the implied warranty of
17 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18 * GNU General Public License for more details.
19 *
20 * You should have received a copy of the GNU General Public License
21 * along with this program; if not, write to the Free Software
22 * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
23 *
24 *********************************************************************/
25
26#include "gsdl_modules_cfg.h"
27#ifdef GSDL_USE_COLLECTOR_ACTION
28
29// argdb is used by the collector for storing cgi arguments on disk (in a
30// gdbm database)
31
32#include "argdb.h"
33#include "gdbmclass.h"
34
35argdb::argdb (const text_t &filename) {
36 dbfile = filename;
37}
38
39bool argdb::update_args (text_tmap &argmap) {
40 gdbmclass argdb;
41 if (!argdb.opendatabase(dbfile, DB_WRITER_CREATE, 1000, true)) return false;
42 infodbclass info;
43
44 argdb.getinfo("savedargs", info);
45
46 text_tmap::iterator here = argmap.begin();
47 text_tmap::iterator end = argmap.end();
48 while (here != end) {
49 if (!(*here).second.empty()) {
50 info.setinfo((*here).first, (*here).second);
51 }
52 ++here;
53 }
54
55 bool rv = argdb.setinfo ("savedargs", info);
56 argdb.closedatabase();
57 return rv;
58}
59
60bool argdb::get_args (text_tmap &argmap) {
61 argmap.erase(argmap.begin(), argmap.end());
62 gdbmclass argdb;
63 if (!argdb.opendatabase(dbfile, DB_READER, 1000, true)) return false;
64 infodbclass info;
65
66 if (!argdb.getinfo("savedargs", info)) return false;
67
68 infodbclass::const_iterator here = info.begin();
69 infodbclass::const_iterator end = info.end();
70 while (here != end) {
71 argmap[(*here).first] = info[(*here).first];
72 ++here;
73 }
74 argdb.closedatabase();
75 return true;
76}
77
78#endif //GSDL_USE_COLLECTOR_ACTION
Note: See TracBrowser for help on using the repository browser.