summaryrefslogtreecommitdiffstats
path: root/libmsi/libmsi-record.c
diff options
context:
space:
mode:
Diffstat (limited to 'libmsi/libmsi-record.c')
-rw-r--r--libmsi/libmsi-record.c49
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 )