/+junk/codegen

To get this branch, use:
bzr branch http://gegoxaren.bato24.eu/bzr/%2Bjunk/codegen

« back to all changes in this revision

Viewing changes to src/utils.h

  • Committer: Gustav Hartvigsson
  • Date: 2022-10-19 21:06:55 UTC
  • Revision ID: gustav.hartvigsson@gmail.com-20221019210655-9iqu2dhjbpvedoma
Beep Boop, nothin yet.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
#pragma once
 
2
 
 
3
#include "defs.h"
 
4
 
 
5
CG_BEGIN_DEFS
 
6
 
 
7
/**
 
8
 * allocate and zero memory.
 
9
 *
 
10
 * Returns: The newly allocated memory
 
11
 *          or NULL if the system is unable to.
 
12
 */
 
13
__attribute__((malloc))
 
14
ptr_t malloc0 (size_t sz);
 
15
 
 
16
/**
 
17
 * Removes trailing whitespaces in string s.
 
18
 *
 
19
 * Note: this may invalitate the original string s, and on error be NULL.
 
20
 */
 
21
str_t string_vacuum (str_t s);
 
22
 
 
23
/**
 
24
 * concatonates the null terminated list into a string with new lines
 
25
 * between each entry.
 
26
 */
 
27
str_t string_concat_list_nl (str_t* list);
 
28
 
 
29
/**
 
30
 * the same as
 
31
 * ```
 
32
 * fprintf (stderr, pmt ....)
 
33
 * ```
 
34
 */
 
35
F_FORMAT_STR(1, 2)
 
36
void err_print (str_t fmt, ...);
 
37
 
 
38
/**
 
39
 * ***************************************************************************
 
40
 */
 
41
 
 
42
typedef struct ByteStream ByteStream;
 
43
 
 
44
ByteStream *
 
45
byte_stream_new (size_t length);
 
46
 
 
47
ByteStream *
 
48
byte_stream_new_from_file (FILE * f);
 
49
 
 
50
void
 
51
byte_stream_seek (ByteStream * bstream, long int offset, SEEK_OFFSET origin);
 
52
 
 
53
size_t
 
54
byte_stream_read (ByteStream * bstream, OUT ptr_t ptr, size_t size, size_t count);
 
55
 
 
56
size_t
 
57
byte_stream_write (ByteStream * bstream, IN ptr_t ptr, size_t size, size_t count);
 
58
 
 
59
size_t
 
60
byte_stream_length (ByteStream * ByteStream);
 
61
 
 
62
 
 
63
CG_END_DEFS