--- gvpe/src/gvpe.C 2005/03/18 02:32:20 1.2 +++ gvpe/src/gvpe.C 2007/12/01 23:35:31 1.12 @@ -1,5 +1,5 @@ /* - vped.C -- the main file for gvpe + gvpe.C -- the main file for gvpe Copyright (C) 1998-2002 Ivo Timmermans 2000-2002 Guus Sliepen 2003-2005 Marc Lehmann @@ -18,7 +18,7 @@ You should have received a copy of the GNU General Public License along with gvpe; if not, write to the Free Software - Foundation, Inc. 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA + Foundation, Inc. 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ #include "config.h" @@ -50,7 +50,7 @@ #include "slog.h" #include "util.h" #include "vpn.h" -#include "iom.h" +#include "ev_cpp.h" static loglevel llevel = L_NONE; @@ -92,7 +92,7 @@ " -L, --mlock Lock tinc into main memory.\n" " --help Display this help and exit.\n" " --version Output version information and exit.\n\n")); - printf (_("Report bugs to .\n")); + printf (_("Report bugs to .\n")); } exit (status); @@ -104,17 +104,13 @@ int r; int option_index = 0; - while ((r = getopt_long (argc, argv, "-c:DLl:", long_options, &option_index)) != EOF) + while ((r = getopt_long (argc, argv, "c:DLl:", long_options, &option_index)) != EOF) { switch (r) { case 0: /* long option */ break; - case 1: /* this node name */ - thisnode = strdup (optarg); - break; - case 'c': /* config file */ confbase = strdup (optarg); break; @@ -167,14 +163,14 @@ sigterm_handler (int a) { network.events |= vpn::EVENT_SHUTDOWN; - network.event.start (0); + network.event.start (); } RETSIGTYPE sighup_handler (int a) { network.events |= vpn::EVENT_RECONNECT; - network.event.start (0); + network.event.start (); } RETSIGTYPE @@ -221,13 +217,16 @@ parse_options (argc, argv, envp); + argc -= optind; + argv += optind; + if (show_version) { - printf (_("%s version %s (built %s %s, protocol %d.%d)\n"), get_identity (), + printf (_("%s version %s (built %s %s, protocol version %d.%d)\n"), get_identity (), VERSION, __DATE__, __TIME__, PROTOCOL_MAJOR, PROTOCOL_MINOR); printf (_("Built with kernel interface %s/%s.\n"), IFTYPE, IFSUBTYPE); printf (_ - ("Copyright (C) 2003 Marc Lehmann and others.\n" + ("Copyright (C) 2003 Marc Lehmann and others.\n" "See the AUTHORS file for a complete list.\n\n" "tinc comes with ABSOLUTELY NO WARRANTY. This is free software,\n" "and you are welcome to redistribute it under certain conditions;\n" @@ -249,7 +248,21 @@ slog (L_ERR, _("system call `%s' failed: %s"), "mlockall", strerror (errno)); #endif - conf.read_config (true); + if (argc >= 1) + { + thisnode = *argv++; + argc--; + } + + if (!ev_default_loop (0)) + { + slog (L_ERR, _("unable to initialise the event loop (bad $LIBEV_METHODS?)")); + exit (EXIT_FAILURE); + } + + { + configuration_parser (conf, true, argc, argv); + } set_loglevel (llevel != L_NONE ? llevel : conf.llevel); @@ -257,7 +270,7 @@ if (!THISNODE) { - slog (L_ERR, _("current node not set, or node '%s' not found in configfile, specify the nodename when starting vped."), + slog (L_ERR, _("current node not set, or node '%s' not found in configfile, specify the nodename when starting gvpe."), thisnode ? thisnode : ""); exit (EXIT_FAILURE); } @@ -269,7 +282,7 @@ if (!network.setup ()) { - io_manager::loop (); + ev_loop (EV_DEFAULT_ 0); cleanup_and_exit (EXIT_FAILURE); }