-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathbytesobj.h
69 lines (56 loc) · 2.03 KB
/
bytesobj.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
/*
$Id: bytesobj.h 3136 2024-05-11 09:05:50Z soci $
This program 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 2 of the License, or
(at your option) any later version.
This program 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, write to the Free Software Foundation, Inc.,
51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
*/
#ifndef BYTESOBJ_H
#define BYTESOBJ_H
#include "obj.h"
extern struct Type *const BYTES_OBJ;
typedef struct Bytes {
Obj v;
ssize_t len;
uint8_t *data;
union {
uint8_t val[16];
struct {
size_t max;
int hash;
} s;
} u;
} Bytes;
#define Bytes(a) OBJ_CAST(Bytes, a)
extern Obj *const null_bytes;
extern Obj *const inv_bytes;
extern void bytesobj_init(void);
extern void bytesobj_names(void);
extern void bytesobj_destroy(void);
typedef enum Textconv_types {
BYTES_MODE_TEXT,
BYTES_MODE_SHIFT_CHECK,
BYTES_MODE_SHIFT,
BYTES_MODE_SHIFTL,
BYTES_MODE_NULL_CHECK,
BYTES_MODE_NULL,
BYTES_MODE_PTEXT
} Textconv_types;
extern MUST_CHECK Bytes *new_bytes(size_t);
struct Str;
struct Bits;
extern MUST_CHECK Obj *bytes_from_uval(uval_t, unsigned int);
extern MUST_CHECK Obj *bytes_from_str(struct Str *, linepos_t, Textconv_types);
extern MUST_CHECK Obj *bytes_from_bits(const struct Bits *, linepos_t);
extern MUST_CHECK Obj *bytes_from_hexstr(const uint8_t *, linecpos_t *, linepos_t);
extern MUST_CHECK Obj *bytes_from_z85str(const uint8_t *, linecpos_t *, linepos_t);
extern MUST_CHECK Obj *bytes_from_obj(Obj *, linepos_t);
extern MUST_CHECK Obj *float_from_bytes(const Bytes *, linepos_t);
#endif