diff options
-rw-r--r-- | configure.ac | 10 | ||||
-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 | ||||
-rw-r--r-- | src/cbuf.c | 6 | ||||
-rw-r--r-- | src/collection.c | 12 | ||||
-rw-r--r-- | src/common.h | 18 | ||||
-rw-r--r-- | src/opack.c | 4 | ||||
-rw-r--r-- | src/socket.c | 34 | ||||
-rw-r--r-- | src/termcolors.c | 10 | ||||
-rw-r--r-- | src/thread.c | 32 | ||||
-rw-r--r-- | src/tlv.c | 14 | ||||
-rw-r--r-- | src/utils.c | 16 |
20 files changed, 190 insertions, 144 deletions
diff --git a/configure.ac b/configure.ac index 04165c9..d950709 100644 --- a/configure.ac +++ b/configure.ac @@ -110,12 +110,12 @@ fi AC_CHECK_MEMBER(struct dirent.d_type, AC_DEFINE(HAVE_DIRENT_D_TYPE, 1, [define if struct dirent has member d_type]),, [#include <dirent.h>]) AS_COMPILER_FLAGS(GLOBAL_CFLAGS, "-Wall -Wextra -Wmissing-declarations -Wredundant-decls -Wshadow -Wpointer-arith -Wwrite-strings -Wswitch-default -Wno-unused-parameter -fsigned-char -fvisibility=hidden") -AC_SUBST(GLOBAL_CFLAGS) -case "$GLOBAL_CFLAGS" in - *-fvisibility=hidden*) - AC_DEFINE([HAVE_FVISIBILITY], [1], [Define if compiled with -fvisibility=hidden]) -esac +if test "x$enable_static" = "xyes" -a "x$enable_shared" = "xno"; then + GLOBAL_CFLAGS+=" -DLIMD_GLUE_STATIC" +fi + +AC_SUBST(GLOBAL_CFLAGS) # check for large file support AC_SYS_LARGEFILE 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 @@ -30,7 +30,7 @@ #include "common.h" #include "libimobiledevice-glue/cbuf.h" -LIBIMOBILEDEVICE_GLUE_API struct char_buf* char_buf_new() +struct char_buf* char_buf_new() { struct char_buf* cbuf = (struct char_buf*)malloc(sizeof(struct char_buf)); cbuf->capacity = 256; @@ -39,7 +39,7 @@ LIBIMOBILEDEVICE_GLUE_API struct char_buf* char_buf_new() return cbuf; } -LIBIMOBILEDEVICE_GLUE_API void char_buf_free(struct char_buf* cbuf) +void char_buf_free(struct char_buf* cbuf) { if (cbuf) { free(cbuf->data); @@ -47,7 +47,7 @@ LIBIMOBILEDEVICE_GLUE_API void char_buf_free(struct char_buf* cbuf) } } -LIBIMOBILEDEVICE_GLUE_API void char_buf_append(struct char_buf* cbuf, unsigned int length, unsigned char* data) +void char_buf_append(struct char_buf* cbuf, unsigned int length, unsigned char* data) { if (!cbuf || !cbuf->data) { return; diff --git a/src/collection.c b/src/collection.c index ef47217..0744427 100644 --- a/src/collection.c +++ b/src/collection.c @@ -37,7 +37,7 @@ #define CAPACITY_STEP 8 -LIBIMOBILEDEVICE_GLUE_API void collection_init(struct collection *col) +void collection_init(struct collection *col) { col->list = malloc(sizeof(void *) * CAPACITY_STEP); assert(col->list); @@ -45,14 +45,14 @@ LIBIMOBILEDEVICE_GLUE_API void collection_init(struct collection *col) col->capacity = CAPACITY_STEP; } -LIBIMOBILEDEVICE_GLUE_API void collection_free(struct collection *col) +void collection_free(struct collection *col) { free(col->list); col->list = NULL; col->capacity = 0; } -LIBIMOBILEDEVICE_GLUE_API void collection_add(struct collection *col, void *element) +void collection_add(struct collection *col, void *element) { int i; for(i=0; i<col->capacity; i++) { @@ -69,7 +69,7 @@ LIBIMOBILEDEVICE_GLUE_API void collection_add(struct collection *col, void *elem col->capacity += CAPACITY_STEP; } -LIBIMOBILEDEVICE_GLUE_API int collection_remove(struct collection *col, void *element) +int collection_remove(struct collection *col, void *element) { int i; for(i=0; i<col->capacity; i++) { @@ -82,7 +82,7 @@ LIBIMOBILEDEVICE_GLUE_API int collection_remove(struct collection *col, void *el return -1; } -LIBIMOBILEDEVICE_GLUE_API int collection_count(struct collection *col) +int collection_count(struct collection *col) { int i, cnt = 0; for(i=0; i<col->capacity; i++) { @@ -92,7 +92,7 @@ LIBIMOBILEDEVICE_GLUE_API int collection_count(struct collection *col) return cnt; } -LIBIMOBILEDEVICE_GLUE_API void collection_copy(struct collection *dest, struct collection *src) +void collection_copy(struct collection *dest, struct collection *src) { if (!dest || !src) return; dest->capacity = src->capacity; diff --git a/src/common.h b/src/common.h index bd22e3d..94b5fdd 100644 --- a/src/common.h +++ b/src/common.h @@ -25,14 +25,18 @@ #include <config.h> #endif -#ifdef WIN32 -#define LIBIMOBILEDEVICE_GLUE_API __declspec( dllexport ) +#ifdef LIMD_GLUE_STATIC + #define LIMD_GLUE_API +#elif defined(_WIN32) + #define LIMD_GLUE_API __declspec( dllexport ) #else -#ifdef HAVE_FVISIBILITY -#define LIBIMOBILEDEVICE_GLUE_API __attribute__((visibility("default"))) -#else -#define LIBIMOBILEDEVICE_GLUE_API -#endif + #if __GNUC__ >= 4 + #define LIMD_GLUE_API __attribute__((visibility("default"))) + #else + #define LIMD_GLUE_API + #endif #endif +#include "libimobiledevice-glue/glue.h" + #endif diff --git a/src/opack.c b/src/opack.c index 9c4ba55..8a9264a 100644 --- a/src/opack.c +++ b/src/opack.c @@ -237,7 +237,7 @@ static void opack_encode_node(plist_t node, struct char_buf* cbuf) } } -LIBIMOBILEDEVICE_GLUE_API void opack_encode_from_plist(plist_t plist, unsigned char** out, unsigned int* out_len) +void opack_encode_from_plist(plist_t plist, unsigned char** out, unsigned int* out_len) { if (!plist || !out || !out_len) { return; @@ -462,7 +462,7 @@ static int opack_decode_obj(unsigned char** p, unsigned char* end, plist_t* plis return 0; } -LIBIMOBILEDEVICE_GLUE_API int opack_decode_to_plist(unsigned char* buf, unsigned int buf_len, plist_t* plist_out) +int opack_decode_to_plist(unsigned char* buf, unsigned int buf_len, plist_t* plist_out) { if (!buf || buf_len == 0 || !plist_out) { return -1; diff --git a/src/socket.c b/src/socket.c index c2ebf25..f3ea882 100644 --- a/src/socket.c +++ b/src/socket.c @@ -85,12 +85,12 @@ static int wsa_init = 0; static int verbose = 0; -LIBIMOBILEDEVICE_GLUE_API void socket_set_verbose(int level) +void socket_set_verbose(int level) { verbose = level; } -LIBIMOBILEDEVICE_GLUE_API const char *socket_addr_to_string(struct sockaddr *addr, char *addr_out, size_t addr_out_size) +const char *socket_addr_to_string(struct sockaddr *addr, char *addr_out, size_t addr_out_size) { #ifdef WIN32 WSADATA wsa_data; @@ -277,7 +277,7 @@ static inline __attribute__((always_inline)) enum poll_status poll_wrapper(int f } #ifndef WIN32 -LIBIMOBILEDEVICE_GLUE_API int socket_create_unix(const char *filename) +int socket_create_unix(const char *filename) { struct sockaddr_un name; int sock; @@ -323,7 +323,7 @@ LIBIMOBILEDEVICE_GLUE_API int socket_create_unix(const char *filename) return sock; } -LIBIMOBILEDEVICE_GLUE_API int socket_connect_unix(const char *filename) +int socket_connect_unix(const char *filename) { struct sockaddr_un name; int sfd = -1; @@ -405,7 +405,7 @@ LIBIMOBILEDEVICE_GLUE_API int socket_connect_unix(const char *filename) } #endif -LIBIMOBILEDEVICE_GLUE_API int socket_create(const char* addr, uint16_t port) +int socket_create(const char* addr, uint16_t port) { int sfd = -1; int yes = 1; @@ -828,7 +828,7 @@ static int getifaddrs(struct ifaddrs** ifap) #endif #endif -LIBIMOBILEDEVICE_GLUE_API int get_primary_mac_address(unsigned char mac_addr_buf[6]) +int get_primary_mac_address(unsigned char mac_addr_buf[6]) { int result = -1; struct ifaddrs *ifaddr = NULL, *ifa = NULL; @@ -975,7 +975,7 @@ static int32_t _sockaddr_in6_scope_id(struct sockaddr_in6* addr) } #endif -LIBIMOBILEDEVICE_GLUE_API int socket_connect_addr(struct sockaddr* addr, uint16_t port) +int socket_connect_addr(struct sockaddr* addr, uint16_t port) { int sfd = -1; int yes = 1; @@ -1098,7 +1098,7 @@ LIBIMOBILEDEVICE_GLUE_API int socket_connect_addr(struct sockaddr* addr, uint16_ return sfd; } -LIBIMOBILEDEVICE_GLUE_API int socket_connect(const char *addr, uint16_t port) +int socket_connect(const char *addr, uint16_t port) { int sfd = -1; int yes = 1; @@ -1211,7 +1211,7 @@ LIBIMOBILEDEVICE_GLUE_API int socket_connect(const char *addr, uint16_t port) return sfd; } -LIBIMOBILEDEVICE_GLUE_API int socket_check_fd(int fd, fd_mode fdm, unsigned int timeout) +int socket_check_fd(int fd, fd_mode fdm, unsigned int timeout) { if (fd < 0) { if (verbose >= 2) @@ -1243,7 +1243,7 @@ LIBIMOBILEDEVICE_GLUE_API int socket_check_fd(int fd, fd_mode fdm, unsigned int return -1; } -LIBIMOBILEDEVICE_GLUE_API int socket_accept(int fd, uint16_t port) +int socket_accept(int fd, uint16_t port) { #ifdef WIN32 int addr_len; @@ -1259,12 +1259,12 @@ LIBIMOBILEDEVICE_GLUE_API int socket_accept(int fd, uint16_t port) return result; } -LIBIMOBILEDEVICE_GLUE_API int socket_shutdown(int fd, int how) +int socket_shutdown(int fd, int how) { return shutdown(fd, how); } -LIBIMOBILEDEVICE_GLUE_API int socket_close(int fd) { +int socket_close(int fd) { #ifdef WIN32 return closesocket(fd); #else @@ -1272,17 +1272,17 @@ LIBIMOBILEDEVICE_GLUE_API int socket_close(int fd) { #endif } -LIBIMOBILEDEVICE_GLUE_API int socket_receive(int fd, void *data, size_t length) +int socket_receive(int fd, void *data, size_t length) { return socket_receive_timeout(fd, data, length, 0, RECV_TIMEOUT); } -LIBIMOBILEDEVICE_GLUE_API int socket_peek(int fd, void *data, size_t length) +int socket_peek(int fd, void *data, size_t length) { return socket_receive_timeout(fd, data, length, MSG_PEEK, RECV_TIMEOUT); } -LIBIMOBILEDEVICE_GLUE_API int socket_receive_timeout(int fd, void *data, size_t length, int flags, unsigned int timeout) +int socket_receive_timeout(int fd, void *data, size_t length, int flags, unsigned int timeout) { int res; int result; @@ -1306,7 +1306,7 @@ LIBIMOBILEDEVICE_GLUE_API int socket_receive_timeout(int fd, void *data, size_t return result; } -LIBIMOBILEDEVICE_GLUE_API int socket_send(int fd, void *data, size_t length) +int socket_send(int fd, void *data, size_t length) { int flags = 0; int res = socket_check_fd(fd, FDM_WRITE, SEND_TIMEOUT); @@ -1319,7 +1319,7 @@ LIBIMOBILEDEVICE_GLUE_API int socket_send(int fd, void *data, size_t length) return send(fd, data, length, flags); } -LIBIMOBILEDEVICE_GLUE_API int socket_get_socket_port(int fd, uint16_t *port) +int socket_get_socket_port(int fd, uint16_t *port) { #ifdef WIN32 int addr_len; diff --git a/src/termcolors.c b/src/termcolors.c index 710c9df..5c436f2 100644 --- a/src/termcolors.c +++ b/src/termcolors.c @@ -92,7 +92,7 @@ static int bgcolor_map[8] = { static int WIN32_LEGACY_MODE = 0; #endif -LIBIMOBILEDEVICE_GLUE_API void term_colors_init() +void term_colors_init() { #ifdef WIN32 DWORD conmode = 0; @@ -126,12 +126,12 @@ LIBIMOBILEDEVICE_GLUE_API void term_colors_init() } } -LIBIMOBILEDEVICE_GLUE_API void term_colors_set_enabled(int en) +void term_colors_set_enabled(int en) { use_colors = en; } -LIBIMOBILEDEVICE_GLUE_API int cvfprintf(FILE* stream, const char* fmt, va_list vargs) +int cvfprintf(FILE* stream, const char* fmt, va_list vargs) { int res = 0; int colorize = use_colors; @@ -298,7 +298,7 @@ LIBIMOBILEDEVICE_GLUE_API int cvfprintf(FILE* stream, const char* fmt, va_list v return res; } -LIBIMOBILEDEVICE_GLUE_API int cfprintf(FILE* stream, const char* fmt, ...) +int cfprintf(FILE* stream, const char* fmt, ...) { int res = 0; va_list va; @@ -308,7 +308,7 @@ LIBIMOBILEDEVICE_GLUE_API int cfprintf(FILE* stream, const char* fmt, ...) return res; } -LIBIMOBILEDEVICE_GLUE_API int cprintf(const char* fmt, ...) +int cprintf(const char* fmt, ...) { int res = 0; va_list va; diff --git a/src/thread.c b/src/thread.c index e2c3b63..50639dd 100644 --- a/src/thread.c +++ b/src/thread.c @@ -28,7 +28,7 @@ #include "common.h" #include "libimobiledevice-glue/thread.h" -LIBIMOBILEDEVICE_GLUE_API int thread_new(THREAD_T *thread, thread_func_t thread_func, void* data) +int thread_new(THREAD_T *thread, thread_func_t thread_func, void* data) { #ifdef WIN32 HANDLE th = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)(void*)thread_func, data, 0, NULL); @@ -43,7 +43,7 @@ LIBIMOBILEDEVICE_GLUE_API int thread_new(THREAD_T *thread, thread_func_t thread_ #endif } -LIBIMOBILEDEVICE_GLUE_API void thread_detach(THREAD_T thread) +void thread_detach(THREAD_T thread) { #ifdef WIN32 CloseHandle(thread); @@ -52,14 +52,14 @@ LIBIMOBILEDEVICE_GLUE_API void thread_detach(THREAD_T thread) #endif } -LIBIMOBILEDEVICE_GLUE_API void thread_free(THREAD_T thread) +void thread_free(THREAD_T thread) { #ifdef WIN32 CloseHandle(thread); #endif } -LIBIMOBILEDEVICE_GLUE_API int thread_join(THREAD_T thread) +int thread_join(THREAD_T thread) { /* wait for thread to complete */ #ifdef WIN32 @@ -69,7 +69,7 @@ LIBIMOBILEDEVICE_GLUE_API int thread_join(THREAD_T thread) #endif } -LIBIMOBILEDEVICE_GLUE_API int thread_alive(THREAD_T thread) +int thread_alive(THREAD_T thread) { if (!thread) return 0; @@ -80,7 +80,7 @@ LIBIMOBILEDEVICE_GLUE_API int thread_alive(THREAD_T thread) #endif } -LIBIMOBILEDEVICE_GLUE_API int thread_cancel(THREAD_T thread) +int thread_cancel(THREAD_T thread) { #ifdef WIN32 return -1; @@ -93,7 +93,7 @@ LIBIMOBILEDEVICE_GLUE_API int thread_cancel(THREAD_T thread) #endif } -LIBIMOBILEDEVICE_GLUE_API void mutex_init(mutex_t* mutex) +void mutex_init(mutex_t* mutex) { #ifdef WIN32 InitializeCriticalSection((LPCRITICAL_SECTION)mutex); @@ -102,7 +102,7 @@ LIBIMOBILEDEVICE_GLUE_API void mutex_init(mutex_t* mutex) #endif } -LIBIMOBILEDEVICE_GLUE_API void mutex_destroy(mutex_t* mutex) +void mutex_destroy(mutex_t* mutex) { #ifdef WIN32 DeleteCriticalSection((LPCRITICAL_SECTION)mutex); @@ -111,7 +111,7 @@ LIBIMOBILEDEVICE_GLUE_API void mutex_destroy(mutex_t* mutex) #endif } -LIBIMOBILEDEVICE_GLUE_API void mutex_lock(mutex_t* mutex) +void mutex_lock(mutex_t* mutex) { #ifdef WIN32 EnterCriticalSection((LPCRITICAL_SECTION)mutex); @@ -120,7 +120,7 @@ LIBIMOBILEDEVICE_GLUE_API void mutex_lock(mutex_t* mutex) #endif } -LIBIMOBILEDEVICE_GLUE_API void mutex_unlock(mutex_t* mutex) +void mutex_unlock(mutex_t* mutex) { #ifdef WIN32 LeaveCriticalSection((LPCRITICAL_SECTION)mutex); @@ -129,7 +129,7 @@ LIBIMOBILEDEVICE_GLUE_API void mutex_unlock(mutex_t* mutex) #endif } -LIBIMOBILEDEVICE_GLUE_API void thread_once(thread_once_t *once_control, void (*init_routine)(void)) +void thread_once(thread_once_t *once_control, void (*init_routine)(void)) { #ifdef WIN32 while (InterlockedExchange(&(once_control->lock), 1) != 0) { @@ -145,7 +145,7 @@ LIBIMOBILEDEVICE_GLUE_API void thread_once(thread_once_t *once_control, void (*i #endif } -LIBIMOBILEDEVICE_GLUE_API void cond_init(cond_t* cond) +void cond_init(cond_t* cond) { #ifdef WIN32 cond->sem = CreateSemaphore(NULL, 0, 32767, NULL); @@ -154,7 +154,7 @@ LIBIMOBILEDEVICE_GLUE_API void cond_init(cond_t* cond) #endif } -LIBIMOBILEDEVICE_GLUE_API void cond_destroy(cond_t* cond) +void cond_destroy(cond_t* cond) { #ifdef WIN32 CloseHandle(cond->sem); @@ -163,7 +163,7 @@ LIBIMOBILEDEVICE_GLUE_API void cond_destroy(cond_t* cond) #endif } -LIBIMOBILEDEVICE_GLUE_API int cond_signal(cond_t* cond) +int cond_signal(cond_t* cond) { #ifdef WIN32 int result = 0; @@ -176,7 +176,7 @@ LIBIMOBILEDEVICE_GLUE_API int cond_signal(cond_t* cond) #endif } -LIBIMOBILEDEVICE_GLUE_API int cond_wait(cond_t* cond, mutex_t* mutex) +int cond_wait(cond_t* cond, mutex_t* mutex) { #ifdef WIN32 mutex_unlock(mutex); @@ -192,7 +192,7 @@ LIBIMOBILEDEVICE_GLUE_API int cond_wait(cond_t* cond, mutex_t* mutex) #endif } -LIBIMOBILEDEVICE_GLUE_API int cond_wait_timeout(cond_t* cond, mutex_t* mutex, unsigned int timeout_ms) +int cond_wait_timeout(cond_t* cond, mutex_t* mutex, unsigned int timeout_ms) { #ifdef WIN32 mutex_unlock(mutex); @@ -32,7 +32,7 @@ #include "libimobiledevice-glue/tlv.h" #include "endianness.h" -LIBIMOBILEDEVICE_GLUE_API tlv_buf_t tlv_buf_new() +tlv_buf_t tlv_buf_new() { tlv_buf_t tlv = malloc(sizeof(struct tlv_buf)); tlv->capacity = 1024; @@ -41,7 +41,7 @@ LIBIMOBILEDEVICE_GLUE_API tlv_buf_t tlv_buf_new() return tlv; } -LIBIMOBILEDEVICE_GLUE_API void tlv_buf_free(tlv_buf_t tlv) +void tlv_buf_free(tlv_buf_t tlv) { if (tlv) { free(tlv->data); @@ -49,7 +49,7 @@ LIBIMOBILEDEVICE_GLUE_API void tlv_buf_free(tlv_buf_t tlv) } } -LIBIMOBILEDEVICE_GLUE_API void tlv_buf_append(tlv_buf_t tlv, uint8_t tag, unsigned int length, void* data) +void tlv_buf_append(tlv_buf_t tlv, uint8_t tag, unsigned int length, void* data) { if (!tlv || !tlv->data) { return; @@ -86,7 +86,7 @@ LIBIMOBILEDEVICE_GLUE_API void tlv_buf_append(tlv_buf_t tlv, uint8_t tag, unsign tlv->length = p - tlv->data; } -LIBIMOBILEDEVICE_GLUE_API unsigned char* tlv_get_data_ptr(const void* tlv_data, void* tlv_end, uint8_t tag, uint8_t* length) +unsigned char* tlv_get_data_ptr(const void* tlv_data, void* tlv_end, uint8_t tag, uint8_t* length) { unsigned char* p = (unsigned char*)tlv_data; unsigned char* end = (unsigned char*)tlv_end; @@ -102,7 +102,7 @@ LIBIMOBILEDEVICE_GLUE_API unsigned char* tlv_get_data_ptr(const void* tlv_data, return NULL; } -LIBIMOBILEDEVICE_GLUE_API int tlv_data_get_uint(const void* tlv_data, unsigned int tlv_length, uint8_t tag, uint64_t* value) +int tlv_data_get_uint(const void* tlv_data, unsigned int tlv_length, uint8_t tag, uint64_t* value) { if (!tlv_data || tlv_length < 2 || !value) { return 0; @@ -136,7 +136,7 @@ LIBIMOBILEDEVICE_GLUE_API int tlv_data_get_uint(const void* tlv_data, unsigned i return 1; } -LIBIMOBILEDEVICE_GLUE_API int tlv_data_get_uint8(const void* tlv_data, unsigned int tlv_length, uint8_t tag, uint8_t* value) +int tlv_data_get_uint8(const void* tlv_data, unsigned int tlv_length, uint8_t tag, uint8_t* value) { if (!tlv_data || tlv_length < 2 || !value) { return 0; @@ -156,7 +156,7 @@ LIBIMOBILEDEVICE_GLUE_API int tlv_data_get_uint8(const void* tlv_data, unsigned return 1; } -LIBIMOBILEDEVICE_GLUE_API int tlv_data_copy_data(const void* tlv_data, unsigned int tlv_length, uint8_t tag, void** out, unsigned int* out_len) +int tlv_data_copy_data(const void* tlv_data, unsigned int tlv_length, uint8_t tag, void** out, unsigned int* out_len) { if (!tlv_data || tlv_length < 2 || !out || !out_len) { return 0; diff --git a/src/utils.c b/src/utils.c index 196d29d..ad8e9c4 100644 --- a/src/utils.c +++ b/src/utils.c @@ -75,7 +75,7 @@ char *stpcpy(char *s1, const char *s2) * @return a newly allocated string, or NULL if @str is NULL. This will also * return NULL and set errno to ENOMEM if memory is exhausted. */ -LIBIMOBILEDEVICE_GLUE_API char *string_concat(const char *str, ...) +char *string_concat(const char *str, ...) { size_t len; va_list args; @@ -119,7 +119,7 @@ LIBIMOBILEDEVICE_GLUE_API char *string_concat(const char *str, ...) return result; } -LIBIMOBILEDEVICE_GLUE_API char *string_append(char* str, ...) +char *string_append(char* str, ...) { size_t len = 0; size_t slen; @@ -163,7 +163,7 @@ LIBIMOBILEDEVICE_GLUE_API char *string_append(char* str, ...) return result; } -LIBIMOBILEDEVICE_GLUE_API char *string_build_path(const char *elem, ...) +char *string_build_path(const char *elem, ...) { if (!elem) return NULL; @@ -191,7 +191,7 @@ LIBIMOBILEDEVICE_GLUE_API char *string_build_path(const char *elem, ...) return out; } -LIBIMOBILEDEVICE_GLUE_API char *string_format_size(uint64_t size) +char *string_format_size(uint64_t size) { char buf[80]; double sz; @@ -213,7 +213,7 @@ LIBIMOBILEDEVICE_GLUE_API char *string_format_size(uint64_t size) return strdup(buf); } -LIBIMOBILEDEVICE_GLUE_API char *string_toupper(char* str) +char *string_toupper(char* str) { char *res = strdup(str); size_t i; @@ -229,7 +229,7 @@ static int get_rand(int min, int max) return retval; } -LIBIMOBILEDEVICE_GLUE_API char *generate_uuid() +char *generate_uuid() { const char *chars = "ABCDEF0123456789"; int i = 0; @@ -251,7 +251,7 @@ LIBIMOBILEDEVICE_GLUE_API char *generate_uuid() return uuid; } -LIBIMOBILEDEVICE_GLUE_API int buffer_read_from_filename(const char *filename, char **buffer, uint64_t *length) +int buffer_read_from_filename(const char *filename, char **buffer, uint64_t *length) { FILE *f; uint64_t size; @@ -295,7 +295,7 @@ LIBIMOBILEDEVICE_GLUE_API int buffer_read_from_filename(const char *filename, ch return ret; } -LIBIMOBILEDEVICE_GLUE_API int buffer_write_to_filename(const char *filename, const char *buffer, uint64_t length) +int buffer_write_to_filename(const char *filename, const char *buffer, uint64_t length) { FILE *f; |