summaryrefslogtreecommitdiffstats
path: root/tools
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-12-19 15:00:40 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-12-19 15:00:40 +0000
commit323f297aded859c4c042eb43ce1e595034bb2527 (patch)
tree1ed46dbc05989b4a017ffd09ff82a9a9c72dd8c0 /tools
parent5ff920e20597b0eec01f312e8d83d32c883a292a (diff)
downloadrockbox-323f297aded859c4c042eb43ce1e595034bb2527.tar.gz
rockbox-323f297aded859c4c042eb43ce1e595034bb2527.tar.bz2
rockbox-323f297aded859c4c042eb43ce1e595034bb2527.zip
Added incomplete support for the FM Recorder header
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3030 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools')
-rw-r--r--tools/scramble.c62
1 files changed, 46 insertions, 16 deletions
diff --git a/tools/scramble.c b/tools/scramble.c
index 5b59cf3d64..a5c8caea3e 100644
--- a/tools/scramble.c
+++ b/tools/scramble.c
@@ -25,18 +25,27 @@ int main (int argc, char** argv)
unsigned long length,i,slen;
unsigned char *inbuf,*outbuf;
unsigned short crc=0;
- unsigned char header[6];
+ unsigned char header[24];
+ unsigned char *iname = argv[1];
+ unsigned char *oname = argv[2];
+ int headerlen = 6;
FILE* file;
if (argc < 3) {
- printf("usage: %s <input file> <output file>\n",argv[0]);
+ printf("usage: %s [-fm] <input file> <output file>\n",argv[0]);
return -1;
}
+
+ if (argv[1][0] == '-') { /* assume any parameter is -fm :-) */
+ headerlen = 24;
+ iname = argv[2];
+ oname = argv[3];
+ }
/* open file */
- file = fopen(argv[1],"rb");
+ file = fopen(iname,"rb");
if (!file) {
- perror(argv[1]);
+ perror(iname);
return -1;
}
fseek(file,0,SEEK_END);
@@ -52,7 +61,7 @@ int main (int argc, char** argv)
/* read file */
i=fread(inbuf,1,length,file);
if ( !i ) {
- perror(argv[1]);
+ perror(iname);
return -1;
}
fclose(file);
@@ -71,25 +80,46 @@ int main (int argc, char** argv)
crc += inbuf[i];
/* make header */
- header[0] = (length >> 24) & 0xff;
- header[1] = (length >> 16) & 0xff;
- header[2] = (length >> 8) & 0xff;
- header[3] = length & 0xff;
- header[4] = (crc >> 8) & 0xff;
- header[5] = crc & 0xff;
+ memset(header, 0, sizeof header);
+ if (headerlen == 6) {
+ header[0] = (length >> 24) & 0xff;
+ header[1] = (length >> 16) & 0xff;
+ header[2] = (length >> 8) & 0xff;
+ header[3] = length & 0xff;
+ header[4] = (crc >> 8) & 0xff;
+ header[5] = crc & 0xff;
+ }
+ else {
+ header[0] =
+ header[1] =
+ header[2] =
+ header[3] = 0xff; /* ??? */
+
+ header[6] = (crc >> 8) & 0xff;
+ header[7] = crc & 0xff;
+
+ header[11] = 4; /* ??? */
+
+ header[15] = headerlen; /* really? */
+
+ header[20] = (length >> 24) & 0xff;
+ header[21] = (length >> 16) & 0xff;
+ header[22] = (length >> 8) & 0xff;
+ header[23] = length & 0xff;
+ }
/* write file */
- file = fopen(argv[2],"wb");
+ file = fopen(oname,"wb");
if ( !file ) {
- perror(argv[2]);
+ perror(oname);
return -1;
}
- if ( !fwrite(header,6,1,file) ) {
- perror(argv[2]);
+ if ( !fwrite(header,headerlen,1,file) ) {
+ perror(oname);
return -1;
}
if ( !fwrite(outbuf,length,1,file) ) {
- perror(argv[2]);
+ perror(oname);
return -1;
}
fclose(file);