Skip to content

Commit

Permalink
fix print info TEXT
Browse files Browse the repository at this point in the history
  • Loading branch information
w4kfu committed Nov 15, 2014
1 parent a7fd2fb commit 289ee2c
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 13 deletions.
2 changes: 1 addition & 1 deletion CMakeLists.txt
Expand Up @@ -25,7 +25,7 @@ IF(MSVC)
ENDIF(MSVC)

if(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)
add_definitions(-Wall -W -Werror -pedantic)
add_definitions(-Wall -W -Werror -pedantic -std=c99)
endif(CMAKE_COMPILER_IS_GNUCC OR CMAKE_COMPILER_IS_GNUCXX)

add_subdirectory(src)
22 changes: 11 additions & 11 deletions src/resources/odv_resource_text.c
Expand Up @@ -43,15 +43,14 @@ struct ODVResourceTextEntry *odv_ressource_parse_text_entry(struct ODVResourceFi
struct ODVResourceTextEntry *entry = NULL;
size_t numberofbytesread = 0;
unsigned short length;
char *buf = NULL;
wchar_t *wbuf = NULL;

numberofbytesread = odv_file_read(rfile->file, &length, 2);
if (numberofbytesread != 2) {
fprintf(stderr, "[-] odv_ressource_parse_text_entry - file read 2 failed\n");
return NULL;
}
wbuf = calloc((length * 2) + 1, sizeof (char));
wbuf = calloc(length + 1, sizeof (wchar_t));
if (wbuf == NULL) {
fprintf(stderr, "[-] odv_ressource_parse_text_entry - calloc failed\n");
return NULL;
Expand All @@ -62,22 +61,23 @@ struct ODVResourceTextEntry *odv_ressource_parse_text_entry(struct ODVResourceFi
free(wbuf);
return NULL;
}
buf = calloc(length + 1, sizeof (char));
/*buf = calloc(length + 1, sizeof (char));
if (buf == NULL) {
fprintf(stderr, "[-] odv_ressource_parse_text_entry - calloc failed\n");
free(wbuf);
return NULL;
}
hex_dump(wbuf, length);
wcstombs(buf, wbuf, length);
free(wbuf);
free(wbuf);*/
entry = calloc(1, sizeof (struct ODVResourceTextEntry));
if (entry == NULL) {
fprintf(stderr, "[-] odv_ressource_parse_text_entry - calloc failed\n");
free(buf);
free(wbuf);
return NULL;
}
entry->length = length;
entry->buf = buf;
entry->wbuf = wbuf;
return entry;
}

Expand All @@ -93,8 +93,8 @@ void odv_resource_text_info(const struct ODVResourceText *text)
if (text->entries != NULL) {
for (i = 0; i < text->nbentry; i++) {
if (text->entries[i] != NULL) {
printf("(%d): %s\n", i, text->entries[i]->buf);
hex_dump(text->entries[i]->buf, text->entries[i]->length);
printf("(%d): %ls\n", i, text->entries[i]->wbuf);
/* wprintf(L"(%d): %s\n", i, text->entries[i]->wbuf); */
}
}
}
Expand All @@ -107,9 +107,9 @@ void odv_resource_clean_text_entry(struct ODVResourceTextEntry *entry)
if (entry == NULL)
return;
entry->length = 0;
if (entry->buf != NULL)
free(entry->buf);
entry->buf = NULL;
if (entry->wbuf != NULL)
free(entry->wbuf);
entry->wbuf = NULL;
free(entry);
}

Expand Down
4 changes: 3 additions & 1 deletion src/resources/odv_resource_text.h
@@ -1,14 +1,16 @@
#ifndef OPENDV_RESOURCE_TEXT_H
#define OPENDV_RESOURCE_TEXT_H

#include <wchar.h>

#include "odv_resource.h"

#define TEXT_SIGNATURE 0x54584554

struct ODVResourceTextEntry
{
unsigned short length;
char *buf;
wchar_t *wbuf;
};

struct ODVResourceText
Expand Down

0 comments on commit 289ee2c

Please sign in to comment.