|
a/src/common/rclinit.cpp |
|
b/src/common/rclinit.cpp |
1 |
#ifndef lint
|
1 |
#ifndef lint
|
2 |
static char rcsid[] = "@(#$Id: rclinit.cpp,v 1.1 2005-04-05 09:35:35 dockes Exp $ (C) 2004 J.F.Dockes";
|
2 |
static char rcsid[] = "@(#$Id: rclinit.cpp,v 1.2 2005-11-05 14:40:50 dockes Exp $ (C) 2004 J.F.Dockes";
|
3 |
#endif
|
3 |
#endif
|
4 |
|
4 |
|
5 |
#include <stdio.h>
|
5 |
#include <stdio.h>
|
6 |
#include <signal.h>
|
6 |
#include <signal.h>
|
7 |
|
7 |
|
8 |
#include "debuglog.h"
|
8 |
#include "debuglog.h"
|
9 |
#include "rclconfig.h"
|
9 |
#include "rclconfig.h"
|
|
|
10 |
#include "rclinit.h"
|
10 |
|
11 |
|
11 |
RclConfig *recollinit(void (*cleanup)(void), void (*sigcleanup)(int))
|
12 |
RclConfig *recollinit(void (*cleanup)(void), void (*sigcleanup)(int),
|
|
|
13 |
string &reason)
|
12 |
{
|
14 |
{
|
13 |
atexit(cleanup);
|
15 |
atexit(cleanup);
|
14 |
if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
|
16 |
if (signal(SIGHUP, SIG_IGN) != SIG_IGN)
|
15 |
signal(SIGHUP, sigcleanup);
|
17 |
signal(SIGHUP, sigcleanup);
|
16 |
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
|
18 |
if (signal(SIGINT, SIG_IGN) != SIG_IGN)
|
|
... |
|
... |
22 |
|
24 |
|
23 |
DebugLog::getdbl()->setloglevel(DEBDEB1);
|
25 |
DebugLog::getdbl()->setloglevel(DEBDEB1);
|
24 |
DebugLog::setfilename("stderr");
|
26 |
DebugLog::setfilename("stderr");
|
25 |
RclConfig *config = new RclConfig;
|
27 |
RclConfig *config = new RclConfig;
|
26 |
if (!config || !config->ok()) {
|
28 |
if (!config || !config->ok()) {
|
27 |
fprintf(stderr, "Config could not be built\n");
|
29 |
reason = "Configuration could not be built:\n";
|
28 |
exit(1);
|
30 |
if (config)
|
|
|
31 |
reason += config->getReason();
|
|
|
32 |
else
|
|
|
33 |
reason += "Out of memory ?";
|
|
|
34 |
return 0;
|
29 |
}
|
35 |
}
|
30 |
|
36 |
|
31 |
string logfilename, loglevel;
|
37 |
string logfilename, loglevel;
|
32 |
if (config->getConfParam(string("logfilename"), logfilename))
|
38 |
if (config->getConfParam(string("logfilename"), logfilename))
|
33 |
DebugLog::setfilename(logfilename.c_str());
|
39 |
DebugLog::setfilename(logfilename.c_str());
|