mmvari/LogFile.h

281 lines
8.4 KiB
C
Raw Permalink Normal View History

2013-07-05 22:09:45 +02:00
//Copyright+LGPL
//-----------------------------------------------------------------------------------------------------------------------------------------------
// Copyright 2000-2013 Makoto Mori, Nobuyuki Oba
//-----------------------------------------------------------------------------------------------------------------------------------------------
// This file is part of MMVARI.
// MMVARI is free software: you can redistribute it and/or modify it under the terms of the GNU Lesser General Public License
// as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
// MMVARI is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details.
// You should have received a copy of the GNU Lesser General Public License along with MMTTY. If not, see
// <http://www.gnu.org/licenses/>.
//-----------------------------------------------------------------------------------------------------------------------------------------------
//---------------------------------------------------------------------------
#ifndef LogFileH
#define LogFileH
#include "ComLib.h"
//---------------------------------------------------------------------------
#define MMLOGID "MMLOG DATA Ver1.00\032"
extern const char *_band[];
typedef struct { // Log<6F>̓<EFBFBD><CC93><EFBFBD><EFBFBD>I<EFBFBD>v<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD>
char m_TimeZone; // <20>\<5C><><EFBFBD>p<EFBFBD>^<5E>C<EFBFBD><43><EFBFBD>]<5D>[<5B><>
int m_UpperName; // <20><EFBFBD><E595B6><EFBFBD>ւ̕ϊ<CC95>
int m_UpperQTH; // <20><EFBFBD><E595B6><EFBFBD>ւ̕ϊ<CC95>
int m_UpperREM; // <20><EFBFBD><E595B6><EFBFBD>ւ̕ϊ<CC95>
int m_UpperQSL; // <20><EFBFBD><E595B6><EFBFBD>ւ̕ϊ<CC95>
int m_DefMyRST; // 0-OFF, 1-ON
int m_CopyFreq; // 0-Band, 1-Freq
int m_CopyHis; // 0-599, 1-599001, 2-599UTC
int m_CopyName; // 0-OFF, 1-ON
int m_CopyQTH; // 0-OFF, 1-ON
int m_CopyREM; // 0-OFF, 1-ON
int m_CopyQSL; // 0-OFF, 1-ON
int m_CopyREMB4; // 0-OFF, 1-ON
int m_AutoSave; // <20><><EFBFBD><EFBFBD><EFBFBD>Z<EFBFBD>[<5B>u
int m_QSOMacroFlag; // 0-OFF, 1-ON
int m_CheckBand; // <20><><EFBFBD><EFBFBD><EFBFBD>o<EFBFBD><6F><EFBFBD>h<EFBFBD>ł̏d<CC8F><64><EFBFBD><EFBFBD><EFBFBD>`<60>F<EFBFBD>b<EFBFBD>N
int m_QSOMacro[5]; // 0-Run 1st, 1-Run 2nd, 2-Run Dupe, 3-S&P 1st, 4-S&P 2nd
WORD m_QSOMacroKey[5];
AnsiString m_QSOMacroStr[5];
AnsiString m_THRTTY;
AnsiString m_THSSTV;
AnsiString m_THGMSK;
int m_THTZ;
int m_ClipRSTADIF;
int m_DateType;
int m_Backup; // <20>o<EFBFBD>b<EFBFBD>N<EFBFBD>A<EFBFBD>b<EFBFBD>v<EFBFBD>
BYTE m_Hamlog5Len[17];
}LOGSET;
#define MLCALL 16 /* <20><>ٻ<EFBFBD>݂̒<DD82><CC92><EFBFBD> */
#define MLRST 20 /* RST<53>i<EFBFBD><69><EFBFBD>o<EFBFBD>̒<EFBFBD><CC92><EFBFBD> */
#define MLREM 56 /* <20>L<EFBFBD><4C><EFBFBD>̒<EFBFBD><CC92><EFBFBD> */
#define MLNAME 16 /* <20><><EFBFBD>O<EFBFBD>̒<EFBFBD><CC92><EFBFBD> */
#define MLQTH 28 /* <20>p<EFBFBD>s<EFBFBD>g<EFBFBD>̒<EFBFBD><CC92><EFBFBD> */
#define MLQSL 54 /* <20>p<EFBFBD>r<EFBFBD>k<EFBFBD>̒<EFBFBD><CC92><EFBFBD> */
#define MLPOW 4 /* <20>d<EFBFBD><64> */
#define MLOPT 8 /* <20>I<EFBFBD>v<EFBFBD>V<EFBFBD><56><EFBFBD><EFBFBD> */
#define MODEMAX 48
#define YEAR(c) (((c)<50)?(2000+(c)):(1900+(c)))
#pragma option -a- // <20>p<EFBFBD>b<EFBFBD>N<EFBFBD>̎w<CC8E><77>
typedef struct { /* <20>l<EFBFBD>l<EFBFBD>k<EFBFBD>n<EFBFBD>f<EFBFBD>f<EFBFBD>[<5B>^<5E>`<60><> */
BYTE year; /* <20>N */
WORD date; /* <20><><EFBFBD>t */
WORD btime; /* <20>J<EFBFBD>n<EFBFBD><6E><EFBFBD><EFBFBD> */
WORD etime; /* <20>I<EFBFBD><49><EFBFBD><EFBFBD><EFBFBD><EFBFBD> */
char call[MLCALL+1]; /* <20><>ٻ<EFBFBD><D9BB> */
char ur[MLRST+1]; /* T <20><>߰<EFBFBD> */
char my[MLRST+1]; /* R <20><>߰<EFBFBD> */
BYTE band; /* <20><><EFBFBD><EFBFBD><EFBFBD> */
SHORT fq; /* <20><><EFBFBD>g<EFBFBD><67> */
BYTE mode; /* Ӱ<><D3B0> */
char pow[MLPOW+1]; /* <20>d<EFBFBD><64> */
char name[MLNAME+1]; /* <20><><EFBFBD>O */
char qth[MLQTH+1]; /* QTH */
char qsl[MLQSL+1]; /* QSL */
char send; /* QSL <20><><EFBFBD>M */
char recv; /* QSL <20><><EFBFBD>M */
char cq; /* cq/call */
WORD env; /* <20><><EFBFBD>NJ‹<C78A> */
char rem[MLREM+1]; /* <20>L<EFBFBD><4C> */
char opt1[MLOPT+1]; /* <20><>߼<EFBFBD><DFBC> */
char opt2[MLOPT+1]; /* <20><>߼<EFBFBD><DFBC>2 */
}SDMMLOG;
#define FHDOFF 256 /* <20><EFBFBD>̃w<CC83>b<EFBFBD>_<EFBFBD>̃I<CC83>t<EFBFBD>Z<EFBFBD>b<EFBFBD>g */
#define UMODEMAX 32
typedef struct {
char id[20]; /* <20>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD>o<EFBFBD>[<5B>W<EFBFBD><57><EFBFBD><EFBFBD> */
char dmy[4]; /* <20>_<EFBFBD>~<7E>[<5B>̈<EFBFBD> */
USHORT mlt; /* <20>}<7D><><EFBFBD>`<60><><EFBFBD><EFBFBD><EFBFBD>̃T<CC83>C<EFBFBD>Y */
char td; /* <20><><EFBFBD><EFBFBD><EFBFBD>R<EFBFBD>[<5B>h */
char hash; /* <20>n<EFBFBD>b<EFBFBD>V<EFBFBD><56><EFBFBD>f<EFBFBD>[<5B>^<5E>i<EFBFBD>[<5B>t<EFBFBD><74><EFBFBD>O */
long size; /* <20>f<EFBFBD>[<5B>^<5E>T<EFBFBD>C<EFBFBD>Y */
char master; /* <20>}<7D>X<EFBFBD>^<5E>[<5B>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD>t<EFBFBD><74><EFBFBD>O */
char dm2[15]; /* <20>_<EFBFBD>~<7E>[<5B>Q */
char mode[UMODEMAX][6]; /* <20><><EFBFBD>[<5B>U<EFBFBD><55><EFBFBD>`<60><><EFBFBD>[<5B>h */
}FHD;
#pragma option -a. // <20>p<EFBFBD>b<EFBFBD>N<EFBFBD><4E><EFBFBD><EFBFBD><EFBFBD>̎w<CC8E><77>
class CIndex
{
private:
int m_IndexMax; // <20>m<EFBFBD>ے<EFBFBD><DB92>̃C<CC83><43><EFBFBD>f<EFBFBD>b<EFBFBD>N<EFBFBD>X<EFBFBD>̐<EFBFBD>
int m_IndexCnt; // <20><><EFBFBD>݂̃C<CC83><43><EFBFBD>f<EFBFBD>b<EFBFBD>N<EFBFBD>X<EFBFBD>̐<EFBFBD>
LPSTR pIndex; // <20>C<EFBFBD><43><EFBFBD>f<EFBFBD>b<EFBFBD>N<EFBFBD>X<EFBFBD>̈<EFBFBD><CC88>̃|<7C>C<EFBFBD><43><EFBFBD>^(16<31>o<EFBFBD>C<EFBFBD>g<EFBFBD>C<EFBFBD><43><EFBFBD>f<EFBFBD>b<EFBFBD>N<EFBFBD>X)
BYTE *pMult; // <20>}<7D><><EFBFBD>`<60><><EFBFBD><EFBFBD><EFBFBD>̃|<7C>C<EFBFBD><43><EFBFBD>^
public:
__fastcall CIndex();
__fastcall ~CIndex();
void __fastcall AllocIndex(int n);
void __fastcall ClearIndex(void);
void __fastcall WriteIndex(LPCSTR pCall, int n);
void __fastcall ReadIndex(LPSTR pCall, int n);
LPSTR __fastcall PointIndex(int n);
void __fastcall AddBlock(LPCSTR p, int len);
int __fastcall ReadIndex(int handle, FHD *hp);
void __fastcall MakeIndex(int handle, FHD *hp);
int __fastcall WriteIndex(int handle, FHD *hp);
};
#define FINDMAX 32768
class CLogFind
{
public:
int m_FindCnt;
int m_FindCmp1Max;
int m_FindCmp2Max;
int m_FindStr1Max;
int m_FindStr2Max;
int *pFindTbl;
AnsiString m_FindStr;
public:
__fastcall CLogFind();
__fastcall ~CLogFind();
inline int __fastcall GetCount(void){return m_FindCnt;};
inline void __fastcall Clear(void){
m_FindCnt = m_FindCmp1Max = m_FindCmp2Max = m_FindStr1Max = m_FindStr2Max = 0;
};
int __fastcall Add(int n);
void __fastcall Ins(int n);
inline void __fastcall Write(int n){
pFindTbl[m_FindCnt] = n;
m_FindCnt++;
};
inline void __fastcall SetText(LPCSTR p){
if( p != m_FindStr.c_str() ){
m_FindStr = p;
}
};
inline LPCSTR __fastcall GetText(void){
return m_FindStr.c_str();
};
inline void __fastcall ClearText(void){
m_FindStr = "";
};
};
class CLogFile
{
private:
int m_Open; // <20>I<EFBFBD>[<5B>v<EFBFBD><76><EFBFBD>t<EFBFBD><74><EFBFBD>O
int m_EditFlag; // <20>ҏW<D28F>t<EFBFBD><74><EFBFBD>O
int m_Handle; // <20>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD>n<EFBFBD><6E><EFBFBD>h<EFBFBD><68>
CIndex m_Index; // <20><><EFBFBD>݃I<DD83>[<5B>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD>̃C<CC83><43><EFBFBD>f<EFBFBD>b<EFBFBD>N<EFBFBD>X
FHD m_fhd; // <20><><EFBFBD>݃I<DD83>[<5B>v<EFBFBD><76><EFBFBD><EFBFBD><EFBFBD>̃t<CC83>@<40>C<EFBFBD><43><EFBFBD>w<EFBFBD>b<EFBFBD>_
AnsiString m_Name; // <20><><EFBFBD>O<EFBFBD>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD>̖<EFBFBD><CC96>O
char m_modebuf[8];
public:
AnsiString m_FileName; // <20><><EFBFBD>O<EFBFBD>t<EFBFBD>@<40>C<EFBFBD><43><EFBFBD>̖<EFBFBD><CC96>O<EFBFBD>i<EFBFBD>t<EFBFBD><74><EFBFBD>p<EFBFBD>X<EFBFBD>j
int m_CurNo;
int m_CurChg;
SDMMLOG m_sd;
SDMMLOG m_bak;
SDMMLOG m_asd;
CLogFind m_Find; // <20>J<EFBFBD><4A><EFBFBD><EFBFBD><EFBFBD>g<EFBFBD><67><EFBFBD><EFBFBD><EFBFBD>f<EFBFBD>[<5B>^
LOGSET m_LogSet;
private:
void __fastcall SetHisRST(SDMMLOG *sp);
void __fastcall InitHeader(void);
public:
__fastcall CLogFile();
__fastcall ~CLogFile();
void __fastcall DoBackup(void);
int __fastcall Open(LPCSTR pName, BOOL fNew);
int __fastcall Close(void);
void __fastcall ReadIniFile(LPCSTR pKey, TMemIniFile *pIniFile);
void __fastcall WriteIniFile(LPCSTR pKey, TMemIniFile *pIniFile);
void __fastcall MakeIndex(void);
inline int __fastcall IsEdit(void){return m_EditFlag;};
void __fastcall MakePathName(LPCSTR pName);
void __fastcall MakeName(LPCSTR pName);
inline LPCSTR __fastcall GetName(void){return m_Name.c_str();};
inline int __fastcall GetCount(void){return m_fhd.size;};
inline int __fastcall IsOpen(void){return m_Open;};
int __fastcall GetData(SDMMLOG *sp, int n);
int __fastcall PutData(SDMMLOG *sp, int n);
LPCSTR __fastcall GetDateString(SDMMLOG *sp, int sw);
inline LPCSTR __fastcall GetDateString(SDMMLOG *sp){ return GetDateString(sp, m_LogSet.m_DateType); };
LPCSTR __fastcall GetTimeString(WORD d);
LPCSTR __fastcall GetModeString(BYTE m);
void __fastcall SetMode(SDMMLOG *sp, LPCSTR s);
LPCSTR __fastcall GetFreqString(BYTE b, short fq);
void __fastcall SetFreq(SDMMLOG *sp, LPCSTR p);
LPCSTR __fastcall GetOptStr(int n, SDMMLOG *sp);
void __fastcall SetOptStr(int n, SDMMLOG *sp, LPCSTR pOpt);
void __fastcall CopyAF(void);
void __fastcall SortDate(int bb, int eb);
int __fastcall FindSameBand(BOOL fMode);
int __fastcall FindSameDate(void);
void __fastcall FindStrSet(CLogFind *fp, LPCSTR pCall);
int __fastcall FindCmpSet(CLogFind *fp, LPCSTR pCall);
int __fastcall FindClipSet(CLogFind *fp, LPCSTR pCall);
int __fastcall FindSet(CLogFind *fp, LPCSTR pCall);
int __fastcall Find(LPCSTR pCall, int b, int dir);
int __fastcall IsAlready(LPCSTR pCall);
void __fastcall DeleteAll(void);
void __fastcall DeleteLast(void);
void __fastcall Delete(int top, int end);
void __fastcall Insert(int n, SDMMLOG *sp);
void __fastcall InitCur(void);
void __fastcall SetLastPos(void);
int __fastcall ReadAscii(SDMMLOG *sp, LPSTR p);
};
void __fastcall JSTtoUTC(int &Year, int &Mon, int &Day, int &Hour);
void __fastcall JSTtoUTC(SDMMLOG *sp);
void __fastcall UTCtoJST(int &Year, int &Mon, int &Day, int &Hour);
void __fastcall UTCtoJST(SDMMLOG *sp);
void __fastcall UTCtoJST(SYSTEMTIME *tp);
void __fastcall mBandToBand(SDMMLOG *sp, LPCSTR p);
LPCSTR __fastcall FreqTomBand(SDMMLOG *sp);
int __fastcall GetLMode(BYTE m);
extern CLogFile Log;
extern const char MONN[];
extern const char MONU[];
#endif