@@ -188,7 +188,7 @@ int main( int argc, char *argv[] )
188
188
printf ("Need: short=%d int=%d long=%d long long=%d bytes\n" ,2 ,4 ,4 ,8 );
189
189
exit (1 );
190
190
}
191
-
191
+
192
192
/*printf("Sizeof qwhs = %d\n",sizeof(qwhs));*/
193
193
194
194
/******************************************************************/
@@ -448,39 +448,50 @@ int main( int argc, char *argv[] )
448
448
if (recordType == 116 || recordType == 115 )
449
449
{
450
450
/*******************************************************************/
451
- /* The first triplet past the standard header points at a */
451
+ /* The first triplet past the standard header usually points at a */
452
452
/* QWHS structure. */
453
453
/* */
454
454
/* This has various pieces of information about the record. */
455
455
/* Most important here is to say how many data sections are */
456
456
/* in it, which says how many further triplets should be */
457
- /* used. */
457
+ /* used. If there is no valid QWHS, then we assume that there */
458
+ /* is only one further triplet so force that value. */
458
459
/* */
459
460
/* Also pick up the STCK value that may be useful */
460
461
/* for sorting. */
461
462
/*******************************************************************/
462
463
p = & dataBuf [conv32 (pSMFRecord -> s [0 ].offset )];
463
- pqwhs = (qwhs * )p ;
464
- sectionCount = pqwhs -> qwhsnsda [0 ];
465
- strcpy (commonF .stckFormat ,convDate (pqwhs -> qwhsstck ));
466
- if (recordType == 115 )
464
+ if (conv16 (pSMFRecord -> s [0 ].l ) == 4 ) /* There is no QWHS */
467
465
{
468
- if (conv16 (pqwhs -> qwhslen ) >= 52 )
469
- {
470
- /* This structure changes size on different platforms because */
471
- /* of how the compiler deals with bitfields. So have to do it */
472
- /* explicitly with known offsets after the structure changes. */
473
- char * t = (char * )& (pqwhs -> qwhsflag1 );
474
- t += 4 ;
475
- memcpy (& commonF .intstart ,t ,8 );
476
- t += 8 ;
477
- memcpy (& commonF .intduration ,t ,8 );
478
- }
479
- else
466
+ sectionCount = 2 ; /* 1 extra triplet beyond the QWHS location */
467
+ pqwhs = NULL ;
468
+ commonF .intstart = 0 ;
469
+ commonF .intduration = 0 ;
470
+ }
471
+ else
472
+ {
473
+ pqwhs = (qwhs * )p ;
474
+ sectionCount = pqwhs -> qwhsnsda [0 ];
475
+ strcpy (commonF .stckFormat ,convDate (pqwhs -> qwhsstck ));
476
+ if (recordType == 115 )
480
477
{
481
- /* These fields were added after V701 so ignore for old SMF */
482
- commonF .intstart = 0 ;
483
- commonF .intduration = 0 ;
478
+ if (conv16 (pqwhs -> qwhslen ) >= 52 )
479
+ {
480
+ /* This structure changes size on different platforms because */
481
+ /* of how the compiler deals with bitfields. So have to do it */
482
+ /* explicitly with known offsets after the structure changes. */
483
+ char * t = (char * )& (pqwhs -> qwhsflag1 );
484
+ t += 4 ;
485
+ memcpy (& commonF .intstart ,t ,8 );
486
+ t += 8 ;
487
+ memcpy (& commonF .intduration ,t ,8 );
488
+ }
489
+ else
490
+ {
491
+ /* These fields were added after V701 so ignore for old SMF */
492
+ commonF .intstart = 0 ;
493
+ commonF .intduration = 0 ;
494
+ }
484
495
}
485
496
}
486
497
}
@@ -837,6 +848,7 @@ FILE * fopenext(const char * basename, const char *ext, BOOL *newFile)
837
848
838
849
fseek (fp ,0 ,SEEK_END );
839
850
pos = ftell (fp );
851
+ /*setbuf(fp,0); */ /* useful to have this line when debugging */
840
852
841
853
if (pos == 0 ) /* Have we just created the file, even for "append" mode */
842
854
* newFile = TRUE;
0 commit comments