Bug Summary

File:libraries/HDDM/hddm_r.c
Location:line 1922, column 8
Description:Access to field 'popListLength' results in a dereference of a null pointer (loaded from field 'popTop')

Annotated Source Code

1/*
2 * hddm_r.c - DO NOT EDIT THIS FILE
3 *
4 * This file was generated automatically by hddm-c from the file
5 * rest.xml
6
7 * This c file contains the i/o interface to the c structures
8 * described in the data model (from rest.xml).
9 *
10 * The hddm data model tool set was written by
11 * Richard Jones, University of Connecticut.
12 *
13 * For more information see the following web site
14 *
15 * http://zeus.phys.uconn.edu/halld/datamodel/doc
16 */
17
18int hddm_r_nullTarget=0;
19#define HDDM_NULL(void*)&hddm_r_nullTarget (void*)&hddm_r_nullTarget
20
21#include "hddm_r.h"
22
23
24r_HDDM_t* make_r_HDDM()
25{
26 int size = sizeof(r_HDDM_t);
27 r_HDDM_t* p = (r_HDDM_t*)MALLOC(size,"r_HDDM_t")malloc(size);
28 p->reconstructedPhysicsEvent = (r_ReconstructedPhysicsEvent_t*)&hddm_r_nullTarget;
29 return p;
30}
31
32r_ReconstructedPhysicsEvent_t* make_r_ReconstructedPhysicsEvent()
33{
34 int size = sizeof(r_ReconstructedPhysicsEvent_t);
35 r_ReconstructedPhysicsEvent_t* p = (r_ReconstructedPhysicsEvent_t*)MALLOC(size,"r_ReconstructedPhysicsEvent_t")malloc(size);
36 p->eventNo = 0;
37 p->runNo = 0;
38 p->comments = (r_Comments_t*)&hddm_r_nullTarget;
39 p->reactions = (r_Reactions_t*)&hddm_r_nullTarget;
40 p->taggerHits = (r_TaggerHits_t*)&hddm_r_nullTarget;
41 p->calorimeterClusters = (r_CalorimeterClusters_t*)&hddm_r_nullTarget;
42 p->chargedTracks = (r_ChargedTracks_t*)&hddm_r_nullTarget;
43 p->startHits = (r_StartHits_t*)&hddm_r_nullTarget;
44 p->tofPoints = (r_TofPoints_t*)&hddm_r_nullTarget;
45 p->RFtime = (r_RFtime_t*)&hddm_r_nullTarget;
46 return p;
47}
48
49r_Comments_t* make_r_Comments(int n)
50{
51 int i;
52 int rep = (n > 1) ? n-1 : 0;
53 int size = sizeof(r_Comments_t) + rep * sizeof(r_Comment_t);
54 r_Comments_t* p = (r_Comments_t*)MALLOC(size,"r_Comments_t")malloc(size);
55 p->mult = 0;
56 for (i=0; i<n; i++) {
57 r_Comment_t* pp = &p->in[i];
58 pp->text = (string_t)&hddm_r_nullTarget;
59 }
60 return p;
61}
62
63r_Reactions_t* make_r_Reactions(int n)
64{
65 int i;
66 int rep = (n > 1) ? n-1 : 0;
67 int size = sizeof(r_Reactions_t) + rep * sizeof(r_Reaction_t);
68 r_Reactions_t* p = (r_Reactions_t*)MALLOC(size,"r_Reactions_t")malloc(size);
69 p->mult = 0;
70 for (i=0; i<n; i++) {
71 r_Reaction_t* pp = &p->in[i];
72 pp->Ebeam = 0;
73 pp->jtag = (string_t)&hddm_r_nullTarget;
74 pp->targetType = (Particle_t)0;
75 pp->type = 0;
76 pp->weight = 0;
77 pp->vertices = (r_Vertices_t*)&hddm_r_nullTarget;
78 }
79 return p;
80}
81
82r_Vertices_t* make_r_Vertices(int n)
83{
84 int i;
85 int rep = (n > 1) ? n-1 : 0;
86 int size = sizeof(r_Vertices_t) + rep * sizeof(r_Vertex_t);
87 r_Vertices_t* p = (r_Vertices_t*)MALLOC(size,"r_Vertices_t")malloc(size);
88 p->mult = 0;
89 for (i=0; i<n; i++) {
90 r_Vertex_t* pp = &p->in[i];
91 pp->origin = (r_Origin_t*)&hddm_r_nullTarget;
92 pp->products = (r_Products_t*)&hddm_r_nullTarget;
93 }
94 return p;
95}
96
97r_Origin_t* make_r_Origin()
98{
99 int size = sizeof(r_Origin_t);
100 r_Origin_t* p = (r_Origin_t*)MALLOC(size,"r_Origin_t")malloc(size);
101 p->t = 0;
102 p->vx = 0;
103 p->vy = 0;
104 p->vz = 0;
105 return p;
106}
107
108r_Products_t* make_r_Products(int n)
109{
110 int i;
111 int rep = (n > 1) ? n-1 : 0;
112 int size = sizeof(r_Products_t) + rep * sizeof(r_Product_t);
113 r_Products_t* p = (r_Products_t*)MALLOC(size,"r_Products_t")malloc(size);
114 p->mult = 0;
115 for (i=0; i<n; i++) {
116 r_Product_t* pp = &p->in[i];
117 pp->id = 0;
118 pp->parentId = 0;
119 pp->pdgtype = 0;
120 pp->momentum = (r_Momentum_t*)&hddm_r_nullTarget;
121 }
122 return p;
123}
124
125r_Momentum_t* make_r_Momentum()
126{
127 int size = sizeof(r_Momentum_t);
128 r_Momentum_t* p = (r_Momentum_t*)MALLOC(size,"r_Momentum_t")malloc(size);
129 p->E = 0;
130 p->px = 0;
131 p->py = 0;
132 p->pz = 0;
133 return p;
134}
135
136r_TaggerHits_t* make_r_TaggerHits(int n)
137{
138 int i;
139 int rep = (n > 1) ? n-1 : 0;
140 int size = sizeof(r_TaggerHits_t) + rep * sizeof(r_TaggerHit_t);
141 r_TaggerHits_t* p = (r_TaggerHits_t*)MALLOC(size,"r_TaggerHits_t")malloc(size);
142 p->mult = 0;
143 for (i=0; i<n; i++) {
144 r_TaggerHit_t* pp = &p->in[i];
145 pp->E = 0;
146 pp->jtag = (string_t)&hddm_r_nullTarget;
147 pp->t = 0;
148 }
149 return p;
150}
151
152r_CalorimeterClusters_t* make_r_CalorimeterClusters(int n)
153{
154 int i;
155 int rep = (n > 1) ? n-1 : 0;
156 int size = sizeof(r_CalorimeterClusters_t) + rep * sizeof(r_CalorimeterCluster_t);
157 r_CalorimeterClusters_t* p = (r_CalorimeterClusters_t*)MALLOC(size,"r_CalorimeterClusters_t")malloc(size);
158 p->mult = 0;
159 for (i=0; i<n; i++) {
160 r_CalorimeterCluster_t* pp = &p->in[i];
161 pp->E = 0;
162 pp->Eerr = 0;
163 pp->Ezcorr = 0;
164 pp->jtag = (string_t)&hddm_r_nullTarget;
165 pp->t = 0;
166 pp->terr = 0;
167 pp->tzcorr = 0;
168 pp->x = 0;
169 pp->xerr = 0;
170 pp->xycorr = 0;
171 pp->xzcorr = 0;
172 pp->y = 0;
173 pp->yerr = 0;
174 pp->yzcorr = 0;
175 pp->z = 0;
176 pp->zerr = 0;
177 }
178 return p;
179}
180
181r_ChargedTracks_t* make_r_ChargedTracks(int n)
182{
183 int i;
184 int rep = (n > 1) ? n-1 : 0;
185 int size = sizeof(r_ChargedTracks_t) + rep * sizeof(r_ChargedTrack_t);
186 r_ChargedTracks_t* p = (r_ChargedTracks_t*)MALLOC(size,"r_ChargedTracks_t")malloc(size);
187 p->mult = 0;
188 for (i=0; i<n; i++) {
189 r_ChargedTrack_t* pp = &p->in[i];
190 pp->candidateId = 0;
191 pp->jtag = (string_t)&hddm_r_nullTarget;
192 pp->ptype = (Particle_t)0;
193 pp->trackFit = (r_TrackFit_t*)&hddm_r_nullTarget;
194 pp->dEdxDC = (r_DEdxDC_t*)&hddm_r_nullTarget;
195 }
196 return p;
197}
198
199r_TrackFit_t* make_r_TrackFit()
200{
201 int size = sizeof(r_TrackFit_t);
202 r_TrackFit_t* p = (r_TrackFit_t*)MALLOC(size,"r_TrackFit_t")malloc(size);
203 p->Ndof = 0;
204 p->chisq = 0;
205 p->e11 = 0;
206 p->e12 = 0;
207 p->e13 = 0;
208 p->e14 = 0;
209 p->e15 = 0;
210 p->e22 = 0;
211 p->e23 = 0;
212 p->e24 = 0;
213 p->e25 = 0;
214 p->e33 = 0;
215 p->e34 = 0;
216 p->e35 = 0;
217 p->e44 = 0;
218 p->e45 = 0;
219 p->e55 = 0;
220 p->px = 0;
221 p->py = 0;
222 p->pz = 0;
223 p->t0 = 0;
224 p->t0det = 0;
225 p->t0err = 0;
226 p->x0 = 0;
227 p->y0 = 0;
228 p->z0 = 0;
229 return p;
230}
231
232r_DEdxDC_t* make_r_DEdxDC()
233{
234 int size = sizeof(r_DEdxDC_t);
235 r_DEdxDC_t* p = (r_DEdxDC_t*)MALLOC(size,"r_DEdxDC_t")malloc(size);
236 p->NsampleCDC = 0;
237 p->NsampleFDC = 0;
238 p->dEdxCDC = 0;
239 p->dEdxFDC = 0;
240 p->dxCDC = 0;
241 p->dxFDC = 0;
242 return p;
243}
244
245r_StartHits_t* make_r_StartHits(int n)
246{
247 int i;
248 int rep = (n > 1) ? n-1 : 0;
249 int size = sizeof(r_StartHits_t) + rep * sizeof(r_StartHit_t);
250 r_StartHits_t* p = (r_StartHits_t*)MALLOC(size,"r_StartHits_t")malloc(size);
251 p->mult = 0;
252 for (i=0; i<n; i++) {
253 r_StartHit_t* pp = &p->in[i];
254 pp->dE = 0;
255 pp->jtag = (string_t)&hddm_r_nullTarget;
256 pp->sector = 0;
257 pp->t = 0;
258 }
259 return p;
260}
261
262r_TofPoints_t* make_r_TofPoints(int n)
263{
264 int i;
265 int rep = (n > 1) ? n-1 : 0;
266 int size = sizeof(r_TofPoints_t) + rep * sizeof(r_TofPoint_t);
267 r_TofPoints_t* p = (r_TofPoints_t*)MALLOC(size,"r_TofPoints_t")malloc(size);
268 p->mult = 0;
269 for (i=0; i<n; i++) {
270 r_TofPoint_t* pp = &p->in[i];
271 pp->dE = 0;
272 pp->jtag = (string_t)&hddm_r_nullTarget;
273 pp->t = 0;
274 pp->x = 0;
275 pp->y = 0;
276 pp->z = 0;
277 }
278 return p;
279}
280
281r_RFtime_t* make_r_RFtime()
282{
283 int size = sizeof(r_RFtime_t);
284 r_RFtime_t* p = (r_RFtime_t*)MALLOC(size,"r_RFtime_t")malloc(size);
285 p->jtag = (string_t)&hddm_r_nullTarget;
286 p->tsync = 0;
287 p->tsyncerr = 0;
288 return p;
289}
290
291char HDDM_r_DocumentString[] =
292"<HDDM class=\"r\" version=\"1.0.1\" xmlns=\"http://www.gluex.org/hddm\">\n"
293" <reconstructedPhysicsEvent eventNo=\"int\" runNo=\"int\">\n"
294" <comment maxOccurs=\"unbounded\" minOccurs=\"0\" text=\"string\" />\n"
295" <reaction Ebeam=\"float\" Eunit=\"GeV\" jtag=\"string\" maxOccurs=\"unbounded\" minOccurs=\"0\" targetType=\"Particle_t\" type=\"int\" weight=\"float\">\n"
296" <vertex maxOccurs=\"unbounded\">\n"
297" <origin lunit=\"cm\" t=\"float\" vx=\"float\" vy=\"float\" vz=\"float\" />\n"
298" <product id=\"int\" maxOccurs=\"unbounded\" parentId=\"int\" pdgtype=\"int\">\n"
299" <momentum E=\"float\" Eunit=\"GeV\" punit=\"GeV/c\" px=\"float\" py=\"float\" pz=\"float\" />\n"
300" </product>\n"
301" </vertex>\n"
302" </reaction>\n"
303" <taggerHit E=\"float\" Eunit=\"GeV\" jtag=\"string\" maxOccurs=\"unbounded\" minOccurs=\"0\" t=\"float\" tunit=\"ns\" />\n"
304" <calorimeterCluster E=\"float\" Eerr=\"float\" Eunit=\"GeV\" Ezcorr=\"float\" jtag=\"string\" lunit=\"cm\" maxOccurs=\"unbounded\" minOccurs=\"0\" t=\"float\" terr=\"float\" tunit=\"ns\" tzcorr=\"float\" x=\"float\" xerr=\"float\" xycorr=\"float\" xzcorr=\"float\" y=\"float\" yerr=\"float\" yzcorr=\"float\" z=\"float\" zerr=\"float\" />\n"
305" <chargedTrack candidateId=\"int\" jtag=\"string\" maxOccurs=\"unbounded\" minOccurs=\"0\" ptype=\"Particle_t\">\n"
306" <trackFit Ndof=\"int\" chisq=\"float\" e11=\"float\" e12=\"float\" e13=\"float\" e14=\"float\" e15=\"float\" e22=\"float\" e23=\"float\" e24=\"float\" e25=\"float\" e33=\"float\" e34=\"float\" e35=\"float\" e44=\"float\" e45=\"float\" e55=\"float\" lunit=\"cm\" punit=\"GeV/c\" px=\"float\" py=\"float\" pz=\"float\" t0=\"float\" t0det=\"int\" t0err=\"float\" tunit=\"ns\" x0=\"float\" y0=\"float\" z0=\"float\" />\n"
307" <dEdxDC NsampleCDC=\"int\" NsampleFDC=\"int\" dEdxCDC=\"float\" dEdxFDC=\"float\" dEdx_unit=\"GeV/cm\" dxCDC=\"float\" dxFDC=\"float\" lunit=\"cm\" minOccurs=\"0\" />\n"
308" </chargedTrack>\n"
309" <startHit dE=\"float\" jtag=\"string\" maxOccurs=\"unbounded\" minOccurs=\"0\" sector=\"int\" t=\"float\" />\n"
310" <tofPoint dE=\"float\" jtag=\"string\" maxOccurs=\"unbounded\" minOccurs=\"0\" t=\"float\" x=\"float\" y=\"float\" z=\"float\" />\n"
311" <RFtime jtag=\"string\" minOccurs=\"0\" tsync=\"float\" tsyncerr=\"float\" tunit=\"ns\" />\n"
312" </reconstructedPhysicsEvent>\n"
313"</HDDM>\n"
314;
315
316#ifndef _FILE_OFFSET_BITS64
317# define _FILE_OFFSET_BITS64 64
318#endif
319
320static off_t xdr_getpos64(XDR *xdrs)
321{
322 if (xdrs->x_base == 0) {
323 return ftello((FILE *)xdrs->x_private);
324 }
325 off_t pos = xdr_getpos(xdrs)(*(xdrs)->x_ops->x_getpostn)(xdrs);
326 return pos;
327}
328
329static bool_t xdr_setpos64(XDR *xdrs, off_t pos)
330{
331 if (xdrs->x_base == 0) {
332 return ((fseeko((FILE *)xdrs->x_private, pos, 0) < 0)? FALSE(0) : TRUE(1));
333 }
334 return xdr_setpos(xdrs,pos)(*(xdrs)->x_ops->x_setpostn)(xdrs, pos);
335}
336
337
338static r_HDDM_t* unpack_r_HDDM(XDR* xdrs, popNode* pop)
339{
340 r_HDDM_t* this1 = (r_HDDM_t*)HDDM_NULL(void*)&hddm_r_nullTarget;
341 unsigned int size;
342 if (! xdr_u_int(xdrs,&size))
343 {
344 return this1;
345 }
346 else if (size == 1)
347 {
348 fprintf(stderrstderr,"hddm error - "
349 "compressed data found in input stream.\n"
350 "Compression/decompression is not supported "
351 "by the hddm c i/o interface.\n");
352 fprintf(stderrstderr,"You must use the c++ "
353 "interface to read this file.\n");
354 exit(9);
355 }
356 else if (size > 0)
357 {
358 off_t start = xdr_getpos64(xdrs);
359 this1 = make_r_HDDM();
360 {
361 int p;
362 void* (*ptr) = (void**) &this1->reconstructedPhysicsEvent;
363 for (p = 0; p < pop->popListLength; p++)
364 {
365 popNode* pnode = pop->popList[p];
366 if (pnode)
367 {
368 int kid = pnode->inParent;
369 ptr[kid] = pnode->unpacker(xdrs,pnode);
370 }
371 else
372 {
373 unsigned int skip;
374 xdr_u_int(xdrs,&skip);
375 xdr_setpos64(xdrs,xdr_getpos64(xdrs)+skip);
376 }
377 }
378 }
379 xdr_setpos64(xdrs,start+size);
380 }
381 return this1;
382}
383
384static r_ReconstructedPhysicsEvent_t* unpack_r_ReconstructedPhysicsEvent(XDR* xdrs, popNode* pop)
385{
386 r_ReconstructedPhysicsEvent_t* this1 = (r_ReconstructedPhysicsEvent_t*)HDDM_NULL(void*)&hddm_r_nullTarget;
387 unsigned int size;
388 if (! xdr_u_int(xdrs,&size))
389 {
390 return this1;
391 }
392 else if (size == 1)
393 {
394 fprintf(stderrstderr,"hddm error - "
395 "compressed data found in input stream.\n"
396 "Compression/decompression is not supported "
397 "by the hddm c i/o interface.\n");
398 fprintf(stderrstderr,"You must use the c++ "
399 "interface to read this file.\n");
400 exit(9);
401 }
402 else if (size > 0)
403 {
404 off_t start = xdr_getpos64(xdrs);
405 this1 = make_r_ReconstructedPhysicsEvent();
406 {
407 int p;
408 void* (*ptr) = (void**) &this1->comments;
409 xdr_int(xdrs,&this1->eventNo);
410 xdr_int(xdrs,&this1->runNo);
411 for (p = 0; p < pop->popListLength; p++)
412 {
413 popNode* pnode = pop->popList[p];
414 if (pnode)
415 {
416 int kid = pnode->inParent;
417 ptr[kid] = pnode->unpacker(xdrs,pnode);
418 }
419 else
420 {
421 unsigned int skip;
422 xdr_u_int(xdrs,&skip);
423 xdr_setpos64(xdrs,xdr_getpos64(xdrs)+skip);
424 }
425 }
426 }
427 xdr_setpos64(xdrs,start+size);
428 }
429 return this1;
430}
431
432static r_Comments_t* unpack_r_Comments(XDR* xdrs, popNode* pop)
433{
434 r_Comments_t* this1 = (r_Comments_t*)HDDM_NULL(void*)&hddm_r_nullTarget;
435 unsigned int size;
436 if (! xdr_u_int(xdrs,&size))
437 {
438 return this1;
439 }
440 else if (size == 1)
441 {
442 fprintf(stderrstderr,"hddm error - "
443 "compressed data found in input stream.\n"
444 "Compression/decompression is not supported "
445 "by the hddm c i/o interface.\n");
446 fprintf(stderrstderr,"You must use the c++ "
447 "interface to read this file.\n");
448 exit(9);
449 }
450 else if (size > 0)
451 {
452 off_t start = xdr_getpos64(xdrs);
453 int m;
454 unsigned int mult;
455 xdr_u_int(xdrs,&mult);
456 this1 = make_r_Comments(mult);
457 this1->mult = mult;
458 for (m = 0; m < mult; m++ )
459 {
460 this1->in[m].text = 0;
461 xdr_string(xdrs, &this1->in[m].text, 1000000);
462 }
463 xdr_setpos64(xdrs,start+size);
464 }
465 return this1;
466}
467
468static r_Reactions_t* unpack_r_Reactions(XDR* xdrs, popNode* pop)
469{
470 r_Reactions_t* this1 = (r_Reactions_t*)HDDM_NULL(void*)&hddm_r_nullTarget;
471 unsigned int size;
472 if (! xdr_u_int(xdrs,&size))
473 {
474 return this1;
475 }
476 else if (size == 1)
477 {
478 fprintf(stderrstderr,"hddm error - "
479 "compressed data found in input stream.\n"
480 "Compression/decompression is not supported "
481 "by the hddm c i/o interface.\n");
482 fprintf(stderrstderr,"You must use the c++ "
483 "interface to read this file.\n");
484 exit(9);
485 }
486 else if (size > 0)
487 {
488 off_t start = xdr_getpos64(xdrs);
489 int m;
490 unsigned int mult;
491 xdr_u_int(xdrs,&mult);
492 this1 = make_r_Reactions(mult);
493 this1->mult = mult;
494 for (m = 0; m < mult; m++ )
495 {
496 int p;
497 void* (*ptr) = (void**) &this1->in[m].vertices;
498 xdr_float(xdrs,&this1->in[m].Ebeam);
499 this1->in[m].jtag = 0;
500 xdr_string(xdrs, &this1->in[m].jtag, 1000000);
501 xdr_int(xdrs,(int*)&this1->in[m].targetType);
502 xdr_int(xdrs,&this1->in[m].type);
503 xdr_float(xdrs,&this1->in[m].weight);
504 for (p = 0; p < pop->popListLength; p++)
505 {
506 popNode* pnode = pop->popList[p];
507 if (pnode)
508 {
509 int kid = pnode->inParent;
510 ptr[kid] = pnode->unpacker(xdrs,pnode);
511 }
512 else
513 {
514 unsigned int skip;
515 xdr_u_int(xdrs,&skip);
516 xdr_setpos64(xdrs,xdr_getpos64(xdrs)+skip);
517 }
518 }
519 }
520 xdr_setpos64(xdrs,start+size);
521 }
522 return this1;
523}
524
525static r_Vertices_t* unpack_r_Vertices(XDR* xdrs, popNode* pop)
526{
527 r_Vertices_t* this1 = (r_Vertices_t*)HDDM_NULL(void*)&hddm_r_nullTarget;
528 unsigned int size;
529 if (! xdr_u_int(xdrs,&size))
530 {
531 return this1;
532 }
533 else if (size == 1)
534 {
535 fprintf(stderrstderr,"hddm error - "
536 "compressed data found in input stream.\n"
537 "Compression/decompression is not supported "
538 "by the hddm c i/o interface.\n");
539 fprintf(stderrstderr,"You must use the c++ "
540 "interface to read this file.\n");
541 exit(9);
542 }
543 else if (size > 0)
544 {
545 off_t start = xdr_getpos64(xdrs);
546 int m;
547 unsigned int mult;
548 xdr_u_int(xdrs,&mult);
549 this1 = make_r_Vertices(mult);
550 this1->mult = mult;
551 for (m = 0; m < mult; m++ )
552 {
553 int p;
554 void* (*ptr) = (void**) &this1->in[m].origin;
555 for (p = 0; p < pop->popListLength; p++)
556 {
557 popNode* pnode = pop->popList[p];
558 if (pnode)
559 {
560 int kid = pnode->inParent;
561 ptr[kid] = pnode->unpacker(xdrs,pnode);
562 }
563 else
564 {
565 unsigned int skip;
566 xdr_u_int(xdrs,&skip);
567 xdr_setpos64(xdrs,xdr_getpos64(xdrs)+skip);
568 }
569 }
570 }
571 xdr_setpos64(xdrs,start+size);
572 }
573 return this1;
574}
575
576static r_Origin_t* unpack_r_Origin(XDR* xdrs, popNode* pop)
577{
578 r_Origin_t* this1 = (r_Origin_t*)HDDM_NULL(void*)&hddm_r_nullTarget;
579 unsigned int size;
580 if (! xdr_u_int(xdrs,&size))
581 {
582 return this1;
583 }
584 else if (size == 1)
585 {
586 fprintf(stderrstderr,"hddm error - "
587 "compressed data found in input stream.\n"
588 "Compression/decompression is not supported "
589 "by the hddm c i/o interface.\n");
590 fprintf(stderrstderr,"You must use the c++ "
591 "interface to read this file.\n");
592 exit(9);
593 }
594 else if (size > 0)
595 {
596 off_t start = xdr_getpos64(xdrs);
597 this1 = make_r_Origin();
598 {
599 xdr_float(xdrs,&this1->t);
600 xdr_float(xdrs,&this1->vx);
601 xdr_float(xdrs,&this1->vy);
602 xdr_float(xdrs,&this1->vz);
603 }
604 xdr_setpos64(xdrs,start+size);
605 }
606 return this1;
607}
608
609static r_Products_t* unpack_r_Products(XDR* xdrs, popNode* pop)
610{
611 r_Products_t* this1 = (r_Products_t*)HDDM_NULL(void*)&hddm_r_nullTarget;
612 unsigned int size;
613 if (! xdr_u_int(xdrs,&size))
614 {
615 return this1;
616 }
617 else if (size == 1)
618 {
619 fprintf(stderrstderr,"hddm error - "
620 "compressed data found in input stream.\n"
621 "Compression/decompression is not supported "
622 "by the hddm c i/o interface.\n");
623 fprintf(stderrstderr,"You must use the c++ "
624 "interface to read this file.\n");
625 exit(9);
626 }
627 else if (size > 0)
628 {
629 off_t start = xdr_getpos64(xdrs);
630 int m;
631 unsigned int mult;
632 xdr_u_int(xdrs,&mult);
633 this1 = make_r_Products(mult);
634 this1->mult = mult;
635 for (m = 0; m < mult; m++ )
636 {
637 int p;
638 void* (*ptr) = (void**) &this1->in[m].momentum;
639 xdr_int(xdrs,&this1->in[m].id);
640 xdr_int(xdrs,&this1->in[m].parentId);
641 xdr_int(xdrs,&this1->in[m].pdgtype);
642 for (p = 0; p < pop->popListLength; p++)
643 {
644 popNode* pnode = pop->popList[p];
645 if (pnode)
646 {
647 int kid = pnode->inParent;
648 ptr[kid] = pnode->unpacker(xdrs,pnode);
649 }
650 else
651 {
652 unsigned int skip;
653 xdr_u_int(xdrs,&skip);
654 xdr_setpos64(xdrs,xdr_getpos64(xdrs)+skip);
655 }
656 }
657 }
658 xdr_setpos64(xdrs,start+size);
659 }
660 return this1;
661}
662
663static r_Momentum_t* unpack_r_Momentum(XDR* xdrs, popNode* pop)
664{
665 r_Momentum_t* this1 = (r_Momentum_t*)HDDM_NULL(void*)&hddm_r_nullTarget;
666 unsigned int size;
667 if (! xdr_u_int(xdrs,&size))
668 {
669 return this1;
670 }
671 else if (size == 1)
672 {
673 fprintf(stderrstderr,"hddm error - "
674 "compressed data found in input stream.\n"
675 "Compression/decompression is not supported "
676 "by the hddm c i/o interface.\n");
677 fprintf(stderrstderr,"You must use the c++ "
678 "interface to read this file.\n");
679 exit(9);
680 }
681 else if (size > 0)
682 {
683 off_t start = xdr_getpos64(xdrs);
684 this1 = make_r_Momentum();
685 {
686 xdr_float(xdrs,&this1->E);
687 xdr_float(xdrs,&this1->px);
688 xdr_float(xdrs,&this1->py);
689 xdr_float(xdrs,&this1->pz);
690 }
691 xdr_setpos64(xdrs,start+size);
692 }
693 return this1;
694}
695
696static r_TaggerHits_t* unpack_r_TaggerHits(XDR* xdrs, popNode* pop)
697{
698 r_TaggerHits_t* this1 = (r_TaggerHits_t*)HDDM_NULL(void*)&hddm_r_nullTarget;
699 unsigned int size;
700 if (! xdr_u_int(xdrs,&size))
701 {
702 return this1;
703 }
704 else if (size == 1)
705 {
706 fprintf(stderrstderr,"hddm error - "
707 "compressed data found in input stream.\n"
708 "Compression/decompression is not supported "
709 "by the hddm c i/o interface.\n");
710 fprintf(stderrstderr,"You must use the c++ "
711 "interface to read this file.\n");
712 exit(9);
713 }
714 else if (size > 0)
715 {
716 off_t start = xdr_getpos64(xdrs);
717 int m;
718 unsigned int mult;
719 xdr_u_int(xdrs,&mult);
720 this1 = make_r_TaggerHits(mult);
721 this1->mult = mult;
722 for (m = 0; m < mult; m++ )
723 {
724 xdr_float(xdrs,&this1->in[m].E);
725 this1->in[m].jtag = 0;
726 xdr_string(xdrs, &this1->in[m].jtag, 1000000);
727 xdr_float(xdrs,&this1->in[m].t);
728 }
729 xdr_setpos64(xdrs,start+size);
730 }
731 return this1;
732}
733
734static r_CalorimeterClusters_t* unpack_r_CalorimeterClusters(XDR* xdrs, popNode* pop)
735{
736 r_CalorimeterClusters_t* this1 = (r_CalorimeterClusters_t*)HDDM_NULL(void*)&hddm_r_nullTarget;
737 unsigned int size;
738 if (! xdr_u_int(xdrs,&size))
739 {
740 return this1;
741 }
742 else if (size == 1)
743 {
744 fprintf(stderrstderr,"hddm error - "
745 "compressed data found in input stream.\n"
746 "Compression/decompression is not supported "
747 "by the hddm c i/o interface.\n");
748 fprintf(stderrstderr,"You must use the c++ "
749 "interface to read this file.\n");
750 exit(9);
751 }
752 else if (size > 0)
753 {
754 off_t start = xdr_getpos64(xdrs);
755 int m;
756 unsigned int mult;
757 xdr_u_int(xdrs,&mult);
758 this1 = make_r_CalorimeterClusters(mult);
759 this1->mult = mult;
760 for (m = 0; m < mult; m++ )
761 {
762 xdr_float(xdrs,&this1->in[m].E);
763 xdr_float(xdrs,&this1->in[m].Eerr);
764 xdr_float(xdrs,&this1->in[m].Ezcorr);
765 this1->in[m].jtag = 0;
766 xdr_string(xdrs, &this1->in[m].jtag, 1000000);
767 xdr_float(xdrs,&this1->in[m].t);
768 xdr_float(xdrs,&this1->in[m].terr);
769 xdr_float(xdrs,&this1->in[m].tzcorr);
770 xdr_float(xdrs,&this1->in[m].x);
771 xdr_float(xdrs,&this1->in[m].xerr);
772 xdr_float(xdrs,&this1->in[m].xycorr);
773 xdr_float(xdrs,&this1->in[m].xzcorr);
774 xdr_float(xdrs,&this1->in[m].y);
775 xdr_float(xdrs,&this1->in[m].yerr);
776 xdr_float(xdrs,&this1->in[m].yzcorr);
777 xdr_float(xdrs,&this1->in[m].z);
778 xdr_float(xdrs,&this1->in[m].zerr);
779 }
780 xdr_setpos64(xdrs,start+size);
781 }
782 return this1;
783}
784
785static r_ChargedTracks_t* unpack_r_ChargedTracks(XDR* xdrs, popNode* pop)
786{
787 r_ChargedTracks_t* this1 = (r_ChargedTracks_t*)HDDM_NULL(void*)&hddm_r_nullTarget;
788 unsigned int size;
789 if (! xdr_u_int(xdrs,&size))
790 {
791 return this1;
792 }
793 else if (size == 1)
794 {
795 fprintf(stderrstderr,"hddm error - "
796 "compressed data found in input stream.\n"
797 "Compression/decompression is not supported "
798 "by the hddm c i/o interface.\n");
799 fprintf(stderrstderr,"You must use the c++ "
800 "interface to read this file.\n");
801 exit(9);
802 }
803 else if (size > 0)
804 {
805 off_t start = xdr_getpos64(xdrs);
806 int m;
807 unsigned int mult;
808 xdr_u_int(xdrs,&mult);
809 this1 = make_r_ChargedTracks(mult);
810 this1->mult = mult;
811 for (m = 0; m < mult; m++ )
812 {
813 int p;
814 void* (*ptr) = (void**) &this1->in[m].trackFit;
815 xdr_int(xdrs,&this1->in[m].candidateId);
816 this1->in[m].jtag = 0;
817 xdr_string(xdrs, &this1->in[m].jtag, 1000000);
818 xdr_int(xdrs,(int*)&this1->in[m].ptype);
819 for (p = 0; p < pop->popListLength; p++)
820 {
821 popNode* pnode = pop->popList[p];
822 if (pnode)
823 {
824 int kid = pnode->inParent;
825 ptr[kid] = pnode->unpacker(xdrs,pnode);
826 }
827 else
828 {
829 unsigned int skip;
830 xdr_u_int(xdrs,&skip);
831 xdr_setpos64(xdrs,xdr_getpos64(xdrs)+skip);
832 }
833 }
834 }
835 xdr_setpos64(xdrs,start+size);
836 }
837 return this1;
838}
839
840static r_TrackFit_t* unpack_r_TrackFit(XDR* xdrs, popNode* pop)
841{
842 r_TrackFit_t* this1 = (r_TrackFit_t*)HDDM_NULL(void*)&hddm_r_nullTarget;
843 unsigned int size;
844 if (! xdr_u_int(xdrs,&size))
845 {
846 return this1;
847 }
848 else if (size == 1)
849 {
850 fprintf(stderrstderr,"hddm error - "
851 "compressed data found in input stream.\n"
852 "Compression/decompression is not supported "
853 "by the hddm c i/o interface.\n");
854 fprintf(stderrstderr,"You must use the c++ "
855 "interface to read this file.\n");
856 exit(9);
857 }
858 else if (size > 0)
859 {
860 off_t start = xdr_getpos64(xdrs);
861 this1 = make_r_TrackFit();
862 {
863 xdr_int(xdrs,&this1->Ndof);
864 xdr_float(xdrs,&this1->chisq);
865 xdr_float(xdrs,&this1->e11);
866 xdr_float(xdrs,&this1->e12);
867 xdr_float(xdrs,&this1->e13);
868 xdr_float(xdrs,&this1->e14);
869 xdr_float(xdrs,&this1->e15);
870 xdr_float(xdrs,&this1->e22);
871 xdr_float(xdrs,&this1->e23);
872 xdr_float(xdrs,&this1->e24);
873 xdr_float(xdrs,&this1->e25);
874 xdr_float(xdrs,&this1->e33);
875 xdr_float(xdrs,&this1->e34);
876 xdr_float(xdrs,&this1->e35);
877 xdr_float(xdrs,&this1->e44);
878 xdr_float(xdrs,&this1->e45);
879 xdr_float(xdrs,&this1->e55);
880 xdr_float(xdrs,&this1->px);
881 xdr_float(xdrs,&this1->py);
882 xdr_float(xdrs,&this1->pz);
883 xdr_float(xdrs,&this1->t0);
884 xdr_int(xdrs,&this1->t0det);
885 xdr_float(xdrs,&this1->t0err);
886 xdr_float(xdrs,&this1->x0);
887 xdr_float(xdrs,&this1->y0);
888 xdr_float(xdrs,&this1->z0);
889 }
890 xdr_setpos64(xdrs,start+size);
891 }
892 return this1;
893}
894
895static r_DEdxDC_t* unpack_r_DEdxDC(XDR* xdrs, popNode* pop)
896{
897 r_DEdxDC_t* this1 = (r_DEdxDC_t*)HDDM_NULL(void*)&hddm_r_nullTarget;
898 unsigned int size;
899 if (! xdr_u_int(xdrs,&size))
900 {
901 return this1;
902 }
903 else if (size == 1)
904 {
905 fprintf(stderrstderr,"hddm error - "
906 "compressed data found in input stream.\n"
907 "Compression/decompression is not supported "
908 "by the hddm c i/o interface.\n");
909 fprintf(stderrstderr,"You must use the c++ "
910 "interface to read this file.\n");
911 exit(9);
912 }
913 else if (size > 0)
914 {
915 off_t start = xdr_getpos64(xdrs);
916 this1 = make_r_DEdxDC();
917 {
918 xdr_int(xdrs,&this1->NsampleCDC);
919 xdr_int(xdrs,&this1->NsampleFDC);
920 xdr_float(xdrs,&this1->dEdxCDC);
921 xdr_float(xdrs,&this1->dEdxFDC);
922 xdr_float(xdrs,&this1->dxCDC);
923 xdr_float(xdrs,&this1->dxFDC);
924 }
925 xdr_setpos64(xdrs,start+size);
926 }
927 return this1;
928}
929
930static r_StartHits_t* unpack_r_StartHits(XDR* xdrs, popNode* pop)
931{
932 r_StartHits_t* this1 = (r_StartHits_t*)HDDM_NULL(void*)&hddm_r_nullTarget;
933 unsigned int size;
934 if (! xdr_u_int(xdrs,&size))
935 {
936 return this1;
937 }
938 else if (size == 1)
939 {
940 fprintf(stderrstderr,"hddm error - "
941 "compressed data found in input stream.\n"
942 "Compression/decompression is not supported "
943 "by the hddm c i/o interface.\n");
944 fprintf(stderrstderr,"You must use the c++ "
945 "interface to read this file.\n");
946 exit(9);
947 }
948 else if (size > 0)
949 {
950 off_t start = xdr_getpos64(xdrs);
951 int m;
952 unsigned int mult;
953 xdr_u_int(xdrs,&mult);
954 this1 = make_r_StartHits(mult);
955 this1->mult = mult;
956 for (m = 0; m < mult; m++ )
957 {
958 xdr_float(xdrs,&this1->in[m].dE);
959 this1->in[m].jtag = 0;
960 xdr_string(xdrs, &this1->in[m].jtag, 1000000);
961 xdr_int(xdrs,&this1->in[m].sector);
962 xdr_float(xdrs,&this1->in[m].t);
963 }
964 xdr_setpos64(xdrs,start+size);
965 }
966 return this1;
967}
968
969static r_TofPoints_t* unpack_r_TofPoints(XDR* xdrs, popNode* pop)
970{
971 r_TofPoints_t* this1 = (r_TofPoints_t*)HDDM_NULL(void*)&hddm_r_nullTarget;
972 unsigned int size;
973 if (! xdr_u_int(xdrs,&size))
974 {
975 return this1;
976 }
977 else if (size == 1)
978 {
979 fprintf(stderrstderr,"hddm error - "
980 "compressed data found in input stream.\n"
981 "Compression/decompression is not supported "
982 "by the hddm c i/o interface.\n");
983 fprintf(stderrstderr,"You must use the c++ "
984 "interface to read this file.\n");
985 exit(9);
986 }
987 else if (size > 0)
988 {
989 off_t start = xdr_getpos64(xdrs);
990 int m;
991 unsigned int mult;
992 xdr_u_int(xdrs,&mult);
993 this1 = make_r_TofPoints(mult);
994 this1->mult = mult;
995 for (m = 0; m < mult; m++ )
996 {
997 xdr_float(xdrs,&this1->in[m].dE);
998 this1->in[m].jtag = 0;
999 xdr_string(xdrs, &this1->in[m].jtag, 1000000);
1000 xdr_float(xdrs,&this1->in[m].t);
1001 xdr_float(xdrs,&this1->in[m].x);
1002 xdr_float(xdrs,&this1->in[m].y);
1003 xdr_float(xdrs,&this1->in[m].z);
1004 }
1005 xdr_setpos64(xdrs,start+size);
1006 }
1007 return this1;
1008}
1009
1010static r_RFtime_t* unpack_r_RFtime(XDR* xdrs, popNode* pop)
1011{
1012 r_RFtime_t* this1 = (r_RFtime_t*)HDDM_NULL(void*)&hddm_r_nullTarget;
1013 unsigned int size;
1014 if (! xdr_u_int(xdrs,&size))
1015 {
1016 return this1;
1017 }
1018 else if (size == 1)
1019 {
1020 fprintf(stderrstderr,"hddm error - "
1021 "compressed data found in input stream.\n"
1022 "Compression/decompression is not supported "
1023 "by the hddm c i/o interface.\n");
1024 fprintf(stderrstderr,"You must use the c++ "
1025 "interface to read this file.\n");
1026 exit(9);
1027 }
1028 else if (size > 0)
1029 {
1030 off_t start = xdr_getpos64(xdrs);
1031 this1 = make_r_RFtime();
1032 {
1033 this1->jtag = 0;
1034 xdr_string(xdrs, &this1->jtag, 1000000);
1035 xdr_float(xdrs,&this1->tsync);
1036 xdr_float(xdrs,&this1->tsyncerr);
1037 }
1038 xdr_setpos64(xdrs,start+size);
1039 }
1040 return this1;
1041}
1042
1043r_HDDM_t* read_r_HDDM(r_iostream_t* fp)
1044{
1045 r_HDDM_t* nextEvent = unpack_r_HDDM(fp->xdrs,fp->popTop);
1046 return (nextEvent == HDDM_NULL(void*)&hddm_r_nullTarget)? 0 : nextEvent;
1047}
1048
1049int skip_r_HDDM(r_iostream_t* fp, int nskip)
1050{
1051 int skipped;
1052 for (skipped=0; skipped < nskip; ++skipped)
1053 {
1054 unsigned int size;
1055 if (! xdr_u_int(fp->xdrs,&size))
1056 {
1057 return skipped;
1058 }
1059 else if (size == 1)
1060 {
1061 fprintf(stderrstderr,"hddm error - "
1062 "compressed data found in input stream.\n"
1063 "Compression/decompression is not supported "
1064 "by the hddm c i/o interface.\n");
1065 fprintf(stderrstderr,"You must use the c++ "
1066 "interface to read this file.\n");
1067 exit(9);
1068 }
1069 else if (size > 0)
1070 {
1071 off_t start = xdr_getpos64(fp->xdrs);
1072 if (xdr_setpos64(fp->xdrs,start+size) != 0) {
1073 fp->lerrno = errno(*__errno_location ());
1074 return skipped;
1075 }
1076 }
1077 }
1078 return skipped;
1079}
1080
1081static int pack_r_HDDM(XDR* xdrs, r_HDDM_t* this1);
1082static int pack_r_ReconstructedPhysicsEvent(XDR* xdrs, r_ReconstructedPhysicsEvent_t* this1);
1083static int pack_r_Comments(XDR* xdrs, r_Comments_t* this1);
1084static int pack_r_Reactions(XDR* xdrs, r_Reactions_t* this1);
1085static int pack_r_Vertices(XDR* xdrs, r_Vertices_t* this1);
1086static int pack_r_Origin(XDR* xdrs, r_Origin_t* this1);
1087static int pack_r_Products(XDR* xdrs, r_Products_t* this1);
1088static int pack_r_Momentum(XDR* xdrs, r_Momentum_t* this1);
1089static int pack_r_TaggerHits(XDR* xdrs, r_TaggerHits_t* this1);
1090static int pack_r_CalorimeterClusters(XDR* xdrs, r_CalorimeterClusters_t* this1);
1091static int pack_r_ChargedTracks(XDR* xdrs, r_ChargedTracks_t* this1);
1092static int pack_r_TrackFit(XDR* xdrs, r_TrackFit_t* this1);
1093static int pack_r_DEdxDC(XDR* xdrs, r_DEdxDC_t* this1);
1094static int pack_r_StartHits(XDR* xdrs, r_StartHits_t* this1);
1095static int pack_r_TofPoints(XDR* xdrs, r_TofPoints_t* this1);
1096static int pack_r_RFtime(XDR* xdrs, r_RFtime_t* this1);
1097
1098static int pack_r_HDDM(XDR* xdrs, r_HDDM_t* this1)
1099{
1100 int m=0;
1101 unsigned int size=0;
1102 off_t base,start,end;
1103 base = xdr_getpos64(xdrs);
1104 xdr_u_int(xdrs,&size);
1105 start = xdr_getpos64(xdrs);
1106
1107 {
1108 if (this1->reconstructedPhysicsEvent != (r_ReconstructedPhysicsEvent_t*)&hddm_r_nullTarget)
1109 {
1110 if (pack_r_ReconstructedPhysicsEvent(xdrs,this1->reconstructedPhysicsEvent) < 0) {
1111 return -1;
1112 }
1113 }
1114 else
1115 {
1116 int zero=0;
1117 xdr_int(xdrs,&zero);
1118 }
1119 }
1120 FREE(this1)free(this1);
1121 end = xdr_getpos64(xdrs);
1122 xdr_setpos64(xdrs,base);
1123 size = end-start;
1124 xdr_u_int(xdrs,&size);
1125 xdr_setpos64(xdrs,end);
1126 return size;
1127}
1128
1129static int pack_r_ReconstructedPhysicsEvent(XDR* xdrs, r_ReconstructedPhysicsEvent_t* this1)
1130{
1131 int m=0;
1132 unsigned int size=0;
1133 off_t base,start,end;
1134 base = xdr_getpos64(xdrs);
1135 xdr_u_int(xdrs,&size);
1136 start = xdr_getpos64(xdrs);
1137
1138 {
1139 xdr_int(xdrs,&this1->eventNo);
1140 xdr_int(xdrs,&this1->runNo);
1141 if (this1->comments != (r_Comments_t*)&hddm_r_nullTarget)
1142 {
1143 if (pack_r_Comments(xdrs,this1->comments) < 0) {
1144 return -1;
1145 }
1146 }
1147 else
1148 {
1149 int zero=0;
1150 xdr_int(xdrs,&zero);
1151 }
1152 if (this1->reactions != (r_Reactions_t*)&hddm_r_nullTarget)
1153 {
1154 if (pack_r_Reactions(xdrs,this1->reactions) < 0) {
1155 return -1;
1156 }
1157 }
1158 else
1159 {
1160 int zero=0;
1161 xdr_int(xdrs,&zero);
1162 }
1163 if (this1->taggerHits != (r_TaggerHits_t*)&hddm_r_nullTarget)
1164 {
1165 if (pack_r_TaggerHits(xdrs,this1->taggerHits) < 0) {
1166 return -1;
1167 }
1168 }
1169 else
1170 {
1171 int zero=0;
1172 xdr_int(xdrs,&zero);
1173 }
1174 if (this1->calorimeterClusters != (r_CalorimeterClusters_t*)&hddm_r_nullTarget)
1175 {
1176 if (pack_r_CalorimeterClusters(xdrs,this1->calorimeterClusters) < 0) {
1177 return -1;
1178 }
1179 }
1180 else
1181 {
1182 int zero=0;
1183 xdr_int(xdrs,&zero);
1184 }
1185 if (this1->chargedTracks != (r_ChargedTracks_t*)&hddm_r_nullTarget)
1186 {
1187 if (pack_r_ChargedTracks(xdrs,this1->chargedTracks) < 0) {
1188 return -1;
1189 }
1190 }
1191 else
1192 {
1193 int zero=0;
1194 xdr_int(xdrs,&zero);
1195 }
1196 if (this1->startHits != (r_StartHits_t*)&hddm_r_nullTarget)
1197 {
1198 if (pack_r_StartHits(xdrs,this1->startHits) < 0) {
1199 return -1;
1200 }
1201 }
1202 else
1203 {
1204 int zero=0;
1205 xdr_int(xdrs,&zero);
1206 }
1207 if (this1->tofPoints != (r_TofPoints_t*)&hddm_r_nullTarget)
1208 {
1209 if (pack_r_TofPoints(xdrs,this1->tofPoints) < 0) {
1210 return -1;
1211 }
1212 }
1213 else
1214 {
1215 int zero=0;
1216 xdr_int(xdrs,&zero);
1217 }
1218 if (this1->RFtime != (r_RFtime_t*)&hddm_r_nullTarget)
1219 {
1220 if (pack_r_RFtime(xdrs,this1->RFtime) < 0) {
1221 return -1;
1222 }
1223 }
1224 else
1225 {
1226 int zero=0;
1227 xdr_int(xdrs,&zero);
1228 }
1229 }
1230 FREE(this1)free(this1);
1231 end = xdr_getpos64(xdrs);
1232 xdr_setpos64(xdrs,base);
1233 size = end-start;
1234 xdr_u_int(xdrs,&size);
1235 xdr_setpos64(xdrs,end);
1236 return size;
1237}
1238
1239static int pack_r_Comments(XDR* xdrs, r_Comments_t* this1)
1240{
1241 int m=0;
1242 unsigned int size=0;
1243 off_t base,start,end;
1244 base = xdr_getpos64(xdrs);
1245 xdr_u_int(xdrs,&size);
1246 start = xdr_getpos64(xdrs);
1247
1248 xdr_u_int(xdrs,&this1->mult);
1249 for (m = 0; m < this1->mult; m++)
1250 {
1251 xdr_string(xdrs,&this1->in[m].text, 1000000);
1252 FREE(this1->in[m].text)free(this1->in[m].text);
1253 }
1254 FREE(this1)free(this1);
1255 end = xdr_getpos64(xdrs);
1256 xdr_setpos64(xdrs,base);
1257 size = end-start;
1258 xdr_u_int(xdrs,&size);
1259 xdr_setpos64(xdrs,end);
1260 return size;
1261}
1262
1263static int pack_r_Reactions(XDR* xdrs, r_Reactions_t* this1)
1264{
1265 int m=0;
1266 unsigned int size=0;
1267 off_t base,start,end;
1268 base = xdr_getpos64(xdrs);
1269 xdr_u_int(xdrs,&size);
1270 start = xdr_getpos64(xdrs);
1271
1272 xdr_u_int(xdrs,&this1->mult);
1273 for (m = 0; m < this1->mult; m++)
1274 {
1275 xdr_float(xdrs,&this1->in[m].Ebeam);
1276 xdr_string(xdrs,&this1->in[m].jtag, 1000000);
1277 FREE(this1->in[m].jtag)free(this1->in[m].jtag);
1278 xdr_int(xdrs,(int*)&this1->in[m].targetType);
1279 xdr_int(xdrs,&this1->in[m].type);
1280 xdr_float(xdrs,&this1->in[m].weight);
1281 if (this1->in[m].vertices != (r_Vertices_t*)&hddm_r_nullTarget)
1282 {
1283 if (pack_r_Vertices(xdrs,this1->in[m].vertices) < 0) {
1284 return -1;
1285 }
1286 }
1287 else
1288 {
1289 int zero=0;
1290 xdr_int(xdrs,&zero);
1291 }
1292 }
1293 FREE(this1)free(this1);
1294 end = xdr_getpos64(xdrs);
1295 xdr_setpos64(xdrs,base);
1296 size = end-start;
1297 xdr_u_int(xdrs,&size);
1298 xdr_setpos64(xdrs,end);
1299 return size;
1300}
1301
1302static int pack_r_Vertices(XDR* xdrs, r_Vertices_t* this1)
1303{
1304 int m=0;
1305 unsigned int size=0;
1306 off_t base,start,end;
1307 base = xdr_getpos64(xdrs);
1308 xdr_u_int(xdrs,&size);
1309 start = xdr_getpos64(xdrs);
1310
1311 xdr_u_int(xdrs,&this1->mult);
1312 for (m = 0; m < this1->mult; m++)
1313 {
1314 if (this1->in[m].origin != (r_Origin_t*)&hddm_r_nullTarget)
1315 {
1316 if (pack_r_Origin(xdrs,this1->in[m].origin) < 0) {
1317 return -1;
1318 }
1319 }
1320 else
1321 {
1322 int zero=0;
1323 xdr_int(xdrs,&zero);
1324 }
1325 if (this1->in[m].products != (r_Products_t*)&hddm_r_nullTarget)
1326 {
1327 if (pack_r_Products(xdrs,this1->in[m].products) < 0) {
1328 return -1;
1329 }
1330 }
1331 else
1332 {
1333 int zero=0;
1334 xdr_int(xdrs,&zero);
1335 }
1336 }
1337 FREE(this1)free(this1);
1338 end = xdr_getpos64(xdrs);
1339 xdr_setpos64(xdrs,base);
1340 size = end-start;
1341 xdr_u_int(xdrs,&size);
1342 xdr_setpos64(xdrs,end);
1343 return size;
1344}
1345
1346static int pack_r_Origin(XDR* xdrs, r_Origin_t* this1)
1347{
1348 int m=0;
1349 unsigned int size=0;
1350 off_t base,start,end;
1351 base = xdr_getpos64(xdrs);
1352 xdr_u_int(xdrs,&size);
1353 start = xdr_getpos64(xdrs);
1354
1355 {
1356 xdr_float(xdrs,&this1->t);
1357 xdr_float(xdrs,&this1->vx);
1358 xdr_float(xdrs,&this1->vy);
1359 xdr_float(xdrs,&this1->vz);
1360 }
1361 FREE(this1)free(this1);
1362 end = xdr_getpos64(xdrs);
1363 xdr_setpos64(xdrs,base);
1364 size = end-start;
1365 xdr_u_int(xdrs,&size);
1366 xdr_setpos64(xdrs,end);
1367 return size;
1368}
1369
1370static int pack_r_Products(XDR* xdrs, r_Products_t* this1)
1371{
1372 int m=0;
1373 unsigned int size=0;
1374 off_t base,start,end;
1375 base = xdr_getpos64(xdrs);
1376 xdr_u_int(xdrs,&size);
1377 start = xdr_getpos64(xdrs);
1378
1379 xdr_u_int(xdrs,&this1->mult);
1380 for (m = 0; m < this1->mult; m++)
1381 {
1382 xdr_int(xdrs,&this1->in[m].id);
1383 xdr_int(xdrs,&this1->in[m].parentId);
1384 xdr_int(xdrs,&this1->in[m].pdgtype);
1385 if (this1->in[m].momentum != (r_Momentum_t*)&hddm_r_nullTarget)
1386 {
1387 if (pack_r_Momentum(xdrs,this1->in[m].momentum) < 0) {
1388 return -1;
1389 }
1390 }
1391 else
1392 {
1393 int zero=0;
1394 xdr_int(xdrs,&zero);
1395 }
1396 }
1397 FREE(this1)free(this1);
1398 end = xdr_getpos64(xdrs);
1399 xdr_setpos64(xdrs,base);
1400 size = end-start;
1401 xdr_u_int(xdrs,&size);
1402 xdr_setpos64(xdrs,end);
1403 return size;
1404}
1405
1406static int pack_r_Momentum(XDR* xdrs, r_Momentum_t* this1)
1407{
1408 int m=0;
1409 unsigned int size=0;
1410 off_t base,start,end;
1411 base = xdr_getpos64(xdrs);
1412 xdr_u_int(xdrs,&size);
1413 start = xdr_getpos64(xdrs);
1414
1415 {
1416 xdr_float(xdrs,&this1->E);
1417 xdr_float(xdrs,&this1->px);
1418 xdr_float(xdrs,&this1->py);
1419 xdr_float(xdrs,&this1->pz);
1420 }
1421 FREE(this1)free(this1);
1422 end = xdr_getpos64(xdrs);
1423 xdr_setpos64(xdrs,base);
1424 size = end-start;
1425 xdr_u_int(xdrs,&size);
1426 xdr_setpos64(xdrs,end);
1427 return size;
1428}
1429
1430static int pack_r_TaggerHits(XDR* xdrs, r_TaggerHits_t* this1)
1431{
1432 int m=0;
1433 unsigned int size=0;
1434 off_t base,start,end;
1435 base = xdr_getpos64(xdrs);
1436 xdr_u_int(xdrs,&size);
1437 start = xdr_getpos64(xdrs);
1438
1439 xdr_u_int(xdrs,&this1->mult);
1440 for (m = 0; m < this1->mult; m++)
1441 {
1442 xdr_float(xdrs,&this1->in[m].E);
1443 xdr_string(xdrs,&this1->in[m].jtag, 1000000);
1444 FREE(this1->in[m].jtag)free(this1->in[m].jtag);
1445 xdr_float(xdrs,&this1->in[m].t);
1446 }
1447 FREE(this1)free(this1);
1448 end = xdr_getpos64(xdrs);
1449 xdr_setpos64(xdrs,base);
1450 size = end-start;
1451 xdr_u_int(xdrs,&size);
1452 xdr_setpos64(xdrs,end);
1453 return size;
1454}
1455
1456static int pack_r_CalorimeterClusters(XDR* xdrs, r_CalorimeterClusters_t* this1)
1457{
1458 int m=0;
1459 unsigned int size=0;
1460 off_t base,start,end;
1461 base = xdr_getpos64(xdrs);
1462 xdr_u_int(xdrs,&size);
1463 start = xdr_getpos64(xdrs);
1464
1465 xdr_u_int(xdrs,&this1->mult);
1466 for (m = 0; m < this1->mult; m++)
1467 {
1468 xdr_float(xdrs,&this1->in[m].E);
1469 xdr_float(xdrs,&this1->in[m].Eerr);
1470 xdr_float(xdrs,&this1->in[m].Ezcorr);
1471 xdr_string(xdrs,&this1->in[m].jtag, 1000000);
1472 FREE(this1->in[m].jtag)free(this1->in[m].jtag);
1473 xdr_float(xdrs,&this1->in[m].t);
1474 xdr_float(xdrs,&this1->in[m].terr);
1475 xdr_float(xdrs,&this1->in[m].tzcorr);
1476 xdr_float(xdrs,&this1->in[m].x);
1477 xdr_float(xdrs,&this1->in[m].xerr);
1478 xdr_float(xdrs,&this1->in[m].xycorr);
1479 xdr_float(xdrs,&this1->in[m].xzcorr);
1480 xdr_float(xdrs,&this1->in[m].y);
1481 xdr_float(xdrs,&this1->in[m].yerr);
1482 xdr_float(xdrs,&this1->in[m].yzcorr);
1483 xdr_float(xdrs,&this1->in[m].z);
1484 xdr_float(xdrs,&this1->in[m].zerr);
1485 }
1486 FREE(this1)free(this1);
1487 end = xdr_getpos64(xdrs);
1488 xdr_setpos64(xdrs,base);
1489 size = end-start;
1490 xdr_u_int(xdrs,&size);
1491 xdr_setpos64(xdrs,end);
1492 return size;
1493}
1494
1495static int pack_r_ChargedTracks(XDR* xdrs, r_ChargedTracks_t* this1)
1496{
1497 int m=0;
1498 unsigned int size=0;
1499 off_t base,start,end;
1500 base = xdr_getpos64(xdrs);
1501 xdr_u_int(xdrs,&size);
1502 start = xdr_getpos64(xdrs);
1503
1504 xdr_u_int(xdrs,&this1->mult);
1505 for (m = 0; m < this1->mult; m++)
1506 {
1507 xdr_int(xdrs,&this1->in[m].candidateId);
1508 xdr_string(xdrs,&this1->in[m].jtag, 1000000);
1509 FREE(this1->in[m].jtag)free(this1->in[m].jtag);
1510 xdr_int(xdrs,(int*)&this1->in[m].ptype);
1511 if (this1->in[m].trackFit != (r_TrackFit_t*)&hddm_r_nullTarget)
1512 {
1513 if (pack_r_TrackFit(xdrs,this1->in[m].trackFit) < 0) {
1514 return -1;
1515 }
1516 }
1517 else
1518 {
1519 int zero=0;
1520 xdr_int(xdrs,&zero);
1521 }
1522 if (this1->in[m].dEdxDC != (r_DEdxDC_t*)&hddm_r_nullTarget)
1523 {
1524 if (pack_r_DEdxDC(xdrs,this1->in[m].dEdxDC) < 0) {
1525 return -1;
1526 }
1527 }
1528 else
1529 {
1530 int zero=0;
1531 xdr_int(xdrs,&zero);
1532 }
1533 }
1534 FREE(this1)free(this1);
1535 end = xdr_getpos64(xdrs);
1536 xdr_setpos64(xdrs,base);
1537 size = end-start;
1538 xdr_u_int(xdrs,&size);
1539 xdr_setpos64(xdrs,end);
1540 return size;
1541}
1542
1543static int pack_r_TrackFit(XDR* xdrs, r_TrackFit_t* this1)
1544{
1545 int m=0;
1546 unsigned int size=0;
1547 off_t base,start,end;
1548 base = xdr_getpos64(xdrs);
1549 xdr_u_int(xdrs,&size);
1550 start = xdr_getpos64(xdrs);
1551
1552 {
1553 xdr_int(xdrs,&this1->Ndof);
1554 xdr_float(xdrs,&this1->chisq);
1555 xdr_float(xdrs,&this1->e11);
1556 xdr_float(xdrs,&this1->e12);
1557 xdr_float(xdrs,&this1->e13);
1558 xdr_float(xdrs,&this1->e14);
1559 xdr_float(xdrs,&this1->e15);
1560 xdr_float(xdrs,&this1->e22);
1561 xdr_float(xdrs,&this1->e23);
1562 xdr_float(xdrs,&this1->e24);
1563 xdr_float(xdrs,&this1->e25);
1564 xdr_float(xdrs,&this1->e33);
1565 xdr_float(xdrs,&this1->e34);
1566 xdr_float(xdrs,&this1->e35);
1567 xdr_float(xdrs,&this1->e44);
1568 xdr_float(xdrs,&this1->e45);
1569 xdr_float(xdrs,&this1->e55);
1570 xdr_float(xdrs,&this1->px);
1571 xdr_float(xdrs,&this1->py);
1572 xdr_float(xdrs,&this1->pz);
1573 xdr_float(xdrs,&this1->t0);
1574 xdr_int(xdrs,&this1->t0det);
1575 xdr_float(xdrs,&this1->t0err);
1576 xdr_float(xdrs,&this1->x0);
1577 xdr_float(xdrs,&this1->y0);
1578 xdr_float(xdrs,&this1->z0);
1579 }
1580 FREE(this1)free(this1);
1581 end = xdr_getpos64(xdrs);
1582 xdr_setpos64(xdrs,base);
1583 size = end-start;
1584 xdr_u_int(xdrs,&size);
1585 xdr_setpos64(xdrs,end);
1586 return size;
1587}
1588
1589static int pack_r_DEdxDC(XDR* xdrs, r_DEdxDC_t* this1)
1590{
1591 int m=0;
1592 unsigned int size=0;
1593 off_t base,start,end;
1594 base = xdr_getpos64(xdrs);
1595 xdr_u_int(xdrs,&size);
1596 start = xdr_getpos64(xdrs);
1597
1598 {
1599 xdr_int(xdrs,&this1->NsampleCDC);
1600 xdr_int(xdrs,&this1->NsampleFDC);
1601 xdr_float(xdrs,&this1->dEdxCDC);
1602 xdr_float(xdrs,&this1->dEdxFDC);
1603 xdr_float(xdrs,&this1->dxCDC);
1604 xdr_float(xdrs,&this1->dxFDC);
1605 }
1606 FREE(this1)free(this1);
1607 end = xdr_getpos64(xdrs);
1608 xdr_setpos64(xdrs,base);
1609 size = end-start;
1610 xdr_u_int(xdrs,&size);
1611 xdr_setpos64(xdrs,end);
1612 return size;
1613}
1614
1615static int pack_r_StartHits(XDR* xdrs, r_StartHits_t* this1)
1616{
1617 int m=0;
1618 unsigned int size=0;
1619 off_t base,start,end;
1620 base = xdr_getpos64(xdrs);
1621 xdr_u_int(xdrs,&size);
1622 start = xdr_getpos64(xdrs);
1623
1624 xdr_u_int(xdrs,&this1->mult);
1625 for (m = 0; m < this1->mult; m++)
1626 {
1627 xdr_float(xdrs,&this1->in[m].dE);
1628 xdr_string(xdrs,&this1->in[m].jtag, 1000000);
1629 FREE(this1->in[m].jtag)free(this1->in[m].jtag);
1630 xdr_int(xdrs,&this1->in[m].sector);
1631 xdr_float(xdrs,&this1->in[m].t);
1632 }
1633 FREE(this1)free(this1);
1634 end = xdr_getpos64(xdrs);
1635 xdr_setpos64(xdrs,base);
1636 size = end-start;
1637 xdr_u_int(xdrs,&size);
1638 xdr_setpos64(xdrs,end);
1639 return size;
1640}
1641
1642static int pack_r_TofPoints(XDR* xdrs, r_TofPoints_t* this1)
1643{
1644 int m=0;
1645 unsigned int size=0;
1646 off_t base,start,end;
1647 base = xdr_getpos64(xdrs);
1648 xdr_u_int(xdrs,&size);
1649 start = xdr_getpos64(xdrs);
1650
1651 xdr_u_int(xdrs,&this1->mult);
1652 for (m = 0; m < this1->mult; m++)
1653 {
1654 xdr_float(xdrs,&this1->in[m].dE);
1655 xdr_string(xdrs,&this1->in[m].jtag, 1000000);
1656 FREE(this1->in[m].jtag)free(this1->in[m].jtag);
1657 xdr_float(xdrs,&this1->in[m].t);
1658 xdr_float(xdrs,&this1->in[m].x);
1659 xdr_float(xdrs,&this1->in[m].y);
1660 xdr_float(xdrs,&this1->in[m].z);
1661 }
1662 FREE(this1)free(this1);
1663 end = xdr_getpos64(xdrs);
1664 xdr_setpos64(xdrs,base);
1665 size = end-start;
1666 xdr_u_int(xdrs,&size);
1667 xdr_setpos64(xdrs,end);
1668 return size;
1669}
1670
1671static int pack_r_RFtime(XDR* xdrs, r_RFtime_t* this1)
1672{
1673 int m=0;
1674 unsigned int size=0;
1675 off_t base,start,end;
1676 base = xdr_getpos64(xdrs);
1677 xdr_u_int(xdrs,&size);
1678 start = xdr_getpos64(xdrs);
1679
1680 {
1681 xdr_string(xdrs,&this1->jtag, 1000000);
1682 FREE(this1->jtag)free(this1->jtag);
1683 xdr_float(xdrs,&this1->tsync);
1684 xdr_float(xdrs,&this1->tsyncerr);
1685 }
1686 FREE(this1)free(this1);
1687 end = xdr_getpos64(xdrs);
1688 xdr_setpos64(xdrs,base);
1689 size = end-start;
1690 xdr_u_int(xdrs,&size);
1691 xdr_setpos64(xdrs,end);
1692 return size;
1693}
1694
1695int flush_r_HDDM(r_HDDM_t* this1,r_iostream_t* fp)
1696{
1697 if (this1 == 0)
1698 {
1699 return 0;
1700 }
1701 else if (fp == 0)
1702 {
1703 XDR* xdrs = (XDR*)malloc(sizeof(XDR));
1704 int max_buffer_size = 1000000;
1705 char* dump = (char*)malloc(max_buffer_size);
1706 xdrmem_create(xdrs,dump,max_buffer_size,XDR_ENCODE);
1707 pack_r_HDDM(xdrs,this1);
1708 xdr_destroy(xdrs)do { if ((xdrs)->x_ops->x_destroy) (*(xdrs)->x_ops->
x_destroy)(xdrs); } while (0)
;
1709 free(xdrs);
1710 free(dump);
1711 }
1712 else if (fp->iomode == HDDM_STREAM_OUTPUT-92)
1713 {
1714 if (pack_r_HDDM(fp->xdrs,this1) < 0) {
1715 fp->lerrno = errno(*__errno_location ());
1716 return -1;
1717 }
1718 }
1719 return 0;
1720}
1721
1722static int getTag(char* d, char* tag)
1723{
1724 int level;
1725 char* token;
1726 char line[500];
1727 strncpy(line,d,500);
1728 line[499] = 0;
1729 level = index(line,'<')-line;
1730 if (level < 500 &&
1731 (token = strtok(line+level+1," >")))
1732 {
1733 strncpy(tag,token,500);
1734 return level/2;
1735 }
1736 return -1;
1737}
1738
1739static char* getEndTag(char* d, char* tag)
1740{
1741 char line[500];
1742 char endTag[510];
1743 strncpy(line,d,500);
1744 line[499] = 0;
1745 if (strstr(strtok(line,"\n"),"/>") == 0)
1746 {
1747 sprintf(endTag,"</%s>",tag);
1748 }
1749 else
1750 {
1751 strcpy(endTag,"/>");
1752 }
1753 return strstr(d,endTag);
1754}
1755
1756static void collide(char* b, char* c)
1757{
1758 char btag[500];
1759 getTag(b,btag);
1760 b = index(b,'<');
1761 c = index(c,'<');
1762 *(index(b,'\n')) = 0;
1763 *(index(c,'\n')) = 0;
1764 fprintf(stderrstderr,"HDDM warning: ");
1765 fprintf(stderrstderr,"tag %s in input file ", btag);
1766 fprintf(stderrstderr,"does not match c header hddm_r.h\n");
1767 fprintf(stderrstderr," input file: %s\n", b);
1768 fprintf(stderrstderr," c header: %s\n", c);
1769 fprintf(stderrstderr," === Tag %s will be ignored,", btag);
1770 fprintf(stderrstderr," rebuild to cure the problem ===\n");
1771 *(index(b,0)) = '\n';
1772 *(index(c,0)) = '\n';
1773}
1774
1775static popNode* matches(char* b, char* c)
1776{
1777 char btag[500];
1778 char ctag[500];
1779 int blevel, clevel;
1780 int ptrSeqNo = 0;
1781 blevel = getTag(b,btag);
1782 while ((clevel = getTag(c,ctag)) == blevel)
1783 {
1784 if ((clevel == blevel) && (strcmp(ctag,btag) == 0))
1785 {
1786 popNode* this1 = (popNode*)malloc(sizeof(popNode));
1787 int len = index(c+1,'\n') - c;
1788 if (strncmp(c,b,len) != 0)
1789 {
1790 collide(b,c);
1791 return 0;
1792 }
1793 else if (strcmp(btag,"HDDM") == 0)
1794 {
1795 this1->unpacker = (void*(*)(XDR*,popNode*))unpack_r_HDDM;
1796 }
1797 else if (strcmp(btag,"reconstructedPhysicsEvent") == 0)
1798 {
1799 this1->unpacker = (void*(*)(XDR*,popNode*))unpack_r_ReconstructedPhysicsEvent;
1800 }
1801 else if (strcmp(btag,"comment") == 0)
1802 {
1803 this1->unpacker = (void*(*)(XDR*,popNode*))unpack_r_Comments;
1804 }
1805 else if (strcmp(btag,"reaction") == 0)
1806 {
1807 this1->unpacker = (void*(*)(XDR*,popNode*))unpack_r_Reactions;
1808 }
1809 else if (strcmp(btag,"vertex") == 0)
1810 {
1811 this1->unpacker = (void*(*)(XDR*,popNode*))unpack_r_Vertices;
1812 }
1813 else if (strcmp(btag,"origin") == 0)
1814 {
1815 this1->unpacker = (void*(*)(XDR*,popNode*))unpack_r_Origin;
1816 }
1817 else if (strcmp(btag,"product") == 0)
1818 {
1819 this1->unpacker = (void*(*)(XDR*,popNode*))unpack_r_Products;
1820 }
1821 else if (strcmp(btag,"momentum") == 0)
1822 {
1823 this1->unpacker = (void*(*)(XDR*,popNode*))unpack_r_Momentum;
1824 }
1825 else if (strcmp(btag,"taggerHit") == 0)
1826 {
1827 this1->unpacker = (void*(*)(XDR*,popNode*))unpack_r_TaggerHits;
1828 }
1829 else if (strcmp(btag,"calorimeterCluster") == 0)
1830 {
1831 this1->unpacker = (void*(*)(XDR*,popNode*))unpack_r_CalorimeterClusters;
1832 }
1833 else if (strcmp(btag,"chargedTrack") == 0)
1834 {
1835 this1->unpacker = (void*(*)(XDR*,popNode*))unpack_r_ChargedTracks;
1836 }
1837 else if (strcmp(btag,"trackFit") == 0)
1838 {
1839 this1->unpacker = (void*(*)(XDR*,popNode*))unpack_r_TrackFit;
1840 }
1841 else if (strcmp(btag,"dEdxDC") == 0)
1842 {
1843 this1->unpacker = (void*(*)(XDR*,popNode*))unpack_r_DEdxDC;
1844 }
1845 else if (strcmp(btag,"startHit") == 0)
1846 {
1847 this1->unpacker = (void*(*)(XDR*,popNode*))unpack_r_StartHits;
1848 }
1849 else if (strcmp(btag,"tofPoint") == 0)
1850 {
1851 this1->unpacker = (void*(*)(XDR*,popNode*))unpack_r_TofPoints;
1852 }
1853 else if (strcmp(btag,"RFtime") == 0)
1854 {
1855 this1->unpacker = (void*(*)(XDR*,popNode*))unpack_r_RFtime;
1856 }
1857 this1->inParent = ptrSeqNo;
1858 this1->popListLength = 0;
1859 c = index(c+1,'\n');
1860 b = index(b+1,'\n');
1861 while (getTag(b,btag) > blevel)
1862 {
1863 this1->popList[this1->popListLength++] = matches(b,c);
1864 if (this1->popListLength > 99)
1865 {
1866 fprintf(stderrstderr,"hddm error - popList overflow.\n");
1867 fprintf(stderrstderr,"Increase MAX_POPLIST_LENGTH and recompile.\n");
1868 exit(9);
1869 }
1870 b = getEndTag(b,btag);
1871 b = index(b+1,'\n');
1872 }
1873 return this1;
1874 }
1875 else
1876 {
1877 c = getEndTag(c,ctag);
1878 c = index(c+1,'\n');
1879 ++ptrSeqNo;
1880 }
1881 }
1882 return 0;
1883}
1884
1885r_iostream_t* open_r_HDDM(char* filename)
1886{
1887 r_iostream_t* fp = (r_iostream_t*)malloc(sizeof(r_iostream_t));
1888 char* p;
1889 char* head;
1890 if (filename)
1
Taking false branch
1891 {
1892 fp->fd = fopen(filename,"r");
1893 }
1894 else
1895 {
1896 fp->fd = fdopen(0,"r");
1897 }
1898 if (fp->fd == 0)
2
Taking false branch
1899 {
1900 free(fp);
1901 return 0;
1902 }
1903 fp->iomode = HDDM_STREAM_INPUT-91;
1904 head = (char*)malloc(1000000);
1905 *head = 0;
1906 for (p = head;
3
Loop condition is false. Execution continues on line 1920
1907 strstr(head,"</HDDM>") == 0;
1908 p += strlen(p))
1909 {
1910 if (p-head < 999000)
1911 {
1912 char *pbuf;
1913 pbuf = fgets(p,1000,fp->fd);
1914 }
1915 else
1916 {
1917 break;
1918 }
1919 }
1920 fp->popTop = matches(head,HDDM_r_DocumentString);
1921 free(head);
1922 if (fp->popTop->popListLength == 0)
4
Access to field 'popListLength' results in a dereference of a null pointer (loaded from field 'popTop')
1923 {
1924 fprintf(stderrstderr,"HDDM Error: ");
1925 fprintf(stderrstderr,"input template model ");
1926 fprintf(stderrstderr,"does not match c header.");
1927 fprintf(stderrstderr," Please recompile.\n");
1928 exit(9);
1929 }
1930 fp->filename = (char*)malloc(strlen(filename) + 1);
1931 strcpy(fp->filename,filename);
1932 fp->xdrs = (XDR*)malloc(sizeof(XDR));
1933 xdrstdio_create(fp->xdrs,fp->fd,XDR_DECODE);
1934 return fp;
1935}
1936
1937r_iostream_t* init_r_HDDM(char* filename)
1938{
1939 int len;
1940 char* head;
1941 r_iostream_t* fp = (r_iostream_t*)malloc(sizeof(r_iostream_t));
1942 if (filename)
1943 {
1944 fp->fd = fopen(filename,"w");
1945 }
1946 else
1947 {
1948 fp->fd = fdopen(1,"w");
1949 }
1950 if (fp->fd == 0)
1951 {
1952 free(fp);
1953 return 0;
1954 }
1955 fp->iomode = HDDM_STREAM_OUTPUT-92;
1956 len = strlen(HDDM_r_DocumentString);
1957 head = (char*)malloc(len+1);
1958 strcpy(head,HDDM_r_DocumentString);
1959 if (fwrite(head,1,len,fp->fd) != len)
1960 {
1961 fprintf(stderrstderr,"HDDM Error: ");
1962 fprintf(stderrstderr,"error writing to ");
1963 fprintf(stderrstderr,"output file %s\n",filename);
1964 exit(9);
1965 }
1966 fp->filename = (char*)malloc(strlen(filename) + 1);
1967 strcpy(fp->filename,filename);
1968 fp->popTop = 0;
1969 fp->xdrs = (XDR*)malloc(sizeof(XDR));
1970 xdrstdio_create(fp->xdrs,fp->fd,XDR_ENCODE);
1971 free(head);
1972 return fp;
1973}
1974
1975static void popaway(popNode* p)
1976{
1977 if (p)
1978 {
1979 int n;
1980 for (n = 0; n < p->popListLength; n++)
1981 {
1982 popaway(p->popList[n]);
1983 }
1984 free(p);
1985 }
1986}
1987
1988void close_r_HDDM(r_iostream_t* fp)
1989{
1990 xdr_destroy(fp->xdrs)do { if ((fp->xdrs)->x_ops->x_destroy) (*(fp->xdrs
)->x_ops->x_destroy)(fp->xdrs); } while (0)
;
1991 free(fp->xdrs);
1992 fclose(fp->fd);
1993 free(fp->filename);
1994 popaway(fp->popTop);
1995 free(fp);
1996}