⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 log.c

📁 Dos6.0
💻 C
字号:
/**************************************************************************/
/***									***/
/***	LOG.C	- Cache hit rate logging routines			***/
/***									***/
/***									***/
/***									***/
/***									***/
/**************************************************************************/

#include <windows.h>
#include <io.h>
#include <stdio.h>
#include "smartmon.h"

char szLogFile[MAXFILENAMELEN];
char *szLogTitle = "   ticks,    total,     hits\r\n";
BOOL fLogAppend = TRUE;
BOOL fAutoStop;
WORD AutoLogTime;	// minutes
int hLogFile;


/**************************************************************************/
/***									***/
/***	StartLog							***/
/***									***/
/**************************************************************************/

BOOL StartLog()
{
    OFSTRUCT of;
    WORD mode;

    mode = OF_WRITE | OF_SHARE_DENY_WRITE;

    //
    // Create file if it doesn't exist or new file is requested
    //
    if ( !fLogAppend ||
	 OpenFile( (LPSTR)szLogFile, (OFSTRUCT FAR *)&of, OF_EXIST ) == -1)
	mode |= OF_CREATE;

    hLogFile = OpenFile( (LPSTR)szLogFile, (OFSTRUCT FAR*)&of, mode );

    if ( hLogFile != -1 ) {
	if ( mode & OF_CREATE )
	    write( hLogFile, szLogTitle, lstrlen(szLogTitle) );
	if ( fLogAppend ) {
	    lseek( hLogFile, 0L, SEEK_END );
	    write( hLogFile, "\r\n", 2 );
	}
	return TRUE;
    }

    return FALSE;
}


/**************************************************************************/
/***									***/
/***	StopLog 							***/
/***									***/
/**************************************************************************/

void StopLog()
{
    if ( hLogFile ) {
	close( hLogFile );
	hLogFile = 0;
    }
}


/**************************************************************************/
/***									***/
/***	WriteLog							***/
/***									***/
/**************************************************************************/

BOOL WriteLog( void )
{
    extern DWORD PrevTotal, PrevHits;
    extern char szBuffer[];

    wsprintf( szBuffer, "%8lu, %8lu, %8lu\r\n",
	GetTickCount(), PrevTotal, PrevHits );
    return write( hLogFile, szBuffer, lstrlen(szBuffer) ) != -1;
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -