Skip to content

Commit 2089728

Browse files
committed
Deal with 115 subtypes that do not have a valid QWHS
1 parent 94c5c34 commit 2089728

File tree

10 files changed

+39
-25
lines changed

10 files changed

+39
-25
lines changed

README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,10 @@ May 2017
6767
* Using a VERS flag during the build to select correct base header file
6868
and features
6969

70+
Oct 2017
71+
* Found that some 115 subtypes do not have a QWHS structure correctly
72+
created; cannot rely on it being there
73+
7074

7175
Pull requests
7276
=============

bin/aix/convH

0 Bytes
Binary file not shown.

bin/aix/mqsmfcsv

20 Bytes
Binary file not shown.

bin/linux/convH

-312 Bytes
Binary file not shown.

bin/linux/mqsmfcsv

-204 Bytes
Binary file not shown.

bin/win/convH.exe

602 Bytes
Binary file not shown.

bin/win/mqsmfcsv.exe

0 Bytes
Binary file not shown.

mqsmfcsv.doc

512 Bytes
Binary file not shown.

src/Makefile.gcc.win

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -37,12 +37,10 @@ HDR = mqsmfstruc.h \
3737
mqsmf.h
3838

3939
mqsmfcsv.exe: $(SRC) $(HDR) Makefile.gcc.win dummy
40+
-rm -f $@
4041
$(CC) $(PLATFLAGS) -o $@ $(SRC) $(CFLAGS) -DCSQDSMF_VERSION=$(VERS)
41-
-rm -f out/*
42-
-rm -f SMF-*
4342
-mkdir out >/dev/null 2>&1 || true
4443
cp $@ ../bin/win
45-
# dbx ./$@
4644

4745
mqsmfstruc.h: csqdsmfc-$(VERS).h convH.exe dummy
4846
./convH.exe < csqdsmfc-$(VERS).h > $@

src/mqsmf.c

Lines changed: 34 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -188,7 +188,7 @@ int main( int argc, char *argv[] )
188188
printf("Need: short=%d int=%d long=%d long long=%d bytes\n",2,4,4,8);
189189
exit(1);
190190
}
191-
191+
192192
/*printf("Sizeof qwhs = %d\n",sizeof(qwhs));*/
193193

194194
/******************************************************************/
@@ -448,39 +448,50 @@ int main( int argc, char *argv[] )
448448
if (recordType == 116 || recordType == 115)
449449
{
450450
/*******************************************************************/
451-
/* The first triplet past the standard header points at a */
451+
/* The first triplet past the standard header usually points at a */
452452
/* QWHS structure. */
453453
/* */
454454
/* This has various pieces of information about the record. */
455455
/* Most important here is to say how many data sections are */
456456
/* 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. */
458459
/* */
459460
/* Also pick up the STCK value that may be useful */
460461
/* for sorting. */
461462
/*******************************************************************/
462463
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 */
467465
{
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)
480477
{
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+
}
484495
}
485496
}
486497
}
@@ -837,6 +848,7 @@ FILE * fopenext(const char * basename, const char *ext, BOOL *newFile)
837848

838849
fseek(fp,0,SEEK_END);
839850
pos = ftell(fp);
851+
/*setbuf(fp,0); */ /* useful to have this line when debugging */
840852

841853
if (pos == 0) /* Have we just created the file, even for "append" mode */
842854
*newFile = TRUE;

0 commit comments

Comments
 (0)