/********************************************************************** * * maincfg.cpp -- * Copyright (C) 2008 The New Zealand Digital Library Project * * A component of the Greenstone digital library software * from the New Zealand Digital Library Project at the * University of Waikato, New Zealand. * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by * the Free Software Foundation; either version 2 of the License, or * (at your option) any later version. * * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. * *********************************************************************/ #include "maincfg.h" #include "fileutil.h" #if defined(GSDL_USE_OBJECTSPACE) # include # include #elif defined(GSDL_USE_IOS_H) # include # include #else # include # include #endif // main_cfg_read reads both main.cfg and collect.cfg. It attempts // to read main.cfg first so values in collect.cfg override those // set earlier by main.cfg bool main_cfg_read (receptionist &recpt, const text_t &gsdlhome, const text_t &collection) { // read in the main configuration file bool rv = false; text_t key, filename; text_tarray cfgline; filename = filename_cat (gsdlhome, "etc"); filename = filename_cat (filename, "main.cfg"); if (!collection.empty() && file_exists(filename)) { rv = recpt.read_configfile(filename); } else { filename_cat (filename, gsdlhome, "etc", "main.cfg"); if (file_exists (filename)) { rv = recpt.read_configfile(filename); } } // Look for collect.cfg in GSDLHOME/collect/collection-name/etc directory // (if this is for a particular collection), and then GSDLHOME/etc. if (!collection.empty()) { filename = filename_cat (gsdlhome, "collect"); filename = filename_cat (filename, collection); filename = filename_cat (filename, "etc"); filename = filename_cat (filename, "collect.cfg"); if (!file_exists (filename)) { filename = filename_cat (gsdlhome, "etc"); filename = filename_cat (filename, "collect.cfg"); if (!file_exists (filename)) filename.clear(); } if (!filename.empty()) { rv |= recpt.read_configfile(filename); } } return rv; }