#ifndef ITS1_CSV_H_INCLUDED #define ITS1_CSV_H_INCLUDED #include /* FILE */ #include /* size_t */ #ifdef __cplusplus extern "C" { #endif typedef struct { char quote_symbol; char sep_symbol; void *cb_arg; void (*cb_error)(const char *, void *); void *(*cb_allocate)(size_t, size_t, void *); void *(*cb_reallocate)(void *, size_t, size_t, void *); void (*cb_free)(void *, size_t sz, void *); } csv_options_t; extern const csv_options_t csv_default_options; typedef struct { char *str; int cap, pos; } csv_string_t; typedef struct { int *fields; int cap, pos; } csv_field_t; typedef struct { const csv_options_t *csv_options; csv_string_t csv_string; csv_field_t csv_field; } csv_t; void csv_init(csv_t *csv); void csv_init_opt(csv_t *csv, const csv_options_t * const csv_options); void csv_free(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); void csv_write(FILE *out, int n, const char *fields[], const csv_options_t * const csv_options); #ifdef __cplusplus } #endif #endif