summaryrefslogtreecommitdiff
path: root/net-wireless/rtl_433/files/rtl_433-21.12-test-visibility.patch
blob: 01626361f5cccb15bbc00c57796223ba05ef259b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
From eda74c17dba1cfed7bcbb0654251cb0cd4e1f4b2 Mon Sep 17 00:00:00 2001
From: "Christian W. Zuckschwerdt" <christian@zuckschwerdt.org>
Date: Thu, 17 Mar 2022 08:55:49 +0100
Subject: [PATCH] minor: Add visibility to dynamic lib exports (closes #2010)

Co-authored-by: "Rick Farina (Zero_Chaos)" <zerochaos@gentoo.org>
---
 include/data.h       | 58 ++++++++++++++++++++++++++++----------------
 src/CMakeLists.txt   |  2 +-
 tests/CMakeLists.txt |  2 +-
 3 files changed, 39 insertions(+), 23 deletions(-)

diff --git a/include/data.h b/include/data.h
index 34fe79525..e892c7fa2 100644
--- a/include/data.h
+++ b/include/data.h
@@ -21,6 +21,22 @@
 #ifndef INCLUDE_DATA_H_
 #define INCLUDE_DATA_H_
 
+#if defined _WIN32 || defined __CYGWIN__
+    #ifdef data_EXPORTS
+        #define R_API __stdcall __declspec(dllexport) // Note: actually gcc seems to also supports this syntax.
+    #else
+        #define R_API __stdcall __declspec(dllimport) // Note: actually gcc seems to also supports this syntax.
+    #endif
+    #define R_API_CALLCONV __stdcall
+#else
+    #if __GNUC__ >= 4
+        #define R_API __attribute__((visibility ("default")))
+    #else
+        #define R_API
+    #endif
+    #define R_API_CALLCONV
+#endif
+
 #include <stddef.h>
 
 typedef enum {
@@ -87,19 +103,19 @@ typedef struct data {
 
     @return A constructed data_t* object or NULL if there was a memory allocation error.
 */
-data_t *data_make(const char *key, const char *pretty_key, ...);
+R_API data_t *data_make(const char *key, const char *pretty_key, ...);
 
 /** Adds to a structured data object, by appending data.
 
     @see data_make()
 */
-data_t *data_append(data_t *first, const char *key, const char *pretty_key, ...);
+R_API data_t *data_append(data_t *first, const char *key, const char *pretty_key, ...);
 
 /** Adds to a structured data object, by prepending data.
 
     @see data_make()
 */
-data_t *data_prepend(data_t *first, const char *key, const char *pretty_key, ...);
+R_API data_t *data_prepend(data_t *first, const char *key, const char *pretty_key, ...);
 
 /** Constructs an array from given data of the given uniform type.
 
@@ -110,28 +126,28 @@ data_t *data_prepend(data_t *first, const char *key, const char *pretty_key, ...
     @return The constructed data array object, typically placed inside a data_t or NULL
             if there was a memory allocation error.
 */
-data_array_t *data_array(int num_values, data_type_t type, void *ptr);
+R_API data_array_t *data_array(int num_values, data_type_t type, void *ptr);
 
 /** Releases a data array. */
-void data_array_free(data_array_t *array);
+R_API void data_array_free(data_array_t *array);
 
 /** Retain a structure object, returns the structure object passed in. */
-data_t *data_retain(data_t *data);
+R_API data_t *data_retain(data_t *data);
 
 /** Releases a structure object if retain is zero, decrement retain otherwise. */
-void data_free(data_t *data);
+R_API void data_free(data_t *data);
 
 struct data_output;
 
 typedef struct data_output {
-    void (*print_data)(struct data_output *output, data_t *data, char const *format);
-    void (*print_array)(struct data_output *output, data_array_t *data, char const *format);
-    void (*print_string)(struct data_output *output, const char *data, char const *format);
-    void (*print_double)(struct data_output *output, double data, char const *format);
-    void (*print_int)(struct data_output *output, int data, char const *format);
-    void (*output_start)(struct data_output *output, char const *const *fields, int num_fields);
-    void (*output_flush)(struct data_output *output);
-    void (*output_free)(struct data_output *output);
+    void (R_API_CALLCONV *print_data)(struct data_output *output, data_t *data, char const *format);
+    void (R_API_CALLCONV *print_array)(struct data_output *output, data_array_t *data, char const *format);
+    void (R_API_CALLCONV *print_string)(struct data_output *output, const char *data, char const *format);
+    void (R_API_CALLCONV *print_double)(struct data_output *output, double data, char const *format);
+    void (R_API_CALLCONV *print_int)(struct data_output *output, int data, char const *format);
+    void (R_API_CALLCONV *output_start)(struct data_output *output, char const *const *fields, int num_fields);
+    void (R_API_CALLCONV *output_flush)(struct data_output *output);
+    void (R_API_CALLCONV *output_free)(struct data_output *output);
 } data_output_t;
 
 /** Setup known field keys and start output, used by CSV only.
@@ -141,19 +157,19 @@ typedef struct data_output {
                   strings not. The list may contain duplicates and they are eliminated.
     @param num_fields number of fields
 */
-void data_output_start(struct data_output *output, char const *const *fields, int num_fields);
+R_API void data_output_start(struct data_output *output, char const *const *fields, int num_fields);
 
 /** Prints a structured data object, flushes the output if applicable. */
-void data_output_print(struct data_output *output, data_t *data);
+R_API void data_output_print(struct data_output *output, data_t *data);
 
-void data_output_free(struct data_output *output);
+R_API void data_output_free(struct data_output *output);
 
 /* data output helpers */
 
-void print_value(data_output_t *output, data_type_t type, data_value_t value, char const *format);
+R_API void print_value(data_output_t *output, data_type_t type, data_value_t value, char const *format);
 
-void print_array_value(data_output_t *output, data_array_t *array, char const *format, int idx);
+R_API void print_array_value(data_output_t *output, data_array_t *array, char const *format, int idx);
 
-size_t data_print_jsons(data_t *data, char *dst, size_t len);
+R_API size_t data_print_jsons(data_t *data, char *dst, size_t len);
 
 #endif // INCLUDE_DATA_H_
diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt
index b050dd597..443393e67 100644
--- a/src/CMakeLists.txt
+++ b/src/CMakeLists.txt
@@ -253,7 +253,7 @@ if(MSVC)
     target_sources(rtl_433 PRIVATE getopt/getopt.c)
 endif()
 
-add_library(data data.c abuf.c term_ctl.c)
+add_library(data data.c abuf.c)
 target_link_libraries(data ${NET_LIBRARIES})
 
 target_link_libraries(rtl_433
diff --git a/tests/CMakeLists.txt b/tests/CMakeLists.txt
index aaae3d498..9a3a14302 100644
--- a/tests/CMakeLists.txt
+++ b/tests/CMakeLists.txt
@@ -1,7 +1,7 @@
 ########################################################################
 # Compile test cases
 ########################################################################
-add_executable(data-test data-test.c ../src/output_file.c)
+add_executable(data-test data-test.c ../src/output_file.c ../src/term_ctl.c)
 
 target_link_libraries(data-test data)