Browse Source

Add extern "C" guards to public headers

Nikias Bassen 4 months ago
parent
commit
440dbbbf61

+ 8 - 0
include/libimobiledevice-glue/cbuf.h

@@ -30,8 +30,16 @@ struct char_buf {
 	unsigned int capacity;
 };
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 LIMD_GLUE_API struct char_buf* char_buf_new();
 LIMD_GLUE_API void char_buf_free(struct char_buf* cbuf);
 LIMD_GLUE_API void char_buf_append(struct char_buf* cbuf, unsigned int length, unsigned char* data);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* __CBUF_H */

+ 8 - 0
include/libimobiledevice-glue/collection.h

@@ -29,6 +29,10 @@ struct collection {
 	int capacity;
 };
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 LIMD_GLUE_API void collection_init(struct collection *col);
 LIMD_GLUE_API void collection_add(struct collection *col, void *element);
 LIMD_GLUE_API int collection_remove(struct collection *col, void *element);
@@ -51,4 +55,8 @@ LIMD_GLUE_API void collection_copy(struct collection *dest, struct collection *s
 		} \
 	} while(0);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif

+ 8 - 0
include/libimobiledevice-glue/glue.h

@@ -32,6 +32,14 @@
   #endif
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 LIMD_GLUE_API const char* libimobiledevice_glue_version();
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif

+ 8 - 0
include/libimobiledevice-glue/nskeyedarchive.h

@@ -50,6 +50,10 @@ enum nskeyedarchive_class_type_t {
 
 typedef struct nskeyedarchive_st *nskeyedarchive_t;
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 LIMD_GLUE_API nskeyedarchive_t nskeyedarchive_new(void);
 LIMD_GLUE_API nskeyedarchive_t nskeyedarchive_new_from_plist(plist_t plist);
 LIMD_GLUE_API nskeyedarchive_t nskeyedarchive_new_from_data(const void* data, uint32_t size);
@@ -87,4 +91,8 @@ LIMD_GLUE_API int nskeyedarchive_get_class_property(nskeyedarchive_t ka, uint64_
 
 LIMD_GLUE_API plist_t nskeyedarchive_to_plist(nskeyedarchive_t ka);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif

+ 8 - 0
include/libimobiledevice-glue/opack.h

@@ -24,7 +24,15 @@
 #include <libimobiledevice-glue/glue.h>
 #include <plist/plist.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 LIMD_GLUE_API void opack_encode_from_plist(plist_t plist, unsigned char** out, unsigned int* out_len);
 LIMD_GLUE_API int opack_decode_to_plist(unsigned char* buf, unsigned int buf_len, plist_t* plist_out);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* __OPACK_H */

+ 8 - 0
include/libimobiledevice-glue/sha.h

@@ -6,6 +6,10 @@
 
 #include <libimobiledevice-glue/glue.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* LibTomCrypt, modular cryptographic library -- Tom St Denis
  *
  * LibTomCrypt is a library that provides various cryptographic
@@ -83,4 +87,8 @@ LIMD_GLUE_API int sha384_final(sha384_context * md, unsigned char *out);
 LIMD_GLUE_API int sha384_update(sha384_context * md, const void *data, size_t inlen);
 LIMD_GLUE_API int sha384(const unsigned char *message, size_t message_len, unsigned char *out);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif

+ 8 - 0
include/libimobiledevice-glue/socket.h

@@ -43,6 +43,10 @@ typedef enum fd_mode fd_mode;
 
 #include <libimobiledevice-glue/glue.h>
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 #ifndef _WIN32
 LIMD_GLUE_API int socket_create_unix(const char *filename);
 LIMD_GLUE_API int socket_connect_unix(const char *filename);
@@ -69,4 +73,8 @@ LIMD_GLUE_API const char *socket_addr_to_string(struct sockaddr *addr, char *add
 
 LIMD_GLUE_API int get_primary_mac_address(unsigned char mac_addr_buf[6]);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif	/* SOCKET_SOCKET_H */

+ 8 - 0
include/libimobiledevice-glue/termcolors.h

@@ -74,6 +74,10 @@
 #define BG_WHITE              "\e[107m"
 #define BG_DEFAULT            "\e[49m"
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 /* automatically called by library constructor */
 LIMD_GLUE_API void term_colors_init();
 
@@ -85,4 +89,8 @@ LIMD_GLUE_API int cprintf(const char* fmt, ...);
 LIMD_GLUE_API int cfprintf(FILE* stream, const char* fmt, ...);
 LIMD_GLUE_API int cvfprintf(FILE* stream, const char* fmt, va_list vargs);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif

+ 8 - 0
include/libimobiledevice-glue/thread.h

@@ -66,6 +66,10 @@ typedef pthread_once_t thread_once_t;
 #define THREAD_T_NULL (THREAD_T)NULL
 #endif
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 typedef void* (*thread_func_t)(void* data);
 
 LIMD_GLUE_API int thread_new(THREAD_T* thread, thread_func_t thread_func, void* data);
@@ -99,4 +103,8 @@ LIMD_GLUE_API int cond_signal(cond_t* cond);
 LIMD_GLUE_API int cond_wait(cond_t* cond, mutex_t* mutex);
 LIMD_GLUE_API int cond_wait_timeout(cond_t* cond, mutex_t* mutex, unsigned int timeout_ms);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif

+ 8 - 0
include/libimobiledevice-glue/tlv.h

@@ -31,6 +31,10 @@ struct tlv_buf {
 };
 typedef struct tlv_buf* tlv_buf_t;
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 LIMD_GLUE_API tlv_buf_t tlv_buf_new();
 LIMD_GLUE_API void tlv_buf_free(tlv_buf_t tlv);
 
@@ -40,4 +44,8 @@ LIMD_GLUE_API int tlv_data_get_uint(const void* tlv_data, unsigned int tlv_lengt
 LIMD_GLUE_API int tlv_data_get_uint8(const void* tlv_data, unsigned int tlv_length, uint8_t tag, uint8_t* value);
 LIMD_GLUE_API int tlv_data_copy_data(const void* tlv_data, unsigned int tlv_length, uint8_t tag, void** out, unsigned int* out_len);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif /* __TLV_H */

+ 8 - 0
include/libimobiledevice-glue/utils.h

@@ -31,6 +31,10 @@
 
 #define MAC_EPOCH 978307200
 
+#ifdef __cplusplus
+extern "C" {
+#endif
+
 LIMD_GLUE_API char *string_concat(const char *str, ...);
 LIMD_GLUE_API char *string_append(char *str, ...);
 LIMD_GLUE_API char *string_build_path(const char *elem, ...);
@@ -41,4 +45,8 @@ LIMD_GLUE_API char *generate_uuid(void);
 LIMD_GLUE_API int buffer_read_from_filename(const char *filename, char **buffer, uint64_t *length);
 LIMD_GLUE_API int buffer_write_to_filename(const char *filename, const char *buffer, uint64_t length);
 
+#ifdef __cplusplus
+}
+#endif
+
 #endif