forked from len0rd/rockbox
On MacOS, gcc is a symlink for clang. Patch gets rid of the warnings produced by clang, when it is set as HOSTCC, and fixes voicetools compilation on MacOS when calling make voicetools from the simulator directory. lua rb_defines_helper: format specifies type 'int' but the argument has type 'long' codecs: opus / speex (LOGF): format '%ld' expects argument of type 'long int', but argument 7 has type 'off_t' gigabeat: variable 'size' set but not used rdf2binary: a function declaration without a prototype is deprecated in all versions of C rbspeexdec: passing 'unsigned char *' to parameter of type 'char *' converts between pointers to integer types where one is of the unique plain 'char' type and the other is not hmac-sha1.c defining a type within 'offsetof' is a Clang extension Change-Id: I90539906698868f9589650585d865aee9f7e8539
85 lines
2.3 KiB
C
85 lines
2.3 KiB
C
/***************************************************************************
|
|
* __________ __ ___.
|
|
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
|
|
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
|
|
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
|
|
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
|
|
* \/ \/ \/ \/ \/
|
|
* $Id$
|
|
*
|
|
* Copyright (C) 2006 by Christian Hack
|
|
*
|
|
* This program is free software; you can redistribute it and/or
|
|
* modify it under the terms of the GNU General Public License
|
|
* as published by the Free Software Foundation; either version 2
|
|
* of the License, or (at your option) any later version.
|
|
*
|
|
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
|
|
* KIND, either express or implied.
|
|
*
|
|
****************************************************************************/
|
|
|
|
#include <stdio.h>
|
|
#include <stdlib.h>
|
|
|
|
extern void int2le(unsigned int val, unsigned char* addr);
|
|
extern unsigned int le2int(unsigned char* buf);
|
|
|
|
static FILE * openinfile( const char * filename )
|
|
{
|
|
FILE * F = fopen( filename, "rb" );
|
|
if( F == NULL )
|
|
{
|
|
fprintf( stderr, "Couldn't open input file %s\n", filename );
|
|
perror( "Error was " );
|
|
exit( -1 );
|
|
};
|
|
return F;
|
|
}
|
|
|
|
static FILE * openoutfile( const char * filename )
|
|
{
|
|
FILE * F = fopen( filename, "wb" );
|
|
if( F == NULL )
|
|
{
|
|
fprintf( stderr, "Couldn't open output file %s\n", filename );
|
|
perror( "Error was " );
|
|
exit( -1 );
|
|
};
|
|
return F;
|
|
}
|
|
|
|
int gigabeat_code(char *infile, char *outfile)
|
|
{
|
|
FILE *in, *out;
|
|
unsigned long bytes_read;
|
|
unsigned char buf[4];
|
|
unsigned long data;
|
|
unsigned long key = 0x19751217;
|
|
|
|
in = openinfile(infile);
|
|
out = openoutfile(outfile);
|
|
|
|
while (!feof(in)) {
|
|
bytes_read = fread(buf, 1, 4, in);
|
|
|
|
/* Read in little-endian */
|
|
data = le2int(buf);
|
|
|
|
data = data ^ key;
|
|
|
|
key = key + (key << 1);
|
|
key = key + 0x19751217;
|
|
|
|
/* Write out little-endian */
|
|
int2le(data, buf);
|
|
|
|
fwrite(buf, 1, bytes_read, out);
|
|
}
|
|
|
|
fprintf(stderr, "File processed successfully\n" );
|
|
|
|
fclose(in);
|
|
fclose(out);
|
|
return(0);
|
|
}
|