GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> EDS / V2-11-6 > ebf2c / rhel6-32


Interface   Data Structures   File List   Data Fields   Globals  

ebf2c.c File Reference

Converts a .ebf file into a C file. More...

#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <EDS/io/EBF_swap.h>
#include <EDS/io/EBF_stream.h>
#include <EDS/io/EBF_evts.h>
#include <EDS/EBF_evt.h>

Classes

struct  _Ctl
 Collections all the control parameters together. These are essentially the interpretted command line options. More...

Defines

#define _ADVANCE(_ptr, _nbytes)   (typeof (_ptr))((unsigned char *)(_ptr) + (_nbytes))
 Advances _ptr by _nbytes. The return value is always recast to the type of _ptr.

Typedefs

typedef struct _Ctl Ctl
 Typedef for struct _Ctl.

Functions

int main (int argc, char **argv)
 Entry point for filter.
static int fillCtl (int argc, char *argv[], Ctl *ctl)
 Examines the command line parameters and fills the print control structure.
static void printCtl (const Ctl *ctl)
 Prints the contents of the print control context.
static int convert (const Ctl *ctl)
 converts the .ebf to an output .c file
static void reportUsage (void)
 Describes the command line parameters for daqeb_print.
static const char * constructCname (const char *iname)
 Returns a pointer to the name of the output file.
static const char * constructDname (const char *cname)
 Returns a pointer to the name of data structure.
static __inline EBF_evts setupEvents (EBF_evts evts, int maxevts, int nskip, int *nevts)
 Skips to the first event to be output.
static void printHeader (FILE *cfile, const char *iname, const char *dname, int totsize)
 Prints the C file heading.
static void printEvents (FILE *cfile, EBF_evts evts, int nevts)
 Writes out the data, ASCII, for the each event.
static void printTrailer (FILE *cfile)
 Adds the trailer to words to the output file.
static __inline const unsigned
int * 
printWrds (FILE *cfile, const unsigned int *wrds, int nwrds)
 Prints the array of 32-bit words in to the output file.


Detailed Description

Converts a .ebf file into a C file.

Author:
JJRussell - russell@slac.stanford.edu
    CVS $Id: ebf2c.c,v 1.5 2011/08/04 19:46:12 russell Exp $

Define Documentation

#define _ADVANCE ( _ptr,
_nbytes   )     (typeof (_ptr))((unsigned char *)(_ptr) + (_nbytes))

Advances _ptr by _nbytes. The return value is always recast to the type of _ptr.

Parameters:
_ptr The pointer to advance
_nbytes The number of nbytes to advance _ptr by.
Returns:
The advanced pointer, recast to the type of _ptr.


Function Documentation

static const char * constructCname ( const char *  iname  )  [static]

Returns a pointer to the name of the output file.

Parameters:
iname The name of the input file
Returns:
The name of the output file
A name for the output file is constructed by appending a ".c" to the input file name.

Referenced by fillCtl().

static const char * constructDname ( const char *  cname  )  [static]

Returns a pointer to the name of data structure.

Parameters:
cname The name of the output "C" file
Returns:
The name of the output data structure
A name for the output data structure is constructed by stripping the directory and extensions from the input file name and prefixing it with "EBD_".

Warning:
Currently the algorithm is not smart enough to deal with characters that are valid in filenames but invalid in C names, eg '-'.

Referenced by fillCtl().

static int convert ( const Ctl ctl  )  [static]

converts the .ebf to an output .c file

Parameters:
ctl The control parameters, assumed to be already filled in
Returns:
Status

References _Ctl::cname, _Ctl::dname, _Ctl::iname, printCtl(), printEvents(), printHeader(), printTrailer(), setupEvents(), _Ctl::to_process, and _Ctl::to_skip.

Referenced by main().

static int fillCtl ( int  argc,
char *  argv[],
Ctl ctl 
) [static]

Examines the command line parameters and fills the print control structure.

Parameters:
argc The number of command line parameters.
argv The array of pointers to the command line parameters.
ctl The run time parameters control block to be filled.
Return values:
0,Everything is okay.
-1,Incorrect command usage. Usually this means that the input file name was absent.
This routine uses 'getopt' to process the command line parameters. Example


      $> ebf2c -n10 -s5 -c my_file.c my_file.ebf

  

Skips 5 events, then processes the next 10 of my_file.ebf. The output is rewritten to my_file.c

References _Ctl::cname, constructCname(), constructDname(), _Ctl::dname, _Ctl::iname, _Ctl::quiet, _Ctl::to_process, and _Ctl::to_skip.

Referenced by main().

int main ( int  argc,
char **  argv 
)

Entry point for filter.

Parameters:
argc Standard argument count.
argv Standard vector of command line parameter strings.
Return values:
0,if successful -1, if the file does not exist or some other internal error.
The usage of this routine is self-documenting. Simply type ebfcmp with no parameters for its usage.

References convert(), fillCtl(), and reportUsage().

static void printCtl ( const Ctl ctl  )  [static]

Prints the contents of the print control context.

Parameters:
ctl Pointer to the print control context block.

References _Ctl::cname, _Ctl::dname, _Ctl::iname, _Ctl::to_process, and _Ctl::to_skip.

Referenced by convert().

static void printEvents ( FILE *  cfile,
EBF_evts  evts,
int  nevts 
) [static]

Writes out the data, ASCII, for the each event.

Parameters:
cfile The output file stream.
evts The array of events to write out
nevts The number of events to write out

References EBF__evtSize(), and printWrds().

Referenced by convert().

static void printHeader ( FILE *  cfile,
const char *  iname,
const char *  dname,
int  esize 
) [static]

Prints the C file heading.

Parameters:
cfile The output file stream
iname The name of the input file
dname The name of the output data structure
esize The size, in bytes, of the output data

Referenced by convert().

static void printTrailer ( FILE *  cfile  )  [static]

Adds the trailer to words to the output file.

Parameters:
cfile The output file stream.

Referenced by convert().

static const unsigned int * printWrds ( FILE *  cfile,
const unsigned int *  wrds,
int  nwrds 
) [static]

Prints the array of 32-bit words in to the output file.

Parameters:
cfile The file handle
wrds The array of words to format
nwrds The number of words to format

Referenced by printEvents().

static __inline EBF_evts setupEvents ( EBF_evts  evts,
int  maxevts,
int  nskip,
int *  nevts 
) [static]

Skips to the first event to be output.

Parameters:
evts The events
maxevts The maximum number of events to process, if -1, do all
nskip The number of events to skip
nevts Returned as the number of events to process
Returns:
A pointer to the first event to be output

Referenced by convert().


Generated on Fri Dec 9 16:40:33 2011 by  doxygen 1.5.8