Skip to content

Commit c57b88c

Browse files
committed
Support large input files >2GB
1 parent 963bdb4 commit c57b88c

File tree

10 files changed

+34
-5
lines changed

10 files changed

+34
-5
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,9 @@ August 2016
5353
* Add correlator field to better link WQ/WTID/WTAS
5454
* Add user-written content in docs directory. How to use SQL.
5555

56+
October 2016
57+
* Support reading from large (>2GB) files
58+
5659

5760
Pull requests
5861
=============

bin/aix/convH

8 Bytes
Binary file not shown.

bin/aix/mqsmfcsv

540 Bytes
Binary file not shown.

bin/linux/convH

8 Bytes
Binary file not shown.

bin/linux/mqsmfcsv

4.06 KB
Binary file not shown.

bin/win/convH.exe

-512 Bytes
Binary file not shown.

bin/win/mqsmfcsv.exe

73.4 KB
Binary file not shown.

mqsmfcsv.doc

0 Bytes
Binary file not shown.

src/mqsmf.c

Lines changed: 30 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,16 @@
5353
/* */
5454
/**********************************************************************/
5555

56+
/**********************************************************************/
57+
/* Define flags so that this 32-bit program can access 64-bit files */
58+
/* These flags need to be set up before including any other headers */
59+
/**********************************************************************/
60+
#ifndef _WIN32
61+
#define __USE_LARGEFILE64 /* for Linux */
62+
#define _FILE_OFFSET_BITS 64 /* for Linux */
63+
#define _LARGE_FILES /* for AIX */
64+
#endif
65+
5666
#include <stdio.h>
5767
#include <stdlib.h>
5868
#include <string.h>
@@ -61,9 +71,22 @@
6171
#include <ctype.h>
6272
#include <sys/stat.h>
6373

74+
/**********************************************************************/
75+
/* Different ways of getting to 64-bit file offsets, and different */
76+
/* datatypes. Now the system headers have been loaded, define the */
77+
/* real functions and datatypes for the large values. */
78+
/**********************************************************************/
6479
#ifdef _WIN32
6580
#include <io.h>
6681
#include <fcntl.h>
82+
83+
#define fstat _fstat64
84+
#define ftello _ftelli64
85+
typedef signed long long myoff_t;
86+
typedef struct __stat64 mystat_t;
87+
#else
88+
typedef off_t myoff_t;
89+
typedef struct stat mystat_t;
6790
#endif
6891

6992
#include "mqsmf.h"
@@ -124,8 +147,8 @@ int main( int argc, char *argv[] )
124147

125148
char *inputFile = NULL;
126149
FILE *fp;
127-
size_t totalFileSize = 0;
128-
struct stat statbuf;
150+
myoff_t totalFileSize = 0;
151+
mystat_t statbuf;
129152
unsigned int totalRecords = 0;
130153
unsigned int maxRecords = 0xFFFFFFFF;
131154
unsigned int unknownCount = 0;
@@ -243,6 +266,8 @@ int main( int argc, char *argv[] )
243266

244267
fstat(fileno(fp),&statbuf);
245268
totalFileSize = statbuf.st_size;
269+
if (debugLevel >=3 )
270+
printf("Total File Size = %lld\n",totalFileSize);
246271

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

@@ -739,8 +764,8 @@ int main( int argc, char *argv[] )
739764

740765
if (totalRecords % ticker == 0)
741766
{
742-
long pos;
743-
pos = ftell(fp);
767+
myoff_t pos;
768+
pos = ftello(fp);
744769
printf("Processed %u records [%5.2f%%]\n",totalRecords,(totalFileSize > 0)?((float)(100.0*pos)/totalFileSize):(float)0);
745770
}
746771

@@ -800,7 +825,7 @@ FILE * fopenext(const char * basename, const char *ext, BOOL *newFile)
800825
fp = fopen(filename, mode);
801826
if (fp)
802827
{
803-
long pos;
828+
off_t pos;
804829

805830
fseek(fp,0,SEEK_END);
806831
pos = ftell(fp);

src/smfConv.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,6 +310,7 @@ char *strMQQT (int v)
310310
case 3: c = "Alias"; break;
311311
case 6: c = "Remote"; break;
312312
case 7: c = "Cluster"; break;
313+
case 8: c = "Topic"; break; /* not really a qtype but unique MQOT value */
313314
case 1001: c = "All"; break;
314315
default: c = ""; break;
315316
}

0 commit comments

Comments
 (0)