evio  5.2
 All Data Structures Files Functions Variables Typedefs Macros Groups
eviofmt.c File Reference
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include <limits.h>
#include "evio.h"

Macros

#define MAX(a, b)   ( (a) > (b) ? (a) : (b) )
 
#define debugprint(ii)   printf(" [%3d] %3d (16 * %2d + %2d), nr=%d\n",ii,ifmt[ii],ifmt[ii]/16,ifmt[ii]-(ifmt[ii]/16)*16,nr)
 

Functions

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

Macro Definition Documentation

#define debugprint (   ii)    printf(" [%3d] %3d (16 * %2d + %2d), nr=%d\n",ii,ifmt[ii],ifmt[ii]/16,ifmt[ii]-(ifmt[ii]/16)*16,nr)

Referenced by eviofmt().

#define MAX (   a,
 
)    ( (a) > (b) ? (a) : (b) )

Referenced by eviofmt().

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.