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
|
/*
* Copyright (C) 2026 Peter Mikkelsen <petermikkelsen10@gmail.com>
*
* This file is part of aplwc.
*
* Aplwc 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 3 of the License, or
* (at your option) any later version.
*
* Aplwc 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 aplwc. If not, see <https://www.gnu.org/licenses/>.
*/
#ifndef APLWC_H
#define APLWC_H
#include <stdint.h>
#include <stddef.h>
enum aplwc_rc {
APLWC_OK,
APLWC_OUT_OF_MEMORY,
APLWC_NOT_YET_IMPLEMENTED,
APLWC_INVALID_UTF8,
APLWC_INVALID_SYNTAX,
APLWC_RC_LAST = APLWC_INVALID_SYNTAX
};
struct aplwc;
struct aplwc_ref {
struct aplwc *aplwc;
void *ptr;
struct aplwc_ref *link;
};
typedef struct { struct aplwc_ref ref; } AplwcLine;
typedef struct { struct aplwc_ref ref; } AplwcValue;
struct aplwc_fns {
void *(*alloc)(size_t, size_t *);
void (*dealloc)(void *);
};
extern uint64_t aplwc_simulate_failure_at;
extern uint64_t aplwc_simulate_failure_count;
struct aplwc *aplwc_new(struct aplwc_fns, enum aplwc_rc *);
void aplwc_destroy(struct aplwc *);
void aplwc_clear_line(AplwcLine *);
void aplwc_clear_value(AplwcValue *);
int aplwc_valid_line(AplwcLine *);
int aplwc_valid_value(AplwcValue *);
const char *aplwc_errstr_rc(enum aplwc_rc);
const char *aplwc_errstr(struct aplwc *);
enum aplwc_rc aplwc_last_error(struct aplwc *);
void aplwc_read(struct aplwc *, const char *, AplwcLine *);
void aplwc_free_line(AplwcLine *);
void aplwc_eval(AplwcLine *, AplwcValue *);
void aplwc_free_value(AplwcValue *);
const char *aplwc_value_string(AplwcValue *);
enum aplwc_rc aplwc_load_module(struct aplwc *, const char *, const char *, int n);
int aplwc_simulate_failure(void);
#endif /* APLWC_H */
|