// http2email/main.cc // This file is part of Decimail; see http://decimail.org/ // (C) 2005-2006 Philip Endecott // 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 // 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., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. #include "Http2EmailDaemon.hh" #include #include namespace po = boost::program_options; using namespace std; struct Options { short httpport; short imapport; string imaphost; short smtpport; string smtphost; string user; }; static Options parse_command_line(int argc, char* argv[]) { po::options_description desc("Allowed options"); desc.add_options() ("help", "show help message") ("httpport,p", po::value() ->default_value(8143), "HTTP port number") ("imapport,i", po::value() ->default_value(143), "IMAP port number") ("imaphost,h", po::value()->default_value("localhost"), "IMAP hostname") ("smtpport,s", po::value() ->default_value(25), "SMTP port number") ("smtphost,m", po::value()->default_value("localhost"), "SMTP hostname") ("user,u", po::value()->default_value(""), "User to run as") ; po::variables_map vm; po::store(po::command_line_parser(argc, argv) .options(desc) .run(), vm); po::notify(vm); if (vm.count("help")) { cout << desc << "\n"; exit(1); } struct Options opts; opts.httpport = vm["httpport"].as(); opts.imapport = vm["imapport"].as(); opts.imaphost = vm["imaphost"].as(); opts.smtpport = vm["smtpport"].as(); opts.smtphost = vm["smtphost"].as(); opts.user = vm["user"].as(); return opts; } int main(int argc, char* argv[]) { Options options = parse_command_line(argc,argv); Http2EmailDaemon d(options.httpport, options.user, options.imapport, options.imaphost, options.smtpport, options.smtphost); d.run_as_daemon(); }