?? uddump.c
字號:
/* $Header: "%n Ver=%v %f LastEdit=%w Locker=%l" */
/* "UDDUMP.C Ver=1 5-Nov-97,14:00:00 LastEdit=JIMV Locker=***_NOBODY_***" */
/***********************************************************************\
* *
* Copyright Wonderware Software Development Corp. 1992-1997 *
* *
* ThisFileName="L:\ww\dde_serv\src\udsample\uddump.c" *
* LastEditDate="1997 Nov 05 14:00:00" *
* *
\***********************************************************************/
/* Displays for debugging purposes the contents of various protocol data
structures.
*/
#define LINT_ARGS
#include <windows.h>
#include <stdio.h>
#include <string.h>
#include "ntconv.h"
#include "hmemcpy.h"
#include "chainmgr.h"
#include "udprot.h"
#include "uddefs.h"
#include "udgetstr.h"
#include "debug.h"
/***********************************************************************/
/** have the logger display dump information,
using data from the indicated message structure.
returns pointer to next message if successful **/
LPUDMSG
WINAPI
UdprotDumpMessage( LPUDMSG lpMsg )
{
int i;
/* check message pointer */
if( lpMsg == (LPUDMSG)NULL ) {
/* do nothing, just return */
return (LPUDMSG)NULL;
}
/*******************************************************************\
Note: The display of the message should be tailored to the
protocol for clarity and ease of debugging.
\*******************************************************************/
/* display message pointer, linked list pointers, status, and address range */
sprintf(dbgBuf,"MSG: %Fp Nx:%Fp Sn:%Fp Act:%2d St:%5u En:%5u Sz:%2d",
lpMsg, lpMsg->mmChainLink.next_item.ptr, lpMsg->mmTopic, lpMsg->mmActiveCt,
lpMsg->mmStartAddr, lpMsg->mmEndAddr, lpMsg->mmSize );
debug( dbgBuf );
/* display contents of message as hex ASCII */
dbgBuf[0] = '\0';
for (i=0; i<lpMsg->mmSize; i++) {
sprintf( &dbgBuf[strlen(dbgBuf)], "%02X ", lpMsg->mmData[i] );
}
debug( dbgBuf );
/* get and return pointer to next message, if any */
return ((LPUDMSG) (lpMsg->mmChainLink.next_item.ptr));
} /* UdprotDumpMessage */
/***********************************************************************/
/** have the logger display dump information,
using data from the indicated station's symbol table **/
void
WINAPI
UdprotDumpSymbolTable( LPSTAT lpTopic )
{
LPEXTARRAY lpSymbol_table;
LPCHAIN lpUsed_symbols;
SYMPTR lpSymEnt;
CHAINSCANNER symbol_scanner;
/* get pointers to symbol table, chains */
lpSymbol_table = &lpTopic->statSymTab;
lpUsed_symbols = &lpTopic->statSymUsed;
/* check whether symbol table has been allocated */
if (lpSymbol_table->member_count == 0) {
/* do nothing, just return */
return;
}
/* display size of symbol table, number of entries used */
sprintf(dbgBuf,"SYMBOL TABLE: %Fp Cap:%3ul Cnt:%3ul",
lpSymbol_table->first_member,
(unsigned long) lpSymbol_table->member_count,
(unsigned long) lpUsed_symbols->item_count);
debug( dbgBuf );
/*******************************************************************\
Note: The display of the symbols should be tailored to the
protocol for clarity and ease of debugging.
\*******************************************************************/
/* scan through list of used symbols */
lpSymEnt = (SYMPTR) FindFirstItem (lpUsed_symbols, SCAN_FROM_HEAD,
NULL, NULL, &symbol_scanner);
while( lpSymEnt != (SYMPTR) NULL ) {
/* display details of symbol */
sprintf(dbgBuf, "PlcDataType (%d), Alias(%05u) Bit(%04X) Sub (%d) "
"Prcs(%d) Hnd(%04lX) Type(%d) ",
(int) lpSymEnt->msPlcDataType, (int) lpSymEnt->msAddr1,
(int) lpSymEnt->msBitPos, (int) lpSymEnt->msSubType,
(int)lpSymEnt->msNumBytes,
(unsigned long)lpSymEnt->msDbHnd, (int)lpSymEnt->msDdeType);
/* display list links for symbol */
sprintf(&dbgBuf[strlen(dbgBuf)], "Prv(%3lu) Self(%3lu) Nxt(%3lu)",
(unsigned long) (lpSymEnt->msChainLink.prev_item.offs),
(unsigned long) (lpSymEnt->msIndex),
(unsigned long) (lpSymEnt->msChainLink.next_item.offs));
debug( dbgBuf );
/* get pointer to next used symbol, if any */
lpSymEnt = (SYMPTR) FindNextItem (&symbol_scanner);
}
} /* UdprotDumpSymbolTable */
/***********************************************************************/
/** have logger display dump information,
using data from indicated station structure.
returns pointer to next station if successful **/
LPSTAT
WINAPI
UdprotDumpTopic( LPSTAT lpTopic )
{
LPUDMSG lpMsg;
CHAINSCANNER message_scanner;
/* check station pointer */
if( lpTopic == (LPSTAT)NULL ) {
/* do nothing, just return */
return (LPSTAT)NULL;
}
/* display station pointer, topic name, etc., list links for station */
sprintf(dbgBuf,"STN:%Fp Id:%2d Prt:%Fp Nx:%Fp Sym:%Fp FR:%Fp FW:%Fp",
lpTopic, lpTopic->statTopic, lpTopic->statPort,
lpTopic->statChainLink.next_item.ptr,
lpTopic->statSymTab, lpTopic->statReadMsgList.first_item.ptr,
lpTopic->statWriteMsgList.first_item.ptr );
debug( dbgBuf );
/* display dump info for symbol table */
UdprotDumpSymbolTable( lpTopic );
/* display dump info for all read messages in queue */
debug(" ** Read Messages Queued **");
lpMsg = (LPUDMSG) FindFirstItem (&lpTopic->statReadMsgList, SCAN_FROM_HEAD,
NULL, NULL, &message_scanner);
while( lpMsg != (LPUDMSG)NULL ) {
UdprotDumpMessage( lpMsg );
lpMsg = (LPUDMSG) FindNextItem (&message_scanner);
}
/* display dump info for all write messages in queue */
lpMsg = (LPUDMSG) FindFirstItem (&lpTopic->statWriteMsgList, SCAN_FROM_HEAD,
NULL, NULL, &message_scanner);
if( lpMsg != (LPUDMSG)NULL ) {
debug(" ** Write Messages Queued **");
while( lpMsg != (LPUDMSG)NULL ) {
UdprotDumpMessage( lpMsg );
lpMsg = (LPUDMSG) FindNextItem (&message_scanner);
}
}
/* get and return pointer to next station, if any */
return( (LPSTAT) (lpTopic->statChainLink.next_item.ptr) );
} /* UdprotDumpTopic */
/***********************************************************************/
/** have logger display dump information,
using data from indicated port structure.
returns pointer to next port if successful */
LPPORT
WINAPI
UdprotDumpPort( LPPORT lpPort )
{
LPSTAT lpTopic;
CHAINSCANNER station_scanner;
/* check port pointer */
if( lpPort == (LPPORT)NULL ) {
/* do nothing, just return */
return (LPPORT)NULL;
}
/* display port pointer, name, protocol status, linked list pointers */
sprintf( dbgBuf,
"PORT: %Fp %Fs Nx:%Fp Pv:%Fp FSn:%Fp CSn:%Fp CM:%Fp cid:%d",
lpPort, (LPSTR) lpPort->mbPortName,
lpPort->mbChainLink.next_item.ptr,
lpPort->mbChainLink.prev_item.ptr,
lpPort->mbTopicList.first_item.ptr, lpPort->mbCurTopic,
lpPort->mbCurMsg, lpPort->mbCid );
debug( dbgBuf );
/* display dump info for all stations associated with this port */
lpTopic = (LPSTAT) FindFirstItem (&lpPort->mbTopicList, SCAN_FROM_HEAD,
NULL, NULL, &station_scanner);
while( lpTopic != (LPSTAT)NULL ) {
UdprotDumpTopic( lpTopic );
lpTopic = (LPSTAT) FindNextItem (&station_scanner);
}
/* get and return handle to next port, if any */
return( (LPPORT) (lpPort->mbChainLink.next_item.ptr) );
} /* UdprotDumpPort */
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -