1 /*
2  * COPYRIGHT:   See COPYING in the top level directory
3  * PROJECT:     ReactOS HTTP Daemon
4  * FILE:        roshttpd.cpp
5  * PURPOSE:     Main program
6  * PROGRAMMERS: Casper S. Hornstrup (chorns@users.sourceforge.net)
7  * REVISIONS:
8  *   CSH  01/09/2000 Created
9  */
10 #include <debug.h>
11 #include <new>
12 #include <winsock2.h>
13 #include <stdio.h>
14 #include <config.h>
15 #include <error.h>
16 #include <httpd.h>
17 
18 using namespace std;
19 
20 
Run()21 VOID Run()
22 {
23     InitWinsock();
24 
25     pDaemonThread = NULL;
26 	pConfiguration = NULL;
27 
28 	try {
29         // Create configuration object
30 		pConfiguration = new CConfig;
31         pConfiguration->Default();
32 
33         // Create daemon object
34         pDaemonThread = new CHttpDaemonThread;
35 
36 		MSG Msg;
37 		BOOL bQuit = FALSE;
38 		while ((!bQuit) && (!pDaemonThread->Terminated())) {
39 		    bQuit = PeekMessage(&Msg, NULL, 0, 0, PM_REMOVE);
40 			if (!bQuit)
41 			    DispatchMessage(&Msg);
42         }
43 
44 		delete pDaemonThread;
45 
46 		if (pConfiguration != NULL)
47 		    delete pConfiguration;
48 	} catch (bad_alloc&) {
49 		if (pConfiguration != NULL)
50 			delete pConfiguration;
51 		ReportErrorStr(TS("Insufficient resources."));
52 	}
53 
54     DeinitWinsock();
55 }
56 
57 /* Program entry point */
main(int argc,char * argv[])58 int main(int argc, char* argv[])
59 {
60     printf("ReactOS HTTP Daemon\n");
61     printf("Type Control-C to stop.\n");
62 
63     Run();
64 
65     printf("Daemon stopped.\n");
66 }
67