OSDN Git Service

Make <winreg.h> header effectively self-contained.
[mingw/mingw-org-wsl.git] / w32api / include / nspapi.h
1 /*
2  * nspapi.h
3  *
4  * Windows Sockets Namespace Service Provider API definitions.
5  *
6  *
7  * $Id$
8  *
9  * Written by Anders Norlander <anorland@hem2.passagen.se>
10  * Copyright (C) 1998, 1999, 2002, 2004, 2017, MinGW.org Project
11  *
12  *
13  * Permission is hereby granted, free of charge, to any person obtaining a
14  * copy of this software and associated documentation files (the "Software"),
15  * to deal in the Software without restriction, including without limitation
16  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
17  * and/or sell copies of the Software, and to permit persons to whom the
18  * Software is furnished to do so, subject to the following conditions:
19  *
20  * The above copyright notice and this permission notice (including the next
21  * paragraph) shall be included in all copies or substantial portions of the
22  * Software.
23  *
24  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
25  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
26  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
27  * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
28  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
29  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
30  * DEALINGS IN THE SOFTWARE.
31  *
32  */
33 #ifndef _NSPAPI_H
34 #pragma GCC system_header
35
36 /* <winsock2.h> will include <nspapi.i> selectively, to resolve circular
37  * definition references; thus...
38  */
39 #ifndef __WINSOCK2_H_SOURCED__
40 /* ...only when NOT engaged in such selective inclusion, do we process
41  * the entire content of <nspapi.h>; furthermore, before we DO process
42  * the full content, we must process the WinSock API declarations from
43  * <winsock.h> or <winsock2.h>, BEFORE we define the <nspapi.h> repeat
44  * inclusion guard, so that <winsock2.h> may, if necessary, recurse to
45  * access the selectively exposed content.  Inclusion of the following
46  * private header will declare the necessary WinSock API, choosing to
47  * include either <winsock.h> or <winsock2.h> by default, on the same
48  * basis as the similar choice made in <windows.h>
49  */
50 #include "_winsock.h"
51
52 /* We can now be confident that the WinSock API has been appropriately
53  * declared; we may now define the <nspapi.h> repeat inclusion guard.
54  */
55 #define _NSPAPI_H
56
57 #define NS_ALL                                   0
58
59 #define NS_SAP                                   1
60 #define NS_NDS                                   2
61 #define NS_PEER_BROWSE                           3
62
63 #define NS_TCPIP_LOCAL                          10
64 #define NS_TCPIP_HOSTS                          11
65 #define NS_DNS                                  12
66 #define NS_NETBT                                13
67 #define NS_WINS                                 14
68
69 #define NS_NBP                                  20
70
71 #define NS_MS                                   30
72 #define NS_STDA                                 31
73 #define NS_NTDS                                 32
74
75 #define NS_X500                                 40
76 #define NS_NIS                                  41
77 #define NS_NISPLUS                              42
78
79 #define NS_WRQ                                  50
80
81 #define SERVICE_REGISTER                         1
82 #define SERVICE_DEREGISTER                       2
83 #define SERVICE_FLUSH                            3
84 #define SERVICE_FLAG_HARD               0x00000002
85
86 #endif  /* !__WINSOCK2_H_SOURCED__ */
87
88 #ifndef RC_INVOKED
89 #if ! (defined _NSPAPI_H && defined _WINSOCK2_H)
90 /* The following definitions are exposed either when <nspapi.h> is included
91  * directly, or when selectively included by <winsock2.h>, but we must take
92  * care to define them only on the first time of reading.
93  *
94  * We need a complete definition for the BLOB data type, which is provided
95  * in "wtypes.h", (and possibly exposed due to prior selective inclusion by
96  * <winsock2.h>); if neither of these have been included previously, we may
97  * acquire the requisite definition by selective inclusion now.
98  */
99 #define __NSPAPI_H_SOURCED__  1
100 #include "wtypes.h"
101
102 _BEGIN_C_DECLS
103
104 /* Technically, according to MSDN, the SOCKET_ADDRESS structure should be
105  * defined in <winsock2.h>, which has not necessarily been included by the
106  * time we get to here, yet the CSADDR_INFO structure, (which is correctly
107  * defined in this file), requires its full definition.  Furthermore, the
108  * CSADDR_INFO structure is representative of the data which is returned
109  * by the GetAddressByName() function, (also declared in this file), which
110  * is declared as deprecated in WinSock v2, (and thus, we would not expect
111  * any such dependency on this WinSock v2 specific <winsock2.h> data type).
112  * This Microsoft API design is critically flawed, but we can mitigate the
113  * fault by defining the SOCKET_ADDRESS structure here, whence we make it
114  * available to <winsock2.h> via selective inclusion.
115  */
116 typedef
117 struct _SOCKET_ADDRESS
118 { LPSOCKADDR             lpSockaddr;
119   INT                    iSockaddrLength;
120 } SOCKET_ADDRESS, *PSOCKET_ADDRESS, *LPSOCKET_ADDRESS;
121
122 /* Notwithstanding that, according to MSDN,  the CSADDR_INFO structure is
123  * correctly defined below, (it should not be defined in <winsock2.h>, and
124  * user code should include <nspapi.h> to obtain the complete definition),
125  * <winsock2.h> DOES define the WSAQUERYSET data type, which requires at
126  * least an incomplete type definition for the LPCSADDR_INFO pointer type;
127  * thus, it is convenient to expose this incomplete definition when this
128  * file, <nspapi.h>, is selectively included by <winsock2.h>, whereas the
129  * complete definition of the CSADDR_INFO data type may be deferred until
130  * the user includes <nspapi.h> directly.
131  */
132 typedef struct _CSADDR_INFO  CSADDR_INFO, *PCSADDR_INFO, *LPCSADDR_INFO;
133
134 _END_C_DECLS
135
136 #undef __NSPAPI_H_SOURCED__
137 #endif  /* ! (_NSPAPI_H && _WINSOCK2_H) */
138
139 #ifdef _NSPAPI_H
140 /* This indicates that <nspapi.h> has been included directly...
141  */
142 _BEGIN_C_DECLS
143
144 /* ...thus it is now appropriate to provide the complete type definition
145  * for the CSADDR_INFO structure...
146  */
147 struct _CSADDR_INFO
148 { SOCKET_ADDRESS         LocalAddr;
149   SOCKET_ADDRESS         RemoteAddr;
150   INT                    iSocketType;
151   INT                    iProtocol;
152 };
153
154 /* ...in addition to other data types, and function prototypes, which are
155  * specific to this header file.
156  */
157 typedef
158 struct _SERVICE_ADDRESS
159 { DWORD                  dwAddressType;
160   DWORD                  dwAddressFlags;
161   DWORD                  dwAddressLength;
162   DWORD                  dwPrincipalLength;
163   BYTE                  *lpAddress;
164   BYTE                  *lpPrincipal;
165 } SERVICE_ADDRESS;
166
167 typedef
168 struct _SERVICE_ADDRESSES
169 { DWORD                  dwAddressCount;
170   SERVICE_ADDRESS        Addresses[1];
171 } SERVICE_ADDRESSES, *PSERVICE_ADDRESSES, *LPSERVICE_ADDRESSES;
172
173 typedef
174 struct _SERVICE_INFOA
175 { LPGUID                 lpServiceType;
176   LPSTR                  lpServiceName;
177   LPSTR                  lpComment;
178   LPSTR                  lpLocale;
179   DWORD                  dwDisplayHint;
180   DWORD                  dwVersion;
181   DWORD                  dwTime;
182   LPSTR                  lpMachineName;
183   LPSERVICE_ADDRESSES    lpServiceAddress;
184   BLOB                   ServiceSpecificInfo;
185 } SERVICE_INFOA, *LPSERVICE_INFOA;
186
187 typedef
188 struct _SERVICE_INFOW
189 { LPGUID                 lpServiceType;
190   LPWSTR                 lpServiceName;
191   LPWSTR                 lpComment;
192   LPWSTR                 lpLocale;
193   DWORD                  dwDisplayHint;
194   DWORD                  dwVersion;
195   DWORD                  dwTime;
196   LPWSTR                 lpMachineName;
197   LPSERVICE_ADDRESSES    lpServiceAddress;
198   BLOB                   ServiceSpecificInfo;
199 } SERVICE_INFOW, *LPSERVICE_INFOW;
200
201 typedef __AW_ALIAS__(SERVICE_INFO), *LPSERVICE_INFO;
202 typedef void *LPSERVICE_ASYNC_INFO;
203
204 #define SetService __AW_SUFFIXED__(SetService)
205 INT WINAPI SetServiceA
206   ( DWORD, DWORD, DWORD, LPSERVICE_INFOA, LPSERVICE_ASYNC_INFO, LPDWORD
207   );
208 INT WINAPI SetServiceW
209   ( DWORD, DWORD, DWORD, LPSERVICE_INFOW, LPSERVICE_ASYNC_INFO, LPDWORD
210   );
211
212 #define GetAddressByName __AW_SUFFIXED__(GetAddressByName)
213 INT WINAPI GetAddressByNameA
214   ( DWORD, LPGUID, LPSTR, LPINT, DWORD, LPSERVICE_ASYNC_INFO, LPVOID,
215     LPDWORD, LPSTR, LPDWORD
216   );
217 INT WINAPI GetAddressByNameW
218   ( DWORD, LPGUID, LPWSTR, LPINT, DWORD, LPSERVICE_ASYNC_INFO, LPVOID,
219     LPDWORD, LPWSTR, LPDWORD
220   );
221
222 #define _SERVICE_INFO __AW_SUFFIXED__(SERVICE_INFO)
223
224 _END_C_DECLS
225
226 #endif  /* _NSPAPI_H */
227 #endif  /* ! RC_INVOKED */
228
229 #endif  /* _NSPAPI_H: $RCSfile$: end of file */