2 * This file is part of PowerDNS or dnsdist.
3 * Copyright -- PowerDNS.COM B.V. and its contributors
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of version 2 of the GNU General Public License as
7 * published by the Free Software Foundation.
9 * In addition, for the avoidance of any doubt, permission is granted to
10 * link this program with OpenSSL and to (re)distribute the binaries
11 * produced as the result of such linking.
13 * This program is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 * GNU General Public License for more details.
18 * You should have received a copy of the GNU General Public License
19 * along with this program; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
27 // This class is responsible for the reading of a CDB file.
28 // The constructor opens the CDB file, the destructor closes it, so make sure you call that.
32 CDB(const string &cdbfile);
35 /* Return negative value on error or non-negative value on success.
36 Values can be retrieved via readNext() */
37 int searchKey(const string &key);
38 bool searchSuffix(const string &key);
40 bool readNext(pair<string, string> &value);
41 vector<string> findall(string &key);
42 bool keyExists(const string& key);
43 bool findOne(const string& key, string& value);
50 struct cdb_find d_cdbf;
53 enum SearchType { SearchSuffix, SearchKey, SearchAll } d_searchType{SearchKey};
59 /* we own the fd after this call, don't ever touch it */
63 bool addEntry(const std::string& key, const std::string& value);
64 /* finalize the database and close the fd, the only thing you can do now is to call the destructor */
68 struct cdb_make d_cdbm;