Add Ian to the team
[privoxy.git] / w32svrapi.h
1 #ifndef W32_SVRAPI_H_INCLUDED
2 #define W32_SVRAPI_H_INCLUDED
3 #define W32_SVRAPI_H_VERSION "$Id: w32svrapi.h,v 1.2 2009/05/16 13:27:20 fabiankeil Exp $"
4 /*********************************************************************
5  *
6  * File        :  $Source: /cvsroot/ijbswa/current/w32svrapi.h,v $
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  *********************************************************************/
51
52
53 #ifdef __cplusplus
54 extern "C" {
55 #endif
56
57 #ifdef _WIN32
58
59
60 extern char szThisServiceName[];
61 extern BOOL bRunAsService;
62 extern SERVICE_TABLE_ENTRY w32ServiceDispatchTable[];
63
64 extern BOOL install_service(const char *service_name);
65 extern BOOL uninstall_service(const char *service_name);
66 extern void w32_service_exit_notify(void);
67 extern void w32_set_service_cwd(void);
68 extern void w32_service_listen_loop(void *p);
69
70
71 extern BOOL CanSystemSupportServices();
72
73
74 extern SC_HANDLE w32_open_sc_manager(
75   LPCTSTR lpMachineName,   /* computer name */
76   LPCTSTR lpDatabaseName,  /* SCM database name */
77   DWORD dwDesiredAccess);  /* access type */
78
79
80 extern BOOL w32_close_service_handle(
81   SC_HANDLE hSCObject);    /* handle to service or SCM object */
82
83
84 extern SC_HANDLE w32_open_service(
85   SC_HANDLE hSCManager,    /* handle to SCM database */
86   LPCTSTR lpServiceName,   /* service name */
87   DWORD dwDesiredAccess);  /* access */
88
89
90 extern SC_HANDLE w32_create_service(
91   SC_HANDLE hSCManager,       /* handle to SCM database */
92   LPCTSTR lpServiceName,      /* name of service to start */
93   LPCTSTR lpDisplayName,      /* display name */
94   DWORD dwDesiredAccess,      /* type of access to service */
95   DWORD dwServiceType,        /* type of service */
96   DWORD dwStartType,          /* when to start service */
97   DWORD dwErrorControl,       /* severity of service failure */
98   LPCTSTR lpBinaryPathName,   /* name of binary file */
99   LPCTSTR lpLoadOrderGroup,   /* name of load ordering group */
100   LPDWORD lpdwTagId,          /* tag identifier */
101   LPCTSTR lpDependencies,     /* array of dependency names */
102   LPCTSTR lpServiceStartName, /* account name */
103   LPCTSTR lpPassword);        /* account password */
104
105
106 extern BOOL w32_delete_service(
107   SC_HANDLE hService);   /* handle to service */
108
109
110 extern BOOL w32_query_service_config(
111   SC_HANDLE hService,                     /* handle to service */
112   LPQUERY_SERVICE_CONFIG lpServiceConfig, /* buffer */
113   DWORD cbBufSize,                        /* size of buffer */
114   LPDWORD pcbBytesNeeded);                /* bytes needed */
115
116
117 extern BOOL w32_start_service_ctrl_dispatcher(
118   CONST LPSERVICE_TABLE_ENTRY lpServiceTable);   /* service table */
119
120
121 extern SERVICE_STATUS_HANDLE w32_register_service_ctrl_handler(
122   LPCTSTR lpServiceName,               /* service name */
123   LPHANDLER_FUNCTION lpHandlerProc);   /* handler function */
124
125
126 extern BOOL w32_set_service_status(
127   SERVICE_STATUS_HANDLE hServiceStatus,   /* service status handle */
128   LPSERVICE_STATUS lpServiceStatus);      /* status buffer */
129
130
131 #endif  /* def _WIN32 */
132
133
134 #ifdef __cplusplus
135 } /* extern "C" */
136 #endif
137
138 #endif /* ndef W32_SVRAPI_H_INCLUDED */
139