summaryrefslogtreecommitdiffstats
path: root/tools/creative.c
diff options
context:
space:
mode:
authorMaurus Cuelenaere <mcuelenaere@gmail.com>2008-08-03 19:32:14 +0000
committerMaurus Cuelenaere <mcuelenaere@gmail.com>2008-08-03 19:32:14 +0000
commit06e3c660ccc09a5161bd600bf0ee5d5d7a59c589 (patch)
tree2d9015af877f4a4a1113abfbdc2f4c6944817a27 /tools/creative.c
parent7a4c33358122e73afc06ea1d417365f06445aefb (diff)
downloadrockbox-06e3c660ccc09a5161bd600bf0ee5d5d7a59c589.tar.gz
rockbox-06e3c660ccc09a5161bd600bf0ee5d5d7a59c589.tar.bz2
rockbox-06e3c660ccc09a5161bd600bf0ee5d5d7a59c589.zip
Prepare Creative bootloader compilation for future dual boot integration
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@18187 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools/creative.c')
-rw-r--r--tools/creative.c39
1 files changed, 28 insertions, 11 deletions
diff --git a/tools/creative.c b/tools/creative.c
index 43fdbbc917..1698f58930 100644
--- a/tools/creative.c
+++ b/tools/creative.c
@@ -155,7 +155,7 @@ static int make_jrm_file(const unsigned char *inbuf, unsigned char *outbuf)
return 0xC+length;
}
-int zvm_encode(const char *iname, const char *oname, int device)
+int zvm_encode(const char *iname, const char *oname, int device, bool enable_ciff)
{
size_t len;
int length;
@@ -164,7 +164,8 @@ int zvm_encode(const char *iname, const char *oname, int device)
unsigned char *buf;
file = fopen(iname, "rb");
- if (!file) {
+ if (!file)
+ {
perror(iname);
return -1;
}
@@ -174,20 +175,23 @@ int zvm_encode(const char *iname, const char *oname, int device)
fseek(file, 0, SEEK_SET);
buf = (unsigned char*)malloc(length);
- if ( !buf ) {
+ if ( !buf )
+ {
printf("Out of memory!\n");
return -1;
}
len = fread(buf, 1, length, file);
- if(len < (size_t)length) {
+ if(len < (size_t)length)
+ {
perror(iname);
return -2;
}
fclose(file);
outbuf = (unsigned char*)malloc(length+0x300);
- if ( !outbuf ) {
+ if ( !outbuf )
+ {
free(buf);
printf("Out of memory!\n");
return -1;
@@ -200,20 +204,33 @@ int zvm_encode(const char *iname, const char *oname, int device)
printf("Error in making JRM file!\n");
return -1;
}
- buf = (unsigned char*)malloc(length+0x200);
- memset(buf, 0, length+0x200);
- length = make_ciff_file(outbuf, length, buf, device);
- free(outbuf);
+ if(enable_ciff)
+ {
+ buf = (unsigned char*)malloc(length+0x200);
+ if ( !buf )
+ {
+ free(outbuf);
+ printf("Out of memory!\n");
+ return -1;
+ }
+ memset(buf, 0, length+0x200);
+ length = make_ciff_file(outbuf, length, buf, device);
+ free(outbuf);
+ }
+ else
+ buf = outbuf;
file = fopen(oname, "wb");
- if (!file) {
+ if (!file)
+ {
free(buf);
perror(oname);
return -3;
}
len = fwrite(buf, 1, length, file);
- if(len < (size_t)length) {
+ if(len < (size_t)length)
+ {
free(buf);
perror(oname);
return -4;