GLAST / LAT > DAQ and FSW > FSW > Doxygen Index> EDST / V1-2-1 > ebf_diff / rhel6-32


Interface   Data Structures   File List   Data Fields   Globals  

ebf_diff.c File Reference

Crude program to check for differences between two ebf files. More...

#include <EDS/EDSD_print.h>
#include <EDS/io/EBF_stream.h>
#include <EDS/io/LCBP.h>
#include <EDS/LCBV.h>
#include <EDS/EBF_mc.h>
#include <EDS/EBF_evt.h>
#include <EDS/EBF_cid.h>
#include <EDS/EBF_dir.h>
#include <EDS/EBF_gem.h>
#include <EDS/EBF_cal.h>
#include <EDS/EBF_tkr.h>
#include <EDS/EBF_tem.h>
#include <EDS/EBF_err.h>
#include <EDS/EBF_siv.h>
#include <EDS/EBF_match.h>
#include <EDST/EDST_compareList.h>
#include <PBI/FFS.ih>
#include <PBI/Ofs.h>
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include <strings.h>

Defines

#define ET(_seq)   "\033[" _seq "m"
#define ET2(_seq0, _seq1)   "\033[" _seq0 ";" _seq1 "m"
#define ET3(_seq0, _seq1, seq2)   "\033[" _seq0 ";" _seq1 ";" _seq2 "m"
#define ET4(_seq0, _seq1, seq2, seq3)
#define NORMAL   "0"
#define BOLD   "1"
#define DIM   "2"
#define UNDERSCORE   "4"
#define BLINK   "5"
#define REVERSE   "7"
#define FG_BLACK   "30"
#define FG_RED   "31"
#define FG_GREEN   "32"
#define FG_YELLOW   "33"
#define FG_BLUE   "34"
#define FG_MAGENTA   "35"
#define FG_CYAN   "36"
#define FG_WHITE   "37"
#define BG_BLACK   "40"
#define BG_RED   "41"
#define BG_GREEN   "42"
#define BG_YELLOW   "43"
#define BG_BLUE   "44"
#define BG_MAGENTA   "45"
#define BG_CYAN   "46"
#define BG_WHITE   "47"
#define EH(string)   ET(BOLD) # string ET(NORMAL) "\n"
#define EA(string)   ET(BOLD) # string ET(NORMAL)

Typedefs

typedef enum _PARSE_REASON_K PARSE_REASON_K
typedef int(* ParseProcess )(void *ctx, PARSE_REASON_K reason, int pidx, char optchr, const char *optstr)
 Parsing callback routine.

Enumerations

enum  _PARSE_REASON_K {
  PARSE_REASON_K_OPTNOARG = -2,
  PARSE_REASON_K_OPTUNK = -1,
  PARSE_REASON_K_PRMNEW = 0,
  PARSE_REASON_K_OPTION = 1
}

Functions

static int FillCtl (Ctl *ctl, int argc, char *const argv[])
 Examines the command line parameters and fills the print control structure.
int main (int argc, char *const argv[])
 Usual entry point for the readtest.
static int parse (const char *options, int argc, char *const argv[], ParseProcess process, void *ctx)
 Cheap replacement for getopt that provides some capability for global, local and positional parameters. It also allows more than one list arguments to be parsed.
static int parameter_set (Prms *prms, PARSE_REASON_K reason, int pidx, char optchr, const char *optstr)
 The callback routine for parse. parse calls this back once for every new parameter, option or error that it encounters as it sequentially processes the command line tokens.
static void ignore_static_compile (Ignore *ignore, unsigned int processOpts)
 Compiles the static portion of the ignore lists.
static int compile (Ctl *ctl, const Prms *prms)
static void ReportUsage (void)
 Reports the usage of the ebf_diff utility.


Detailed Description

Crude program to check for differences between two ebf files.

Author:
Ed Bacho - ebacho@slac.stanford.edu

JJRussell - russell@slac.stanford.edu

Example:

    $ ebf_diff -n<# of events> -s<# to skip in file2> <file1.ebf> <file2.ebf>
   

For a complete explanation type ebf_diff with no arguments.
Basic Algorithm for the program Use file1 as the "compare" file loop thru all events in file1 to determine how many events in file allocate a compareList to hold info on each event loop thru all events in file1 as the pre-process step, for each event save its fileSeq number save a copy of the event in a contigous buffer (i.e. remove any extra data due to event splitting in the file save a description of the event Loop thru file2 (whether memory array or file)

    CVS $Id: ebf_diff.c,v 1.10 2011/03/30 20:37:49 russell Exp $

Define Documentation

#define ET4 ( _seq0,
_seq1,
seq2,
seq3   ) 

Value:

"\033[" _seq0 ";" _seq1 ";" _seq2 ";" \
                                                                  _seq3 "m"


Typedef Documentation

int(* ParseProcess)(void *ctx, PARSE_REASON_K reason, int parameter_idx, char optchr, const char *optstr)

Parsing callback routine.

Return values:
== 0 Continue parsing
!= 0 Stop parsing, presumably because of an non-recoverable error.
Parameters:
ctx User context parameter
reason Reason for callback. These are enumerated by PARSE_REASON_K
  • PARSE_REASON_K_OPTNOARG, the command line specified an option that demanded a value, but no value was given. The optchr parameter contains the offending option.
  • PARSE_REASON_K_OPTUNK, the command line contained an option not in the options string provided to parse. The optchr parameter contains the offending option.

  • PARSE_REASON_K_PRMNEW, a new parameter was found. The parameter's string value is found in the optstr parameter.

  • PARSE_REASON_K_OPTION, an option character was encountered. If the option takes an argument, that argument is pointed to by optstr. Note that PARSE guarantees that all error reasons are negative.
    Parameters:
    pidx The value of the parameter index. The value for pidx after the first parameter is 0, after the second 1, etc. The value before any parameters is -1. This allows one so associate options with a given parameter or with the global parameters. This roughly approximates the idea of global, local and positional parameters.
    optchr The option character. In the case of an error reason code or PARSE_REASON_K_OPTION, this is the option character. In the case of PARSE_REASON_K_PRMNEW, the value is 0.
    optstr If the reason is
    • PARSE_REASON_K_PRMNEW, optstr is a pointer parameter string. In many utilities, this is, for example, a file name.
    • PARSE_REASON_K_OPTION and the option takes an argument, optstr is a pointer to the argument.


Enumeration Type Documentation

Enumerator:
PARSE_REASON_K_OPTNOARG  Option needs, but does not have an argument
PARSE_REASON_K_OPTUNK  Invalid options, optchr is the invalid option character
PARSE_REASON_K_PRMNEW  New parameter
PARSE_REASON_K_OPTION  New option, optchr is the option character


Function Documentation

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

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

Parameters:
ctl The parameter control block.
argc The number of command line parameters.
argv The array of pointers to the command line parameters.
Return values:
0,Everything is okay.
-1,Incorrect command usage. Usually this means that the input file name was absent.
Host argument parsing routine

References parameter_set(), parse(), and ReportUsage().

Referenced by main().

static void ignore_static_compile ( Ignore *  ignore,
unsigned int  processOpts 
) [static]

Compiles the static portion of the ignore lists.

void ignore_static_compile (Ignore *ignore, unsigned int processOpts)

Parameters:
ignore The ignore structure to fill
processOpts The list of process options
The ignore lists contain, on a contributor-by-contributor basis a list of descriptors giving which words and which fields of those words should be ignored when checking for equality. There are really two types of descriptors
  • Those that have fixed offsets in the contributor. These are fields like the event sequence number
  • Those that whose offsets that are dependent on the data. These are fields like the pad fields, both whose offset and count are dependent on the contributors length

This routine fills in the descriptors for those with fixed offsets. Since the code assumes the descriptors are sorted by offset, by good fortune all the fix offset descriptors occur first. If this were not the case, then something more complicated would have to be done.

int main ( int  argc,
char *const   argv[] 
)

Usual entry point for the readtest.

Parameters:
argc The number of arguments
argv The vector of arguments.
Host main routine

References FillCtl().

static int parameter_set ( Prms *  prms,
PARSE_REASON_K  reason,
int  pidx,
char  optchr,
const char *  optstr 
) [static]

The callback routine for parse. parse calls this back once for every new parameter, option or error that it encounters as it sequentially processes the command line tokens.

int parameter_set (Prms *prms, PARSE_REASON_K reason, int pidx, char optchr, const char *optstr)

Return values:
== 0, continue parsing
!= 0, stop parsing, presumably because of an error.
Parameters:
prms Data structure to receive the parsed parameter/option
reason Reason for callback. These are enumerated by PARSE_REASON_K
  • PARSE_REASON_K_OPTNOARG, the command line specified an option that demanded a value, but no value was given. The optchr parameter contains the offending option.
  • PARSE_REASON_K_OPTUNK, the command line contained an option not in the options string provided to parse. The optchr parameter contains the offending option.

  • PARSE_REASON_K_PRMNEW, a new parameter was found. The parameter's string value is found in the optstr parameter.

  • PARSE_REASON_K_OPTION, an option character was encountered. If the option takes an argument, that argument is pointed to by optstr. Note that PARSE guarantees that all error reasons are negative.

Parameters:
pidx The value of the parameter index. The value for pidx after the first parameter is 0, after the second 1, etc. The value before any parameters is -1. This allows one so associate options with a given parameter or with the global parameters. This roughly approximates the idea of global, local and positional parameters.
optchr The option character. In the case of an error reason code or PARSE_REASON_K_OPTION, this is the option character. In the case of PARSE_REASON_K_PRMNEW, the value is 0.
optstr If the reason is
  • PARSE_REASON_K_PRMNEW, optstr is a pointer parameter string. In many utilities, this is, for example, a file name.
  • PARSE_REASON_K_OPTION and the option takes an argument, optstr is a pointer to the argument.

References PARSE_REASON_K_OPTNOARG, PARSE_REASON_K_OPTUNK, and PARSE_REASON_K_PRMNEW.

Referenced by FillCtl().

static int parse ( const char *  options,
int  argc,
char *const   argv[],
ParseProcess  process,
void *  ctx 
) [static]

Cheap replacement for getopt that provides some capability for global, local and positional parameters. It also allows more than one list arguments to be parsed.

Parameters:
options The options string. The format is the same as for getopt.
argc The count of the number of arguments in argv
argv The array of arguments
process A user provided callback routine to process both the command line parameters and options
ctx A context parameter for process.
While this routine is currently private to ebf_diff, it is, in fact, almost a decent general purpose command line parsing utility. All the is really needed is more flexible way to specify the options string. Ideally, one wants a set of global options and a set of local and/or positional options that can be different for each parameter. This routine only takes one set of command line options for everything.

printf ("Argv[%2u] = %s\n", idx, s);

printf ("Parameter: %s\n", s);

printf ("Option = %c : %s\n", c, arg ? arg : "<none>");

References PARSE_REASON_K_OPTION, PARSE_REASON_K_OPTNOARG, PARSE_REASON_K_OPTUNK, and PARSE_REASON_K_PRMNEW.

Referenced by FillCtl().


Generated on Tue Nov 29 17:27:50 2011 by  doxygen 1.5.8