forked from len0rd/rockbox
Hopefully fix compilation warnings and link errors. Add some feedback (file being hashed). Boost CPU.
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@17710 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
34d4165f7b
commit
8e7454cc73
2 changed files with 31 additions and 8 deletions
|
@ -34,7 +34,14 @@ void md5_init( const struct plugin_api *api )
|
||||||
rb = api;
|
rb = api;
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef WORDS_BIGENDIAN
|
#ifdef ROCKBOX_BIG_ENDIAN
|
||||||
|
static inline uint32_t GetDWLE( const void * _p )
|
||||||
|
{
|
||||||
|
const uint8_t * p = (const uint8_t *)_p;
|
||||||
|
return ( ((uint32_t)p[3] << 24) | ((uint32_t)p[2] << 16)
|
||||||
|
| ((uint32_t)p[1] << 8) | p[0] );
|
||||||
|
}
|
||||||
|
|
||||||
/*****************************************************************************
|
/*****************************************************************************
|
||||||
* Reverse: reverse byte order
|
* Reverse: reverse byte order
|
||||||
*****************************************************************************/
|
*****************************************************************************/
|
||||||
|
@ -246,10 +253,10 @@ void psz_md5_hash( char *psz, struct md5_s *md5_s )
|
||||||
for ( i = 0; i < 4; i++ )
|
for ( i = 0; i < 4; i++ )
|
||||||
{
|
{
|
||||||
rb->snprintf( &psz[8*i], 9, "%02x%02x%02x%02x",
|
rb->snprintf( &psz[8*i], 9, "%02x%02x%02x%02x",
|
||||||
md5_s->p_digest[i] & 0xff,
|
(unsigned int)(md5_s->p_digest[i] & 0xff),
|
||||||
( md5_s->p_digest[i] >> 8 ) & 0xff,
|
(unsigned int)(( md5_s->p_digest[i] >> 8 ) & 0xff),
|
||||||
( md5_s->p_digest[i] >> 16 ) & 0xff,
|
(unsigned int)(( md5_s->p_digest[i] >> 16 ) & 0xff),
|
||||||
md5_s->p_digest[i] >> 24
|
(unsigned int)(md5_s->p_digest[i] >> 24)
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -24,12 +24,15 @@ PLUGIN_HEADER
|
||||||
|
|
||||||
static const struct plugin_api *rb;
|
static const struct plugin_api *rb;
|
||||||
|
|
||||||
|
MEM_FUNCTION_WRAPPERS(rb);
|
||||||
|
|
||||||
int hash( char *string, const char *path )
|
int hash( char *string, const char *path )
|
||||||
{
|
{
|
||||||
char *buffer[512];
|
char *buffer[512];
|
||||||
ssize_t len;
|
ssize_t len;
|
||||||
struct md5_s md5;
|
struct md5_s md5;
|
||||||
int in = rb->open( path, O_RDONLY );
|
int in = rb->open( path, O_RDONLY );
|
||||||
|
rb->splash( 0, path );
|
||||||
if( in < 0 ) return -1;
|
if( in < 0 ) return -1;
|
||||||
|
|
||||||
InitMD5( &md5 );
|
InitMD5( &md5 );
|
||||||
|
@ -50,7 +53,7 @@ void hash_file( int out, const char *path )
|
||||||
rb->write( out, "error", 5 );
|
rb->write( out, "error", 5 );
|
||||||
else
|
else
|
||||||
rb->write( out, string, MD5_STRING_LENGTH );
|
rb->write( out, string, MD5_STRING_LENGTH );
|
||||||
rb->write( out, " ", 1 );
|
rb->write( out, " ", 2 );
|
||||||
rb->write( out, path, rb->strlen( path ) );
|
rb->write( out, path, rb->strlen( path ) );
|
||||||
rb->write( out, "\n", 1 );
|
rb->write( out, "\n", 1 );
|
||||||
}
|
}
|
||||||
|
@ -129,7 +132,8 @@ void hash_check( int out, const char *path )
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
char string[MD5_STRING_LENGTH+1];
|
char string[MD5_STRING_LENGTH+1];
|
||||||
filename++;
|
while( *filename == ' ' )
|
||||||
|
filename++;
|
||||||
rb->write( out, filename, rb->strlen( filename ) );
|
rb->write( out, filename, rb->strlen( filename ) );
|
||||||
rb->write( out, ": ", 2 );
|
rb->write( out, ": ", 2 );
|
||||||
if( hash( string, filename ) )
|
if( hash( string, filename ) )
|
||||||
|
@ -151,6 +155,9 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame
|
||||||
|
|
||||||
md5_init( api );
|
md5_init( api );
|
||||||
rb = api;
|
rb = api;
|
||||||
|
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
||||||
|
rb->cpu_boost( true );
|
||||||
|
#endif
|
||||||
|
|
||||||
if( arg && *arg )
|
if( arg && *arg )
|
||||||
{
|
{
|
||||||
|
@ -158,7 +165,13 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame
|
||||||
DIR *dir;
|
DIR *dir;
|
||||||
rb->snprintf( filename, MAX_PATH, "%s.md5sum", arg );
|
rb->snprintf( filename, MAX_PATH, "%s.md5sum", arg );
|
||||||
out = rb->open( filename, O_WRONLY|O_CREAT );
|
out = rb->open( filename, O_WRONLY|O_CREAT );
|
||||||
if( out < 0 ) return PLUGIN_ERROR;
|
if( out < 0 )
|
||||||
|
{
|
||||||
|
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
||||||
|
rb->cpu_boost( false );
|
||||||
|
#endif
|
||||||
|
return PLUGIN_ERROR;
|
||||||
|
}
|
||||||
|
|
||||||
if( ext )
|
if( ext )
|
||||||
{
|
{
|
||||||
|
@ -202,5 +215,8 @@ enum plugin_status plugin_start(const struct plugin_api* api, const void* parame
|
||||||
|
|
||||||
exit:
|
exit:
|
||||||
rb->close( out );
|
rb->close( out );
|
||||||
|
#ifdef HAVE_ADJUSTABLE_CPU_FREQ
|
||||||
|
rb->cpu_boost( false );
|
||||||
|
#endif
|
||||||
return PLUGIN_OK;
|
return PLUGIN_OK;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue