As suggested, this just adds _DEFAULT_SOURCE while preserving
_SVID_SOURCE for whatever old systems still need it.
Signed-off-by: Daniel Bomar <dbdaniel42@gmail.com>
Signed-off-by: Michael Niedermayer <michaelni@gmx.at>
When libavformat was changed to use the new avpriv_open function
in 51eb213d00, this silently bypassed the existing wrapper for
win32. Move the win32 wrapper into libavutil/file.c to make sure
it gets called everywhere (not just in the libavformat case).
This makes sure that non-ascii file names gets opened properly
(where file names internally are stored as utf8, but they get
converted to wchar_t and opened with _wsopen).
Signed-off-by: Martin Storsjö <martin@martin.st>
- Make MultiByteToWideChar fail when it encounters invalid encoding.
Without this, invalid characters might just be skipped
- When MultiByteToWideChar fails, assume the file name is in CP_ACP
and open it via normal open function, even when the file will be
written
- When malloc fails return error instead of crashing
Signed-off-by: Martin Storsjö <martin@martin.st>
In order to match Linux behaviour better our Windows-specific
open() replacement should disable Windows default file locking.
Signed-off-by: Martin Storsjö <martin@martin.st>
- Make MultiByteToWideChar fail when it encounters invalid encoding.
Without this, invalid characters might just be skipped
- When MultiByteToWideChar fails, assume the file name is in CP_ACP
and open it via normal open function, even when the file will be
written
- When malloc fails return error instead of crashing
Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
The absence of this function will only give a less informative
string back from our fallback implementation of getnameinfo().
Signed-off-by: Mans Rullgard <mans@mansr.com>
Even if linking directly to getaddrinfo, use our version of
gai_strerror instead of the system's version. Microsoft explicitly
documents that their version of gai_strerror is thread-unsafe.
Signed-off-by: Martin Storsjö <martin@martin.st>
This is useful if a proper getaddrinfo is loaded dynamically on
windows, while using the fallback implementation of gai_strerror.
Signed-off-by: Martin Storsjö <martin@martin.st>
The fallback function is a non-static function, we shouldn't be
defining non-static functions outside of the proper ff/av prefix
namespaces.
This is especially important for a function like poll, which
other parties (other libraries, or executables linking these
libraries) also might provide similar but incompatible fallbacks for.
Signed-off-by: Martin Storsjö <martin@martin.st>
The fds are unsigned integers in the windows definition of struct
sockfds. Due to this, the comparison if (fds[i].fd > n) was always
false.
Signed-off-by: Martin Storsjö <martin@martin.st>
io.h is required for open and _wopen, and fcntl.h is required for
the O_CREAT flag. On mingw, fcntl.h is included by os_support.h (and
the mingw fcntl.h includes io.h), but include it explicitly here
since this implementation requires it.
Also move the #undef open up. open must not be defined to ff_win32_open
while including the headers that declare the open function. On mingw,
this happened in os_support.h before open was redirected.
Signed-off-by: Martin Storsjö <martin@martin.st>
Apparently this include is needed on some systems for building the
poll fallback (for the timeval struct for select?), but it isn't
available on all systems. Thus only include it if it exists.
Signed-off-by: Martin Storsjö <martin@martin.st>
In order to match Linux behaviour better our
Windows-specific open() replacement should disable
Windows default file locking.
Signed-off-by: Reimar Döffinger <Reimar.Doeffinger@gmx.de>
Adding _POSIX_C_SOURCE to CPPFLAGS globally produces all sorts of problems
since it causes certain system functions to be hidden on some (BSD) systems.
The solution is to only add the flag on systems that really require it, i.e.
glibc-based ones.
This change makes BSD systems compile out-of-the-box without the need for
adding specific flags manually. It also allows dropping a number of flags
set manually on a file-per-file basis, but were only present to work around
breakage introduced by the presence of _POSIX_C_SOURCE.
Also add _XOPEN_SOURCE to CPPFLAGS for glibc systems. We use XSI extensions
in several places already, so it is preferable to define it globally instead
of littering source files with individual #defines only needed for glibc.
All file names should be in UTF-8 within libavformat.
This is handled by mapping the open() function to an internal one
in os_support.h for windows.
fopen() could be overridden in the same way, but if that would be
used from ffmpeg.c, it would add a dependency on an ff prefixed
internal lavf function.
Signed-off-by: Martin Storsjö <martin@martin.st>
Our poll implementation does not iterate over the pollfd array properly
while setting the revents.
Signed-off-by: Luca Barbato <lu_zero@gentoo.org>
(cherry picked from commit 9ac2085dbf)
poll() is only used by networking code, so the fallback should
only be built if networking is enabled. Also remove CONFIG_FFSERVER
condition from the declarations.
This should fix building on systems without poll(), broken
by a8475bbdb6.
Signed-off-by: Mans Rullgard <mans@mansr.com>
(cherry picked from commit 362d8f7d9e)
poll() is only used by networking code, so the fallback should
only be built if networking is enabled. Also remove CONFIG_FFSERVER
condition from the declarations.
This should fix building on systems without poll(), broken
by a8475bbdb6.
Signed-off-by: Mans Rullgard <mans@mansr.com>
This deprecated function is only used by ffserver, yet does not have
a prototype visible there.
In the long term, ffserver should be made IPv6-aware. In the meantime,
this change removes cruft from lavf and fixes some warnings in ffserver.
Originally committed as revision 22329 to svn://svn.ffmpeg.org/ffmpeg/trunk
only works correctly on little-endian. The attached patch makes it endian
independent.
Patch by Martin Storsjö <$firstname()$firstname,st>.
Originally committed as revision 21080 to svn://svn.ffmpeg.org/ffmpeg/trunk