- Timestamp:
- Dec 2, 1999, 10:35:29 PM (26 years ago)
- Location:
- trunk/src/wsock32/new
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wsock32/new/makefile
r1933 r1951 1 # $Id: makefile,v 1. 6 1999-12-02 07:47:26phaller Exp $1 # $Id: makefile,v 1.7 1999-12-02 21:35:28 phaller Exp $ 2 2 3 3 # … … 40 40 $(IMPDEF) $** $@ 41 41 42 wsock32.obj: wsock32.cpp 43 unknown.obj: unknown.cpp 42 wsock32.obj: wsock32.cpp relaywin.h wsock32.h 43 unknown.obj: unknown.cpp wsock32.h 44 44 initterm.obj: initterm.cpp 45 relaywin.obj: relaywin.cpp 45 relaywin.obj: relaywin.cpp relaywin.h wsock32.h 46 46 47 47 -
trunk/src/wsock32/new/relaywin.cpp
r1945 r1951 1 /* $Id: relaywin.cpp,v 1. 7 1999-12-02 16:39:46 achimhaExp $ */1 /* $Id: relaywin.cpp,v 1.8 1999-12-02 21:35:29 phaller Exp $ */ 2 2 3 3 /* … … 75 75 *****************************************************************************/ 76 76 77 ULONG RelayAlloc(HWND hwnd, ULONG ulMsg, ULONG ulRequestType, 78 PVOID pvUserData1, PVOID pvUserData2) 77 ULONG RelayAlloc(HWND hwnd, 78 ULONG ulMsg, 79 ULONG ulRequestType, 80 BOOL fSingleRequestPerWindow, 81 PVOID pvUserData1, 82 PVOID pvUserData2) 79 83 { 80 84 ULONG ulCounter; … … 84 88 ulCounter++) 85 89 if ( (arrHwndMsgPair[ulCounter].hwnd == 0) || // slot free? 86 (arrHwndMsgPair[ulCounter].hwnd == hwnd) ) // same window? 90 ( (fSingleRequestPerWindow == TRUE) && // more than one request 91 // per window ? 92 (arrHwndMsgPair[ulCounter].hwnd == hwnd) ) ) // same window? 87 93 { 88 94 // occupy slot 89 arrHwndMsgPair[ulCounter].hwnd = hwnd;90 arrHwndMsgPair[ulCounter].ulMsg = ulMsg;95 arrHwndMsgPair[ulCounter].hwnd = hwnd; 96 arrHwndMsgPair[ulCounter].ulMsg = ulMsg; 91 97 arrHwndMsgPair[ulCounter].ulRequestType = ulRequestType; 92 arrHwndMsgPair[ulCounter].pvUserData1 = pvUserData1;93 arrHwndMsgPair[ulCounter].pvUserData2 = pvUserData2;94 return ulCounter ; // return "id"98 arrHwndMsgPair[ulCounter].pvUserData1 = pvUserData1; 99 arrHwndMsgPair[ulCounter].pvUserData2 = pvUserData2; 100 return ulCounter + 1; // return "id" 95 101 } 96 102 … … 113 119 ULONG RelayFree(ULONG ulID) 114 120 { 115 if ( (ulID < 0) || // check range116 (ulID > =MAX_ASYNC_SOCKETS) )121 if ( (ulID < 1) || // check range 122 (ulID > MAX_ASYNC_SOCKETS) ) 117 123 return -1; // error 118 124 119 arrHwndMsgPair[ulID ].hwnd = 0; // mark free125 arrHwndMsgPair[ulID-1].hwnd = 0; // mark free 120 126 121 127 return 0; // OK … … 166 172 PHWNDMSGPAIR RelayQuery(ULONG ulID) 167 173 { 168 if ( (ulID < 0) || // check range169 (ulID > =MAX_ASYNC_SOCKETS) )174 if ( (ulID < 1) || // check range 175 (ulID > MAX_ASYNC_SOCKETS) ) 170 176 return NULL; // error 171 177 172 if (arrHwndMsgPair[ulID ].hwnd == 0)178 if (arrHwndMsgPair[ulID-1].hwnd == 0) 173 179 return NULL; // error, free entry 174 180 else 175 return (&arrHwndMsgPair[ulID ]);181 return (&arrHwndMsgPair[ulID-1]); 176 182 } 177 183 … … 195 201 { 196 202 PHWNDMSGPAIR pHM; 203 int rc; 197 204 198 205 // termination flag handling? … … 203 210 if (pHM != NULL) // message pair found 204 211 { 212 rc = SHORT1FROMMP(mp2); /* asynchronous operation result */ 213 205 214 /* check request type for special handling */ 206 215 switch (pHM->ulRequestType) 207 216 { 217 /********** 218 * SELECT * 219 **********/ 208 220 case ASYNCREQUEST_SELECT: 209 221 { … … 211 223 break; 212 224 } 225 226 227 /***************** 228 * GETHOSTBYNAME * 229 *****************/ 213 230 case ASYNCREQUEST_GETHOSTBYNAME: 214 231 { 215 232 dprintf(("WSOCK32:RelayWindowProc, Converting hostent for " 216 233 "WSAAyncGetHostByName\n")); 217 /* we need to convert the hostent structure here */ 218 Whostent *WinHostent = (Whostent*)pHM->pvUserData1; 219 hostent *OS2Hostent = (hostent*)pHM->pvUserData1; 220 short h_addrtype = (short)OS2Hostent->h_addrtype; 221 WinHostent->h_addrtype = h_addrtype; 222 short h_length = (short)OS2Hostent->h_length; 223 WinHostent->h_length = h_length; 224 char **h_addr_list = OS2Hostent->h_addr_list; 225 WinHostent->h_addr_list = h_addr_list; 226 //TODO: the size of OS/2 hostent is 4 bytes bigger so the original buffer *might* be too small 227 234 235 /* is there a valid result ? */ 236 if (rc == 0) 237 { 238 /* we need to convert the hostent structure here */ 239 Whostent *WinHostent = (Whostent*)pHM->pvUserData1; 240 hostent *OS2Hostent = (hostent*)pHM->pvUserData1; 241 242 short h_addrtype = (short)OS2Hostent->h_addrtype; 243 WinHostent->h_addrtype = h_addrtype; 244 short h_length = (short)OS2Hostent->h_length; 245 WinHostent->h_length = h_length; 246 char **h_addr_list = OS2Hostent->h_addr_list; 247 WinHostent->h_addr_list = h_addr_list; 248 //TODO: the size of OS/2 hostent is 4 bytes bigger 249 // so the original buffer *might* be too small 250 } 251 break; 252 } 253 254 255 /***************** 256 * GETHOSTBYADDR * 257 *****************/ 258 case ASYNCREQUEST_GETHOSTBYADDR: 259 { 260 dprintf(("WSOCK32:RelayWindowProc, Converting hostent for " 261 "WSAAyncGetHostByAddr\n")); 262 263 if (rc == 0) 264 { 265 /* we need to convert the hostent structure here */ 266 Whostent *WinHostent = (Whostent*)pHM->pvUserData1; 267 hostent *OS2Hostent = (hostent*)pHM->pvUserData1; 268 269 short h_addrtype = (short)OS2Hostent->h_addrtype; 270 WinHostent->h_addrtype = h_addrtype; 271 short h_length = (short)OS2Hostent->h_length; 272 WinHostent->h_length = h_length; 273 char **h_addr_list = OS2Hostent->h_addr_list; 274 WinHostent->h_addr_list = h_addr_list; 275 //TODO: the size of OS/2 hostent is 4 bytes bigger 276 // so the original buffer *might* be too small 277 } 278 break; 279 } 280 281 282 /***************** 283 * GETSERVBYNAME * 284 *****************/ 285 case ASYNCREQUEST_GETSERVBYNAME: 286 { 287 dprintf(("WSOCK32:RelayWindowProc, Converting servent for " 288 "WSAAyncGetServByName\n")); 289 290 if (rc == 0) 291 { 292 /* we need to convert the servent structure here */ 293 Wservent *WinServent = (Wservent*)pHM->pvUserData1; 294 servent *OS2Servent = (servent*)pHM->pvUserData1; 295 296 WinServent->s_port = OS2Servent->s_port; 297 WinServent->s_proto = OS2Servent->s_proto; 298 //TODO: the size of OS/2 servent is 2 bytes bigger 299 // so the original buffer *might* be too small 300 } 301 break; 302 } 303 304 305 /***************** 306 * GETSERVBYPORT * 307 *****************/ 308 case ASYNCREQUEST_GETSERVBYPORT: 309 { 310 dprintf(("WSOCK32:RelayWindowProc, Converting servent for " 311 "WSAAyncGetServByPort\n")); 312 313 if (rc == 0) 314 { 315 /* we need to convert the servent structure here */ 316 Wservent *WinServent = (Wservent*)pHM->pvUserData1; 317 servent *OS2Servent = (servent*)pHM->pvUserData1; 318 319 WinServent->s_port = OS2Servent->s_port; 320 WinServent->s_proto = OS2Servent->s_proto; 321 //TODO: the size of OS/2 servent is 2 bytes bigger 322 // so the original buffer *might* be too small 323 } 324 break; 325 } 326 327 328 /****************** 329 * GETPROTOBYNAME * 330 ******************/ 331 case ASYNCREQUEST_GETPROTOBYNAME: 332 { 333 dprintf(("WSOCK32:RelayWindowProc, Converting protoent for " 334 "WSAAyncGetProtoByName\n")); 335 336 if (rc == 0) 337 { 338 /* we need to convert the protoent structure here */ 339 Wprotoent *WinProtoent = (Wprotoent*)pHM->pvUserData1; 340 protoent *OS2Protoent = (protoent*)pHM->pvUserData1; 341 342 WinProtoent->p_proto = OS2Protoent->p_proto; 343 344 //TODO: the size of OS/2 hostent is 2 bytes bigger 345 // so the original buffer *might* be too small 346 } 347 break; 348 } 349 350 351 /******************** 352 * GETPROTOBYNUMBER * 353 ********************/ 354 case ASYNCREQUEST_GETPROTOBYNUMBER: 355 { 356 dprintf(("WSOCK32:RelayWindowProc, Converting protoent for " 357 "WSAAyncGetProtoByNumber\n")); 358 359 if (rc == 0) 360 { 361 /* we need to convert the protoent structure here */ 362 Wprotoent *WinProtoent = (Wprotoent*)pHM->pvUserData1; 363 protoent *OS2Protoent = (protoent*)pHM->pvUserData1; 364 365 WinProtoent->p_proto = OS2Protoent->p_proto; 366 367 //TODO: the size of OS/2 hostent is 2 bytes bigger 368 // so the original buffer *might* be too small 369 } 228 370 break; 229 371 } 230 372 } 231 232 dprintf(("WSOCK32:RelayWinProc, Posting %d to %d\n", pHM->ulMsg, pHM->hwnd)); 373 374 375 dprintf(("WSOCK32:RelayWinProc, Posting hwnd=%08xh, msg=%08xh, w=%08xh, l=%08xh\n", 376 pHM->hwnd, 377 pHM->ulMsg, 378 mp1, 379 mp2)); 380 233 381 PostMessageA(pHM->hwnd, 234 382 pHM->ulMsg, … … 236 384 (ULONG)mp2); 237 385 238 // if socket close, free entry 239 //@@@PH 386 // if socket close or non-select call, free entry 387 // @@@PH 388 if (pHM->ulRequestType != ASYNCREQUEST_SELECT) 389 RelayFree(pHM->ulMsg); 240 390 241 391 return FALSE; // OK, message sent -
trunk/src/wsock32/new/relaywin.h
r1940 r1951 1 /* $Id: relaywin.h,v 1. 3 1999-12-02 15:22:05 achimhaExp $ */1 /* $Id: relaywin.h,v 1.4 1999-12-02 21:35:29 phaller Exp $ */ 2 2 3 3 /* … … 37 37 38 38 /* these are the request types so we can interpret the messages and convert the results */ 39 #define ASYNCREQUEST_SELECT 0 40 #define ASYNCREQUEST_GETHOSTBYNAME 1 39 40 #define ASYNCREQUEST_GETHOSTBYNAME 0 41 #define ASYNCREQUEST_GETHOSTBYADDR 1 42 #define ASYNCREQUEST_GETSERVBYNAME 2 43 #define ASYNCREQUEST_GETSERVBYPORT 3 44 #define ASYNCREQUEST_GETPROTOBYNAME 4 45 #define ASYNCREQUEST_GETPROTOBYNUMBER 5 46 #define ASYNCREQUEST_SELECT 6 47 41 48 42 49 typedef struct tagHwndMsgPair … … 49 56 } HWNDMSGPAIR, *PHWNDMSGPAIR; 50 57 58 51 59 /***************************************************************************** 52 60 * Prototypes * 53 61 *****************************************************************************/ 54 62 55 ULONG RelayAlloc(HWND hwnd, ULONG ulMsg, ULONG ulRequestType, 56 PVOID pvUserData1 = 0, PVOID pvUserData2 = 0); 57 ULONG RelayFree (ULONG ulID); 58 ULONG RelayFreeByHwnd(HWND hwnd); 59 PHWNDMSGPAIR RelayQuery (ULONG ulID); 60 MRESULT EXPENTRY RelayWindowProc(HWND hwnd, ULONG ulMsg, MPARAM mp1, MPARAM mp2); 61 HWND RelayInitialize(HWND hwndPost); 62 BOOL RelayTerminate (HWND hwndRelay); 63 ULONG RelayAlloc (HWND hwnd, 64 ULONG ulMsg, 65 ULONG ulRequestType, 66 BOOL fSingleRequestPerWindow, 67 PVOID pvUserData1 = 0, 68 PVOID pvUserData2 = 0); 69 70 ULONG RelayFree (ULONG ulID); 71 72 ULONG RelayFreeByHwnd(HWND hwnd); 73 74 PHWNDMSGPAIR RelayQuery (ULONG ulID); 75 76 MRESULT EXPENTRY RelayWindowProc(HWND hwnd, 77 ULONG ulMsg, 78 MPARAM mp1, 79 MPARAM mp2); 80 81 HWND RelayInitialize(HWND hwndPost); 82 83 BOOL RelayTerminate (HWND hwndRelay); 63 84 64 85 -
trunk/src/wsock32/new/wsock32.cpp
r1943 r1951 1 /* $Id: wsock32.cpp,v 1.1 0 1999-12-02 16:12:24 achimhaExp $ */1 /* $Id: wsock32.cpp,v 1.11 1999-12-02 21:35:29 phaller Exp $ */ 2 2 3 3 /* … … 63 63 static WSOCKTHREADDATA wstdFallthru; // for emergency only 64 64 65 static HWND hwndRelay; // handle to our relay window 65 static HWND hwndRelay = NULL; // handle to our relay window 66 66 67 67 68 /***************************************************************************** … … 890 891 891 892 ODINFUNCTION2(struct Wservent *,OS2getservbyport, 892 int, port,893 const char *, proto)893 int, port, 894 const char *, proto) 894 895 { 895 896 struct servent *xx; … … 927 928 928 929 ODINFUNCTION2(struct Wservent *,OS2getservbyname, 929 const char *, name,930 const char *, proto)930 const char *, name, 931 const char *, proto) 931 932 { 932 933 WSERVENT *yy; … … 1158 1159 int,buflen) 1159 1160 { 1160 return(WSAAsyncGetServByName(hWnd, 1161 wMsg, 1162 name, 1163 proto, 1164 buf, 1165 buflen)); 1161 int rc; 1162 HWND hwndOS2 = Win32ToOS2Handle(hWnd); 1163 ULONG ulNewID; 1164 1165 if (hwndRelay == NULL) // already initialized ? 1166 hwndRelay = RelayInitialize(hwndOS2); 1167 1168 // add entry to list, we need to store both our temp buffer and the apps buffer 1169 ulNewID = RelayAlloc(hWnd, 1170 wMsg, 1171 FALSE, 1172 ASYNCREQUEST_GETSERVBYNAME, 1173 buf); 1174 1175 // call pmwsock function, will fill our temp buffer 1176 rc = WSAAsyncGetServByName(hwndRelay, 1177 ulNewID, 1178 name, 1179 proto, 1180 buf, 1181 buflen); 1182 1183 // if an error occurs, free the allocated relay entry 1184 if (rc == SOCKET_ERROR) 1185 RelayFree(ulNewID); 1186 1187 return (rc); 1166 1188 } 1167 1189 … … 1187 1209 int,buflen) 1188 1210 { 1189 return(WSAAsyncGetServByPort(hWnd, 1190 wMsg, 1191 port, 1192 proto, 1193 buf, 1194 buflen)); 1211 int rc; 1212 HWND hwndOS2 = Win32ToOS2Handle(hWnd); 1213 ULONG ulNewID; 1214 1215 if (hwndRelay == NULL) // already initialized ? 1216 hwndRelay = RelayInitialize(hwndOS2); 1217 1218 // add entry to list, we need to store both our temp buffer and the apps buffer 1219 ulNewID = RelayAlloc(hWnd, 1220 wMsg, 1221 FALSE, 1222 ASYNCREQUEST_GETSERVBYPORT, 1223 buf); 1224 1225 // call pmwsock function, will fill our temp buffer 1226 rc = WSAAsyncGetServByPort(hwndRelay, 1227 ulNewID, 1228 port, 1229 proto, 1230 buf, 1231 buflen); 1232 1233 // if an error occurs, free the allocated relay entry 1234 if (rc == SOCKET_ERROR) 1235 RelayFree(ulNewID); 1236 1237 return rc; 1195 1238 } 1196 1239 … … 1215 1258 int,buflen) 1216 1259 { 1217 return(WSAAsyncGetProtoByName(hWnd, 1218 wMsg, 1219 name, 1220 buf, 1221 buflen)); 1260 int rc; 1261 HWND hwndOS2 = Win32ToOS2Handle(hWnd); 1262 ULONG ulNewID; 1263 1264 if (hwndRelay == NULL) // already initialized ? 1265 hwndRelay = RelayInitialize(hwndOS2); 1266 1267 // add entry to list, we need to store both our temp buffer and the apps buffer 1268 ulNewID = RelayAlloc(hWnd, 1269 wMsg, 1270 FALSE, 1271 ASYNCREQUEST_GETPROTOBYNAME, 1272 buf); 1273 1274 // call pmwsock function, will fill our temp buffer 1275 rc = WSAAsyncGetProtoByName(hwndRelay, 1276 ulNewID, 1277 name, 1278 buf, 1279 buflen); 1280 1281 // if an error occurs, free the allocated relay entry 1282 if (rc == SOCKET_ERROR) 1283 RelayFree(ulNewID); 1284 1285 return (rc); 1222 1286 } 1223 1287 … … 1242 1306 int,buflen) 1243 1307 { 1244 return(WSAAsyncGetProtoByNumber(hWnd, 1245 wMsg, 1246 number, 1247 buf, 1248 buflen)); 1308 int rc; 1309 HWND hwndOS2 = Win32ToOS2Handle(hWnd); 1310 ULONG ulNewID; 1311 1312 if (hwndRelay == NULL) // already initialized ? 1313 hwndRelay = RelayInitialize(hwndOS2); 1314 1315 // add entry to list, we need to store both our temp buffer and the apps buffer 1316 ulNewID = RelayAlloc(hWnd, 1317 wMsg, 1318 FALSE, 1319 ASYNCREQUEST_GETPROTOBYNUMBER, 1320 buf); 1321 1322 // call pmwsock function, will fill our temp buffer 1323 rc = WSAAsyncGetProtoByNumber(hwndRelay, 1324 ulNewID, 1325 number, 1326 buf, 1327 buflen); 1328 1329 // if an error occurs, free the allocated relay entry 1330 if (rc == SOCKET_ERROR) 1331 RelayFree(ulNewID); 1332 1333 return rc; 1249 1334 } 1250 1335 … … 1276 1361 hwndRelay = RelayInitialize(hwndOS2); 1277 1362 1278 // TODO: Is this the original behaviour? 1279 if ((name == NULL) || (buf == NULL)) 1280 { 1281 // remove entry from list 1282 RelayFreeByHwnd(hWnd); 1283 } 1284 else 1285 // add entry to list, we need to store both our temp buffer and the apps buffer 1286 ulNewID = RelayAlloc(hWnd, wMsg, ASYNCREQUEST_GETHOSTBYNAME, buf); 1363 // add entry to list, we need to store both our temp buffer and the apps buffer 1364 ulNewID = RelayAlloc(hWnd, 1365 wMsg, 1366 FALSE, 1367 ASYNCREQUEST_GETHOSTBYNAME, 1368 buf); 1287 1369 1288 1370 // call pmwsock function, will fill our temp buffer … … 1292 1374 buf, 1293 1375 buflen); 1294 1376 1377 // if an error occurs, free the allocated relay entry 1378 if (rc == SOCKET_ERROR) 1379 RelayFree(ulNewID); 1380 1295 1381 return rc; 1296 1382 } … … 1318 1404 int,buflen) 1319 1405 { 1320 return(WSAAsyncGetHostByAddr(hWnd, 1321 wMsg, 1322 addr, 1323 len, 1324 type, 1325 buf, 1326 buflen)); 1406 int rc; 1407 HWND hwndOS2 = Win32ToOS2Handle(hWnd); 1408 ULONG ulNewID; 1409 1410 if (hwndRelay == NULL) // already initialized ? 1411 hwndRelay = RelayInitialize(hwndOS2); 1412 1413 // add entry to list, we need to store both our temp buffer and the apps buffer 1414 ulNewID = RelayAlloc(hWnd, 1415 wMsg, 1416 FALSE, 1417 ASYNCREQUEST_GETHOSTBYADDR, 1418 buf); 1419 1420 // call pmwsock function, will fill our temp buffer 1421 rc = WSAAsyncGetHostByAddr(hwndRelay, 1422 ulNewID, 1423 addr, 1424 len, 1425 type, 1426 buf, 1427 buflen); 1428 1429 // if an error occurs, free the allocated relay entry 1430 if (rc == SOCKET_ERROR) 1431 RelayFree(ulNewID); 1432 1433 return (rc); 1327 1434 } 1328 1435 … … 1399 1506 else 1400 1507 // add entry to list 1401 ulNewID = RelayAlloc(hWnd, wMsg, ASYNCREQUEST_SELECT); 1508 ulNewID = RelayAlloc(hWnd, 1509 wMsg, 1510 TRUE, 1511 ASYNCREQUEST_SELECT); 1402 1512 1403 1513 rc = WSAAsyncSelect(s,
Note:
See TracChangeset
for help on using the changeset viewer.