COMQUEUE.CPP (44637B)
1 // 2 // Copyright 2020 Electronic Arts Inc. 3 // 4 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is free 5 // software: you can redistribute it and/or modify it under the terms of 6 // the GNU General Public License as published by the Free Software Foundation, 7 // either version 3 of the License, or (at your option) any later version. 8 9 // TiberianDawn.DLL and RedAlert.dll and corresponding source code is distributed 10 // in the hope that it will be useful, but with permitted additional restrictions 11 // under Section 7 of the GPL. See the GNU General Public License in LICENSE.TXT 12 // distributed with this program. You should have received a copy of the 13 // GNU General Public License along with permitted additional restrictions 14 // with this program. If not, see https://github.com/electronicarts/CnC_Remastered_Collection 15 16 /* $Header: F:\projects\c&c\vcs\code\comqueue.cpv 1.10 16 Oct 1995 16:49:14 JOE_BOSTIC $ */ 17 /*************************************************************************** 18 ** C O N F I D E N T I A L --- W E S T W O O D S T U D I O S ** 19 *************************************************************************** 20 * * 21 * Project Name : Command & Conquer * 22 * * 23 * File Name : COMQUEUE.CPP * 24 * * 25 * Programmer : Bill Randolph * 26 * * 27 * Start Date : December 19, 1994 * 28 * * 29 * Last Update : May 31, 1995 [BRR] * 30 * * 31 *-------------------------------------------------------------------------* 32 * Functions: * 33 * CommQueueClass::CommQueueClass -- class constructor * 34 * CommQueueClass::~CommQueueClass -- class destructor * 35 * CommQueueClass::Init -- initializes this queue * 36 * CommQueueClass::Queue_Send -- queues a message for sending * 37 * CommQueueClass::UnQueue_Send -- removes next entry from send queue * 38 * CommQueueClass::Next_Send -- gets ptr to next entry in send queue * 39 * CommQueueClass::Get_Send -- gets ptr to queue entry * 40 * CommQueueClass::Queue_Receive -- queues a received message * 41 * CommQueueClass::UnQueue_Receive -- removes next entry from send queue * 42 * CommQueueClass::Next_Receive -- gets ptr to next entry in send queue * 43 * CommQueueClass::Get_Receive -- gets ptr to queue entry * 44 * CommQueueClass::Add_Delay -- adds a new delay value for response time * 45 * CommQueueClass::Avg_Response_Time -- returns average response time * 46 * CommQueueClass::Max_Response_Time -- returns max response time * 47 * CommQueueClass::Reset_Response_Time -- resets computations * 48 * CommQueueClass::Configure_Debug -- sets up special debug values * 49 * CommQueueClass::Mono_Debug_Print -- Debug output routine * 50 * CommQueueClass::Mono_Debug_Print2 -- Debug output; alternate format * 51 * - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */ 52 #if (0) 53 54 55 #include "function.h" 56 57 #ifndef DEMO 58 59 /*************************************************************************** 60 * CommQueueClass::CommQueueClass -- class constructor * 61 * * 62 * INPUT: * 63 * numsend # queue entries for sending * 64 * numreceive # queue entries for receiving * 65 * maxlen maximum desired packet length, in bytes * 66 * * 67 * OUTPUT: * 68 * none. * 69 * * 70 * WARNINGS: * 71 * none. * 72 * * 73 * HISTORY: * 74 * 12/19/1994 BR : Created. * 75 *=========================================================================*/ 76 CommQueueClass::CommQueueClass(int numsend, int numreceive, int maxlen) 77 { 78 int i; 79 80 /* 81 ----------------------------- Init variables ----------------------------- 82 */ 83 MaxSend = numsend; 84 MaxReceive = numreceive; 85 MaxPacketSize = maxlen; 86 87 /* 88 ----------------------- Allocate the queue entries ----------------------- 89 */ 90 SendQueue = new SendQueueType[numsend]; 91 ReceiveQueue = new ReceiveQueueType[numreceive]; 92 93 /* 94 ---------------------- Allocate queue entry buffers ---------------------- 95 */ 96 for (i = 0; i < MaxSend; i++) { 97 SendQueue[i].Buffer = new char[maxlen]; 98 } 99 100 for (i = 0; i < MaxReceive; i++) { 101 ReceiveQueue[i].Buffer = new char[maxlen]; 102 } 103 104 Init(); 105 106 } /* end of CommQueueClass */ 107 108 109 /*************************************************************************** 110 * CommQueueClass::~CommQueueClass -- class destructor * 111 * * 112 * INPUT: * 113 * none. * 114 * * 115 * OUTPUT: * 116 * none. * 117 * * 118 * WARNINGS: * 119 * none. * 120 * * 121 * HISTORY: * 122 * 12/19/1994 BR : Created. * 123 *=========================================================================*/ 124 CommQueueClass::~CommQueueClass() 125 { 126 int i; 127 128 /* 129 ------------------------ Free queue entry buffers ------------------------ 130 */ 131 for (i = 0; i < MaxSend; i++) { 132 delete [] SendQueue[i].Buffer; 133 } 134 135 for (i = 0; i < MaxReceive; i++) { 136 delete [] ReceiveQueue[i].Buffer; 137 } 138 139 delete [] SendQueue; 140 delete [] ReceiveQueue; 141 142 } /* end of ~CommQueueClass */ 143 144 145 /*************************************************************************** 146 * CommQueueClass::Init -- initializes this queue * 147 * * 148 * INPUT: * 149 * none. * 150 * * 151 * OUTPUT: * 152 * none. * 153 * * 154 * WARNINGS: * 155 * none. * 156 * * 157 * HISTORY: * 158 * 01/20/1995 BR : Created. * 159 *=========================================================================*/ 160 void CommQueueClass::Init(void) 161 { 162 int i; 163 164 /*------------------------------------------------------------------------ 165 Init data members 166 ------------------------------------------------------------------------*/ 167 SendTotal = 0L; 168 ReceiveTotal = 0L; 169 170 DelaySum = 0L; 171 NumDelay = 0L; 172 MeanDelay = 0L; 173 MaxDelay = 0L; 174 175 SendCount = 0; 176 SendNext = 0; 177 SendEmpty = 0; 178 179 ReceiveCount = 0; 180 ReceiveNext = 0; 181 ReceiveEmpty = 0; 182 183 /*------------------------------------------------------------------------ 184 Init the queue entries 185 ------------------------------------------------------------------------*/ 186 for (i = 0; i < MaxSend; i++) { 187 SendQueue[i].IsActive = 0; 188 SendQueue[i].IsACK = 0; 189 SendQueue[i].FirstTime = 0L; 190 SendQueue[i].LastTime = 0L; 191 SendQueue[i].SendCount = 0L; 192 ReceiveQueue[i].BufLen = 0; 193 } 194 for (i = 0; i < MaxReceive; i++) { 195 ReceiveQueue[i].IsActive = 0; 196 ReceiveQueue[i].IsRead = 0; 197 ReceiveQueue[i].IsACK = 0; 198 ReceiveQueue[i].BufLen = 0; 199 } 200 201 /*------------------------------------------------------------------------ 202 Init debug values 203 ------------------------------------------------------------------------*/ 204 DebugOffset = 0; 205 DebugSize = 0; 206 DebugNames = NULL; 207 DebugMaxNames = 0; 208 209 } /* end of Init */ 210 211 212 /*************************************************************************** 213 * CommQueueClass::Queue_Send -- queues a message for sending * 214 * * 215 * INPUT: * 216 * buf buffer containing the message * 217 * buflen length of 'buf' * 218 * * 219 * OUTPUT: * 220 * 1 = OK, 0 = no room in the queue * 221 * * 222 * WARNINGS: * 223 * none. * 224 * * 225 * HISTORY: * 226 * 12/20/1994 BR : Created. * 227 *=========================================================================*/ 228 int CommQueueClass::Queue_Send(void *buf, int buflen) 229 { 230 /* 231 --------------------- Error if no room in the queue ---------------------- 232 */ 233 if (SendCount==MaxSend || SendQueue[SendEmpty].IsActive!=0) 234 return(0); 235 236 /* 237 ---------------------------- Set entry flags ----------------------------- 238 */ 239 SendQueue[SendEmpty].IsActive = 1; // entry is now active 240 SendQueue[SendEmpty].IsACK = 0; // entry hasn't been ACK'd 241 SendQueue[SendEmpty].FirstTime = 0L; // filled in by Manager when sent 242 SendQueue[SendEmpty].LastTime = 0L; // filled in by Manager when sent 243 SendQueue[SendEmpty].SendCount = 0L; // filled in by Manager when sent 244 SendQueue[SendEmpty].BufLen = buflen; // save buffer size 245 246 /* 247 ------------------------- Copy the packet data --------------------------- 248 */ 249 memcpy(SendQueue[SendEmpty].Buffer,buf,buflen); 250 251 /* 252 -------------------- Increment counters & entry ptr ---------------------- 253 */ 254 SendCount++; 255 SendEmpty++; 256 if (SendEmpty==MaxSend) 257 SendEmpty = 0; 258 259 SendTotal++; 260 261 return(1); 262 263 } /* end of Queue_Send */ 264 265 266 /*************************************************************************** 267 * CommQueueClass::UnQueue_Send -- removes next entry from send queue * 268 * * 269 * INPUT: * 270 * buf buffer to store entry's data in; if NULL, it's discarded * 271 * buflen filled in with length of entry retrieved * 272 * * 273 * OUTPUT: * 274 * 1 = OK, 0 = no entry to retreive * 275 * * 276 * WARNINGS: * 277 * none. * 278 * * 279 * HISTORY: * 280 * 12/20/1994 BR : Created. * 281 *=========================================================================*/ 282 int CommQueueClass::UnQueue_Send(void *buf, int *buflen) 283 { 284 /* 285 --------------------- Error if no entry to retrieve ---------------------- 286 */ 287 if (SendCount==0 || SendQueue[SendNext].IsActive==0) 288 return(0); 289 290 /* 291 ---------------------- Copy the data from the entry ---------------------- 292 */ 293 if (buf!=NULL) { 294 memcpy(buf,SendQueue[SendNext].Buffer,SendQueue[SendNext].BufLen); 295 (*buflen) = SendQueue[SendNext].BufLen; 296 } 297 298 /* 299 ---------------------------- Set entry flags ----------------------------- 300 */ 301 SendQueue[SendNext].IsActive = 0; 302 SendQueue[SendNext].IsACK = 0; 303 SendQueue[SendNext].FirstTime = 0L; 304 SendQueue[SendNext].LastTime = 0L; 305 SendQueue[SendNext].SendCount = 0L; 306 SendQueue[SendNext].BufLen = 0; 307 SendCount--; 308 SendNext++; 309 if (SendNext==MaxSend) 310 SendNext = 0; 311 312 return(1); 313 314 } /* end of UnQueue_Send */ 315 316 317 /*************************************************************************** 318 * CommQueueClass::Next_Send -- gets ptr to next entry in send queue * 319 * * 320 * INPUT: * 321 * none. * 322 * * 323 * OUTPUT: * 324 * ptr to entry, NULL if there is none. * 325 * * 326 * WARNINGS: * 327 * none. * 328 * * 329 * HISTORY: * 330 * 12/20/1994 BR : Created. * 331 *=========================================================================*/ 332 SendQueueType * CommQueueClass::Next_Send(void) 333 { 334 if (SendCount==0) { 335 return(NULL); 336 } else { 337 return(&SendQueue[SendNext]); 338 } 339 } 340 341 342 /*************************************************************************** 343 * CommQueueClass::Get_Send -- gets ptr to queue entry * 344 * * 345 * This routine gets a pointer to the indicated queue entry. The index * 346 * value is relative to the next-accessable queue entry; 0 = get the * 347 * next available queue entry, 1 = get the one behind that, etc. * 348 * * 349 * INPUT: * 350 * index index of entry to get (0 = 1st available) * 351 * * 352 * OUTPUT: * 353 * ptr to entry * 354 * * 355 * WARNINGS: * 356 * none. * 357 * * 358 * HISTORY: * 359 * 12/21/1994 BR : Created. * 360 *=========================================================================*/ 361 SendQueueType * CommQueueClass::Get_Send(int index) 362 { 363 int i; 364 365 i = SendNext + index; 366 if (i >= MaxSend) 367 i -= MaxSend; 368 369 if (SendQueue[i].IsActive==0) { 370 return(NULL); 371 } else { 372 return(&SendQueue[i]); 373 } 374 } 375 376 377 /*************************************************************************** 378 * CommQueueClass::Queue_Receive -- queues a received message * 379 * * 380 * INPUT: * 381 * buf buffer containing the message * 382 * buflen length of 'buf' * 383 * * 384 * OUTPUT: * 385 * 1 = OK, 0 = no room in the queue * 386 * * 387 * WARNINGS: * 388 * none. * 389 * * 390 * HISTORY: * 391 * 12/20/1994 BR : Created. * 392 *=========================================================================*/ 393 int CommQueueClass::Queue_Receive(void *buf, int buflen) 394 { 395 /* 396 --------------------- Error if no room in the queue ---------------------- 397 */ 398 if (ReceiveCount==MaxReceive || ReceiveQueue[ReceiveEmpty].IsActive!=0) { 399 return(0); 400 } 401 402 /* 403 ---------------------------- Set entry flags ----------------------------- 404 */ 405 ReceiveQueue[ReceiveEmpty].IsActive = 1; 406 ReceiveQueue[ReceiveEmpty].IsRead = 0; 407 ReceiveQueue[ReceiveEmpty].IsACK = 0; 408 ReceiveQueue[ReceiveEmpty].BufLen = buflen; 409 410 /* 411 ------------------------- Copy the packet data --------------------------- 412 */ 413 if (buflen > MaxPacketLen){ 414 CCDebugString ("C&C95 - Error. Incoming packet too large"); 415 } 416 memcpy(ReceiveQueue[ReceiveEmpty].Buffer,buf,buflen); 417 418 /* 419 -------------------- Increment counters & entry ptr ---------------------- 420 */ 421 ReceiveCount++; 422 ReceiveEmpty++; 423 if (ReceiveEmpty==MaxReceive) 424 ReceiveEmpty = 0; 425 426 ReceiveTotal++; 427 428 return(1); 429 430 } /* end of Queue_Receive */ 431 432 433 /*************************************************************************** 434 * CommQueueClass::UnQueue_Receive -- removes next entry from send queue * 435 * * 436 * INPUT: * 437 * buf buffer to store entry's data in; if NULL, it's discarded * 438 * buflen filled in with length of entry retrieved * 439 * * 440 * OUTPUT: * 441 * 1 = OK, 0 = no entry to retreive * 442 * * 443 * WARNINGS: * 444 * none. * 445 * * 446 * HISTORY: * 447 * 12/20/1994 BR : Created. * 448 *=========================================================================*/ 449 int CommQueueClass::UnQueue_Receive(void *buf, int *buflen) 450 { 451 /* 452 --------------------- Error if no entry to retrieve ---------------------- 453 */ 454 if (ReceiveCount==0 || ReceiveQueue[ReceiveNext].IsActive==0) { 455 return(0); 456 } 457 458 /* 459 ---------------------- Copy the data from the entry ---------------------- 460 */ 461 if (buf!=NULL) { 462 memcpy(buf,ReceiveQueue[ReceiveNext].Buffer, 463 ReceiveQueue[ReceiveNext].BufLen); 464 (*buflen) = ReceiveQueue[ReceiveNext].BufLen; 465 } 466 467 /* 468 ---------------------------- Set entry flags ----------------------------- 469 */ 470 ReceiveQueue[ReceiveNext].IsActive = 0; 471 ReceiveQueue[ReceiveNext].IsRead = 0; 472 ReceiveQueue[ReceiveNext].IsACK = 0; 473 ReceiveQueue[ReceiveNext].BufLen = 0; 474 ReceiveCount--; 475 ReceiveNext++; 476 if (ReceiveNext==MaxReceive) 477 ReceiveNext = 0; 478 479 return(1); 480 481 } /* end of UnQueue_Receive */ 482 483 484 /*************************************************************************** 485 * CommQueueClass::Next_Receive -- gets ptr to next entry in send queue * 486 * * 487 * INPUT: * 488 * none. * 489 * * 490 * OUTPUT: * 491 * ptr to entry, NULL if there is none. * 492 * * 493 * WARNINGS: * 494 * none. * 495 * * 496 * HISTORY: * 497 * 12/20/1994 BR : Created. * 498 *=========================================================================*/ 499 ReceiveQueueType * CommQueueClass::Next_Receive(void) 500 { 501 if (ReceiveCount==0) { 502 return(NULL); 503 } else { 504 return(&ReceiveQueue[ReceiveNext]); 505 } 506 } 507 508 509 /*************************************************************************** 510 * CommQueueClass::Get_Receive -- gets ptr to queue entry * 511 * * 512 * This routine gets a pointer to the indicated queue entry. The index * 513 * value is relative to the next-accessable queue entry; 0 = get the * 514 * next available queue entry, 1 = get the one behind that, etc. * 515 * * 516 * INPUT: * 517 * index index of entry to get (0 = 1st available) * 518 * * 519 * OUTPUT: * 520 * ptr to entry * 521 * * 522 * WARNINGS: * 523 * none. * 524 * * 525 * HISTORY: * 526 * 12/21/1994 BR : Created. * 527 *=========================================================================*/ 528 ReceiveQueueType * CommQueueClass::Get_Receive(int index) 529 { 530 int i; 531 532 i = ReceiveNext + index; 533 if (i >= MaxReceive) 534 i -= MaxReceive; 535 536 if (ReceiveQueue[i].IsActive==0) { 537 return(NULL); 538 } else { 539 return(&ReceiveQueue[i]); 540 } 541 } 542 543 544 /*************************************************************************** 545 * CommQueueClass::Add_Delay -- adds a new delay value for response time * 546 * * 547 * This routine updates the average response time for this queue. The * 548 * computation is based on the average of the last 'n' delay values given, * 549 * It computes a running total of the last n delay values, then divides * 550 * that by n to compute the average. * 551 * * 552 * When the number of values given exceeds the max, the mean is subtracted * 553 * off the total, then the new value is added in. Thus, any single delay * 554 * value will have an effect on the total that approaches 0 over time, and * 555 * the new delay value contributes to 1/n of the mean. * 556 * * 557 * INPUT: * 558 * delay value to add into the response time computation * 559 * * 560 * OUTPUT: * 561 * none. * 562 * * 563 * WARNINGS: * 564 * none. * 565 * * 566 * HISTORY: * 567 * 01/19/1995 BR : Created. * 568 *=========================================================================*/ 569 void CommQueueClass::Add_Delay(unsigned long delay) 570 { 571 int roundoff = 0; 572 573 if (NumDelay==256) { 574 DelaySum -= MeanDelay; 575 DelaySum += delay; 576 if ( (DelaySum & 0x00ff) > 127) 577 roundoff = 1; 578 MeanDelay = (DelaySum >> 8) + roundoff; 579 } else { 580 NumDelay++; 581 DelaySum += delay; 582 MeanDelay = DelaySum / NumDelay; 583 } 584 585 if (delay > MaxDelay) { 586 MaxDelay = delay; 587 } 588 589 } /* end of Add_Delay */ 590 591 592 /*************************************************************************** 593 * CommQueueClass::Avg_Response_Time -- returns average response time * 594 * * 595 * INPUT: * 596 * none. * 597 * * 598 * OUTPUT: * 599 * latest computed average response time * 600 * * 601 * WARNINGS: * 602 * none. * 603 * * 604 * HISTORY: * 605 * 01/19/1995 BR : Created. * 606 *=========================================================================*/ 607 unsigned long CommQueueClass::Avg_Response_Time(void) 608 { 609 return(MeanDelay); 610 611 } /* end of Avg_Response_Time */ 612 613 614 /*************************************************************************** 615 * CommQueueClass::Max_Response_Time -- returns max response time * 616 * * 617 * INPUT: * 618 * none. * 619 * * 620 * OUTPUT: * 621 * latest computed average response time * 622 * * 623 * WARNINGS: * 624 * none. * 625 * * 626 * HISTORY: * 627 * 01/19/1995 BR : Created. * 628 *=========================================================================*/ 629 unsigned long CommQueueClass::Max_Response_Time(void) 630 { 631 return(MaxDelay); 632 633 } /* end of Max_Response_Time */ 634 635 636 /*************************************************************************** 637 * CommQueueClass::Reset_Response_Time -- resets computations * 638 * * 639 * INPUT: * 640 * none. * 641 * * 642 * OUTPUT: * 643 * none. * 644 * * 645 * WARNINGS: * 646 * none. * 647 * * 648 * HISTORY: * 649 * 01/19/1995 BR : Created. * 650 *=========================================================================*/ 651 void CommQueueClass::Reset_Response_Time(void) 652 { 653 DelaySum = 0L; 654 NumDelay = 0L; 655 MeanDelay = 0L; 656 MaxDelay = 0L; 657 658 } /* end of Reset_Response_Time */ 659 660 661 /*************************************************************************** 662 * CommQueueClass::Configure_Debug -- sets up special debug values * 663 * * 664 * Mono_Debug_Print2() can look into a packet to pull out a particular * 665 * ID, and can print both that ID and a string corresponding to * 666 * that ID. This routine configures these values so it can find * 667 * and decode the ID. This ID is used in addition to the normal * 668 * CommHeaderType values. * 669 * * 670 * INPUT: * 671 * offset ID's byte offset into packet * 672 * size size of ID, in bytes; 0 if none * 673 * names ptr to array of names; use ID as an index into this * 674 * maxnames max # in the names array; 0 if none. * 675 * * 676 * OUTPUT: * 677 * none. * 678 * * 679 * WARNINGS: * 680 * Names shouldn't be longer than 12 characters. * 681 * * 682 * HISTORY: * 683 * 05/31/1995 BRR : Created. * 684 *=========================================================================*/ 685 void CommQueueClass::Configure_Debug(int offset, int size, char **names, 686 int maxnames) 687 { 688 DebugOffset = offset; 689 DebugSize = size; 690 DebugNames = names; 691 DebugMaxNames = maxnames; 692 693 } /* end of Configure_Debug */ 694 695 696 /*************************************************************************** 697 * Mono_Debug_Print -- Debug output routine * 698 * * 699 * This routine leaves 5 lines at the top for the caller's use. * 700 * * 701 * INPUT: * 702 * refresh 1 = clear screen & completely refresh * 703 * * 704 * OUTPUT: * 705 * none. * 706 * * 707 * WARNINGS: * 708 * none. * 709 * * 710 * HISTORY: * 711 * 05/02/1995 BRR : Created. * 712 *=========================================================================*/ 713 void CommQueueClass::Mono_Debug_Print(int refresh) 714 { 715 #ifdef WWLIB32_H 716 int i; // loop counter 717 static int send_col[] = {1,14,28}; // coords of send queue columns 718 static int receive_col[] = {40,54,68}; // coords of recv queue columns 719 int row,col; // current row,col for printing 720 int num; // max # items to print 721 722 struct CommHdr { // this mirrors the CommHeaderType 723 unsigned short MagicNumber; 724 unsigned char Code; 725 unsigned long PacketID; 726 } *hdr; 727 728 /*------------------------------------------------------------------------ 729 If few enough entries, call the verbose debug version 730 ------------------------------------------------------------------------*/ 731 if (MaxSend <= 16) { 732 Mono_Debug_Print2(refresh); 733 return; 734 } 735 736 /*------------------------------------------------------------------------ 737 Refresh the screen 738 ------------------------------------------------------------------------*/ 739 if (refresh) { 740 Mono_Clear_Screen (); 741 Mono_Printf("ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿\n"); 742 Mono_Printf("³ ³\n"); 743 Mono_Printf("³ ³\n"); 744 Mono_Printf("³ ³\n"); 745 Mono_Printf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´\n"); 746 Mono_Printf("³ Send Queue ³ Receive Queue ³\n"); 747 Mono_Printf("³ ³ ³\n"); 748 Mono_Printf("³ ID Ct ACK ID Ct ACK ID Ct ACK³ ID Rd ACK ID Rd ACK ID Rd ACK³\n"); 749 Mono_Printf("³ ³ ³\n"); 750 Mono_Printf("³ ³ ³\n"); 751 Mono_Printf("³ ³ ³\n"); 752 Mono_Printf("³ ³ ³\n"); 753 Mono_Printf("³ ³ ³\n"); 754 Mono_Printf("³ ³ ³\n"); 755 Mono_Printf("³ ³ ³\n"); 756 Mono_Printf("³ ³ ³\n"); 757 Mono_Printf("³ ³ ³\n"); 758 Mono_Printf("³ ³ ³\n"); 759 Mono_Printf("³ ³ ³\n"); 760 Mono_Printf("³ ³ ³\n"); 761 Mono_Printf("³ ³ ³\n"); 762 Mono_Printf("³ ³ ³\n"); 763 Mono_Printf("³ ³ ³\n"); 764 Mono_Printf("³ ³ ³\n"); 765 Mono_Printf("ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"); 766 } 767 768 /*------------------------------------------------------------------------ 769 Print Send Queue items 770 ------------------------------------------------------------------------*/ 771 if (MaxSend <= 48) { 772 num = MaxSend; 773 } else { 774 num = 48; 775 } 776 col = 0; 777 row = 0; 778 for (i = 0; i < MaxSend; i++) { 779 Mono_Set_Cursor (send_col[col],row + 8); 780 if (SendQueue[i].IsActive) { 781 hdr = (CommHdr *)SendQueue[i].Buffer; 782 hdr->MagicNumber = hdr->MagicNumber; 783 hdr->Code = hdr->Code; 784 Mono_Printf ("%4d %2d %d",hdr->PacketID, SendQueue[i].SendCount, 785 SendQueue[i].IsACK); 786 } else { 787 Mono_Printf ("____ __ _ "); 788 } 789 790 row++; 791 if (row > 15) { 792 row = 0; 793 col++; 794 } 795 } 796 797 /*------------------------------------------------------------------------ 798 Print Receive Queue items 799 ------------------------------------------------------------------------*/ 800 if (MaxReceive <= 48) { 801 num = MaxSend; 802 } else { 803 num = 48; 804 } 805 col = 0; 806 row = 0; 807 for (i = 0; i < MaxReceive; i++) { 808 Mono_Set_Cursor (receive_col[col],row + 8); 809 if (ReceiveQueue[i].IsActive) { 810 hdr = (CommHdr *)ReceiveQueue[i].Buffer; 811 Mono_Printf ("%4d %d %d",hdr->PacketID, ReceiveQueue[i].IsRead, 812 ReceiveQueue[i].IsACK); 813 } else { 814 Mono_Printf ("____ _ _ "); 815 } 816 817 row++; 818 if (row > 15) { 819 row = 0; 820 col++; 821 } 822 } 823 824 #else 825 refresh = refresh; 826 #endif 827 } /* end of Mono_Debug_Print */ 828 829 830 /*************************************************************************** 831 * CommQueueClass::Mono_Debug_Print2 -- Debug output; alternate format * 832 * * 833 * This routine prints more information than the other version; it's * 834 * called only if the number of queue entries is small enough to support * 835 * this format. * 836 * * 837 * INPUT: * 838 * refresh 1 = clear screen & completely refresh * 839 * * 840 * OUTPUT: * 841 * none. * 842 * * 843 * WARNINGS: * 844 * none. * 845 * * 846 * HISTORY: * 847 * 05/31/1995 BRR : Created. * 848 *=========================================================================*/ 849 void CommQueueClass::Mono_Debug_Print2(int refresh) 850 { 851 #ifdef WWLIB32_H 852 int i; // loop counter 853 char txt[80]; 854 int val; 855 856 struct CommHdr { // this mirrors the CommHeaderType 857 unsigned short MagicNumber; 858 unsigned char Code; 859 unsigned long PacketID; 860 } *hdr; 861 862 /*------------------------------------------------------------------------ 863 Refresh the screen 864 ------------------------------------------------------------------------*/ 865 if (refresh) { 866 Mono_Clear_Screen (); 867 Mono_Printf("ÚÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ¿\n"); 868 Mono_Printf("³ ³\n"); 869 Mono_Printf("³ ³\n"); 870 Mono_Printf("³ ³\n"); 871 Mono_Printf("ÃÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÂÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄ´\n"); 872 Mono_Printf("³ Send Queue ³ Receive Queue ³\n"); 873 Mono_Printf("³ ³ ³\n"); 874 Mono_Printf("³ ID Ct Type Data Name ACK ³ ID Rd Type Data Name ACK ³\n"); 875 Mono_Printf("³ ³ ³\n"); 876 Mono_Printf("³ ³ ³\n"); 877 Mono_Printf("³ ³ ³\n"); 878 Mono_Printf("³ ³ ³\n"); 879 Mono_Printf("³ ³ ³\n"); 880 Mono_Printf("³ ³ ³\n"); 881 Mono_Printf("³ ³ ³\n"); 882 Mono_Printf("³ ³ ³\n"); 883 Mono_Printf("³ ³ ³\n"); 884 Mono_Printf("³ ³ ³\n"); 885 Mono_Printf("³ ³ ³\n"); 886 Mono_Printf("³ ³ ³\n"); 887 Mono_Printf("³ ³ ³\n"); 888 Mono_Printf("³ ³ ³\n"); 889 Mono_Printf("³ ³ ³\n"); 890 Mono_Printf("³ ³ ³\n"); 891 Mono_Printf("ÀÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÁÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÄÙ"); 892 } 893 894 /*------------------------------------------------------------------------ 895 Print Send Queue items 896 ------------------------------------------------------------------------*/ 897 for (i = 0; i < MaxSend; i++) { 898 Mono_Set_Cursor (1,8 + i); 899 /*..................................................................... 900 Print an active entry 901 .....................................................................*/ 902 if (SendQueue[i].IsActive) { 903 /*.................................................................. 904 Get header info 905 ..................................................................*/ 906 hdr = (CommHdr *)SendQueue[i].Buffer; 907 hdr->MagicNumber = hdr->MagicNumber; 908 hdr->Code = hdr->Code; 909 sprintf(txt,"%4d %2d %-5s ", 910 hdr->PacketID, 911 SendQueue[i].SendCount, 912 ConnectionClass::Command_Name(hdr->Code)); 913 914 /*.................................................................. 915 Decode app's ID & its name 916 ..................................................................*/ 917 if (DebugSize && (DebugOffset + DebugSize) <= SendQueue[i].BufLen) { 918 if (DebugSize==1) { 919 val = *(SendQueue[i].Buffer + DebugOffset); 920 } else { 921 if (DebugSize==2) { 922 val = *((short *)(SendQueue[i].Buffer + DebugOffset)); 923 } else { 924 if (DebugSize==4) { 925 val = *((int *)(SendQueue[i].Buffer + DebugOffset)); 926 } 927 } 928 } 929 sprintf(txt + strlen(txt),"%4d ",val); 930 931 if (DebugMaxNames && val > 0 && val < DebugMaxNames) { 932 sprintf(txt + strlen(txt),"%-12s %x", 933 DebugNames[val], 934 SendQueue[i].IsACK); 935 } else { 936 sprintf(txt + strlen(txt)," %x",SendQueue[i].IsACK); 937 } 938 } 939 } else { 940 941 /*..................................................................... 942 Entry isn't active; print blanks 943 .....................................................................*/ 944 Mono_Printf("____ __ _"); 945 } 946 } 947 948 /*------------------------------------------------------------------------ 949 Print Receive Queue items 950 ------------------------------------------------------------------------*/ 951 for (i = 0; i < MaxReceive; i++) { 952 Mono_Set_Cursor (40,8 + i); 953 /*..................................................................... 954 Print an active entry 955 .....................................................................*/ 956 if (ReceiveQueue[i].IsActive) { 957 /*.................................................................. 958 Get header info 959 ..................................................................*/ 960 hdr = (CommHdr *)ReceiveQueue[i].Buffer; 961 hdr->MagicNumber = hdr->MagicNumber; 962 hdr->Code = hdr->Code; 963 sprintf(txt,"%4d %2d %-5s ", 964 hdr->PacketID, 965 ReceiveQueue[i].IsRead, 966 ConnectionClass::Command_Name(hdr->Code)); 967 /*.................................................................. 968 Decode app's ID & its name 969 ..................................................................*/ 970 if (DebugSize && (DebugOffset + DebugSize) <= SendQueue[i].BufLen) { 971 if (DebugSize==1) { 972 val = *(ReceiveQueue[i].Buffer + DebugOffset); 973 } else { 974 if (DebugSize==2) { 975 val = *((short *)(ReceiveQueue[i].Buffer + DebugOffset)); 976 } else { 977 if (DebugSize==4) { 978 val = *((int *)(ReceiveQueue[i].Buffer + DebugOffset)); 979 } 980 } 981 } 982 sprintf(txt + strlen(txt),"%4d ",val); 983 984 if (DebugMaxNames && val > 0 && val < DebugMaxNames) { 985 sprintf(txt + strlen(txt),"%-12s %x", DebugNames[val], ReceiveQueue[i].IsACK); 986 } else { 987 sprintf(txt + strlen(txt)," %x",ReceiveQueue[i].IsACK); 988 } 989 } 990 } else { 991 992 /*..................................................................... 993 Entry isn't active; print blanks 994 .....................................................................*/ 995 Mono_Printf("____ __ _"); 996 } 997 } 998 999 #else 1000 refresh = refresh; 1001 #endif 1002 } /* end of Mono_Debug_Print2 */ 1003 1004 1005 #endif 1006 1007 1008 1009 #endif