-
Notifications
You must be signed in to change notification settings - Fork 0
/
tmp.h
67 lines (62 loc) · 1.54 KB
/
tmp.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
#include <stdarg.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
/**
* A return type for C.
*
* Contains a `return_code` which indicates any errors
* and an `output` indicating the output of the method
*/
typedef struct C_Return {
uint32_t return_code;
char *output;
} C_Return;
/**
* Encodes a string to jaartal
*
* ## Parameters
* - input: the string to be encoded
* - jaar: the jaar it has to be encoded with
*
* ## Returns
* - A C_Return struct containing:
* - c_int: the return code (0 if no errors occur,
* other variables if there was an error)
* - c_char: the encoded string
*
* ## Errors
* Error codes:<br/>
* 1: Couldn't convert CString to Rust str
*
* ## Freeing memory
* For Swift, it is important to call `jaar_free` after this function is called to free memory.
* Disregarding to do this will cause a memory leak.
*/
struct C_Return encode_jaar(const char *input, const char *jaar);
/**
* Reverses each word in a string.
*
* ## Parameters
* - input: the string to be encoded
*
* ## Returns
* - A string where all the words of the `input`have been reversed
*
* ## Freeing memory
* `omkeren_free`
*/
char *encode_omkeren(const char *input);
/**
* Has to be called after `encode_jaar` to the free memory
*
* Disregarding to do this will cause a **memory leak**.
*
* Not applicable for Java.
*/
void jaar_free(struct C_Return cret);
/**
* Has to be called after `encode_omkeren` to the free memory.<br/>
* Disregarding to do this will cause a **memory leak**.
*/
void omkeren_free(char *s);