summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2012-12-17 12:28:19 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2013-01-09 13:56:07 +0100
commit377666075f7eb5ee07e0c76ed18ce417f7491150 (patch)
tree159f5852bcb06c99dcf2bd859d7eb945b8359300 /tools
parent6106dcb112c0ff995744281c5a343a7918491884 (diff)
downloadmsitools-377666075f7eb5ee07e0c76ed18ce417f7491150.tar.gz
msitools-377666075f7eb5ee07e0c76ed18ce417f7491150.tar.xz
msitools-377666075f7eb5ee07e0c76ed18ce417f7491150.zip
database: make export() GObject-like
Diffstat (limited to 'tools')
-rw-r--r--tools/msiinfo.c22
1 files changed, 13 insertions, 9 deletions
diff --git a/tools/msiinfo.c b/tools/msiinfo.c
index ea41713..a9786d8 100644
--- a/tools/msiinfo.c
+++ b/tools/msiinfo.c
@@ -434,7 +434,7 @@ static unsigned export_create_table(const char *table,
guint num_columns = libmsi_record_get_field_count(names);
guint num_keys = libmsi_record_get_field_count(keys);
guint i, len;
- unsigned r;
+ unsigned r = LIBMSI_RESULT_SUCCESS;
char size[20], extra[30];
gchar *name, *type;
unsigned sz;
@@ -660,7 +660,7 @@ done:
static int cmd_export(struct Command *cmd, int argc, char **argv, GError **error)
{
LibmsiDatabase *db = NULL;
- LibmsiResult r;
+ LibmsiResult r = LIBMSI_RESULT_SUCCESS;
gboolean sql = FALSE;
if (argc > 1 && !strcmp(argv[1], "-s")) {
@@ -679,20 +679,24 @@ static int cmd_export(struct Command *cmd, int argc, char **argv, GError **error
if (sql) {
r = export_sql(db, argv[2], error);
+ if (r) {
+ print_libmsi_error(r);
+ }
+
+
} else {
#if O_BINARY
_setmode(STDOUT_FILENO, O_BINARY);
#endif
- r = libmsi_database_export(db, argv[2], STDOUT_FILENO);
- }
-
- if (r) {
- print_libmsi_error(r);
+ if (!libmsi_database_export(db, argv[2], STDOUT_FILENO, error))
+ goto end;
}
- g_object_unref(db);
+end:
+ if (db)
+ g_object_unref(db);
- return 0;
+ return *error ? 1 : 0;
}
static int cmd_version(struct Command *cmd, int argc, char **argv, GError **error)