ViewVC Help
View File | Revision Log | Show Annotations | Download File
/cvs/gvpe/src/gvpe.C
(Generate patch)

Comparing gvpe/src/gvpe.C (file contents):
Revision 1.1 by pcg, Fri Mar 18 01:53:05 2005 UTC vs.
Revision 1.6 by pcg, Mon Mar 28 20:39:18 2005 UTC

1/* 1/*
2 vped.C -- the main file for gvpe 2 gvpe.C -- the main file for gvpe
3 Copyright (C) 1998-2002 Ivo Timmermans <ivo@o2w.nl> 3 Copyright (C) 1998-2002 Ivo Timmermans <ivo@o2w.nl>
4 2000-2002 Guus Sliepen <guus@sliepen.eu.org> 4 2000-2002 Guus Sliepen <guus@sliepen.eu.org>
5 2003-2005 Marc Lehmann <gvpe@schmorp.de> 5 2003-2005 Marc Lehmann <gvpe@schmorp.de>
6 6
7 This file is part of GVPE. 7 This file is part of GVPE.
41#endif 41#endif
42 42
43#include <openssl/err.h> 43#include <openssl/err.h>
44#include <openssl/rand.h> 44#include <openssl/rand.h>
45 45
46#include "gettext.h"
46#include "pidfile.h" 47#include "pidfile.h"
47 48
48#include "conf.h" 49#include "conf.h"
49#include "slog.h" 50#include "slog.h"
50#include "util.h" 51#include "util.h"
101parse_options (int argc, char **argv, char **envp) 102parse_options (int argc, char **argv, char **envp)
102{ 103{
103 int r; 104 int r;
104 int option_index = 0; 105 int option_index = 0;
105 106
106 while ((r = getopt_long (argc, argv, "-c:DLl:", long_options, &option_index)) != EOF) 107 while ((r = getopt_long (argc, argv, "c:DLl:", long_options, &option_index)) != EOF)
107 { 108 {
108 switch (r) 109 switch (r)
109 { 110 {
110 case 0: /* long option */ 111 case 0: /* long option */
111 break;
112
113 case 1: /* this node name */
114 thisnode = strdup (optarg);
115 break; 112 break;
116 113
117 case 'c': /* config file */ 114 case 'c': /* config file */
118 confbase = strdup (optarg); 115 confbase = strdup (optarg);
119 break; 116 break;
196 act.sa_flags = 0; 193 act.sa_flags = 0;
197 194
198 act.sa_handler = sighup_handler; sigaction (SIGHUP , &act, NULL); 195 act.sa_handler = sighup_handler; sigaction (SIGHUP , &act, NULL);
199 act.sa_handler = sigusr1_handler; sigaction (SIGUSR1, &act, NULL); 196 act.sa_handler = sigusr1_handler; sigaction (SIGUSR1, &act, NULL);
200 act.sa_handler = sigusr2_handler; sigaction (SIGUSR2, &act, NULL); 197 act.sa_handler = sigusr2_handler; sigaction (SIGUSR2, &act, NULL);
201 act.sa_handler = SIG_IGN; sigaction (SIGCHLD, &act, NULL); 198// act.sa_handler = SIG_IGN; sigaction (SIGCHLD, &act, NULL);
202 act.sa_handler = SIG_IGN; sigaction (SIGPIPE, &act, NULL); 199 act.sa_handler = SIG_IGN; sigaction (SIGPIPE, &act, NULL);
203 act.sa_flags = SA_RESETHAND; 200 act.sa_flags = SA_RESETHAND;
204 act.sa_handler = sigterm_handler; sigaction (SIGINT , &act, NULL); 201 act.sa_handler = sigterm_handler; sigaction (SIGINT , &act, NULL);
205 act.sa_handler = sigterm_handler; sigaction (SIGTERM, &act, NULL); 202 act.sa_handler = sigterm_handler; sigaction (SIGTERM, &act, NULL);
206} 203}
217 setlocale (LC_ALL, ""); 214 setlocale (LC_ALL, "");
218 bindtextdomain (PACKAGE, LOCALEDIR); 215 bindtextdomain (PACKAGE, LOCALEDIR);
219 textdomain (PACKAGE); 216 textdomain (PACKAGE);
220 217
221 parse_options (argc, argv, envp); 218 parse_options (argc, argv, envp);
219
220 argc -= optind;
221 argv += optind;
222 222
223 if (show_version) 223 if (show_version)
224 { 224 {
225 printf (_("%s version %s (built %s %s, protocol %d.%d)\n"), get_identity (), 225 printf (_("%s version %s (built %s %s, protocol %d.%d)\n"), get_identity (),
226 VERSION, __DATE__, __TIME__, PROTOCOL_MAJOR, PROTOCOL_MINOR); 226 VERSION, __DATE__, __TIME__, PROTOCOL_MAJOR, PROTOCOL_MINOR);
246 if (do_mlock) 246 if (do_mlock)
247 if (mlockall (MCL_CURRENT | MCL_FUTURE)) 247 if (mlockall (MCL_CURRENT | MCL_FUTURE))
248 slog (L_ERR, _("system call `%s' failed: %s"), "mlockall", strerror (errno)); 248 slog (L_ERR, _("system call `%s' failed: %s"), "mlockall", strerror (errno));
249#endif 249#endif
250 250
251 conf.read_config (true); 251 if (argc >= 1)
252 {
253 thisnode = *argv++;
254 argc--;
255 }
256
257 {
258 configuration_parser (conf, true, argc, argv);
259 }
252 260
253 set_loglevel (llevel != L_NONE ? llevel : conf.llevel); 261 set_loglevel (llevel != L_NONE ? llevel : conf.llevel);
254 262
255 RAND_load_file ("/dev/urandom", 1024); 263 RAND_load_file ("/dev/urandom", 1024);
256 264
257 if (!THISNODE) 265 if (!THISNODE)
258 { 266 {
259 slog (L_ERR, _("current node not set, or node '%s' not found in configfile, specify the nodename when starting vped."), 267 slog (L_ERR, _("current node not set, or node '%s' not found in configfile, specify the nodename when starting gvpe."),
260 thisnode ? thisnode : "<unset>"); 268 thisnode ? thisnode : "<unset>");
261 exit (EXIT_FAILURE); 269 exit (EXIT_FAILURE);
262 } 270 }
263 271
264 if (detach (do_detach)) 272 if (detach (do_detach))

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines