@@ -105,6 +105,7 @@ void takeCheckPoint(char *,myoff_t);
105105myoff_t readCheckPoint (FILE * );
106106static char * getFormatRate (myoff_t pos );
107107static char * getFormatPercent (myoff_t totalFileSize ,myoff_t pos );
108+ static BOOL inconsistentVersions (char * v1 ,char * v2 ,int l );
108109
109110#define DEFAULT_TICKER 10000 /* Print out status every N records */
110111
@@ -185,6 +186,7 @@ int main( int argc, char *argv[] )
185186 unsigned int d [3 ]; /* used in date conversion */
186187 unsigned int ddd ,year ; /* day number and year number */
187188 unsigned int smfTime ; /* Copied from the SMF header */
189+ char savedMqVer [3 ] = {0 };
188190
189191 char * inputFile = NULL ;
190192 FILE * fp ;
@@ -208,6 +210,7 @@ int main( int argc, char *argv[] )
208210
209211 BOOL error = FALSE;
210212 BOOL knownSubType = TRUE;
213+ BOOL formatWarning = FALSE;
211214 int c ;
212215
213216 int sectionCount ;
@@ -229,7 +232,7 @@ int main( int argc, char *argv[] )
229232 fprintf (stderr ,"Data type sizes do not match requirements.\n" );
230233 fprintf (stderr ,"Need to rebuild program with correct options.\n" );
231234 fprintf (stderr ,"Here: short=%d int=%d long=%d long long=%d bytes\n" ,
232- sizeof (short ), sizeof (int ), sizeof (long ), sizeof (long long ));
235+ ( int ) sizeof (short ), ( int ) sizeof (int ), ( int ) sizeof (long ), ( int ) sizeof (long long ));
233236 fprintf (stderr ,"Need: short=%d int=%d long=%d long long=%d bytes\n" ,2 ,4 ,4 ,8 );
234237 exit (1 );
235238 }
@@ -267,9 +270,11 @@ int main( int argc, char *argv[] )
267270 useRDW = TRUE;
268271 if (strstr (mqoptarg ,"JSON" ))
269272 outputFormat = OF_JSON ;
270- else if (strstr (mqoptarg ,"SQL" ))
273+ else if (strstr (mqoptarg ,"SQL" )) {
271274 outputFormat = OF_SQL ;
272- else if (strstr (mqoptarg ,"CSV" ))
275+ printHeaders = FALSE;
276+ addEquals = 0 ;
277+ } else if (strstr (mqoptarg ,"CSV" ))
273278 outputFormat = OF_CSV ;
274279 break ;
275280 case 'h' :
@@ -530,6 +535,7 @@ int main( int argc, char *argv[] )
530535 memcpy (commonF .systemId ,convStr (pSMFRecord -> Header .SMFRECSID ,4 ),4 );
531536 memcpy (commonF .mqVer ,convStr (pSMFRecord -> Header .SMFRECREL ,3 ),3 );
532537
538+
533539 /*********************************************************************/
534540 /* The SMF header contains a date formatted as 0x0cyydddF The "ddd" */
535541 /* is the day-of-the-year (1-365). Extract the digits and convert */
@@ -601,6 +607,13 @@ int main( int argc, char *argv[] )
601607
602608 if (recordType == 116 || recordType == 115 )
603609 {
610+ if (savedMqVer [0 ] == 0 )
611+ memcpy (savedMqVer ,commonF .mqVer ,3 );
612+
613+ if (inconsistentVersions (commonF .mqVer ,savedMqVer ,3 )) {
614+ fprintf (stderr ,"Warning: Data contains records from multiple versions of MQ - %3.3s and %3.3s\n" ,commonF .mqVer ,savedMqVer );
615+ }
616+
604617 /*******************************************************************/
605618 /* The first triplet past the standard header usually points at a */
606619 /* QWHS structure. */
@@ -959,7 +972,7 @@ int main( int argc, char *argv[] )
959972
960973 default :
961974 knownSubType = FALSE;
962- sprintf (tmpHead , "Unknown subtype %d for 116 records" );
975+ sprintf (tmpHead , "Unknown subtype %d for 116 records" , recordSubType );
963976 printDEBUG (tmpHead , dataBuf ,offset );
964977 fprintf (infoStream ,"%s\n" ,tmpHead );
965978 break ;
@@ -978,6 +991,10 @@ int main( int argc, char *argv[] )
978991 sprintf (tmpHead ,"Unknown SMF record type %d at record %u" ,recordType ,totalRecords );
979992 printDEBUG (tmpHead , dataBuf ,offset );
980993 fprintf (infoStream ,"%s\n" ,tmpHead );
994+ if (offset > 32768 && !formatWarning ) {
995+ fprintf (infoStream ,"WARNING: Possible incorrect input format. Check use of RDW/NORDW flag.\n" );
996+ formatWarning = TRUE;
997+ }
981998 }
982999
9831000 if (totalRecords % ticker == 0 && totalRecords > startingRecords )
@@ -1365,3 +1382,23 @@ static char *getFormatPercent(myoff_t totalFileSize,myoff_t pos)
13651382 }
13661383 return formatPercentString ;
13671384}
1385+
1386+ /*****************************************************************/
1387+ /* FUNCTION: inconsistentVersions */
1388+ /* PURPOSE: */
1389+ /* There may be times where the MQ versions in the data would */
1390+ /* cause problems with missing header or columns (eg fields */
1391+ /* put into a later version, when we have already printed the */
1392+ /* headers for an older version). So this test will be able */
1393+ /* to look for that. */
1394+ /* */
1395+ /* But for now, always return FALSE. */
1396+ /*****************************************************************/
1397+ static BOOL inconsistentVersions (char * v1 ,char * v2 ,int l )
1398+ {
1399+ BOOL rc = FALSE;
1400+ if (memcmp (v1 ,v2 ,l ) != 0 ) /* Maybe need to do more about specific version comparisons */
1401+ rc = TRUE;
1402+ return FALSE;
1403+ }
1404+
0 commit comments