memset、sprintf、sscanfをそれぞれMIライブラリ、STDライブラリの関数に置換。 テストプログラム内のエントリ数計算方法を変更。

git-svn-id: file:///Users/lillianskinner/Downloads/platinum/twl/TwlIPL/branches/20080626_SDK500fc_plus5_branch@1778 b08762b0-b915-fc4b-9d8c-17b2551a87ff
This commit is contained in:
aoki_ryoma 2008-07-04 02:49:33 +00:00
parent 87b2a11270
commit 9baa31f135
2 changed files with 32 additions and 21 deletions

View File

@ -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[] = {

View File

@ -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);