diff options
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); |
