evio  6.0
 All Data Structures Files Functions Variables Typedefs Macros Groups
evioswap.c File Reference
#include <stdio.h>
#include "evio.h"

Functions

int eviofmt (char *fmt, unsigned short *ifmt, int ifmtLen)
 
int eviofmtswap (uint32_t *iarr, int nwrd, unsigned short *ifmt, int nfmt, int tolocal, int padding)
 
int evioIsLocalHostBigEndian ()
 Is the local host big endian? More...
 
uint64_t evioToLongWord (uint32_t word1, uint32_t word2, int needToSwap)
 Take 2, 32 bit words and change that into a 64 bit word, taking endianness and swapping into account. More...
 
void evioSwapFileHeaderV6 (uint32_t *header)
 Swap an evio version 6 file header in place (but not the following index arrary, etc). More...
 
void evioSwapRecordHeaderV6 (uint32_t *header)
 Swap an evio version 6 record header in place (but not the following index arrary, etc). More...
 
void evioswap (uint32_t *buf, int tolocal, uint32_t *dest)
 Routine to swap the endianness of an evio event (bank). More...
 
uint32_tswap_int32_t (uint32_t *data, unsigned int length, uint32_t *dest)
 This routine swaps a buffer of 32 bit integers. More...
 
uint64_tswap_int64_t (uint64_t *data, unsigned int length, uint64_t *dest)
 This routine swaps a buffer of 64 bit integers. More...
 
uint16_tswap_int16_t (uint16_t *data, unsigned int length, uint16_t *dest)
 This routine swaps a buffer of 16 bit integers. More...
 

Detailed Description


################################
COMPOSITE DATA:
################################
  This is a new type of data (value = 0xf) which originated with Hall B.
  It is a composite type and allows for possible expansion in the future
  if there is a demand. Basically it allows the user to specify a custom
  format by means of a string - stored in a tagsegment. The data in that
  format follows in a bank. The routine to swap this data must be provided
  by the definer of the composite type - in this case Hall B. The swapping
  function is plugged into this evio library's swapping routine.
  Here's what it looks like.
MSB(31)                          LSB(0)
<---  32 bits ------------------------>
_______________________________________
|  tag    | type |    length          | --> tagsegment header
|_________|______|____________________|
|        Data Format String           |
|                                     |
|_____________________________________|
|              length                 | \
|_____________________________________|  \  bank header
|       tag      |  type   |   num    |  /
|________________|_________|__________| /
|               Data                  |
|                                     |
|_____________________________________|

The beginning tagsegment is a normal evio tagsegment containing a string (type = 0x3). Currently its type and tag are not used - at least not for data formatting. The bank is a normal evio bank header with data following. The format string is used to read/write this data so that takes care of any padding that may exist. As with the tagsegment, the tag, type, & num are ignored.

Function Documentation

int eviofmt ( char *  fmt,
unsigned short *  ifmt,
int  ifmtLen 
)

 This routine transforms a composite, format-containing
 ASCII string to an unsigned char array. It is to be used
 in conjunction with eviofmtswap to swap the endianness of
 composite data.
  format code bits <- format in ascii form
   [15:14] [13:8] [7:0]
     Nnm      #     0           #'('
       0      0     0            ')'
     Nnm      #     1           #'i'   unsigned int
     Nnm      #     2           #'F'   floating point
     Nnm      #     3           #'a'   8-bit char (C++)
     Nnm      #     4           #'S'   short
     Nnm      #     5           #'s'   unsigned short
     Nnm      #     6           #'C'   char
     Nnm      #     7           #'c'   unsigned char
     Nnm      #     8           #'D'   double (64-bit float)
     Nnm      #     9           #'L'   long long (64-bit int)
     Nnm      #    10           #'l'   unsigned long long (64-bit int)
     Nnm      #    11           #'I'   int
     Nnm      #    12           #'A'   hollerit (4-byte char with int endining)
  NOTES:
   1. The number of repeats '#' must be the number between 2 and 63, number 1 assumed by default
   2. If the number of repeats is symbol 'N' instead of the number, it will be taken from data assuming 'int32' format;
      if the number of repeats is symbol 'n' instead of the number, it will be taken from data assuming 'int16' format;
      if the number of repeats is symbol 'm' instead of the number, it will be taken from data assuming 'int8' format;
      Two bits Nnm [15:14], if not zero, requires to take the number of repeats from data in appropriate format:
           [01] means that number is integer (N),
           [10] - short (n),
           [11] - char (m)
   3. If format ends but end of data did not reach, format in last parenthesis
      will be repeated until all data processed; if there are no parenthesis
      in format, data processing will be started from the beginnig of the format
      (FORTRAN agreement)
Parameters
fmtnull-terminated composite data format string
ifmtunsigned short array to hold transformed format
ifmtLenlength of unsigned short array, ifmt, in # of shorts
Returns
the number of shorts in ifmt[] (positive)
-1 to -8 for improper format string
-9 if unsigned char array is too small

References debugprint, and MAX.

int eviofmtswap ( uint32_t iarr,
int  nwrd,
unsigned short *  ifmt,
int  nfmt,
int  tolocal,
int  padding 
)