diff options
Diffstat (limited to 'lib/include')
| -rw-r--r-- | lib/include/csv.h | 71 |
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 | ||
| 7 | extern "C" { | ||
| 8 | #endif | ||
| 9 | |||
| 10 | typedef 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 | |||
| 18 | typedef 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 | |||
| 31 | extern const csv_options_t csv_default_options; | ||
| 32 | |||
| 33 | typedef struct { | ||
| 34 | char * str; | ||
| 35 | size_t cap, pos; | ||
| 36 | } csv_string_t; | ||
| 37 | |||
| 38 | typedef struct { | ||
| 39 | size_t *fields; | ||
| 40 | size_t cap, pos; | ||
| 41 | } csv_field_t; | ||
| 42 | |||
| 43 | typedef 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 */ | ||
| 50 | extern const char csv_version[]; | ||
| 51 | |||
| 52 | /* initialization */ | ||
| 53 | void csv_init(csv_t *csv); | ||
| 54 | void csv_init_opt(csv_t *csv, const csv_options_t *const csv_options); | ||
| 55 | |||
| 56 | /* cleanup after error */ | ||
| 57 | void csv_cleanup(csv_t *csv); | ||
| 58 | |||
| 59 | /* read */ | ||
| 60 | size_t csv_read(csv_t *csv, FILE *in); | ||
| 61 | |||
| 62 | /* field access */ | ||
| 63 | size_t csv_nfields(const csv_t *const csv); | ||
| 64 | const char *csv_field(const csv_t *const csv, size_t idx); | ||
| 65 | |||
| 66 | /* error handling */ | ||
| 67 | const char *csv_err_str(csv_err_t csv_err); | ||
| 68 | |||
| 69 | #ifdef __cplusplus | ||
| 70 | } | ||
| 71 | #endif | ||
