aboutsummaryrefslogtreecommitdiff
path: root/lib/include
diff options
context:
space:
mode:
authorThomas Schmucker <ts@its1.de>2026-06-21 17:20:13 +0200
committerThomas Schmucker <ts@its1.de>2026-06-21 17:20:13 +0200
commit08a5f3441675c446482b473777cbba53d5191f20 (patch)
treebb462b2439317d8c3be3e542501aa3211357045c /lib/include
parent7d956c533e9fd7d3bbb9a4a8b7f89f0fe54d4bc3 (diff)
downloadlibcsv-rework.tar.gz
libcsv-rework.tar.bz2
libcsv-rework.zip
rework: add testing frameworkrework
Diffstat (limited to 'lib/include')
-rw-r--r--lib/include/csv.h71
1 files changed, 0 insertions, 71 deletions
diff --git a/lib/include/csv.h b/lib/include/csv.h
deleted file mode 100644
index 9ac7c05..0000000
--- a/lib/include/csv.h
+++ /dev/null
@@ -1,71 +0,0 @@
1#pragma once
2
3#include <stddef.h> /* size_t */
4#include <stdio.h> /* FILE */
5
6#ifdef __cplusplus
7extern "C" {
8#endif
9
10typedef enum {
11 CSV_ERR_OK = 0,
12 CSV_ERR_OUT_OF_MEMORY = -1,
13 CSV_ERR_OUT_OF_RANGE = -2,
14 CSV_ERR_IO_READ = -3,
15 CSV_ERR_IO_WRITE = -4
16} csv_err_t;
17
18typedef struct {
19 int field_delimiter;
20 int field_separator;
21
22 void (*cb_error)(csv_err_t, void *);
23 void *cb_error_arg;
24
25 void *(*cb_allocate)(size_t, size_t, void *);
26 void *(*cb_reallocate)(void *, size_t, size_t, void *);
27 void (*cb_free)(void *, size_t, size_t, void *);
28 void *cb_memory_arg;
29} csv_options_t;
30
31extern const csv_options_t csv_default_options;
32
33typedef struct {
34 char * str;
35 size_t cap, pos;
36} csv_string_t;
37
38typedef struct {
39 size_t *fields;
40 size_t cap, pos;
41} csv_field_t;
42
43typedef struct {
44 const csv_options_t *csv_options;
45 csv_string_t csv_string;
46 csv_field_t csv_field;
47} csv_t;
48
49/* version */
50extern const char csv_version[];
51
52/* initialization */
53void csv_init(csv_t *csv);
54void csv_init_opt(csv_t *csv, const csv_options_t *const csv_options);
55
56/* cleanup after error */
57void csv_cleanup(csv_t *csv);
58
59/* read */
60size_t csv_read(csv_t *csv, FILE *in);
61
62/* field access */
63size_t csv_nfields(const csv_t *const csv);
64const char *csv_field(const csv_t *const csv, size_t idx);
65
66/* error handling */
67const char *csv_err_str(csv_err_t csv_err);
68
69#ifdef __cplusplus
70}
71#endif