Skip to content

Commit

Permalink
win32: Fix compilation
Browse files Browse the repository at this point in the history
  • Loading branch information
nikias committed Aug 2, 2019
1 parent 219e6bc commit b097ea3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 2 deletions.
3 changes: 3 additions & 0 deletions common/socket.c
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,9 @@ static int wsa_init = 0;
#ifndef ECONNRESET
#define ECONNRESET 108
#endif
#ifndef ETIMEDOUT
#define ETIMEDOUT 138
#endif

static int verbose = 0;

Expand Down
20 changes: 18 additions & 2 deletions tools/icat.c
Original file line number Diff line number Diff line change
Expand Up @@ -29,19 +29,35 @@
#include <stddef.h>
#include <unistd.h>
#include <errno.h>
#ifdef WIN32
#include <windows.h>
#include <winsock2.h>
#else
#include <sys/socket.h>
#include <sys/un.h>
#include <sys/ioctl.h>
#endif

#include "usbmuxd.h"
#include "socket.h"

static size_t read_data_socket(int fd, uint8_t* buf, size_t bufsize)
{
size_t bytesavailable;
#ifdef WIN32
u_long bytesavailable = 0;
if (fd == STDIN_FILENO) {
bytesavailable = bufsize;
} else if (ioctlsocket(fd, FIONREAD, &bytesavailable) != 0) {
perror("ioctlsocket FIONREAD failed");
exit(1);
}
#else
size_t bytesavailable = 0;
if (ioctl(fd, FIONREAD, &bytesavailable) != 0) {
perror("ioctl FIONREAD failed");
exit(1);
}
#endif
size_t bufread = (bytesavailable >= bufsize) ? bufsize:bytesavailable;
ssize_t ret = read(fd, buf, bufread);
if (ret < 0) {
Expand Down Expand Up @@ -143,6 +159,6 @@ int main(int argc, char **argv)
}
}

close(devfd);
socket_close(devfd);
return ret;
}
4 changes: 4 additions & 0 deletions tools/iproxy.c
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,10 @@ typedef unsigned int socklen_t;
#include "socket.h"
#include "usbmuxd.h"

#ifndef ETIMEDOUT
#define ETIMEDOUT 138
#endif

static uint16_t listen_port = 0;
static uint16_t device_port = 0;
static char* device_udid = NULL;
Expand Down

0 comments on commit b097ea3

Please sign in to comment.