summaryrefslogtreecommitdiffabout
path: root/src/calloutd.c
blob: d82f936a9e825dbe0d2557e22fa5f3d5d5413257 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
/* This file is part of Mailfromd.
   Copyright (C) 2005, 2006, 2007, 2008, 2009, 2010, 2011 Sergey
   Poznyakoff

   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 3, or (at your option)
   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, see <http://www.gnu.org/licenses/>. */

#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <sys/socket.h>
#include <netinet/in.h>
#include <arpa/inet.h>
#include <netdb.h>
#include <sysexits.h>

#include <mailutils/mailutils.h>
#include <mailutils/libcfg.h>
#include <mailutils/libargp.h>
#include <mailutils/daemon.h>

#include "libmf.h"
#include "callout.h"
#include "srvman.h"
#include "srvcfg.h"
#include "mfdb.h"
#include "mf-dbm.h"

void
xalloc_die()
{
	mu_error(_("not enough memory"));
        abort();
}


static void
version(FILE *stream, struct argp_state *state)
{
	mailfromd_version("calloutd", stream);
}


const char *program_version = "calloutd (" PACKAGE_STRING ")";
static char doc[] = N_("calloutd -- a call out server");
static char args_doc[] = "";

static struct argp_option options[] = {
	{ NULL }
};

static error_t
parse_opt(int key, char *arg, struct argp_state *state)
{
	switch (key) {
	default:
		return ARGP_ERR_UNKNOWN;
	}
	return 0;
}
	

struct mu_cfg_param callout_cfg_param[] = {
 	{ ".mfd:server",  mu_cfg_section, NULL, 0, NULL, NULL },
	{ NULL }
};



extern char **environ;

static const char *capa[] = {
	"common",
	"debug",
	"logging",
	NULL
};

static struct argp argp = {
	options,
	parse_opt,
	args_doc,
	doc,
	NULL,
	NULL,
	NULL
};


int
mf_server_function(const char *key, struct mf_srvcfg *cfg)
{
	cfg->server = callout_session_server;
	return 0;
}

int
main(int argc, char **argv)
{
	int rc;
	
	mf_init_nls();
	mf_proctitle_init(argc, argv, environ);
	if (!program_invocation_short_name)
		program_invocation_short_name = argv[0];
	argp_program_version_hook = version;
	/* Set default logging */
	mu_log_facility = DEFAULT_LOG_FACILITY;
	mf_srvcfg_log_setup(stderr_closed_p() ? "syslog" : "stderr");

	libcallout_init();
	libdbm_init();
	db_format_setup();
	
	mf_server_save_cmdline(argc, argv);
	dnsbase_init();
	database_cfg_init();
	mu_acl_cfg_init();
	srvman_init();
	mf_srvcfg_init(argv[0], NULL);

	mu_argp_init(program_version, "<" PACKAGE_BUGREPORT ">");
	mu_site_rcfile = SYSCONFDIR "/calloutd.conf";
	rc = mu_app_init(&argp, capa, callout_cfg_param, argc, argv,
			 0, NULL, NULL);
	if (rc)
		exit(EX_CONFIG);
	mf_srvcfg_flush();

	mf_server_start("calloutd", mailfromd_state_dir, pidfile,
			server_flags);
	exit(0);
}

Return to:

Send suggestions and report system problems to the System administrator.