OSDN Git Service

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