summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
Diffstat (limited to 'tools')
-rw-r--r--tools/msibuild.c123
-rw-r--r--tools/msiinfo.c25
2 files changed, 85 insertions, 63 deletions
diff --git a/tools/msibuild.c b/tools/msibuild.c
index 3f5d318..28d55a1 100644
--- a/tools/msibuild.c
+++ b/tools/msibuild.c
@@ -32,26 +32,35 @@
#include "sqldelim.h"
-static void init_suminfo(LibmsiSummaryInfo *si)
+static gboolean init_suminfo(LibmsiSummaryInfo *si, GError **error)
{
- libmsi_summary_info_set_property(si, LIBMSI_PROPERTY_TITLE,
- LIBMSI_PROPERTY_TYPE_STRING, 0, NULL,
- "Installation Database");
- libmsi_summary_info_set_property(si, LIBMSI_PROPERTY_KEYWORDS,
- LIBMSI_PROPERTY_TYPE_STRING, 0, NULL,
- "Installer, MSI");
- libmsi_summary_info_set_property(si, LIBMSI_PROPERTY_TEMPLATE,
- LIBMSI_PROPERTY_TYPE_STRING, 0, NULL,
- ";1033");
- libmsi_summary_info_set_property(si, LIBMSI_PROPERTY_APPNAME,
- LIBMSI_PROPERTY_TYPE_STRING, 0, NULL,
- "libmsi msibuild");
- libmsi_summary_info_set_property(si, LIBMSI_PROPERTY_VERSION,
- LIBMSI_PROPERTY_TYPE_INT, 200, NULL, NULL);
- libmsi_summary_info_set_property(si, LIBMSI_PROPERTY_SOURCE,
- LIBMSI_PROPERTY_TYPE_INT, 0, NULL, NULL);
- libmsi_summary_info_set_property(si, LIBMSI_PROPERTY_RESTRICT,
- LIBMSI_PROPERTY_TYPE_INT, 0, NULL, NULL);
+ if (!libmsi_summary_info_set_string(si, LIBMSI_PROPERTY_TITLE,
+ "Installation Database", error))
+ return FALSE;
+
+ if (!libmsi_summary_info_set_string(si, LIBMSI_PROPERTY_KEYWORDS,
+ "Installer, MSI", error))
+ return FALSE;
+
+ if (!libmsi_summary_info_set_string(si, LIBMSI_PROPERTY_TEMPLATE,
+ ";1033", error))
+ return FALSE;
+
+ if (!libmsi_summary_info_set_string(si, LIBMSI_PROPERTY_APPNAME,
+ "libmsi msibuild", error))
+ return FALSE;
+
+ if (!libmsi_summary_info_set_int(si, LIBMSI_PROPERTY_VERSION,
+ 200, error))
+ return FALSE;
+
+ if (!libmsi_summary_info_set_int(si, LIBMSI_PROPERTY_SOURCE,
+ 0, error))
+ return FALSE;
+
+ if (!libmsi_summary_info_set_int(si, LIBMSI_PROPERTY_RESTRICT,
+ 0, error))
+ return FALSE;
#ifdef HAVE_LIBUUID
{
@@ -61,14 +70,17 @@ static void init_suminfo(LibmsiSummaryInfo *si)
uustr[0] = '{';
uuid_unparse_upper(uu, uustr + 1);
strcat(uustr, "}");
- libmsi_summary_info_set_property(si, LIBMSI_PROPERTY_UUID,
- LIBMSI_PROPERTY_TYPE_STRING, 0, NULL, uustr);
+ if (!libmsi_summary_info_set_string(si, LIBMSI_PROPERTY_UUID,
+ uustr, error))
+ return FALSE;
}
#endif
+
+ return TRUE;
}
static LibmsiResult open_database(const char *msifile, LibmsiDatabase **db,
- LibmsiSummaryInfo **si)
+ LibmsiSummaryInfo **si, GError **error)
{
LibmsiResult r;
struct stat st;
@@ -89,7 +101,8 @@ static LibmsiResult open_database(const char *msifile, LibmsiDatabase **db,
return r;
}
- init_suminfo(*si);
+ if (!init_suminfo(*si, error))
+ return LIBMSI_RESULT_FUNCTION_FAILED;
r = libmsi_database_commit(*db);
if (r != LIBMSI_RESULT_SUCCESS)
@@ -139,27 +152,26 @@ static int import_table(char *table)
return (r != LIBMSI_RESULT_SUCCESS);
}
-static int add_summary_info(const char *name, const char *author,
- const char *template, const char *uuid)
+static gboolean add_summary_info(const char *name, const char *author,
+ const char *template, const char *uuid,
+ GError **error)
{
- libmsi_summary_info_set_property(si, LIBMSI_PROPERTY_SUBJECT,
- LIBMSI_PROPERTY_TYPE_STRING,
- 0, NULL, name);
- if (author) {
- libmsi_summary_info_set_property(si, LIBMSI_PROPERTY_AUTHOR,
- LIBMSI_PROPERTY_TYPE_STRING,
- 0, NULL, author);
- }
- if (template) {
- libmsi_summary_info_set_property(si, LIBMSI_PROPERTY_TEMPLATE,
- LIBMSI_PROPERTY_TYPE_STRING,
- 0, NULL, template);
- }
- if (uuid) {
- libmsi_summary_info_set_property(si, LIBMSI_PROPERTY_UUID,
- LIBMSI_PROPERTY_TYPE_STRING,
- 0, NULL, uuid);
- }
+ if (!libmsi_summary_info_set_string(si, LIBMSI_PROPERTY_SUBJECT, name, error))
+ return FALSE;
+
+ if (author &&
+ !libmsi_summary_info_set_string(si, LIBMSI_PROPERTY_AUTHOR, author, error))
+ return FALSE;
+
+ if (template &&
+ !libmsi_summary_info_set_string(si, LIBMSI_PROPERTY_TEMPLATE, template, error))
+ return FALSE;
+
+ if (uuid &&
+ !libmsi_summary_info_set_string(si, LIBMSI_PROPERTY_UUID, uuid, error))
+ return FALSE;
+
+ return TRUE;
}
static int add_stream(const char *stream, const char *file)
@@ -237,10 +249,10 @@ int main(int argc, char *argv[])
/* Accept package after first option for winemsibuilder compatibility. */
if (argc >= 3 && argv[1][0] == '-') {
- r = open_database(argv[2], &db, &si);
+ r = open_database(argv[2], &db, &si, &error);
argv[2] = argv[1];
} else {
- r = open_database(argv[1], &db, &si);
+ r = open_database(argv[1], &db, &si, &error);
}
if (r != LIBMSI_RESULT_SUCCESS) return 1;
@@ -260,10 +272,11 @@ int main(int argc, char *argv[])
if (argv[2] && argv[2][0] != '-') n++;
if (n > 2 && argv[3] && argv[3][0] != '-') n++;
if (n > 3 && argv[4] && argv[4][0] != '-') n++;
- ret = add_summary_info(argv[1],
- n > 2 ? argv[2] : NULL,
- n > 3 ? argv[3] : NULL,
- n > 4 ? argv[4] : NULL);
+ if (!add_summary_info(argv[1],
+ n > 2 ? argv[2] : NULL,
+ n > 3 ? argv[3] : NULL,
+ n > 4 ? argv[4] : NULL, &error))
+ goto end;
argc -= 3, argv += 3;
break;
case 'i':
@@ -305,12 +318,10 @@ int main(int argc, char *argv[])
}
if (r == LIBMSI_RESULT_SUCCESS) {
- r = libmsi_summary_info_persist(si);
- if (r != LIBMSI_RESULT_SUCCESS)
- {
- fprintf(stderr, "failed to commit summary info (%u)\n", r);
- exit(1);
- }
+ libmsi_summary_info_persist(si, &error);
+ if (error)
+ goto end;
+
r = libmsi_database_commit(db);
if (r != LIBMSI_RESULT_SUCCESS)
{
@@ -318,6 +329,8 @@ int main(int argc, char *argv[])
exit(1);
}
}
+
+end:
g_object_unref(si);
g_object_unref(db);
return r != LIBMSI_RESULT_SUCCESS;
diff --git a/tools/msiinfo.c b/tools/msiinfo.c
index 8043f0d..fdf963c 100644
--- a/tools/msiinfo.c
+++ b/tools/msiinfo.c
@@ -260,10 +260,11 @@ static int cmd_tables(struct Command *cmd, int argc, char **argv)
static void print_suminfo(LibmsiSummaryInfo *si, int prop, const char *name)
{
+ GError *error = NULL;
unsigned type;
+ const gchar* str;
int val;
uint64_t valtime;
- char *buf;
unsigned sz;
unsigned r;
time_t t;
@@ -276,20 +277,23 @@ static void print_suminfo(LibmsiSummaryInfo *si, int prop, const char *name)
switch (type) {
case LIBMSI_PROPERTY_TYPE_INT:
+ val = libmsi_summary_info_get_int(si, prop, &error);
+ if (error)
+ goto end;
printf ("%s: %d (%x)\n", name, val, val);
break;
case LIBMSI_PROPERTY_TYPE_STRING:
- buf = g_malloc(++sz);
- r = libmsi_summary_info_get_property(si, prop, NULL, NULL, NULL, buf, &sz);
- if (r) {
- print_libmsi_error(r);
- }
- printf ("%s: %s\n", name, buf);
- free(buf);
+ str = libmsi_summary_info_get_string(si, prop, &error);
+ if (error)
+ goto end;
+ printf ("%s: %s\n", name, str);
break;
case LIBMSI_PROPERTY_TYPE_FILETIME:
+ valtime = libmsi_summary_info_get_filetime(si, prop, &error);
+ if (error)
+ goto end;
/* Convert nanoseconds since 1601 to seconds since Unix epoch. */
t = (valtime / 10000000) - (uint64_t) 134774 * 86400;
printf ("%s: %s", name, ctime(&t));
@@ -301,6 +305,11 @@ static void print_suminfo(LibmsiSummaryInfo *si, int prop, const char *name)
default:
abort();
}
+
+end:
+ if (error)
+ g_warning("Can't print summary info: %s", error->message);
+ g_clear_error(&error);
}
static int cmd_suminfo(struct Command *cmd, int argc, char **argv)