Short: Script driven messageport monitor Author: schettler@informatik.fh-wuerzburg.de (Michael Schettler) Uploader: schettler informatik fh-wuerzburg de (Michael Schettler) Type: dev/misc Architecture: m68k-amigaos This is just a small hack i needed some time ago. The programm reads an ascii scriptfile where a messageport name and the structure of the incomming messages is given, and monitors the port. If a message arrives, it's dumped to the specified output using the defined structure. To exit press CTRL-C use the break command. Example scriptfile: ; Cmd Offset Text ; -------------------------------------------------------------------- OUTPUT "CON:0/100/640/156/PortSnoop/auto/smart/close" PORT "REXX" TEXT $0c,"Monitoring 'REXX' port",$0a MPTR "Message ($%06lx)",$0a TEXT $0a BYTE=$08 "LN_TYPE $%02lx",$0a BYTE=$09 "LN_PRI $%02lx",$0a ASTR=$0a "LN_NAME $%08lx ('%s')",$0a APTR=$0e "MN_REPLYPORT $%08lx",$0a APTR=$0e.ASTR=$0a " LN_NAME $%08lx ('%s')",$0a WORD=$12 "MN_LENGTH $%04lx",$0a TEXT $0a LONG=$1c "rm_Action $%08lx",$0a LONG=$20 "rm_Result1 $%08lx",$0a LONG=$24 "rm_Result2 $%08lx",$0a ASTR=$28 "rm_Args,16*4 $%08lx ('%s')",$0a APTR=$68 "rm_PassPort $%08lx",$0a APTR=$68.ASTR=$0a " LN_NAME $%08lx ('%s')",$0a END ; -------------------------------------------------------------------- Any field of the message can be displayed. It's even possible, to reference values. That means that the value, which is contained at offset, is taken as a new structure address. Example: APTR=$0e "MN_REPLYPORT $%08lx",$0a -> the address of the replyport is printed. APTR=$0e.ASTR=$0a " LN_NAME $%08lx ('%s')",$0a 1 2 -> the address of the reply-port (1) contained at offset $0e of the message is taken as a pointer to a new structure (in this case the node structure of the message replyport). The pointer at offset $0a (2) of the new (actual) structure is taken again as pointer to another structure (in this case the LN_NAME field). Finally the name of the replyport (LN_NAME), which is pointed to at offset $0a (2), is printed together with the address of the last (the node) structure. Syntax of the script file: each line consists of COMMAND [OFFSET] ['TEXT' | "TEXT" | $xx] where COMMAND see syntax below OFFSET a hexadecimal offset into the message, wich is given with an equal sign example: $09 to access the LN_PRI field of a node TEXT surrounded by either single- or doublequote. Also single chars given in hexadecimal can be printed (including PrintF()-style formatting). example: $09,"LN_PRI = %02lx",$0a note1: add a carrige-return (= $0a) to each line! note2: always specify long size in PrintF()-style Syntax of the commands: Command Argument Description ---------------------------------------------------------------------- ; comment introducer OUTPUT specifies the output e.g. OUTPUT "CON:0/0/640/256/Snoop" or OUTPUT "RAM:output.txt" PORT [text | $address] the name or the address e.g. PORT "REXX" of the port to monitor or PORT $BADC0DE TEXT displays given text e.g. TEXT $0c,"Hello!",$0a MPTR (1) insert the adress of e.g. MPTR "Adr of Msg = %lx",$0a the message BYTE (1) reads the value which e.g. BYTE=$09 "LN_PRI=%02lx",$0a is stored at offset as byte. WORD see BYTE, only as word LONG see BYTE, only as long APTR see LONG BPTR see LONG, shown as value*4 ASTR (2) reads the value and e.g. ASTR=$0a $0c,"LN_NAME %s",$0a displays the text, which is pointed to BSTR see ASTR, only value*4 END signals the end of the script. (important!) ---------------------------------------------------------------------- means PrintF() style format parameters. (1) Has only one format parameter: "%lx" (2) Has two format parameters: "%s" and "%lx"