From 4509fd0a9f3b17e0c099efa6c235c4e80bf6a97d Mon Sep 17 00:00:00 2001 From: Marc-André Lureau Date: Sun, 16 Dec 2012 22:18:02 +0100 Subject: database: remove libmsi_database_open() --- tools/msibuild.c | 18 ++++++------------ tools/msiinfo.c | 35 +++++++++++++++-------------------- 2 files changed, 21 insertions(+), 32 deletions(-) (limited to 'tools') diff --git a/tools/msibuild.c b/tools/msibuild.c index af717b0..4a1f0e2 100644 --- a/tools/msibuild.c +++ b/tools/msibuild.c @@ -87,12 +87,9 @@ static LibmsiResult open_database(const char *msifile, LibmsiDatabase **db, if (stat(msifile, &st) == -1) { - r = libmsi_database_open(msifile, LIBMSI_DB_OPEN_CREATE, db); - if (r != LIBMSI_RESULT_SUCCESS) - { - fprintf(stderr, "failed to create package database %s (%u)\n", msifile, r); - return r; - } + *db = libmsi_database_new(msifile, LIBMSI_DB_OPEN_CREATE, error); + if (!*db) + return LIBMSI_RESULT_FUNCTION_FAILED; r = libmsi_database_get_summary_info(*db, INT_MAX, si); if (r != LIBMSI_RESULT_SUCCESS) @@ -114,12 +111,9 @@ static LibmsiResult open_database(const char *msifile, LibmsiDatabase **db, } else { - r = libmsi_database_open(msifile, LIBMSI_DB_OPEN_TRANSACT, db); - if (r != LIBMSI_RESULT_SUCCESS) - { - fprintf(stderr, "failed to open package database %s (%u)\n", msifile, r); - return r; - } + *db = libmsi_database_new(msifile, LIBMSI_DB_OPEN_TRANSACT, error); + if (!*db) + return LIBMSI_RESULT_FUNCTION_FAILED; r = libmsi_database_get_summary_info(*db, INT_MAX, si); if (r != LIBMSI_RESULT_SUCCESS) diff --git a/tools/msiinfo.c b/tools/msiinfo.c index db2066b..71fcba3 100644 --- a/tools/msiinfo.c +++ b/tools/msiinfo.c @@ -196,10 +196,9 @@ static int cmd_streams(struct Command *cmd, int argc, char **argv, GError **erro cmd_usage(stderr, cmd); } - r = libmsi_database_open(argv[1], LIBMSI_DB_OPEN_READONLY, &db); - if (r) { - print_libmsi_error(r); - } + db = libmsi_database_new(argv[1], LIBMSI_DB_OPEN_READONLY, error); + if (!db) + return 1; r = libmsi_database_open_query(db, "SELECT `Name` FROM `_Streams`", &query); if (r) { @@ -229,10 +228,9 @@ static int cmd_tables(struct Command *cmd, int argc, char **argv, GError **error cmd_usage(stderr, cmd); } - r = libmsi_database_open(argv[1], LIBMSI_DB_OPEN_READONLY, &db); - if (r) { - print_libmsi_error(r); - } + db = libmsi_database_new(argv[1], LIBMSI_DB_OPEN_READONLY, error); + if (!db) + return 1; r = libmsi_database_open_query(db, "SELECT `Name` FROM `_Tables`", &query); if (r) { @@ -315,10 +313,9 @@ static int cmd_suminfo(struct Command *cmd, int argc, char **argv, GError **erro cmd_usage(stderr, cmd); } - r = libmsi_database_open(argv[1], LIBMSI_DB_OPEN_READONLY, &db); - if (r) { - print_libmsi_error(r); - } + db = libmsi_database_new(argv[1], LIBMSI_DB_OPEN_READONLY, error); + if (!db) + return 1; r = libmsi_database_get_summary_info(db, 0, &si); if (r) { @@ -376,10 +373,9 @@ static int cmd_extract(struct Command *cmd, int argc, char **argv, GError **erro cmd_usage(stderr, cmd); } - r = libmsi_database_open(argv[1], LIBMSI_DB_OPEN_READONLY, &db); - if (r) { - print_libmsi_error(r); - } + db = libmsi_database_new(argv[1], LIBMSI_DB_OPEN_READONLY, error); + if (!db) + return 1; r = libmsi_database_open_query(db, "SELECT `Data` FROM `_Streams` WHERE `Name` = ?", &query); if (r) { @@ -672,10 +668,9 @@ static int cmd_export(struct Command *cmd, int argc, char **argv, GError **error cmd_usage(stderr, cmd); } - r = libmsi_database_open(argv[1], LIBMSI_DB_OPEN_READONLY, &db); - if (r) { - print_libmsi_error(r); - } + db = libmsi_database_new(argv[1], LIBMSI_DB_OPEN_READONLY, error); + if (!db) + return 1; if (sql) { r = export_sql(db, argv[2], error); -- cgit