From cea09fa139e5a9794e1feb7ba8213e3b7179af59 Mon Sep 17 00:00:00 2001 From: Daniel Stenberg Date: Fri, 1 Jul 2005 21:08:12 +0000 Subject: code police stand-in git-svn-id: svn://svn.rockbox.org/rockbox/trunk@6976 a1c6a512-1295-4272-9138-f99709370657 --- apps/database.c | 88 +++++++++++++++++++++++++++++++++++++-------------------- 1 file changed, 57 insertions(+), 31 deletions(-) diff --git a/apps/database.c b/apps/database.c index f4d6e47fba..a69385dd03 100644 --- a/apps/database.c +++ b/apps/database.c @@ -5,7 +5,7 @@ * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < < * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \ * \/ \/ \/ \/ \/ - * $Id + * $Id$ * * Copyright (C) 2005 by Michiel van der Kolk * @@ -98,7 +98,8 @@ int tagdb_init(void) #endif if ( (tagdbheader.version&0xFF) != TAGDB_VERSION) { - splash(HZ,true,"Unsupported database version %d!", tagdbheader.version&0xFF); + splash(HZ,true,"Unsupported database version %d!", + tagdbheader.version&0xFF); return -1; } @@ -125,20 +126,23 @@ void tagdb_shutdown(void) /*** TagDatabase code ***/ -void writetagdbheader(void) { +void writetagdbheader(void) +{ lseek(tagdb_fd,0,SEEK_SET); write(tagdb_fd, &tagdbheader, 68); fsync(tagdb_fd); } -void writefentry(void) { +void writefentry(void) +{ lseek(tagdb_fd,currentfeoffset,SEEK_SET); write(tagdb_fd,sbuf,tagdbheader.filelen); write(tagdb_fd,&fe.hash,12); fsync(tagdb_fd); } -void getfentrybyoffset(int offset) { +void getfentrybyoffset(int offset) +{ memset(&fe,0,sizeof(struct file_entry)); lseek(tagdb_fd,offset,SEEK_SET); read(tagdb_fd,sbuf,tagdbheader.filelen); @@ -150,7 +154,8 @@ void getfentrybyoffset(int offset) { #define getfentrybyrecord(_x_) getfentrybyoffset(FILERECORD2OFFSET(_x_)) -int getfentrybyfilename(char *fname) { +int getfentrybyfilename(char *fname) +{ int min=0; int max=tagdbheader.filecount; while(min=startingoffset) { splash(HZ*2,true,"Woah. no beeping way. (tagdb_shiftdown)"); @@ -225,7 +237,8 @@ int tagdb_shiftdown(int targetoffset, int startingoffset, int bytes) { written=write(tagdb_fd,sbuf,amount); targetoffset+=written; if(amount!=written) { - splash(HZ*2,true,"Something went very wrong. expect database corruption. (tagdb_shiftdown)"); + splash(HZ*2,true,"Something went very wrong. expect database " + "corruption. (tagdb_shiftdown)"); return 0; } lseek(tagdb_fd,startingoffset,SEEK_SET); @@ -234,7 +247,8 @@ int tagdb_shiftdown(int targetoffset, int startingoffset, int bytes) { return 1; } -int tagdb_shiftup(int targetoffset, int startingoffset, int bytes) { +int tagdb_shiftup(int targetoffset, int startingoffset, int bytes) +{ int amount,amount2; int readpos,writepos,filelen; if(targetoffset<=startingoffset) { @@ -250,13 +264,15 @@ int tagdb_shiftup(int targetoffset, int startingoffset, int bytes) { lseek(tagdb_fd,readpos,SEEK_SET); amount2=read(tagdb_fd,sbuf,amount); if(amount2!=amount) { - splash(HZ*2,true,"Something went very wrong. expect database corruption. (tagdb_shiftup)"); + splash(HZ*2,true,"Something went very wrong. expect database " + "corruption. (tagdb_shiftup)"); return 0; } lseek(tagdb_fd,writepos,SEEK_SET); amount=write(tagdb_fd,sbuf,amount2); if(amount2!=amount) { - splash(HZ*2,true,"Something went very wrong. expect database corruption. (tagdb_shiftup)"); + splash(HZ*2,true,"Something went very wrong. expect database " + "corruption. (tagdb_shiftup)"); return 0; } bytes-=amount; @@ -280,7 +296,8 @@ static struct rundb_entry rundbentry; /*** RuntimeDatabase code ***/ -void rundb_track_changed(struct track_info *ti) { +void rundb_track_changed(struct track_info *ti) +{ increaseplaycount(); logf("rundb new track: %s", ti->id3.path); loadruntimeinfo(ti->id3.path); @@ -327,7 +344,8 @@ int rundb_init(void) #endif if ( (rundbheader.version&0xFF) != RUNDB_VERSION) { - splash(HZ,true,"Unsupported runtime database version %d!", rundbheader.version&0xFF); + splash(HZ,true,"Unsupported runtime database version %d!", + rundbheader.version&0xFF); return -1; } @@ -339,7 +357,8 @@ int rundb_init(void) #endif } -void writerundbheader(void) { +void writerundbheader(void) +{ lseek(rundb_fd,0,SEEK_SET); write(rundb_fd, &rundbheader, 8); fsync(rundb_fd); @@ -361,7 +380,8 @@ void getrundbentrybyoffset(int offset) { #endif } -int getrundbentrybyhash(int hash) { +int getrundbentrybyhash(int hash) +{ int min=0; for(min=0;min