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
|
#pragma once
#include "defs.h"
CG_BEGIN_DEFS
/**
* allocate and zero memory.
*
* Returns: The newly allocated memory
* or NULL if the system is unable to.
*/
__attribute__((malloc))
ptr_t malloc0 (size_t sz);
/**
* Removes trailing whitespaces in string s.
*
* Note: this may invalitate the original string s, and on error be NULL.
*/
str_t string_vacuum (str_t s);
/**
* concatonates the null terminated list into a string with new lines
* between each entry.
*/
str_t string_concat_list_nl (str_t* list);
/**
* the same as
* ```
* fprintf (stderr, pmt ....)
* ```
*/
F_FORMAT_STR(1, 2)
void err_print (str_t fmt, ...);
/**
* ***************************************************************************
*/
typedef struct ByteStream ByteStream;
ByteStream *
byte_stream_new (size_t length);
ByteStream *
byte_stream_new_from_file (FILE * f);
void
byte_stream_seek (ByteStream * bstream, long int offset, SEEK_OFFSET origin);
size_t
byte_stream_read (ByteStream * bstream, OUT ptr_t ptr, size_t size, size_t count);
size_t
byte_stream_write (ByteStream * bstream, IN ptr_t ptr, size_t size, size_t count);
size_t
byte_stream_length (ByteStream * ByteStream);
CG_END_DEFS
|