1
/* $Id: list.cpp,v 1.8 2004/08/27 15:04:05 terpstra Exp $
3
* list.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-list (v" << VERSION << ") parses lists from the config file.\n";
41
cerr << "Usage: " << name << " -c <config-file> -f <locale>\n";
42
cerr << " [-i -g -t -a -l -d -s -o] [listid ...]\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-i Output only the list id\n";
47
cerr << "\t-g Output only the group\n";
48
cerr << "\t-t Output only the title\n";
49
cerr << "\t-a Output only the email address\n";
50
cerr << "\t-l Output only the url link\n";
51
cerr << "\t-d Output only the description\n";
52
cerr << "\t-s Output only the language\n";
53
cerr << "\t-o Output only the offline status\n";
55
cerr << "Output various lurker settings from the config file for use in shell scripts.\n";
56
cerr << "Do not use sed/grep/etc, instead use this as it respects include.\n";
60
int main(int argc, char** argv)
64
const char* config = 0;
72
bool language = false;
76
while ((c = getopt(argc, (char*const*)argv, "c:f:igtaldso?")) != -1)
132
cerr << "Please either retrieval all fields or exactly one.\n";
137
if (cfg.load(config) != 0)
139
cerr << cfg.getError() << flush;
144
for (; optind < argc; ++optind)
146
Config::Lists::const_iterator l = cfg.lists.find(argv[optind]);
147
if (l == cfg.lists.end())
149
cerr << "'" << argv[optind] << "' is not a mailing list id.\n";
152
output.push_back(l->second);
157
Config::Lists::const_iterator l;
158
for (l = cfg.lists.begin(); l != cfg.lists.end(); ++l)
159
output.push_back(l->second);
162
if (lc != "" && !lstring::locale_normalize(lc))
164
cerr << "'" << lc << "' is not a valid locale\n";
168
vector<List>::const_iterator o;
169
for (o = output.begin(); o != output.end(); ++o)
171
if (!fields || ids) cout << o->mbox << "\n";
172
if (!fields || group) cout << o->group << "\n";
173
if (!fields || title) cout << o->title(lc) << "\n";
174
if (!fields || address) cout << o->address << "\n";
175
if (!fields || link) cout << o->link(lc) << "\n";
176
if (!fields || desc) cout << o->description(lc) << "\n";
177
if (!fields || language)cout << o->language << "\n";
178
if (!fields || offline) cout << (o->offline?"true\n":"false\n");