1 | /* $Id: oslibnet.cpp,v 1.4 2001-09-05 10:27:54 bird Exp $
|
---|
2 | *
|
---|
3 | * Wrappers for OS/2 Netbios/Network/LAN API
|
---|
4 | *
|
---|
5 | * Copyright 2000 Patrick Haller (patrick.haller@innotek.de)
|
---|
6 | *
|
---|
7 | * Project Odin Software License can be found in LICENSE.TXT
|
---|
8 | *
|
---|
9 | */
|
---|
10 | #define INCL_BASE
|
---|
11 | #define INCL_DOSEXCEPTIONS
|
---|
12 | #define INCL_DOSMEMMGR
|
---|
13 | #define INCL_DOSPROCESS
|
---|
14 | #define INCL_DOSFILEMGR
|
---|
15 | #define INCL_DOSERRORS
|
---|
16 | #define INCL_NPIPES
|
---|
17 | #include <os2wrap.h> //Odin32 OS/2 api wrappers
|
---|
18 | #include <stdlib.h>
|
---|
19 | #include <stdio.h>
|
---|
20 | #include <string.h>
|
---|
21 | #include <ctype.h>
|
---|
22 | #include <win32api.h>
|
---|
23 | #include <winconst.h>
|
---|
24 | #include <misc.h>
|
---|
25 |
|
---|
26 | #define PURE_32
|
---|
27 | #include <netcons.h>
|
---|
28 | #include <wksta.h>
|
---|
29 | #include <neterr.h>
|
---|
30 | #include <netstats.h>
|
---|
31 |
|
---|
32 |
|
---|
33 | //******************************************************************************
|
---|
34 | // translate OS/2 error codes to Windows codes
|
---|
35 | // NOTE: add all codes you need, list is not complete!
|
---|
36 | //******************************************************************************
|
---|
37 | static DWORD error2WinError(APIRET rc)
|
---|
38 | {
|
---|
39 | switch (rc)
|
---|
40 | {
|
---|
41 | // NT/LAN Manager specific error codes
|
---|
42 | case NERR_NetNotStarted: return NERR_NetNotStarted;
|
---|
43 | case NERR_UnknownServer: return NERR_UnknownServer;
|
---|
44 | case NERR_ShareMem: return NERR_ShareMem;
|
---|
45 | case NERR_NoNetworkResource: return NERR_NoNetworkResource;
|
---|
46 | case NERR_RemoteOnly: return NERR_RemoteOnly;
|
---|
47 | case NERR_DevNotRedirected: return NERR_DevNotRedirected;
|
---|
48 | case NERR_ServerNotStarted: return NERR_ServerNotStarted;
|
---|
49 | case NERR_ItemNotFound: return NERR_ItemNotFound;
|
---|
50 | case NERR_UnknownDevDir: return NERR_UnknownDevDir;
|
---|
51 | case NERR_RedirectedPath: return NERR_RedirectedPath;
|
---|
52 | case NERR_DuplicateShare: return NERR_DuplicateShare;
|
---|
53 | case NERR_NoRoom: return NERR_NoRoom;
|
---|
54 | case NERR_TooManyItems: return NERR_TooManyItems;
|
---|
55 | case NERR_InvalidMaxUsers: return NERR_InvalidMaxUsers;
|
---|
56 | case NERR_BufTooSmall: return NERR_BufTooSmall;
|
---|
57 | case NERR_RemoteErr: return NERR_RemoteErr;
|
---|
58 | case NERR_LanmanIniError: return NERR_LanmanIniError;
|
---|
59 | // case NERR_OS2IoctlError
|
---|
60 | case NERR_NetworkError: return NERR_NetworkError;
|
---|
61 | case NERR_WkstaNotStarted: return NERR_WkstaNotStarted;
|
---|
62 | case NERR_BASE + 39: return NERR_BASE + 39; // NERR_BrowserNotStarted
|
---|
63 | case NERR_InternalError: return NERR_InternalError;
|
---|
64 | case NERR_BadTransactConfig: return NERR_BadTransactConfig;
|
---|
65 | case NERR_InvalidAPI: return NERR_InvalidAPI;
|
---|
66 | case NERR_BadEventName: return NERR_BadEventName;
|
---|
67 | case NERR_BASE + 44: return NERR_BASE + 44; // NERR_DupNameReboot
|
---|
68 |
|
---|
69 | // ...
|
---|
70 |
|
---|
71 | case NO_ERROR: //0
|
---|
72 | return ERROR_SUCCESS_W;
|
---|
73 |
|
---|
74 | case ERROR_INVALID_FUNCTION: //1
|
---|
75 | return ERROR_INVALID_FUNCTION_W;
|
---|
76 |
|
---|
77 | case ERROR_FILE_NOT_FOUND: //2
|
---|
78 | return ERROR_FILE_NOT_FOUND_W;
|
---|
79 |
|
---|
80 | case ERROR_PATH_NOT_FOUND: //3
|
---|
81 | return ERROR_PATH_NOT_FOUND_W;
|
---|
82 |
|
---|
83 | case ERROR_TOO_MANY_OPEN_FILES: //4
|
---|
84 | return ERROR_TOO_MANY_OPEN_FILES_W;
|
---|
85 |
|
---|
86 | case ERROR_ACCESS_DENIED: //5
|
---|
87 | return ERROR_ACCESS_DENIED_W;
|
---|
88 |
|
---|
89 | case ERROR_INVALID_HANDLE: //6
|
---|
90 | return ERROR_INVALID_HANDLE_W;
|
---|
91 |
|
---|
92 | case ERROR_NOT_ENOUGH_MEMORY: //8
|
---|
93 | return ERROR_NOT_ENOUGH_MEMORY_W;
|
---|
94 |
|
---|
95 | case ERROR_BAD_FORMAT: //11
|
---|
96 | return ERROR_BAD_FORMAT_W;
|
---|
97 |
|
---|
98 | case ERROR_INVALID_ACCESS: //12
|
---|
99 | return ERROR_INVALID_ACCESS_W;
|
---|
100 |
|
---|
101 | case ERROR_NO_MORE_FILES: //18
|
---|
102 | return ERROR_NO_MORE_FILES_W;
|
---|
103 |
|
---|
104 | case ERROR_WRITE_PROTECT: //19
|
---|
105 | return ERROR_WRITE_PROTECT_W;
|
---|
106 |
|
---|
107 | case ERROR_NOT_DOS_DISK: //26
|
---|
108 | return ERROR_NOT_DOS_DISK_W;
|
---|
109 |
|
---|
110 | case ERROR_WRITE_FAULT: //29
|
---|
111 | return ERROR_WRITE_FAULT_W;
|
---|
112 |
|
---|
113 | case ERROR_SHARING_VIOLATION: //32
|
---|
114 | return ERROR_SHARING_VIOLATION_W;
|
---|
115 |
|
---|
116 | case ERROR_LOCK_VIOLATION: //32
|
---|
117 | return ERROR_LOCK_VIOLATION_W;
|
---|
118 |
|
---|
119 | case ERROR_SHARING_BUFFER_EXCEEDED: //36
|
---|
120 | return ERROR_SHARING_BUFFER_EXCEEDED_W;
|
---|
121 |
|
---|
122 | case ERROR_CANNOT_MAKE: //82
|
---|
123 | return ERROR_CANNOT_MAKE_W;
|
---|
124 |
|
---|
125 | case ERROR_OUT_OF_STRUCTURES: //84
|
---|
126 | return ERROR_OUT_OF_STRUCTURES_W;
|
---|
127 |
|
---|
128 | case ERROR_INVALID_PARAMETER: //87
|
---|
129 | return ERROR_INVALID_PARAMETER_W;
|
---|
130 |
|
---|
131 | case ERROR_INTERRUPT: //95
|
---|
132 | return ERROR_INVALID_AT_INTERRUPT_TIME_W; //CB: right???
|
---|
133 |
|
---|
134 | case ERROR_DEVICE_IN_USE: //99
|
---|
135 | return ERROR_DEVICE_IN_USE_W;
|
---|
136 |
|
---|
137 | case ERROR_DRIVE_LOCKED: //108
|
---|
138 | return ERROR_DRIVE_LOCKED_W;
|
---|
139 |
|
---|
140 | case ERROR_BROKEN_PIPE: //109
|
---|
141 | return ERROR_BROKEN_PIPE_W;
|
---|
142 |
|
---|
143 | case ERROR_OPEN_FAILED: //110
|
---|
144 | return ERROR_OPEN_FAILED_W;
|
---|
145 |
|
---|
146 | case ERROR_BUFFER_OVERFLOW: //111
|
---|
147 | return ERROR_BUFFER_OVERFLOW_W;
|
---|
148 |
|
---|
149 | case ERROR_DISK_FULL: //112
|
---|
150 | return ERROR_DISK_FULL_W;
|
---|
151 |
|
---|
152 | case ERROR_NO_MORE_SEARCH_HANDLES: //113
|
---|
153 | return ERROR_NO_MORE_SEARCH_HANDLES_W;
|
---|
154 |
|
---|
155 | case ERROR_SEM_TIMEOUT: //121
|
---|
156 | return ERROR_SEM_TIMEOUT_W;
|
---|
157 |
|
---|
158 | case ERROR_DIRECT_ACCESS_HANDLE: //130
|
---|
159 | return ERROR_DIRECT_ACCESS_HANDLE_W;
|
---|
160 |
|
---|
161 | case ERROR_NEGATIVE_SEEK: //131
|
---|
162 | return ERROR_NEGATIVE_SEEK;
|
---|
163 |
|
---|
164 | case ERROR_SEEK_ON_DEVICE: //132
|
---|
165 | return ERROR_SEEK_ON_DEVICE_W;
|
---|
166 |
|
---|
167 | case ERROR_DISCARDED: //157
|
---|
168 | return ERROR_DISCARDED_W;
|
---|
169 |
|
---|
170 | case ERROR_FILENAME_EXCED_RANGE: //206
|
---|
171 | return ERROR_FILENAME_EXCED_RANGE_W;
|
---|
172 |
|
---|
173 | case ERROR_META_EXPANSION_TOO_LONG: //208
|
---|
174 | return ERROR_META_EXPANSION_TOO_LONG_W;
|
---|
175 |
|
---|
176 | case ERROR_BAD_PIPE: //230
|
---|
177 | return ERROR_BAD_PIPE_W;
|
---|
178 |
|
---|
179 | case ERROR_PIPE_BUSY: //231
|
---|
180 | return ERROR_PIPE_BUSY_W;
|
---|
181 |
|
---|
182 | case ERROR_NO_DATA: //232
|
---|
183 | return ERROR_NO_DATA_W;
|
---|
184 |
|
---|
185 | case ERROR_PIPE_NOT_CONNECTED: //233
|
---|
186 | return ERROR_PIPE_NOT_CONNECTED_W;
|
---|
187 |
|
---|
188 | case ERROR_MORE_DATA: //234
|
---|
189 | return ERROR_MORE_DATA_W;
|
---|
190 |
|
---|
191 | case ERROR_INVALID_EA_NAME: //254
|
---|
192 | return ERROR_INVALID_EA_NAME_W;
|
---|
193 |
|
---|
194 | case ERROR_EA_LIST_INCONSISTENT: //255
|
---|
195 | return ERROR_EA_LIST_INCONSISTENT_W;
|
---|
196 |
|
---|
197 | case ERROR_EAS_DIDNT_FIT: //275
|
---|
198 | return ERROR_EAS_DIDNT_FIT;
|
---|
199 |
|
---|
200 | default:
|
---|
201 | dprintf(("WARNING: error2WinError: error %d not included!!!!", rc));
|
---|
202 | return rc;
|
---|
203 | }
|
---|
204 | }
|
---|
205 |
|
---|
206 |
|
---|
207 | /*****************************************************************************
|
---|
208 | * Name : NET_API_STATUS OSLibNetWkstaGetInfo
|
---|
209 | * Purpose :
|
---|
210 | * Parameters:
|
---|
211 | * Variables :
|
---|
212 | * Result :
|
---|
213 | * Remark :
|
---|
214 | * Status : UNTESTED STUB
|
---|
215 | *
|
---|
216 | * Author : Patrick Haller 2000/01/10 01:42
|
---|
217 | *****************************************************************************/
|
---|
218 |
|
---|
219 | DWORD OSLibNetWkstaGetInfo (const unsigned char * pszServer,
|
---|
220 | unsigned long ulLevel,
|
---|
221 | unsigned char * pbBuffer,
|
---|
222 | unsigned long ulBuffer,
|
---|
223 | unsigned long * pulTotalAvail)
|
---|
224 | {
|
---|
225 | USHORT sel = RestoreOS2FS();
|
---|
226 |
|
---|
227 | APIRET rc = error2WinError(Net32WkstaGetInfo(pszServer, ulLevel, pbBuffer, ulBuffer, pulTotalAvail));
|
---|
228 | SetFS(sel);
|
---|
229 | return rc;
|
---|
230 | }
|
---|
231 |
|
---|
232 |
|
---|
233 | /*****************************************************************************
|
---|
234 | * Name : NET_API_STATUS OSLibNetStatisticsGet
|
---|
235 | * Purpose :
|
---|
236 | * Parameters:
|
---|
237 | * Variables :
|
---|
238 | * Result :
|
---|
239 | * Remark :
|
---|
240 | * Status : UNTESTED STUB
|
---|
241 | *
|
---|
242 | * Author : Patrick Haller 2000/01/10 01:42
|
---|
243 | *****************************************************************************/
|
---|
244 |
|
---|
245 | DWORD OSLibNetStatisticsGet(const unsigned char * pszServer,
|
---|
246 | const unsigned char * pszService,
|
---|
247 | unsigned long ulReserved,
|
---|
248 | unsigned long ulLevel,
|
---|
249 | unsigned long flOptions,
|
---|
250 | unsigned char * pbBuffer,
|
---|
251 | unsigned long ulBuffer,
|
---|
252 | unsigned long * pulTotalAvail)
|
---|
253 | {
|
---|
254 | USHORT sel = RestoreOS2FS();
|
---|
255 | APIRET rc = error2WinError(Net32StatisticsGet2(pszServer,
|
---|
256 | pszService,
|
---|
257 | ulReserved,
|
---|
258 | ulLevel,
|
---|
259 | flOptions,
|
---|
260 | pbBuffer,
|
---|
261 | ulBuffer,
|
---|
262 | pulTotalAvail));
|
---|
263 | SetFS(sel);
|
---|
264 | return rc;
|
---|
265 | }
|
---|