winemac.drv: Don't filter non active displays out.
[wine/zf.git] / dlls / fntcache / main.c
blob0f8508652f2eb7badb5170340c0ccf8236fe5b4c
1 /*
2 * Font Cache service
4 * Copyright 2014 Nikolay Sivov for CodeWeavers
6 * This library is free software; you can redistribute it and/or
7 * modify it under the terms of the GNU Lesser General Public
8 * License as published by the Free Software Foundation; either
9 * version 2.1 of the License, or (at your option) any later version.
11 * This library 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 GNU
14 * Lesser General Public License for more details.
16 * You should have received a copy of the GNU Lesser General Public
17 * License along with this library; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
21 #define WIN32_LEAN_AND_MEAN
22 #include <windows.h>
23 #include "winsvc.h"
24 #include "wine/debug.h"
26 WINE_DEFAULT_DEBUG_CHANNEL(fontcache);
28 static SERVICE_STATUS_HANDLE service_handle;
29 static HANDLE stop_event;
31 static DWORD WINAPI service_handler( DWORD ctrl, DWORD event_type, void *event_data, void *context )
33 SERVICE_STATUS status;
35 status.dwServiceType = SERVICE_WIN32;
36 status.dwControlsAccepted = SERVICE_ACCEPT_STOP;
37 status.dwWin32ExitCode = 0;
38 status.dwServiceSpecificExitCode = 0;
39 status.dwCheckPoint = 0;
40 status.dwWaitHint = 0;
42 switch(ctrl)
44 case SERVICE_CONTROL_STOP:
45 case SERVICE_CONTROL_SHUTDOWN:
46 TRACE( "shutting down\n" );
47 status.dwCurrentState = SERVICE_STOP_PENDING;
48 status.dwControlsAccepted = 0;
49 SetServiceStatus( service_handle, &status );
50 SetEvent( stop_event );
51 return NO_ERROR;
52 default:
53 FIXME( "got service ctrl %x\n", ctrl );
54 status.dwCurrentState = SERVICE_RUNNING;
55 SetServiceStatus( service_handle, &status );
56 return NO_ERROR;
60 /***********************************************************************
61 * ServiceMain (fntcache.@)
63 VOID WINAPI ServiceMain(DWORD argc, LPWSTR *argv)
65 SERVICE_STATUS status;
67 TRACE( "starting service\n" );
69 stop_event = CreateEventW( NULL, TRUE, FALSE, NULL );
71 service_handle = RegisterServiceCtrlHandlerExW( L"FontCache", 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 TRACE( "service stopped\n" );