ncrypt/tests: Test for symmetric keys support.
[wine.git] / programs / wuauserv / main.c
blob79eb84e67030d14b9e52101eeb328407ffdaae2a
1 /*
2 * Copyright 2007 Jacek Caban for CodeWeavers
3 * Copyright 2016 Michael Müller
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
10 * This library is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 * Lesser General Public License for more details.
15 * You should have received a copy of the GNU Lesser General Public
16 * License along with this library; if not, write to the Free Software
17 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
20 #define WIN32_LEAN_AND_MEAN
22 #include <windows.h>
23 #include <winsvc.h>
25 #include "wine/debug.h"
27 WINE_DEFAULT_DEBUG_CHANNEL(wuauserv);
29 static WCHAR wuauservW[] = {'w','u','a','u','s','e','r','v',0};
31 static SERVICE_STATUS_HANDLE service_handle;
32 static HANDLE stop_event;
34 static DWORD WINAPI service_handler( DWORD ctrl, DWORD event_type, LPVOID event_data, LPVOID context )
36 SERVICE_STATUS status;
38 status.dwServiceType = SERVICE_WIN32;
39 status.dwControlsAccepted = SERVICE_ACCEPT_STOP;
40 status.dwWin32ExitCode = 0;
41 status.dwServiceSpecificExitCode = 0;
42 status.dwCheckPoint = 0;
43 status.dwWaitHint = 0;
45 switch(ctrl)
47 case SERVICE_CONTROL_STOP:
48 case SERVICE_CONTROL_SHUTDOWN:
49 WINE_TRACE( "shutting down\n" );
50 status.dwCurrentState = SERVICE_STOP_PENDING;
51 status.dwControlsAccepted = 0;
52 SetServiceStatus( service_handle, &status );
53 SetEvent( stop_event );
54 return NO_ERROR;
55 default:
56 WINE_FIXME( "got service ctrl %lx\n", ctrl );
57 status.dwCurrentState = SERVICE_RUNNING;
58 SetServiceStatus( service_handle, &status );
59 return NO_ERROR;
63 static void WINAPI serv_main(DWORD argc, LPWSTR *argv)
65 SERVICE_STATUS status;
67 WINE_TRACE( "starting service\n" );
69 stop_event = CreateEventW( NULL, TRUE, FALSE, NULL );
71 service_handle = RegisterServiceCtrlHandlerExW( wuauservW, service_handler, NULL );
72 if (!service_handle)
73 return;
75 status.dwServiceType = SERVICE_WIN32;
76 status.dwCurrentState = SERVICE_RUNNING;
77 status.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
78 status.dwWin32ExitCode = 0;
79 status.dwServiceSpecificExitCode = 0;
80 status.dwCheckPoint = 0;
81 status.dwWaitHint = 10000;
82 SetServiceStatus( service_handle, &status );
84 WaitForSingleObject( stop_event, INFINITE );
86 status.dwCurrentState = SERVICE_STOPPED;
87 status.dwControlsAccepted = 0;
88 SetServiceStatus( service_handle, &status );
89 WINE_TRACE( "service stopped\n" );
92 int __cdecl main(int argc, char **argv)
94 static const SERVICE_TABLE_ENTRYW servtbl[] =
96 {wuauservW, serv_main},
97 {NULL, NULL}
100 WINE_TRACE( "(%d %p)\n", argc, argv );
102 StartServiceCtrlDispatcherW( servtbl );
103 return 0;