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