mirror of
https://github.com/owntone/owntone-server.git
synced 2025-03-20 04:24:20 -04:00
cleanups for io_ on win32. still not quite working right, some read or write errors when streaming files, but a strong "mostly works"
This commit is contained in:
parent
ca7beedde3
commit
4f0b1f24e0
@ -5,7 +5,7 @@
|
||||
# include "config.h"
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRCASESTR
|
||||
#if !HAVE_STRCASESTR
|
||||
extern char *strcasestr(char* haystack, char* needle);
|
||||
#endif
|
||||
|
||||
@ -13,6 +13,10 @@ extern char *strcasestr(char* haystack, char* needle);
|
||||
extern char *strptime(char *buf, char *fmt, struct tm *tm );
|
||||
#endif
|
||||
|
||||
#if !HAVE_STRSEP
|
||||
char *strsep(char **stringp, const char *delim);
|
||||
#endif
|
||||
|
||||
#ifndef HAVE_STRTOK_R
|
||||
#undef strtok_r /* defend against win32 pthreads */
|
||||
extern char *strtok_r(char *s, char *delim, char **last);
|
||||
|
@ -57,7 +57,7 @@ struct tag_io_privhandle {
|
||||
IO_OPTIONLIST *pol; /**< List of passed options */
|
||||
char *proto; /**< proto of file */
|
||||
int buffering; /**< are we in linebuffer mode? */
|
||||
int buffer_offset; /**< current offset pointer */
|
||||
uint32_t buffer_offset; /**< current offset pointer */
|
||||
uint32_t buffer_len; /**< total size of buffer */
|
||||
unsigned char *buffer; /**< linebuffer */
|
||||
|
||||
|
8
src/io.c
8
src/io.c
@ -336,6 +336,8 @@ static IO_FNPTR io_pfn_udplisten = {
|
||||
|
||||
static WSADATA io_WSAData;
|
||||
|
||||
#undef gettimeofday /* FIXME: proper gettimeofday fixups */
|
||||
|
||||
int gettimeofday (struct timeval *tv, void* tz) {
|
||||
union {
|
||||
uint64_t ns100; /*time since 1 Jan 1601 in 100ns units */
|
||||
@ -422,14 +424,14 @@ int io_urldecode(char *str) {
|
||||
io_err_printf(IO_LOG_DEBUG,"urldecode: bad hex digit\n");
|
||||
return FALSE;
|
||||
}
|
||||
digit1 = strchr(hexdigits,tolower(*current)) - hexdigits;
|
||||
digit1 = (int)(strchr(hexdigits,tolower(*current)) - hexdigits);
|
||||
|
||||
current++;
|
||||
if(!strchr(hexdigits,tolower(*current))) {
|
||||
io_err_printf(IO_LOG_DEBUG,"urldecode: bad hex digit\n");
|
||||
return FALSE;
|
||||
}
|
||||
digit2 = strchr(hexdigits,tolower(*current)) - hexdigits;
|
||||
digit2 = (int)(strchr(hexdigits,tolower(*current)) - hexdigits);
|
||||
current++;
|
||||
|
||||
*dst++ = (char)(((digit1 & 0x0F) << 4) | (digit2 & 0x0F));
|
||||
@ -814,7 +816,7 @@ int io_read_timeout(IO_PRIVHANDLE *phandle, unsigned char *buf, uint32_t *len,
|
||||
int io_read(IO_PRIVHANDLE *phandle, unsigned char *buf, uint32_t *len) {
|
||||
int result;
|
||||
unsigned char *buf_ptr = buf;
|
||||
int read_size;
|
||||
uint32_t read_size;
|
||||
uint32_t max_len = *len;
|
||||
|
||||
ASSERT(io_initialized);
|
||||
|
295
src/os-win32.c
295
src/os-win32.c
@ -35,39 +35,16 @@ static int os_maps_init=0;
|
||||
/* Forwards */
|
||||
static void _os_socket_startup(void);
|
||||
static void _os_socket_shutdown(void);
|
||||
static int _os_sock_to_fd(SOCKET sock);
|
||||
static void _os_lock(void);
|
||||
static void _os_unlock(void);
|
||||
static BOOL WINAPI _os_cancelhandler(DWORD dwCtrlType);
|
||||
static void _os_phandle_dump(void);
|
||||
char *_os_filepath(char *file);
|
||||
|
||||
|
||||
extern int gettimeout(struct timeval end,struct timeval *timeoutp);
|
||||
|
||||
#define OSFI_OPEN 1
|
||||
#define OSFI_SHUTDOWN 2
|
||||
|
||||
#define NOTSOCK (fd < MAXDESC)
|
||||
#define REALSOCK (file_info[fd - MAXDESC].sock)
|
||||
#define SOCKSTATE (file_info[fd - MAXDESC].state)
|
||||
|
||||
#define MAXBACKLOG 5
|
||||
|
||||
typedef struct tag_osfileinfo {
|
||||
SOCKET sock;
|
||||
int state;
|
||||
} OSFILEINFO;
|
||||
|
||||
/* Globals */
|
||||
OSFILEINFO file_info[MAXDESC];
|
||||
char os_config_file[PATH_MAX];
|
||||
char *os_w32_socket_states[] = {
|
||||
"Closed/Unused",
|
||||
"Open/Listening",
|
||||
"Shutdown, not closed"
|
||||
};
|
||||
|
||||
/* "official" os interface functions */
|
||||
|
||||
/**
|
||||
@ -101,17 +78,6 @@ int os_init(int foreground, char *runas) {
|
||||
os_maps_init=1;
|
||||
free(inifile);
|
||||
|
||||
_os_socket_startup();
|
||||
|
||||
if(!os_initialized) {
|
||||
_os_lock();
|
||||
if(!os_initialized) {
|
||||
memset((void*)&file_info,0,sizeof(file_info));
|
||||
}
|
||||
os_initialized=1;
|
||||
_os_unlock();
|
||||
}
|
||||
|
||||
if(!foreground) {
|
||||
/* startup as service */
|
||||
os_serviceflag = 1;
|
||||
@ -126,22 +92,6 @@ int os_init(int foreground, char *runas) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
/**
|
||||
* dump pseudo-handles
|
||||
*/
|
||||
void _os_phandle_dump(void) {
|
||||
int fd;
|
||||
/* walk through and log the different sockets */
|
||||
fd=1; /* skip the main listen socket */
|
||||
while(fd < MAXDESC) {
|
||||
if(file_info[fd].state) {
|
||||
DPRINTF(E_LOG,L_MISC,"Socket %d (%d): State %s\n",fd,fd+MAXDESC,
|
||||
os_w32_socket_states[file_info[fd].state]);
|
||||
}
|
||||
fd++;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* wait for signals
|
||||
*
|
||||
@ -154,11 +104,6 @@ void os_wait(int seconds) {
|
||||
* shutdown the system-specific stuff started in os_init.
|
||||
*/
|
||||
void os_deinit(void) {
|
||||
|
||||
_os_socket_shutdown();
|
||||
|
||||
_os_phandle_dump();
|
||||
|
||||
if(os_serviceflag) {
|
||||
/* then we need to stop the service */
|
||||
SetConsoleCtrlHandler(_os_cancelhandler,FALSE);
|
||||
@ -227,116 +172,6 @@ static BOOL WINAPI _os_cancelhandler(DWORD dwCtrlType) {
|
||||
return TRUE;
|
||||
}
|
||||
|
||||
|
||||
int _os_sock_to_fd(SOCKET sock) {
|
||||
int fd;
|
||||
|
||||
if(sock == INVALID_SOCKET)
|
||||
return -1;
|
||||
|
||||
DPRINTF(E_DBG,L_MISC,"Converting socket to fd\n");
|
||||
|
||||
/* I was doing strange osfhandle stuff here, but it seemed
|
||||
* to be leaking file handles, and I don't really know what
|
||||
* it was doing. Thanks, Microsoft. Anyway, since I'm handling
|
||||
* reads, writes, opens and closes, I might just as well hand out
|
||||
* FAKE fds and swap them out to SOCKETS when I need to. No
|
||||
* more fd leaks. Problem solved.
|
||||
*/
|
||||
/*
|
||||
fd=_open_osfhandle(sock,O_RDWR|O_BINARY);
|
||||
// fd=_open_osfhandle(sock,0);
|
||||
if(fd > 0) {
|
||||
file_info[fd].flags = OSFI_SOCKET | OSFI_OPEN;
|
||||
file_info[fd].sock=sock;
|
||||
} else {
|
||||
DPRINTF(E_LOG,L_MISC,"Could not fd for socket osfhandle\n");
|
||||
}
|
||||
*/
|
||||
_os_lock();
|
||||
fd=0;
|
||||
while((fd < MAXDESC) && (file_info[fd].state)) {
|
||||
fd++;
|
||||
}
|
||||
|
||||
if(fd == MAXDESC) {
|
||||
_os_unlock();
|
||||
_os_phandle_dump();
|
||||
DPRINTF(E_FATAL,L_MISC,"Out of pseudo file handles. See ya\n");
|
||||
}
|
||||
|
||||
DPRINTF(E_DBG,L_MISC,"Returning fd %d\n",fd + MAXDESC);
|
||||
file_info[fd].sock = sock;
|
||||
file_info[fd].state = OSFI_OPEN;
|
||||
_os_unlock();
|
||||
return fd + MAXDESC;
|
||||
}
|
||||
|
||||
int os_acceptsocket(int fd, struct in_addr *hostaddr) {
|
||||
socklen_t len = sizeof(struct sockaddr);
|
||||
struct sockaddr_in netclient;
|
||||
SOCKET retval;
|
||||
|
||||
DPRINTF(E_SPAM,L_MISC,"Accepting socket %d -- %d\n",fd,REALSOCK);
|
||||
|
||||
if(NOTSOCK || (SOCKSTATE != OSFI_OPEN)) {
|
||||
DPRINTF(E_LOG,L_MISC,"Bad socket passed to accept\n");
|
||||
return -1;
|
||||
}
|
||||
|
||||
while (((retval =
|
||||
accept(REALSOCK,(struct sockaddr *)(&netclient), &len)) == SOCKET_ERROR) &&
|
||||
(WSAGetLastError() == WSAEINTR));
|
||||
|
||||
if (retval == INVALID_SOCKET) {
|
||||
DPRINTF(E_LOG,L_MISC,"Error accepting...\n");
|
||||
return _os_sock_to_fd(retval);
|
||||
}
|
||||
|
||||
*hostaddr = netclient.sin_addr;
|
||||
return _os_sock_to_fd(retval);
|
||||
}
|
||||
|
||||
int os_waitfdtimed(int fd, struct timeval end) {
|
||||
fd_set readset;
|
||||
int retval;
|
||||
struct timeval timeout;
|
||||
SOCKET sock;
|
||||
|
||||
DPRINTF(E_SPAM,L_MISC,"Timed wait on fd %d\n");
|
||||
if(NOTSOCK || (SOCKSTATE != OSFI_OPEN))
|
||||
return -1;
|
||||
|
||||
sock = REALSOCK;
|
||||
|
||||
/*
|
||||
if ((fd < 0) || (fd >= FD_SETSIZE)) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
*/
|
||||
|
||||
FD_ZERO(&readset);
|
||||
FD_SET(sock, &readset);
|
||||
if (gettimeout(end, &timeout) == -1)
|
||||
return -1;
|
||||
while (((retval = select(1, &readset, NULL, NULL, NULL)) == SOCKET_ERROR)
|
||||
&& (WSAGetLastError() == WSAEINTR)) {
|
||||
if (gettimeout(end, &timeout) == -1)
|
||||
return -1;
|
||||
FD_ZERO(&readset);
|
||||
FD_SET(fd, &readset);
|
||||
}
|
||||
if (retval == 0) {
|
||||
errno = ETIME;
|
||||
return -1;
|
||||
}
|
||||
if (retval == -1)
|
||||
return -1;
|
||||
DPRINTF(E_SPAM,L_MISC,"Timed wait successful\n");
|
||||
return 0;
|
||||
}
|
||||
|
||||
/* from the gnu c library */
|
||||
char *os_strsep(char **stringp, const char *delim) {
|
||||
char *begin, *end;
|
||||
@ -377,111 +212,6 @@ char *os_strsep(char **stringp, const char *delim) {
|
||||
return begin;
|
||||
}
|
||||
|
||||
int os_opensocket(unsigned short port) {
|
||||
int error;
|
||||
struct sockaddr_in server;
|
||||
SOCKET sock;
|
||||
int true = 1;
|
||||
int fd;
|
||||
|
||||
DPRINTF(E_SPAM,L_MISC,"Opening socket\n");
|
||||
/* make sure the file_info struct is initialized */
|
||||
if(!os_initialized) {
|
||||
_os_lock();
|
||||
if(!os_initialized) {
|
||||
memset((void*)&file_info,0,sizeof(file_info));
|
||||
os_initialized=1;
|
||||
}
|
||||
_os_unlock();
|
||||
}
|
||||
|
||||
if((sock = socket(AF_INET, SOCK_STREAM, 0)) == -1)
|
||||
return -1;
|
||||
|
||||
if (setsockopt(sock, SOL_SOCKET, SO_REUSEADDR, (char *)&true,
|
||||
sizeof(true)) == SOCKET_ERROR) {
|
||||
error = WSAGetLastError();
|
||||
while ((closesocket(sock) == SOCKET_ERROR) && (WSAGetLastError() == WSAEINTR));
|
||||
errno = EINVAL; /* windows errnos suck */
|
||||
return -1;
|
||||
}
|
||||
|
||||
server.sin_family = AF_INET;
|
||||
server.sin_addr.s_addr = htonl(INADDR_ANY);
|
||||
server.sin_port = htons((short)port);
|
||||
if ((bind(sock, (struct sockaddr *)&server, sizeof(server)) == -1) ||
|
||||
(listen(sock, MAXBACKLOG) == -1)) {
|
||||
error = errno;
|
||||
while ((closesocket(sock) == SOCKET_ERROR) && (WSAGetLastError() == WSAEINTR));
|
||||
errno = WSAGetLastError();
|
||||
return -1;
|
||||
}
|
||||
|
||||
fd=_os_sock_to_fd(sock);
|
||||
DPRINTF(E_SPAM,L_MISC,"created socket %d\n",fd);
|
||||
return fd;
|
||||
}
|
||||
|
||||
int os_write(int fd, void *buffer, unsigned int count) {
|
||||
int retval;
|
||||
|
||||
if(NOTSOCK) {
|
||||
retval = _write(fd,buffer,count);
|
||||
} else {
|
||||
if(SOCKSTATE != OSFI_OPEN) {
|
||||
DPRINTF(E_LOG,L_MISC,"Write to socket with status: %d\n",
|
||||
file_info[fd-MAXDESC].state);
|
||||
return -1;
|
||||
}
|
||||
retval=send(REALSOCK,buffer,count,0);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
int os_read(int fd,void *buffer,unsigned int count) {
|
||||
int retval;
|
||||
|
||||
// DPRINTF(E_SPAM,L_MISC,"Reading %d bytes from %d\n",count,fd);
|
||||
if(NOTSOCK) {
|
||||
retval = _read(fd,buffer,count);
|
||||
} else {
|
||||
if(SOCKSTATE != OSFI_OPEN) {
|
||||
DPRINTF(E_LOG,L_MISC,"Read to socket with status: %d\n",
|
||||
file_info[fd-MAXDESC].state);
|
||||
return -1;
|
||||
}
|
||||
retval=recv(REALSOCK,buffer,count,0);
|
||||
// DPRINTF(E_SPAM,L_MISC,"Actually returning %d\n",retval);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
int os_shutdown(int fd, int how) {
|
||||
if(NOTSOCK || (SOCKSTATE != OSFI_OPEN))
|
||||
return -1;
|
||||
|
||||
SOCKSTATE = OSFI_SHUTDOWN;
|
||||
shutdown(REALSOCK,how);
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
int os_close(int fd) {
|
||||
if(NOTSOCK) {
|
||||
_close(fd);
|
||||
} else { /* socket */
|
||||
if(SOCKSTATE == OSFI_OPEN) {
|
||||
os_shutdown(fd,SHUT_RDWR);
|
||||
}
|
||||
if(SOCKSTATE == OSFI_SHUTDOWN) {
|
||||
closesocket(REALSOCK);
|
||||
SOCKSTATE = 0;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* get uid of current user. this is really stubbed, as it's only used
|
||||
* as a check during startup (it fails normally if you run non-root, as it means
|
||||
@ -843,28 +573,3 @@ int os_lstat(const char *path, struct _stat *sb) {
|
||||
}
|
||||
|
||||
|
||||
/* These should be fixed by io_ functions
|
||||
int os_open(const char *filename, int oflag) {
|
||||
WCHAR utf16_path[PATH_MAX+1];
|
||||
int fd;
|
||||
|
||||
memset(utf16_path,0,sizeof(utf16_path));
|
||||
util_utf8toutf16((unsigned char *)&utf16_path,PATH_MAX * 2,(char*)filename,(int)strlen(filename));
|
||||
|
||||
fd = _wopen(utf16_path, oflag | O_BINARY);
|
||||
return fd;
|
||||
}
|
||||
|
||||
FILE *os_fopen(const char *filename, const char *mode) {
|
||||
WCHAR utf16_path[PATH_MAX+1];
|
||||
WCHAR utf16_mode[10];
|
||||
|
||||
memset(utf16_path,0,sizeof(utf16_path));
|
||||
memset(utf16_mode,0,sizeof(utf16_mode));
|
||||
util_utf8toutf16((unsigned char *)&utf16_path,PATH_MAX * 2,(char*)filename,(int)strlen(filename));
|
||||
util_utf8toutf16((unsigned char *)&utf16_mode,10 * 2,(char*)mode,(int)strlen(mode));
|
||||
return _wfopen((wchar_t *)&utf16_path, (wchar_t *)&utf16_mode);
|
||||
}
|
||||
*/
|
||||
|
||||
|
||||
|
@ -356,8 +356,8 @@ int dmap_add_long(unsigned char *where, char *tag, uint64_t value) {
|
||||
where[4]=where[5]=where[6]=0;
|
||||
where[7]=8;
|
||||
|
||||
v_hi = (value >> 32) & 0xFFFFFFFF;
|
||||
v_lo = value & 0xFFFFFFFF;
|
||||
v_hi = (uint32_t)((value >> 32) & 0xFFFFFFFF);
|
||||
v_lo = (uint32_t)(value & 0xFFFFFFFF);
|
||||
|
||||
/* value */
|
||||
where[8] = (v_hi >> 24) & 0xFF;
|
||||
|
@ -43,7 +43,7 @@
|
||||
#include "out-daap.h"
|
||||
#include "out-daap-proto.h"
|
||||
|
||||
#undef strsep /* FIXME */
|
||||
//#undef strsep /* FIXME */
|
||||
|
||||
/**
|
||||
* Hold the inf for the output serializer
|
||||
|
@ -15,8 +15,10 @@
|
||||
#include <string.h>
|
||||
|
||||
#include <windows.h>
|
||||
#include <mmreg.h>
|
||||
#include <wmsdk.h>
|
||||
|
||||
|
||||
#include "ff-plugins.h"
|
||||
|
||||
#ifndef TRUE
|
||||
|
@ -72,7 +72,7 @@ time_t scan_aac_mac_to_unix_time(int t) {
|
||||
*/
|
||||
uint64_t scan_aac_drilltoatom(IOHANDLE hfile,char *atom_path,
|
||||
unsigned int *atom_length) {
|
||||
long atom_offset;
|
||||
uint64_t atom_offset;
|
||||
uint64_t file_size,pos;
|
||||
char *cur_p, *end_p;
|
||||
char atom_name[5];
|
||||
|
@ -108,8 +108,8 @@ int scan_aif_parse_comm(IOHANDLE hfile, MP3FILE *pmp3) {
|
||||
pmp3->bitrate = pmp3->samplerate * comm.channels *
|
||||
((comm.sample_size + 7)/8)*8;
|
||||
|
||||
sec = pmp3->file_size / (pmp3->bitrate / 8);
|
||||
ms = ((pmp3->file_size % (pmp3->bitrate / 8)) * 1000) / (pmp3->bitrate/8);
|
||||
sec = (int)(pmp3->file_size / (pmp3->bitrate / 8));
|
||||
ms = (int)(((pmp3->file_size % (pmp3->bitrate / 8)) * 1000) / (pmp3->bitrate/8));
|
||||
pmp3->song_length = (sec * 1000) + ms;
|
||||
|
||||
pmp3->bitrate /= 1000;
|
||||
|
@ -108,7 +108,7 @@ int scan_get_flacinfo(char *filename, MP3FILE *pmp3) {
|
||||
if ((sec == 0) && (ms == 0))
|
||||
break; /* Info is crap, escape div-by-zero. */
|
||||
pmp3->song_length = (sec * 1000) + ms;
|
||||
pmp3->bitrate = (pmp3->file_size) / (((sec * 1000) + ms) / 8);
|
||||
pmp3->bitrate = (uint32_t)((pmp3->file_size) / (((sec * 1000) + ms) / 8));
|
||||
pmp3->samplerate = block->data.stream_info.sample_rate;
|
||||
pmp3->bits_per_sample = block->data.stream_info.bits_per_sample;
|
||||
pmp3->sample_count = block->data.stream_info.total_samples;
|
||||
|
@ -63,7 +63,7 @@ typedef struct tag_scan_frameinfo {
|
||||
int xing_offset; /**< Where the xing header should be relative to end of hdr */
|
||||
int number_of_frames; /**< Number of frames in the song */
|
||||
|
||||
int frame_offset; /**< Where this frame was found */
|
||||
uint64_t frame_offset; /**< Where this frame was found */
|
||||
|
||||
double version; /**< MPEG version (e.g. 2.0, 2.5, 1.0) */
|
||||
|
||||
@ -1036,7 +1036,7 @@ int scan_mp3_get_mp3fileinfo(char *file, MP3FILE *pmp3) {
|
||||
|
||||
/* back-calculate bitrate from duration */
|
||||
if((pmp3->song_length) && (!pmp3->bitrate)) { /* could still be unknown */
|
||||
pmp3->bitrate = (file_size / pmp3->song_length) * 8;
|
||||
pmp3->bitrate = (uint32_t)((file_size / pmp3->song_length) * 8);
|
||||
}
|
||||
|
||||
|
||||
|
@ -30,7 +30,7 @@ size_t scan_ogg_read(void *ptr, size_t size, size_t nmemb, void *datasource) {
|
||||
IOHANDLE hfile = (IOHANDLE)datasource;
|
||||
uint32_t bytes_read;
|
||||
|
||||
bytes_read = size * nmemb;
|
||||
bytes_read = (uint32_t)(size * nmemb);
|
||||
if(!io_read(hfile,ptr,&bytes_read))
|
||||
return -1;
|
||||
|
||||
|
@ -1192,7 +1192,7 @@ int ws_writefd(WS_CONNINFO *pwsc, char *fmt, ...) {
|
||||
vsnprintf(buffer, 1024, fmt, ap);
|
||||
va_end(ap);
|
||||
|
||||
len = strlen(buffer);
|
||||
len = (uint32_t)strlen(buffer);
|
||||
if(!io_write(pwsc->hclient,(unsigned char *)buffer,&len)) {
|
||||
ws_dprintf(L_WS_LOG,"Error writing to client socket: %s",
|
||||
io_errstr(pwsc->hclient));
|
||||
@ -2101,11 +2101,12 @@ extern char *ws_hostname(WS_CONNINFO *pwsc) {
|
||||
* @return TRUE on success
|
||||
*/
|
||||
int ws_set_err(WS_CONNINFO *pwsc, int ws_error) {
|
||||
ASSERT(pwsc);
|
||||
#ifdef WIN32
|
||||
char lpErrorBuf[256];
|
||||
#endif
|
||||
|
||||
ASSERT(pwsc);
|
||||
|
||||
if(!pwsc)
|
||||
return FALSE;
|
||||
|
||||
|
39
src/win32.h
39
src/win32.h
@ -12,14 +12,17 @@
|
||||
#if defined(_MSC_VER)
|
||||
# if _MSC_VER >= 1400
|
||||
# define _CRT_SECURE_NO_DEPRECATE 1
|
||||
# define _CRT_NONSTDC_NO_DEPRECATE 1
|
||||
# endif
|
||||
#endif
|
||||
|
||||
// Don't pull in winsock...
|
||||
#define WIN32_LEAN_AND_MEAN
|
||||
|
||||
// Must include all these before defining the non-underscore versions
|
||||
// otherwise the prototypes will go awry.
|
||||
#include <windows.h>
|
||||
//#include <winsock2.h>
|
||||
#include <io.h>
|
||||
//#include <io.h>
|
||||
#include <stddef.h>
|
||||
#include <fcntl.h>
|
||||
#include <direct.h>
|
||||
@ -28,14 +31,13 @@
|
||||
/* Type fixups */
|
||||
#define mode_t int
|
||||
#define ssize_t int
|
||||
#define socklen_t int
|
||||
//#define socklen_t int
|
||||
|
||||
/* Consts */
|
||||
#define PIPE_BUF 256 /* What *should* this be on win32? */
|
||||
#define MAXDESC 512 /* http://msdn.microsoft.com/en-us/library/kdfaxaay.aspx */
|
||||
#define SHUT_RDWR 2
|
||||
#define ETIME 101
|
||||
#define PATH_MAX 512 /* it's clearly not _MAX_PATH... other projects seem to use 512 */
|
||||
#define PATH_MAX 2048 /* it's clearly not _MAX_PATH... other projects seem to use 512 */
|
||||
#define MAX_NAME_LEN _MAX_PATH
|
||||
#define EADDRINUSE WSAEADDRINUSE
|
||||
#define S_IFLNK 0x1
|
||||
@ -61,31 +63,20 @@ typedef INT64 int64_t;
|
||||
|
||||
|
||||
/* Funtion fixups */
|
||||
#define snprintf _snprintf
|
||||
#define vsnprintf _vsnprintf
|
||||
#define usleep Sleep
|
||||
#define sleep(a) Sleep((a) * 1000)
|
||||
#define read(a,b,c) os_read((a),(b),(int)(c))
|
||||
#define write(a,b,c) os_write((a),(b),(int)(c))
|
||||
#define strncasecmp _strnicmp
|
||||
#define strcasecmp _stricmp
|
||||
#define mkdir(a,b) _mkdir((a))
|
||||
#define popen _popen
|
||||
#define pclose _pclose
|
||||
#define strtoll strtol
|
||||
#define access _access
|
||||
#define strdup _strdup
|
||||
#define dup _dup
|
||||
#define fdopen _fdopen
|
||||
#define lseek _lseek
|
||||
#define dup2 _dup2
|
||||
#define fileno _fileno
|
||||
#define tzset _tzset
|
||||
#define putenv _putenv
|
||||
#define strtoll strtol /* FIXME: compat functions */
|
||||
#define atoll atol
|
||||
|
||||
#define realpath os_realpath
|
||||
#define strsep os_strsep
|
||||
|
||||
#define strncasecmp strnicmp
|
||||
#define strcasecmp stricmp
|
||||
#define snprintf _snprintf
|
||||
#define access _access
|
||||
|
||||
// #define close os_close
|
||||
// #define open os_open
|
||||
// #define waitfdtimed os_waitfdtimed
|
||||
@ -96,7 +87,7 @@ typedef INT64 int64_t;
|
||||
#define opendir os_opendir
|
||||
|
||||
#define getuid os_getuid
|
||||
#define strerror os_strerror
|
||||
#define strerror os_strerror /* FIXME: get rid of posix errors */
|
||||
|
||||
/* override the uici stuff */
|
||||
// #define u_open os_opensocket
|
||||
|
@ -26,6 +26,10 @@
|
||||
# include <unistd.h>
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#include <io.h>
|
||||
#endif
|
||||
|
||||
#include <sys/stat.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
|
@ -63,7 +63,7 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="zdll.lib libid3tag.lib gnu_regex.lib pthreadVC2.lib wsock32.lib sqlite3.lib sqlite.lib dnssd.lib libFLAC.lib ogg_static.lib vorbis_static.lib vorbisfile_static.lib"
|
||||
AdditionalDependencies="zdll.lib libid3tag.lib gnu_regex.lib pthreadVC2.lib ws2_32.lib sqlite3.lib sqlite.lib dnssd.lib libFLAC.lib ogg_static.lib vorbis_static.lib vorbisfile_static.lib"
|
||||
OutputFile="$(OutDir)/mt-daapd.exe"
|
||||
LinkIncremental="2"
|
||||
AdditionalLibraryDirectories=""
|
||||
@ -143,7 +143,7 @@
|
||||
/>
|
||||
<Tool
|
||||
Name="VCLinkerTool"
|
||||
AdditionalDependencies="zdll.lib libid3tag.lib gnu_regex.lib pthreadVC2.lib wsock32.lib sqlite3.lib sqlite.lib dnssd.lib libFLAC.lib ogg_static.lib vorbis_static.lib vorbisfile_static.lib"
|
||||
AdditionalDependencies="zdll.lib libid3tag.lib gnu_regex.lib pthreadVC2.lib ws2_32.lib sqlite3.lib sqlite.lib dnssd.lib libFLAC.lib ogg_static.lib vorbis_static.lib vorbisfile_static.lib"
|
||||
OutputFile="$(OutDir)/mt-daapd.exe"
|
||||
LinkIncremental="1"
|
||||
AdditionalLibraryDirectories=""
|
||||
@ -188,6 +188,10 @@
|
||||
Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx"
|
||||
UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\src\bsd-snprintf.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\compat.c"
|
||||
>
|
||||
@ -228,6 +232,10 @@
|
||||
RelativePath="..\src\getopt.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\io.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\ll.c"
|
||||
>
|
||||
@ -256,10 +264,6 @@
|
||||
RelativePath="..\src\rend-win32.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\restart.c"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\rxml.c"
|
||||
>
|
||||
@ -362,6 +366,14 @@
|
||||
RelativePath="..\src\ff-plugins.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\io-errors.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\io-plugin.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\src\ll.h"
|
||||
>
|
||||
|
@ -4,6 +4,7 @@
|
||||
Version="8.00"
|
||||
Name="out-daap"
|
||||
ProjectGUID="{C1EF5133-DFB3-4FEC-B999-3655DBB14786}"
|
||||
RootNamespace="out-daap"
|
||||
Keyword="Win32Proj"
|
||||
>
|
||||
<Platforms>
|
||||
@ -201,6 +202,10 @@
|
||||
<Filter
|
||||
Name="Header Files"
|
||||
>
|
||||
<File
|
||||
RelativePath="..\..\src\compat.h"
|
||||
>
|
||||
</File>
|
||||
<File
|
||||
RelativePath="..\..\src\plugins\out-daap-db.h"
|
||||
>
|
||||
|
Loading…
x
Reference in New Issue
Block a user