From 1c5bb82c5e991d71e9ae5a6645c032f220131f5d Mon Sep 17 00:00:00 2001 From: Thomas Schmucker Date: Sun, 21 Jun 2020 11:28:57 +0200 Subject: Überarbeitets Error-Handling MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- csv.h | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'csv.h') diff --git a/csv.h b/csv.h index fe59f5b..a8be413 100644 --- a/csv.h +++ b/csv.h @@ -8,11 +8,19 @@ extern "C" { #endif +typedef enum { + CSV_ERR_OK = 0, + CSV_ERR_OUT_OF_MEMORY = -1, + CSV_ERR_OUT_OF_RANGE = -2, + CSV_ERR_IO_READ = -3, + CSV_ERR_IO_WRITE = -4 +} csv_error_t; + typedef struct { char quote_symbol; char sep_symbol; - void (*cb_error)(const char *, void *); + void (*cb_error)(csv_error_t, void *); void *cb_error_arg; void *(*cb_allocate)(size_t, size_t, void *); @@ -45,6 +53,7 @@ void csv_cleanup(csv_t *csv); int csv_nfields(csv_t *csv); const char * csv_field(csv_t *csv, int idx); int csv_read(csv_t *csv, FILE *in); +const char * csv_err_str(csv_error_t csv_error); void csv_write(FILE *out, int n, const char *fields[], const csv_options_t * const csv_options); #ifdef __cplusplus -- cgit v1.3