Parolin 0.7.9 6796
Console (soon DLLs) to do a tar like job
Loading...
Searching...
No Matches
dll.c
Go to the documentation of this file.
1/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
2
3 #2023 X March 21 19:50 PM Brasília Time
4
5* *
6* Licensa de Copia (C) <2024> <Aurora Boreal> *
7* *
8* Este programa e software livre: voce pode redistribuir isto e/ou *
9* modificar isto sobre os termos do GNU Licensa Geral Pública como 25
10* publicado pela Fundacao de Software Livre, tanto a versão 3 da *
11* Licensa, ou (dependendo da sua opcao) qualquer versao posterior. *
12* *
13* Este programa e distribuido na esperanca que isto vai ser util, *
14* mas SEM QUALQUER GARANTIA; sem ate mesmo a implicada garantia de *
15* COMERCIALIZAcaO ou CABIMENTO PARA UM FIM PARTICULAR. Veja a *
16* Licensa Geral Publica para mais detalhes. *
17* *
18* Você deve ter recebido uma cópia da LICENSA GERAL PUBLICA e a GNU *
19* Licensa Publica Menor junto com este programa *
20* Se não, veja <http://www.gnu.org/licenses/>. *
21* *
22* Suporte: sourceforge.net github.com *
23* *
24* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * *
25
26* Pereira: arsoftware25@gmail.com ricardo@arsoftware.net.br *
27* xcx: arsoftware10@gmail.com charli@arsoftware.net.br *
28 Yasmin: yasmin@arsoftware.net.br *
29 pereira1001@users.sourceforge.net
30 */
31
32// definicao de uint e uchar, but why?...
33#ifndef uchar
34#define uchar unsigned char
35#endif
36
37#ifndef uint
38#define uint unsigned int
39#endif
40
41#ifndef ushort
42#define ushort unsigned short
43#endif
44
45#include <windows.h>
46#include <stdint.h>
47#include <stdio.h>
48#include <stdlib.h>
49#include <string.h>
50#include <time.h>
51#include <errno.h>
52#include <fcntl.h>
53#include <ctype.h>
54#include <math.h>
55#include <wctype.h>
56#include <wchar.h>
57#include <stdarg.h>
58#include <stddef.h>
59#include <setjmp.h>
60#include <locale.h>
61#include <signal.h>
62#include <limits.h>
63#include <float.h>
64#include <iso646.h>
65
66#undef NDEBUG
67#include <assert.h>
68
70#ifdef WIN64
71#define MYCAST __int64
72#else
73#define MYCAST int
74#endif
75
76#ifndef __GNUC__
77#define __attribute__(unused) /* Chloe */
78#endif
79
92 int amanda_level,
93 char *format, ...);
94
95WCHAR *amanda_asciitowide_1_v27(char *pUTF8);
96
97void pedro_dprintf(
98 int amanda_level,
99 char *format, ...);
100
104#define AMANDA__SIZE ((32767 * 6) + 2)
109#define AMANDA__SIZE_w (32767)
110
111extern int unicodemode;
112
114
116
118
119int isgzip2 = 0;
120
121extern int zlibpercent;
122
123__int64 lffilesize_dl(const char *szFileName);
124
125uint __stdcall rspcompress(char *inputfile, char *outfile);
126int zcompress_sha512_k(char *input, char *output, int levelin);
127uint __stdcall rspuncompress(uchar *outfile, uchar *outfile2);
128
129int zuncompress(char *input, char *output);
130int zcompress(char *input, char *output, int level);
131
132int utf8towide(const char *pUTF8, WCHAR *pUSC2, int nUSC2);
133
134/*
135static float inittimer(uint comando)
136{
137
138 static uint clock1;
139 static uint clock2;
140
141 if (comando == 0)
142 {
143 clock1 = clock();
144 return 0;
145 }
146 else
147 {
148
149 clock2 = clock();
150
151 return ((float)clock2 - (float)clock1) / 1000;
152 }
153};
154*/
155typedef void *myfile;
156
157int gzclose(myfile file);
158
159myfile gzopen(char *path_now_as_utf8, char *mode);
160
161myfile gzopen_w(WCHAR *path_now_as_utf8, char *mode);
162
163int gzread(myfile file, char *buf, uint len);
164
165char *gzerror(myfile file, int *errnum);
166
167int gzwrite(myfile file, const char *buf, uint len);
168
170
171void dprintf(char *format, ...);
172
173uint __stdcall rspvalidatefile(uchar *outfile2);
174
175int __stdcall startapi_xcx_gz(int parameter);
176
180
184
188
189uint getval(int max, uint por)
190{
191
192 double maxa;
193 double porr;
194
195 maxa = (double)max;
196 porr = (double)por;
197
198 maxa = (maxa / 100) * porr;
199
200 return (uint)maxa;
201}
202
203/*
204
205 a formula aqui é (100/max * fatia)
206 aqui é para saber a porcentagem referente ao valor passado em relacao ao maximo
207
208 max = 10000
209 fatia = 5000
210 result = 50
211 */
212static uint getpor(int max, uint fatia)
213{
214
215 double maxa;
216 double fatiaa;
217
218 maxa = (double)max;
219 fatiaa = (double)fatia;
220
221 if (max == 0)
222 {
223 return 0;
224 }
225
226 maxa = ((double)100 / maxa * fatiaa);
227
228 return (uint)maxa;
229}
230
231/*
232 a formula aqui é (fatia/porcentagem) * 100
233 o resultado é sempre uma porcentagem
234
235 por = 70
236 fatia = 10000
237 result = 142
238
239 basicamente é para saber o maximo a partir da fatia e da porcentagem
240 sera pouco utilizada esta funcao
241 */
242uint getmax(int por, uint fatia)
243{
244
245 float a;
246 float b;
247
248 a = (float)por;
249 b = (float)fatia;
250
251 if (por == 0)
252 {
253 return 0;
254 }
255
256 a = (b / a) * (float)100;
257
258 return (uint)a;
259}
260/*
261BOOL WINAPI DllMain(__attribute__((unused)) HINSTANCE hModule,
262 __attribute__((unused)) DWORD ul_reason_for_call,
263 __attribute__((unused)) LPVOID lpReserved)
264{
265 switch (ul_reason_for_call)
266 {
267 case DLL_PROCESS_ATTACH:
268 OutputDebugString("BW Gzip DLL DLL_PROCESS_ATTACH (" __TIME__ " " __DATE__ ") \n");
269
270#ifdef NPRINTF
271 MessageBox(0, "Bhond debugging code", "BW", MB_OK | MB_TOPMOST);
272#endif
273 break;
274 case DLL_THREAD_ATTACH:
275
276 break;
277 case DLL_THREAD_DETACH:
278
279 break;
280 case DLL_PROCESS_DETACH:
281
282 break;
283 }
284 return TRUE;
285}
286*/
287uint __stdcall rspcompress(char *inputfile, char *outfile)
288{
289
290 // pedro_dprintf2(1001, "-entrada.");
291 int returnvalue = 0;
292
293 int ret;
294
295 int ret3 = 0;
296
297 uchar buf[4097];
298
299 FILE *input;
301
302 pauseflag = 0;
303 cancelflag = 0;
304
305 // pedro_dprintf(0, "-entrada.1 %s", inputfile);
306
307 filesize = lffilesize_dl(inputfile);
308
309 // pedro_dprintf(0, "-entrada.2");
310
311#ifdef NPRINTF
312 dprintf("certeira \n");
313 dprintf("Compression level %d\n", compressionlevel);
314#endif
315
316 // pedro_dprintf(0, "level amor... %d\n", compressionlevel);
317
318 switch (compressionlevel)
319 {
320
321 case 0:
322 output = gzopen_w(utf8_2_wide_dl(outfile), "wb0h");
323 break;
324
325 case 1:
326 output = gzopen_w(utf8_2_wide_dl(outfile), "wb1h");
327 break;
328 case 2:
329 output = gzopen_w(utf8_2_wide_dl(outfile), "wb2h");
330 break;
331 case 3:
332 output = gzopen_w(utf8_2_wide_dl(outfile), "wb3h");
333 break;
334 case 4:
335 output = gzopen_w(utf8_2_wide_dl(outfile), "wb4h");
336 break;
337 case 5:
338 output = gzopen_w(utf8_2_wide_dl(outfile), "wb5h");
339 break;
340 case 6:
341 output = gzopen_w(utf8_2_wide_dl(outfile), "wb6f");
342 break;
343 case 7:
344 output = gzopen_w(utf8_2_wide_dl(outfile), "wb7f");
345 break;
346 case 8:
347 output = gzopen_w(utf8_2_wide_dl(outfile), "wb8f");
348 break;
349 case 9:
350#ifdef NPRINTF
351 dprintf("Usou modo 9 \n");
352#endif
353 output = gzopen_w(utf8_2_wide_dl(outfile), "wb9f");
354 break;
355 default:
356 output = gzopen_w(utf8_2_wide_dl(outfile), "wb6f");
357 break;
358 }
359
360 if (output == NULL)
361 {
362
363 finished = 1;
364
365 return 8;
366 }
367 else
368 {
369 ;
370 }
371
372 input = _wfopen(utf8_2_wide_dl(inputfile), L"rb");
373
374 if (input == NULL)
375 {
376 finished = 1;
378 return 7;
379 }
380 else
381 {
382 ;
383 }
384
385 fileread = 0;
386
387#ifdef NPRINTF
388 dprintf("verificando \n");
389#endif
390
391 while (1)
392 {
393
394 while (pauseflag)
395 {
396
397 Sleep(50);
398
399 if (cancelflag)
400 {
401 returnvalue = 19;
402 goto saida;
403 }
404 }
405
406 if (cancelflag)
407 {
408 returnvalue = 19;
409 goto saida;
410 }
411
412 ret = fread(buf, 1, 4096, input);
413
414 if (ret <= 0)
415 {
416 break;
417 }
418
420
421 gzwrite(output, (void *)buf, ret);
422
423 // string = gzerror (output, &ret3);
424
425 if (ret3)
426 {
427 returnvalue = 14; // never will occur
428 }
429 }
430
431saida:
432
433 fclose(input);
434
436
437 finished = 1;
438
439 return returnvalue;
440}
441
442uint __stdcall rspuncompress(uchar *outfile, uchar *outfile2)
443{
444
445 int ret;
446
447 int returnvalue = 0;
448 int ret3 = 0;
449
450 uchar buf[4097];
451
452 FILE *input;
454
455 pauseflag = 0;
456 cancelflag = 0;
457
458 filesize = lffilesize_dl((void *)outfile);
459
460 output = gzopen_w(utf8_2_wide_dl((void *)outfile), "rb");
461
462 if (output == NULL)
463 {
464 finished = 1;
465 return 10;
466 }
467 else
468 {
469 ;
470 }
471
472 input = _wfopen(utf8_2_wide_dl((void *)outfile2), L"wb");
473
474 if (input == NULL)
475 {
476 finished = 1;
477
479 return 11;
480 }
481 else
482 {
483 ;
484 }
485
486 fileread = 0;
487
488 while (1)
489 {
490
491 while (pauseflag)
492 {
493
494 Sleep(50);
495
496 if (cancelflag)
497 {
498 returnvalue = 19;
499 goto saida;
500 }
501 }
502
503 if (cancelflag)
504 {
505 returnvalue = 19;
506 goto saida;
507 }
508
509 ret = gzread(output, (void *)buf, 4096);
510
511 gzerror(output, &ret3);
512
513#ifdef NPRINTF
514 dprintf("%d .%s. \n", ret3, string);
515#endif
516
517 if ((ret3 != 0) && (ret3 != 1))
518 {
519 returnvalue = 15;
520 }
521
522 if (ret <= 0)
523 {
524 break;
525 }
526
528
529 fwrite(buf, 1, ret, input);
530 }
531
532saida:
533
534 fclose(input);
535
537
538 finished = 1;
539 return returnvalue;
540}
541
543{
544
545 uint ret;
546
547 if (isgzip2)
548 {
550 }
551 else
552 {
553 if (filesize == 0)
554 {
555
556 return 0;
557 }
558
560 }
561
562 if (ret > 100)
563 {
564 ret = 100;
565 }
566
567 /*
568 if ((int)ret < 0)
569 {
570 ret = 0;
571 }
572 */
573
574 return ret;
575}
576
577uint __stdcall tcompress(char *inputfile, char *outfile)
578{
579
580 HANDLE myhandle;
581 MYCAST ThreadId;
582 MYCAST parameter = 1;
583
584 comando = 0;
585 intret = 0;
586 strcpy((void *)intoutfile, outfile);
587
588 strcpy((void *)intinputfile, inputfile);
589
590 myhandle = CreateThread((LPSECURITY_ATTRIBUTES)0, (SIZE_T)0, (void *)startapi_xcx_gz, (LPVOID)parameter, (DWORD)0, (LPDWORD)&ThreadId);
591
592 CloseHandle(myhandle);
593
594 return 0;
595}
596
597uint __stdcall tuncompress(uchar *outfile, uchar *outfile2)
598{
599
600 HANDLE myhandle;
601 MYCAST ThreadId;
602 MYCAST parameter = 1;
603 comando = 1;
604
605 intret = 0;
606
607 strcpy((void *)intoutfile, (void *)outfile2);
608
609 strcpy((void *)intinputfile, (void *)outfile);
610
611 myhandle = CreateThread((LPSECURITY_ATTRIBUTES)0, 0, (void *)startapi_xcx_gz, (LPVOID)parameter, (DWORD)0, (LPDWORD)&ThreadId);
612
613 CloseHandle(myhandle);
614
615 return 0;
616}
617
618uint __stdcall tcompressgzip2(char *inputfile, char *outfile)
619{
620 HANDLE myhandle;
621 MYCAST ThreadId;
622 MYCAST parameter = 1;
623 comando = 2;
624 intret = 0;
625 strcpy((void *)intoutfile, (void *)outfile);
626 strcpy((void *)intinputfile, (void *)inputfile);
627 myhandle = CreateThread((LPSECURITY_ATTRIBUTES)0, 0, (void *)startapi_xcx_gz, (LPVOID)parameter, (DWORD)0, (LPDWORD)&ThreadId);
628 CloseHandle(myhandle);
629 return 0;
630}
631
632uint __stdcall tcompressgzip2_sha512_k(char *inputfile, char *outfile)
633{
634 HANDLE myhandle;
635 MYCAST ThreadId;
636 MYCAST parameter = 1;
637 comando = 10002;
638 intret = 0;
639 strcpy((void *)intoutfile, (void *)outfile);
640 strcpy((void *)intinputfile, (void *)inputfile);
641 myhandle = CreateThread((LPSECURITY_ATTRIBUTES)0, 0, (void *)startapi_xcx_gz, (LPVOID)parameter, (DWORD)0, (LPDWORD)&ThreadId);
642 CloseHandle(myhandle);
643 return 0;
644}
645
646uint __stdcall tuncompressgzip2(uchar *outfile, uchar *outfile2)
647{
648
649 HANDLE myhandle;
650 MYCAST ThreadId;
651 MYCAST parameter = 1;
652 comando = 3;
653 intret = 0;
654 strcpy((void *)intoutfile, (void *)outfile2);
655 strcpy((void *)intinputfile, (void *)outfile);
656 myhandle = CreateThread((LPSECURITY_ATTRIBUTES)0, 0, (void *)startapi_xcx_gz, (LPVOID)parameter, (DWORD)0, (LPDWORD)&ThreadId);
657 CloseHandle(myhandle);
658 return 0;
659}
660
661uint __stdcall tcompressgzip2_utf8_k(char *inputfile, char *outfile)
662{
663 HANDLE myhandle;
664 MYCAST ThreadId;
665 MYCAST parameter = 1;
666 comando = 10000;
667 intret = 0;
668 strcpy((void *)intoutfile, (void *)outfile);
669 strcpy((void *)intinputfile, (void *)inputfile);
670 myhandle = CreateThread((LPSECURITY_ATTRIBUTES)0, 0, (void *)startapi_xcx_gz, (LPVOID)parameter, (DWORD)0, (LPDWORD)&ThreadId);
671 CloseHandle(myhandle);
672 return 0;
673}
674
675uint __stdcall tuncompressgzip2_utf8_k(uchar *outfile, uchar *outfile2)
676{
677
678 HANDLE myhandle;
679 MYCAST ThreadId;
680 MYCAST parameter = 1;
681 comando = 10001;
682 intret = 0;
683 strcpy((void *)intoutfile, (void *)outfile2);
684 strcpy((void *)intinputfile, (void *)outfile);
685 myhandle = CreateThread((LPSECURITY_ATTRIBUTES)0, 0, (void *)startapi_xcx_gz, (LPVOID)parameter, (DWORD)0, (LPDWORD)&ThreadId);
686 CloseHandle(myhandle);
687 return 0;
688}
689
690int __stdcall startapi_xcx_gz(__attribute__((unused)) int parameter)
691{
692
693 if (0 == comando)
694 {
695 unicodemode = 0;
696 intret = rspcompress((void *)intinputfile, (void *)intoutfile);
697 }
698
699 if (1 == comando)
700 {
701 unicodemode = 0;
702 intret = rspuncompress((void *)intinputfile, (void *)intoutfile);
703 }
704
705 if (2 == comando)
706 {
707
709 }
710
711 if (3 == comando)
712 {
713
714 intret = zuncompress((void *)intinputfile, (void *)intoutfile);
715 }
716
717 if (10000 == comando)
718 {
719 unicodemode = 1;
720
721 // pedro_dprintf(0, "-99.000001");
722
723 intret = rspcompress((void *)intinputfile, (void *)intoutfile);
724
725 // pedro_dprintf(0, "-99.000002");
726 }
727
728 if (10001 == comando)
729 {
730 unicodemode = 1;
731 intret = rspuncompress((void *)intinputfile, (void *)intoutfile);
732 }
733
734 if (10002 == comando)
735 {
736 unicodemode = 1;
738 }
739
740 intstatus = 0;
741 return intret;
742}
743
744int __stdcall getintret()
745{
746
747 return intret;
748}
749
750int __stdcall getfinished()
751{
752
753 return finished;
754}
755
756int __stdcall setfinished(uint newvalue)
757{
758
759 finished = newvalue;
760
761 return 0;
762}
763
764#ifdef WIN64
765int __stdcall interface1_xcx_gz(__int64 argumento1, __int64 argumento2, __int64 argumento3, __attribute__((unused)) __int64 argumento4)
766{
767#else
768int __stdcall interface1_xcx_gz(int argumento1, int argumento2, int argumento3, __attribute__((unused)) int argumento4)
769{
770#endif
771
772 static uchar inputfile[AMANDA__SIZE]; // for Unicode sake, (utf-8)
773 static uchar inputfile2[AMANDA__SIZE];
774 static uchar outputfile[AMANDA__SIZE];
775 static uchar key[255 * 6];
776
777 if (!strcmp((char *)argumento1, "compress"))
778 {
779 memset(inputfile, 0, 255);
780 memset(outputfile, 0, 255);
781 memset(key, 0, 256);
782
783 isgzip2 = 0;
784 intstatus = 1;
785
786 ;
787
788 strcpy((void *)inputfile, (char *)argumento2);
789
790 strcpy((void *)inputfile2, (char *)argumento3);
791
792 return tcompress((void *)inputfile, (void *)inputfile2);
793 }
794
795 if (!strcmp((char *)argumento1, "compressgzip2"))
796 {
797 memset(inputfile, 0, 255);
798 memset(outputfile, 0, 255);
799 memset(key, 0, 256);
800
801 isgzip2 = 1;
802 intstatus = 1;
803
804 ;
805
806 strcpy((void *)inputfile, (char *)argumento2);
807
808 strcpy((void *)inputfile2, (char *)argumento3);
809
810 return tcompressgzip2((void *)inputfile, (void *)inputfile2);
811 }
812
813 if (!strcmp((char *)argumento1, "compressgzip2_sha512_k"))
814 {
815 memset(inputfile, 0, 255);
816 memset(outputfile, 0, 255);
817 memset(key, 0, 256);
818
819 isgzip2 = 1;
820 intstatus = 1;
821
822 ;
823
824 strcpy((void *)inputfile, (char *)argumento2);
825
826 strcpy((void *)inputfile2, (char *)argumento3);
827
828 return tcompressgzip2_sha512_k((void *)inputfile, (void *)inputfile2);
829 }
830
831 if (!strcmp((char *)argumento1, "compressgzip2_utf8_k"))
832 {
833 memset(inputfile, 0, 255);
834 memset(outputfile, 0, 255);
835 memset(key, 0, 256);
836
837 isgzip2 = 0;
838 intstatus = 1;
839
840 ;
841
842 strcpy((void *)inputfile, (char *)argumento2);
843
844 strcpy((void *)inputfile2, (char *)argumento3);
845
846 return tcompressgzip2_utf8_k((void *)inputfile, (void *)inputfile2);
847 }
848
849 if (!strcmp((char *)argumento1, "uncompress"))
850 {
851 memset(inputfile, 0, 255);
852 memset(outputfile, 0, 255);
853 ;
854 strcpy((void *)inputfile, (char *)argumento2);
855 strcpy((void *)inputfile2, (char *)argumento3);
856 intstatus = 1;
857 isgzip2 = 0;
858 return tuncompress((void *)inputfile, (void *)inputfile2);
859 }
860
861 if (!strcmp((char *)argumento1, "uncompressgzip2"))
862 {
863 memset(inputfile, 0, 255);
864 memset(outputfile, 0, 255);
865
866 ;
867
868 strcpy((void *)inputfile, (char *)argumento2);
869
870 strcpy((void *)inputfile2, (char *)argumento3);
871 intstatus = 1;
872 isgzip2 = 1;
873
874 return tuncompressgzip2((void *)inputfile, (void *)inputfile2);
875 }
876
877 if (!strcmp((char *)argumento1, "uncompressgzip2_utf8_k"))
878 {
879 memset(inputfile, 0, sizeof(inputfile));
880 memset(outputfile, 0, sizeof(outputfile));
881
882 strcpy((void *)inputfile, (char *)argumento2);
883
884 strcpy((void *)inputfile2, (char *)argumento3);
885 intstatus = 1;
886 isgzip2 = 0;
887 return tuncompressgzip2_utf8_k((void *)inputfile, (void *)inputfile2);
888 }
889
890 if (!strcmp((char *)argumento1, "setfinished"))
891 {
892
893 setfinished(argumento2);
894
895 return 0;
896 }
897
898 if (!strcmp((char *)argumento1, "getfinished"))
899 {
900
901 return getfinished();
902 }
903
904 if (!strcmp((char *)argumento1, "getporcentagem"))
905 {
906
907 return getporcentagem();
908 }
909
910 if (!strcmp((char *)argumento1, "pause"))
911 {
912
913 pauseflag = 1;
914
915 return 0;
916 }
917
918 if (!strcmp((char *)argumento1, "resume"))
919 {
920
921 pauseflag = 0;
922
923 return 0;
924 }
925
926 if (!strcmp((char *)argumento1, "cancel"))
927 {
928
929 pauseflag = 1;
930 cancelflag = 1;
931
932 while (intstatus)
933 {
934#ifdef NPRINTF
935 dprintf("Loopeando no cancel \n");
936#endif
937 Sleep(50);
938 }
939
940 return 0;
941 }
942
943 if (!strcmp((char *)argumento1, "getintret"))
944 {
945
946 return getintret();
947 }
948
949 if (!strcmp((char *)argumento1, "compressionlevel"))
950 {
951
952 switch (argumento2)
953 {
954
955 case 0:
956 break;
957
958 case 1:
959 break;
960 case 2:
961 break;
962 case 3:
963 break;
964 case 4:
965 break;
966 case 5:
967 break;
968 case 6:
969 break;
970 case 7:
971 break;
972 case 8:
973 break;
974 case 9:
975 break;
976
977 default:
978
979 return 1;
980 }
981
982 compressionlevel = argumento2;
983
984 return 0;
985 }
986
987 if (!strcmp((char *)argumento1, "status"))
988 {
989
990 return intstatus;
991 }
992
993 assert(0);
994 return 0;
995}
996
998
999void mprintf2(char *format, ...)
1000{
1001 {
1002 va_list args;
1003 static char buffer[500000];
1004 va_start(args, format);
1005 vsprintf(buffer, format, args);
1006 MessageBox(0, buffer, "BW", MB_OK | MB_TOPMOST);
1007 /*
1008 if (val != IDOK)
1009 {
1010
1011 }
1012 */
1013 va_end(args);
1014 }
1015}
1016
1017/*
1018int __stdcall ControlName(char *data)
1019{
1020 strcpy(data, "BW Gzip DLL " AMARIC__VERSION
1021#ifdef WIN64
1022 " 64 bits"
1023#else
1024 " 32 bits"
1025#endif
1026 );
1027 return 0;
1028}
1029*/
1030
1031int __stdcall About()
1032{
1033 mprintf2("Brazilian Win32 and Win64 DLL to compress or uncompress gzip and gzip2 files, now with SHA512 support...");
1034 return 0;
1035}
1036
1037int wait = 0;
1038
1039int __stdcall WaitExecution(int val)
1040{
1041 wait = val;
1042 return 0;
1043}
1044
1045void __stdcall PauseExecution()
1046{
1047 pauseflag = 1;
1048}
1049void __stdcall ResumeExecution()
1050{
1051 pauseflag = 0;
1052}
1053void __stdcall CancelExecution()
1054{
1055 pauseflag = 1;
1056 cancelflag = 1;
1057
1058 while (intstatus)
1059 {
1060#ifdef NPRINTF
1061 dprintf("Loopeando no cancel \n");
1062#endif
1063 Sleep(50);
1064 }
1065}
1066
1067int __stdcall Compress(char *Inputfile, char *OutPutFile, int CompressionLevel)
1068{
1069
1070 if (0 != interface1_xcx_gz((MYCAST) "status", 0, 0, 0))
1071 {
1072 return 13;
1073 }
1074
1075 if (0 != interface1_xcx_gz((MYCAST) "compressionlevel", (MYCAST)CompressionLevel, 0, 0))
1076 {
1077
1078 return 12;
1079 }
1080
1081 interface1_xcx_gz((MYCAST) "setfinished", 0, 0, 0);
1082
1083 interface1_xcx_gz((MYCAST) "compress", (MYCAST)Inputfile, (MYCAST)OutPutFile, (MYCAST) "file3");
1084
1085volta:
1086
1087 if (wait)
1088 {
1089 Sleep(50);
1090 if (0 == interface1_xcx_gz((MYCAST) "getfinished", (MYCAST) " ", (MYCAST) " ", (MYCAST) " "))
1091 {
1092
1093 goto volta;
1094 }
1095 }
1096 return 0;
1097}
1098
1099int __stdcall CompressGzip2(char *Inputfile, char *OutPutFile, int CompressionLevel)
1100{
1101 unicodemode = 1;
1102 if (0 != interface1_xcx_gz((MYCAST) "status", 0, 0, 0))
1103 {
1104 return 13;
1105 }
1106
1107 if (0 != interface1_xcx_gz((MYCAST) "compressionlevel", (MYCAST)CompressionLevel, 0, 0))
1108 {
1109 return 12;
1110 }
1111
1112 interface1_xcx_gz((MYCAST) "setfinished", 0, 0, 0);
1113
1114 interface1_xcx_gz((MYCAST) "compressgzip2", (MYCAST)Inputfile, (MYCAST)OutPutFile, (MYCAST) "file3");
1115
1116volta:
1117
1118 if (wait)
1119 {
1120 Sleep(50);
1121 if (0 == interface1_xcx_gz((MYCAST) "getfinished", (MYCAST) " ", (MYCAST) " ", (MYCAST) " "))
1122 {
1123 goto volta;
1124 }
1125 }
1126
1127 return 0;
1128}
1129
1130int __stdcall CompressGzip2_SHA512_k(char *Inputfile, char *OutPutFile, int CompressionLevel)
1131{
1132 unicodemode = 1;
1133 if (0 != interface1_xcx_gz((MYCAST) "status", 0, 0, 0))
1134 {
1135 return 13;
1136 }
1137
1138 if (0 != interface1_xcx_gz((MYCAST) "compressionlevel", (MYCAST)CompressionLevel, 0, 0))
1139 {
1140 return 12;
1141 }
1142
1143 interface1_xcx_gz((MYCAST) "setfinished", 0, 0, 0);
1144
1145 interface1_xcx_gz((MYCAST) "compressgzip2_sha512_k", (MYCAST)Inputfile, (MYCAST)OutPutFile, (MYCAST) "file3");
1146
1147volta:
1148
1149 if (wait)
1150 {
1151 Sleep(50);
1152 if (0 == interface1_xcx_gz((MYCAST) "getfinished", (MYCAST) " ", (MYCAST) " ", (MYCAST) " "))
1153 {
1154
1155 goto volta;
1156 }
1157 }
1158
1159 return 0;
1160}
1161
1162
1178int __stdcall CompressGzip_utf8_k(char *Inputfile, char *OutPutFile, int CompressionLevel)
1179{
1180
1181 // pedro_dprintf(0, "9.99999");
1182
1183 if (0 != interface1_xcx_gz((MYCAST) "status", 0, 0, 0))
1184 {
1185 // pedro_dprintf(0, "9.999991");
1186 return 13;
1187 }
1188
1189 // pedro_dprintf(0, "9.999992");
1190 if (0 != interface1_xcx_gz((MYCAST) "compressionlevel", (MYCAST)CompressionLevel, 0, 0))
1191 {
1192 // pedro_dprintf(0, "9.999993");
1193 return 12;
1194 }
1195
1196 // pedro_dprintf(0, "9.999994");
1197
1198 compressionlevel = CompressionLevel;
1199
1200 interface1_xcx_gz((MYCAST) "setfinished", 0, 0, 0);
1201
1202 // pedro_dprintf(0, "9.999995");
1203
1204 interface1_xcx_gz((MYCAST) "compressgzip2_utf8_k", (MYCAST)Inputfile, (MYCAST)OutPutFile, (MYCAST) "file3");
1205
1206 // pedro_dprintf(0, "9.999996");
1207
1208volta:
1209
1210 if (wait)
1211 {
1212 Sleep(50);
1213 if (0 == interface1_xcx_gz((MYCAST) "getfinished", (MYCAST) " ", (MYCAST) " ", (MYCAST) " "))
1214 {
1215
1216 goto volta;
1217 }
1218 }
1219
1220 // pedro_dprintf(0, "9.999997");
1221
1222 return 0;
1223}
1224int __stdcall GetFinished() // retorna 0 se nao terminou ainda
1225{
1226 return interface1_xcx_gz((MYCAST) "getfinished", (MYCAST) " ", (MYCAST) " ", (MYCAST) " ");
1227}
1228
1229int __stdcall GetReturnValue()
1230{
1231 return interface1_xcx_gz((MYCAST) "getintret", (MYCAST) " ", (MYCAST) " ", (MYCAST) " ");
1232}
1233
1234int __stdcall GetProgress()
1235{
1236
1237 return interface1_xcx_gz((MYCAST) "getporcentagem", (MYCAST) " ", (MYCAST) " ", (MYCAST) " ");
1238 return 0;
1239}
1240
1241int __stdcall Uncompress(char *Inputfile, char *OutPutFile)
1242{
1243
1244 if (0 != interface1_xcx_gz((MYCAST) "status", 0, 0, 0))
1245 {
1246 return 13;
1247 }
1248
1249 interface1_xcx_gz((MYCAST) "setfinished", 0, 0, 0);
1250
1251 interface1_xcx_gz((MYCAST) "uncompress", (MYCAST)Inputfile, (MYCAST)OutPutFile, (MYCAST) "file3");
1252
1253volta:
1254
1255 if (wait)
1256 {
1257 Sleep(50);
1258 if (0 == interface1_xcx_gz((MYCAST) "getfinished", (MYCAST) " ", (MYCAST) " ", (MYCAST) " "))
1259 {
1260
1261 goto volta;
1262 }
1263 }
1264
1265 return 0;
1266}
1267
1268int __stdcall UncompressGzip2(char *Inputfile, char *OutPutFile)
1269{
1270
1271 unicodemode = 1;
1272 if (interface1_xcx_gz((MYCAST) "status", 0, 0, 0))
1273 {
1274
1275 return 13;
1276 }
1277
1278 interface1_xcx_gz((MYCAST) "setfinished", 0, 0, 0);
1279 interface1_xcx_gz((MYCAST) "uncompressgzip2", (MYCAST)Inputfile, (MYCAST)OutPutFile, (MYCAST) "file3");
1280
1281volta:
1282
1283 if (wait)
1284 {
1285 Sleep(50);
1286 if (0 == interface1_xcx_gz((MYCAST) "getfinished", (MYCAST) " ", (MYCAST) " ", (MYCAST) " "))
1287 {
1288
1289 goto volta;
1290 }
1291 }
1292
1293 return 0;
1294}
1295
1309int __stdcall UncompressGzip_utf8_k(char *Inputfile, char *OutPutFile)
1310{
1311
1312 unicodemode = 1;
1313 if (interface1_xcx_gz((MYCAST) "status", 0, 0, 0))
1314 {
1315
1316 return 13;
1317 }
1318
1319 interface1_xcx_gz((MYCAST) "setfinished", 0, 0, 0);
1320 interface1_xcx_gz((MYCAST) "uncompressgzip2_utf8_k", (MYCAST)Inputfile, (MYCAST)OutPutFile, (MYCAST) "file3");
1321
1322volta:
1323
1324 if (wait)
1325 {
1326 Sleep(50);
1327 if (0 == interface1_xcx_gz((MYCAST) "getfinished", (MYCAST) " ", (MYCAST) " ", (MYCAST) " "))
1328 {
1329
1330 goto volta;
1331 }
1332 }
1333
1334 return 0;
1335}
1336
1337// for your pleasure...
void * LPVOID
Definition 7zTypes.h:200
UINT32 DWORD
Definition 7zTypes.h:194
size_t SIZE_T
Definition 7zTypes.h:209
uint getpor(int max, uint fatia)
#define pedro_dprintf2
Definition brotli.c:69
#define assert(condition)
Definition lz4.c:273
#define input(b, o, c, n, m)
Definition compress42.c:610
#define output(b, o, c, n)
Definition compress42.c:592
char buf[N_BUF]
Definition spewG.c:36
WCHAR * utf8_2_wide_dl(char *pUTF8)
Definition tar_1_33.c:745
int __stdcall GetProgress()
Definition dll.c:1234
#define AMANDA__SIZE
Definition dll.c:104
void dprintf(char *format,...)
Definition dprintf.c:96
uint __stdcall tuncompress(uchar *outfile, uchar *outfile2)
Definition dll.c:597
int zcompress(char *input, char *output, int level)
Definition zlib.c:158
int __stdcall WaitExecution(int val)
Definition dll.c:1039
int __stdcall setfinished(uint newvalue)
Definition dll.c:756
int gzwrite(myfile file, const char *buf, uint len)
int gzread(myfile file, char *buf, uint len)
int __stdcall Compress(char *Inputfile, char *OutPutFile, int CompressionLevel)
Definition dll.c:1067
uchar intoutfile[AMANDA__SIZE]
Definition dll.c:177
uint __stdcall tcompressgzip2_utf8_k(char *inputfile, char *outfile)
Definition dll.c:661
int __stdcall CompressGzip_utf8_k(char *Inputfile, char *OutPutFile, int CompressionLevel)
Definition dll.c:1178
void mprintf2(char *format,...)
Definition dll.c:999
char * gzerror(myfile file, int *errnum)
void __stdcall ResumeExecution()
Definition dll.c:1049
uint intstatus
Definition dll.c:115
uint pauseflag
Definition dll.c:181
int erroglobal
Definition dll.c:117
int __stdcall About()
Definition dll.c:1031
int __stdcall getintret()
Definition dll.c:744
int unicodemode
Definition dll.c:997
uint __stdcall tcompressgzip2(char *inputfile, char *outfile)
Definition dll.c:618
#define __attribute__(unused)
Definition dll.c:77
myfile gzopen_w(WCHAR *path_now_as_utf8, char *mode)
uint filesize
Definition dll.c:183
uint __stdcall rspuncompress(uchar *outfile, uchar *outfile2)
Definition dll.c:442
int __stdcall startapi_xcx_gz(int parameter)
uint __stdcall getporcentagem()
Definition dll.c:542
int __stdcall UncompressGzip_utf8_k(char *Inputfile, char *OutPutFile)
Funtion to uncompress a standard gzip file.
Definition dll.c:1309
int gzclose(myfile file)
uint getmax(int por, uint fatia)
Definition dll.c:242
void __stdcall CancelExecution()
Definition dll.c:1053
myfile gzopen(char *path_now_as_utf8, char *mode)
void * myfile
Definition dll.c:155
uint compressionlevel
Definition dll.c:113
uint __stdcall rspvalidatefile(uchar *outfile2)
int __stdcall GetReturnValue()
Definition dll.c:1229
__int64 lffilesize_dl(const char *szFileName)
default function to get the size of files with Unicode support
Definition tar_1_33.c:11745
int zlibpercent
Definition zlib.c:132
uint __stdcall tuncompressgzip2_utf8_k(uchar *outfile, uchar *outfile2)
Definition dll.c:675
int __stdcall UncompressGzip2(char *Inputfile, char *OutPutFile)
Definition dll.c:1268
int __stdcall CompressGzip2_SHA512_k(char *Inputfile, char *OutPutFile, int CompressionLevel)
Definition dll.c:1130
uint intret
Definition dll.c:186
uint cancelflag
Definition dll.c:182
#define uchar
Definition dll.c:34
int wait
Definition dll.c:1037
int __stdcall getfinished()
Definition dll.c:750
uint __stdcall rspcompress(char *inputfile, char *outfile)
Definition dll.c:287
uint __stdcall tuncompressgzip2(uchar *outfile, uchar *outfile2)
Definition dll.c:646
int __stdcall Uncompress(char *Inputfile, char *OutPutFile)
Definition dll.c:1241
void __stdcall PauseExecution()
Definition dll.c:1045
int zcompress_sha512_k(char *input, char *output, int levelin)
Definition zlib.c:548
WCHAR * amanda_asciitowide_1_v27(char *pUTF8)
int __stdcall CompressGzip2(char *Inputfile, char *OutPutFile, int CompressionLevel)
Definition dll.c:1099
int zuncompress(char *input, char *output)
Definition zlib.c:930
uint __stdcall tcompress(char *inputfile, char *outfile)
Definition dll.c:577
#define uint
Definition dll.c:38
int __stdcall interface1_xcx_gz(int argumento1, int argumento2, int argumento3, __attribute__((unused)) int argumento4)
Definition dll.c:768
#define MYCAST
Definition dll.c:73
float inittimer(uint comando)
uint finished
Definition dll.c:187
uchar intinputfile[AMANDA__SIZE]
Definition dll.c:178
uint fileread
Definition dll.c:185
int __stdcall GetFinished()
Definition dll.c:1224
uint getval(int max, uint por)
Definition dll.c:189
int utf8towide(const char *pUTF8, WCHAR *pUSC2, int nUSC2)
uint comando
Definition dll.c:179
int isgzip2
Definition dll.c:119
uint __stdcall tcompressgzip2_sha512_k(char *inputfile, char *outfile)
Definition dll.c:632
void pedro_dprintf(int amanda_level, char *format,...)
Definition pedro.c:43
#define b(i)
Definition sha256.c:42
#define a(i)
Definition sha256.c:41
#define NULL
Definition getopt1.c:37
static uint32_t const uint8_t uint32_t len
Definition memcmplen.h:44
ret
Definition zlib_interface.c:30