~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

Wine Cross Reference
wine/programs/termsv/main.c

Version: ~ [ wine-1.1.33 ] ~ [ wine-1.1.32 ] ~ [ wine-1.1.31 ] ~ [ wine-1.1.30 ] ~ [ wine-1.1.29 ] ~ [ wine-1.1.28 ] ~ [ wine-1.1.27 ] ~ [ wine-1.1.26 ] ~ [ wine-1.1.25 ] ~ [ wine-1.1.24 ] ~ [ wine-1.1.23 ] ~ [ wine-1.1.22 ] ~ [ wine-1.1.21 ] ~ [ wine-1.1.20 ] ~ [ wine-1.1.19 ] ~ [ wine-1.1.18 ] ~ [ wine-1.1.17 ] ~ [ wine-1.1.16 ] ~ [ wine-1.1.15 ] ~ [ wine-1.1.14 ] ~ [ wine-1.1.13 ] ~ [ wine-1.1.12 ] ~ [ wine-1.1.11 ] ~ [ wine-1.1.10 ] ~ [ wine-1.1.9 ] ~ [ wine-1.1.8 ] ~ [ wine-1.1.7 ] ~ [ wine-1.0.1 ] ~ [ wine-1.1.6 ] ~ [ wine-1.1.5 ] ~ [ wine-1.1.4 ] ~ [ wine-1.1.3 ] ~ [ wine-1.1.2 ] ~ [ wine-1.1.1 ] ~ [ wine-1.1.0 ] ~ [ wine-1.0 ] ~

  1 /*
  2  * Copyright 2008 Hans Leidekker for CodeWeavers
  3  *
  4  * This library is free software; you can redistribute it and/or
  5  * modify it under the terms of the GNU Lesser General Public
  6  * License as published by the Free Software Foundation; either
  7  * version 2.1 of the License, or (at your option) any later version.
  8  *
  9  * This library is distributed in the hope that it will be useful,
 10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
 11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 12  * Lesser General Public License for more details.
 13  *
 14  * You should have received a copy of the GNU Lesser General Public
 15  * License along with this library; if not, write to the Free Software
 16  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301, USA
 17  */
 18 
 19 #define WIN32_LEAN_AND_MEAN
 20 
 21 #include <windows.h>
 22 #include "wine/debug.h"
 23 
 24 WINE_DEFAULT_DEBUG_CHANNEL(termsv);
 25 
 26 static WCHAR termserviceW[] = {'T','e','r','m','S','e','r','v','i','c','e',0};
 27 
 28 static SERVICE_STATUS_HANDLE service_handle;
 29 static HANDLE stop_event;
 30 
 31 static DWORD WINAPI service_handler( DWORD ctrl, DWORD event_type, LPVOID event_data, LPVOID context )
 32 {
 33     SERVICE_STATUS status;
 34 
 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;
 41 
 42     switch(ctrl)
 43     {
 44     case SERVICE_CONTROL_STOP:
 45     case SERVICE_CONTROL_SHUTDOWN:
 46         WINE_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         WINE_FIXME( "got service ctrl %x\n", ctrl );
 54         status.dwCurrentState = SERVICE_RUNNING;
 55         SetServiceStatus( service_handle, &status );
 56         return NO_ERROR;
 57     }
 58 }
 59 
 60 static void WINAPI ServiceMain( DWORD argc, LPWSTR *argv )
 61 {
 62     SERVICE_STATUS status;
 63 
 64     WINE_TRACE( "starting service\n" );
 65 
 66     stop_event = CreateEventW( NULL, TRUE, FALSE, NULL );
 67 
 68     service_handle = RegisterServiceCtrlHandlerExW( termserviceW, service_handler, NULL );
 69     if (!service_handle)
 70         return;
 71 
 72     status.dwServiceType             = SERVICE_WIN32;
 73     status.dwCurrentState            = SERVICE_RUNNING;
 74     status.dwControlsAccepted        = SERVICE_ACCEPT_STOP | SERVICE_ACCEPT_SHUTDOWN;
 75     status.dwWin32ExitCode           = 0;
 76     status.dwServiceSpecificExitCode = 0;
 77     status.dwCheckPoint              = 0;
 78     status.dwWaitHint                = 10000;
 79     SetServiceStatus( service_handle, &status );
 80 
 81     WaitForSingleObject( stop_event, INFINITE );
 82 
 83     status.dwCurrentState     = SERVICE_STOPPED;
 84     status.dwControlsAccepted = 0;
 85     SetServiceStatus( service_handle, &status );
 86     WINE_TRACE( "service stopped\n" );
 87 }
 88 
 89 int wmain( int argc, WCHAR *argv[] )
 90 {
 91     static const SERVICE_TABLE_ENTRYW service_table[] =
 92     {
 93         { termserviceW, ServiceMain },
 94         { NULL, NULL }
 95     };
 96 
 97     StartServiceCtrlDispatcherW( service_table );
 98     return 0;
 99 }
100 

~ [ source navigation ] ~ [ diff markup ] ~ [ identifier search ] ~ [ freetext search ] ~ [ file search ] ~

This page was automatically generated by the LXR engine.
Visit the LXR main site for more information.