Moved system applications
[reactos.git] / reactos / subsys / system / services / services.c
1 /* $Id: services.c,v 1.1 2000/12/05 02:38:08 ekohl Exp $
2 *
3 * service control manager
4 *
5 * ReactOS Operating System
6 *
7 * --------------------------------------------------------------------
8 *
9 * This software is free software; you can redistribute it and/or
10 * modify it under the terms of the GNU General Public License as
11 * published by the Free Software Foundation; either version 2 of the
12 * License, or (at your option) any later version.
13 *
14 * This software is distributed in the hope that it will be useful,
15 * but WITHOUT ANY WARRANTY; without even the implied warranty of
16 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17 * Library General Public License for more details.
18 *
19 * You should have received a copy of the GNU General Public License
20 * along with this software; see the file COPYING.LIB. If not, write
21 * to the Free Software Foundation, Inc., 675 Mass Ave, Cambridge,
22 * MA 02139, USA.
23 *
24 */
25
26 /* NOTE:
27 * - Services.exe is NOT a native application, it is a GUI app.
28 */
29
30 /* INCLUDES *****************************************************************/
31
32 #define NTOS_MODE_USER
33 #include <ntos.h>
34 #include <windows.h>
35
36 #include <services/services.h>
37
38 /* GLOBALS ******************************************************************/
39
40 HANDLE OutputHandle;
41
42
43 /* FUNCTIONS *****************************************************************/
44
45 void PrintString (char* fmt,...)
46 {
47 char buffer[512];
48 va_list ap;
49
50 va_start(ap, fmt);
51 vsprintf(buffer, fmt, ap);
52 va_end(ap);
53
54 WriteConsoleA(OutputHandle, buffer, strlen(buffer), NULL, NULL);
55 }
56
57
58 BOOL ScmCreateStartEvent(PHANDLE StartEvent)
59 {
60 HANDLE hEvent;
61
62 hEvent = CreateEvent(NULL,
63 TRUE,
64 FALSE,
65 _T("SvcctrlStartEvent_A3725DX"));
66 if (hEvent == NULL)
67 {
68 if (GetLastError() == ERROR_ALREADY_EXISTS)
69 {
70 hEvent = OpenEvent(EVENT_ALL_ACCESS,
71 FALSE,
72 _T("SvcctrlStartEvent_A3725DX"));
73 if (hEvent == NULL)
74 {
75 return FALSE;
76 }
77 }
78 else
79 {
80 return FALSE;
81 }
82 }
83
84 *StartEvent = hEvent;
85
86 return TRUE;
87 }
88
89
90 //int main (int argc, char *argv[])
91 int STDCALL
92 WinMain(HINSTANCE hInstance,
93 HINSTANCE hPrevInstance,
94 LPSTR lpCmdLine,
95 int nShowCmd)
96 {
97 HANDLE hScmStartEvent;
98
99 AllocConsole();
100 OutputHandle = GetStdHandle(STD_OUTPUT_HANDLE);
101
102 PrintString("Service Control Manager\n");
103
104 /* Create start event */
105 if (!ScmCreateStartEvent(&hScmStartEvent))
106 {
107 PrintString("SERVICES: Failed to create start event\n");
108 ExitThread(0);
109 }
110
111
112
113
114 /* FIXME: more initialization */
115
116
117
118
119 PrintString("SERVICES: Initialized.\n");
120
121 /* Signal start event */
122 SetEvent(hScmStartEvent);
123
124
125 /* FIXME: more to do ? */
126
127
128 PrintString("SERVICES: Running.\n");
129
130 ExitThread (0);
131 return 0;
132 }
133
134 /* EOF */