~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

Viewing changes to sql/nt_servc.h

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/**
 
2
  @file
 
3
 
 
4
  @brief
 
5
  Windows NT Service class library
 
6
 
 
7
  Copyright Abandoned 1998 Irena Pancirov - Irnet Snc
 
8
  This file is public domain and comes with NO WARRANTY of any kind
 
9
*/
 
10
 
 
11
// main application thread
 
12
typedef void (*THREAD_FC)(void *);
 
13
 
 
14
class NTService
 
15
{
 
16
  public:
 
17
    NTService();
 
18
   ~NTService();
 
19
 
 
20
    BOOL    bOsNT;            ///< true if OS is NT, false for Win95
 
21
    //install optinos
 
22
    DWORD   dwDesiredAccess;
 
23
    DWORD   dwServiceType;
 
24
    DWORD   dwStartType;
 
25
    DWORD   dwErrorControl;
 
26
 
 
27
    LPSTR   szLoadOrderGroup;
 
28
    LPDWORD lpdwTagID;
 
29
    LPSTR   szDependencies;
 
30
    OSVERSIONINFO osVer;
 
31
 
 
32
    // time-out (in milisec)
 
33
    int     nStartTimeOut;
 
34
    int     nStopTimeOut;
 
35
    int     nPauseTimeOut;
 
36
    int     nResumeTimeOut;
 
37
 
 
38
    //
 
39
    DWORD   my_argc;
 
40
    LPTSTR *my_argv;
 
41
    HANDLE  hShutdownEvent;
 
42
    int     nError;
 
43
    DWORD   dwState;
 
44
 
 
45
    BOOL GetOS();             // returns TRUE if WinNT
 
46
    BOOL IsNT() { return bOsNT;}
 
47
    //init service entry point
 
48
    long Init(LPCSTR szInternName,void *ServiceThread);
 
49
 
 
50
    //application shutdown event
 
51
    void SetShutdownEvent(HANDLE hEvent){ hShutdownEvent=hEvent; }
 
52
 
 
53
 
 
54
    //service install / un-install
 
55
    BOOL Install(int startType,LPCSTR szInternName,LPCSTR szDisplayName,
 
56
                 LPCSTR szFullPath, LPCSTR szAccountName=NULL,
 
57
                 LPCSTR szPassword=NULL);
 
58
    BOOL SeekStatus(LPCSTR szInternName, int OperationType);
 
59
    BOOL Remove(LPCSTR szInternName);
 
60
    BOOL IsService(LPCSTR ServiceName);
 
61
    BOOL got_service_option(char **argv, char *service_option);
 
62
    BOOL is_super_user();
 
63
 
 
64
    /* 
 
65
      SetRunning() is to be called by the application 
 
66
      when initialization completes and it can accept
 
67
      stop request
 
68
    */
 
69
    void SetRunning(void);
 
70
 
 
71
    /*
 
72
      Stop() is to be called by the application to stop 
 
73
      the service
 
74
    */
 
75
    void Stop(void); 
 
76
 
 
77
  protected:
 
78
    LPSTR                  ServiceName;
 
79
    HANDLE                 hExitEvent;
 
80
    SERVICE_STATUS_HANDLE  hServiceStatusHandle;
 
81
    BOOL                   bPause;
 
82
    BOOL                   bRunning;
 
83
    HANDLE                 hThreadHandle;
 
84
    THREAD_FC              fpServiceThread;
 
85
 
 
86
    void PauseService();
 
87
    void ResumeService();
 
88
    void StopService();
 
89
    BOOL StartService();
 
90
 
 
91
    static void ServiceMain(DWORD argc, LPTSTR *argv);
 
92
    static void ServiceCtrlHandler (DWORD ctrlCode);
 
93
 
 
94
    void Exit(DWORD error);
 
95
    BOOL SetStatus (DWORD dwCurrentState,DWORD dwWin32ExitCode,
 
96
                    DWORD dwServiceSpecificExitCode,
 
97
                    DWORD dwCheckPoint,DWORD dwWaitHint);
 
98
 
 
99
};
 
100
/* ------------------------- the end -------------------------------------- */