]> git.sesse.net Git - ffmpeg/blobdiff - libavformat/os_support.c
mpjpeg: Use proper CR/LF in multipart headers
[ffmpeg] / libavformat / os_support.c
index 2d8a90346a2a743fc7995d0716e6f3f0b797d9dd..e9b1f88fb8efee5124f0222025b3974e56127ea0 100644 (file)
 #include "avformat.h"
 #include "os_support.h"
 
-#if defined(_WIN32) && !defined(__MINGW32CE__)
-#undef open
-#undef lseek
-#undef stat
-#undef fstat
-#include <fcntl.h>
-#include <io.h>
-#include <windows.h>
-#include <share.h>
-#include <errno.h>
-
-int ff_win32_open(const char *filename_utf8, int oflag, int pmode)
-{
-    int fd;
-    int num_chars;
-    wchar_t *filename_w;
-
-    /* convert UTF-8 to wide chars */
-    num_chars = MultiByteToWideChar(CP_UTF8, MB_ERR_INVALID_CHARS, filename_utf8, -1, NULL, 0);
-    if (num_chars <= 0)
-        goto fallback;
-    filename_w = av_mallocz(sizeof(wchar_t) * num_chars);
-    if (!filename_w) {
-        errno = ENOMEM;
-        return -1;
-    }
-    MultiByteToWideChar(CP_UTF8, 0, filename_utf8, -1, filename_w, num_chars);
-
-    fd = _wsopen(filename_w, oflag, SH_DENYNO, pmode);
-    av_freep(&filename_w);
-
-    if (fd != -1 || (oflag & O_CREAT))
-        return fd;
-
-fallback:
-    /* filename may be be in CP_ACP */
-    return _sopen(filename_utf8, oflag, SH_DENYNO, pmode);
-}
-#endif
-
 #if CONFIG_NETWORK
 #include <fcntl.h>
 #if !HAVE_POLL_H
 #if HAVE_SYS_TIME_H
 #include <sys/time.h>
-#endif
+#endif /* HAVE_SYS_TIME_H */
 #if HAVE_WINSOCK2_H
 #include <winsock2.h>
 #elif HAVE_SYS_SELECT_H
 #include <sys/select.h>
-#endif
-#endif
+#endif /* HAVE_WINSOCK2_H */
+#endif /* !HAVE_POLL_H */
 
 #include "network.h"
 
@@ -122,7 +82,7 @@ int ff_getaddrinfo(const char *node, const char *service,
     win_getaddrinfo = GetProcAddress(ws2mod, "getaddrinfo");
     if (win_getaddrinfo)
         return win_getaddrinfo(node, service, hints, res);
-#endif
+#endif /* HAVE_WINSOCK2_H */
 
     *res = NULL;
     sin  = av_mallocz(sizeof(struct sockaddr_in));
@@ -196,7 +156,7 @@ void ff_freeaddrinfo(struct addrinfo *res)
         win_freeaddrinfo(res);
         return;
     }
-#endif
+#endif /* HAVE_WINSOCK2_H */
 
     av_free(res->ai_canonname);
     av_free(res->ai_addr);
@@ -217,7 +177,7 @@ int ff_getnameinfo(const struct sockaddr *sa, int salen,
     win_getnameinfo = GetProcAddress(ws2mod, "getnameinfo");
     if (win_getnameinfo)
         return win_getnameinfo(sa, salen, host, hostlen, serv, servlen, flags);
-#endif
+#endif /* HAVE_WINSOCK2_H */
 
     if (sa->sa_family != AF_INET)
         return EAI_FAMILY;
@@ -244,16 +204,9 @@ int ff_getnameinfo(const struct sockaddr *sa, int salen,
     }
 
     if (serv && servlen > 0) {
-        struct servent *ent = NULL;
-#if HAVE_GETSERVBYPORT
         if (!(flags & NI_NUMERICSERV))
-            ent = getservbyport(sin->sin_port, flags & NI_DGRAM ? "udp" : "tcp");
-#endif
-
-        if (ent)
-            snprintf(serv, servlen, "%s", ent->s_name);
-        else
-            snprintf(serv, servlen, "%d", ntohs(sin->sin_port));
+            return EAI_FAIL;
+        snprintf(serv, servlen, "%d", ntohs(sin->sin_port));
     }
 
     return 0;
@@ -278,7 +231,7 @@ const char *ff_gai_strerror(int ecode)
 #if EAI_NODATA != EAI_NONAME
     case EAI_NODATA:
         return "No address associated with hostname";
-#endif
+#endif /* EAI_NODATA != EAI_NONAME */
     case EAI_NONAME:
         return "The name does not resolve for the supplied parameters";
     case EAI_SERVICE:
@@ -301,7 +254,7 @@ int ff_socket_nonblock(int socket, int enable)
         return fcntl(socket, F_SETFL, fcntl(socket, F_GETFL) | O_NONBLOCK);
     else
         return fcntl(socket, F_SETFL, fcntl(socket, F_GETFL) & ~O_NONBLOCK);
-#endif
+#endif /* HAVE_WINSOCK2_H */
 }
 
 #if !HAVE_POLL_H
@@ -319,7 +272,7 @@ int ff_poll(struct pollfd *fds, nfds_t numfds, int timeout)
         errno = EINVAL;
         return -1;
     }
-#endif
+#endif /* HAVE_WINSOCK2_H */
 
     FD_ZERO(&read_set);
     FD_ZERO(&write_set);
@@ -334,7 +287,7 @@ int ff_poll(struct pollfd *fds, nfds_t numfds, int timeout)
             errno = EINVAL;
             return -1;
         }
-#endif
+#endif /* !HAVE_WINSOCK2_H */
 
         if (fds[i].events & POLLIN)
             FD_SET(fds[i].fd, &read_set);
@@ -376,5 +329,6 @@ int ff_poll(struct pollfd *fds, nfds_t numfds, int timeout)
 
     return rc;
 }
-#endif /* HAVE_POLL_H */
+#endif /* !HAVE_POLL_H */
+
 #endif /* CONFIG_NETWORK */