[tracker/binary-log-2: 20/45] Use typedef enum for journal data formats



commit e3bc991f387e9af91850a58566f5d75ad06389e7
Author: Martyn Russell <martyn lanedo com>
Date:   Tue Jan 5 17:18:37 2010 +0000

    Use typedef enum for journal data formats

 src/libtracker-db/tracker-db-journal.c |   48 ++++++++++++++++----------------
 1 files changed, 24 insertions(+), 24 deletions(-)
---
diff --git a/src/libtracker-db/tracker-db-journal.c b/src/libtracker-db/tracker-db-journal.c
index 6d425be..4b8e296 100644
--- a/src/libtracker-db/tracker-db-journal.c
+++ b/src/libtracker-db/tracker-db-journal.c
@@ -49,11 +49,11 @@
  *            `--- operation type (0 = insert, 1 = delete)
  */
 
-enum {
+typedef enum {
 	DATA_FORMAT_RESOURCE_INSERT  = 1 << 0,
 	DATA_FORMAT_OBJECT_ID        = 1 << 1,
 	DATA_FORMAT_OPERATION_DELETE = 1 << 2
-};
+} DataFormat;
 
 static struct {
 	gchar *filename;
@@ -324,19 +324,19 @@ tracker_db_journal_append_delete_statement (guint32      s_id,
                                             const gchar *object)
 {
 	gint o_len;
-	gchar data_format;
+	DataFormat df;
 	gint size;
 
 	g_return_val_if_fail (writer.journal > 0, FALSE);
 
 	o_len = strlen (object);
-	data_format = DATA_FORMAT_OPERATION_DELETE;
+	df = DATA_FORMAT_OPERATION_DELETE;
 
 	size = (sizeof (guint32) * 3) + o_len + 1;
 
 	cur_block_maybe_expand (size);
 
-	cur_setnum (writer.cur_block, &writer.cur_pos, data_format);
+	cur_setnum (writer.cur_block, &writer.cur_pos, df);
 	cur_setnum (writer.cur_block, &writer.cur_pos, s_id);
 	cur_setnum (writer.cur_block, &writer.cur_pos, p_id);
 	cur_setstr (writer.cur_block, &writer.cur_pos, object, o_len);
@@ -352,17 +352,17 @@ tracker_db_journal_append_delete_statement_id (guint32 s_id,
                                                  guint32 p_id,
                                                  guint32 o_id)
 {
-	gchar data_format;
+	DataFormat df;
 	gint size;
 
 	g_return_val_if_fail (writer.journal > 0, FALSE);
 
-	data_format = DATA_FORMAT_OPERATION_DELETE | DATA_FORMAT_OBJECT_ID;
+	df = DATA_FORMAT_OPERATION_DELETE | DATA_FORMAT_OBJECT_ID;
 	size = sizeof (guint32) * 4;
 
 	cur_block_maybe_expand (size);
 
-	cur_setnum (writer.cur_block, &writer.cur_pos, data_format);
+	cur_setnum (writer.cur_block, &writer.cur_pos, df);
 	cur_setnum (writer.cur_block, &writer.cur_pos, s_id);
 	cur_setnum (writer.cur_block, &writer.cur_pos, p_id);
 	cur_setnum (writer.cur_block, &writer.cur_pos, o_id);
@@ -379,18 +379,18 @@ tracker_db_journal_append_insert_statement (guint32      s_id,
                                             const gchar *object)
 {
 	gint o_len;
-	gchar data_format;
+	DataFormat df;
 	gint size;
 
 	g_return_val_if_fail (writer.journal > 0, FALSE);
 
 	o_len = strlen (object);
-	data_format = 0x00;
+	df = 0x00;
 	size = (sizeof (guint32) * 3) + o_len + 1;
 
 	cur_block_maybe_expand (size);
 
-	cur_setnum (writer.cur_block, &writer.cur_pos, data_format);
+	cur_setnum (writer.cur_block, &writer.cur_pos, df);
 	cur_setnum (writer.cur_block, &writer.cur_pos, s_id);
 	cur_setnum (writer.cur_block, &writer.cur_pos, p_id);
 	cur_setstr (writer.cur_block, &writer.cur_pos, object, o_len);
@@ -406,17 +406,17 @@ tracker_db_journal_append_insert_statement_id (guint32 s_id,
                                                guint32 p_id,
                                                guint32 o_id)
 {
-	gchar data_format;
+	DataFormat df;
 	gint size;
 
 	g_return_val_if_fail (writer.journal > 0, FALSE);
 
-	data_format = DATA_FORMAT_OBJECT_ID;
+	df = DATA_FORMAT_OBJECT_ID;
 	size = sizeof (guint32) * 4;
 
 	cur_block_maybe_expand (size);
 
-	cur_setnum (writer.cur_block, &writer.cur_pos, data_format);
+	cur_setnum (writer.cur_block, &writer.cur_pos, df);
 	cur_setnum (writer.cur_block, &writer.cur_pos, s_id);
 	cur_setnum (writer.cur_block, &writer.cur_pos, p_id);
 	cur_setnum (writer.cur_block, &writer.cur_pos, o_id);
@@ -432,18 +432,18 @@ tracker_db_journal_append_resource (guint32      s_id,
                                     const gchar *uri)
 {
 	gint o_len;
-	gchar data_format;
+	DataFormat df;
 	gint size;
 
 	g_return_val_if_fail (writer.journal > 0, FALSE);
 
 	o_len = strlen (uri);
-	data_format = DATA_FORMAT_RESOURCE_INSERT;
+	df = DATA_FORMAT_RESOURCE_INSERT;
 	size = (sizeof (guint32) * 2) + o_len + 1;
 
 	cur_block_maybe_expand (size);
 
-	cur_setnum (writer.cur_block, &writer.cur_pos, data_format);
+	cur_setnum (writer.cur_block, &writer.cur_pos, df);
 	cur_setnum (writer.cur_block, &writer.cur_pos, s_id);
 	cur_setstr (writer.cur_block, &writer.cur_pos, uri, o_len);
 
@@ -684,7 +684,7 @@ tracker_db_journal_reader_next (GError **error)
 		reader.type = TRACKER_DB_JOURNAL_END_TRANSACTION;
 		return TRUE;
 	} else {
-		guint32 data_format;
+		DataFormat df;
 		gsize str_length;
 
 		if (reader.end - reader.current < sizeof (guint32)) {
@@ -695,10 +695,10 @@ tracker_db_journal_reader_next (GError **error)
 			return FALSE;
 		}
 
-		data_format = read_uint32 (reader.current);
+		df = read_uint32 (reader.current);
 		reader.current += 4;
 
-		if (data_format == DATA_FORMAT_RESOURCE_INSERT) {
+		if (df == DATA_FORMAT_RESOURCE_INSERT) {
 			reader.type = TRACKER_DB_JOURNAL_RESOURCE;
 
 			if (reader.end - reader.current < sizeof (guint32) + 1) {
@@ -731,14 +731,14 @@ tracker_db_journal_reader_next (GError **error)
 			reader.uri = reader.current;
 			reader.current += str_length + 1;
 		} else {
-			if (data_format & DATA_FORMAT_OPERATION_DELETE) {
-				if (data_format & DATA_FORMAT_OBJECT_ID) {
+			if (df & DATA_FORMAT_OPERATION_DELETE) {
+				if (df & DATA_FORMAT_OBJECT_ID) {
 					reader.type = TRACKER_DB_JOURNAL_DELETE_STATEMENT_ID;
 				} else {
 					reader.type = TRACKER_DB_JOURNAL_DELETE_STATEMENT;
 				}
 			} else {
-				if (data_format & DATA_FORMAT_OBJECT_ID) {
+				if (df & DATA_FORMAT_OBJECT_ID) {
 					reader.type = TRACKER_DB_JOURNAL_INSERT_STATEMENT_ID;
 				} else {
 					reader.type = TRACKER_DB_JOURNAL_INSERT_STATEMENT;
@@ -759,7 +759,7 @@ tracker_db_journal_reader_next (GError **error)
 			reader.p_id = read_uint32 (reader.current);
 			reader.current += 4;
 
-			if (data_format & DATA_FORMAT_OBJECT_ID) {
+			if (df & DATA_FORMAT_OBJECT_ID) {
 				if (reader.end - reader.current < sizeof (guint32)) {
 					/* damaged journal entry */
 					g_set_error (error, TRACKER_DB_JOURNAL_ERROR, 0, 



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]