summaryrefslogtreecommitdiffstats
path: root/src/libusbmuxd.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/libusbmuxd.c')
-rw-r--r--src/libusbmuxd.c42
1 files changed, 21 insertions, 21 deletions
diff --git a/src/libusbmuxd.c b/src/libusbmuxd.c
index 1cf6dcb..97114a8 100644
--- a/src/libusbmuxd.c
+++ b/src/libusbmuxd.c
@@ -69,7 +69,7 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
// usbmuxd protocol
#include "usbmuxd-proto.h"
// socket utility functions
-#include "sock_stuff.h"
+#include "socket.h"
// misc utility functions
#include "collection.h"
@@ -111,9 +111,9 @@ static usbmuxd_device_info_t *devices_find(uint32_t handle)
static int connect_usbmuxd_socket()
{
#if defined(WIN32) || defined(__CYGWIN__)
- return connect_socket("127.0.0.1", USBMUXD_SOCKET_PORT);
+ return socket_connect("127.0.0.1", USBMUXD_SOCKET_PORT);
#else
- return connect_unix_socket(USBMUXD_SOCKET_FILE);
+ return socket_connect_unix(USBMUXD_SOCKET_FILE);
#endif
}
@@ -169,7 +169,7 @@ static int receive_packet(int sfd, struct usbmuxd_header *header, void **payload
header->message = 0;
header->tag = 0;
- recv_len = recv_buf_timeout(sfd, &hdr, sizeof(hdr), 0, timeout);
+ recv_len = socket_receive_timeout(sfd, &hdr, sizeof(hdr), 0, timeout);
if (recv_len < 0) {
return recv_len;
} else if ((size_t)recv_len < sizeof(hdr)) {
@@ -179,7 +179,7 @@ static int receive_packet(int sfd, struct usbmuxd_header *header, void **payload
uint32_t payload_size = hdr.length - sizeof(hdr);
if (payload_size > 0) {
payload_loc = (char*)malloc(payload_size);
- if (recv_buf_timeout(sfd, payload_loc, payload_size, 0, 5000) != (int)payload_size) {
+ if (socket_receive_timeout(sfd, payload_loc, payload_size, 0, 5000) != (int)payload_size) {
DEBUG(1, "%s: Error receiving payload of size %d\n", __func__, payload_size);
free(payload_loc);
return -EBADMSG;
@@ -204,7 +204,7 @@ static int receive_packet(int sfd, struct usbmuxd_header *header, void **payload
memcpy(header, &hdr, sizeof(hdr));
return hdr.length;
}
-
+
plist_get_string_val(node, &message);
if (message) {
uint64_t val = 0;
@@ -338,17 +338,17 @@ static int send_packet(int sfd, uint32_t message, uint32_t tag, void *payload, u
if (payload && (payload_size > 0)) {
header.length += payload_size;
}
- int sent = send_buf(sfd, &header, sizeof(header));
+ int sent = socket_send(sfd, &header, sizeof(header));
if (sent != sizeof(header)) {
DEBUG(1, "%s: ERROR: could not send packet header\n", __func__);
return -1;
}
if (payload && (payload_size > 0)) {
- sent += send_buf(sfd, payload, payload_size);
+ sent += socket_send(sfd, payload, payload_size);
}
if (sent != (int)header.length) {
DEBUG(1, "%s: ERROR: could not send whole packet\n", __func__);
- close_socket(sfd);
+ socket_close(sfd);
return -1;
}
return sent;
@@ -591,11 +591,11 @@ retry:
tag = ++use_tag;
if (send_listen_packet(sfd, tag) <= 0) {
DEBUG(1, "%s: ERROR: could not send listen packet\n", __func__);
- close_socket(sfd);
+ socket_close(sfd);
return -1;
}
if (usbmuxd_get_result(sfd, tag, &res, NULL) && (res != 0)) {
- close_socket(sfd);
+ socket_close(sfd);
if ((res == RESULT_BADVERSION) && (proto_version == 1)) {
proto_version = 0;
goto retry;
@@ -685,7 +685,7 @@ static void device_monitor_cleanup(void* data)
} ENDFOREACH
collection_free(&devices);
- close_socket(listenfd);
+ socket_close(listenfd);
listenfd = -1;
}
@@ -753,7 +753,7 @@ int usbmuxd_unsubscribe()
{
event_cb = NULL;
- shutdown_socket(listenfd, SHUT_RDWR);
+ socket_shutdown(listenfd, SHUT_RDWR);
#ifdef WIN32
if (devmon != NULL) {
@@ -842,7 +842,7 @@ retry:
if (res == RESULT_BADVERSION) {
proto_version = 0;
}
- close_socket(sfd);
+ socket_close(sfd);
try_list_devices = 0;
goto retry;
}
@@ -856,7 +856,7 @@ retry:
if (usbmuxd_get_result(sfd, tag, &res, NULL) && (res == 0)) {
listen_success = 1;
} else {
- close_socket(sfd);
+ socket_close(sfd);
if ((res == RESULT_BADVERSION) && (proto_version == 1)) {
proto_version = 0;
goto retry;
@@ -918,7 +918,7 @@ retry:
got_device_list:
// explicitly close connection
- close_socket(sfd);
+ socket_close(sfd);
// create copy of device info entries from collection
newlist = (usbmuxd_device_info_t*)malloc(sizeof(usbmuxd_device_info_t) * (collection_count(&tmpdevs) + 1));
@@ -1009,7 +1009,7 @@ retry:
} else {
if ((res == RESULT_BADVERSION) && (proto_version == 1)) {
proto_version = 0;
- close_socket(sfd);
+ socket_close(sfd);
goto retry;
}
DEBUG(1, "%s: Connect failed, Error code=%d\n", __func__, res);
@@ -1021,14 +1021,14 @@ retry:
return sfd;
}
- close_socket(sfd);
+ socket_close(sfd);
return -1;
}
int usbmuxd_disconnect(int sfd)
{
- return close_socket(sfd);
+ return socket_close(sfd);
}
int usbmuxd_send(int sfd, const char *data, uint32_t len, uint32_t *sent_bytes)
@@ -1056,7 +1056,7 @@ int usbmuxd_send(int sfd, const char *data, uint32_t len, uint32_t *sent_bytes)
int usbmuxd_recv_timeout(int sfd, char *data, uint32_t len, uint32_t *recv_bytes, unsigned int timeout)
{
- int num_recv = recv_buf_timeout(sfd, (void*)data, len, 0, timeout);
+ int num_recv = socket_receive_timeout(sfd, (void*)data, len, 0, timeout);
if (num_recv < 0) {
*recv_bytes = 0;
return num_recv;
@@ -1241,5 +1241,5 @@ void libusbmuxd_set_use_inotify(int set)
void libusbmuxd_set_debug_level(int level)
{
libusbmuxd_debug = level;
- sock_stuff_set_verbose(level);
+ socket_set_verbose(level);
}