summaryrefslogtreecommitdiffstats
path: root/libmsi
diff options
context:
space:
mode:
authorMarc-André Lureau <marcandre.lureau@gmail.com>2012-12-17 15:31:31 +0100
committerPaolo Bonzini <pbonzini@redhat.com>2013-01-09 13:56:07 +0100
commit3bddf664dc9c491660c2ab91630a9b50163214e5 (patch)
tree76d45e40af22508ac55cd41cb2ce8cef4286008e /libmsi
parentb1efff0fdee6d986df33ec13d9d64808bf2619b6 (diff)
downloadmsitools-3bddf664dc9c491660c2ab91630a9b50163214e5.tar.gz
msitools-3bddf664dc9c491660c2ab91630a9b50163214e5.tar.xz
msitools-3bddf664dc9c491660c2ab91630a9b50163214e5.zip
database: make is_table_persistent() return a boolean
Diffstat (limited to 'libmsi')
-rw-r--r--libmsi/libmsi-database.c21
-rw-r--r--libmsi/msipriv.h8
2 files changed, 23 insertions, 6 deletions
diff --git a/libmsi/libmsi-database.c b/libmsi/libmsi-database.c
index 0720cc3..580cb7e 100644
--- a/libmsi/libmsi-database.c
+++ b/libmsi/libmsi-database.c
@@ -2443,20 +2443,29 @@ libmsi_database_get_primary_keys (LibmsiDatabase *db,
return rec;
}
-LibmsiCondition libmsi_database_is_table_persistent(
- LibmsiDatabase *db, const char *szTableName)
+gboolean
+libmsi_database_is_table_persistent (LibmsiDatabase *db, const char *table,
+ GError **error)
{
LibmsiCondition r;
- TRACE("%x %s\n", db, debugstr_a(szTableName));
+ TRACE("%p %s\n", db, debugstr_a(table));
- g_return_val_if_fail(LIBMSI_IS_DATABASE(db), LIBMSI_CONDITION_ERROR);
+ g_return_val_if_fail (LIBMSI_IS_DATABASE (db), LIBMSI_CONDITION_ERROR);
+ g_return_val_if_fail (table != NULL, NULL);
+ g_return_val_if_fail (!error || *error == NULL, NULL);
g_object_ref(db);
- r = _libmsi_database_is_table_persistent( db, szTableName );
+ r = _libmsi_database_is_table_persistent( db, table );
g_object_unref(db);
- return r;
+ if (r == LIBMSI_CONDITION_NONE)
+ g_set_error (error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_INVALID_TABLE,
+ "The table is unknown");
+ else if (r == LIBMSI_CONDITION_ERROR)
+ g_set_error (error, LIBMSI_RESULT_ERROR, LIBMSI_RESULT_FUNCTION_FAILED, "");
+
+ return r == LIBMSI_CONDITION_TRUE;
}
/* TODO: use GInitable */
diff --git a/libmsi/msipriv.h b/libmsi/msipriv.h
index 8ff0aee..a74f9a5 100644
--- a/libmsi/msipriv.h
+++ b/libmsi/msipriv.h
@@ -50,6 +50,14 @@
#define MAX_PATH PATH_MAX
#endif
+typedef enum LibmsiCondition
+{
+ LIBMSI_CONDITION_FALSE = 0,
+ LIBMSI_CONDITION_TRUE = 1,
+ LIBMSI_CONDITION_NONE = 2,
+ LIBMSI_CONDITION_ERROR = 3,
+} LibmsiCondition;
+
#define MSI_DATASIZEMASK 0x00ff
#define MSITYPE_VALID 0x0100
#define MSITYPE_LOCALIZABLE 0x200