~ubuntu-branches/ubuntu/saucy/openvpn/saucy-proposed

« back to all changes in this revision

Viewing changes to service-win32/service.h

  • Committer: Package Import Robot
  • Author(s): Stéphane Graber
  • Date: 2013-05-24 17:42:45 UTC
  • mfrom: (1.1.19) (10.2.22 sid)
  • Revision ID: package-import@ubuntu.com-20130524174245-g9y6wlforycufqy5
Tags: 2.3.1-2ubuntu1
* Merge from Debian unstable. Remaining changes:
  - debian/openvpn.init.d:
    + Do not use start-stop-daemon and </dev/null to avoid blocking boot.
    + Show per-VPN result messages.
    + Add "--script-security 2" by default for backwards compatabliity.

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
 
/*---------------------------------------------------------------------------
2
 
THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
3
 
ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED
4
 
TO THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
5
 
PARTICULAR PURPOSE.
6
 
 
7
 
Copyright (C) 1993 - 2000.  Microsoft Corporation.  All rights reserved.
8
 
 
9
 
 MODULE: service.h
10
 
 
11
 
 Comments:  The use of this header file and the accompanying service.c
12
 
 file simplifies the process of writting a service.  You as a developer
13
 
 simply need to follow the TODO's outlined in this header file, and
14
 
 implement the ServiceStart() and ServiceStop() functions.
15
 
 
16
 
 There is no need to modify the code in service.c.  Just add service.c
17
 
 to your project and link with the following libraries...
18
 
 
19
 
 libcmt.lib kernel32.lib advapi.lib shell32.lib
20
 
 
21
 
 This code also supports unicode.  Be sure to compile both service.c and
22
 
 and code #include "service.h" with the same Unicode setting.
23
 
 
24
 
 Upon completion, your code will have the following command line interface
25
 
 
26
 
 <service exe> -?                to display this list
27
 
 <service exe> -install          to install the service
28
 
 <service exe> -remove           to remove the service
29
 
 <service exe> -debug <params>   to run as a console app for debugging
30
 
 
31
 
 Note: This code also implements Ctrl+C and Ctrl+Break handlers
32
 
       when using the debug option.  These console events cause
33
 
       your ServiceStop routine to be called
34
 
 
35
 
       Also, this code only handles the OWN_SERVICE service type
36
 
       running in the LOCAL_SYSTEM security context.
37
 
 
38
 
       To control your service ( start, stop, etc ) you may use the
39
 
       Services control panel applet or the NET.EXE program.
40
 
 
41
 
       To aid in writing/debugging service, the
42
 
       SDK contains a utility (MSTOOLS\BIN\SC.EXE) that
43
 
       can be used to control, configure, or obtain service status.
44
 
       SC displays complete status for any service/driver
45
 
       in the service database, and allows any of the configuration
46
 
       parameters to be easily changed at the command line.
47
 
       For more information on SC.EXE, type SC at the command line.
48
 
 
49
 
 
50
 
------------------------------------------------------------------------------*/
51
 
 
52
 
#ifndef _SERVICE_H
53
 
#define _SERVICE_H
54
 
 
55
 
 
56
 
#ifdef __cplusplus
57
 
extern "C" {
58
 
#endif
59
 
 
60
 
#include "config.h"
61
 
 
62
 
//////////////////////////////////////////////////////////////////////////////
63
 
//// todo: change to desired strings
64
 
////
65
 
// name of the executable
66
 
#define SZAPPNAME            PACKAGE "serv"
67
 
// internal name of the service
68
 
#define SZSERVICENAME        PACKAGE_NAME "Service"
69
 
// displayed name of the service
70
 
#define SZSERVICEDISPLAYNAME PACKAGE_NAME " Service"
71
 
// list of service dependencies - "dep1\0dep2\0\0"
72
 
#define SZDEPENDENCIES       TAP_ID "\0Dhcp\0\0"
73
 
//////////////////////////////////////////////////////////////////////////////
74
 
 
75
 
 
76
 
 
77
 
//////////////////////////////////////////////////////////////////////////////
78
 
//// todo: ServiceStart()must be defined by in your code.
79
 
////       The service should use ReportStatusToSCMgr to indicate
80
 
////       progress.  This routine must also be used by StartService()
81
 
////       to report to the SCM when the service is running.
82
 
////
83
 
////       If a ServiceStop procedure is going to take longer than
84
 
////       3 seconds to execute, it should spawn a thread to
85
 
////       execute the stop code, and return.  Otherwise, the
86
 
////       ServiceControlManager will believe that the service has
87
 
////       stopped responding
88
 
////
89
 
   VOID ServiceStart(DWORD dwArgc, LPTSTR *lpszArgv);
90
 
   VOID ServiceStop();
91
 
//////////////////////////////////////////////////////////////////////////////
92
 
 
93
 
 
94
 
 
95
 
//////////////////////////////////////////////////////////////////////////////
96
 
//// The following are procedures which
97
 
//// may be useful to call within the above procedures,
98
 
//// but require no implementation by the user.
99
 
//// They are implemented in service.c
100
 
 
101
 
//
102
 
//  FUNCTION: ReportStatusToSCMgr()
103
 
//
104
 
//  PURPOSE: Sets the current status of the service and
105
 
//           reports it to the Service Control Manager
106
 
//
107
 
//  PARAMETERS:
108
 
//    dwCurrentState - the state of the service
109
 
//    dwWin32ExitCode - error code to report
110
 
//    dwWaitHint - worst case estimate to next checkpoint
111
 
//
112
 
//  RETURN VALUE:
113
 
//    TRUE  - success
114
 
//    FALSE - failure
115
 
//
116
 
   BOOL ReportStatusToSCMgr(DWORD dwCurrentState, DWORD dwWin32ExitCode, DWORD dwWaitHint);
117
 
 
118
 
 
119
 
//
120
 
//  FUNCTION: AddToMessageLog(LPTSTR lpszMsg)
121
 
//
122
 
//  PURPOSE: Allows any thread to log an error message
123
 
//
124
 
//  PARAMETERS:
125
 
//    lpszMsg - text for message
126
 
//
127
 
//  RETURN VALUE:
128
 
//    none
129
 
//
130
 
#  define MSG_FLAGS_ERROR     (1<<0)
131
 
#  define MSG_FLAGS_SYS_CODE  (1<<1)
132
 
   void AddToMessageLog(DWORD flags, LPTSTR lpszMsg);
133
 
   void ResetError (void);
134
 
//////////////////////////////////////////////////////////////////////////////
135
 
 
136
 
 
137
 
#ifdef __cplusplus
138
 
}
139
 
#endif
140
 
 
141
 
#endif