diff options
author | Marc-André Lureau <marcandre.lureau@gmail.com> | 2013-01-17 20:16:15 +0100 |
---|---|---|
committer | Marc-André Lureau <marcandre.lureau@gmail.com> | 2013-01-17 20:16:19 +0100 |
commit | 6556c61586d79ee0ae599248f25d591d99da8a97 (patch) | |
tree | 5392d273386dbf868e7ca2cb9b680c700bb7a4e0 /libmsi | |
parent | e9cf5c17fe55779628503718139f3048b6eab5d2 (diff) | |
download | msitools-6556c61586d79ee0ae599248f25d591d99da8a97.tar.gz msitools-6556c61586d79ee0ae599248f25d591d99da8a97.tar.xz msitools-6556c61586d79ee0ae599248f25d591d99da8a97.zip |
Remove LIBMSI_RESULT_NO_MORE_ITEMS from API
Raising an error for indicating the end of the results is really
inconvenient, it's like throwing an exception for something quite
normal... The user can still make a distinction when there is an error
if the GError is set.
Diffstat (limited to 'libmsi')
-rw-r--r-- | libmsi/distinct.c | 2 | ||||
-rw-r--r-- | libmsi/libmsi-database.c | 2 | ||||
-rw-r--r-- | libmsi/libmsi-query.c | 15 | ||||
-rw-r--r-- | libmsi/msipriv.h | 2 | ||||
-rw-r--r-- | libmsi/storages.c | 4 | ||||
-rw-r--r-- | libmsi/streams.c | 4 | ||||
-rw-r--r-- | libmsi/table.c | 4 | ||||
-rw-r--r-- | libmsi/where.c | 4 |
8 files changed, 20 insertions, 17 deletions
diff --git a/libmsi/distinct.c b/libmsi/distinct.c index d134b03..f47a289 100644 --- a/libmsi/distinct.c +++ b/libmsi/distinct.c @@ -240,7 +240,7 @@ static unsigned distinct_view_find_matching_rows( LibmsiView *view, unsigned col r = dv->table->ops->find_matching_rows( dv->table, col, val, row, handle ); if( *row > dv->row_count ) - return LIBMSI_RESULT_NO_MORE_ITEMS; + return NO_MORE_ITEMS; *row = dv->translation[ *row ]; diff --git a/libmsi/libmsi-database.c b/libmsi/libmsi-database.c index 158c9ff..a8185a6 100644 --- a/libmsi/libmsi-database.c +++ b/libmsi/libmsi-database.c @@ -1696,7 +1696,7 @@ static unsigned merge_diff_row(LibmsiRecord *rec, void *param) table->numconflicts++; goto done; } - else if (r != LIBMSI_RESULT_NO_MORE_ITEMS) + else if (r != NO_MORE_ITEMS) goto done; r = LIBMSI_RESULT_SUCCESS; diff --git a/libmsi/libmsi-query.c b/libmsi/libmsi-query.c index eacbb8c..c61c23c 100644 --- a/libmsi/libmsi-query.c +++ b/libmsi/libmsi-query.c @@ -251,7 +251,7 @@ unsigned _libmsi_query_iterate_records( LibmsiQuery *view, unsigned *count, if( count ) *count = n; - if( r == LIBMSI_RESULT_NO_MORE_ITEMS ) + if( r == NO_MORE_ITEMS ) r = LIBMSI_RESULT_SUCCESS; return r; @@ -315,7 +315,7 @@ unsigned msi_view_get_row(LibmsiDatabase *db, LibmsiView *view, unsigned row, Li return LIBMSI_RESULT_INVALID_PARAMETER; if (row >= row_count) - return LIBMSI_RESULT_NO_MORE_ITEMS; + return NO_MORE_ITEMS; *rec = libmsi_record_new (col_count); if (!*rec) @@ -402,11 +402,11 @@ LibmsiResult _libmsi_query_fetch(LibmsiQuery *query, LibmsiRecord **prec) * @query: a #LibmsiQuery * @error: (allow-none): return location for the error * - * Return the next query result. A %LIBMSI_RESULT_NO_MORE_ITEMS error - * is returned when the query result set has reached the end. + * Return the next query result. %NULL is returned when there + * is no more results. * - * Returns: (transfer full): a newly allocated #LibmsiRecord - * or %NULL when no results or failure. + * Returns: (transfer full) (allow-none): a newly allocated + * #LibmsiRecord or %NULL when no results or failure. **/ LibmsiRecord * libmsi_query_fetch (LibmsiQuery *query, GError **error) @@ -424,7 +424,8 @@ libmsi_query_fetch (LibmsiQuery *query, GError **error) g_object_unref(query); /* FIXME: raise error when it happens */ - if (ret != LIBMSI_RESULT_SUCCESS) + if (ret != LIBMSI_RESULT_SUCCESS && + ret != NO_MORE_ITEMS) g_set_error_literal (error, LIBMSI_RESULT_ERROR, ret, G_STRFUNC); return record; diff --git a/libmsi/msipriv.h b/libmsi/msipriv.h index 9929e51..5241f9f 100644 --- a/libmsi/msipriv.h +++ b/libmsi/msipriv.h @@ -72,6 +72,8 @@ typedef enum LibmsiCondition #define MAX_STREAM_NAME_LEN 62 #define LONG_STR_BYTES 3 +#define NO_MORE_ITEMS G_MAXINT + #define MSITYPE_IS_BINARY(type) (((type) & ~MSITYPE_NULLABLE) == (MSITYPE_STRING|MSITYPE_VALID)) struct _LibmsiTable; diff --git a/libmsi/storages.c b/libmsi/storages.c index 6829849..7846e69 100644 --- a/libmsi/storages.c +++ b/libmsi/storages.c @@ -81,7 +81,7 @@ static unsigned storages_view_fetch_int(LibmsiView *view, unsigned row, unsigned return LIBMSI_RESULT_INVALID_PARAMETER; if (row >= sv->num_rows) - return LIBMSI_RESULT_NO_MORE_ITEMS; + return NO_MORE_ITEMS; *val = sv->storages[row]->str_index; @@ -291,7 +291,7 @@ static unsigned storages_view_find_matching_rows(LibmsiView *view, unsigned col, *handle = (MSIITERHANDLE)(uintptr_t)++index; if (index >= sv->num_rows) - return LIBMSI_RESULT_NO_MORE_ITEMS; + return NO_MORE_ITEMS; return LIBMSI_RESULT_SUCCESS; } diff --git a/libmsi/streams.c b/libmsi/streams.c index 93e05cc..4760e18 100644 --- a/libmsi/streams.c +++ b/libmsi/streams.c @@ -93,7 +93,7 @@ static unsigned streams_view_fetch_int(LibmsiView *view, unsigned row, unsigned return LIBMSI_RESULT_INVALID_PARAMETER; if (row >= sv->num_rows) - return LIBMSI_RESULT_NO_MORE_ITEMS; + return NO_MORE_ITEMS; *val = sv->streams[row]->str_index; @@ -332,7 +332,7 @@ static unsigned streams_view_find_matching_rows(LibmsiView *view, unsigned col, *handle = (MSIITERHANDLE)(uintptr_t)++index; if (index > sv->num_rows) - return LIBMSI_RESULT_NO_MORE_ITEMS; + return NO_MORE_ITEMS; return LIBMSI_RESULT_SUCCESS; } diff --git a/libmsi/table.c b/libmsi/table.c index 16057e3..b01943c 100644 --- a/libmsi/table.c +++ b/libmsi/table.c @@ -1025,7 +1025,7 @@ static unsigned table_view_fetch_int( LibmsiView *view, unsigned row, unsigned c /* how many rows are there ? */ if( row >= tv->table->row_count ) - return LIBMSI_RESULT_NO_MORE_ITEMS; + return NO_MORE_ITEMS; if( tv->columns[col-1].offset >= tv->row_size ) { @@ -1773,7 +1773,7 @@ static unsigned table_view_find_matching_rows( LibmsiView *view, unsigned col, *handle = entry; if (!entry) - return LIBMSI_RESULT_NO_MORE_ITEMS; + return NO_MORE_ITEMS; *row = entry->row; diff --git a/libmsi/where.c b/libmsi/where.c index fac7fa1..f0403bf 100644 --- a/libmsi/where.c +++ b/libmsi/where.c @@ -107,7 +107,7 @@ static unsigned init_reorder(LibmsiWhereView *wv) static inline unsigned find_row(LibmsiWhereView *wv, unsigned row, unsigned *(values[])) { if (row >= wv->row_count) - return LIBMSI_RESULT_NO_MORE_ITEMS; + return NO_MORE_ITEMS; *values = wv->reorder[row]->values; @@ -927,7 +927,7 @@ static unsigned where_view_find_matching_rows( LibmsiView *view, unsigned col, } } - return LIBMSI_RESULT_NO_MORE_ITEMS; + return NO_MORE_ITEMS; } static unsigned where_view_sort(LibmsiView *view, column_info *columns) |