-
Notifications
You must be signed in to change notification settings - Fork 0
/
segmenter.h
84 lines (62 loc) · 1.66 KB
/
segmenter.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
// Copyright 2020 DriveX.Tech. All rights reserved.
//
// Licensed under the License.
#pragma once
#ifndef _SEGMENTER_H_
#define _SEGMENTER_H_
#include <stdbool.h>
#include "types/types.h"
#ifdef __cplusplus
extern "C" {
#endif
const extern WORD SEGMENTER_HDER_LEN;
// const WORD SEGMENTER_HDER_LEN = 5; // segment header length 5B
typedef enum {
CONTINUE,
FAILED,
SUCCESSFUL,
} SegmenterStatus;
typedef struct _segmenter_t {
data_buf_hder_t data_buf_hdr;
WORD max_seger_length, max_seger_payload_length;
BYTE seger_ind;
WORD seger_off;
} segmenter_t;
bool
segmenter_init(segmenter_t* segmenter, WORD data_chunk_length);
bool
segmenter_set_data_chunk_length(segmenter_t* segmenter, WORD data_chunk_length);
void
segmenter_reset(segmenter_t* segmenter);
bool
segmenter_segment(
segmenter_t* segmenter,
const BYTE* data_buf,
const WORD data_len);
bool segmenter_test_started(segmenter_t* segmenter, const BYTE* seger_buf);
bool segmenter_test_finished(segmenter_t* segmenter, const BYTE* seger_buf);
bool segmenter_skip(segmenter_t* segmenter, WORD len);
SegmenterStatus
segmenter_try_pack(
segmenter_t* segmenter,
BYTE* seger_buf,
WORD* seger_buf_len);
SegmenterStatus
segmenter_pack(
segmenter_t* segmenter,
BYTE* seger_buf,
WORD* seger_buf_len);
SegmenterStatus
segmenter_try_unpack(
segmenter_t* segmenter,
const BYTE* seger_buf,
const WORD seger_buf_len);
SegmenterStatus
segmenter_unpack(
segmenter_t* segmenter,
const BYTE* seger_buf,
const WORD seger_buf_len);
#ifdef __cplusplus
}
#endif
#endif