Parolin 0.7.9 6796
Console (soon DLLs) to do a tar like job
Loading...
Searching...
No Matches
lzop2_multi.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
33static uint64_t bytes_in_each_slice_z[129];
34static uint64_t offset_of_each_slice_z[129];
35
36extern int *cores_used_z_14;
37
38#include "lzop2_thread.c"
39
40int __valquiriacall compress2_uncompress_k_real_mt_z_14(char *input_z, char *output_z)
41{
42 //enum error_modes_J juliete_result = ERROR_AMANDA_NO_ERROR__;
43 my_thread_struct_z *ptr_my_struct_z;
44 FILE *dest_z;
45 FILE *input_file;
46 FILE *temp_z = NULL;
47 int ret_z;
48 int ret2_z;
49 int retvalue_z = 0;
50 int n_threads_copy;
51 int n_thread_counter;
52 int ret_arp;
53 int thread_counter = 0;
54 int i_z;
55 int64_t remaining_z;
56 char signature_z[5] = "AR__";
57 static char buffer[CHUNK];
58 ar_data ar = {0};
59
60 thread_return_value_z_14 = 0; //initial thread error value
61
62 //n_threads_copy = n_threads_z_14;
63
64 n_thread_counter = 0;
65
66 //primeiro precisa detectar quantos threads foram usados no arquivo compactado
67
68 if (true)
69 {
70
71 input_file = _wfopen(utf8_2_wide_dl(input_z), L"rb");
72
73 }
74
75 if (NULL == input_file)
76 {
77 return 1; //Cannot open input file
78 }
79
80 signature_z[3] = '_' - 11; // new lzop2 multi-thread and single-thread signature
81
82 while (1)
83 {
84
85 memset(&ar, 0, sizeof(ar));
86 ret_arp = fread(&ar, 1, sizeof(ar), input_file);
87
88 if (0 == ret_arp)
89 {
90 goto saida_z;
91 }
92
93 if (ret_arp != sizeof(ar))
94 {
95 retvalue_z = 5;
96 goto saida_z;
97 }
98
99 if (0 != memcmp(ar.string, signature_z, 4))
100 {
101 retvalue_z = 7;
102 goto saida_z;
103 }
104
105 ret_arp = fread(&remaining_z, 1, sizeof(remaining_z), input_file);
106
107 if (sizeof(remaining_z) != ret_arp)
108 {
109 retvalue_z = 5;
110 goto saida_z;
111 }
112 bytes_in_each_slice_z[thread_counter] = remaining_z;
113 offset_of_each_slice_z[thread_counter] = _ftelli64(input_file);
114
115 _fseeki64(input_file, remaining_z, SEEK_CUR);
116
117 thread_counter++;
118 }
119
120saida_z:;
121
122 fclose(input_file);
123
124 if (retvalue_z)
125 {
126 return 7;
127 }
128
129 //exit(27);
130
131 n_threads_z_14 = thread_counter;
132
134
136
137 n_threads_copy = thread_counter;
138
139 while (n_threads_copy--)
140 {
141
142 ptr_my_struct_z = calloc(1, sizeof(my_thread_struct_z));
143 assert(ptr_my_struct_z);
144
145 ptr_my_struct_z->thread_id_z = n_thread_counter;
146
147 ptr_my_struct_z->input_file = _wfopen(utf8_2_wide_dl(input_z), L"rb");
148
149 intpause_14 = 0;
150 intcancel_14 = 0;
151
152 ptr_my_struct_z->intpause_14 = &intpause_14;
153 ptr_my_struct_z->intcancel_14 = &intcancel_14;
154
155 bytes__read_thread_z_14[n_thread_counter] = 0;
156
157 ptr_my_struct_z->bytes_read_z =
158 &bytes__read_thread_z_14[n_thread_counter];
159
160 ptr_my_struct_z->size_of_input_file_z = ptr_my_struct_z->size_of_input_file_copy_z = bytes_in_each_slice_z[n_thread_counter];
161
162 ptr_my_struct_z->offset_z =
163 offset_of_each_slice_z[n_thread_counter];
164
165 {
166
167 void
169 (
170 int amanda_level,
171 char *format, ...
172 );
173 // yasmin_charlotte_pereira_dprintf(0, "path temp ric -%s-", temp_path_z_14);
174 // exit(27);
175 // assert(0);
176 }
178 {
180 {
181 thread_return_value_z_14 = 407; //Cannot create temp file
182 }
183 }
184 else
185 {
186 if (true)
187 {
189
190#ifdef ARP_USE_ENHANCED_STDIO
191
192 ptr_my_struct_z->dest = fopen(temp_files_z_14[n_thread_counter], "wb");
193
194#else
195#error stdio ric
196 ptr_my_struct_z->dest = _wfopen(wpmode, L"wb");
197#endif
198 }
199
200 if (NULL == ptr_my_struct_z->dest)
201 {
203 {
204 thread_return_value_z_14 = 405; //Cannot open output tempfile
205 }
206 }
207 }
208
209 my_thread_handle_14[n_thread_counter] = (__INT32_OR_INT64)_beginthreadex(NULL, 0, my_thread_function_v27_14, ptr_my_struct_z, 0, NULL);
210
211 n_thread_counter++;
212 }
213
214 for (i_z = 0; i_z < n_threads_z_14; i_z++)
215 {
216 WaitForSingleObject((void *)my_thread_handle_14[i_z], INFINITE);
217 CloseHandle((void *)my_thread_handle_14[i_z]);
218 }
219
220 {
221
222 SetFileAttributesW(utf8_2_wide_dl(output_z), FILE_ATTRIBUTE_ARCHIVE);
223
224 dest_z = _wfopen(utf8_2_wide_dl(output_z), L"wb");
225
226 }
227
228 if (NULL == dest_z)
229 {
231 {
232 thread_return_value_z_14 = 2; //Cannot open output file
233 }
234 }
235
236 //depois de finalizar
237 for (i_z = 0; i_z < n_threads_z_14; i_z++)
238 {
239
240 if (dest_z)
241 {
242
243 if (TRUE)
244 {
246#ifdef ARP_USE_ENHANCED_STDIO
247
248 temp_z = fopen(temp_files_z_14[i_z], "rb");
249
250#else
251 temp_z = _wfopen(wpmode, L"rb");
252#endif
253 }
254
255 if (temp_z)
256 {
257 //Mr. Do
258
259 volta_amanda:;
260#ifdef ARP_USE_ENHANCED_STDIO
261 ret_z = fread(buffer, 1, CHUNK, temp_z);
262#else
263 ret_z = fread(buffer, 1, CHUNK, temp_z);
264#endif
265 if (0 > ret_z) //nunca vai acontecer porque é size_t...kkk
266 {
268 {
269 thread_return_value_z_14 = 5; //Cannot read from input file
270 }
271 }
272 else if (0 == ret_z)
273 {
274 ; //just go by...
275 }
276 else
277 {
278
279 ret2_z = fwrite(buffer, 1, ret_z, dest_z);
280
281 if (ret2_z != ret_z)
282 {
284 {
285 assert(0 && "aqui ok");
286 thread_return_value_z_14 = 6; //Cannot write to output file
287 }
288 goto exit_loop_z;
289 }
290
291 goto volta_amanda;
292 }
293
294 exit_loop_z:;
295
296 fclose(temp_z);
297 }
298 else
299 {
301 {
302 thread_return_value_z_14 = 405; //Cannot open temp file
303 }
304 }
305 }
306
307 unlink(temp_files_z_14[i_z]);
308
309 }
310
311 //precisa setar isto antes de retornar
312 finished_14 = 1; //e depois return
313
314 if (dest_z)
315 {
316 fclose(dest_z);
317 }
318 intstatus_14 = 0;
320
321 exit(27);
322 return 0;
323}
#define FILE_ATTRIBUTE_ARCHIVE
Definition 7zTypes.h:147
#define TRUE
Definition 7zMain.c:348
#define CHUNK
Definition brotli2.c:163
#define assert(condition)
Definition lz4.c:273
void yasmin_charlotte_pereira_dprintf(int amanda_level, char *format,...)
Definition pedro.c:35
Definition stdio_v3.h:12
char string[4]
Definition stdio_v3.h:13
Definition stdio_v3.h:23
int64_t offset_z
Definition stdio_v3.h:44
int * intpause_14
Definition stdio_v3.h:27
int64_t size_of_input_file_copy_z
Definition stdio_v3.h:46
int64_t * bytes_read_z
Definition stdio_v3.h:43
int * intcancel_14
Definition stdio_v3.h:28
FILE * dest
Definition stdio_v3.h:26
int thread_id_z
Definition stdio_v3.h:40
FILE * input_file
Definition stdio_v3.h:35
int64_t size_of_input_file_z
Definition stdio_v3.h:47
WCHAR * utf8_2_wide_dl(char *pUTF8)
Definition tar_1_33.c:745
#define __valquiriacall
Definition tar_1_33.c:80
#define __INT32_OR_INT64
Definition win64.h:41
int intcancel_14
Definition compress2dll.c:122
int createtempfilename_and_keep_z_12(char *path1, char *out_z, char *signature_z)
Definition compress2_2_z.c:232
int intstatus_14
Definition compress2dll.c:124
int thread_return_value_z_14
Definition compress2_2_z.c:305
int64_t max_memory_size_k__p_14
Definition compress2_2_z.c:156
__INT32_OR_INT64 my_thread_handle_14[129]
Definition compress2_2_z.c:303
int64_t bytes__read_thread_z_14[129]
Definition compress2_2_z.c:300
int intpause_14
Definition compress2dll.c:121
int finished_14
Definition compress2_2_z.c:160
char temp_path_z_14[]
Definition compress2dll.c:88
char temp_files_z_14[129][2048]
Definition compress2_2_z.c:304
int n_threads_z_14
Definition compress2dll.c:76
int __valquiriacall compress2_uncompress_k_real_mt_z_14(char *input_z, char *output_z)
Definition lzop2_multi.c:40
int * cores_used_z_14
Definition compress2dll.c:73
unsigned __stdcall my_thread_function_v27_14(void *my_argument_z)
Definition lzop2_thread.c:33
#define SEEK_CUR
Definition zconf.h:499
#define NULL
Definition getopt1.c:37
signature_z[3]
Definition zlib_interface.c:37