Changeset 1951 for trunk/src/wsock32/new/relaywin.cpp
- Timestamp:
- Dec 2, 1999, 10:35:29 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note:
See TracChangeset
for help on using the changeset viewer.