1
/* $Id: params.cpp,v 1.11 2004/08/27 17:53:44 terpstra Exp $
3
* params.cpp - Parse the config file for helper scripts
5
* Copyright (C) 2002 - Wesley W. Terpstra
9
* Authors: 'Wesley W. Terpstra' <wesley@terpstra.ca>
11
* This program is free software; you can redistribute it and/or modify
12
* it under the terms of the GNU General Public License as published by
13
* the Free Software Foundation; version 2.
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.
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., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
25
#define _XOPEN_SOURCE 500
26
#define _FILE_OFFSET_BITS 64
28
#include <ConfigFile.h>
37
void help(const char* name)
39
cerr << "Lurker-params (v" << VERSION << ") parses params from the config file.\n";
41
cerr << "Usage: " << name << " -c <config-file> -f <locale>\n";
42
cerr << " [-d -a -n -e -x -m -i -w -h -r -g]\n";
44
cerr << "\t-c <config-file> Use this config file for lurker settings\n";
45
cerr << "\t-f <locale> Output the fields for this locale\n";
46
cerr << "\t-d Output only the dbdir parameter\n";
47
cerr << "\t-a Output only the archive parameter\n";
48
cerr << "\t-n Output only the administrator name\n";
49
cerr << "\t-e Output only the administrator email address\n";
50
cerr << "\t-x Output only the xslt processing command\n";
51
cerr << "\t-m Output only the mime pgp verifying command\n";
52
cerr << "\t-i Output only the inline pgp verifying command\n";
53
cerr << "\t-w Output only the web_cache state\n";
54
cerr << "\t-h Output only the hide_email state\n";
55
cerr << "\t-r Output only the raw_email state\n";
56
cerr << "\t-g Output only the regroupable state\n";
58
cerr << "Output various lurker settings from the config file for use in shell scripts.\n";
59
cerr << "Do not use sed/grep/etc, instead use this as it respects include.\n";
63
int main(int argc, char** argv)
67
const char* config = 0;
71
bool admin_name = false;
72
bool admin_address = false;
74
bool pgpv_mime = false;
75
bool pgpv_inline = false;
76
bool web_cache = false;
77
bool hide_email = false;
78
bool raw_email = false;
79
bool regroupable = false;
82
while ((c = getopt(argc, (char*const*)argv, "c:f:danexmiwhrg?")) != -1)
106
admin_address = true;
142
if (!config || optind < argc)
150
cerr << "Please either retrieval all fields or exactly one.\n";
155
if (cfg.load(config) != 0)
157
cerr << cfg.getError() << flush;
161
if (!fields || dbdir) cout << cfg.dbdir << "\n";
162
if (!fields || archive) cout << cfg.archive(lc) << "\n";
163
if (!fields || admin_name) cout << cfg.admin_name(lc)<< "\n";
164
if (!fields || admin_address) cout << cfg.admin_address << "\n";
165
if (!fields || xslt) cout << cfg.xslt << "\n";
166
if (!fields || pgpv_mime) cout << cfg.pgpv_mime << "\n";
167
if (!fields || pgpv_inline) cout << cfg.pgpv_inline << "\n";
168
if (!fields || web_cache) cout << (cfg.web_cache?"on":"off") << "\n";
169
if (!fields || hide_email) cout << (cfg.hide_email?"on":"off") << "\n";
170
if (!fields || raw_email) cout << (cfg.raw_email?"on":"off") << "\n";
171
if (!fields || regroupable) cout << (cfg.regroupable?"on":"off") << "\n";