diff options
author | Paolo Bonzini <pbonzini@redhat.com> | 2012-12-12 10:29:26 +0100 |
---|---|---|
committer | Paolo Bonzini <pbonzini@redhat.com> | 2012-12-12 10:29:26 +0100 |
commit | 5e6b60c69feea5c6569af91926ba8ba5db4c17fa (patch) | |
tree | 1b5855c3f7091fbfec62584f87e51457aa44444f /libmsi/libmsi-record.c | |
parent | 7856a17b9931445c3a0c578f85c2956133adaf22 (diff) | |
parent | 5993fa0bf82c58f1d071499b00e4df16a8c6d1c3 (diff) | |
download | msitools-5e6b60c69feea5c6569af91926ba8ba5db4c17fa.tar.gz msitools-5e6b60c69feea5c6569af91926ba8ba5db4c17fa.tar.xz msitools-5e6b60c69feea5c6569af91926ba8ba5db4c17fa.zip |
Merge branch 'pre-gsf'
Conflicts:
libmsi/libmsi-record.c
Diffstat (limited to 'libmsi/libmsi-record.c')
-rw-r--r-- | libmsi/libmsi-record.c | 49 |
1 files changed, 10 insertions, 39 deletions
diff --git a/libmsi/libmsi-record.c b/libmsi/libmsi-record.c index 12e96aa..87ab4ac 100644 --- a/libmsi/libmsi-record.c +++ b/libmsi/libmsi-record.c @@ -292,54 +292,25 @@ gboolean libmsi_record_is_null( const LibmsiRecord *rec, unsigned iField ) return r; } -LibmsiResult libmsi_record_get_string(const LibmsiRecord *rec, unsigned iField, - char *szValue, unsigned *pcchValue) +gchar* libmsi_record_get_string(const LibmsiRecord *self, unsigned field) { - unsigned len=0, ret; - char buffer[16]; + g_return_val_if_fail (LIBMSI_IS_RECORD (self), NULL); - TRACE("%p %d %p %p\n", rec, iField, szValue, pcchValue); + TRACE ("%p %d\n", self, field); - if( !rec ) - return LIBMSI_RESULT_INVALID_HANDLE; + if (field > self->count) + return g_strdup (""); // FIXME: really? - if( iField > rec->count ) - { - if ( szValue && *pcchValue > 0 ) - szValue[0] = 0; - - *pcchValue = 0; - return LIBMSI_RESULT_SUCCESS; - } - - ret = LIBMSI_RESULT_SUCCESS; - switch( rec->fields[iField].type ) - { + switch (self->fields[field].type) { case LIBMSI_FIELD_TYPE_INT: - sprintf(buffer, "%d", rec->fields[iField].u.iVal); - len = strlen( buffer ); - if (szValue) - strcpyn(szValue, buffer, *pcchValue); - break; + return g_strdup_printf ("%d", self->fields[field].u.iVal); case LIBMSI_FIELD_TYPE_STR: - len = strlen( rec->fields[iField].u.szVal ); - if (szValue) - strcpyn(szValue, rec->fields[iField].u.szVal, *pcchValue ); - break; + return g_strdup (self->fields[field].u.szVal); case LIBMSI_FIELD_TYPE_NULL: - if( szValue && *pcchValue > 0 ) - szValue[0] = 0; - break; - default: - ret = LIBMSI_RESULT_INVALID_PARAMETER; - break; + return g_strdup (""); } - if( szValue && *pcchValue <= len ) - ret = LIBMSI_RESULT_MORE_DATA; - *pcchValue = len; - - return ret; + return NULL; } const char *_libmsi_record_get_string_raw( const LibmsiRecord *rec, unsigned iField ) |