From 440dbbbf615de11acdd8216df0e3676e8efb9ba1 Mon Sep 17 00:00:00 2001 From: Nikias Bassen Date: Fri, 27 Dec 2024 01:55:34 +0100 Subject: [PATCH] Add extern "C" guards to public headers --- include/libimobiledevice-glue/cbuf.h | 8 ++++++++ include/libimobiledevice-glue/collection.h | 8 ++++++++ include/libimobiledevice-glue/glue.h | 8 ++++++++ include/libimobiledevice-glue/nskeyedarchive.h | 8 ++++++++ include/libimobiledevice-glue/opack.h | 8 ++++++++ include/libimobiledevice-glue/sha.h | 8 ++++++++ include/libimobiledevice-glue/socket.h | 8 ++++++++ include/libimobiledevice-glue/termcolors.h | 8 ++++++++ include/libimobiledevice-glue/thread.h | 8 ++++++++ include/libimobiledevice-glue/tlv.h | 8 ++++++++ include/libimobiledevice-glue/utils.h | 8 ++++++++ 11 files changed, 88 insertions(+) diff --git a/include/libimobiledevice-glue/cbuf.h b/include/libimobiledevice-glue/cbuf.h index 2463af7..02c5442 100644 --- a/include/libimobiledevice-glue/cbuf.h +++ b/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 */ diff --git a/include/libimobiledevice-glue/collection.h b/include/libimobiledevice-glue/collection.h index 46ef461..b256cef 100644 --- a/include/libimobiledevice-glue/collection.h +++ b/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 diff --git a/include/libimobiledevice-glue/glue.h b/include/libimobiledevice-glue/glue.h index e1e9900..e0364e1 100644 --- a/include/libimobiledevice-glue/glue.h +++ b/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 diff --git a/include/libimobiledevice-glue/nskeyedarchive.h b/include/libimobiledevice-glue/nskeyedarchive.h index 304495a..18a0ab3 100644 --- a/include/libimobiledevice-glue/nskeyedarchive.h +++ b/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 diff --git a/include/libimobiledevice-glue/opack.h b/include/libimobiledevice-glue/opack.h index 2d7a94a..7561fce 100644 --- a/include/libimobiledevice-glue/opack.h +++ b/include/libimobiledevice-glue/opack.h @@ -24,7 +24,15 @@ #include #include +#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 */ diff --git a/include/libimobiledevice-glue/sha.h b/include/libimobiledevice-glue/sha.h index 3a00578..98bcd71 100644 --- a/include/libimobiledevice-glue/sha.h +++ b/include/libimobiledevice-glue/sha.h @@ -6,6 +6,10 @@ #include +#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 diff --git a/include/libimobiledevice-glue/socket.h b/include/libimobiledevice-glue/socket.h index 500d382..fbb06da 100644 --- a/include/libimobiledevice-glue/socket.h +++ b/include/libimobiledevice-glue/socket.h @@ -43,6 +43,10 @@ typedef enum fd_mode fd_mode; #include +#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 */ diff --git a/include/libimobiledevice-glue/termcolors.h b/include/libimobiledevice-glue/termcolors.h index d7799c3..afde0a6 100644 --- a/include/libimobiledevice-glue/termcolors.h +++ b/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 diff --git a/include/libimobiledevice-glue/thread.h b/include/libimobiledevice-glue/thread.h index a29573c..d04dae7 100644 --- a/include/libimobiledevice-glue/thread.h +++ b/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 diff --git a/include/libimobiledevice-glue/tlv.h b/include/libimobiledevice-glue/tlv.h index 42be4f6..28cf2b9 100644 --- a/include/libimobiledevice-glue/tlv.h +++ b/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 */ diff --git a/include/libimobiledevice-glue/utils.h b/include/libimobiledevice-glue/utils.h index 355f1da..dd12265 100644 --- a/include/libimobiledevice-glue/utils.h +++ b/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