diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2012-12-12 10:26:10 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2012-12-12 10:26:15 +0100 |
commit | 79385dd37ad96abe473f957a368c80631307111b (patch) | |
tree | 27faf56a8efe07bc3132f5b9fe369da016961a0d | |
parent | a656e3eb1840c0637ab0eb1f5eba24071cc46ba8 (diff) | |
parent | 382ca48cbcf5941be0d4f412ad4ef6fc1d6136ac (diff) | |
download | msitools-79385dd37ad96abe473f957a368c80631307111b.tar.gz msitools-79385dd37ad96abe473f957a368c80631307111b.tar.xz msitools-79385dd37ad96abe473f957a368c80631307111b.zip |
Merge branch 'pre-gsf'
Conflicts:
libmsi/libmsi-record.c
tests/test.h
-rw-r--r-- | Makefile.am | 5 | ||||
-rw-r--r-- | include/libmsi-record.h | 1 | ||||
-rw-r--r-- | include/libmsi-types.h | 118 | ||||
-rw-r--r-- | libmsi/Makefile.am | 9 | ||||
-rw-r--r-- | libmsi/debug.h (renamed from include/debug.h) | 0 | ||||
-rw-r--r-- | libmsi/libmsi-database.c | 12 | ||||
-rw-r--r-- | libmsi/libmsi-record.c | 24 | ||||
-rw-r--r-- | tests/testrecord.c | 18 | ||||
-rw-r--r-- | tests/testsuminfo.c | 1 |
9 files changed, 82 insertions, 106 deletions
diff --git a/Makefile.am b/Makefile.am index 2359f25..c12ace6 100644 --- a/Makefile.am +++ b/Makefile.am @@ -1,7 +1,6 @@ ACLOCAL_AMFLAGS = -I m4 SUBDIRS = libmsi tests . -noinst_HEADERS = include/debug.h tools/sqldelim.h dist_include_HEADERS = \ include/libmsi.h \ include/libmsi-database.h \ @@ -16,7 +15,7 @@ AM_LDFLAGS = -Llibmsi bin_PROGRAMS = msibuild msiinfo -msibuild_SOURCES = tools/msibuild.c tools/sqldelim.c +msibuild_SOURCES = tools/msibuild.c tools/sqldelim.c tools/sqldelim.h msibuild_LDADD = -lmsi $(GLIB_LIBS) $(GSF_LIBS) $(UUID_LIBS) msibuild_DEPENDENCIES = libmsi/libmsi.la @@ -37,7 +36,7 @@ installcheck-local: $(srcdir)/tests/testsuite atconfig atlocal $(SHELL) $(srcdir)/tests/testsuite AUTOTEST_PATH=$(bindir) $(TESTSUITEFLAGS) clean-local: - -$(SHELL) tests/testsuite --clean + -$(SHELL) $(srcdir)/tests/testsuite --clean $(srcdir)/tests/testsuite: tests/testsuite.at tests/package.m4 cd $(srcdir)/tests && \ diff --git a/include/libmsi-record.h b/include/libmsi-record.h index ab3f078..f3f3989 100644 --- a/include/libmsi-record.h +++ b/include/libmsi-record.h @@ -48,7 +48,6 @@ LibmsiResult libmsi_record_set_string (LibmsiRecord *,unsigned,const char * LibmsiResult libmsi_record_get_string (const LibmsiRecord *,unsigned,char *,unsigned *); unsigned libmsi_record_get_field_count (const LibmsiRecord *); int libmsi_record_get_integer (const LibmsiRecord *,unsigned); -unsigned libmsi_record_get_field_size (const LibmsiRecord *,unsigned); gboolean libmsi_record_is_null (const LibmsiRecord *,unsigned); LibmsiResult libmsi_record_load_stream (LibmsiRecord *,unsigned,const char *); diff --git a/include/libmsi-types.h b/include/libmsi-types.h index 426c043..f23398e 100644 --- a/include/libmsi-types.h +++ b/include/libmsi-types.h @@ -23,6 +23,12 @@ G_BEGIN_DECLS +#define LIBMSI_RESULT_ERROR libmsi_result_error_quark () +GQuark libmsi_result_error_quark (void); + +#define LIBMSI_DB_ERROR libmsi_db_error_quark () +GQuark libmsi_db_error_quark (void); + typedef struct _LibmsiDatabase LibmsiDatabase; typedef struct _LibmsiQuery LibmsiQuery; typedef struct _LibmsiRecord LibmsiRecord; @@ -36,29 +42,31 @@ typedef enum LibmsiCondition LIBMSI_CONDITION_ERROR = 3, } LibmsiCondition; -typedef enum LibmsiResult +typedef enum LibmsiResultError { - LIBMSI_RESULT_SUCCESS = 0, - LIBMSI_RESULT_ACCESS_DENIED = 5, - LIBMSI_RESULT_INVALID_HANDLE = 6, - LIBMSI_RESULT_NOT_ENOUGH_MEMORY = 8, - LIBMSI_RESULT_INVALID_DATA = 13, - LIBMSI_RESULT_OUTOFMEMORY = 14, - LIBMSI_RESULT_INVALID_PARAMETER = 87, - LIBMSI_RESULT_OPEN_FAILED = 110, - LIBMSI_RESULT_CALL_NOT_IMPLEMENTED = 120, - LIBMSI_RESULT_MORE_DATA = 234, - LIBMSI_RESULT_NO_MORE_ITEMS = 259, - LIBMSI_RESULT_NOT_FOUND = 1168, - LIBMSI_RESULT_CONTINUE = 1246, - LIBMSI_RESULT_UNKNOWN_PROPERTY = 1608, - LIBMSI_RESULT_BAD_QUERY_SYNTAX = 1615, - LIBMSI_RESULT_INVALID_FIELD = 1616, - LIBMSI_RESULT_FUNCTION_FAILED = 1627, - LIBMSI_RESULT_INVALID_TABLE = 1628, - LIBMSI_RESULT_DATATYPE_MISMATCH = 1629, - LIBMSI_RESULT_INVALID_DATATYPE = 1804 -} LibmsiResult; + LIBMSI_RESULT_SUCCESS, // FIXME: remove me + LIBMSI_RESULT_ACCESS_DENIED, + LIBMSI_RESULT_INVALID_HANDLE, + LIBMSI_RESULT_NOT_ENOUGH_MEMORY, + LIBMSI_RESULT_INVALID_DATA, + LIBMSI_RESULT_OUTOFMEMORY, + LIBMSI_RESULT_INVALID_PARAMETER, + LIBMSI_RESULT_OPEN_FAILED, + LIBMSI_RESULT_CALL_NOT_IMPLEMENTED, + LIBMSI_RESULT_MORE_DATA, + LIBMSI_RESULT_NO_MORE_ITEMS, + LIBMSI_RESULT_NOT_FOUND, + LIBMSI_RESULT_CONTINUE, + LIBMSI_RESULT_UNKNOWN_PROPERTY, + LIBMSI_RESULT_BAD_QUERY_SYNTAX, + LIBMSI_RESULT_INVALID_FIELD, + LIBMSI_RESULT_FUNCTION_FAILED, + LIBMSI_RESULT_INVALID_TABLE, + LIBMSI_RESULT_DATATYPE_MISMATCH, + LIBMSI_RESULT_INVALID_DATATYPE +} LibmsiResultError; + +typedef LibmsiResultError LibmsiResult; // FIXME: remove me typedef enum LibmsiPropertyType { @@ -84,39 +92,39 @@ typedef enum LibmsiColInfo typedef enum LibmsiDBError { - LIBMSI_DB_ERROR_INVALIDARG = -3, - LIBMSI_DB_ERROR_MOREDATA = -2, - LIBMSI_DB_ERROR_FUNCTIONERROR = -1, - LIBMSI_DB_ERROR_NOERROR = 0, - LIBMSI_DB_ERROR_DUPLICATEKEY = 1, - LIBMSI_DB_ERROR_REQUIRED = 2, - LIBMSI_DB_ERROR_BADLINK = 3, - LIBMSI_DB_ERROR_OVERFLOW = 4, - LIBMSI_DB_ERROR_UNDERFLOW = 5, - LIBMSI_DB_ERROR_NOTINSET = 6, - LIBMSI_DB_ERROR_BADVERSION = 7, - LIBMSI_DB_ERROR_BADCASE = 8, - LIBMSI_DB_ERROR_BADGUID = 9, - LIBMSI_DB_ERROR_BADWILDCARD = 10, - LIBMSI_DB_ERROR_BADIDENTIFIER = 11, - LIBMSI_DB_ERROR_BADLANGUAGE = 12, - LIBMSI_DB_ERROR_BADFILENAME = 13, - LIBMSI_DB_ERROR_BADPATH = 14, - LIBMSI_DB_ERROR_BADCONDITION = 15, - LIBMSI_DB_ERROR_BADFORMATTED = 16, - LIBMSI_DB_ERROR_BADTEMPLATE = 17, - LIBMSI_DB_ERROR_BADDEFAULTDIR = 18, - LIBMSI_DB_ERROR_BADREGPATH = 19, - LIBMSI_DB_ERROR_BADCUSTOMSOURCE = 20, - LIBMSI_DB_ERROR_BADPROPERTY = 21, - LIBMSI_DB_ERROR_MISSINGDATA = 22, - LIBMSI_DB_ERROR_BADCATEGORY = 23, - LIBMSI_DB_ERROR_BADKEYTABLE = 24, - LIBMSI_DB_ERROR_BADMAXMINVALUES = 25, - LIBMSI_DB_ERROR_BADCABINET = 26, - LIBMSI_DB_ERROR_BADSHORTCUT= 27, - LIBMSI_DB_ERROR_STRINGOVERFLOW = 28, - LIBMSI_DB_ERROR_BADLOCALIZEATTRIB = 29 + LIBMSI_DB_ERROR_SUCCESS, // FIXME: remove me + LIBMSI_DB_ERROR_INVALIDARG, + LIBMSI_DB_ERROR_MOREDATA, + LIBMSI_DB_ERROR_FUNCTIONERROR, + LIBMSI_DB_ERROR_DUPLICATEKEY, + LIBMSI_DB_ERROR_REQUIRED, + LIBMSI_DB_ERROR_BADLINK, + LIBMSI_DB_ERROR_OVERFLOW, + LIBMSI_DB_ERROR_UNDERFLOW, + LIBMSI_DB_ERROR_NOTINSET, + LIBMSI_DB_ERROR_BADVERSION, + LIBMSI_DB_ERROR_BADCASE, + LIBMSI_DB_ERROR_BADGUID, + LIBMSI_DB_ERROR_BADWILDCARD, + LIBMSI_DB_ERROR_BADIDENTIFIER, + LIBMSI_DB_ERROR_BADLANGUAGE, + LIBMSI_DB_ERROR_BADFILENAME, + LIBMSI_DB_ERROR_BADPATH, + LIBMSI_DB_ERROR_BADCONDITION, + LIBMSI_DB_ERROR_BADFORMATTED, + LIBMSI_DB_ERROR_BADTEMPLATE, + LIBMSI_DB_ERROR_BADDEFAULTDIR, + LIBMSI_DB_ERROR_BADREGPATH, + LIBMSI_DB_ERROR_BADCUSTOMSOURCE, + LIBMSI_DB_ERROR_BADPROPERTY, + LIBMSI_DB_ERROR_MISSINGDATA, + LIBMSI_DB_ERROR_BADCATEGORY, + LIBMSI_DB_ERROR_BADKEYTABLE, + LIBMSI_DB_ERROR_BADMAXMINVALUES, + LIBMSI_DB_ERROR_BADCABINET, + LIBMSI_DB_ERROR_BADSHORTCUT, + LIBMSI_DB_ERROR_STRINGOVERFLOW, + LIBMSI_DB_ERROR_BADLOCALIZEATTRIB } LibmsiDBError; typedef enum LibmsiDBState diff --git a/libmsi/Makefile.am b/libmsi/Makefile.am index 3004d1c..9bfd503 100644 --- a/libmsi/Makefile.am +++ b/libmsi/Makefile.am @@ -8,14 +8,10 @@ AM_CFLAGS = -Wunused -Wimplicit AM_YFLAGS = -d BUILT_SOURCES = sql-parser.c sql-parser.h -noinst_HEADERS = \ - list.h \ - msipriv.h \ - query.h - libmsi_la_SOURCES = \ alter.c \ create.c \ + debug.h \ delete.c \ distinct.c \ drop.c \ @@ -24,6 +20,9 @@ libmsi_la_SOURCES = \ libmsi-query.c \ libmsi-record.c \ libmsi-summary-info.c \ + list.h \ + msipriv.h \ + query.h \ select.c \ sql-parser.y \ storages.c \ diff --git a/include/debug.h b/libmsi/debug.h index a4393c1..a4393c1 100644 --- a/include/debug.h +++ b/libmsi/debug.h diff --git a/libmsi/libmsi-database.c b/libmsi/libmsi-database.c index 6b9f25f..765be66 100644 --- a/libmsi/libmsi-database.c +++ b/libmsi/libmsi-database.c @@ -77,6 +77,18 @@ typedef struct _LibmsiStream { GsfInput *stm; } LibmsiStream; +GQuark +libmsi_result_error_quark (void) +{ + return g_quark_from_static_string ("libmsi-result-error-quark"); +} + +GQuark +libmsi_db_error_quark (void) +{ + return g_quark_from_static_string ("libmsi-db-error-quark"); +} + static void libmsi_database_init (LibmsiDatabase *p) { diff --git a/libmsi/libmsi-record.c b/libmsi/libmsi-record.c index 9390c03..a725049 100644 --- a/libmsi/libmsi-record.c +++ b/libmsi/libmsi-record.c @@ -400,30 +400,6 @@ unsigned _libmsi_record_get_string(const LibmsiRecord *rec, unsigned iField, return ret; } -unsigned libmsi_record_get_field_size(const LibmsiRecord *rec, unsigned iField) -{ - TRACE("%p %d\n", rec, iField); - - if( !rec ) - return 0; - - if( iField > rec->count ) - return 0; - - switch( rec->fields[iField].type ) - { - case LIBMSI_FIELD_TYPE_INT: - return sizeof (int); - case LIBMSI_FIELD_TYPE_STR: - return strlen( rec->fields[iField].u.szVal ); - case LIBMSI_FIELD_TYPE_NULL: - break; - case LIBMSI_FIELD_TYPE_STREAM: - return gsf_input_size( rec->fields[iField].u.stream ); - } - return 0; -} - LibmsiResult libmsi_record_set_string( LibmsiRecord *rec, unsigned iField, const char *szValue ) { char *str; diff --git a/tests/testrecord.c b/tests/testrecord.c index 2800039..373cc2d 100644 --- a/tests/testrecord.c +++ b/tests/testrecord.c @@ -79,8 +79,6 @@ static void test_msirecord(void) ok(r == LIBMSI_RESULT_INVALID_HANDLE, "libmsi_record_set_int returned wrong error\n"); r = libmsi_record_clear_data(0); ok(r == LIBMSI_RESULT_INVALID_HANDLE, "libmsi_record_clear_data returned wrong error\n"); - r = libmsi_record_get_field_size(0,0); - ok(r == 0, "libmsi_record_get_field_size returned wrong error\n"); /* check behaviour of a record with 0 elements */ @@ -94,8 +92,6 @@ static void test_msirecord(void) ok(r, "out of range record wasn't null\n"); r = libmsi_record_is_null(h,-1); ok(r, "out of range record wasn't null\n"); - r = libmsi_record_get_field_size(h,0); - ok(r==0, "size of null record is 0\n"); sz = sizeof buf; strcpy(buf,"x"); r = libmsi_record_get_string(h, 0, buf, &sz); @@ -108,8 +104,6 @@ static void test_msirecord(void) ok(r == LIBMSI_RESULT_SUCCESS, "Failed to set integer at 0 to 0\n"); r = libmsi_record_is_null(h,0); ok(r==0, "new record is null after setting an integer\n"); - r = libmsi_record_get_field_size(h,0); - ok(r==sizeof(unsigned), "size of integer record is 4\n"); r = libmsi_record_set_int(h, 0, 1); ok(r == LIBMSI_RESULT_SUCCESS, "Failed to set integer at 0 to 1\n"); r = libmsi_record_set_int(h, 1, 1); @@ -126,8 +120,6 @@ static void test_msirecord(void) ok(r == LIBMSI_RESULT_SUCCESS, "Failed to set null string at 0\n"); r = libmsi_record_is_null(h, 0); ok(r == true, "null string not null field\n"); - r = libmsi_record_get_field_size(h, 0); - ok(r == 0, "size of string record is strlen\n"); buf[0] = 0; sz = sizeof buf; r = libmsi_record_get_string(h, 0, buf, &sz); @@ -138,8 +130,6 @@ static void test_msirecord(void) ok(r == LIBMSI_RESULT_SUCCESS, "Failed to set empty string at 0\n"); r = libmsi_record_is_null(h, 0); ok(r == true, "null string not null field\n"); - r = libmsi_record_get_field_size(h, 0); - ok(r == 0, "size of string record is strlen\n"); buf[0] = 0; sz = sizeof buf; r = libmsi_record_get_string(h, 0, buf, &sz); @@ -152,8 +142,6 @@ static void test_msirecord(void) ok(r == LIBMSI_RESULT_SUCCESS, "Failed to set string at 0\n"); r = libmsi_record_get_integer(h, 0); ok(r == LIBMSI_NULL_INT, "should get invalid integer\n"); - r = libmsi_record_get_field_size(h,0); - ok(r==sizeof str-1, "size of string record is strlen\n"); buf[0]=0; sz = sizeof buf; r = libmsi_record_get_string(h,0,buf,&sz); @@ -284,10 +272,6 @@ static void test_msirecord(void) r = libmsi_record_save_stream(h, 0, buf, &sz); ok(r == LIBMSI_RESULT_INVALID_DATATYPE, "read non-stream type\n"); ok(sz == sizeof buf, "set sz\n"); - r = libmsi_record_get_field_size( h, -1); - ok(r == 0,"libmsi_record_get_field_size returned wrong size\n"); - r = libmsi_record_get_field_size( h, 0); - ok(r == 4,"libmsi_record_get_field_size returned wrong size\n"); /* same record, now close it */ g_object_unref(h); @@ -345,8 +329,6 @@ static void test_msirecord(void) r = libmsi_record_save_stream(h, 1, NULL, &sz); ok(r == LIBMSI_RESULT_SUCCESS, "bytes left wrong after reset\n"); ok(sz==26,"couldn't get size of stream\n"); - r = libmsi_record_get_field_size(h,1); - ok(r == 26,"libmsi_record_get_field_size returned wrong size\n"); /* now close the stream record */ g_object_unref(h); diff --git a/tests/testsuminfo.c b/tests/testsuminfo.c index 796ae39..522b8b3 100644 --- a/tests/testsuminfo.c +++ b/tests/testsuminfo.c @@ -22,6 +22,7 @@ #include <stdint.h> #include <stdio.h> +#include <stdint.h> #include <windows.h> #include <libmsi.h> #include <objidl.h> |