From 9baa31f1351b6d831e650de4cf25eb474cfee2f3 Mon Sep 17 00:00:00 2001 From: aoki_ryoma Date: Fri, 4 Jul 2008 02:49:33 +0000 Subject: [PATCH] =?UTF-8?q?memset=E3=80=81sprintf=E3=80=81sscanf=E3=82=92?= =?UTF-8?q?=E3=81=9D=E3=82=8C=E3=81=9E=E3=82=8CMI=E3=83=A9=E3=82=A4?= =?UTF-8?q?=E3=83=96=E3=83=A9=E3=83=AA=E3=80=81STD=E3=83=A9=E3=82=A4?= =?UTF-8?q?=E3=83=96=E3=83=A9=E3=83=AA=E3=81=AE=E9=96=A2=E6=95=B0=E3=81=AB?= =?UTF-8?q?=E7=BD=AE=E6=8F=9B=E3=80=82=20=E3=83=86=E3=82=B9=E3=83=88?= =?UTF-8?q?=E3=83=97=E3=83=AD=E3=82=B0=E3=83=A9=E3=83=A0=E5=86=85=E3=81=AE?= =?UTF-8?q?=E3=82=A8=E3=83=B3=E3=83=88=E3=83=AA=E6=95=B0=E8=A8=88=E7=AE=97?= =?UTF-8?q?=E6=96=B9=E6=B3=95=E3=82=92=E5=A4=89=E6=9B=B4=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/branches/20080626_SDK500fc_plus5_branch@1778 b08762b0-b915-fc4b-9d8c-17b2551a87ff --- .../errorLog/ARM9/src/errorLog.c | 42 ++++++++++--------- .../ErrorLogTest/ARM9/src/ErrorLogTest.c | 11 ++++- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/build/libraries_sysmenu/errorLog/ARM9/src/errorLog.c b/build/libraries_sysmenu/errorLog/ARM9/src/errorLog.c index 0fadd6d8..22c47790 100644 --- a/build/libraries_sysmenu/errorLog/ARM9/src/errorLog.c +++ b/build/libraries_sysmenu/errorLog/ARM9/src/errorLog.c @@ -11,8 +11,8 @@ in whole or in part, without the prior written consent of Nintendo. $Date:: $ - $Rev:$ - $Author:$ + $Rev$ + $Author$ *---------------------------------------------------------------------------*/ // Fatal error発生時に"nand:/sys/log/sysmenu.log"にログを吐くためのライブラリ @@ -235,7 +235,7 @@ CheckStatus ELi_CheckAndCreateFile( FSFile *file, const char *path ) char nullbuf[1024]; int i; - memset( nullbuf, '\0', 1024); + MI_CpuClear8( nullbuf, 1024); for(i = 0; i < 16; i++) { @@ -262,25 +262,27 @@ CheckStatus ELi_CheckAndCreateFile( FSFile *file, const char *path ) int ELi_ReadEntry( FSFile *file, ErrorLogEntry *entry ) { - char buf[ERRORLOG_BUFSIZE]; + char buf[ERRORLOG_BUFSIZE+1]; int numEntry = 0; - FS_SeekFileToBegin( file ); + buf[ERRORLOG_BUFSIZE] = '\0'; + + FS_SeekFileToBegin( file ); FS_ReadFile( file, buf, ERRORLOG_BUFSIZE ); // エントリの頭には必ず'#'が書き込まれているのでそれで判定 while( buf[0] == '#' ) { // 決められたファイルフォーマットからエントリに読み込む - sscanf( buf, ERRORLOG_READ_FORMAT, - &(entry[numEntry].year) , - &(entry[numEntry].month) , - &(entry[numEntry].day) , - &(entry[numEntry].week) , - &(entry[numEntry].hour) , - &(entry[numEntry].minute) , - &(entry[numEntry].second) , - &(entry[numEntry].errorCode) ); + STD_TSScanf( buf, ERRORLOG_READ_FORMAT, + &(entry[numEntry].year) , + &(entry[numEntry].month) , + &(entry[numEntry].day) , + &(entry[numEntry].week) , + &(entry[numEntry].hour) , + &(entry[numEntry].minute) , + &(entry[numEntry].second) , + &(entry[numEntry].errorCode) ); numEntry++; @@ -306,10 +308,10 @@ int ELi_ReadEntry( FSFile *file, ErrorLogEntry *entry ) BOOL ELi_SetString( char *buf, ErrorLogEntry *entry ) { - snprintf(buf, ERRORLOG_BUFSIZE, ERRORLOG_WRITE_FORMAT, - entry->year, entry->month, entry->day, entry->week, - entry->hour, entry->minute, entry->second, - entry->errorCode, s_strError[entry->errorCode] ); + STD_TSNPrintf(buf, ERRORLOG_BUFSIZE, ERRORLOG_WRITE_FORMAT, + entry->year, entry->month, entry->day, entry->week, + entry->hour, entry->minute, entry->second, + entry->errorCode, s_strError[entry->errorCode] ); // 余りをスペースで埋めて、改行で終端する ELi_fillSpace( buf, ERRORLOG_BUFSIZE ); @@ -388,7 +390,7 @@ BOOL ELi_WriteLog( FSFile *file ,ErrorLogEntry *entry, int num, u64 err ) // ファイルの余りを0埋めする // open modeがサイズ固定なのでファイル終端を気にせず書き込む - memset( buf, '\0', ERRORLOG_BUFSIZE ); + MI_CpuClear8( buf, ERRORLOG_BUFSIZE ); while ( FS_WriteFile( file, buf, (s32) ERRORLOG_BUFSIZE ) == ERRORLOG_BUFSIZE ) {}; @@ -407,7 +409,7 @@ void ELi_fillSpace( char *buf, int bufsize ) // エントリの末尾にスペースを入れて // 一つのエントリがちょうど128バイトになるように辻褄を合わせる u32 length = strlen( buf ); - memset( &buf[length], ' ', bufsize - length ); + MI_CpuFill8( &buf[length], ' ', bufsize - length ); } static char *s_strWeek[] = { diff --git a/build/tests/ErrorLogTest/ARM9/src/ErrorLogTest.c b/build/tests/ErrorLogTest/ARM9/src/ErrorLogTest.c index 519c94ae..eec34fb9 100644 --- a/build/tests/ErrorLogTest/ARM9/src/ErrorLogTest.c +++ b/build/tests/ErrorLogTest/ARM9/src/ErrorLogTest.c @@ -69,9 +69,18 @@ void TwlMain( void ) while( ( nowSize = FS_ReadFile( &file, buf, BUFSIZE ) ) == BUFSIZE ) { + char *p = buf; + OS_TPrintf("%s",buf); - numEntry++; totalSize += nowSize; + + while( (p = STD_SearchChar(p, '#')) != NULL) + { + // '#'が出てきた回数だけエントリ数を増やす + numEntry++; + p++; + } + } OS_TPrintf("%s\n",buf);