1 /***************************************************************************
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
10 * Copyright (C) 2006 by Christian Hack
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
25 extern void int2le(unsigned int val
, unsigned char* addr
);
26 extern unsigned int le2int(unsigned char* buf
);
28 static FILE * openinfile( const char * filename
)
30 FILE * F
= fopen( filename
, "rb" );
33 fprintf( stderr
, "Couldn't open input file %s\n", filename
);
34 perror( "Error was " );
40 static FILE * openoutfile( const char * filename
)
42 FILE * F
= fopen( filename
, "wb" );
45 fprintf( stderr
, "Couldn't open output file %s\n", filename
);
46 perror( "Error was " );
52 int gigabeat_code(char *infile
, char *outfile
)
55 unsigned long size
= 0;
56 unsigned long bytes_read
;
59 unsigned long key
= 0x19751217;
61 in
= openinfile(infile
);
62 out
= openoutfile(outfile
);
65 bytes_read
= fread(buf
, 1, 4, in
);
67 /* Read in little-endian */
72 key
= key
+ (key
<< 1);
73 key
= key
+ 0x19751217;
77 /* Write out little-endian */
80 fwrite(buf
, 1, bytes_read
, out
);
83 fprintf(stderr
, "File processed successfully\n" );