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

Last change on this file since 3036 was 2368, checked in by sjboddie, 23 years ago

Many cgi arguments used by the collector are now stored in a gdbm database
on disk instead of being passed about in the url. This was done to prevent
specific url length problems in some situations when using the collector.
Since the same problem could potentially surface within other parts of
Greenstone we should probably look at a similar but more general solution
to be used throughout Greenstone. I'll leave that for another day though
:-)

  • Property svn:keywords set to Author Date Id Revision
File size: 2.2 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// argdb is used by the collector for storing cgi arguments on disk (in a
27// gdbm database)
28
29#include "argdb.h"
30
31argdb::argdb (const text_t &filename) {
32 dbfile = filename;
33}
34
35bool argdb::update_args (text_tmap &argmap) {
36 gdbmclass argdb;
37 if (!argdb.opendatabase(dbfile, GDBM_WRCREAT, 1000, true)) return false;
38 infodbclass info;
39
40 argdb.getinfo("savedargs", info);
41
42 text_tmap::iterator here = argmap.begin();
43 text_tmap::iterator end = argmap.end();
44 while (here != end) {
45 if (!(*here).second.empty()) {
46 info.setinfo((*here).first, (*here).second);
47 }
48 here ++;
49 }
50
51 bool rv = argdb.setinfo ("savedargs", info);
52 argdb.closedatabase();
53 return rv;
54}
55
56bool argdb::get_args (text_tmap &argmap) {
57 argmap.erase(argmap.begin(), argmap.end());
58 gdbmclass argdb;
59 if (!argdb.opendatabase(dbfile, GDBM_READER, 1000, true)) return false;
60 infodbclass info;
61
62 if (!argdb.getinfo("savedargs", info)) return false;
63
64 infodbclass::const_iterator here = info.begin();
65 infodbclass::const_iterator end = info.end();
66 while (here != end) {
67 argmap[(*here).first] = info[(*here).first];
68 here ++;
69 }
70 argdb.closedatabase();
71 return true;
72}
Note: See TracBrowser for help on using the repository browser.