diff options
author | Nikias Bassen | 2024-01-30 11:30:12 +0100 |
---|---|---|
committer | Nikias Bassen | 2024-01-30 11:30:12 +0100 |
commit | 7ddaea319550bd44bb295f935bef038a1ac37c3f (patch) | |
tree | 12c590e42fb3d367b7b9fb00a035cd03b4175602 /include | |
parent | 2d517ebcebe326e79186e41ee7bbd1cf5ed1f2b9 (diff) | |
download | libimobiledevice-glue-7ddaea319550bd44bb295f935bef038a1ac37c3f.tar.gz libimobiledevice-glue-7ddaea319550bd44bb295f935bef038a1ac37c3f.tar.bz2 |
Move LIMD_GLUE_API definitions to public headers
Diffstat (limited to 'include')
-rw-r--r-- | include/Makefile.am | 1 | ||||
-rw-r--r-- | include/libimobiledevice-glue/cbuf.h | 8 | ||||
-rw-r--r-- | include/libimobiledevice-glue/collection.h | 14 | ||||
-rw-r--r-- | include/libimobiledevice-glue/glue.h | 35 | ||||
-rw-r--r-- | include/libimobiledevice-glue/opack.h | 5 | ||||
-rw-r--r-- | include/libimobiledevice-glue/socket.h | 36 | ||||
-rw-r--r-- | include/libimobiledevice-glue/termcolors.h | 11 | ||||
-rw-r--r-- | include/libimobiledevice-glue/thread.h | 32 | ||||
-rw-r--r-- | include/libimobiledevice-glue/tlv.h | 15 | ||||
-rw-r--r-- | include/libimobiledevice-glue/utils.h | 21 |
10 files changed, 110 insertions, 68 deletions
diff --git a/include/Makefile.am b/include/Makefile.am index a071583..a194664 100644 --- a/include/Makefile.am +++ b/include/Makefile.am @@ -2,6 +2,7 @@ EXTRA_DIST = \ endianness.h nobase_include_HEADERS = \ + libimobiledevice-glue/glue.h \ libimobiledevice-glue/socket.h \ libimobiledevice-glue/thread.h \ libimobiledevice-glue/utils.h \ diff --git a/include/libimobiledevice-glue/cbuf.h b/include/libimobiledevice-glue/cbuf.h index 01e2f43..2463af7 100644 --- a/include/libimobiledevice-glue/cbuf.h +++ b/include/libimobiledevice-glue/cbuf.h @@ -22,14 +22,16 @@ #ifndef __CBUF_H #define __CBUF_H +#include <libimobiledevice-glue/glue.h> + struct char_buf { unsigned char* data; unsigned int length; unsigned int capacity; }; -struct char_buf* char_buf_new(); -void char_buf_free(struct char_buf* cbuf); -void char_buf_append(struct char_buf* cbuf, unsigned int length, unsigned char* data); +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); #endif /* __CBUF_H */ diff --git a/include/libimobiledevice-glue/collection.h b/include/libimobiledevice-glue/collection.h index df1680c..46ef461 100644 --- a/include/libimobiledevice-glue/collection.h +++ b/include/libimobiledevice-glue/collection.h @@ -22,17 +22,19 @@ #ifndef COLLECTION_H #define COLLECTION_H +#include <libimobiledevice-glue/glue.h> + struct collection { void **list; int capacity; }; -void collection_init(struct collection *col); -void collection_add(struct collection *col, void *element); -int collection_remove(struct collection *col, void *element); -int collection_count(struct collection *col); -void collection_free(struct collection *col); -void collection_copy(struct collection *dest, struct collection *src); +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); +LIMD_GLUE_API int collection_count(struct collection *col); +LIMD_GLUE_API void collection_free(struct collection *col); +LIMD_GLUE_API void collection_copy(struct collection *dest, struct collection *src); #define MERGE_(a,b) a ## _ ## b #define LABEL_(a,b) MERGE_(a, b) diff --git a/include/libimobiledevice-glue/glue.h b/include/libimobiledevice-glue/glue.h new file mode 100644 index 0000000..1ffca02 --- /dev/null +++ b/include/libimobiledevice-glue/glue.h @@ -0,0 +1,35 @@ +/* + * glue.h + * Common definitions + * + * Copyright (c) 2024 Nikias Bassen, All Rights Reserved. + * + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef __GLUE_H +#define __GLUE_H + +#ifndef LIMD_GLUE_API + #ifdef LIMD_GLUE_STATIC + #define LIMD_GLUE_API + #elif defined(_WIN32) + #define LIMD_GLUE_API __declspec(dllimport) + #else + #define LIMD_GLUE_API + #endif +#endif + +#endif diff --git a/include/libimobiledevice-glue/opack.h b/include/libimobiledevice-glue/opack.h index 43b1d1d..2d7a94a 100644 --- a/include/libimobiledevice-glue/opack.h +++ b/include/libimobiledevice-glue/opack.h @@ -21,9 +21,10 @@ #ifndef __OPACK_H #define __OPACK_H +#include <libimobiledevice-glue/glue.h> #include <plist/plist.h> -void opack_encode_from_plist(plist_t plist, unsigned char** out, unsigned int* out_len); -int opack_decode_to_plist(unsigned char* buf, unsigned int buf_len, plist_t* plist_out); +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); #endif /* __OPACK_H */ diff --git a/include/libimobiledevice-glue/socket.h b/include/libimobiledevice-glue/socket.h index 53f58b8..39391c6 100644 --- a/include/libimobiledevice-glue/socket.h +++ b/include/libimobiledevice-glue/socket.h @@ -41,30 +41,32 @@ typedef enum fd_mode fd_mode; #include <sys/socket.h> #endif +#include <libimobiledevice-glue/glue.h> + #ifndef WIN32 -int socket_create_unix(const char *filename); -int socket_connect_unix(const char *filename); +LIMD_GLUE_API int socket_create_unix(const char *filename); +LIMD_GLUE_API int socket_connect_unix(const char *filename); #endif -int socket_create(const char *addr, uint16_t port); -int socket_connect_addr(struct sockaddr *addr, uint16_t port); -int socket_connect(const char *addr, uint16_t port); -int socket_check_fd(int fd, fd_mode fdm, unsigned int timeout); -int socket_accept(int fd, uint16_t port); +LIMD_GLUE_API int socket_create(const char *addr, uint16_t port); +LIMD_GLUE_API int socket_connect_addr(struct sockaddr *addr, uint16_t port); +LIMD_GLUE_API int socket_connect(const char *addr, uint16_t port); +LIMD_GLUE_API int socket_check_fd(int fd, fd_mode fdm, unsigned int timeout); +LIMD_GLUE_API int socket_accept(int fd, uint16_t port); -int socket_shutdown(int fd, int how); -int socket_close(int fd); +LIMD_GLUE_API int socket_shutdown(int fd, int how); +LIMD_GLUE_API int socket_close(int fd); -int socket_receive(int fd, void *data, size_t length); -int socket_peek(int fd, void *data, size_t length); -int socket_receive_timeout(int fd, void *data, size_t length, int flags, unsigned int timeout); -int socket_send(int fd, void *data, size_t length); +LIMD_GLUE_API int socket_receive(int fd, void *data, size_t length); +LIMD_GLUE_API int socket_peek(int fd, void *data, size_t length); +LIMD_GLUE_API int socket_receive_timeout(int fd, void *data, size_t length, int flags, unsigned int timeout); +LIMD_GLUE_API int socket_send(int fd, void *data, size_t length); -int socket_get_socket_port(int fd, uint16_t *port); +LIMD_GLUE_API int socket_get_socket_port(int fd, uint16_t *port); -void socket_set_verbose(int level); +LIMD_GLUE_API void socket_set_verbose(int level); -const char *socket_addr_to_string(struct sockaddr *addr, char *addr_out, size_t addr_out_size); +LIMD_GLUE_API const char *socket_addr_to_string(struct sockaddr *addr, char *addr_out, size_t addr_out_size); -int get_primary_mac_address(unsigned char mac_addr_buf[6]); +LIMD_GLUE_API int get_primary_mac_address(unsigned char mac_addr_buf[6]); #endif /* SOCKET_SOCKET_H */ diff --git a/include/libimobiledevice-glue/termcolors.h b/include/libimobiledevice-glue/termcolors.h index 3e03e97..d7799c3 100644 --- a/include/libimobiledevice-glue/termcolors.h +++ b/include/libimobiledevice-glue/termcolors.h @@ -26,6 +26,7 @@ #include <stdarg.h> #include <stdio.h> +#include <libimobiledevice-glue/glue.h> #define COLOR_RESET "\e[m" #define STYLE_NORMAL "\e[0m" @@ -74,14 +75,14 @@ #define BG_DEFAULT "\e[49m" /* automatically called by library constructor */ -void term_colors_init(); +LIMD_GLUE_API void term_colors_init(); /* enable / disable terminal colors */ -void term_colors_set_enabled(int en); +LIMD_GLUE_API void term_colors_set_enabled(int en); /* color-aware *printf variants */ -int cprintf(const char* fmt, ...); -int cfprintf(FILE* stream, const char* fmt, ...); -int cvfprintf(FILE* stream, const char* fmt, va_list vargs); +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); #endif diff --git a/include/libimobiledevice-glue/thread.h b/include/libimobiledevice-glue/thread.h index b9c0bd0..05ba358 100644 --- a/include/libimobiledevice-glue/thread.h +++ b/include/libimobiledevice-glue/thread.h @@ -67,13 +67,13 @@ typedef pthread_once_t thread_once_t; typedef void* (*thread_func_t)(void* data); -int thread_new(THREAD_T* thread, thread_func_t thread_func, void* data); -void thread_detach(THREAD_T thread); -void thread_free(THREAD_T thread); -int thread_join(THREAD_T thread); -int thread_alive(THREAD_T thread); +LIMD_GLUE_API int thread_new(THREAD_T* thread, thread_func_t thread_func, void* data); +LIMD_GLUE_API void thread_detach(THREAD_T thread); +LIMD_GLUE_API void thread_free(THREAD_T thread); +LIMD_GLUE_API int thread_join(THREAD_T thread); +LIMD_GLUE_API int thread_alive(THREAD_T thread); -int thread_cancel(THREAD_T thread); +LIMD_GLUE_API int thread_cancel(THREAD_T thread); #ifdef WIN32 #undef HAVE_THREAD_CLEANUP @@ -85,17 +85,17 @@ int thread_cancel(THREAD_T thread); #endif #endif -void mutex_init(mutex_t* mutex); -void mutex_destroy(mutex_t* mutex); -void mutex_lock(mutex_t* mutex); -void mutex_unlock(mutex_t* mutex); +LIMD_GLUE_API void mutex_init(mutex_t* mutex); +LIMD_GLUE_API void mutex_destroy(mutex_t* mutex); +LIMD_GLUE_API void mutex_lock(mutex_t* mutex); +LIMD_GLUE_API void mutex_unlock(mutex_t* mutex); -void thread_once(thread_once_t *once_control, void (*init_routine)(void)); +LIMD_GLUE_API void thread_once(thread_once_t *once_control, void (*init_routine)(void)); -void cond_init(cond_t* cond); -void cond_destroy(cond_t* cond); -int cond_signal(cond_t* cond); -int cond_wait(cond_t* cond, mutex_t* mutex); -int cond_wait_timeout(cond_t* cond, mutex_t* mutex, unsigned int timeout_ms); +LIMD_GLUE_API void cond_init(cond_t* cond); +LIMD_GLUE_API void cond_destroy(cond_t* cond); +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); #endif diff --git a/include/libimobiledevice-glue/tlv.h b/include/libimobiledevice-glue/tlv.h index 895c883..42be4f6 100644 --- a/include/libimobiledevice-glue/tlv.h +++ b/include/libimobiledevice-glue/tlv.h @@ -22,6 +22,7 @@ #define __TLV_H #include <stdint.h> +#include <libimobiledevice-glue/glue.h> struct tlv_buf { unsigned char* data; @@ -30,13 +31,13 @@ struct tlv_buf { }; typedef struct tlv_buf* tlv_buf_t; -tlv_buf_t tlv_buf_new(); -void tlv_buf_free(tlv_buf_t tlv); +LIMD_GLUE_API tlv_buf_t tlv_buf_new(); +LIMD_GLUE_API void tlv_buf_free(tlv_buf_t tlv); -void tlv_buf_append(tlv_buf_t tlv, uint8_t tag, unsigned int length, void* data); -unsigned char* tlv_get_data_ptr(const void* tlv_data, void* tlv_end, uint8_t tag, uint8_t* length); -int tlv_data_get_uint(const void* tlv_data, unsigned int tlv_length, uint8_t tag, uint64_t* value); -int tlv_data_get_uint8(const void* tlv_data, unsigned int tlv_length, uint8_t tag, uint8_t* value); -int tlv_data_copy_data(const void* tlv_data, unsigned int tlv_length, uint8_t tag, void** out, unsigned int* out_len); +LIMD_GLUE_API void tlv_buf_append(tlv_buf_t tlv, uint8_t tag, unsigned int length, void* data); +LIMD_GLUE_API unsigned char* tlv_get_data_ptr(const void* tlv_data, void* tlv_end, uint8_t tag, uint8_t* length); +LIMD_GLUE_API int tlv_data_get_uint(const void* tlv_data, unsigned int tlv_length, uint8_t tag, uint64_t* value); +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); #endif /* __TLV_H */ diff --git a/include/libimobiledevice-glue/utils.h b/include/libimobiledevice-glue/utils.h index f7f60f2..355f1da 100644 --- a/include/libimobiledevice-glue/utils.h +++ b/include/libimobiledevice-glue/utils.h @@ -25,23 +25,20 @@ #ifndef __UTILS_H #define __UTILS_H -#ifdef HAVE_CONFIG_H -#include <config.h> -#endif - #include <stdio.h> #include <stdint.h> +#include <libimobiledevice-glue/glue.h> #define MAC_EPOCH 978307200 -char *string_concat(const char *str, ...); -char *string_append(char *str, ...); -char *string_build_path(const char *elem, ...); -char *string_format_size(uint64_t size); -char *string_toupper(char *str); -char *generate_uuid(void); +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, ...); +LIMD_GLUE_API char *string_format_size(uint64_t size); +LIMD_GLUE_API char *string_toupper(char *str); +LIMD_GLUE_API char *generate_uuid(void); -int buffer_read_from_filename(const char *filename, char **buffer, uint64_t *length); -int buffer_write_to_filename(const char *filename, const char *buffer, uint64_t length); +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); #endif |