also backup doc/pdf
[privoxy.git] / w32svrapi.h
1 #ifndef W32_SVRAPI_H_INCLUDED
2 #define W32_SVRAPI_H_INCLUDED
3 #define W32_SVRAPI_H_VERSION "$Id$"
4 /*********************************************************************
5  *
6  * File        :  $Source$
7  *
8  * Purpose     :  Win32 Services API for Privoxy.
9  *                Provides the implementation of an Win32 service to
10  *                allow the code to directly register and run as a
11  *                native Windows service application.
12  *
13  *                Since Win9x/ME platforms don't provide or support
14  *                running programs as services, this code uses runtime
15  *                loading and calling of the Win32 Service API, to
16  *                prevent the possibility of getting "entry point not
17  *                found" type errors on unsupported platforms. This adds
18  *                a little more complexity to the code, but it is worth
19  *                doing to provide that isolation.
20  *
21  * Copyright   :  Written by and Copyright (C) 2003 members of
22  *                the Privoxy team.  http://www.privoxy.org/
23  *
24  *                Written by and Copyright (C) 2003 Ian Cummings
25  *                <ian_a_c@hotmail.com>
26  *
27  *                Special thanks to Mates Dolák <matesek@post.cz> for
28  *                some very helpful feedback and suggestions during the
29  *                development of this code.
30  *
31  *
32  *                This program is free software; you can redistribute it 
33  *                and/or modify it under the terms of the GNU General
34  *                Public License as published by the Free Software
35  *                Foundation; either version 2 of the License, or (at
36  *                your option) any later version.
37  *
38  *                This program is distributed in the hope that it will
39  *                be useful, but WITHOUT ANY WARRANTY; without even the
40  *                implied warranty of MERCHANTABILITY or FITNESS FOR A
41  *                PARTICULAR PURPOSE.  See the GNU General Public
42  *                License for more details.
43  *
44  *                The GNU General Public License should be included with
45  *                this file.  If not, you can view it at
46  *                http://www.gnu.org/copyleft/gpl.html
47  *                or write to the Free Software Foundation, Inc., 59
48  *                Temple Place - Suite 330, Boston, MA  02111-1307, USA.
49  *
50  * Revisions   :
51  *    $Log$
52  *
53  *
54  *********************************************************************/
55 \f
56
57 #ifdef __cplusplus
58 extern "C" {
59 #endif
60
61 #ifdef _WIN32
62
63
64 extern char szThisServiceName[];
65 extern BOOL bRunAsService;
66 extern SERVICE_TABLE_ENTRY w32ServiceDispatchTable[];
67
68 extern BOOL install_service(const char *service_name);
69 extern BOOL uninstall_service(const char *service_name);
70 extern void w32_service_exit_notify(void);
71 extern void w32_set_service_cwd(void);
72 extern void w32_service_listen_loop(void *p);
73
74
75 extern BOOL CanSystemSupportServices();
76
77
78 extern SC_HANDLE w32_open_sc_manager(
79   LPCTSTR lpMachineName,   /* computer name */
80   LPCTSTR lpDatabaseName,  /* SCM database name */
81   DWORD dwDesiredAccess);  /* access type */
82
83
84 extern BOOL w32_close_service_handle(
85   SC_HANDLE hSCObject);    /* handle to service or SCM object */
86
87
88 extern SC_HANDLE w32_open_service(
89   SC_HANDLE hSCManager,    /* handle to SCM database */
90   LPCTSTR lpServiceName,   /* service name */
91   DWORD dwDesiredAccess);  /* access */
92
93
94 extern SC_HANDLE w32_create_service(
95   SC_HANDLE hSCManager,       /* handle to SCM database */
96   LPCTSTR lpServiceName,      /* name of service to start */
97   LPCTSTR lpDisplayName,      /* display name */
98   DWORD dwDesiredAccess,      /* type of access to service */
99   DWORD dwServiceType,        /* type of service */
100   DWORD dwStartType,          /* when to start service */
101   DWORD dwErrorControl,       /* severity of service failure */
102   LPCTSTR lpBinaryPathName,   /* name of binary file */
103   LPCTSTR lpLoadOrderGroup,   /* name of load ordering group */
104   LPDWORD lpdwTagId,          /* tag identifier */
105   LPCTSTR lpDependencies,     /* array of dependency names */
106   LPCTSTR lpServiceStartName, /* account name */
107   LPCTSTR lpPassword);        /* account password */
108
109
110 extern BOOL w32_delete_service(
111   SC_HANDLE hService);   /* handle to service */
112
113
114 extern BOOL w32_query_service_config(
115   SC_HANDLE hService,                     /* handle to service */
116   LPQUERY_SERVICE_CONFIG lpServiceConfig, /* buffer */
117   DWORD cbBufSize,                        /* size of buffer */
118   LPDWORD pcbBytesNeeded);                /* bytes needed */
119
120
121 extern BOOL w32_start_service_ctrl_dispatcher(
122   CONST LPSERVICE_TABLE_ENTRY lpServiceTable);   /* service table */
123
124
125 extern SERVICE_STATUS_HANDLE w32_register_service_ctrl_handler(
126   LPCTSTR lpServiceName,               /* service name */
127   LPHANDLER_FUNCTION lpHandlerProc);   /* handler function */
128
129
130 extern BOOL w32_set_service_status(
131   SERVICE_STATUS_HANDLE hServiceStatus,   /* service status handle */
132   LPSERVICE_STATUS lpServiceStatus);      /* status buffer */
133
134
135 #endif  /* def _WIN32 */
136
137
138 #ifdef __cplusplus
139 } /* extern "C" */
140 #endif
141
142 #endif /* ndef W32_SVRAPI_H_INCLUDED */
143