forked from oe5hpm/openBCM
-
Notifications
You must be signed in to change notification settings - Fork 0
/
fileio.h
105 lines (77 loc) · 2.72 KB
/
fileio.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
/***************************************************************
BayCom(R) Packet-Radio fuer IBM PC
OpenBayCom-Mailbox
-----------------------------------------------------------------
Filetransfer base class + text- and AutoBIN-methods (definitions)
-----------------------------------------------------------------
Copyright (C) Florian Radlherr
Taubenbergstr. 32
83627 Warngau
Alle Rechte vorbehalten / All Rights Reserved
***************************************************************/
/*---------------------------------------------------------------------------*/
#define REQ_CRCTHP 128
#define REQ_MD5HASH 64
/*---------------------------------------------------------------------------*/
struct file_info_t {
FILE *ptr; // Pointer
int handle; // Handle
char exists; // 1, if file exists
char name[FNAMELEN+1]; // Name without path
char path[FSPATHLEN + FNAMELEN + 1]; // Path
char fullname[FSPATHLEN + FNAMELEN + 1]; // Name with path
off_t size; // Size
off_t offset; // Offset, from which the file will be sent
time_t unixtime; // Date/time in unix-format
unsigned long dostime; // Date/time in DOS-format
char eraseflag; // Erase file after tx?
off_t pos; // Current position
char requires; // Required hashes/CRCs for protocol
char md5hash[16]; // 128 bit MD5 hash
char md5str[33]; // 128 bit MD5 hash, hex-string
unsigned short int crc; // 16 bit CRCthp
};
/*---------------------------------------------------------------------------*/
class fileio
{
private:
char *cut_file (char *);
public:
fileio(void);
virtual ~fileio(void);
void usefile(char *);
void doerase(void);
void setfilename(char *);
void set_offset(off_t);
void rx(void);
void tx(void);
protected:
struct file_info_t *f;
virtual void _rx(void)=0; // abstract
virtual void _tx(void)=0; // abstract
};
/*---------------------------------------------------------------------------*/
class fileio_text : public fileio
{
public:
fileio_text(void);
void settail(signed short int);
protected:
virtual void _rx(void);
virtual void _tx(void);
private:
signed short int tail;
};
/*---------------------------------------------------------------------------*/
class fileio_abin : public fileio
{
public:
fileio_abin(void);
void set_header(char *);
protected:
virtual void _rx(void);
virtual void _tx(void);
private:
char autobin_header[LINELEN+1];
};
/*---------------------------------------------------------------------------*/