PackedSignal.cpp
上传用户:romrleung
上传日期:2022-05-23
资源大小:18897k
文件大小:4k
源码类别:

MySQL数据库

开发平台:

Visual C++

  1. /* Copyright (C) 2003 MySQL AB
  2.    This program is free software; you can redistribute it and/or modify
  3.    it under the terms of the GNU General Public License as published by
  4.    the Free Software Foundation; either version 2 of the License, or
  5.    (at your option) any later version.
  6.    This program is distributed in the hope that it will be useful,
  7.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  8.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  9.    GNU General Public License for more details.
  10.    You should have received a copy of the GNU General Public License
  11.    along with this program; if not, write to the Free Software
  12.    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA */
  13. #include <signaldata/PackedSignal.hpp>
  14. #include <signaldata/LqhKey.hpp>
  15. #include <debugger/DebuggerNames.hpp>
  16. bool
  17. printPACKED_SIGNAL(FILE * output, const Uint32 * theData, Uint32 len, Uint16 receiverBlockNo){
  18.   fprintf(output, "Signal data: ");
  19.   Uint32 i = 0;
  20.   while (i < len)
  21.     fprintf(output, "H'%.8x ", theData[i++]);
  22.   fprintf(output,"n");
  23.   fprintf(output, "--------- Begin Packed Signals --------n");  
  24.   // Print each signal separately
  25.   for (i = 0; i < len;) {
  26.     switch (PackedSignal::getSignalType(theData[i])) {
  27.     case ZCOMMIT: {
  28.       Uint32 signalLength = 4;
  29.       fprintf(output, "--------------- Signal ----------------n");
  30.       fprintf(output, "r.bn: %u "%s", length: %u "COMMIT"n", 
  31.       receiverBlockNo, getBlockName(receiverBlockNo,""), signalLength);
  32.       fprintf(output, "Signal data: ");
  33.       for(Uint32 j = 0; j < signalLength; j++)
  34. fprintf(output, "H'%.8x ", theData[i++]);
  35.       fprintf(output,"n");
  36.       break;
  37.     }
  38.     case ZCOMPLETE: {
  39.       Uint32 signalLength = 3;
  40.       fprintf(output, "--------------- Signal ----------------n");
  41.       fprintf(output, "r.bn: %u "%s", length: %u "COMPLETE"n",
  42.       receiverBlockNo, getBlockName(receiverBlockNo,""), signalLength);
  43.       fprintf(output, "Signal data: ");
  44.       for(Uint32 j = 0; j < signalLength; j++)
  45. fprintf(output, "H'%.8x ", theData[i++]);
  46.       fprintf(output,"n");
  47.       break;
  48.     }    
  49.     case ZCOMMITTED: {
  50.       Uint32 signalLength = 3;
  51.       fprintf(output, "--------------- Signal ----------------n");
  52.       fprintf(output, "r.bn: %u "%s", length: %u "COMMITTED"n",
  53.       receiverBlockNo, getBlockName(receiverBlockNo,""), signalLength);
  54.       fprintf(output, "Signal data: ");
  55.       for(Uint32 j = 0; j < signalLength; j++)
  56. fprintf(output, "H'%.8x ", theData[i++]);
  57.       fprintf(output,"n");
  58.       break;
  59.     }
  60.     case ZCOMPLETED: {
  61.       Uint32 signalLength = 3;
  62.       fprintf(output, "--------------- Signal ----------------n");
  63.       fprintf(output, "r.bn: %u "%s", length: %u "COMPLETED"n",
  64.       receiverBlockNo, getBlockName(receiverBlockNo,""), signalLength);
  65.       fprintf(output, "Signal data: ");
  66.       for(Uint32 j = 0; j < signalLength; j++)
  67. fprintf(output, "H'%.8x ", theData[i++]);
  68.       fprintf(output,"n");
  69.       break;
  70.     }
  71.     case  ZLQHKEYCONF: {
  72.       Uint32 signalLength = LqhKeyConf::SignalLength;
  73.       fprintf(output, "--------------- Signal ----------------n");
  74.       fprintf(output, "r.bn: %u "%s", length: %u "LQHKEYCONF"n",
  75.       receiverBlockNo, getBlockName(receiverBlockNo,""), signalLength);
  76.       printLQHKEYCONF(output, theData + i, signalLength, receiverBlockNo);
  77.       i += signalLength;
  78.       break;
  79.     }
  80.     case ZREMOVE_MARKER: {
  81.       Uint32 signalLength = 2;
  82.       fprintf(output, "--------------- Signal ----------------n");
  83.       fprintf(output, "r.bn: %u "%s", length: %u "REMOVE_MARKER"n",
  84.       receiverBlockNo, getBlockName(receiverBlockNo,""), signalLength);
  85.       fprintf(output, "Signal data: ");
  86.       i++; // Skip first word!
  87.       for(Uint32 j = 0; j < signalLength; j++)
  88. fprintf(output, "H'%.8x ", theData[i++]);
  89.       fprintf(output,"n");
  90.       break;
  91.     }
  92.     default:
  93.       fprintf(output, "Unknown signal typen");
  94.     }
  95.   }//for
  96.   fprintf(output, "--------- End Packed Signals ----------n");
  97.   return true;
  98. }