fast_excel 0.4.1 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (117) hide show
  1. checksums.yaml +4 -4
  2. data/.github/workflows/test.yml +1 -7
  3. data/CHANGELOG.md +9 -0
  4. data/Gemfile +1 -1
  5. data/examples/example.rb +2 -0
  6. data/examples/example_date_time.rb +38 -0
  7. data/fast_excel.gemspec +2 -2
  8. data/lib/fast_excel/binding/format.rb +17 -0
  9. data/lib/fast_excel/binding/workbook.rb +39 -17
  10. data/lib/fast_excel/binding/worksheet.rb +57 -13
  11. data/lib/fast_excel/binding.rb +7 -7
  12. data/lib/fast_excel.rb +27 -20
  13. data/libxlsxwriter/.github/FUNDING.yml +1 -0
  14. data/libxlsxwriter/.github/ISSUE_TEMPLATE.md +85 -0
  15. data/libxlsxwriter/.github/PULL_REQUEST_TEMPLATE.md +130 -0
  16. data/libxlsxwriter/.github/workflows/cmake_actions.yml +48 -0
  17. data/libxlsxwriter/.github/workflows/code_style.yml +23 -0
  18. data/libxlsxwriter/.github/workflows/coverity.yml +22 -0
  19. data/libxlsxwriter/.github/workflows/make_actions.yml +52 -0
  20. data/libxlsxwriter/.github/workflows/valgrind.yml +23 -0
  21. data/libxlsxwriter/.github/workflows/windows_build.yml +54 -0
  22. data/libxlsxwriter/.github/workflows/zig_build.yml +22 -0
  23. data/libxlsxwriter/.gitignore +16 -1
  24. data/libxlsxwriter/.indent.pro +24 -0
  25. data/libxlsxwriter/CMakeLists.txt +156 -56
  26. data/libxlsxwriter/CONTRIBUTING.md +2 -2
  27. data/libxlsxwriter/Changes.txt +344 -2
  28. data/libxlsxwriter/LICENSE.txt +66 -8
  29. data/libxlsxwriter/Makefile +151 -54
  30. data/libxlsxwriter/Package.swift +42 -0
  31. data/libxlsxwriter/Readme.md +4 -2
  32. data/libxlsxwriter/build.zig +324 -0
  33. data/libxlsxwriter/build.zig.zon +11 -0
  34. data/libxlsxwriter/cmake/FindMINIZIP.cmake +3 -3
  35. data/libxlsxwriter/cocoapods/libxlsxwriter-umbrella.h +6 -0
  36. data/libxlsxwriter/include/xlsxwriter/app.h +2 -1
  37. data/libxlsxwriter/include/xlsxwriter/chart.h +236 -32
  38. data/libxlsxwriter/include/xlsxwriter/chartsheet.h +7 -7
  39. data/libxlsxwriter/include/xlsxwriter/comment.h +76 -0
  40. data/libxlsxwriter/include/xlsxwriter/common.h +111 -50
  41. data/libxlsxwriter/include/xlsxwriter/content_types.h +8 -1
  42. data/libxlsxwriter/include/xlsxwriter/core.h +1 -1
  43. data/libxlsxwriter/include/xlsxwriter/custom.h +1 -1
  44. data/libxlsxwriter/include/xlsxwriter/drawing.h +11 -20
  45. data/libxlsxwriter/include/xlsxwriter/format.h +121 -8
  46. data/libxlsxwriter/include/xlsxwriter/hash_table.h +1 -1
  47. data/libxlsxwriter/include/xlsxwriter/metadata.h +49 -0
  48. data/libxlsxwriter/include/xlsxwriter/packager.h +27 -16
  49. data/libxlsxwriter/include/xlsxwriter/relationships.h +1 -1
  50. data/libxlsxwriter/include/xlsxwriter/shared_strings.h +1 -1
  51. data/libxlsxwriter/include/xlsxwriter/styles.h +13 -7
  52. data/libxlsxwriter/include/xlsxwriter/table.h +51 -0
  53. data/libxlsxwriter/include/xlsxwriter/theme.h +1 -1
  54. data/libxlsxwriter/include/xlsxwriter/third_party/emyg_dtoa.h +26 -0
  55. data/libxlsxwriter/include/xlsxwriter/third_party/ioapi.h +27 -25
  56. data/libxlsxwriter/include/xlsxwriter/third_party/md5.h +45 -0
  57. data/libxlsxwriter/include/xlsxwriter/third_party/zip.h +155 -153
  58. data/libxlsxwriter/include/xlsxwriter/utility.h +70 -8
  59. data/libxlsxwriter/include/xlsxwriter/vml.h +55 -0
  60. data/libxlsxwriter/include/xlsxwriter/workbook.h +218 -47
  61. data/libxlsxwriter/include/xlsxwriter/worksheet.h +2770 -241
  62. data/libxlsxwriter/include/xlsxwriter/xmlwriter.h +12 -8
  63. data/libxlsxwriter/include/xlsxwriter.h +4 -2
  64. data/libxlsxwriter/libxlsxwriter.podspec +8 -5
  65. data/libxlsxwriter/src/Makefile +58 -21
  66. data/libxlsxwriter/src/app.c +5 -2
  67. data/libxlsxwriter/src/chart.c +396 -81
  68. data/libxlsxwriter/src/chartsheet.c +22 -22
  69. data/libxlsxwriter/src/comment.c +443 -0
  70. data/libxlsxwriter/src/content_types.c +40 -1
  71. data/libxlsxwriter/src/core.c +2 -2
  72. data/libxlsxwriter/src/custom.c +1 -1
  73. data/libxlsxwriter/src/drawing.c +160 -40
  74. data/libxlsxwriter/src/format.c +109 -25
  75. data/libxlsxwriter/src/hash_table.c +1 -1
  76. data/libxlsxwriter/src/metadata.c +283 -0
  77. data/libxlsxwriter/src/packager.c +794 -94
  78. data/libxlsxwriter/src/relationships.c +1 -1
  79. data/libxlsxwriter/src/shared_strings.c +2 -4
  80. data/libxlsxwriter/src/styles.c +353 -58
  81. data/libxlsxwriter/src/table.c +304 -0
  82. data/libxlsxwriter/src/theme.c +1 -1
  83. data/libxlsxwriter/src/utility.c +143 -43
  84. data/libxlsxwriter/src/vml.c +1062 -0
  85. data/libxlsxwriter/src/workbook.c +567 -77
  86. data/libxlsxwriter/src/worksheet.c +6668 -1462
  87. data/libxlsxwriter/src/xmlwriter.c +95 -5
  88. data/libxlsxwriter/third_party/dtoa/Makefile +42 -0
  89. data/libxlsxwriter/third_party/dtoa/emyg_dtoa.c +461 -0
  90. data/libxlsxwriter/third_party/dtoa/emyg_dtoa.h +26 -0
  91. data/libxlsxwriter/third_party/md5/Makefile +42 -0
  92. data/libxlsxwriter/third_party/md5/md5.c +291 -0
  93. data/libxlsxwriter/third_party/md5/md5.h +45 -0
  94. data/libxlsxwriter/third_party/minizip/Makefile +3 -8
  95. data/libxlsxwriter/third_party/minizip/Makefile.orig +8 -4
  96. data/libxlsxwriter/third_party/minizip/MiniZip64_Changes.txt +1 -1
  97. data/libxlsxwriter/third_party/minizip/configure.ac +1 -1
  98. data/libxlsxwriter/third_party/minizip/crypt.h +13 -16
  99. data/libxlsxwriter/third_party/minizip/ioapi.c +31 -57
  100. data/libxlsxwriter/third_party/minizip/ioapi.h +31 -23
  101. data/libxlsxwriter/third_party/minizip/iowin32.c +29 -45
  102. data/libxlsxwriter/third_party/minizip/iowin32.h +4 -4
  103. data/libxlsxwriter/third_party/minizip/miniunz.c +29 -56
  104. data/libxlsxwriter/third_party/minizip/minizip.c +38 -49
  105. data/libxlsxwriter/third_party/minizip/mztools.c +1 -7
  106. data/libxlsxwriter/third_party/minizip/unzip.c +202 -342
  107. data/libxlsxwriter/third_party/minizip/unzip.h +74 -74
  108. data/libxlsxwriter/third_party/minizip/zip.c +165 -218
  109. data/libxlsxwriter/third_party/minizip/zip.h +164 -154
  110. data/libxlsxwriter/third_party/tmpfileplus/Makefile +3 -3
  111. data/libxlsxwriter/version.txt +1 -1
  112. data/test/auto_width_test.rb +20 -0
  113. data/test/default_format_test.rb +1 -1
  114. data/test/validations_test.rb +3 -3
  115. data/test/worksheet_test.rb +6 -1
  116. metadata +33 -7
  117. data/libxlsxwriter/.travis.yml +0 -37
@@ -27,7 +27,7 @@
27
27
  #endif
28
28
  #endif
29
29
 
30
- #ifdef __APPLE__
30
+ #if defined(__APPLE__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64)
31
31
  // In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
32
32
  #define FOPEN_FUNC(filename, mode) fopen(filename, mode)
33
33
  #define FTELLO_FUNC(stream) ftello(stream)
@@ -45,6 +45,7 @@
45
45
  #include <time.h>
46
46
  #include <errno.h>
47
47
  #include <fcntl.h>
48
+ #include <sys/stat.h>
48
49
 
49
50
  #ifdef _WIN32
50
51
  # include <direct.h>
@@ -80,11 +81,7 @@
80
81
  filename : the filename of the file where date/time must be modified
81
82
  dosdate : the new date at the MSDos format (4 bytes)
82
83
  tmu_date : the SAME new date at the tm_unz format */
83
- void change_file_date(filename,dosdate,tmu_date)
84
- const char *filename;
85
- uLong dosdate;
86
- tm_unz tmu_date;
87
- {
84
+ static void change_file_date(const char *filename, uLong dosdate, tm_unz tmu_date) {
88
85
  #ifdef _WIN32
89
86
  HANDLE hFile;
90
87
  FILETIME ftm,ftLocal,ftCreate,ftLastAcc,ftLastWrite;
@@ -97,7 +94,8 @@ void change_file_date(filename,dosdate,tmu_date)
97
94
  SetFileTime(hFile,&ftm,&ftLastAcc,&ftm);
98
95
  CloseHandle(hFile);
99
96
  #else
100
- #ifdef unix || __APPLE__
97
+ #if defined(unix) || defined(__APPLE__)
98
+ (void)dosdate;
101
99
  struct utimbuf ut;
102
100
  struct tm newdate;
103
101
  newdate.tm_sec = tmu_date.tm_sec;
@@ -113,6 +111,10 @@ void change_file_date(filename,dosdate,tmu_date)
113
111
 
114
112
  ut.actime=ut.modtime=mktime(&newdate);
115
113
  utime(filename,&ut);
114
+ #else
115
+ (void)filename;
116
+ (void)dosdate;
117
+ (void)tmu_date;
116
118
  #endif
117
119
  #endif
118
120
  }
@@ -121,9 +123,7 @@ void change_file_date(filename,dosdate,tmu_date)
121
123
  /* mymkdir and change_file_date are not 100 % portable
122
124
  As I don't know well Unix, I wait feedback for the unix portion */
123
125
 
124
- int mymkdir(dirname)
125
- const char* dirname;
126
- {
126
+ static int mymkdir(const char* dirname) {
127
127
  int ret=0;
128
128
  #ifdef _WIN32
129
129
  ret = _mkdir(dirname);
@@ -131,18 +131,18 @@ int mymkdir(dirname)
131
131
  ret = mkdir (dirname,0775);
132
132
  #elif __APPLE__
133
133
  ret = mkdir (dirname,0775);
134
+ #else
135
+ (void)dirname;
134
136
  #endif
135
137
  return ret;
136
138
  }
137
139
 
138
- int makedir (newdir)
139
- char *newdir;
140
- {
140
+ static int makedir(const char *newdir) {
141
141
  char *buffer ;
142
142
  char *p;
143
- int len = (int)strlen(newdir);
143
+ size_t len = strlen(newdir);
144
144
 
145
- if (len <= 0)
145
+ if (len == 0)
146
146
  return 0;
147
147
 
148
148
  buffer = (char*)malloc(len+1);
@@ -185,14 +185,12 @@ int makedir (newdir)
185
185
  return 1;
186
186
  }
187
187
 
188
- void do_banner()
189
- {
188
+ static void do_banner(void) {
190
189
  printf("MiniUnz 1.01b, demo of zLib + Unz package written by Gilles Vollant\n");
191
190
  printf("more info at http://www.winimage.com/zLibDll/unzip.html\n\n");
192
191
  }
193
192
 
194
- void do_help()
195
- {
193
+ static void do_help(void) {
196
194
  printf("Usage : miniunz [-e] [-x] [-v] [-l] [-o] [-p password] file.zip [file_to_extr.] [-d extractdir]\n\n" \
197
195
  " -e Extract without pathname (junk paths)\n" \
198
196
  " -x Extract with pathname\n" \
@@ -200,11 +198,10 @@ void do_help()
200
198
  " -l list files\n" \
201
199
  " -d directory to extract into\n" \
202
200
  " -o overwrite files without prompting\n" \
203
- " -p extract crypted file using password\n\n");
201
+ " -p extract encrypted file using password\n\n");
204
202
  }
205
203
 
206
- void Display64BitsSize(ZPOS64_T n, int size_char)
207
- {
204
+ static void Display64BitsSize(ZPOS64_T n, int size_char) {
208
205
  /* to avoid compatibility problem , we do here the conversion */
209
206
  char number[21];
210
207
  int offset=19;
@@ -231,9 +228,7 @@ void Display64BitsSize(ZPOS64_T n, int size_char)
231
228
  printf("%s",&number[pos_string]);
232
229
  }
233
230
 
234
- int do_list(uf)
235
- unzFile uf;
236
- {
231
+ static int do_list(unzFile uf) {
237
232
  uLong i;
238
233
  unz_global_info64 gi;
239
234
  int err;
@@ -248,7 +243,7 @@ int do_list(uf)
248
243
  char filename_inzip[256];
249
244
  unz_file_info64 file_info;
250
245
  uLong ratio=0;
251
- const char *string_method;
246
+ const char *string_method = "";
252
247
  char charCrypt=' ';
253
248
  err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
254
249
  if (err!=UNZ_OK)
@@ -259,7 +254,7 @@ int do_list(uf)
259
254
  if (file_info.uncompressed_size>0)
260
255
  ratio = (uLong)((file_info.compressed_size*100)/file_info.uncompressed_size);
261
256
 
262
- /* display a '*' if the file is crypted */
257
+ /* display a '*' if the file is encrypted */
263
258
  if ((file_info.flag & 1) != 0)
264
259
  charCrypt='*';
265
260
 
@@ -309,12 +304,7 @@ int do_list(uf)
309
304
  }
310
305
 
311
306
 
312
- int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
313
- unzFile uf;
314
- const int* popt_extract_without_path;
315
- int* popt_overwrite;
316
- const char* password;
317
- {
307
+ static int do_extract_currentfile(unzFile uf, const int* popt_extract_without_path, int* popt_overwrite, const char* password) {
318
308
  char filename_inzip[256];
319
309
  char* filename_withoutpath;
320
310
  char* p;
@@ -324,7 +314,6 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
324
314
  uInt size_buf;
325
315
 
326
316
  unz_file_info64 file_info;
327
- uLong ratio=0;
328
317
  err = unzGetCurrentFileInfo64(uf,&file_info,filename_inzip,sizeof(filename_inzip),NULL,0,NULL,0);
329
318
 
330
319
  if (err!=UNZ_OK)
@@ -439,7 +428,7 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
439
428
  break;
440
429
  }
441
430
  if (err>0)
442
- if (fwrite(buf,err,1,fout)!=1)
431
+ if (fwrite(buf,(unsigned)err,1,fout)!=1)
443
432
  {
444
433
  printf("error in writing extracted file\n");
445
434
  err=UNZ_ERRNO;
@@ -472,16 +461,10 @@ int do_extract_currentfile(uf,popt_extract_without_path,popt_overwrite,password)
472
461
  }
473
462
 
474
463
 
475
- int do_extract(uf,opt_extract_without_path,opt_overwrite,password)
476
- unzFile uf;
477
- int opt_extract_without_path;
478
- int opt_overwrite;
479
- const char* password;
480
- {
464
+ static int do_extract(unzFile uf, int opt_extract_without_path, int opt_overwrite, const char* password) {
481
465
  uLong i;
482
466
  unz_global_info64 gi;
483
467
  int err;
484
- FILE* fout=NULL;
485
468
 
486
469
  err = unzGetGlobalInfo64(uf,&gi);
487
470
  if (err!=UNZ_OK)
@@ -508,14 +491,7 @@ int do_extract(uf,opt_extract_without_path,opt_overwrite,password)
508
491
  return 0;
509
492
  }
510
493
 
511
- int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite,password)
512
- unzFile uf;
513
- const char* filename;
514
- int opt_extract_without_path;
515
- int opt_overwrite;
516
- const char* password;
517
- {
518
- int err = UNZ_OK;
494
+ static int do_extract_onefile(unzFile uf, const char* filename, int opt_extract_without_path, int opt_overwrite, const char* password) {
519
495
  if (unzLocateFile(uf,filename,CASESENSITIVITY)!=UNZ_OK)
520
496
  {
521
497
  printf("file %s not found in the zipfile\n",filename);
@@ -531,10 +507,7 @@ int do_extract_onefile(uf,filename,opt_extract_without_path,opt_overwrite,passwo
531
507
  }
532
508
 
533
509
 
534
- int main(argc,argv)
535
- int argc;
536
- char *argv[];
537
- {
510
+ int main(int argc, char *argv[]) {
538
511
  const char *zipfilename=NULL;
539
512
  const char *filename_to_extract=NULL;
540
513
  const char *password=NULL;
@@ -565,7 +538,7 @@ int main(argc,argv)
565
538
 
566
539
  while ((*p)!='\0')
567
540
  {
568
- char c=*(p++);;
541
+ char c=*(p++);
569
542
  if ((c=='l') || (c=='L'))
570
543
  opt_do_list = 1;
571
544
  if ((c=='v') || (c=='V'))
@@ -607,7 +580,7 @@ int main(argc,argv)
607
580
  # endif
608
581
 
609
582
  strncpy(filename_try, zipfilename,MAXFILENAME-1);
610
- /* strncpy doesnt append the trailing NULL, of the string is too long. */
583
+ /* strncpy doesn't append the trailing NULL, of the string is too long. */
611
584
  filename_try[ MAXFILENAME ] = '\0';
612
585
 
613
586
  # ifdef USEWIN32IOAPI
@@ -28,7 +28,7 @@
28
28
  #endif
29
29
  #endif
30
30
 
31
- #ifdef __APPLE__
31
+ #if defined(__APPLE__) || defined(__HAIKU__) || defined(MINIZIP_FOPEN_NO_64)
32
32
  // In darwin and perhaps other BSD variants off_t is a 64 bit value, hence no need for specific 64 bit functions
33
33
  #define FOPEN_FUNC(filename, mode) fopen(filename, mode)
34
34
  #define FTELLO_FUNC(stream) ftello(stream)
@@ -71,11 +71,9 @@
71
71
  #define MAXFILENAME (256)
72
72
 
73
73
  #ifdef _WIN32
74
- uLong filetime(f, tmzip, dt)
75
- char *f; /* name of file to get info on */
76
- tm_zip *tmzip; /* return value: access, modific. and creation times */
77
- uLong *dt; /* dostime */
78
- {
74
+ /* f: name of file to get info on, tmzip: return value: access,
75
+ modification and creation times, dt: dostime */
76
+ static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
79
77
  int ret = 0;
80
78
  {
81
79
  FILETIME ftLocal;
@@ -94,12 +92,11 @@ uLong filetime(f, tmzip, dt)
94
92
  return ret;
95
93
  }
96
94
  #else
97
- #ifdef unix || __APPLE__
98
- uLong filetime(f, tmzip, dt)
99
- char *f; /* name of file to get info on */
100
- tm_zip *tmzip; /* return value: access, modific. and creation times */
101
- uLong *dt; /* dostime */
102
- {
95
+ #if defined(unix) || defined(__APPLE__)
96
+ /* f: name of file to get info on, tmzip: return value: access,
97
+ modification and creation times, dt: dostime */
98
+ static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
99
+ (void)dt;
103
100
  int ret=0;
104
101
  struct stat s; /* results of stat() */
105
102
  struct tm* filedate;
@@ -108,12 +105,12 @@ uLong filetime(f, tmzip, dt)
108
105
  if (strcmp(f,"-")!=0)
109
106
  {
110
107
  char name[MAXFILENAME+1];
111
- int len = strlen(f);
108
+ size_t len = strlen(f);
112
109
  if (len > MAXFILENAME)
113
110
  len = MAXFILENAME;
114
111
 
115
112
  strncpy(name, f,MAXFILENAME-1);
116
- /* strncpy doesnt append the trailing NULL, of the string is too long. */
113
+ /* strncpy doesn't append the trailing NULL, of the string is too long. */
117
114
  name[ MAXFILENAME ] = '\0';
118
115
 
119
116
  if (name[len - 1] == '/')
@@ -137,11 +134,12 @@ uLong filetime(f, tmzip, dt)
137
134
  return ret;
138
135
  }
139
136
  #else
140
- uLong filetime(f, tmzip, dt)
141
- char *f; /* name of file to get info on */
142
- tm_zip *tmzip; /* return value: access, modific. and creation times */
143
- uLong *dt; /* dostime */
144
- {
137
+ /* f: name of file to get info on, tmzip: return value: access,
138
+ modification and creation times, dt: dostime */
139
+ static int filetime(const char *f, tm_zip *tmzip, uLong *dt) {
140
+ (void)f;
141
+ (void)tmzip;
142
+ (void)dt;
145
143
  return 0;
146
144
  }
147
145
  #endif
@@ -150,9 +148,7 @@ uLong filetime(f, tmzip, dt)
150
148
 
151
149
 
152
150
 
153
- int check_exist_file(filename)
154
- const char* filename;
155
- {
151
+ static int check_exist_file(const char* filename) {
156
152
  FILE* ftestexist;
157
153
  int ret = 1;
158
154
  ftestexist = FOPEN_FUNC(filename,"rb");
@@ -163,14 +159,12 @@ int check_exist_file(filename)
163
159
  return ret;
164
160
  }
165
161
 
166
- void do_banner()
167
- {
162
+ static void do_banner(void) {
168
163
  printf("MiniZip 1.1, demo of zLib + MiniZip64 package, written by Gilles Vollant\n");
169
164
  printf("more info on MiniZip at http://www.winimage.com/zLibDll/minizip.html\n\n");
170
165
  }
171
166
 
172
- void do_help()
173
- {
167
+ static void do_help(void) {
174
168
  printf("Usage : minizip [-o] [-a] [-0 to -9] [-p password] [-j] file.zip [files_to_add]\n\n" \
175
169
  " -o Overwrite existing file.zip\n" \
176
170
  " -a Append to existing file.zip\n" \
@@ -182,14 +176,13 @@ void do_help()
182
176
 
183
177
  /* calculate the CRC32 of a file,
184
178
  because to encrypt a file, we need known the CRC32 of the file before */
185
- int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigned long* result_crc)
186
- {
179
+ static int getFileCrc(const char* filenameinzip, void* buf, unsigned long size_buf, unsigned long* result_crc) {
187
180
  unsigned long calculate_crc=0;
188
181
  int err=ZIP_OK;
189
182
  FILE * fin = FOPEN_FUNC(filenameinzip,"rb");
190
183
 
191
184
  unsigned long size_read = 0;
192
- unsigned long total_read = 0;
185
+ /* unsigned long total_read = 0; */
193
186
  if (fin==NULL)
194
187
  {
195
188
  err = ZIP_ERRNO;
@@ -199,7 +192,7 @@ int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigne
199
192
  do
200
193
  {
201
194
  err = ZIP_OK;
202
- size_read = (int)fread(buf,1,size_buf,fin);
195
+ size_read = fread(buf,1,size_buf,fin);
203
196
  if (size_read < size_buf)
204
197
  if (feof(fin)==0)
205
198
  {
@@ -208,8 +201,8 @@ int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigne
208
201
  }
209
202
 
210
203
  if (size_read>0)
211
- calculate_crc = crc32(calculate_crc,buf,size_read);
212
- total_read += size_read;
204
+ calculate_crc = crc32_z(calculate_crc,buf,size_read);
205
+ /* total_read += size_read; */
213
206
 
214
207
  } while ((err == ZIP_OK) && (size_read>0));
215
208
 
@@ -221,18 +214,17 @@ int getFileCrc(const char* filenameinzip,void*buf,unsigned long size_buf,unsigne
221
214
  return err;
222
215
  }
223
216
 
224
- int isLargeFile(const char* filename)
225
- {
217
+ static int isLargeFile(const char* filename) {
226
218
  int largeFile = 0;
227
219
  ZPOS64_T pos = 0;
228
220
  FILE* pFile = FOPEN_FUNC(filename, "rb");
229
221
 
230
222
  if(pFile != NULL)
231
223
  {
232
- int n = FSEEKO_FUNC(pFile, 0, SEEK_END);
233
- pos = FTELLO_FUNC(pFile);
224
+ FSEEKO_FUNC(pFile, 0, SEEK_END);
225
+ pos = (ZPOS64_T)FTELLO_FUNC(pFile);
234
226
 
235
- printf("File : %s is %lld bytes\n", filename, pos);
227
+ printf("File : %s is %llu bytes\n", filename, pos);
236
228
 
237
229
  if(pos >= 0xffffffff)
238
230
  largeFile = 1;
@@ -243,10 +235,7 @@ int isLargeFile(const char* filename)
243
235
  return largeFile;
244
236
  }
245
237
 
246
- int main(argc,argv)
247
- int argc;
248
- char *argv[];
249
- {
238
+ int main(int argc, char *argv[]) {
250
239
  int i;
251
240
  int opt_overwrite=0;
252
241
  int opt_compress_level=Z_DEFAULT_COMPRESSION;
@@ -255,7 +244,7 @@ int main(argc,argv)
255
244
  char filename_try[MAXFILENAME+16];
256
245
  int zipok;
257
246
  int err=0;
258
- int size_buf=0;
247
+ size_t size_buf=0;
259
248
  void* buf=NULL;
260
249
  const char* password=NULL;
261
250
 
@@ -276,7 +265,7 @@ int main(argc,argv)
276
265
 
277
266
  while ((*p)!='\0')
278
267
  {
279
- char c=*(p++);;
268
+ char c=*(p++);
280
269
  if ((c=='o') || (c=='O'))
281
270
  opt_overwrite = 1;
282
271
  if ((c=='a') || (c=='A'))
@@ -322,7 +311,7 @@ int main(argc,argv)
322
311
 
323
312
  zipok = 1 ;
324
313
  strncpy(filename_try, argv[zipfilenamearg],MAXFILENAME-1);
325
- /* strncpy doesnt append the trailing NULL, of the string is too long. */
314
+ /* strncpy doesn't append the trailing NULL, of the string is too long. */
326
315
  filename_try[ MAXFILENAME ] = '\0';
327
316
 
328
317
  len=(int)strlen(filename_try);
@@ -392,11 +381,11 @@ int main(argc,argv)
392
381
  ((argv[i][1]=='o') || (argv[i][1]=='O') ||
393
382
  (argv[i][1]=='a') || (argv[i][1]=='A') ||
394
383
  (argv[i][1]=='p') || (argv[i][1]=='P') ||
395
- ((argv[i][1]>='0') || (argv[i][1]<='9'))) &&
384
+ ((argv[i][1]>='0') && (argv[i][1]<='9'))) &&
396
385
  (strlen(argv[i]) == 2)))
397
386
  {
398
- FILE * fin;
399
- int size_read;
387
+ FILE * fin = NULL;
388
+ size_t size_read;
400
389
  const char* filenameinzip = argv[i];
401
390
  const char *savefilenameinzip;
402
391
  zip_fileinfo zi;
@@ -472,7 +461,7 @@ int main(argc,argv)
472
461
  do
473
462
  {
474
463
  err = ZIP_OK;
475
- size_read = (int)fread(buf,1,size_buf,fin);
464
+ size_read = fread(buf,1,size_buf,fin);
476
465
  if (size_read < size_buf)
477
466
  if (feof(fin)==0)
478
467
  {
@@ -482,7 +471,7 @@ int main(argc,argv)
482
471
 
483
472
  if (size_read>0)
484
473
  {
485
- err = zipWriteInFileInZip (zf,buf,size_read);
474
+ err = zipWriteInFileInZip (zf,buf,(unsigned)size_read);
486
475
  if (err<0)
487
476
  {
488
477
  printf("error in writing %s in the zipfile\n",
@@ -27,13 +27,7 @@
27
27
  WRITE_16((unsigned char*)(buff) + 2, (n) >> 16); \
28
28
  } while(0)
29
29
 
30
- extern int ZEXPORT unzRepair(file, fileOut, fileOutTmp, nRecovered, bytesRecovered)
31
- const char* file;
32
- const char* fileOut;
33
- const char* fileOutTmp;
34
- uLong* nRecovered;
35
- uLong* bytesRecovered;
36
- {
30
+ extern int ZEXPORT unzRepair(const char* file, const char* fileOut, const char* fileOutTmp, uLong* nRecovered, uLong* bytesRecovered) {
37
31
  int err = Z_OK;
38
32
  FILE* fpZip = fopen(file, "rb");
39
33
  FILE* fpOut = fopen(fileOut, "wb");