|
53 | 53 | /* */
|
54 | 54 | /**********************************************************************/
|
55 | 55 |
|
| 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 | + |
56 | 66 | #include <stdio.h>
|
57 | 67 | #include <stdlib.h>
|
58 | 68 | #include <string.h>
|
|
61 | 71 | #include <ctype.h>
|
62 | 72 | #include <sys/stat.h>
|
63 | 73 |
|
| 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 | +/**********************************************************************/ |
64 | 79 | #ifdef _WIN32
|
65 | 80 | #include <io.h>
|
66 | 81 | #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; |
67 | 90 | #endif
|
68 | 91 |
|
69 | 92 | #include "mqsmf.h"
|
@@ -124,8 +147,8 @@ int main( int argc, char *argv[] )
|
124 | 147 |
|
125 | 148 | char *inputFile = NULL;
|
126 | 149 | FILE *fp;
|
127 |
| - size_t totalFileSize = 0; |
128 |
| - struct stat statbuf; |
| 150 | + myoff_t totalFileSize = 0; |
| 151 | + mystat_t statbuf; |
129 | 152 | unsigned int totalRecords = 0;
|
130 | 153 | unsigned int maxRecords = 0xFFFFFFFF;
|
131 | 154 | unsigned int unknownCount = 0;
|
@@ -243,6 +266,8 @@ int main( int argc, char *argv[] )
|
243 | 266 |
|
244 | 267 | fstat(fileno(fp),&statbuf);
|
245 | 268 | totalFileSize = statbuf.st_size;
|
| 269 | + if (debugLevel >=3 ) |
| 270 | + printf("Total File Size = %lld\n",totalFileSize); |
246 | 271 |
|
247 | 272 | convInit(); /* Decide whether this is a big or little endian machine*/
|
248 | 273 |
|
@@ -739,8 +764,8 @@ int main( int argc, char *argv[] )
|
739 | 764 |
|
740 | 765 | if (totalRecords % ticker == 0)
|
741 | 766 | {
|
742 |
| - long pos; |
743 |
| - pos = ftell(fp); |
| 767 | + myoff_t pos; |
| 768 | + pos = ftello(fp); |
744 | 769 | printf("Processed %u records [%5.2f%%]\n",totalRecords,(totalFileSize > 0)?((float)(100.0*pos)/totalFileSize):(float)0);
|
745 | 770 | }
|
746 | 771 |
|
@@ -800,7 +825,7 @@ FILE * fopenext(const char * basename, const char *ext, BOOL *newFile)
|
800 | 825 | fp = fopen(filename, mode);
|
801 | 826 | if (fp)
|
802 | 827 | {
|
803 |
| - long pos; |
| 828 | + off_t pos; |
804 | 829 |
|
805 | 830 | fseek(fp,0,SEEK_END);
|
806 | 831 | pos = ftell(fp);
|
|
0 commit comments