22
22
#include "config.h"
23
23
#include "avformat.h"
24
#if defined(CONFIG_WINCE)
25
/* Skip includes on WinCE. */
26
#elif defined(__MINGW32__)
27
#include <sys/types.h>
28
#include <sys/timeb.h>
29
#elif defined(CONFIG_OS2)
33
24
#include <unistd.h>
26
#include "os_support.h"
39
#ifndef HAVE_SYS_POLL_H
40
#if defined(__MINGW32__)
30
#ifdef HAVE_WINSOCK2_H
41
31
#include <winsock2.h>
32
#elif defined (HAVE_SYS_SELECT_H)
43
33
#include <sys/select.h>
48
* gets the current time in micro seconds.
50
int64_t av_gettime(void)
52
#if defined(CONFIG_WINCE)
53
return timeGetTime() * INT64_C(1000);
54
#elif defined(__MINGW32__)
57
return ((int64_t)tb.time * INT64_C(1000) + (int64_t)tb.millitm) * INT64_C(1000);
60
gettimeofday(&tv,NULL);
61
return (int64_t)tv.tv_sec * 1000000 + tv.tv_usec;
65
#if !defined(CONFIG_WINCE) && !defined(HAVE_LOCALTIME_R)
66
struct tm *localtime_r(const time_t *t, struct tm *tp)
76
#endif /* !defined(CONFIG_WINCE) && !defined(HAVE_LOCALTIME_R) */
78
#if !defined(HAVE_INET_ATON) && defined(CONFIG_NETWORK)
39
#if !defined(HAVE_INET_ATON)
79
40
#include <stdlib.h>
80
41
#include <strings.h>
81
#include "barpainet.h"
83
43
int inet_aton (const char * str, struct in_addr * add)
85
const char * pch = str;
86
45
unsigned int add1 = 0, add2 = 0, add3 = 0, add4 = 0;
89
pch = strpbrk(pch,".");
90
if (pch == 0 || ++pch == 0) goto done;
92
pch = strpbrk(pch,".");
93
if (pch == 0 || ++pch == 0) goto done;
95
pch = strpbrk(pch,".");
96
if (pch == 0 || ++pch == 0) goto done;
47
if (sscanf(str, "%d.%d.%d.%d", &add1, &add2, &add3, &add4) != 4)
50
if (!add1 || (add1|add2|add3|add4) > 255) return 0;
100
52
add->s_addr=(add4<<24)+(add3<<16)+(add2<<8)+add1;
104
#endif /* !defined(HAVE_INET_ATON) && defined(CONFIG_NETWORK) */
56
#endif /* !defined(HAVE_INET_ATON) */
58
/* resolve host with also IP address parsing */
59
int resolve_host(struct in_addr *sin_addr, const char *hostname)
63
if (!inet_aton(hostname, sin_addr)) {
64
hp = gethostbyname(hostname);
67
memcpy(sin_addr, hp->h_addr, sizeof(struct in_addr));
72
int ff_socket_nonblock(int socket, int enable)
74
#ifdef HAVE_WINSOCK2_H
75
return ioctlsocket(socket, FIONBIO, &enable);
78
return fcntl(socket, F_SETFL, fcntl(socket, F_GETFL) | O_NONBLOCK);
80
return fcntl(socket, F_SETFL, fcntl(socket, F_GETFL) & ~O_NONBLOCK);
83
#endif /* CONFIG_NETWORK */
106
85
#ifdef CONFIG_FFSERVER
107
#ifndef HAVE_SYS_POLL_H
108
87
int poll(struct pollfd *fds, nfds_t numfds, int timeout)