OSDN Git Service

Refactor <wtypes.h> vs. <nspapi.h> and WinSock headers.
[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.
46  */
47 #ifndef _WINSOCK_H
48 /* We must include <winsock.h> or <winsock2.h>; (we favour <winsock2.h>
49  * over <winsock.h>, on the same basis as our <windows.h> does).
50  */
51 #include <sdkddkver.h>
52 #if _WIN32_WINNT >= _WIN32_WINNT_WIN2K
53 #include <winsock2.h>
54
55 #else   /* _WIN32_WINNT < Win2K */
56 #include <winsock.h>
57 #endif
58
59 #endif  /* !_WINSOCK_H */
60 /* We can now be confident that the WinSock API has been appropriately
61  * declared; we may now define the <nspapi.h> repeat inclusion guard.
62  */
63 #define _NSPAPI_H
64
65 #define NS_ALL                                   0
66
67 #define NS_SAP                                   1
68 #define NS_NDS                                   2
69 #define NS_PEER_BROWSE                           3
70
71 #define NS_TCPIP_LOCAL                          10
72 #define NS_TCPIP_HOSTS                          11
73 #define NS_DNS                                  12
74 #define NS_NETBT                                13
75 #define NS_WINS                                 14
76
77 #define NS_NBP                                  20
78
79 #define NS_MS                                   30
80 #define NS_STDA                                 31
81 #define NS_NTDS                                 32
82
83 #define NS_X500                                 40
84 #define NS_NIS                                  41
85 #define NS_NISPLUS                              42
86
87 #define NS_WRQ                                  50
88
89 #define SERVICE_REGISTER                         1
90 #define SERVICE_DEREGISTER                       2
91 #define SERVICE_FLUSH                            3
92 #define SERVICE_FLAG_HARD               0x00000002
93
94 #endif  /* !__WINSOCK2_H_SOURCED__ */
95
96 #ifndef RC_INVOKED
97 #if ! (defined _NSPAPI_H && defined _WINSOCK2_H)
98 /* The following definitions are exposed either when <nspapi.h> is included
99  * directly, or when selectively included by <winsock2.h>, but we must take
100  * care to define them only on the first time of reading.
101  *
102  * We need a complete definition for the BLOB data type, which is provided
103  * in "wtypes.h", (and possibly exposed due to prior selective inclusion by
104  * <winsock2.h>); if neither of these have been included previously, we may
105  * acquire the requisite definition by selective inclusion now.
106  */
107 #define __NSPAPI_H_SOURCED__  1
108 #include "wtypes.h"
109
110 _BEGIN_C_DECLS
111
112 /* Technically, according to MSDN, the SOCKET_ADDRESS structure should be
113  * defined in <winsock2.h>, which has not necessarily been included by the
114  * time we get to here, yet the CSADDR_INFO structure, (which is correctly
115  * defined in this file), requires its full definition.  Furthermore, the
116  * CSADDR_INFO structure is representative of the data which is returned
117  * by the GetAddressByName() function, (also declared in this file), which
118  * is declared as deprecated in WinSock v2, (and thus, we would not expect
119  * any such dependency on this WinSock v2 specific <winsock2.h> data type).
120  * This Microsoft API design is critically flawed, but we can mitigate the
121  * fault by defining the SOCKET_ADDRESS structure here, whence we make it
122  * available to <winsock2.h> via selective inclusion.
123  */
124 typedef
125 struct _SOCKET_ADDRESS
126 { LPSOCKADDR             lpSockaddr;
127   INT                    iSockaddrLength;
128 } SOCKET_ADDRESS, *PSOCKET_ADDRESS, *LPSOCKET_ADDRESS;
129
130 /* Notwithstanding that, according to MSDN,  the CSADDR_INFO structure is
131  * correctly defined below, (it should not be defined in <winsock2.h>, and
132  * user code should include <nspapi.h> to obtain the complete definition),
133  * <winsock2.h> DOES define the WSAQUERYSET data type, which requires at
134  * least an incomplete type definition for the LPCSADDR_INFO pointer type;
135  * thus, it is convenient to expose this incomplete definition when this
136  * file, <nspapi.h>, is selectively included by <winsock2.h>, whereas the
137  * complete definition of the CSADDR_INFO data type may be deferred until
138  * the user includes <nspapi.h> directly.
139  */
140 typedef struct _CSADDR_INFO  CSADDR_INFO, *PCSADDR_INFO, *LPCSADDR_INFO;
141
142 _END_C_DECLS
143
144 #undef __NSPAPI_H_SOURCED__
145 #endif  /* ! (_NSPAPI_H && _WINSOCK2_H) */
146
147 #ifdef _NSPAPI_H
148 /* This indicates that <nspapi.h> has been included directly...
149  */
150 _BEGIN_C_DECLS
151
152 /* ...thus it is now appropriate to provide the complete type definition
153  * for the CSADDR_INFO structure...
154  */
155 struct _CSADDR_INFO
156 { SOCKET_ADDRESS         LocalAddr;
157   SOCKET_ADDRESS         RemoteAddr;
158   INT                    iSocketType;
159   INT                    iProtocol;
160 };
161
162 /* ...in addition to other data types, and function prototypes, which are
163  * specific to this header file.
164  */
165 typedef
166 struct _SERVICE_ADDRESS
167 { DWORD                  dwAddressType;
168   DWORD                  dwAddressFlags;
169   DWORD                  dwAddressLength;
170   DWORD                  dwPrincipalLength;
171   BYTE                  *lpAddress;
172   BYTE                  *lpPrincipal;
173 } SERVICE_ADDRESS;
174
175 typedef
176 struct _SERVICE_ADDRESSES
177 { DWORD                  dwAddressCount;
178   SERVICE_ADDRESS        Addresses[1];
179 } SERVICE_ADDRESSES, *PSERVICE_ADDRESSES, *LPSERVICE_ADDRESSES;
180
181 typedef
182 struct _SERVICE_INFOA
183 { LPGUID                 lpServiceType;
184   LPSTR                  lpServiceName;
185   LPSTR                  lpComment;
186   LPSTR                  lpLocale;
187   DWORD                  dwDisplayHint;
188   DWORD                  dwVersion;
189   DWORD                  dwTime;
190   LPSTR                  lpMachineName;
191   LPSERVICE_ADDRESSES    lpServiceAddress;
192   BLOB                   ServiceSpecificInfo;
193 } SERVICE_INFOA, *LPSERVICE_INFOA;
194
195 typedef
196 struct _SERVICE_INFOW
197 { LPGUID                 lpServiceType;
198   LPWSTR                 lpServiceName;
199   LPWSTR                 lpComment;
200   LPWSTR                 lpLocale;
201   DWORD                  dwDisplayHint;
202   DWORD                  dwVersion;
203   DWORD                  dwTime;
204   LPWSTR                 lpMachineName;
205   LPSERVICE_ADDRESSES    lpServiceAddress;
206   BLOB                   ServiceSpecificInfo;
207 } SERVICE_INFOW, *LPSERVICE_INFOW;
208
209 typedef __AW_ALIAS__(SERVICE_INFO), *LPSERVICE_INFO;
210 typedef void *LPSERVICE_ASYNC_INFO;
211
212 #define SetService __AW_SUFFIXED__(SetService)
213 INT WINAPI SetServiceA
214   ( DWORD, DWORD, DWORD, LPSERVICE_INFOA, LPSERVICE_ASYNC_INFO, LPDWORD
215   );
216 INT WINAPI SetServiceW
217   ( DWORD, DWORD, DWORD, LPSERVICE_INFOW, LPSERVICE_ASYNC_INFO, LPDWORD
218   );
219
220 #define GetAddressByName __AW_SUFFIXED__(GetAddressByName)
221 INT WINAPI GetAddressByNameA
222   ( DWORD, LPGUID, LPSTR, LPINT, DWORD, LPSERVICE_ASYNC_INFO, LPVOID,
223     LPDWORD, LPSTR, LPDWORD
224   );
225 INT WINAPI GetAddressByNameW
226   ( DWORD, LPGUID, LPWSTR, LPINT, DWORD, LPSERVICE_ASYNC_INFO, LPVOID,
227     LPDWORD, LPWSTR, LPDWORD
228   );
229
230 #define _SERVICE_INFO __AW_SUFFIXED__(SERVICE_INFO)
231
232 _END_C_DECLS
233
234 #endif  /* _NSPAPI_H */
235 #endif  /* ! RC_INVOKED */
236
237 #endif  /* _NSPAPI_H: $RCSfile$: end of file */