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