diff options
| author | Thomas Schmucker <ts@its1.de> | 2020-06-18 10:53:43 +0200 |
|---|---|---|
| committer | Thomas Schmucker <ts@its1.de> | 2020-06-18 10:53:43 +0200 |
| commit | 575ae35abccb0a22d17e3121c19dd59a71aebf3f (patch) | |
| tree | 6fbddb4b4f4ef1b0b14da8fb7107305eab28b090 /csv.h | |
| parent | 36c50e4e77d472e9b7838e1f6385f36ddb52d258 (diff) | |
| download | libcsv-575ae35abccb0a22d17e3121c19dd59a71aebf3f.tar.gz libcsv-575ae35abccb0a22d17e3121c19dd59a71aebf3f.tar.bz2 libcsv-575ae35abccb0a22d17e3121c19dd59a71aebf3f.zip | |
header datei
Diffstat (limited to 'csv.h')
| -rw-r--r-- | csv.h | 51 |
1 files changed, 51 insertions, 0 deletions
| @@ -0,0 +1,51 @@ | |||
| 1 | #ifndef ITS1_CSV_H_INCLUDED | ||
| 2 | #define ITS1_CSV_H_INCLUDED | ||
| 3 | |||
| 4 | #include <stdio.h> /* FILE */ | ||
| 5 | #include <stddef.h> /* size_t */ | ||
| 6 | |||
| 7 | #ifdef __cplusplus | ||
| 8 | extern "C" { | ||
| 9 | #endif | ||
| 10 | |||
| 11 | typedef struct { | ||
| 12 | char quote_symbol; | ||
| 13 | char sep_symbol; | ||
| 14 | void *cb_arg; | ||
| 15 | void (*cb_error)(const char *, void *); | ||
| 16 | void *(*cb_allocate)(size_t, size_t, void *); | ||
| 17 | void *(*cb_reallocate)(void *, size_t, size_t, void *); | ||
| 18 | void (*cb_free)(void *, void *); | ||
| 19 | } csv_options_t; | ||
| 20 | |||
| 21 | extern const csv_options_t csv_default_options; | ||
| 22 | |||
| 23 | typedef struct { | ||
| 24 | char *str; | ||
| 25 | int cap, pos; | ||
| 26 | } csv_string_t; | ||
| 27 | |||
| 28 | typedef struct { | ||
| 29 | int *fields; | ||
| 30 | int cap, pos; | ||
| 31 | } csv_field_t; | ||
| 32 | |||
| 33 | typedef struct { | ||
| 34 | const csv_options_t *csv_options; | ||
| 35 | csv_string_t csv_string; | ||
| 36 | csv_field_t csv_field; | ||
| 37 | } csv_t; | ||
| 38 | |||
| 39 | void csv_init(csv_t *csv); | ||
| 40 | void csv_init_opt(csv_t *csv, const csv_options_t * const csv_options); | ||
| 41 | void csv_free(csv_t *csv); | ||
| 42 | int csv_nfields(csv_t *csv); | ||
| 43 | const char * csv_field(csv_t *csv, int idx); | ||
| 44 | int csv_read(csv_t *csv, FILE *in); | ||
| 45 | void csv_write(FILE *out, int n, const char *fields[], const csv_options_t * const csv_options); | ||
| 46 | |||
| 47 | #ifdef __cplusplus | ||
| 48 | } | ||
| 49 | #endif | ||
| 50 | |||
| 51 | #endif | ||
