forked from n5ac/mmsstv
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathLogFile.h
280 lines (229 loc) · 7.62 KB
/
LogFile.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
//Copyright+LGPL
//-----------------------------------------------------------------------------------------------------------------------------------------------
// Copyright 2000-2013 Makoto Mori, Nobuyuki Oba
//-----------------------------------------------------------------------------------------------------------------------------------------------
// This file is part of MMSSTV.
// MMSSTV 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.
// MMSSTV 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"
typedef struct { // Logの動作オプション
char m_TimeZone; // 表示用タイムゾーン
int m_UpperName; // 大文字への変換
int m_UpperQTH; // 大文字への変換
int m_UpperREM; // 大文字への変換
int m_UpperQSL; // 大文字への変換
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; // 自動セーブ
int m_QSOMacroFlag; // 0-OFF, 1-ON
int m_CheckBand; // 同一バンドでの重複をチェック
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;
int m_THTZ;
int m_ClipRSTADIF;
int m_DateType;
int m_FSKNR; // コンテストNRをFSKIDに含める
int m_Backup; // バックアップ作成
BYTE m_Hamlog5Len[17];
}LOGSET;
#define MLCALL 16 /* コールサインの長さ */
#define MLRST 20 /* RSTナンバの長さ */
#define MLREM 56 /* 記事の長さ */
#define MLNAME 16 /* 名前の長さ */
#define MLQTH 28 /* QTHの長さ */
#define MLQSL 54 /* QSLの長さ */
#define MLPOW 4 /* 電力 */
#define MLOPT 8 /* オプション */
#define MODEMAX 48
#define YEAR(c) (((c)<50)?(2000+(c)):(1900+(c)))
#pragma option -a- // パックの指示
typedef struct { /* MMLOGデータ形式 */
BYTE year; /* 年 */
WORD date; /* 日付 */
WORD btime; /* 開始時刻 */
WORD etime; /* 終了時刻 */
char call[MLCALL+1]; /* コールサイン */
char ur[MLRST+1]; /* T リポート */
char my[MLRST+1]; /* R リポート */
BYTE band; /* バンド */
SHORT fq; /* 周波数 */
BYTE mode; /* モード */
char pow[MLPOW+1]; /* 電力 */
char name[MLNAME+1]; /* 名前 */
char qth[MLQTH+1]; /* QTH */
char qsl[MLQSL+1]; /* QSL */
char send; /* QSL 送信 */
char recv; /* QSL 受信 */
char cq; /* cq/call */
WORD env; /* 自局環境 */
char rem[MLREM+1]; /* 記事 */
char opt1[MLOPT+1]; /* オプション */
char opt2[MLOPT+1]; /* オプション2 */
}SDMMLOG;
#define FHDOFF 256 /* 先頭のヘッダのオフセット */
#define UMODEMAX 32
typedef struct {
char id[20]; /* ファイルバージョン */
char dmy[4]; /* ダミー領域 */
USHORT mlt; /* マルチ情報のサイズ */
char td; /* 時差コード */
char hash; /* ハッシュデータ格納フラグ */
long size; /* データサイズ */
char master; /* マスターファイルフラグ */
char dm2[15]; /* ダミー2 */
char mode[UMODEMAX][6]; /* ユーザ定義モード */
}FHD;
#pragma option -a. // パック解除の指示
class CIndex
{
private:
int m_IndexMax; // 確保中のインデックスの数
int m_IndexCnt; // 現在のインデックスの数
LPSTR pIndex; // インデックス領域のポインタ(16バイトインデックス)
BYTE *pMult; // マルチ情報のポインタ
public:
CIndex();
~CIndex();
void AllocIndex(int n);
void ClearIndex(void);
void WriteIndex(LPCSTR pCall, int n);
void ReadIndex(LPSTR pCall, int n);
LPSTR PointIndex(int n);
void AddBlock(LPCSTR p, int len);
int ReadIndex(int handle, FHD *hp);
void MakeIndex(int handle, FHD *hp);
int 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:
CLogFind();
~CLogFind();
inline int GetCount(void){return m_FindCnt;};
inline void Clear(void){
m_FindCnt = m_FindCmp1Max = m_FindCmp2Max = m_FindStr1Max = m_FindStr2Max = 0;
};
int Add(int n);
void Ins(int n);
inline void Write(int n){
pFindTbl[m_FindCnt] = n;
m_FindCnt++;
};
inline void SetText(LPCSTR p){
if( p != m_FindStr.c_str() ){
m_FindStr = p;
}
};
inline LPCSTR GetText(void){
return m_FindStr.c_str();
};
inline void ClearText(void){
m_FindStr = "";
};
};
class CLogFile
{
private:
int m_Open; // オープンフラグ
int m_EditFlag; // 編集フラグ
int m_Handle; // ファイルハンドル
CIndex m_Index; // 現在オープン中のインデックス
FHD m_fhd; // 現在オープン中のファイルヘッダ
AnsiString m_Name; // ログファイルの名前
char m_modebuf[8];
public:
AnsiString m_FileName; // ログファイルの名前(フルパス)
int m_CurNo;
int m_CurChg;
SDMMLOG m_sd;
SDMMLOG m_bak;
SDMMLOG m_asd;
CLogFind m_Find; // カレント検索データ
LOGSET m_LogSet;
private:
void SetHisRST(SDMMLOG *sp);
void InitHeader(void);
public:
CLogFile();
~CLogFile();
void DoBackup(void);
int Open(LPCSTR pName, BOOL fNew);
int Close(void);
void ReadIniFile(LPCSTR pKey, TMemIniFile *pIniFile);
void WriteIniFile(LPCSTR pKey, TMemIniFile *pIniFile);
void MakeIndex(void);
inline IsEdit(void){return m_EditFlag;};
void MakePathName(LPCSTR pName);
void MakeName(LPCSTR pName);
inline LPCSTR GetName(void){return m_Name.c_str();};
inline int GetCount(void){return m_fhd.size;};
inline int IsOpen(void){return m_Open;};
int GetData(SDMMLOG *sp, int n);
int PutData(SDMMLOG *sp, int n);
LPCSTR GetDateString(SDMMLOG *sp, int sw);
inline LPCSTR GetDateString(SDMMLOG *sp){ return GetDateString(sp, m_LogSet.m_DateType); };
LPCSTR GetTimeString(WORD d);
LPCSTR GetModeString(BYTE m);
void SetMode(SDMMLOG *sp, LPCSTR s);
LPCSTR GetFreqString(BYTE b, short fq);
void SetFreq(SDMMLOG *sp, LPCSTR p);
LPCSTR GetOptStr(int n, SDMMLOG *sp);
void SetOptStr(int n, SDMMLOG *sp, LPCSTR pOpt);
void CopyAF(void);
void SortDate(int bb, int eb);
int FindSameBand(void);
int FindSameDate(void);
void FindStrSet(CLogFind *fp, LPCSTR pCall);
int FindCmpSet(CLogFind *fp, LPCSTR pCall);
int FindClipSet(CLogFind *fp, LPCSTR pCall);
int FindSet(CLogFind *fp, LPCSTR pCall);
int Find(LPCSTR pCall, int b, int dir);
int IsAlready(LPCSTR pCall);
void DeleteAll(void);
void DeleteLast(void);
void Delete(int top, int end);
void Insert(int n, SDMMLOG *sp);
void InitCur(void);
void SetLastPos(void);
int ReadAscii(SDMMLOG *sp, LPSTR p);
};
void JSTtoUTC(int &Year, int &Mon, int &Day, int &Hour);
void JSTtoUTC(SDMMLOG *sp);
void UTCtoJST(int &Year, int &Mon, int &Day, int &Hour);
void UTCtoJST(SDMMLOG *sp);
void UTCtoJST(SYSTEMTIME *tp);
void mBandToBand(SDMMLOG *sp, LPCSTR p);
LPCSTR FreqTomBand(SDMMLOG *sp);
int GetLMode(BYTE m);
extern CLogFile Log;
extern const char MONN[];
extern const char MONU[];
#endif