summaryrefslogtreecommitdiffstats
path: root/H64E-2/h64e.h
blob: c8a210b370336073e57fda987471821b3e5f1380 (plain) (blame)
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
//
//  h64e.h
//  H64E-2
//
//  Created by dianshi on 3/13/20.
//  Copyright © 2020 dianshi. All rights reserved.
//

#ifndef h64e_h
#define h64e_h

#include <stdio.h>
#include <ctype.h>
#include "h64e-model.h"
/*
 Set data structure from arguments and use to handle data
*/
#define H64E_G_NONE   0
#define H64E_G_BYTE   1
#define H64E_G_WORD   2
#define H64E_G_DWORD  3
#define H64E_G_QWORD  4

#define H64E_O_START   0
#define H64E_O_NONE    0
#define H64E_O_STRING  1
#define H64E_O_INT8    2
#define H64E_O_UINT8   3
#define H64E_O_INT16   4
#define H64E_O_UINT16  5
#define H64E_O_INT32   6
#define H64E_O_UINT32  7
#define H64E_O_INT64   8
#define H64E_O_UINT64  9
#define H64E_O_END     H64E_O_UINT64

typedef struct H64E_params
{
    
    int      flag_offset; /* output offset */
    uint64_t offset_addr; /* offset postion */
    uint8_t  column_size; /* size of column to operate with */
    int      flag_no_group; /* dont output hex values */
    uint8_t  group;   /* if there is need transdorm to specific type */
    int      flag_output_types; /* output convereted types */
    uint8_t  output_type; /* output in many different ways */
    int      flag_space; /*space between columns **/
    int      flag_ascii;
} H64E_params;

typedef struct H64E_t
{
    H64E_params fmt;
    H64E_stream_in *sin;
    H64E_stream_out *sout;
    int fd_in;
    int fd_out;
} H64E_t;

int h64e_init(H64E_t *s);
int h64e_check_param( H64E_t *s );
int h64e_set_input(H64E_t *s, H64E_stream_in *sin);
int h64e_set_output(H64E_t *s, H64E_stream_out *sout);
int h64e_convert(H64E_t *s);
int h64e_destroy(H64E_t *s);


#define H64E_FMT_STATE_NONE   0
#define H64E_FMT_STATE_INIT   1
#define H64E_FMT_STATE_CNV    2
#define H64E_FMT_STATE_FINISH 3

typedef struct H64E_format {
    int group_fmt;
    int output_fmt;
    int min_input;
    int max_output;
    int column_size;
    int f_space;
    int column_pos;      //position where output stoped
    int end_pos;      //end postion before new line
    int f_new_line;   //should be new line set after
    int start_offset; //start position of offset
    int slide_offset; //offset since stream start
    int state;
    int t_new_line; // if new line or buffer full
    int f_nw_pos; // if new line then save place where new line is
    int f_ascii;
    int f_offset;
    int total_output;
} H64E_format;

int h64e_fmt_init(  H64E_format *fs);
int h64e_fmt_byte(  H64E_format *fs, uint8_t *in_data, int32_t in_size, uint8_t *out_data, int32_t out_size);
int h64e_fmt_byte_align16(  H64E_format *fs, uint8_t *in_data, int32_t in_size, uint8_t *out_data, int32_t out_size);
int h64e_fmt_word(    H64E_format *fs, uint8_t *in_data, int32_t in_size, uint8_t *out_data, int32_t out_size);
int h64e_fmt_dword(   H64E_format *fs, uint8_t *in_data, int32_t in_size, uint8_t *out_data, int32_t out_size);
int h64e_fmt_qword(   H64E_format *fs, uint8_t *in_data, int32_t in_size, uint8_t *out_data, int32_t out_size);
int h64e_fmt_string(  H64E_format *fs, uint8_t *in_data, int32_t in_size, uint8_t *out_data, int32_t out_size);
int h64e_fmt_finish(  H64E_format *fs);

#endif /* h64e_h */