// SVN1-5150-CR05-055B-1237-7421
//**************************************************************** **
// eventLog.c
//
// Copyright 2003 by ITC, eN1. All rights reserved.
//
// Author: Chen Shuqing
//
// Date: 03/10/14
//
// Description: Read and write event log for NAS2.0.
//
// interface:
// Initial log library, it's called by NAS OS.
// bool LO_Initial();
//
// Exit log library, it's called by NAS OS.
// void LO_Exit();
//
// Write event log information.
// bool LO_WriteItem(struct WRITE_LOGITEM* stuLogItem);
//
// Initial alignment before reading log item.
// bool LO_ReadItem_Initial(time_t lStartTime,
// int nTimeValue,
// int nTimeUnit,
// int nLanguageCode);
//
// Read an item of log information.
// bool LO_ReadItem(struct READ_LOGITEM* stuLogItem);
//
// Set parameters for mail log information email.
// bool SetEmailLogPara(int nDay, int nLanguageCode);
//
// Get parameters for log information email option.
// bool GetEmailLogPara(time_t *ltime,
// *int nDay,
// int *nLanguageCode);
//
// Get info of eventlog.
// bool LO_GetLogInfo(int nlogCode, int nLanguageCode,
// int *nLevel, char* szLogContents);
//
// Function:
// About writing:
// Write event log information.
// bool WriteItem(struct WRITE_LOGITEM* stuLogItem);
//
// Write eventlog
// bool WriteEventLog(struct WRITE_LOGITEM* stuLogItem);
//
// Create new log file.
// FILE* CreateLogFile();
//
// About reading:
// Initial alignment before reading log item.
// bool ReadItem_Initial(time_t lStartTime,
// int nTimeValue,
// int nTimeUnit,
// int nLanguageCode);
//
// Read an item of log information.
// bool ReadItem(struct READ_LOGITEM* stuLogItem);
//
// Reading end.
// bool LO_ReadEnd();
//
// Set Language code for reading log.
// void SetLanguageCode(int nLanguageCode);
//
// Set time for reading log.
// void SetTime(int nTimeValue, int nTimeUnit);
//
// Initial pointer of log file and varible.
// bool InitialLogFile();
//
// Read log data form define file.
// bool ReadDataFromLogDefFile();
//
// fill in parameters to eventlog struct
// bool FillInStructure(struct READ_LOGITEM* stuLogItem);
//
// test time value
// bool IsOutdated(time_t lLogTime);
//
// get log level and contents
// bool GetLogInfo(int nlogCode,
// int *nLevel,
// char* szLogContents);
//
// Replace substring.
// void ReplaceString(char* szString,
// char* szSubString,
// char* szReplaceString);
//
// calculate the maximum
// int MaxValue(int nInt1, int nInt2);
//
// calculate size of a log item
// int CalculateLogItemSize(
// struct WRITE_LOGITEM* stuLogItem);
//
// About semaphore:
// initial semaphore
// static int set_semvalue(void);
//
// delete semaphore
// static void del_semvalue(void);
//
// semaphore P()
// static int semaphore_p(void);
//
// semaphore V()
// static int semaphore_v(void);
//
// About semaphore:
// file lock opration: P()
// bool P();
//
// file lock opration: V()
// void V();
//
// About log mail:
// Set parameters for mail log information email.
// bool WriteEmailLogPara(int nDay, int nLanguageCode);
//
// Get parameters for log information email option.
// bool ReadEmailLogPara(time_t *ltime,
// int *nDay,
// int *nLanguageCode);
//
// Notes: Record the note during the programing
//
// Update:
// Date Name Description
// ========== ============== ==================================-=
// 2003-10-14 Chen Shuqing creating
// 2003-10-15 Chen Shuqing modify eventlog structure
// 2003-10-21 Chen Shuqing modify API name of eventlog
// interface and structure
// 2003-11-11 Chen Shuqing modify API parameters
// 2003-11-18 Chen Shuqing add API of log mail
// 2003-12-19 Chen Shuqing add function (ReadDataFromLogDefFile)
//
// Known restrictions: Writing and reading is mutually exclusive operation.
// Although the linux service syslog could maintain this itself
// We have to known about this.
// But we could ignore the P,V function that defined in NAS
//
// Known bugs:
//****************************************************
// Issue Code: ITC-407-97
// Test Version: A03
// In charge of: itc205042, Zhao , Wei
// Finish Time: 2006/01/19
// Reason Analysis: task&log table error
// SDD Version:
//****************************************************
//****************************************************
// Issue Code: ITC-407-215
// Test Version: A03
// In charge of: itc205042, Zhao , Wei
// Finish Time: 2006/03/09
// Reason Analysis: task&log table error about reboot reason
// SDD Version:
//****************************************************
//****************************************************
// Issue Code: ITC-468-22
// Test Version: A01
// In charge of: itc205042, Zhao , Wei
// Finish Time: 2006/08/15
// Reason Analysis: we should not use syslogd
// SDD Version:
//****************************************************
//****************************************************
// Issue Code: ITC-468-23
// Test Version: A01
// In charge of: itc205042, Zhao , Wei
// Finish Time: 2006/08/15
// Reason Analysis: we should not use syslogd
// SDD Version:
//****************************************************
//****************************************************
// Issue Code: ITC-468-60
// Test Version: A01
// In charge of: itc205042, Zhao , Wei
// Finish Time: 2006/08/15
// Reason Analysis: context not very detailed
// SDD Version:
//****************************************************
//****************************************************
// Issue Code: ITC-468-132
// Test Version: A03
// In charge of: itc205042, Zhao , Wei
// Finish Time: 2006/09/11
// Reason Analysis: context not very detailed