Back to home page

sPhenix code displayed by LXR

 
 

    


File indexing completed on 2025-08-03 08:20:32

0001 /* 
0002 ** CpacketV1.C
0003 ** 
0004 ** Author: $Author: purschke $  
0005 **   Date: $Date: 2000/07/21 01:51:10 $ 
0006 ** 
0007 ** $Log: CpacketV1.C,v $
0008 ** Revision 1.1.1.1  2000/07/21 01:51:10  purschke
0009 ** mlp -- adding the new automakified "basic" module to CVS.
0010 **
0011 **
0012 ** Revision 1.4  1999/07/12 14:23:37  phoncs
0013 ** (stephen markacs) added endianism setting to makePacketV1Hdr() in CpacketV1.C
0014 **
0015 ** Revision 1.3  1998/12/11 22:01:59  markacs
0016 ** (stephen markacs) adding log into cvs tags
0017 ** 
0018 */
0019 /*
0020 **  These are the Version 1 routines to provide
0021 **  information from and acces to the fields in the 
0022 **  packet header.  The inlined routines are 
0023 **  contained in CpacketV1.h.  
0024 **
0025 */
0026 #include "phenixOnline.h"
0027 #include "Cpacket.h"
0028 #include "CpacketV1.h"
0029 
0030 VALUE_ret makePacketV1Hdr (PHDWORD* packet_ptr, UINT maxPacketLength)
0031 {
0032   if (maxPacketLength < packetV1HdrLength) 
0033     return valueFailure;
0034 
0035   dwordClear(packet_ptr, packetV1HdrLength);
0036   setPacketLength(packet_ptr, packetV1HdrLength);
0037   setPacketHdrVersion (packet_ptr, packetV1HdrVersion);
0038   setPacketHdrLength (packet_ptr, packetV1HdrLength);
0039 
0040   unsigned long n = 1;
0041   char * cp = (char*)&n;
0042   if (*cp==1) setPacketEndianism(packet_ptr, 1);
0043          else setPacketEndianism(packet_ptr, 2);
0044 
0045   return packetV1HdrLength;
0046 }
0047 
0048 /*
0049 ** Return a pointer to the debug block.
0050 */
0051 PTR_ret findPacketV1DebugStart (PACKET_ptr packet_ptr)
0052 {
0053   return (packet_ptr + getPacketLength(packet_ptr) - 
0054           getPacketV1DebugLength(packet_ptr) - getPacketV1ErrorLength(packet_ptr) );
0055 }
0056 
0057 /*
0058 ** Return a pointer to the error block.
0059 */
0060 PTR_ret findPacketV1ErrorStart (PACKET_ptr packet_ptr)
0061 {
0062   return (packet_ptr + getPacketLength(packet_ptr) - 
0063       getPacketV1ErrorLength(packet_ptr));
0064 }
0065 
0066 PTR_ret findPacketV1DataStart (PACKET_ptr packet_ptr)
0067 {
0068   return packet_ptr + getPacketHdrLength(packet_ptr);
0069 } 
0070 
0071 PTR_ret findPacketV1DataEnd (PACKET_ptr packet_ptr)
0072 {
0073   return findPacketV1DebugStart(packet_ptr) - 1;
0074 } 
0075 
0076 
0077 /*
0078 **  Check for a valid V1 header. Currently this test only checks the
0079 **    length to make sure its consistent with the expected length.
0080 **
0081 */
0082 LOGIC_ret validPacketV1Hdr (PACKET_ptr packet_ptr)
0083 {
0084   if (getPacketHdrLength(packet_ptr) == packetV1HdrLength) {
0085     setPacketSuccess();
0086     return TRUE;
0087   }
0088   else {
0089     setPacketError (FORMAT_ERR_INVALID_HEADER, packet_ptr, 0);
0090     return FALSE;
0091   }
0092 }
0093 
0094 
0095 
0096 
0097 
0098 
0099 
0100 
0101 
0102 
0103 
0104 
0105 
0106 
0107