Changeset 1952 for trunk/src/wsock32/new/relaywin.cpp
- Timestamp:
- Dec 3, 1999, 2:19:56 AM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/wsock32/new/relaywin.cpp
r1951 r1952 1 /* $Id: relaywin.cpp,v 1.8 1999-12-02 21:35:29 phaller Exp $ */ 1 2 2 3 3 /* … … 57 57 static HWNDMSGPAIR arrHwndMsgPair[MAX_ASYNC_SOCKETS]; 58 58 static char* ODIN_WSOCK_RELAY_CLASS = "ODIN_WSOCK_RELAY"; 59 59 static HWND hwndRelay = NULLHANDLE; 60 60 61 61 // prototype for PostMessageA … … 76 76 77 77 ULONG RelayAlloc(HWND hwnd, 78 ULONG ulMsg, 78 ULONG ulMsg, 79 79 ULONG ulRequestType, 80 80 BOOL fSingleRequestPerWindow, 81 PVOID pvUserData1, 81 PVOID pvUserData1, 82 82 PVOID pvUserData2) 83 83 { … … 175 175 (ulID > MAX_ASYNC_SOCKETS) ) 176 176 return NULL; // error 177 177 178 178 if (arrHwndMsgPair[ulID-1].hwnd == 0) 179 179 return NULL; // error, free entry … … 206 206 // if (fTerminate) 207 207 // WinDefWindowProc() 208 208 209 209 pHM = RelayQuery(ulMsg); // find registered message 210 210 if (pHM != NULL) // message pair found 211 211 { 212 212 rc = SHORT1FROMMP(mp2); /* asynchronous operation result */ 213 213 214 214 /* check request type for special handling */ 215 215 switch (pHM->ulRequestType) … … 223 223 break; 224 224 } 225 226 225 226 227 227 /***************** 228 228 * GETHOSTBYNAME * … … 232 232 dprintf(("WSOCK32:RelayWindowProc, Converting hostent for " 233 233 "WSAAyncGetHostByName\n")); 234 234 235 235 /* is there a valid result ? */ 236 236 if (rc == 0) … … 239 239 Whostent *WinHostent = (Whostent*)pHM->pvUserData1; 240 240 hostent *OS2Hostent = (hostent*)pHM->pvUserData1; 241 241 242 242 short h_addrtype = (short)OS2Hostent->h_addrtype; 243 243 WinHostent->h_addrtype = h_addrtype; … … 246 246 char **h_addr_list = OS2Hostent->h_addr_list; 247 247 WinHostent->h_addr_list = h_addr_list; 248 //TODO: the size of OS/2 hostent is 4 bytes bigger 248 //TODO: the size of OS/2 hostent is 4 bytes bigger 249 249 // so the original buffer *might* be too small 250 250 } 251 251 break; 252 252 } 253 254 253 254 255 255 /***************** 256 256 * GETHOSTBYADDR * … … 260 260 dprintf(("WSOCK32:RelayWindowProc, Converting hostent for " 261 261 "WSAAyncGetHostByAddr\n")); 262 262 263 263 if (rc == 0) 264 264 { … … 266 266 Whostent *WinHostent = (Whostent*)pHM->pvUserData1; 267 267 hostent *OS2Hostent = (hostent*)pHM->pvUserData1; 268 268 269 269 short h_addrtype = (short)OS2Hostent->h_addrtype; 270 270 WinHostent->h_addrtype = h_addrtype; … … 273 273 char **h_addr_list = OS2Hostent->h_addr_list; 274 274 WinHostent->h_addr_list = h_addr_list; 275 //TODO: the size of OS/2 hostent is 4 bytes bigger 275 //TODO: the size of OS/2 hostent is 4 bytes bigger 276 276 // so the original buffer *might* be too small 277 277 } 278 278 break; 279 } 280 281 279 } 280 281 282 282 /***************** 283 283 * GETSERVBYNAME * … … 287 287 dprintf(("WSOCK32:RelayWindowProc, Converting servent for " 288 288 "WSAAyncGetServByName\n")); 289 289 290 290 if (rc == 0) 291 291 { … … 293 293 Wservent *WinServent = (Wservent*)pHM->pvUserData1; 294 294 servent *OS2Servent = (servent*)pHM->pvUserData1; 295 295 296 296 WinServent->s_port = OS2Servent->s_port; 297 297 WinServent->s_proto = OS2Servent->s_proto; … … 300 300 } 301 301 break; 302 } 303 304 302 } 303 304 305 305 /***************** 306 306 * GETSERVBYPORT * … … 310 310 dprintf(("WSOCK32:RelayWindowProc, Converting servent for " 311 311 "WSAAyncGetServByPort\n")); 312 312 313 313 if (rc == 0) 314 314 { … … 316 316 Wservent *WinServent = (Wservent*)pHM->pvUserData1; 317 317 servent *OS2Servent = (servent*)pHM->pvUserData1; 318 318 319 319 WinServent->s_port = OS2Servent->s_port; 320 320 WinServent->s_proto = OS2Servent->s_proto; … … 323 323 } 324 324 break; 325 } 326 327 325 } 326 327 328 328 /****************** 329 329 * GETPROTOBYNAME * … … 333 333 dprintf(("WSOCK32:RelayWindowProc, Converting protoent for " 334 334 "WSAAyncGetProtoByName\n")); 335 335 336 336 if (rc == 0) 337 337 { … … 339 339 Wprotoent *WinProtoent = (Wprotoent*)pHM->pvUserData1; 340 340 protoent *OS2Protoent = (protoent*)pHM->pvUserData1; 341 341 342 342 WinProtoent->p_proto = OS2Protoent->p_proto; 343 343 344 344 //TODO: the size of OS/2 hostent is 2 bytes bigger 345 345 // so the original buffer *might* be too small 346 346 } 347 347 break; 348 } 349 350 348 } 349 350 351 351 /******************** 352 352 * GETPROTOBYNUMBER * … … 356 356 dprintf(("WSOCK32:RelayWindowProc, Converting protoent for " 357 357 "WSAAyncGetProtoByNumber\n")); 358 358 359 359 if (rc == 0) 360 360 { … … 362 362 Wprotoent *WinProtoent = (Wprotoent*)pHM->pvUserData1; 363 363 protoent *OS2Protoent = (protoent*)pHM->pvUserData1; 364 364 365 365 WinProtoent->p_proto = OS2Protoent->p_proto; 366 366 367 367 //TODO: the size of OS/2 hostent is 2 bytes bigger 368 368 // so the original buffer *might* be too small … … 371 371 } 372 372 } 373 374 373 374 375 375 dprintf(("WSOCK32:RelayWinProc, Posting hwnd=%08xh, msg=%08xh, w=%08xh, l=%08xh\n", 376 376 pHM->hwnd, … … 378 378 mp1, 379 379 mp2)); 380 380 381 381 PostMessageA(pHM->hwnd, 382 382 pHM->ulMsg, … … 397 397 398 398 399 400 401 #if 0 399 402 /***************************************************************************** 400 403 * Name : … … 420 423 if (hab == NULLHANDLE) 421 424 return NULLHANDLE; 425 422 426 423 427 // register relay window class … … 444 448 } 445 449 450 #else 451 452 /***************************************************************************** 453 * Name : 454 * Purpose : 455 * Parameters: 456 * Variables : 457 * Result : 458 * Remark : 459 * Status : 460 * 461 * Author : Patrick Haller [Tue, 1999/11/30 23:00] 462 *****************************************************************************/ 463 464 465 //---------------------------------------------------------------------- 466 // thread 2 entry point: gets and dispatches object window messages 467 // _Optlink is an IBM C Set/2 function modifier 468 void _Optlink RelayThreadMain(PVOID pParameter) 469 { 470 BOOL fSuccess; 471 HAB hab; 472 HMQ hmq; 473 QMSG qmsg; 474 475 // thread initialization 476 hab = WinInitialize( 0 ); 477 hmq = WinCreateMsgQueue( hab, 0 ); 478 479 // prevent system from posting object window a WM_QUIT 480 // I'll post WM_QUIT when it's time. 481 fSuccess = WinCancelShutdown( hmq, TRUE ); 482 if (fSuccess != TRUE) 483 { 484 dprintf(("WSOCK32:RelayWin: ERROR WinCancelShutdown failed\n")); 485 return; 486 } 487 488 // register relay window class 489 fSuccess = WinRegisterClass(hab, 490 ODIN_WSOCK_RELAY_CLASS, 491 (PFNWP)RelayWindowProc, 492 0, 493 0); 494 if (fSuccess == FALSE) 495 { 496 dprintf(("WSOCK32:RelayWin: ERROR WinRegisterClass failed\n")); 497 return; 498 } 499 500 hwndRelay = WinCreateWindow(HWND_OBJECT, 501 ODIN_WSOCK_RELAY_CLASS, 502 "ODIN WSock Relay", 503 0, 0, 0, 0, 0, 504 HWND_OBJECT, 505 HWND_BOTTOM, 506 0, 507 NULL, 508 NULL ); 509 if (hwndRelay == NULLHANDLE) 510 { 511 dprintf(("WSOCK32:RelayWin: ERROR WinCreateWindow failed\n")); 512 return; 513 } 514 515 // get/dispatch messages; user messages, for the most part 516 while( WinGetMsg ( hab, &qmsg, 0, 0, 0 )) 517 { 518 WinDispatchMsg ( hab, &qmsg ); 519 } 520 521 // clean up 522 WinDestroyWindow( hwndRelay ); 523 WinDestroyMsgQueue( hmq ); 524 WinTerminate( hab ); 525 526 // reset relay window handle 527 hwndRelay = NULLHANDLE; 528 return; 529 } 530 531 532 /***************************************************************************** 533 * Name : 534 * Purpose : 535 * Parameters: 536 * Variables : 537 * Result : 538 * Remark : 539 * Status : 540 * 541 * Author : Patrick Haller [Tue, 1999/11/30 23:00] 542 *****************************************************************************/ 543 544 HWND RelayInitialize(HWND hwndPost) 545 { 546 int tidRelay; // thread identifier 547 548 if (hwndRelay != NULLHANDLE) 549 { 550 // relay thread has been initialized 551 return hwndRelay; 552 } 553 554 // else create new subsystem 555 // create thread 556 #if defined(__IBMCPP__) 557 tidRelay = _beginthread(RelayThreadMain, 558 NULL, 559 16384, 560 (PVOID)0); 561 #else 562 tidRelay = _beginthread(RelayThreadMain, 563 16384, 564 (PVOID)0); 565 #endif 566 567 // wait for thread to come up and send valid HWND 568 // @@@PH this is an ugly hack 569 dprintf(("WSOCK32:RELAYWIN:RelayInitialize wait for window handle\n")); 570 while (hwndRelay == NULL) 571 { 572 DosSleep(10); 573 } 574 dprintf(("WSOCK32:RELAYWIN:RelayInitialize window handle = %08xh", 575 hwndRelay)); 576 577 return hwndRelay; 578 } 579 580 #endif 581 446 582 447 583 /*****************************************************************************
Note:
See TracChangeset
for help on using the changeset viewer.