Mercurial > mxe-octave
comparison src/msvc-gcab-1.patch @ 3136:5481abb52912
Add gcab (and MSVC-specific patch)
author | Michael Goffioul <michael.goffioul@gmail.com> |
---|---|
date | Sat, 13 Jul 2013 17:10:35 -0400 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
3135:8147e6f8659a | 3136:5481abb52912 |
---|---|
1 diff -ur gcab-0.4-orig/Makefile.in gcab-0.4/Makefile.in | |
2 --- gcab-0.4-orig/Makefile.in 2013-02-08 10:38:12 -0500 | |
3 +++ gcab-0.4/Makefile.in 2013-07-13 17:02:16 -0400 | |
4 @@ -474,8 +474,8 @@ | |
5 libgcab_1_0_la_LIBADD = -lz $(GLIB_LIBS) | |
6 libgcab_1_0_la_LDFLAGS = \ | |
7 -version-info 0:0:0 \ | |
8 - -Wl,--version-script=${srcdir}/libgcab.syms \ | |
9 -no-undefined \ | |
10 + -export-symbols-regex "gcab_.*" \ | |
11 $(NULL) | |
12 | |
13 libgcab_1_0_la_DEPENDENCIES = libgcab.syms | |
14 diff -ur gcab-0.4-orig/gcab.c gcab-0.4/gcab.c | |
15 --- gcab-0.4-orig/gcab.c 2013-02-08 10:34:05 -0500 | |
16 +++ gcab-0.4/gcab.c 2013-07-13 16:40:01 -0400 | |
17 @@ -94,6 +94,14 @@ | |
18 { NULL } | |
19 }; | |
20 | |
21 + gchar *s; | |
22 + GCancellable *cancellable; | |
23 + GCabCabinet *cabinet; | |
24 + GCabFolder *folder; | |
25 + GFile *outputfile; | |
26 + GOutputStream *output; | |
27 + GFile *cwd; | |
28 + | |
29 setlocale (LC_ALL, ""); | |
30 textdomain (GETTEXT_PACKAGE); | |
31 bindtextdomain (GETTEXT_PACKAGE, LOCALEDIR); | |
32 @@ -105,7 +113,7 @@ | |
33 g_set_prgname (PACKAGE_NAME); | |
34 | |
35 context = g_option_context_new (_("- create a Cabinet file")); | |
36 - gchar *s = g_strdup_printf (_("Report bugs to <%s>"), PACKAGE_BUGREPORT); | |
37 + s = g_strdup_printf (_("Report bugs to <%s>"), PACKAGE_BUGREPORT); | |
38 g_option_context_set_description (context, s); | |
39 g_free(s); | |
40 g_option_context_set_summary (context, _("\ | |
41 @@ -129,12 +137,8 @@ | |
42 if (!args || args[0] == NULL) | |
43 gcab_error (_("cabinet file must be specified.")); | |
44 | |
45 - GCancellable *cancellable = g_cancellable_new (); | |
46 - GCabCabinet *cabinet = gcab_cabinet_new (); | |
47 - GCabFolder *folder; | |
48 - GFile *outputfile; | |
49 - GOutputStream *output; | |
50 - GFile *cwd; | |
51 + cancellable = g_cancellable_new (); | |
52 + cabinet = gcab_cabinet_new (); | |
53 | |
54 if (list || extract) { | |
55 GFile *file = g_file_new_for_commandline_arg (args[0]); | |
56 diff -ur gcab-0.4-orig/libgcab/cabinet.c gcab-0.4/libgcab/cabinet.c | |
57 --- gcab-0.4-orig/libgcab/cabinet.c 2013-02-08 10:12:17 -0500 | |
58 +++ gcab-0.4/libgcab/cabinet.c 2013-07-13 16:58:14 -0400 | |
59 @@ -388,12 +388,15 @@ | |
60 guint8 *data, size_t size, gsize *bytes_written, | |
61 GCancellable *cancellable, GError **error) | |
62 { | |
63 + CHECKSUM datacsum; | |
64 + GOutputStream *stream; | |
65 + | |
66 if (!cdata_set(cd, type, data, size)) | |
67 return FALSE; | |
68 | |
69 - CHECKSUM datacsum = compute_checksum(cd->in, cd->ncbytes, 0); | |
70 + datacsum = compute_checksum(cd->in, cd->ncbytes, 0); | |
71 cd->checksum = compute_checksum ((guint8*)&cd->ncbytes, 4, datacsum); | |
72 - GOutputStream *stream = g_filter_output_stream_get_base_stream (G_FILTER_OUTPUT_STREAM (out)); | |
73 + stream = g_filter_output_stream_get_base_stream (G_FILTER_OUTPUT_STREAM (out)); | |
74 | |
75 *bytes_written = 0; | |
76 | |
77 @@ -482,10 +485,12 @@ | |
78 } | |
79 | |
80 if (compression == GCAB_COMPRESSION_MSZIP) { | |
81 + z_stream *z; | |
82 + | |
83 if (cd->in[0] != 'C' || cd->in[1] != 'K') | |
84 goto end; | |
85 | |
86 - z_stream *z = &cd->z; | |
87 + z = &cd->z; | |
88 | |
89 z->avail_in = cd->ncbytes - 2; | |
90 z->next_in = cd->in + 2; | |
91 diff -ur gcab-0.4-orig/libgcab/gcab-cabinet.c gcab-0.4/libgcab/gcab-cabinet.c | |
92 --- gcab-0.4-orig/libgcab/gcab-cabinet.c 2013-02-08 10:10:26 -0500 | |
93 +++ gcab-0.4/libgcab/gcab-cabinet.c 2013-07-13 16:49:56 -0400 | |
94 @@ -62,8 +62,10 @@ | |
95 static void | |
96 gcab_cabinet_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) | |
97 { | |
98 + GCabCabinet *self; | |
99 + | |
100 g_return_if_fail (GCAB_IS_CABINET (object)); | |
101 - GCabCabinet *self = GCAB_CABINET (object); | |
102 + self = GCAB_CABINET (object); | |
103 | |
104 switch (prop_id) { | |
105 case PROP_RESERVED: | |
106 @@ -80,8 +82,10 @@ | |
107 static void | |
108 gcab_cabinet_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) | |
109 { | |
110 + GCabCabinet *self; | |
111 + | |
112 g_return_if_fail (GCAB_IS_CABINET (object)); | |
113 - GCabCabinet *self = GCAB_CABINET (object); | |
114 + self = GCAB_CABINET (object); | |
115 | |
116 switch (prop_id) { | |
117 case PROP_RESERVED: | |
118 @@ -178,22 +182,16 @@ | |
119 GError **error) | |
120 { | |
121 cheader_t header = { | |
122 - .offsetfiles = CFI_START, // CFHEADER + 1 * CFFOLDER | |
123 - .nfolders = 1, // a single CAB folder is enough | |
124 + 0, 0, 0, | |
125 + /* .offsetfiles =*/ CFI_START, // CFHEADER + 1 * CFFOLDER | |
126 + 0, 0, 0, | |
127 + /* .nfolders =*/ 1, // a single CAB folder is enough | |
128 }; | |
129 cfolder_t folder = { 0, }; | |
130 | |
131 - g_return_val_if_fail (GCAB_IS_CABINET (self), FALSE); | |
132 - g_return_val_if_fail (G_IS_OUTPUT_STREAM (out), FALSE); | |
133 - g_return_val_if_fail (G_IS_SEEKABLE (out), FALSE); | |
134 - g_return_val_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable), FALSE); | |
135 - g_return_val_if_fail (!error || *error == NULL, FALSE); | |
136 - /* FIXME: current limitation of 1 folder */ | |
137 - g_return_val_if_fail (self->folders->len == 1, FALSE); | |
138 - | |
139 - GCabFolder *cabfolder = g_ptr_array_index (self->folders, 0); | |
140 + GCabFolder *cabfolder; | |
141 GCabFile *file; | |
142 - gsize nfiles = gcab_folder_get_nfiles (cabfolder); | |
143 + gsize nfiles; | |
144 GInputStream *in = NULL; | |
145 GDataOutputStream *dstream = NULL; | |
146 gboolean success = FALSE; | |
147 @@ -206,6 +204,17 @@ | |
148 cfile_t *prevf = NULL; | |
149 int i; | |
150 | |
151 + g_return_val_if_fail (GCAB_IS_CABINET (self), FALSE); | |
152 + g_return_val_if_fail (G_IS_OUTPUT_STREAM (out), FALSE); | |
153 + g_return_val_if_fail (G_IS_SEEKABLE (out), FALSE); | |
154 + g_return_val_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable), FALSE); | |
155 + g_return_val_if_fail (!error || *error == NULL, FALSE); | |
156 + /* FIXME: current limitation of 1 folder */ | |
157 + g_return_val_if_fail (self->folders->len == 1, FALSE); | |
158 + | |
159 + cabfolder = g_ptr_array_index (self->folders, 0); | |
160 + nfiles = gcab_folder_get_nfiles (cabfolder); | |
161 + | |
162 dstream = g_data_output_stream_new (out); | |
163 g_data_output_stream_set_byte_order (dstream, G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN); | |
164 | |
165 @@ -342,20 +351,23 @@ | |
166 GCancellable *cancellable, | |
167 GError **error) | |
168 { | |
169 + gboolean success = FALSE; | |
170 + cheader_t cheader; | |
171 + int i; | |
172 + GDataInputStream *in; | |
173 + GPtrArray *folders; | |
174 + | |
175 g_return_val_if_fail (GCAB_IS_CABINET (self), FALSE); | |
176 g_return_val_if_fail (G_IS_INPUT_STREAM (stream), FALSE); | |
177 g_return_val_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable), FALSE); | |
178 g_return_val_if_fail (!error || *error == NULL, FALSE); | |
179 g_return_val_if_fail (self->folders->len == 0, FALSE); | |
180 | |
181 - gboolean success = FALSE; | |
182 - cheader_t cheader; | |
183 - int i; | |
184 - GDataInputStream *in = g_data_input_stream_new (stream); | |
185 + in = g_data_input_stream_new (stream); | |
186 g_filter_input_stream_set_close_base_stream (G_FILTER_INPUT_STREAM (in), FALSE); | |
187 g_data_input_stream_set_byte_order (in, G_DATA_STREAM_BYTE_ORDER_LITTLE_ENDIAN); | |
188 | |
189 - GPtrArray *folders = self->folders; | |
190 + folders = self->folders; | |
191 | |
192 if (!cheader_read (&cheader, in, cancellable, error)) | |
193 goto end; | |
194 @@ -367,10 +379,12 @@ | |
195 | |
196 for (i = 0; i < cheader.nfolders; i++) { | |
197 cfolder_t cfolder = { 0, }; | |
198 + GCabFolder *folder; | |
199 + | |
200 if (!cfolder_read (&cfolder, cheader.res_folder, in, cancellable, error)) | |
201 goto end; | |
202 | |
203 - GCabFolder *folder = gcab_folder_new_with_cfolder (&cfolder, stream); | |
204 + folder = gcab_folder_new_with_cfolder (&cfolder, stream); | |
205 if (cfolder.reserved) | |
206 g_object_set (folder, "reserved", | |
207 g_byte_array_new_take (cfolder.reserved, cheader.res_folder), | |
208 @@ -381,11 +395,14 @@ | |
209 | |
210 for (i = 0; i < cheader.nfiles; i++) { | |
211 cfile_t cfile = { 0, }; | |
212 + GCabFile *file; | |
213 + GCabFolder *folder; | |
214 + | |
215 if (!cfile_read (&cfile, in, cancellable, error)) | |
216 goto end; | |
217 | |
218 - GCabFile *file = gcab_file_new_with_cfile (&cfile); | |
219 - GCabFolder *folder = g_ptr_array_index (folders, cfile.index); | |
220 + file = gcab_file_new_with_cfile (&cfile); | |
221 + folder = g_ptr_array_index (folders, cfile.index); | |
222 if (!gcab_folder_add_file (folder, file, FALSE, cancellable, error)) { | |
223 g_object_unref (file); | |
224 goto end; | |
225 diff -ur gcab-0.4-orig/libgcab/gcab-file.c gcab-0.4/libgcab/gcab-file.c | |
226 --- gcab-0.4-orig/libgcab/gcab-file.c 2013-01-17 21:20:09 -0500 | |
227 +++ gcab-0.4/libgcab/gcab-file.c 2013-07-13 16:56:03 -0400 | |
228 @@ -69,8 +69,10 @@ | |
229 static void | |
230 gcab_file_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) | |
231 { | |
232 + GCabFile *self; | |
233 + | |
234 g_return_if_fail (GCAB_IS_FILE (object)); | |
235 - GCabFile *self = GCAB_FILE (object); | |
236 + self = GCAB_FILE (object); | |
237 | |
238 switch (prop_id) { | |
239 case PROP_NAME: | |
240 @@ -88,8 +90,10 @@ | |
241 static void | |
242 gcab_file_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) | |
243 { | |
244 + GCabFile *self; | |
245 + | |
246 g_return_if_fail (GCAB_IS_FILE (object)); | |
247 - GCabFile *self = GCAB_FILE(object); | |
248 + self = GCAB_FILE(object); | |
249 | |
250 switch (prop_id) { | |
251 case PROP_NAME: | |
252 @@ -220,11 +224,13 @@ | |
253 G_GNUC_INTERNAL GCabFile * | |
254 gcab_file_new_with_cfile (const cfile_t *cfile) | |
255 { | |
256 + GCabFile *file; | |
257 + | |
258 g_return_val_if_fail (cfile != NULL, NULL); | |
259 | |
260 - GCabFile *file = g_object_new (GCAB_TYPE_FILE, | |
261 - "name", cfile->name, | |
262 - NULL); | |
263 + file = g_object_new (GCAB_TYPE_FILE, | |
264 + "name", cfile->name, | |
265 + NULL); | |
266 file->cfile = *cfile; | |
267 | |
268 return file; | |
269 diff -ur gcab-0.4-orig/libgcab/gcab-folder.c gcab-0.4/libgcab/gcab-folder.c | |
270 --- gcab-0.4-orig/libgcab/gcab-folder.c 2013-02-08 10:27:33 -0500 | |
271 +++ gcab-0.4/libgcab/gcab-folder.c 2013-07-13 16:54:39 -0400 | |
272 @@ -60,8 +60,10 @@ | |
273 static void | |
274 gcab_folder_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec) | |
275 { | |
276 + GCabFolder *self; | |
277 + | |
278 g_return_if_fail (GCAB_IS_FOLDER (object)); | |
279 - GCabFolder *self = GCAB_FOLDER (object); | |
280 + self = GCAB_FOLDER (object); | |
281 | |
282 switch (prop_id) { | |
283 case PROP_COMPTYPE: | |
284 @@ -81,8 +83,10 @@ | |
285 static void | |
286 gcab_folder_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec) | |
287 { | |
288 + GCabFolder *self; | |
289 + | |
290 g_return_if_fail (GCAB_IS_FOLDER (object)); | |
291 - GCabFolder *self = GCAB_FOLDER (object); | |
292 + self = GCAB_FOLDER (object); | |
293 | |
294 switch (prop_id) { | |
295 case PROP_COMPRESSION: | |
296 @@ -164,10 +168,12 @@ | |
297 GFileType file_type = g_file_info_get_file_type (info); | |
298 | |
299 if (file_type == G_FILE_TYPE_DIRECTORY) { | |
300 + GFileEnumerator *dir; | |
301 + | |
302 if (!recurse) | |
303 return TRUE; | |
304 | |
305 - GFileEnumerator *dir = g_file_enumerate_children (file->file, FILE_ATTRS, 0, NULL, error); | |
306 + dir = g_file_enumerate_children (file->file, FILE_ATTRS, 0, NULL, error); | |
307 if (*error) { | |
308 g_warning ("Couldn't enumerate directory %s: %s", name, (*error)->message); | |
309 g_clear_error (error); | |
310 @@ -227,16 +233,19 @@ | |
311 GError **error) | |
312 { | |
313 gboolean success; | |
314 + GFile *gfile; | |
315 | |
316 g_return_val_if_fail (GCAB_IS_FOLDER (self), FALSE); | |
317 g_return_val_if_fail (GCAB_IS_FILE (file), FALSE); | |
318 g_return_val_if_fail (!error || *error == NULL, FALSE); | |
319 | |
320 - GFile *gfile = gcab_file_get_file (file); | |
321 + gfile = gcab_file_get_file (file); | |
322 if (gfile) { | |
323 + GFileInfo *info; | |
324 + | |
325 g_return_val_if_fail (G_IS_FILE (gfile), FALSE); | |
326 | |
327 - GFileInfo *info = g_file_query_info (gfile, FILE_ATTRS, 0, NULL, error); | |
328 + info = g_file_query_info (gfile, FILE_ATTRS, 0, NULL, error); | |
329 if (*error) | |
330 return FALSE; | |
331 | |
332 @@ -351,18 +360,24 @@ | |
333 | |
334 for (f = files; f != NULL; f = f->next) { | |
335 GCabFile *file = f->data; | |
336 + gchar *fname; | |
337 + int i = 0, len; | |
338 + GFile *gfile; | |
339 + GFile *parent; | |
340 + u4 usize; | |
341 + u4 uoffset; | |
342 | |
343 if (file_callback && !file_callback (file, callback_data)) | |
344 continue; | |
345 | |
346 - gchar *fname = g_strdup (gcab_file_get_extract_name (file)); | |
347 - int i = 0, len = strlen (fname); | |
348 + fname = g_strdup (gcab_file_get_extract_name (file)); | |
349 + len = strlen (fname); | |
350 for (i = 0; i < len; i++) | |
351 if (fname[i] == '\\') | |
352 fname[i] = '/'; | |
353 | |
354 - GFile *gfile = g_file_resolve_relative_path (path, fname); | |
355 - GFile *parent = g_file_get_parent (gfile); | |
356 + gfile = g_file_resolve_relative_path (path, fname); | |
357 + parent = g_file_get_parent (gfile); | |
358 g_free (fname); | |
359 | |
360 if (!g_file_make_directory_with_parents (parent, cancellable, &my_error)) { | |
361 @@ -383,8 +398,8 @@ | |
362 if (!out) | |
363 goto end; | |
364 | |
365 - u4 usize = file->cfile.usize; | |
366 - u4 uoffset = file->cfile.uoffset; | |
367 + usize = file->cfile.usize; | |
368 + uoffset = file->cfile.uoffset; | |
369 do { | |
370 if ((nubytes + cdata.nubytes) <= uoffset) { | |
371 nubytes += cdata.nubytes; |