diff 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
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/src/msvc-msitools-1.patch	Sat Jul 13 23:52:36 2013 -0400
@@ -0,0 +1,579 @@
+diff -urN msitools-0.92-orig/Makefile.in msitools-0.92/Makefile.in
+--- msitools-0.92-orig/Makefile.in	2013-03-07 15:27:29 -0500
++++ msitools-0.92/Makefile.in	2013-07-13 22:25:48 -0400
+@@ -552,7 +552,7 @@
+ 	$(NULL)
+ 
+ wixl_CPPFLAGS = \
+-	-include config.h			\
++	-FI$(top_srcdir)/config.h		\
+ 	-Iinclude				\
+ 	-I$(srcdir)/include			\
+ 	$(WIXL_CFLAGS)				\
+diff -urN msitools-0.92-orig/libmsi/insert.c msitools-0.92/libmsi/insert.c
+--- msitools-0.92-orig/libmsi/insert.c	2013-02-07 20:04:46 -0500
++++ msitools-0.92/libmsi/insert.c	2013-07-13 18:57:31 -0400
+@@ -65,7 +65,7 @@
+     {
+         if( !vl )
+         {
+-            TRACE("Not enough elements in the list to insert\n");
++            TRACE("Not enough elements in the list to insert\n", 0);
+             goto err;
+         }
+         switch( vl->val->type )
+diff -urN msitools-0.92-orig/libmsi/libmsi-database.c msitools-0.92/libmsi/libmsi-database.c
+--- msitools-0.92-orig/libmsi/libmsi-database.c	2013-02-19 17:24:53 -0500
++++ msitools-0.92/libmsi/libmsi-database.c	2013-07-13 19:03:52 -0400
+@@ -134,8 +134,10 @@
+ static void
+ libmsi_database_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+ {
++    LibmsiDatabase *self;
++
+     g_return_if_fail (LIBMSI_IS_DATABASE (object));
+-    LibmsiDatabase *self = LIBMSI_DATABASE (object);
++    self = LIBMSI_DATABASE (object);
+ 
+     switch (prop_id) {
+     case PROP_PATH:
+@@ -158,8 +160,10 @@
+ static void
+ libmsi_database_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+ {
++    LibmsiDatabase *self;
++
+     g_return_if_fail (LIBMSI_IS_DATABASE (object));
+-    LibmsiDatabase *self = LIBMSI_DATABASE (object);
++    self = LIBMSI_DATABASE (object);
+ 
+     switch (prop_id) {
+     case PROP_PATH:
+@@ -1231,6 +1235,7 @@
+     count = libmsi_record_get_field_count (row);
+     for (i = start; i <= count; i++) {
+         char *str;
++        const char *sep;
+ 
+         _libmsi_record_get_gsf_input (row, i, &in);
+         if (in) {
+@@ -1252,7 +1257,7 @@
+ 
+         g_free (str);
+ 
+-        const char *sep = (i < count) ? "\t" : "\r\n";
++        sep = (i < count) ? "\t" : "\r\n";
+         if (write (fd, sep, strlen (sep)) != strlen (sep))
+             goto end;
+     }
+@@ -1354,6 +1359,8 @@
+     r = _libmsi_query_open( db, &view, query, table );
+     if (r == LIBMSI_RESULT_SUCCESS)
+     {
++        ExportRow export;
++
+         /* write out row 1, the column names */
+         r = _libmsi_query_get_column_info(view, LIBMSI_COL_INFO_NAMES, &rec);
+         if (r == LIBMSI_RESULT_SUCCESS)
+@@ -1380,11 +1387,9 @@
+         }
+ 
+         /* write out row 4 onwards, the data */
+-        ExportRow export = {
+-            .fd = fd,
+-            .table_dir = g_file_new_for_path (table),
+-            .error = error
+-        };
++        export.fd = fd;
++        export.table_dir = g_file_new_for_path (table);
++        export.error = error;
+         r = _libmsi_query_iterate_records( view, 0, msi_export_row, &export);
+ 
+         g_object_unref (export.table_dir);
+diff -urN msitools-0.92-orig/libmsi/libmsi-istream.c msitools-0.92/libmsi/libmsi-istream.c
+--- msitools-0.92-orig/libmsi/libmsi-istream.c	2013-02-06 18:00:31 -0500
++++ msitools-0.92/libmsi/libmsi-istream.c	2013-07-13 19:04:46 -0400
+@@ -146,9 +146,10 @@
+ libmsi_istream_new (GsfInput *input)
+ {
+     GsfInput *dup = gsf_input_dup (input, NULL);
++    LibmsiIStream *self;
+     g_return_val_if_fail (dup, NULL);
+ 
+-    LibmsiIStream *self = g_object_new (LIBMSI_TYPE_ISTREAM, NULL);
++    self = g_object_new (LIBMSI_TYPE_ISTREAM, NULL);
+     self->input = dup;
+ 
+     return self;
+diff -urN msitools-0.92-orig/libmsi/libmsi-query.c msitools-0.92/libmsi/libmsi-query.c
+--- msitools-0.92-orig/libmsi/libmsi-query.c	2013-02-11 13:33:02 -0500
++++ msitools-0.92/libmsi/libmsi-query.c	2013-07-13 19:05:38 -0400
+@@ -67,8 +67,10 @@
+ static void
+ libmsi_query_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+ {
++    LibmsiQuery *self;
++
+     g_return_if_fail (LIBMSI_IS_QUERY (object));
+-    LibmsiQuery *self = LIBMSI_QUERY (object);
++    self = LIBMSI_QUERY (object);
+ 
+     switch (prop_id) {
+     case PROP_DATABASE:
+@@ -88,8 +90,10 @@
+ static void
+ libmsi_query_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+ {
++    LibmsiQuery *self;
++
+     g_return_if_fail (LIBMSI_IS_QUERY (object));
+-    LibmsiQuery *self = LIBMSI_QUERY (object);
++    self = LIBMSI_QUERY (object);
+ 
+     switch (prop_id) {
+     case PROP_DATABASE:
+diff -urN msitools-0.92-orig/libmsi/libmsi-record.c msitools-0.92/libmsi/libmsi-record.c
+--- msitools-0.92-orig/libmsi/libmsi-record.c	2013-02-07 20:04:17 -0500
++++ msitools-0.92/libmsi/libmsi-record.c	2013-07-13 19:07:00 -0400
+@@ -85,8 +85,10 @@
+ static void
+ libmsi_record_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+ {
++    LibmsiRecord *self;
++
+     g_return_if_fail (LIBMSI_IS_RECORD (object));
+-    LibmsiRecord *self = LIBMSI_RECORD (object);
++    self = LIBMSI_RECORD (object);
+ 
+     switch (prop_id) {
+     case PROP_COUNT:
+@@ -101,8 +103,10 @@
+ static void
+ libmsi_record_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+ {
++    LibmsiRecord *self;
++
+     g_return_if_fail (LIBMSI_IS_RECORD (object));
+-    LibmsiRecord *self = LIBMSI_RECORD (object);
++    self = LIBMSI_RECORD (object);
+ 
+     switch (prop_id) {
+     case PROP_COUNT:
+@@ -601,6 +605,10 @@
+                           GInputStream *input, gsize count,
+                           GCancellable *cancellable, GError **error)
+ {
++    gsize bytes_read = 0;
++    GsfInput *stm = NULL;
++    guint8 *data;
++
+     g_return_val_if_fail (LIBMSI_IS_RECORD (rec), FALSE);
+     g_return_val_if_fail (G_IS_INPUT_STREAM (input), FALSE);
+     g_return_val_if_fail (field > 0 && field <= rec->count, FALSE);
+@@ -608,9 +616,7 @@
+     g_return_val_if_fail (!cancellable || G_IS_CANCELLABLE (cancellable), FALSE);
+     g_return_val_if_fail (!error || *error == NULL, FALSE);
+ 
+-    gsize bytes_read = 0;
+-    GsfInput *stm = NULL;
+-    guint8 *data = g_malloc (count);
++    data = g_malloc (count);
+ 
+     if (!g_input_stream_read_all (input, data, count, &bytes_read,
+                                   cancellable, error) ||
+diff -urN msitools-0.92-orig/libmsi/libmsi-summary-info.c msitools-0.92/libmsi/libmsi-summary-info.c
+--- msitools-0.92-orig/libmsi/libmsi-summary-info.c	2013-02-07 20:17:23 -0500
++++ msitools-0.92/libmsi/libmsi-summary-info.c	2013-07-13 19:18:27 -0400
+@@ -76,8 +76,10 @@
+ static void
+ summary_info_set_property (GObject *object, guint prop_id, const GValue *value, GParamSpec *pspec)
+ {
++    LibmsiSummaryInfo *self;
++
+     g_return_if_fail (LIBMSI_IS_SUMMARY_INFO (object));
+-    LibmsiSummaryInfo *self = LIBMSI_SUMMARY_INFO (object);
++    self = LIBMSI_SUMMARY_INFO (object);
+ 
+     switch (prop_id) {
+     case PROP_DATABASE:
+@@ -96,8 +98,10 @@
+ static void
+ summary_info_get_property (GObject *object, guint prop_id, GValue *value, GParamSpec *pspec)
+ {
++    LibmsiSummaryInfo *self;
++
+     g_return_if_fail (LIBMSI_IS_SUMMARY_INFO (object));
+-    LibmsiSummaryInfo *self = LIBMSI_SUMMARY_INFO (object);
++    self = LIBMSI_SUMMARY_INFO (object);
+ 
+     switch (prop_id) {
+     case PROP_DATABASE:
+@@ -244,19 +248,19 @@
+ 
+ static gchar* filetime_to_string (guint64 ft)
+ {
+-    struct tm tm;
++    struct tm *tm;
+     time_t t;
+ 
+     ft /= 10000000ULL;
+     ft -= 134774ULL * 86400ULL;
+     t = ft;
+ 
+-    if (!gmtime_r (&t, &tm))
++    if (!(tm = gmtime (&t)))
+         return NULL;
+ 
+     return g_strdup_printf ("%d/%d/%d %d:%d:%d",
+-                            tm.tm_year + 1900, tm.tm_mon + 1, tm.tm_mday,
+-                            tm.tm_hour, tm.tm_min, tm.tm_sec);
++                            tm->tm_year + 1900, tm->tm_mon + 1, tm->tm_mday,
++                            tm->tm_hour, tm->tm_min, tm->tm_sec);
+ }
+ 
+ static void parse_filetime( const char *str, guint64 *ft )
+diff -urN msitools-0.92-orig/libmsi/string.c msitools-0.92/libmsi/string.c
+--- msitools-0.92-orig/libmsi/string.c	2013-02-07 20:07:52 -0500
++++ msitools-0.92/libmsi/string.c	2013-07-13 19:11:26 -0400
+@@ -562,7 +562,7 @@
+     char *data = NULL;
+     uint8_t *pool = NULL;
+ 
+-    TRACE("\n");
++    TRACE("\n", 0);
+ 
+     /* construct the new table in memory first */
+     string_totalsize( st, &datasize, &poolsize );
+diff -urN msitools-0.92-orig/libmsi/table.c msitools-0.92/libmsi/table.c
+--- msitools-0.92-orig/libmsi/table.c	2013-02-19 17:24:53 -0500
++++ msitools-0.92/libmsi/table.c	2013-07-13 20:00:12 -0400
+@@ -27,6 +27,10 @@
+ 
+ #include "debug.h"
+ 
++#ifdef _MSC_VER
++#include <intrin.h>
++#endif
++
+ 
+ #define LibmsiTable_HASH_TABLE_SIZE 37
+ 
+@@ -263,7 +267,7 @@
+     msi_free(encname);
+     if( !stm )
+     {
+-        TRACE("open stream failed - empty table?\n");
++        TRACE("open stream failed - empty table?\n", 0);
+         return ret;
+     }
+ 
+@@ -1527,7 +1531,7 @@
+             continue;
+ 
+         if ( MSITYPE_IS_BINARY(tv->columns[i].type) )
+-            TRACE("skipping binary column\n");
++            TRACE("skipping binary column\n", 0);
+         else if ( tv->columns[i].type & MSITYPE_STRING )
+         {
+             const char *str;
+@@ -1792,10 +1796,18 @@
+     for (i = 0; i < tv->table->col_count; i++)
+     {
+         if (tv->table->colinfo[i].type & MSITYPE_TEMPORARY)
++#ifdef _MSC_VER
++            _InterlockedIncrement((long*)(&tv->table->colinfo[i].ref_count));
++#else
+             __sync_add_and_fetch(&tv->table->colinfo[i].ref_count, 1);
++#endif
+     }
+ 
++#ifdef _MSC_VER
++    return _InterlockedIncrement((long*)(&tv->table->ref_count));
++#else
+     return __sync_add_and_fetch(&tv->table->ref_count, 1);
++#endif
+ }
+ 
+ static unsigned table_view_remove_column(LibmsiView *view, const char *table, unsigned number)
+@@ -1844,7 +1856,11 @@
+     {
+         if (tv->table->colinfo[i].type & MSITYPE_TEMPORARY)
+         {
++#ifdef _MSC_VER
++            ref = _InterlockedDecrement((long*)(&tv->table->colinfo[i].ref_count));
++#else
+             ref = __sync_sub_and_fetch(&tv->table->colinfo[i].ref_count, 1);
++#endif
+             if (ref == 0)
+             {
+                 r = table_view_remove_column(view, tv->table->colinfo[i].tablename,
+@@ -1855,7 +1871,11 @@
+         }
+     }
+ 
++#ifdef _MSC_VER
++    ref = _InterlockedDecrement((long*)(&tv->table->ref_count));
++#else
+     ref = __sync_sub_and_fetch(&tv->table->ref_count, 1);
++#endif
+     if (ref == 0)
+     {
+         if (!tv->table->row_count)
+@@ -1900,7 +1920,11 @@
+     {
+         if (!strcmp( msitable->colinfo[i].colname, column ))
+         {
++#ifdef _MSC_VER
++            _InterlockedIncrement((long*)(&msitable->colinfo[i].ref_count));
++#else
+             __sync_add_and_fetch(&msitable->colinfo[i].ref_count, 1);
++#endif
+             break;
+         }
+     }
+@@ -2157,7 +2181,7 @@
+     if( !rec )
+         return rec;
+ 
+-    TRACE("row ->\n");
++    TRACE("row ->\n", 0);
+     for( i=0; i<tv->num_cols; i++ )
+     {
+         if ( (mask&1) && (i>=(mask>>8)) )
+@@ -2236,7 +2260,7 @@
+         const char *sval;
+ 
+         if( libmsi_record_is_null( rec, i ) )
+-            TRACE("row -> []\n");
++            TRACE("row -> []\n", 0);
+         else if( (sval = _libmsi_record_get_string_raw( rec, i )) )
+             TRACE("row -> [%s]\n", debugstr_a(sval));
+         else
+@@ -2511,7 +2535,7 @@
+             }
+             else
+             {
+-                TRACE("inserting row\n");
++                TRACE("inserting row\n", 0);
+                 r = table_view_insert_row( &tv->view, rec, -1, false );
+                 if (r != LIBMSI_RESULT_SUCCESS)
+                     g_warning("failed to insert row %u\n", r);
+diff -urN msitools-0.92-orig/tools/msibuild.c msitools-0.92/tools/msibuild.c
+--- msitools-0.92-orig/tools/msibuild.c	2013-02-07 19:48:42 -0500
++++ msitools-0.92/tools/msibuild.c	2013-07-13 21:38:48 -0400
+@@ -26,7 +26,11 @@
+ #include <sys/stat.h>
+ #include <libmsi.h>
+ #include <limits.h>
++#ifdef _MSC_VER
++#include <uuid-win32.h>
++#else
+ #include <uuid.h>
++#endif
+ 
+ #include "sqldelim.h"
+ 
+diff -urN msitools-0.92-orig/tools/msiinfo.c msitools-0.92/tools/msiinfo.c
+--- msitools-0.92-orig/tools/msiinfo.c	2013-02-07 19:58:42 -0500
++++ msitools-0.92/tools/msiinfo.c	2013-07-13 22:08:12 -0400
+@@ -34,6 +34,15 @@
+ #include <fcntl.h>
+ #include <limits.h>
+ 
++#ifdef _MSC_VER
++#  ifndef ssize_t
++     typedef int ssize_t;
++#  endif
++#  ifndef STDOUT_FILENO
++#    define STDOUT_FILENO 1
++#  endif
++#endif
++
+ struct Command {
+     const char *cmd;
+     const char *desc;
+@@ -43,7 +52,7 @@
+     int (*func)(struct Command *cmd, int argc, char **argv, GError **error);
+ };
+ 
+-static struct Command cmds[];
++static struct Command *cmds;
+ 
+ static void usage(FILE *out)
+ {
+@@ -690,67 +699,97 @@
+     return 0;
+ }
+ 
+-static struct Command cmds[] = {
++static struct Command _cmds[] = {
+     {
+-        .cmd = "help",
+-        .opts = "[SUBCOMMAND]",
+-        .desc = "Show program or subcommand usage",
+-        .func = cmd_help,
++        "help",
++        "Show program or subcommand usage",
++        0,
++        "[SUBCOMMAND]",
++        0,
++        cmd_help
+     },
+     {
+-        .cmd = "streams",
+-        .opts = "FILE",
+-        .desc = "List streams in a .msi file",
+-        .func = cmd_streams,
++        "streams",
++        "List streams in a .msi file",
++        0,
++        "FILE",
++        0,
++        cmd_streams
+     },
+     {
+-        .cmd = "tables",
+-        .opts = "FILE",
+-        .desc = "List tables in a .msi file",
+-        .func = cmd_tables,
++        "tables",
++        "List tables in a .msi file",
++        0,
++        "FILE",
++        0,
++        cmd_tables
+     },
+     {
+-        .cmd = "extract",
+-        .opts = "FILE STREAM",
+-        .desc = "Extract a binary stream from an .msi file",
+-        .func = cmd_extract,
++        "extract",
++        "Extract a binary stream from an .msi file",
++        0,
++        "FILE STREAM",
++        0,
++        cmd_extract
+     },
+     {
+-        .cmd = "export",
+-        .opts = "[-s] FILE TABLE\n\nOptions:\n"
+-                "  -s                Format output as an SQL query",
+-        .desc = "Export a table in text form from an .msi file",
+-        .func = cmd_export,
++        "export",
++        "Export a table in text form from an .msi file",
++        0,
++        "[-s] FILE TABLE\n\nOptions:\n"
++        "  -s                Format output as an SQL query",
++        0,
++        cmd_export
+     },
+     {
+-        .cmd = "suminfo",
+-        .opts = "FILE",
+-        .desc = "Print summary information",
+-        .func = cmd_suminfo,
++        "suminfo",
++        "Print summary information",
++        0,
++        "FILE",
++        0,
++        cmd_suminfo
+     },
+     {
+-        .cmd = "-h",
+-        .func = cmd_help,
++        "-h",
++        0,
++        0,
++        0,
++        0,
++        cmd_help
+     },
+     {
+-        .cmd = "--help",
+-        .func = cmd_help,
++        "--help",
++        0,
++        0,
++        0,
++        0,
++        cmd_help
+     },
+     {
+-        .cmd = "-v",
+-        .func = cmd_version
++        "-v",
++        0,
++        0,
++        0,
++        0,
++        cmd_version
+     },
+     {
+-        .cmd = "--version",
+-        .func = cmd_version
++        "--version",
++        0,
++        0,
++        0,
++        0,
++        cmd_version
+     },
+     { NULL },
+ };
++static struct Command *cmds = _cmds;
+ 
+ int main(int argc, char **argv)
+ {
+     GError *error = NULL;
+     struct Command *cmd = NULL;
++    int result;
+ 
+ #if !GLIB_CHECK_VERSION(2,35,1)
+     g_type_init ();
+@@ -767,7 +806,7 @@
+         usage(stderr);
+     }
+ 
+-    int result = cmd->func(cmd, argc - 1, argv + 1, &error);
++    result = cmd->func(cmd, argc - 1, argv + 1, &error);
+     if (error != NULL) {
+         g_printerr("error: %s\n", error->message);
+         print_libmsi_error(error->code);
+diff -urN msitools-0.92-orig/tools/wixl/util.c msitools-0.92/tools/wixl/util.c
+--- msitools-0.92-orig/tools/wixl/util.c	2013-03-07 15:28:12 -0500
++++ msitools-0.92/tools/wixl/util.c	2013-07-13 22:33:52 -0400
+@@ -82,6 +82,9 @@
+ static void _vala_array_free (gpointer array, gint array_length, GDestroyNotify destroy_func);
+ static gint _vala_array_length (gpointer array);
+ 
++#ifdef _MSC_VER
++#  include <uuid-win32.h>
++#endif
+ 
+ GQuark wixl_error_quark (void) {
+ 	return g_quark_from_static_string ("wixl_error-quark");
+diff -urN msitools-0.92-orig/uuid-win32.h msitools-0.92/uuid-win32.h
+--- msitools-0.92-orig/uuid-win32.h	1969-12-31 19:00:00 -0500
++++ msitools-0.92/uuid-win32.h	2013-07-13 22:50:42 -0400
+@@ -0,0 +1,18 @@
++#ifndef __UUID_WIN32_H__
++#define __UUID_WIN32_H__
++
++#include <rpc.h>
++
++typedef UUID uuid_t;
++
++#define uuid_generate(uu) UuidCreate(&(uu))
++#define uuid_unparse(uu,str) \
++        do { \
++                RPC_CSTR __buf__; \
++                UuidToString(&(uu), &__buf__); \
++                strcpy(str, __buf__); \
++                RpcStringFree(&__buf__); \
++        } while (0)
++#define uuid_unparse_upper uuid_unparse
++
++#endif /* __UUID_WIN32_H__ */