msvcp90: Implement time_get<char> ctors and dtors (Valgrind).
[wine/multimedia.git] / dlls / fntcache / main.c
blob8de84b262e3aa9e36762c6f3a0532b5668d2b0f2
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 HINSTANCE hInst;
29 static SERVICE_STATUS_HANDLE service_handle;
30 static HANDLE stop_event;
32 /***********************************************************************
33 * DllMain (fntcache.@)
35 BOOL WINAPI DllMain(HINSTANCE hinstDLL, DWORD fdwReason, LPVOID lpvReserved)
37 TRACE("(%p, %d, %p)\n", hinstDLL, fdwReason, lpvReserved);
39 switch (fdwReason)
41 case DLL_WINE_PREATTACH:
42 return FALSE; /* prefer native version */
43 case DLL_PROCESS_ATTACH:
44 DisableThreadLibraryCalls(hinstDLL);
45 hInst = hinstDLL;
46 break;
49 return TRUE;
52 static DWORD WINAPI service_handler( DWORD ctrl, DWORD event_type, void *event_data, void *context )
54 SERVICE_STATUS status;
56 status.dwServiceType = SERVICE_WIN32;
57 status.dwControlsAccepted = SERVICE_ACCEPT_STOP;
58 status.dwWin32ExitCode = 0;
59 status.dwServiceSpecificExitCode = 0;
60 status.dwCheckPoint = 0;
61 status.dwWaitHint = 0;
63 switch(ctrl)
65 case SERVICE_CONTROL_STOP:
66 case SERVICE_CONTROL_SHUTDOWN:
67 TRACE( "shutting down\n" );
68 status.dwCurrentState = SERVICE_STOP_PENDING;
69 status.dwControlsAccepted = 0;
70 SetServiceStatus( service_handle, &status );
71 SetEvent( stop_event );
72 return NO_ERROR;
73 default:
74 FIXME( "got service ctrl %x\n", ctrl );
75 status.dwCurrentState = SERVICE_RUNNING;
76 SetServiceStatus( service_handle, &status );
77 return NO_ERROR;
81 /***********************************************************************
82 * ServiceMain (fntcache.@)
84 VOID WINAPI ServiceMain(DWORD argc, LPWSTR *argv)
86 static const WCHAR fontcacheW[] = {'F','o','n','t','C','a','c','h','e',0};
87 SERVICE_STATUS status;
89 TRACE( "starting service\n" );
91 stop_event = CreateEventW( NULL, TRUE, FALSE, NULL );
93 service_handle = RegisterServiceCtrlHandlerExW( fontcacheW, service_handler, NULL );
94 if (!service_handle)
95 return;
97 status.dwServiceType = SERVICE_WIN32;
98 status.dwCurrentState = SERVICE_RUNNING;
99 status.dwControlsAccepted = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
100 status.dwWin32ExitCode = 0;
101 status.dwServiceSpecificExitCode = 0;
102 status.dwCheckPoint = 0;
103 status.dwWaitHint = 10000;
104 SetServiceStatus( service_handle, &status );
106 WaitForSingleObject( stop_event, INFINITE );
108 status.dwCurrentState = SERVICE_STOPPED;
109 status.dwControlsAccepted = 0;
110 SetServiceStatus( service_handle, &status );
111 TRACE( "service stopped\n" );