diff options
| author | Thomas Schmucker <ts@its1.de> | 2020-06-23 17:49:16 +0200 |
|---|---|---|
| committer | Thomas Schmucker <ts@its1.de> | 2020-06-23 17:49:16 +0200 |
| commit | 582f0fa86d876d53b1779f02c16f9182300a8975 (patch) | |
| tree | 15906db198e8e9d86c396fbef6775d0c2c783b2d /csv.c | |
| parent | d3733c62fe8c6d6ff0737e16f62af6def7783309 (diff) | |
| download | libcsv-582f0fa86d876d53b1779f02c16f9182300a8975.tar.gz libcsv-582f0fa86d876d53b1779f02c16f9182300a8975.tar.bz2 libcsv-582f0fa86d876d53b1779f02c16f9182300a8975.zip | |
erste Version von cvs_write() hinzugefügt!
Diffstat (limited to 'csv.c')
| -rw-r--r-- | csv.c | 22 |
1 files changed, 22 insertions, 0 deletions
| @@ -465,6 +465,28 @@ csv_write_field(FILE *out, const char *field, const csv_options_t * const csv_op | |||
| 465 | } | 465 | } |
| 466 | 466 | ||
| 467 | void | 467 | void |
| 468 | csv_write(FILE *out, const csv_t * const csv) | ||
| 469 | { | ||
| 470 | assert(out != NULL); | ||
| 471 | assert(csv != NULL); | ||
| 472 | assert(csv->csv_options != NULL); | ||
| 473 | assert(csv->csv_string.str != NULL); | ||
| 474 | assert(csv->csv_field.fields != NULL); | ||
| 475 | |||
| 476 | const char SEP = csv->csv_options->field_separator; | ||
| 477 | |||
| 478 | if ( 0 < csv->csv_field.pos ) { | ||
| 479 | csv_write_field(out, csv_field(csv, 0), csv->csv_options); | ||
| 480 | |||
| 481 | for ( int i = 1; i < csv->csv_field.pos; ++i ) { | ||
| 482 | putc(SEP, out); | ||
| 483 | csv_write_field(out, csv_field(csv, i), csv->csv_options); | ||
| 484 | } | ||
| 485 | } | ||
| 486 | fprintf(out, "\r\n"); | ||
| 487 | } | ||
| 488 | |||
| 489 | void | ||
| 468 | csv_write_ex(FILE *out, int n, const char *fields[], const csv_options_t * csv_options) | 490 | csv_write_ex(FILE *out, int n, const char *fields[], const csv_options_t * csv_options) |
| 469 | { | 491 | { |
| 470 | assert(out != NULL); | 492 | assert(out != NULL); |
