Skip to content

Commit a6b8af7

Browse files
committed
Update for MQ 9.3.2
1 parent 5ddf434 commit a6b8af7

20 files changed

+155
-63
lines changed

CHANGES.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,12 @@
22
History (newest at top)
33
=======================
44

5+
Feb 2023 (v5.4.2)
6+
* Update for MQ V9.3.2
7+
* WQ structure extended with streamed message count
8+
* Fix problem when final record in input data was truncated/corrupt
9+
* Removed QIST RAIO/RABP fields as they are never filled in by qmgr so misleading
10+
511
Oct 2022 (v5.4.1)
612
* Update for MQ V9.3.1
713
* Extended QQST structure in the 115 records

bin/aix/convH

836 Bytes
Binary file not shown.

bin/aix/mqsmfcsv

248 KB
Binary file not shown.

bin/linux/convH

-16 Bytes
Binary file not shown.

bin/linux/mqsmfcsv

-4.02 KB
Binary file not shown.

bin/win/convH.exe

0 Bytes
Binary file not shown.

bin/win/mqsmfcsv.exe

1 KB
Binary file not shown.

src/M

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plat=`uname`
44

55
if [ -z "$VERS" ]
66
then
7-
VERS="931"
7+
VERS="932"
88
fi
99

1010
if [ "$plat" = "AIX" ]

src/Makefile.gcc.win

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ CC=i686-w64-mingw32-gcc
33
# CFLAGS= -I. -m32 -fpack-struct=8 -DPLATFORM_WINDOWS
44
CFLAGS= -I. -m32 -DPLATFORM_WINDOWS
55
PLATFLAGS=
6-
VERS=931
6+
VERS=932
77
SRC = mqsmf.c \
88
smfDDL.c \
99
smfDate.c \

src/Makefile.unix

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11

22
CC=cc
3-
CFLAGS= -I.
3+
CFLAGS= -I. -O2
44
PLATFLAGS=
55
SRC = \
66
smfDDL.c \

src/Makefile.win

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
CFLAGS=-nologo /D_CRT_SECURE_NO_WARNINGS /Zp1 /J /O2 /DPLATFORM_WINDOWS
2-
VERS=931
2+
VERS=932
33
SRC = mqsmf.c \
44
smfDDL.c \
55
smfDate.c \

src/convH64.c

Lines changed: 26 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
* to an explicitly-sized standard datatype (eg uint64). This
2727
* is needed if the program is compiled in 64-bit mode. We also
2828
* rewrite bitfield elements in structures.
29-
*
29+
*
3030
* Two variants of the output are created, one for Windows
3131
* and one for Unix, based on the PLATFORM_* definitions because
3232
* of different paddings done for bitfields.
@@ -105,6 +105,7 @@ int inBitfieldReplace = 0;
105105
void bitfieldReprint(int c);
106106
void datatypeReplace(char *);
107107
char *stripLine(char *);
108+
char *trimLine(char *);
108109
void printHeader(char *);
109110

110111
int main(int argc, char **argv)
@@ -140,6 +141,8 @@ int main(int argc, char **argv)
140141
c = fgets(line,sizeof(line)-1,stdin);
141142
if (c)
142143
{
144+
c = trimLine(line);
145+
143146
if (strstr(line,"pragma"))
144147
continue;
145148
/****************************************************/
@@ -185,6 +188,26 @@ int main(int argc, char **argv)
185188
return 0;
186189
}
187190

191+
/* Strip trailing whitespace but leave the final "\n" alone */
192+
char *trimLine(char *l) {
193+
char *p;
194+
int len;
195+
int trimmed = 0;
196+
len = strlen(l);
197+
if (len > 2) {
198+
p = &l[len-2]; /* Start before the final '\n' */
199+
while (*p == ' ' || *p == '\t') {
200+
trimmed=1;
201+
*p=0;
202+
p--;
203+
}
204+
if (trimmed) {
205+
strcat(l,"\n"); /* Put the trailing CR back */
206+
}
207+
}
208+
return l;
209+
}
210+
188211
/* Remove trailing comments and leading spaces */
189212
char *stripLine(char *l) {
190213
char *p = l;
@@ -198,7 +221,7 @@ char *stripLine(char *l) {
198221
cmtEnd = strstr(p,"*/\n");
199222

200223
/* There are a few multi-line macros that have comments embedded
201-
* so we can't just strip to end of line ... if the line ends in
224+
* so we can't just strip to end of line ... if the line ends in
202225
* a continuation marker then leave the comments alone
203226
*/
204227
if (cmtStart != NULL && cmtEnd != NULL && p[strlen(p)-2] != '\\') {
@@ -389,7 +412,7 @@ void datatypeReplace(char *line) {
389412
return;
390413
}
391414

392-
void printHeader(char *version)
415+
void printHeader(char *version)
393416
{
394417
printf("/*\n");
395418
printf(" * This file was generated from cqsdsmfc.h version %s\n",version);

src/mqsmf.c

Lines changed: 48 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright (c) 2016,2020 IBM Corporation and other Contributors.
2+
* Copyright (c) 2016,2023 IBM Corporation and other Contributors.
33
*
44
* All rights reserved. This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License v1.0
@@ -163,6 +163,7 @@ static int offsetCorrection = 0;
163163
static BOOL warn115_240=FALSE;
164164

165165
static time_t startTime = 0;
166+
static time_t endTime = 0;
166167
static char *formatRate;
167168

168169
static int amsType = SMFTYPE_MQ_AMS;
@@ -207,6 +208,7 @@ int main( int argc, char *argv[] )
207208
int i,j; /* loop counters */
208209
char dataBuf[MAX_SMF_DATA]; /* Contains the SMF data */
209210
int bytesRead; /* Number of bytes from fread() */
211+
int tmpBytes;
210212
int offset; /* total number of bytes in a record*/
211213
unsigned int d[3]; /* used in date conversion */
212214
unsigned int ddd,year; /* day number and year number */
@@ -399,8 +401,7 @@ int main( int argc, char *argv[] )
399401

400402
fstat(fileno(fp),&statbuf);
401403
totalFileSize = statbuf.st_size;
402-
if (debugLevel >=3 )
403-
fprintf(infoStream,"Total File Size = %lld\n",totalFileSize);
404+
debugf(3,"Total File Size = %lld\n",totalFileSize);
404405

405406
convInit(); /* Decide whether this is a big or little endian machine*/
406407

@@ -466,15 +467,22 @@ int main( int argc, char *argv[] )
466467
/* same as the SMF record length). It comes from the first two */
467468
/* bytes of the Record Descriptor Word (RDW). */
468469
/********************************************************************/
469-
470470
bytesRead = fread(&pSMFMQRecord->Header.SMFLEN,1,2,fp);
471471
if (bytesRead < 2)
472-
continue;
472+
{
473+
debugf(1,"At end of input data - fread (phase 1a) returned %d bytes\n",tmpBytes);
474+
break;
475+
}
473476

474477
/********************************************************************/
475478
/* The second half-word is the segment indicator. */
476479
/********************************************************************/
477-
fread(&pSMFMQRecord->Header.SMFSEG ,1,2,fp);
480+
tmpBytes = fread(&pSMFMQRecord->Header.SMFSEG ,1,2,fp);
481+
if (tmpBytes < 2)
482+
{
483+
debugf(1,"At end of input data - fread (phase 1b) returned %d bytes\n",tmpBytes);
484+
break;
485+
}
478486

479487
/********************************************************************/
480488
/* And then read the actual data, starting at the RECFLG field in */
@@ -483,8 +491,7 @@ int main( int argc, char *argv[] )
483491
/* amount. */
484492
/********************************************************************/
485493
nextLength = conv16(pSMFMQRecord->Header.SMFLEN) - 4;
486-
if (debugLevel >=3)
487-
fprintf(infoStream," NextLen = %d bytes \n",nextLength);
494+
debugf(3," NextLen = %d bytes \n",(nextLength));
488495

489496
bytesRead = fread(&pSMFMQRecord->Header.SMFRECFLG, 1, nextLength , fp);
490497
if (bytesRead != nextLength)
@@ -504,18 +511,28 @@ int main( int argc, char *argv[] )
504511
/* segmentation, no SMF record is meant to be >32768 bytes, so we */
505512
/* need to check that. Once again, ignore the RDW when working */
506513
/* out how much real data there is. */
514+
/* We've also seen input files which were truncated such that */
515+
/* the continuation records were not captured. So check that we are */
516+
/* actually able to read the data and that we're not at the EOF. */
507517
/********************************************************************/
508518
if (pSMFMQRecord->Header.SMFSEG[0] != 0)
509519
{
510520
do
511521
{
522+
tmpBytes = fread(&nextLength ,1,2,fp);
523+
if (tmpBytes < 2) {
524+
debugf(1,"At end of input data - fread (phase 2a) returned %d bytes\n",tmpBytes);
525+
goto mod_exit;
526+
}
512527

513-
fread(&nextLength ,1,2,fp);
514528
nextLength = conv16(nextLength);
515-
fread(&pSMFMQRecord->Header.SMFSEG ,1,2,fp);
529+
tmpBytes = fread(&pSMFMQRecord->Header.SMFSEG ,1,2,fp);
530+
if (tmpBytes < 2) {
531+
debugf(1,"At end of input data - fread (phase 2b) returned %d bytes\n",tmpBytes);
532+
goto mod_exit;
533+
}
516534

517-
if (debugLevel >=3)
518-
fprintf(infoStream," NextLen = %d bytes \n",nextLength);
535+
debugf(3," NextLen = %d bytes \n",nextLength);
519536

520537
if (offset+nextLength > sizeof(dataBuf))
521538
{
@@ -524,6 +541,10 @@ int main( int argc, char *argv[] )
524541
}
525542

526543
bytesRead = fread(&dataBuf[offset], 1, nextLength-4 , fp );
544+
if (bytesRead < (nextLength - 4)) {
545+
debugf(1,"At end of input data - fread (phase 2c) returned %d bytes\n",tmpBytes);
546+
goto mod_exit;
547+
}
527548
offset += bytesRead;
528549
} while (pSMFMQRecord->Header.SMFSEG[0] != 0x02);/* end of record indicator*/
529550

@@ -685,7 +706,7 @@ int main( int argc, char *argv[] )
685706
convDate(pqwhs->qwhsstck,dt);
686707
strcpy(commonF.stckFormatDate,dt[0]);
687708
strcpy(commonF.stckFormatDate,dt[1]);
688-
if (recordType == SMFTYPE_MQ_STAT)
709+
if (recordType == SMFTYPE_MQ_STAT)
689710
{
690711
if (conv16(pqwhs->qwhslen) >= 52)
691712
{
@@ -745,8 +766,8 @@ int main( int argc, char *argv[] )
745766
}
746767
}
747768

748-
if (debugLevel >=3 && pqwhs != NULL)
749-
fprintf(infoStream,"Section count %d for %4.4s, qwhslen=%d\n",sectionCount,commonF.qMgr,conv16(pqwhs->qwhslen));
769+
if (pqwhs != NULL)
770+
debugf(3,"Section count %d for %4.4s, qwhslen=%d\n",sectionCount,commonF.qMgr,conv16(pqwhs->qwhslen));
750771

751772
/*********************************************************************/
752773
/* Once we know how many sections there are, copy the triplet values */
@@ -792,7 +813,7 @@ int main( int argc, char *argv[] )
792813
case SMFTYPE_MQ_STAT:
793814
switch(recordSubType)
794815
{
795-
case SMFSUBTYPE_MQ_STAT_BASIC:
816+
case SMFSUBTYPE_MQ_STAT_BASIC:
796817
/*****************************************************************/
797818
/* Some of the triplets seem to refer to internal/undocumented */
798819
/* structures. Only the QSST and QJST are known elements. */
@@ -935,15 +956,15 @@ int main( int argc, char *argv[] )
935956

936957
case SMFSUBTYPE_MQ_STAT_RESERVED_1:
937958
/* These are internal undocumented structures. There's not much we can do */
938-
/* except ignore them. We will see them show up in the overall subtype */
959+
/* except ignore them. We will see them show up in the overall subtype */
939960
/* stats of records processed, but no other debug. */
940-
if (!warn115_240)
961+
if (!warn115_240)
941962
{
942963
sprintf(tmpHead,"Internal SMF %d subtype %d records found",SMFTYPE_MQ_STAT,recordSubType);
943964
fprintf(infoStream,"%s\n",tmpHead);
944965
warn115_240=TRUE;
945966
}
946-
break;
967+
break;
947968

948969
default:
949970
knownSubType = FALSE;
@@ -1163,22 +1184,20 @@ int main( int argc, char *argv[] )
11631184
/* Cleanup and exit. If we get here normally, then the checkpoint */
11641185
/* file is not needed any more, so it is deleted. */
11651186
/***********************************************************************/
1166-
if (debugLevel >= 1) {
1167-
fprintf(infoStream,"Removing checkpoint file\n");
1168-
}
1187+
debugf(1,"Removing checkpoint file %s\n",checkPointFileName);
11691188
remove(checkPointFileName);
11701189
pos = ftello(fp);
11711190

1191+
mod_exit:
11721192
if (outputFormat == OF_SQL && ddlTemplateClose != NULL) {
11731193
closeFinalDDL();
11741194
}
11751195

1176-
mod_exit:
1177-
11781196
fflush(NULL); /* Ensure all streams flushed if possible */
11791197

11801198
for (i=0;i<MAXCP;i++) {
11811199
if (checkPoint[i].fp) {
1200+
debugf(1," Closing %s\n",checkPoint[i].name);
11821201
fclose(checkPoint[i].fp);
11831202
}
11841203
}
@@ -1188,8 +1207,8 @@ int main( int argc, char *argv[] )
11881207
}
11891208

11901209
formatRate = getFormatRate(pos);
1191-
fprintf(infoStream,"Processed %u records total %s\n",totalRecords,formatRate);
1192-
1210+
endTime = time(NULL);
1211+
fprintf(infoStream,"Processed %u records total %s in %d seconds \n",totalRecords,formatRate,(int)(endTime-startTime));
11931212

11941213
/**********************************************************************/
11951214
/* If the program has been restarted via checkpoint, these counts are */
@@ -1375,9 +1394,7 @@ myoff_t readCheckPoint(FILE *fp) {
13751394
sscanf(line,"%d %lld",&startingRecords,&inputOffset);
13761395
fprintf(infoStream,"Reading from recovery checkpoint.\n");
13771396

1378-
if (debugLevel >=1) {
1379-
fprintf(infoStream,"InputOffset: %lld Processed records: %d\n",inputOffset, startingRecords);
1380-
}
1397+
debugf(1,"InputOffset: %lld Processed records: %d\n",inputOffset, startingRecords);
13811398

13821399
/************************************************************************/
13831400
/* Subsequent lines have two fields naming the output structure and how */
@@ -1392,9 +1409,7 @@ myoff_t readCheckPoint(FILE *fp) {
13921409
sscanf(line,"%s %lld",field,&offset);
13931410
checkPoint[i].name = strdup(field);
13941411
checkPoint[i].offset = offset;
1395-
if (debugLevel >=2) {
1396-
fprintf(infoStream,"Loaded status[%d] for %s as offset %lld\n",i,field,offset);
1397-
}
1412+
debugf(2,"Loaded status[%d] for %s as offset %lld\n",i,field,offset);
13981413
i++;
13991414
}
14001415
} while (c);
@@ -1552,7 +1567,7 @@ int laterThan(int v)
15521567
strncpy(mqVer,commonF.mqVer,4);
15531568
currentVersion = atoi(mqVer);
15541569
}
1555-
if (currentVersion > v)
1570+
if (currentVersion > v)
15561571
return 1;
15571572
return rc;
15581573
}

src/mqsmf.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -258,6 +258,10 @@ extern void calcYMD(int y,int dY,int *m,int *dM);
258258
extern FILE * fopencsv(const char *, BOOL *);
259259
extern FILE * fopenext(const char *, const char *, BOOL *);
260260

261+
#if !defined(debugf)
262+
#define debugf(_level,_fmt,...) \
263+
{if (debugLevel >= _level) fprintf(infoStream,_fmt,__VA_ARGS__);}
264+
#endif
261265
/*
262266
* Convert some MQI values into the corresponding string
263267
*/

src/mqsmfstrucU.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* This file was generated from cqsdsmfc.h version 931
2+
* This file was generated from cqsdsmfc.h version 932
33
* by the convH program (convH64.c) in the src directory
44
* Do not try to edit this header manually.
55
*
@@ -1087,17 +1087,21 @@ used during close of a topic
10871087
uint32_t putddly; /* Number of messages put with
10881088
delivery delay, and hence sent to
10891089
delivery delay staging queue */
1090+
uint32_t z__004[1];
1091+
uint32_t streamedn;
1092+
uint32_t z__005[1];
10901093
} wq;
10911094
#define WQ_HEXID 0xF702
10921095
#define WQ_EYE "WQST"
1093-
#define WQ_VER 8
1096+
#define WQ_VER 9
10941097
#define WQ_VER_1 1
10951098
#define WQ_VER_2 2
10961099
#define WQ_VER_3 3
10971100
#define WQ_VER_4 4
10981101
#define WQ_VER_5 5
10991102
#define WQ_VER_6 6
11001103
#define WQ_VER_8 8
1104+
#define WQ_VER_9 9
11011105
#define WQ_LEN_1 576
11021106
#define WQ_LEN_2 592
11031107
#define WQ_LEN_3 608

0 commit comments

Comments
 (0)