1 /***********************************************************************\
2 *                                nspapi.d                               *
3 *                                                                       *
4 *                       Windows API header module                       *
5 *                                                                       *
6 *                 Translated from MinGW Windows headers                 *
7 *                           by Stewart Gordon                           *
8 *                                                                       *
9 *                       Placed into public domain                       *
10 \***********************************************************************/
11 module windows.nspapi;
12 
13 private import windows.basetyps, windows.windef;
14 nothrow:
15 // FIXME: check types of constants
16 
17 enum {
18 	NS_ALL         =  0,
19 
20 	NS_SAP,
21 	NS_NDS,
22 	NS_PEER_BROWSE,
23 
24 	NS_TCPIP_LOCAL = 10,
25 	NS_TCPIP_HOSTS,
26 	NS_DNS,
27 	NS_NETBT,
28 	NS_WINS,
29 
30 	NS_NBP         = 20,
31 
32 	NS_MS          = 30,
33 	NS_STDA,
34 	NS_NTDS,
35 
36 	NS_X500        = 40,
37 	NS_NIS,
38 	NS_NISPLUS,
39 
40 	NS_WRQ         = 50
41 }
42 
43 enum {
44 	SERVICE_REGISTER   = 1,
45 	SERVICE_DEREGISTER = 2,
46 	SERVICE_FLUSH      = 3,
47 	SERVICE_FLAG_HARD  = 2
48 }
49 
50 /*	MinGW makes the next section conditional on winsock.h or winsock2.h
51  *	being included.  But that doesn't translate well into D.
52  */
53 version (Win32_Winsock1) {
54 	import windows.winsock;
55 } else {
56 	import windows.winsock2;
57 }
58 
59 struct SOCKET_ADDRESS {
60 	LPSOCKADDR lpSockaddr;
61 	INT        iSockaddrLength;
62 }
63 alias SOCKET_ADDRESS* PSOCKET_ADDRESS, LPSOCKET_ADDRESS;
64 
65 struct CSADDR_INFO {
66 	SOCKET_ADDRESS LocalAddr;
67 	SOCKET_ADDRESS RemoteAddr;
68 	INT            iSocketType;
69 	INT            iProtocol;
70 }
71 alias CSADDR_INFO* PCSADDR_INFO, LPCSADDR_INFO;
72 
73 struct BLOB {
74 	ULONG cbSize;
75 	BYTE* pBlobData;
76 }
77 alias BLOB* PBLOB, LPBLOB;
78 
79 struct SERVICE_ADDRESS {
80 	DWORD dwAddressType;
81 	DWORD dwAddressFlags;
82 	DWORD dwAddressLength;
83 	DWORD dwPrincipalLength;
84 	BYTE* lpAddress;
85 	BYTE* lpPrincipal;
86 }
87 
88 struct SERVICE_ADDRESSES {
89 	DWORD           dwAddressCount;
90 	SERVICE_ADDRESS _Addresses;
91 
92 	SERVICE_ADDRESS* Addresses() { return &_Addresses; }
93 }
94 alias SERVICE_ADDRESSES* PSERVICE_ADDRESSES, LPSERVICE_ADDRESSES;
95 
96 struct SERVICE_INFOA {
97 	LPGUID lpServiceType;
98 	LPSTR  lpServiceName;
99 	LPSTR  lpComment;
100 	LPSTR  lpLocale;
101 	DWORD  dwDisplayHint;
102 	DWORD  dwVersion;
103 	DWORD  dwTime;
104 	LPSTR  lpMachineName;
105 	LPSERVICE_ADDRESSES lpServiceAddress;
106 	BLOB   ServiceSpecificInfo;
107 }
108 alias SERVICE_INFOA* LPSERVICE_INFOA;
109 
110 struct SERVICE_INFOW {
111 	LPGUID lpServiceType;
112 	LPWSTR lpServiceName;
113 	LPWSTR lpComment;
114 	LPWSTR lpLocale;
115 	DWORD  dwDisplayHint;
116 	DWORD  dwVersion;
117 	DWORD  dwTime;
118 	LPWSTR lpMachineName;
119 	LPSERVICE_ADDRESSES lpServiceAddress;
120 	BLOB   ServiceSpecificInfo;
121 }
122 alias SERVICE_INFOW* LPSERVICE_INFOW;
123 
124 alias void* LPSERVICE_ASYNC_INFO;
125 
126 extern (Windows) {
127 	INT SetServiceA(DWORD, DWORD, DWORD, LPSERVICE_INFOA,
128 	  LPSERVICE_ASYNC_INFO, LPDWORD);
129 	INT SetServiceW(DWORD, DWORD, DWORD, LPSERVICE_INFOW,
130 	  LPSERVICE_ASYNC_INFO, LPDWORD);
131 	INT GetAddressByNameA(DWORD, LPGUID, LPSTR, LPINT, DWORD,
132 	  LPSERVICE_ASYNC_INFO, LPVOID, LPDWORD, LPSTR, LPDWORD);
133 	INT GetAddressByNameW(DWORD, LPGUID, LPWSTR, LPINT, DWORD,
134 	  LPSERVICE_ASYNC_INFO, LPVOID, LPDWORD, LPWSTR, LPDWORD);
135 }
136 
137 version (Unicode) {
138 	alias SERVICE_INFOW SERVICE_INFO;
139 	alias SetServiceW SetService;
140 	alias GetAddressByNameW GetAddressByName;
141 } else {
142 	alias SERVICE_INFOA SERVICE_INFO;
143 	alias SetServiceA SetService;
144 	alias GetAddressByNameA GetAddressByName;
145 }
146 
147 alias SERVICE_INFO _SERVICE_INFO;
148 alias SERVICE_INFO* LPSERVICE_INFO;