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