forked from Infinidat/slimfastq
-
Notifications
You must be signed in to change notification settings - Fork 0
/
usrs.hpp
153 lines (128 loc) · 5.16 KB
/
usrs.hpp
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
/***********************************************************************************************************************/
/* This program was written by Josef Ezra <[email protected]> */
/* Copyright (c) 2013, Infinidat */
/* All rights reserved. */
/* */
/* Redistribution and use in source and binary forms, with or without modification, are permitted provided that */
/* the following conditions are met: */
/* */
/* Redistributions of source code must retain the above copyright notice, this list of conditions and the following */
/* disclaimer. */
/* Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following */
/* disclaimer in the documentation and/or other materials provided with the distribution. */
/* Neither the name of the Infinidat nor the names of its contributors may be used to endorse or promote products */
/* derived from this software without specific prior written permission. */
/* */
/* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, */
/* INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE */
/* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, */
/* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR */
/* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, */
/* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE */
/* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
/***********************************************************************************************************************/
#ifndef FQ_USRS_H
#define FQ_USRS_H
#include "common.hpp"
#include "config.hpp"
#include <stdio.h>
#include "xfile.hpp"
// NOTE: soon there would be new machines, providing longer lines.
#define MAX_ID_LLEN 0x2000
#define MAX_GN_LLEN 0x10000
#define MAX_REC_LEN (2*(MAX_GN_LLEN + MAX_ID_LLEN))
class UsrBase {
public:
enum exception_t {
ET_LLEN,
ET_QLEN,
ET_SOLPF_GEN,
ET_SOLPF_QLT,
ET_END
} ;
#define PLL_SIZE 0x100000
#define PLL_STRT MAX_REC_LEN
// PLL_STRT must be more than record size
#define PLL_LAST (PLL_SIZE + PLL_STRT)
struct {
UINT64 i_llen;
UINT64 i_qlen;
UINT64 i_sgen;
UINT64 i_sqlt;
UINT64 i_long;
UCHAR solid_pf_gen;
UCHAR solid_pf_qlt;
} m_last;
};
class UsrSave : public UsrBase {
public:
UsrSave();
~UsrSave();
int encode();
private:
bool get_record();
bool get_oversized_record(int cur, bool from_get=true);
void load_page();
void update(exception_t type, UINT16 dat);
inline void load_check();
inline UCHAR load_char();
inline void expect(UCHAR chr);
bool mid_rec_msg() const ;
void determine_record();
UINT64 estimate_rec_limit();
bool m_valid;
UCHAR m_buff[PLL_LAST+10];
size_t m_page_count;
int m_cur, m_end;
FILE *m_in;
bool first_cycle;
int m_llen, m_qlen;
bool m_solid;
XFileSave* x_llen;
XFileSave* x_qlen;
XFileSave* x_sgen;
XFileSave* x_sqlt;
XFileSave* x_lgen;
XFileSave* x_lqlt;
XFileSave* x_lrec;
struct {
UCHAR* rec;
UCHAR* rec_end;
UCHAR* prev_rec;
UCHAR* prev_rec_end;
UCHAR* gen;
UCHAR* qlt;
} mp;
UCHAR mp_last[MAX_REC_LEN];
};
class UsrLoad : public UsrBase {
public:
UsrLoad();
~UsrLoad();
int decode();
private:
void save();
void update();
void putline(UCHAR* buf, UINT32 size);
FILE *m_out;
size_t m_llen, m_llen_factor, m_qlen;
// UINT64 m_rec_total;
bool m_2nd_rec, m_solid;
UINT32 m_rec_size;
long comp_version;
bool flip;
UCHAR m_rep[MAX_ID_LLEN + 1 ];
UCHAR m_rec[MAX_ID_LLEN + 1 ];
UCHAR m_qlt[MAX_GN_LLEN + 2 ];
UCHAR m_gen[MAX_GN_LLEN + 4 ];
UCHAR * m_qlt_ptr;
UCHAR * m_gen_ptr;
XFileLoad* x_llen;
XFileLoad* x_qlen;
XFileLoad* x_sgen;
XFileLoad* x_sqlt;
XFileLoad* x_lgen;
XFileLoad* x_lqlt;
XFileLoad* x_lrec;
};
#endif