Fork me on GitHub

source: svn/trunk/Utilities/mcfio/mcf_xdr.h@ 338

Last change on this file since 338 was 3, checked in by Xavier Rouby, 16 years ago

first commit

File size: 8.4 KB
RevLine 
[3]1/*******************************************************************************
2* *
3* mcf_xdr.h -- Include file for mcfast Xdr layer. Specifies the headers *
4* ( Block, event, table and files) * *
5* *
6* Copyright (c) 1994 Universities Research Association, Inc. *
7* All rights reserved. *
8* *
9* This material resulted from work developed under a Government Contract and *
10* is subject to the following license: The Government retains a paid-up, *
11* nonexclusive, irrevocable worldwide license to reproduce, prepare derivative *
12* works, perform publicly and display publicly by or for the Government, *
13* including the right to distribute to other Government contractors. Neither *
14* the United States nor the United States Department of Energy, nor any of *
15* their employees, makes any warrenty, express or implied, or assumes any *
16* legal liability or responsibility for the accuracy, completeness, or *
17* usefulness of any information, apparatus, product, or process disclosed, or *
18* represents that its use would not infringe privately owned rights. *
19* *
20*******************************************************************************/
21#define MCF_XDR_F_TITLE_LENGTH 255
22#define MCF_XDR_B_TITLE_LENGTH 80
23#define MCF_XDR_MAXLREC 32000
24#define MCF_XDR_MINLREC 512
25#define MCF_XDR_VERSION "v0.0"
26#define MCF_STREAM_NUM_MAX 20
27#define MCF_DEFAULT_TABLE_SIZE 100
28#define MCF_XDR_VERSION_LENGTH 4
29#define MCF_XDR_STDCM2_LENGTH 20
30#define XDR_MCFIOCODE 1025 /* Private code to be passed to the encoding
31 filter to estimate the length prior to encode
32 in memory */
33
34typedef enum _mcfxdrBlockType {
35 GENERIC, FILEHEADER, EVENTTABLE, SEQUENTIALHEADER,
36 EVENTHEADER, NOTHING
37} mcfxdrBlockType;
38
39
40typedef struct _mcfxdrGeneric{
41 int id; /* Identifier for this item = FILEHEADER */
42 int length; /* The length of data body, byte count, excluding
43 the id and version, and this word */
44 char version[MCF_XDR_VERSION_LENGTH+1];
45 /* The version of this particular block */
46 int *data; /* The data block */
47} mcfxdrGeneric;
48
49typedef struct _mcfxdrFileHeader{
50 int id; /* Identifier for this item = FILEHEADER */
51 int length; /* The length of data body, byte count, excluding
52 the id and version, and this word */
53 char version[MCF_XDR_VERSION_LENGTH+1];
54 /* The version of this particular block */
55 char title[MCF_XDR_F_TITLE_LENGTH+1];
56 /* The title length */
57 char comment[MCF_XDR_F_TITLE_LENGTH+1]; /* The comment ..*/
58 char date[30];
59 char closingDate[30];
60 unsigned int numevts_expect; /* The number of event expected */
61 unsigned int numevts; /* The number of evts really written on tape */
62 unsigned int firstTable; /* The XDR locator for the first table */
63 unsigned int dimTable; /* The number of events listed in the fixed-sized
64 event table */
65 unsigned int nBlocks;
66 /* The maximum number of Block types in the file
67 ( excluding File headers and Event Tables) */
68 int *blockIds; /* The list of Block identifiers */
69
70 char **blockNames; /* The list of names ( Titles) for these blocks */
71 unsigned int nNTuples;
72 /* The maximum number of Ntuples defined for this
73 stream */
74
75} mcfxdrFileHeader;
76
77typedef struct _mcfxdrEventTable{
78 int id; /* Identifier for this item = EVENTTABLE */
79 int length; /* The length of data body, byte count, excluding
80 the id and version, and this word */
81 char version[MCF_XDR_VERSION_LENGTH+1];
82 /* The version of this particular block */
83 int nextLocator; /*The Locator for the next Event Table. */
84 int previousnumevts; /* The size of the previous Table */
85 int numevts; /* The number of events in this chunk */
86 unsigned int dim; /* The dimension of the arrays listed below */
87 unsigned int ievt; /* The current index in the list */
88 int *evtnums; /* The List of event numbers, within a store */
89 int *storenums; /* The list of Store number within a Run */
90 int *runnums; /* The list of run numbers */
91 int *trigMasks; /* The list of user-defined Trigger masks */
92 unsigned int *ptrEvents;
93 /* The list of XDR pointers for these events */
94} mcfxdrEventTable;
95
96typedef struct _mcfxdrSequentialHeader{
97 int id; /* Identifier for this item = SEQUENTIALHEADER */
98 int length; /* The length of data body, byte count, excluding
99 the id and version, and this word */
100 char version[MCF_XDR_VERSION_LENGTH+1];
101 /* The version of this particular block */
102 unsigned int nRecords; /* The number of records (including this one)
103 in the logical event */
104} mcfxdrSequentialHeader;
105
106typedef struct _mcfxdrEventHeader{
107 int id; /* Identifier for this item = CHUNKHEADER */
108 int length; /* The length of data body, byte count, excluding
109 the id and version, and this word */
110 char version[MCF_XDR_VERSION_LENGTH+1];
111 /* The version of this particular block */
112 int previousevtnum; /* The previous event number */
113 int evtnum; /* The event numbers, within a store */
114 int storenum; /* The Store number within a Run */
115 int runnum; /* The Run numbers */
116 int trigMask; /* The Trigger masks */
117 unsigned int nBlocks; /* The number of Blocks */
118 unsigned int dimBlocks; /* The dimension of the two following arrays */
119 int *blockIds; /* The list of Block identifiers */
120 unsigned int *ptrBlocks;
121 /* The list of XDR pointers for these blocks */
122 unsigned int nNTuples;
123 /* The number of Ntuples defined for this event */
124
125 unsigned int dimNTuples; /* The dimension of the two following arrays */
126 int *nTupleIds; /* The list of Ntuple identifiers, pointing to the
127 global list array */
128 unsigned int *ptrNTuples;
129 /* The list of XDR pointers for these NTuples */
130
131} mcfxdrEventHeader;
132
133typedef struct _mcfStream{
134 int id; /* Id of the Stream */
135 int row; /* Read or Write */
136 int dos; /* Direct, Memory Mapped I/O or Sequential */
137 int status; /* The Stream status, either at BOF, RUNNING, EOF
138 or simply declared, and needs to be opened
139 (NTuple usage) */
140 int numWordsC; /* The number of words read or written, Content */
141 int numWordsT; /* The number of words read or written, Total */
142 mcfxdrFileHeader *fhead; /* The File header */
143 mcfxdrEventHeader *ehead; /* The current Event Header */
144 unsigned int currentPos; /* The XDR current position */
145 unsigned int evtPos; /* The XDR position for the begingin of evt */
146 unsigned int tablePos; /* The XDR position for the table */
147 unsigned int firstPos; /* The XDR position just before file header */
148 XDR *xdr; /* The XDR stream */
149 char *filename; /* Filename */
150 FILE *filePtr; /* The file pointer */
151 int fileDescr; /* File descriptor if Memory Mapped */
152 char *fileAddr; /* Address in virtual memory if Memory Mapped */
153 size_t fileLen; /* The file length */
154 mcfxdrEventTable *table; /* The event table */
155 char *device; /* The device name, if any */
156 char *vsn; /* The Visual S. number, e.g., the tape label */
157 int filenumber; /* The sequential file number, if any */
158 int minlrec; /* The minimum record length for this stream */
159 int maxlrec; /* The maximum record length for this stream */
160 int bufferSize; /* The current size of the primary buffer */
161 mcfxdrSequentialHeader *shead; /* The Sequential header */
162 char *buffer; /* A pointer to a generic data buffer, to get the
163 data from tape and then decode it */
164 char *buffer2; /* A secondary buffer, to hold the event
165 as the event grows */
166} mcfStream;
167
168extern mcfStream **McfStreamPtrList;
169extern char **McfGenericVersion;
170extern unsigned int McfNumOfStreamActive;
171extern bool_t McfNTuPleSaveDecoding;
172
173bool_t xdr_mcfast_generic(XDR *xdrs, int *blockid,
174 int *ntot, char** version, char** data);
175bool_t xdr_mcfast_headerBlock(XDR *xdrs, int *blockid,
176 int *ntot, char** version);
177bool_t xdr_mcfast_fileheader(XDR *xdrs, int *blockid,
178 int *ntot, char** version, mcfxdrFileHeader **mcf,
179 int streamId);
180bool_t xdr_mcfast_eventtable(XDR *xdrs, int *blockid,
181 int *ntot, char** version, mcfxdrEventTable **mcf);
182bool_t xdr_mcfast_seqheader(XDR *xdrs, int *blockid,
183 int *ntot, char** version, mcfxdrSequentialHeader **mcf);
184bool_t xdr_mcfast_eventheader(XDR *xdrs, int *blockid,
185 int *ntot, char** version, mcfxdrEventHeader **mcf);
Note: See TracBrowser for help on using the repository browser.