summaryrefslogtreecommitdiff
path: root/tools/descramble.c
diff options
context:
space:
mode:
authorBjörn Stenberg <bjorn@haxx.se>2002-12-19 15:00:16 +0000
committerBjörn Stenberg <bjorn@haxx.se>2002-12-19 15:00:16 +0000
commit5ff920e20597b0eec01f312e8d83d32c883a292a (patch)
tree365fcf6652397341a969be4d31d4c07352a09a63 /tools/descramble.c
parent0b9fbda7ebcad0488a5f3f98ef0445e3254ee2ca (diff)
Added support for the FM Recorder header
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@3029 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'tools/descramble.c')
-rw-r--r--tools/descramble.c23
1 files changed, 16 insertions, 7 deletions
diff --git a/tools/descramble.c b/tools/descramble.c
index d9a4bf59d9..2469db0d21 100644
--- a/tools/descramble.c
+++ b/tools/descramble.c
@@ -24,22 +24,31 @@ int main (int argc, char** argv)
{
unsigned long length,i,slen;
unsigned char *inbuf,*outbuf;
+ 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 and check size */
- file = fopen(argv[1],"rb");
+ file = fopen(iname,"rb");
if (!file) {
- perror(argv[1]);
+ perror(oname);
return -1;
}
fseek(file,0,SEEK_END);
- length = ftell(file) - 6; /* skip 6-byte header */
- fseek(file,6,SEEK_SET);
+ length = ftell(file) - headerlen; /* skip header */
+ fseek(file,headerlen,SEEK_SET);
inbuf = malloc(length);
outbuf = malloc(length);
if ( !inbuf || !outbuf ) {
@@ -50,7 +59,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);
@@ -65,7 +74,7 @@ int main (int argc, char** argv)
}
/* write file */
- file = fopen(argv[2],"wb");
+ file = fopen(oname,"wb");
if ( !file ) {
perror(argv[2]);
return -1;