2014-08-29 07:49:51 +00:00
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
// Copyright (C) 2014
|
|
|
|
// David Freese, W1HKJ
|
|
|
|
//
|
|
|
|
// This file is part of fldigi
|
|
|
|
//
|
|
|
|
// fldigi is free software; you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation; either version 3 of the License, or
|
|
|
|
// (at your option) any later version.
|
|
|
|
//
|
|
|
|
// fldigi 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 General Public License for more details.
|
|
|
|
//
|
|
|
|
// You should have received a copy of the GNU General Public License
|
|
|
|
// along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
|
|
// ----------------------------------------------------------------------------
|
|
|
|
|
2008-11-26 06:21:13 +00:00
|
|
|
#ifndef ADIFIO
|
|
|
|
#define ADIFIO
|
|
|
|
|
2009-04-12 22:57:17 +00:00
|
|
|
#include <cstdio>
|
2010-07-15 15:24:20 +00:00
|
|
|
#include <cstring>
|
2008-11-26 06:21:13 +00:00
|
|
|
|
|
|
|
#include "qso_db.h"
|
|
|
|
|
2009-06-01 22:50:09 +00:00
|
|
|
#define ADIF_VERS "2.2.3"
|
2008-11-26 06:21:13 +00:00
|
|
|
|
|
|
|
class cAdifIO {
|
|
|
|
private:
|
2008-12-06 23:35:09 +00:00
|
|
|
bool write_all;
|
2011-11-18 23:09:52 +00:00
|
|
|
cQsoRec *adifqso;
|
2008-12-06 23:35:09 +00:00
|
|
|
FILE *adiFile;
|
2015-11-12 12:25:32 +00:00
|
|
|
char *fillfield(int, int, char *);
|
2011-11-23 15:42:44 +00:00
|
|
|
static int instances;
|
2008-11-26 06:21:13 +00:00
|
|
|
public:
|
2009-03-21 23:41:36 +00:00
|
|
|
cAdifIO ();
|
2011-11-23 15:42:44 +00:00
|
|
|
~cAdifIO ();
|
2008-12-06 23:35:09 +00:00
|
|
|
int readAdifRec () {return 0;};
|
|
|
|
int writeAdifRec () {return 0;};
|
|
|
|
void readFile (const char *, cQsoDb *);
|
2011-11-17 13:37:07 +00:00
|
|
|
void do_readfile(const char *, cQsoDb *);
|
|
|
|
void do_writelog();
|
2008-12-06 23:35:09 +00:00
|
|
|
int writeFile (const char *, cQsoDb *);
|
2011-11-17 13:37:07 +00:00
|
|
|
int writeLog (const char *, cQsoDb *, bool b = true);
|
2010-07-15 15:24:20 +00:00
|
|
|
bool log_changed(const char *fname);
|
|
|
|
};
|
|
|
|
|
|
|
|
// crc 16 cycle redundancy check sum
|
|
|
|
|
|
|
|
class Ccrc16 {
|
|
|
|
private:
|
|
|
|
unsigned int crcval;
|
|
|
|
char ss[5];
|
|
|
|
public:
|
|
|
|
Ccrc16() { crcval = 0xFFFF; }
|
|
|
|
~Ccrc16() {};
|
|
|
|
void reset() { crcval = 0xFFFF;}
|
|
|
|
unsigned int val() {return crcval;}
|
|
|
|
std::string sval() {
|
|
|
|
snprintf(ss, sizeof(ss), "%04X", crcval);
|
|
|
|
return ss;
|
|
|
|
}
|
|
|
|
void update(char c) {
|
2013-05-19 18:16:41 +00:00
|
|
|
crcval ^= c & 255;
|
|
|
|
for (int i = 0; i < 8; ++i) {
|
|
|
|
if (crcval & 1)
|
|
|
|
crcval = (crcval >> 1) ^ 0xA001;
|
|
|
|
else
|
|
|
|
crcval = (crcval >> 1);
|
|
|
|
}
|
2010-07-15 15:24:20 +00:00
|
|
|
}
|
|
|
|
unsigned int crc16(char c) {
|
|
|
|
update(c);
|
|
|
|
return crcval;
|
|
|
|
}
|
|
|
|
unsigned int crc16(std::string s) {
|
|
|
|
reset();
|
|
|
|
for (size_t i = 0; i < s.length(); i++)
|
|
|
|
update(s[i]);
|
|
|
|
return crcval;
|
|
|
|
}
|
|
|
|
std::string scrc16(std::string s) {
|
|
|
|
crc16(s);
|
|
|
|
return sval();
|
|
|
|
}
|
2008-11-26 06:21:13 +00:00
|
|
|
};
|
|
|
|
|
2010-03-25 22:36:13 +00:00
|
|
|
|
2008-11-26 06:21:13 +00:00
|
|
|
#endif
|