From 582f0fa86d876d53b1779f02c16f9182300a8975 Mon Sep 17 00:00:00 2001 From: Thomas Schmucker Date: Tue, 23 Jun 2020 17:49:16 +0200 Subject: erste Version von cvs_write() hinzugefügt! MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- csv.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/csv.c b/csv.c index 58b1861..3e3bd94 100644 --- a/csv.c +++ b/csv.c @@ -464,6 +464,28 @@ csv_write_field(FILE *out, const char *field, const csv_options_t * const csv_op } } +void +csv_write(FILE *out, const csv_t * const csv) +{ + assert(out != NULL); + assert(csv != NULL); + assert(csv->csv_options != NULL); + assert(csv->csv_string.str != NULL); + assert(csv->csv_field.fields != NULL); + + const char SEP = csv->csv_options->field_separator; + + if ( 0 < csv->csv_field.pos ) { + csv_write_field(out, csv_field(csv, 0), csv->csv_options); + + for ( int i = 1; i < csv->csv_field.pos; ++i ) { + putc(SEP, out); + csv_write_field(out, csv_field(csv, i), csv->csv_options); + } + } + fprintf(out, "\r\n"); +} + void csv_write_ex(FILE *out, int n, const char *fields[], const csv_options_t * csv_options) { -- cgit v1.3