Updated Threads
[fmail.git] / src / fmail.cpp
blob1cc0fdc9edc7142b8d94a807f81a475181310463
1 /*
2 Fancy Mail Server
4 Copyright (C) 2007 Carlos Daniel Ruvalcaba Valenzuela <clsdaniel@gmail.com>
6 This program is free software; you can redistribute it and/or modify
7 it under the terms of the GNU General Public License as published by
8 the Free Software Foundation; either version 2 of the License, or
9 (at your option) any later version.
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.
16 You should have received a copy of the GNU General Public License along
17 with this program; if not, write to the Free Software Foundation, Inc.,
18 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
21 #include <libfmail.h>
22 #include <odkutils.h>
24 typedef ProtocolHandler * (*PROTO_LOAD)();
25 typedef AuthManager * (*AUTH_LOAD)();
27 class SimpleLoad : public LoadHandler{
28 public:
29 int Dispatch(Socket *sock, ProtocolHandler *ph){
30 if (ph)
31 return ph->Handle(sock);
32 return 0;
36 int main(){
37 BaseServer *serv;
38 ProtocolHandler *pop3;
39 ProtocolHandler *smtp;
40 AuthManager *auth;
41 SimpleLoad *lh;
42 IPC *ipc;
44 ipc = IPC::CreateIPC("socket://localhost:1900");
46 odkLibHandle *lib_pop3;
47 odkLibHandle *lib_smtp;
48 PROTO_LOAD load_pop3;
49 PROTO_LOAD load_smtp;
51 odkLibHandle *lib_auth;
52 AUTH_LOAD load_auth;
54 lib_pop3 = odk_library_open("libfmail-pop3");
55 lib_smtp = odk_library_open("libfmail-smtp");
57 load_pop3 = (PROTO_LOAD)odk_library_symbol(lib_pop3, "plugin_protocol_load");
58 load_smtp = (PROTO_LOAD)odk_library_symbol(lib_smtp, "plugin_protocol_load");
60 pop3 = load_pop3();
61 smtp = load_smtp();
63 lib_auth = odk_library_open("libfmail-dbauth");
64 load_auth = (AUTH_LOAD)odk_library_symbol(lib_auth, "plugin_authman_load");
66 auth = load_auth();
68 lh = new SimpleLoad();
70 serv = new BaseServer(pop3, 12001);
72 serv->SetLoadhandler(lh);
73 serv->Listen();
75 while(1){
76 serv->Accept();
79 return 0;