summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--csv.c26
-rw-r--r--csv.h3
2 files changed, 24 insertions, 5 deletions
diff --git a/csv.c b/csv.c
index 6bd157c..0e6e897 100644
--- a/csv.c
+++ b/csv.c
@@ -5,6 +5,8 @@
5#include <stdlib.h> 5#include <stdlib.h>
6#include <string.h> 6#include <string.h>
7 7
8// === Compiletimeoptions ===
9
8#ifndef CSV_DEFAULT_DELIMITER 10#ifndef CSV_DEFAULT_DELIMITER
9# define CSV_DEFAULT_DELIMITER '"' 11# define CSV_DEFAULT_DELIMITER '"'
10#endif 12#endif
@@ -13,7 +15,25 @@
13# define CSV_DEFAULT_SEPARATOR ',' 15# define CSV_DEFAULT_SEPARATOR ','
14#endif 16#endif
15 17
16#if defined(__GNUC__) || defined(__clang__) 18// === some usefull Makros ===
19
20#define UNUSED(x) (void) (sizeof((x), 0)) // mark a parameter as 'unused'
21#define STR(s) #s // Stringify a Makro
22#define XSTR(s) STR(s)
23
24// === Version Information ===
25
26#define CSV_VER_MAJOR 1
27#define CSV_VER_MINOR 0
28#define CSV_VER_PATCH 0
29#define CSV_VER_APPENDIX "-dev"
30
31// version information as described at semver.org
32const char csv_version[] = XSTR(CSV_VER_MAJOR) "." XSTR(CSV_VER_MINOR) "." XSTR(CSV_VER_PATCH) CSV_VER_APPENDIX "\0" XSTR(__DATE__) "\0" XSTR(__TIME__);
33
34// === CSV-MEMORY Interface ===
35
36#if ( (defined(__GNUC__) && __GNUC__ >= 5) || (defined(__clang__) && (__clang_major__ > 3 || (__clang_major__ == 3 && __clang_minor__ >= 4))) )
17# define mul_overflow __builtin_mul_overflow 37# define mul_overflow __builtin_mul_overflow
18#else 38#else
19static inline int 39static inline int
@@ -24,10 +44,6 @@ mul_overflow(size_t a, size_t b, size_t *out)
24} 44}
25#endif 45#endif
26 46
27#define UNUSED(x) (void) (sizeof((x), 0))
28
29// === CSV-MEMORY Interface ===
30
31static void * 47static void *
32csv_mem_allocate(size_t n, size_t sz, void *cb_arg) 48csv_mem_allocate(size_t n, size_t sz, void *cb_arg)
33{ 49{
diff --git a/csv.h b/csv.h
index bbfe150..44c6ff3 100644
--- a/csv.h
+++ b/csv.h
@@ -46,6 +46,9 @@ typedef struct {
46 csv_field_t csv_field; 46 csv_field_t csv_field;
47} csv_t; 47} csv_t;
48 48
49/* version */
50extern const char csv_version[];
51
49/* initialization */ 52/* initialization */
50void csv_init(csv_t *csv); 53void csv_init(csv_t *csv);
51void csv_init_opt(csv_t *csv, const csv_options_t *const csv_options); 54void csv_init_opt(csv_t *csv, const csv_options_t *const csv_options);