Set length on output from read media tag.

This commit is contained in:
2019-03-21 00:18:48 +00:00
parent 4ab2e1bb49
commit 4b20f2057e
4 changed files with 12 additions and 5 deletions

View File

@@ -74,7 +74,8 @@ typedef struct dataLinkedList
struct dataLinkedList *previous;
struct dataLinkedList *next;
uint8_t *data;
int type;
int32_t type;
uint32_t length;
} dataLinkedList;
typedef struct DumpHardwareEntriesWithData

View File

@@ -44,7 +44,7 @@ void *open(const char *filepath);
int close(void *context);
uint8_t *read_media_tag(void *context, int tag);
uint8_t *read_media_tag(void *context, int32_t tag, uint32_t *length);
void *crc64_init(uint64_t polynomial, uint64_t seed);

View File

@@ -383,8 +383,9 @@ void *open(const char *filepath)
// TODO: MediaTagType
// MediaTagType mediaTagType = GetMediaTagTypeForDataType(blockHeader.type);
mediaTag->type = blockHeader.type;
mediaTag->data = data;
mediaTag->type = blockHeader.type;
mediaTag->data = data;
mediaTag->length = blockHeader.length;
if(ctx->mediaTagsHead == NULL)
{

View File

@@ -33,8 +33,10 @@
#include <dicformat.h>
#include <errno.h>
uint8_t *read_media_tag(void *context, int tag)
uint8_t *read_media_tag(void *context, int32_t tag, uint32_t *length)
{
*length = 0;
if(context == NULL)
{
errno = EINVAL;
@@ -56,7 +58,10 @@ uint8_t *read_media_tag(void *context, int tag)
while(item != NULL)
{
if(item->type == tag)
{
*length = item->length;
return item->data;
}
item = item->next;
}