comparison src/msvc-msitools-1.patch @ 3137:98d994cfc408

Add msitools (and MSVC-specific patches)
author Michael Goffioul <michael.goffioul@gmail.com>
date Sat, 13 Jul 2013 23:52:36 -0400
parents
children
comparison
equal deleted inserted replaced
3136:5481abb52912 3137:98d994cfc408
1 diff -urN msitools-0.92-orig/Makefile.in msitools-0.92/Makefile.in
2 --- msitools-0.92-orig/Makefile.in 2013-03-07 15:27:29 -0500
3 +++ msitools-0.92/Makefile.in 2013-07-13 22:25:48 -0400
4 @@ -552,7 +552,7 @@
5 $(NULL)
6
7 wixl_CPPFLAGS = \
8 - -include config.h \
9 + -FI$(top_srcdir)/config.h \
10 -Iinclude \
11 -I$(srcdir)/include \
12 $(WIXL_CFLAGS) \
13 diff -urN msitools-0.92-orig/libmsi/insert.c msitools-0.92/libmsi/insert.c
14 --- msitools-0.92-orig/libmsi/insert.c 2013-02-07 20:04:46 -0500
15 +++ msitools-0.92/libmsi/insert.c 2013-07-13 18:57:31 -0400
16 @@ -65,7 +65,7 @@
17 {
18 if( !vl )
19 {
20 - TRACE("Not enough elements in the list to insert\n");
21 + TRACE("Not enough elements in the list to insert\n", 0);
22 goto err;
23 }
24 switch( vl->val->type )
25 diff -urN msitools-0.92-orig/libmsi/libmsi-database.c msitools-0.92/libmsi/libmsi-database.c
26 --- msitools-0.92-orig/libmsi/libmsi-database.c 2013-02-19 17:24:53 -0500
27 +++ msitools-0.92/libmsi/libmsi-database.c 2013-07-13 19:03:52 -0400
28 @@ -134,8 +134,10 @@
29 static void
30 libmsi_database_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
31 {
32 + LibmsiDatabase *self;
33 +
34 g_return_if_fail (LIBMSI_IS_DATABASE (object));
35 - LibmsiDatabase *self = LIBMSI_DATABASE (object);
36 + self = LIBMSI_DATABASE (object);
37
38 switch (prop_id) {
39 case PROP_PATH:
40 @@ -158,8 +160,10 @@
41 static void
42 libmsi_database_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
43 {
44 + LibmsiDatabase *self;
45 +
46 g_return_if_fail (LIBMSI_IS_DATABASE (object));
47 - LibmsiDatabase *self = LIBMSI_DATABASE (object);
48 + self = LIBMSI_DATABASE (object);
49
50 switch (prop_id) {
51 case PROP_PATH:
52 @@ -1231,6 +1235,7 @@
53 count = libmsi_record_get_field_count (row);
54 for (i = start; i <= count; i++) {
55 char *str;
56 + const char *sep;
57
58 _libmsi_record_get_gsf_input (row, i, &in);
59 if (in) {
60 @@ -1252,7 +1257,7 @@
61
62 g_free (str);
63
64 - const char *sep = (i < count) ? "\t" : "\r\n";
65 + sep = (i < count) ? "\t" : "\r\n";
66 if (write (fd, sep, strlen (sep)) != strlen (sep))
67 goto end;
68 }
69 @@ -1354,6 +1359,8 @@
70 r = _libmsi_query_open( db, &view, query, table );
71 if (r == LIBMSI_RESULT_SUCCESS)
72 {
73 + ExportRow export;
74 +
75 /* write out row 1, the column names */
76 r = _libmsi_query_get_column_info(view, LIBMSI_COL_INFO_NAMES, &rec);
77 if (r == LIBMSI_RESULT_SUCCESS)
78 @@ -1380,11 +1387,9 @@
79 }
80
81 /* write out row 4 onwards, the data */
82 - ExportRow export = {
83 - .fd = fd,
84 - .table_dir = g_file_new_for_path (table),
85 - .error = error
86 - };
87 + export.fd = fd;
88 + export.table_dir = g_file_new_for_path (table);
89 + export.error = error;
90 r = _libmsi_query_iterate_records( view, 0, msi_export_row, &export);
91
92 g_object_unref (export.table_dir);
93 diff -urN msitools-0.92-orig/libmsi/libmsi-istream.c msitools-0.92/libmsi/libmsi-istream.c
94 --- msitools-0.92-orig/libmsi/libmsi-istream.c 2013-02-06 18:00:31 -0500
95 +++ msitools-0.92/libmsi/libmsi-istream.c 2013-07-13 19:04:46 -0400
96 @@ -146,9 +146,10 @@
97 libmsi_istream_new (GsfInput *input)
98 {
99 GsfInput *dup = gsf_input_dup (input, NULL);
100 + LibmsiIStream *self;
101 g_return_val_if_fail (dup, NULL);
102
103 - LibmsiIStream *self = g_object_new (LIBMSI_TYPE_ISTREAM, NULL);
104 + self = g_object_new (LIBMSI_TYPE_ISTREAM, NULL);
105 self->input = dup;
106
107 return self;
108 diff -urN msitools-0.92-orig/libmsi/libmsi-query.c msitools-0.92/libmsi/libmsi-query.c
109 --- msitools-0.92-orig/libmsi/libmsi-query.c 2013-02-11 13:33:02 -0500
110 +++ msitools-0.92/libmsi/libmsi-query.c 2013-07-13 19:05:38 -0400
111 @@ -67,8 +67,10 @@
112 static void
113 libmsi_query_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
114 {
115 + LibmsiQuery *self;
116 +
117 g_return_if_fail (LIBMSI_IS_QUERY (object));
118 - LibmsiQuery *self = LIBMSI_QUERY (object);
119 + self = LIBMSI_QUERY (object);
120
121 switch (prop_id) {
122 case PROP_DATABASE:
123 @@ -88,8 +90,10 @@
124 static void
125 libmsi_query_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
126 {
127 + LibmsiQuery *self;
128 +
129 g_return_if_fail (LIBMSI_IS_QUERY (object));
130 - LibmsiQuery *self = LIBMSI_QUERY (object);
131 + self = LIBMSI_QUERY (object);
132
133 switch (prop_id) {
134 case PROP_DATABASE:
135 diff -urN msitools-0.92-orig/libmsi/libmsi-record.c msitools-0.92/libmsi/libmsi-record.c
136 --- msitools-0.92-orig/libmsi/libmsi-record.c 2013-02-07 20:04:17 -0500
137 +++ msitools-0.92/libmsi/libmsi-record.c 2013-07-13 19:07:00 -0400
138 @@ -85,8 +85,10 @@
139 static void
140 libmsi_record_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
141 {
142 + LibmsiRecord *self;
143 +
144 g_return_if_fail (LIBMSI_IS_RECORD (object));
145 - LibmsiRecord *self = LIBMSI_RECORD (object);
146 + self = LIBMSI_RECORD (object);
147
148 switch (prop_id) {
149 case PROP_COUNT:
150 @@ -101,8 +103,10 @@
151 static void
152 libmsi_record_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
153 {
154 + LibmsiRecord *self;
155 +
156 g_return_if_fail (LIBMSI_IS_RECORD (object));
157 - LibmsiRecord *self = LIBMSI_RECORD (object);
158 + self = LIBMSI_RECORD (object);
159
160 switch (prop_id) {
161 case PROP_COUNT:
162 @@ -601,6 +605,10 @@
163 GInputStream *input, gsize count,
164 GCancellable *cancellable, GError **error)
165 {
166 + gsize bytes_read = 0;
167 + GsfInput *stm = NULL;
168 + guint8 *data;
169 +
170 g_return_val_if_fail (LIBMSI_IS_RECORD (rec), FALSE);
171 g_return_val_if_fail (G_IS_INPUT_STREAM (input), FALSE);
172 g_return_val_if_fail (field > 0 && field <= rec->count, FALSE);
173 @@ -608,9 +616,7 @@
174 g_return_val_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable), FALSE);
175 g_return_val_if_fail (!error || *error == NULL, FALSE);
176
177 - gsize bytes_read = 0;
178 - GsfInput *stm = NULL;
179 - guint8 *data = g_malloc (count);
180 + data = g_malloc (count);
181
182 if (!g_input_stream_read_all (input, data, count, &bytes_read,
183 cancellable, error) ||
184 diff -urN msitools-0.92-orig/libmsi/libmsi-summary-info.c msitools-0.92/libmsi/libmsi-summary-info.c
185 --- msitools-0.92-orig/libmsi/libmsi-summary-info.c 2013-02-07 20:17:23 -0500
186 +++ msitools-0.92/libmsi/libmsi-summary-info.c 2013-07-13 19:18:27 -0400
187 @@ -76,8 +76,10 @@
188 static void
189 summary_info_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
190 {
191 + LibmsiSummaryInfo *self;
192 +
193 g_return_if_fail (LIBMSI_IS_SUMMARY_INFO (object));
194 - LibmsiSummaryInfo *self = LIBMSI_SUMMARY_INFO (object);
195 + self = LIBMSI_SUMMARY_INFO (object);
196
197 switch (prop_id) {
198 case PROP_DATABASE:
199 @@ -96,8 +98,10 @@
200 static void
201 summary_info_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
202 {
203 + LibmsiSummaryInfo *self;
204 +
205 g_return_if_fail (LIBMSI_IS_SUMMARY_INFO (object));
206 - LibmsiSummaryInfo *self = LIBMSI_SUMMARY_INFO (object);
207 + self = LIBMSI_SUMMARY_INFO (object);
208
209 switch (prop_id) {
210 case PROP_DATABASE:
211 @@ -244,19 +248,19 @@
212
213 static gchar* filetime_to_string (guint64 ft)
214 {
215 - struct tm tm;
216 + struct tm *tm;
217 time_t t;
218
219 ft /= 10000000ULL;
220 ft -= 134774ULL * 86400ULL;
221 t = ft;
222
223 - if (!gmtime_r (&t, &tm))
224 + if (!(tm = gmtime (&t)))
225 return NULL;
226
227 return g_strdup_printf ("%d/%d/%d %d:%d:%d",
228 - tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
229 - tm.tm_hour, tm.tm_min, tm.tm_sec);
230 + tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
231 + tm->tm_hour, tm->tm_min, tm->tm_sec);
232 }
233
234 static void parse_filetime( const char *str, guint64 *ft )
235 diff -urN msitools-0.92-orig/libmsi/string.c msitools-0.92/libmsi/string.c
236 --- msitools-0.92-orig/libmsi/string.c 2013-02-07 20:07:52 -0500
237 +++ msitools-0.92/libmsi/string.c 2013-07-13 19:11:26 -0400
238 @@ -562,7 +562,7 @@
239 char *data = NULL;
240 uint8_t *pool = NULL;
241
242 - TRACE("\n");
243 + TRACE("\n", 0);
244
245 /* construct the new table in memory first */
246 string_totalsize( st, &datasize, &poolsize );
247 diff -urN msitools-0.92-orig/libmsi/table.c msitools-0.92/libmsi/table.c
248 --- msitools-0.92-orig/libmsi/table.c 2013-02-19 17:24:53 -0500
249 +++ msitools-0.92/libmsi/table.c 2013-07-13 20:00:12 -0400
250 @@ -27,6 +27,10 @@
251
252 #include "debug.h"
253
254 +#ifdef _MSC_VER
255 +#include <intrin.h>
256 +#endif
257 +
258
259 #define LibmsiTable_HASH_TABLE_SIZE 37
260
261 @@ -263,7 +267,7 @@
262 msi_free(encname);
263 if( !stm )
264 {
265 - TRACE("open stream failed - empty table?\n");
266 + TRACE("open stream failed - empty table?\n", 0);
267 return ret;
268 }
269
270 @@ -1527,7 +1531,7 @@
271 continue;
272
273 if ( MSITYPE_IS_BINARY(tv->columns[i].type) )
274 - TRACE("skipping binary column\n");
275 + TRACE("skipping binary column\n", 0);
276 else if ( tv->columns[i].type & MSITYPE_STRING )
277 {
278 const char *str;
279 @@ -1792,10 +1796,18 @@
280 for (i = 0; i < tv->table->col_count; i++)
281 {
282 if (tv->table->colinfo[i].type & MSITYPE_TEMPORARY)
283 +#ifdef _MSC_VER
284 + _InterlockedIncrement((long*)(&tv->table->colinfo[i].ref_count));
285 +#else
286 __sync_add_and_fetch(&tv->table->colinfo[i].ref_count, 1);
287 +#endif
288 }
289
290 +#ifdef _MSC_VER
291 + return _InterlockedIncrement((long*)(&tv->table->ref_count));
292 +#else
293 return __sync_add_and_fetch(&tv->table->ref_count, 1);
294 +#endif
295 }
296
297 static unsigned table_view_remove_column(LibmsiView *view, const char *table, unsigned number)
298 @@ -1844,7 +1856,11 @@
299 {
300 if (tv->table->colinfo[i].type & MSITYPE_TEMPORARY)
301 {
302 +#ifdef _MSC_VER
303 + ref = _InterlockedDecrement((long*)(&tv->table->colinfo[i].ref_count));
304 +#else
305 ref = __sync_sub_and_fetch(&tv->table->colinfo[i].ref_count, 1);
306 +#endif
307 if (ref == 0)
308 {
309 r = table_view_remove_column(view, tv->table->colinfo[i].tablename,
310 @@ -1855,7 +1871,11 @@
311 }
312 }
313
314 +#ifdef _MSC_VER
315 + ref = _InterlockedDecrement((long*)(&tv->table->ref_count));
316 +#else
317 ref = __sync_sub_and_fetch(&tv->table->ref_count, 1);
318 +#endif
319 if (ref == 0)
320 {
321 if (!tv->table->row_count)
322 @@ -1900,7 +1920,11 @@
323 {
324 if (!strcmp( msitable->colinfo[i].colname, column ))
325 {
326 +#ifdef _MSC_VER
327 + _InterlockedIncrement((long*)(&msitable->colinfo[i].ref_count));
328 +#else
329 __sync_add_and_fetch(&msitable->colinfo[i].ref_count, 1);
330 +#endif
331 break;
332 }
333 }
334 @@ -2157,7 +2181,7 @@
335 if( !rec )
336 return rec;
337
338 - TRACE("row ->\n");
339 + TRACE("row ->\n", 0);
340 for( i=0; i<tv->num_cols; i++ )
341 {
342 if ( (mask&1) && (i>=(mask>>8)) )
343 @@ -2236,7 +2260,7 @@
344 const char *sval;
345
346 if( libmsi_record_is_null( rec, i ) )
347 - TRACE("row -> []\n");
348 + TRACE("row -> []\n", 0);
349 else if( (sval = _libmsi_record_get_string_raw( rec, i )) )
350 TRACE("row -> [%s]\n", debugstr_a(sval));
351 else
352 @@ -2511,7 +2535,7 @@
353 }
354 else
355 {
356 - TRACE("inserting row\n");
357 + TRACE("inserting row\n", 0);
358 r = table_view_insert_row( &tv->view, rec, -1, false );
359 if (r != LIBMSI_RESULT_SUCCESS)
360 g_warning("failed to insert row %u\n", r);
361 diff -urN msitools-0.92-orig/tools/msibuild.c msitools-0.92/tools/msibuild.c
362 --- msitools-0.92-orig/tools/msibuild.c 2013-02-07 19:48:42 -0500
363 +++ msitools-0.92/tools/msibuild.c 2013-07-13 21:38:48 -0400
364 @@ -26,7 +26,11 @@
365 #include <sys/stat.h>
366 #include <libmsi.h>
367 #include <limits.h>
368 +#ifdef _MSC_VER
369 +#include <uuid-win32.h>
370 +#else
371 #include <uuid.h>
372 +#endif
373
374 #include "sqldelim.h"
375
376 diff -urN msitools-0.92-orig/tools/msiinfo.c msitools-0.92/tools/msiinfo.c
377 --- msitools-0.92-orig/tools/msiinfo.c 2013-02-07 19:58:42 -0500
378 +++ msitools-0.92/tools/msiinfo.c 2013-07-13 22:08:12 -0400
379 @@ -34,6 +34,15 @@
380 #include <fcntl.h>
381 #include <limits.h>
382
383 +#ifdef _MSC_VER
384 +# ifndef ssize_t
385 + typedef int ssize_t;
386 +# endif
387 +# ifndef STDOUT_FILENO
388 +# define STDOUT_FILENO 1
389 +# endif
390 +#endif
391 +
392 struct Command {
393 const char *cmd;
394 const char *desc;
395 @@ -43,7 +52,7 @@
396 int (*func)(struct Command *cmd, int argc, char **argv, GError **error);
397 };
398
399 -static struct Command cmds[];
400 +static struct Command *cmds;
401
402 static void usage(FILE *out)
403 {
404 @@ -690,67 +699,97 @@
405 return 0;
406 }
407
408 -static struct Command cmds[] = {
409 +static struct Command _cmds[] = {
410 {
411 - .cmd = "help",
412 - .opts = "[SUBCOMMAND]",
413 - .desc = "Show program or subcommand usage",
414 - .func = cmd_help,
415 + "help",
416 + "Show program or subcommand usage",
417 + 0,
418 + "[SUBCOMMAND]",
419 + 0,
420 + cmd_help
421 },
422 {
423 - .cmd = "streams",
424 - .opts = "FILE",
425 - .desc = "List streams in a .msi file",
426 - .func = cmd_streams,
427 + "streams",
428 + "List streams in a .msi file",
429 + 0,
430 + "FILE",
431 + 0,
432 + cmd_streams
433 },
434 {
435 - .cmd = "tables",
436 - .opts = "FILE",
437 - .desc = "List tables in a .msi file",
438 - .func = cmd_tables,
439 + "tables",
440 + "List tables in a .msi file",
441 + 0,
442 + "FILE",
443 + 0,
444 + cmd_tables
445 },
446 {
447 - .cmd = "extract",
448 - .opts = "FILE STREAM",
449 - .desc = "Extract a binary stream from an .msi file",
450 - .func = cmd_extract,
451 + "extract",
452 + "Extract a binary stream from an .msi file",
453 + 0,
454 + "FILE STREAM",
455 + 0,
456 + cmd_extract
457 },
458 {
459 - .cmd = "export",
460 - .opts = "[-s] FILE TABLE\n\nOptions:\n"
461 - " -s Format output as an SQL query",
462 - .desc = "Export a table in text form from an .msi file",
463 - .func = cmd_export,
464 + "export",
465 + "Export a table in text form from an .msi file",
466 + 0,
467 + "[-s] FILE TABLE\n\nOptions:\n"
468 + " -s Format output as an SQL query",
469 + 0,
470 + cmd_export
471 },
472 {
473 - .cmd = "suminfo",
474 - .opts = "FILE",
475 - .desc = "Print summary information",
476 - .func = cmd_suminfo,
477 + "suminfo",
478 + "Print summary information",
479 + 0,
480 + "FILE",
481 + 0,
482 + cmd_suminfo
483 },
484 {
485 - .cmd = "-h",
486 - .func = cmd_help,
487 + "-h",
488 + 0,
489 + 0,
490 + 0,
491 + 0,
492 + cmd_help
493 },
494 {
495 - .cmd = "--help",
496 - .func = cmd_help,
497 + "--help",
498 + 0,
499 + 0,
500 + 0,
501 + 0,
502 + cmd_help
503 },
504 {
505 - .cmd = "-v",
506 - .func = cmd_version
507 + "-v",
508 + 0,
509 + 0,
510 + 0,
511 + 0,
512 + cmd_version
513 },
514 {
515 - .cmd = "--version",
516 - .func = cmd_version
517 + "--version",
518 + 0,
519 + 0,
520 + 0,
521 + 0,
522 + cmd_version
523 },
524 { NULL },
525 };
526 +static struct Command *cmds = _cmds;
527
528 int main(int argc, char **argv)
529 {
530 GError *error = NULL;
531 struct Command *cmd = NULL;
532 + int result;
533
534 #if !GLIB_CHECK_VERSION(2,35,1)
535 g_type_init ();
536 @@ -767,7 +806,7 @@
537 usage(stderr);
538 }
539
540 - int result = cmd->func(cmd, argc - 1, argv + 1, &error);
541 + result = cmd->func(cmd, argc - 1, argv + 1, &error);
542 if (error != NULL) {
543 g_printerr("error: %s\n", error->message);
544 print_libmsi_error(error->code);
545 diff -urN msitools-0.92-orig/tools/wixl/util.c msitools-0.92/tools/wixl/util.c
546 --- msitools-0.92-orig/tools/wixl/util.c 2013-03-07 15:28:12 -0500
547 +++ msitools-0.92/tools/wixl/util.c 2013-07-13 22:33:52 -0400
548 @@ -82,6 +82,9 @@
549 static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
550 static gint _vala_array_length (gpointer array);
551
552 +#ifdef _MSC_VER
553 +# include <uuid-win32.h>
554 +#endif
555
556 GQuark wixl_error_quark (void) {
557 return g_quark_from_static_string ("wixl_error-quark");
558 diff -urN msitools-0.92-orig/uuid-win32.h msitools-0.92/uuid-win32.h
559 --- msitools-0.92-orig/uuid-win32.h 1969-12-31 19:00:00 -0500
560 +++ msitools-0.92/uuid-win32.h 2013-07-13 22:50:42 -0400
561 @@ -0,0 +1,18 @@
562 +#ifndef __UUID_WIN32_H__
563 +#define __UUID_WIN32_H__
564 +
565 +#include <rpc.h>
566 +
567 +typedef UUID uuid_t;
568 +
569 +#define uuid_generate(uu) UuidCreate(&(uu))
570 +#define uuid_unparse(uu,str) \
571 + do { \
572 + RPC_CSTR __buf__; \
573 + UuidToString(&(uu), &__buf__); \
574 + strcpy(str, __buf__); \
575 + RpcStringFree(&__buf__); \
576 + } while (0)
577 +#define uuid_unparse_upper uuid_unparse
578 +
579 +#endif /* __UUID_WIN32_H__ */