summaryrefslogtreecommitdiff
path: root/csv.h
diff options
context:
space:
mode:
Diffstat (limited to 'csv.h')
-rw-r--r--csv.h26
1 files changed, 13 insertions, 13 deletions
diff --git a/csv.h b/csv.h
index 5ee7695..8abeb18 100644
--- a/csv.h
+++ b/csv.h
@@ -1,14 +1,14 @@
1#pragma once 1#pragma once
2 2
3#include <stdio.h> /* FILE */ 3#include <stddef.h> /* size_t */
4#include <stddef.h> /* size_t */ 4#include <stdio.h> /* FILE */
5 5
6#ifdef __cplusplus 6#ifdef __cplusplus
7extern "C" { 7extern "C" {
8#endif 8#endif
9 9
10typedef enum { 10typedef enum {
11 CSV_ERR_OK = 0, 11 CSV_ERR_OK = 0,
12 CSV_ERR_OUT_OF_MEMORY = -1, 12 CSV_ERR_OUT_OF_MEMORY = -1,
13 CSV_ERR_OUT_OF_RANGE = -2, 13 CSV_ERR_OUT_OF_RANGE = -2,
14 CSV_ERR_IO_READ = -3, 14 CSV_ERR_IO_READ = -3,
@@ -32,23 +32,23 @@ extern const csv_options_t csv_default_options;
32 32
33typedef struct { 33typedef struct {
34 char *str; 34 char *str;
35 int cap, pos; 35 int cap, pos;
36} csv_string_t; 36} csv_string_t;
37 37
38typedef struct { 38typedef struct {
39 int *fields; 39 int *fields;
40 int cap, pos; 40 int cap, pos;
41} csv_field_t; 41} csv_field_t;
42 42
43typedef struct { 43typedef struct {
44 const csv_options_t *csv_options; 44 const csv_options_t *csv_options;
45 csv_string_t csv_string; 45 csv_string_t csv_string;
46 csv_field_t csv_field; 46 csv_field_t csv_field;
47} csv_t; 47} csv_t;
48 48
49/* initialization */ 49/* initialization */
50void csv_init(csv_t *csv); 50void csv_init(csv_t *csv);
51void csv_init_opt(csv_t *csv, const csv_options_t * const csv_options); 51void csv_init_opt(csv_t *csv, const csv_options_t *const csv_options);
52 52
53/* cleanup after error */ 53/* cleanup after error */
54void csv_cleanup(csv_t *csv); 54void csv_cleanup(csv_t *csv);
@@ -57,15 +57,15 @@ void csv_cleanup(csv_t *csv);
57int csv_read(csv_t *csv, FILE *in); 57int csv_read(csv_t *csv, FILE *in);
58 58
59/* field access */ 59/* field access */
60int csv_nfields(const csv_t * const csv); 60int csv_nfields(const csv_t *const csv);
61const char * csv_field(const csv_t * const csv, int idx); 61const char *csv_field(const csv_t *const csv, int idx);
62 62
63/* write */ 63/* write */
64void csv_write(FILE *out, const csv_t * const csv); 64void csv_write(FILE *out, const csv_t *const csv);
65void csv_write_ex(FILE *out, int n, const char *fields[], const csv_options_t * const csv_options); 65void csv_write_ex(FILE *out, int n, const char *fields[], const csv_options_t *const csv_options);
66 66
67/* error handling */ 67/* error handling */
68const char * csv_err_str(csv_err_t csv_err); 68const char *csv_err_str(csv_err_t csv_err);
69 69
70#ifdef __cplusplus 70#ifdef __cplusplus
71} 71}