1 /*
2  Copyright (C) 1999-2004 IC & S  dbmail@ic-s.nl
3  Copyright (C) 2006 Aaron Stone aaron@serendipity.cx
4 
5  This program is free software; you can redistribute it and/or
6  modify it under the terms of the GNU General Public License
7  as published by the Free Software Foundation; either
8  version 2 of the License, or (at your option) any later
9  version.
10 
11  This program is distributed in the hope that it will be useful,
12  but WITHOUT ANY WARRANTY; without even the implied warranty of
13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  GNU General Public License for more details.
15 
16  You should have received a copy of the GNU General Public License
17  along with this program; if not, write to the Free Software
18  Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
19 */
20 
21 /*
22 *
23 * httpd.c
24 *
25 * main prg for http daemon
26 */
27 
28 #include "dbmail.h"
29 #include "dm_request.h"
30 
31 #define THIS_MODULE "httpd"
32 #define PNAME "dbmail/httpd"
33 
main(int argc,char * argv[])34 int main(int argc, char *argv[])
35 {
36 	ServerConfig_T config;
37 	int result;
38 
39 	g_mime_init(GMIME_ENABLE_RFC2047_WORKAROUNDS);
40 	g_mime_parser_get_type();
41 	g_mime_stream_get_type();
42 	g_mime_stream_mem_get_type();
43 	g_mime_stream_file_get_type();
44 	g_mime_stream_buffer_get_type();
45 	g_mime_stream_filter_get_type();
46 	g_mime_filter_crlf_get_type();
47 
48 	openlog(PNAME, LOG_PID, LOG_MAIL);
49 
50         memset(&config, 0, sizeof(ServerConfig_T));
51 	result = server_getopt(&config, "HTTP", argc, argv);
52 	if (result == -1)
53 		goto shutdown;
54 
55 	if (result == 1) {
56 		server_showhelp("dbmail-httpd",
57 			"This daemon provides HTTP services.");
58 		goto shutdown;
59 	}
60 
61 	config.cb = Request_cb;
62 	result = server_mainloop(&config, "dbmail-httpd");
63 
64 shutdown:
65 	g_mime_shutdown();
66 	config_free();
67 
68 	TRACE(TRACE_INFO, "exit");
69 	return result;
70 }
71 
72