os_support.h 2.5 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. /*
  2. * various utilities for ffmpeg system
  3. * copyright (c) 2000, 2001, 2002 Fabrice Bellard
  4. *
  5. * This file is part of FFmpeg.
  6. *
  7. * FFmpeg is free software; you can redistribute it and/or
  8. * modify it under the terms of the GNU Lesser General Public
  9. * License as published by the Free Software Foundation; either
  10. * version 2.1 of the License, or (at your option) any later version.
  11. *
  12. * FFmpeg is distributed in the hope that it will be useful,
  13. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * Lesser General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU Lesser General Public
  18. * License along with FFmpeg; if not, write to the Free Software
  19. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  20. */
  21. #ifndef AVFORMAT_OS_SUPPORT_H
  22. #define AVFORMAT_OS_SUPPORT_H
  23. /**
  24. * @file
  25. * miscellaneous OS support macros and functions.
  26. */
  27. #include "config.h"
  28. #if defined(__MINGW32__) && !defined(__MINGW32CE__)
  29. # include <fcntl.h>
  30. # define lseek(f,p,w) _lseeki64((f), (p), (w))
  31. # define stat _stati64
  32. # define fstat(f,s) _fstati64((f), (s))
  33. #endif /* defined(__MINGW32__) && !defined(__MINGW32CE__) */
  34. static inline int is_dos_path(const char *path)
  35. {
  36. #if HAVE_DOS_PATHS
  37. if (path[0] && path[1] == ':')
  38. return 1;
  39. #endif
  40. return 0;
  41. }
  42. #if defined(_WIN32) && !defined(__MINGW32CE__)
  43. int ff_win32_open(const char *filename, int oflag, int pmode);
  44. #define open ff_win32_open
  45. #endif
  46. #if CONFIG_NETWORK
  47. #if !HAVE_SOCKLEN_T
  48. typedef int socklen_t;
  49. #endif
  50. /* most of the time closing a socket is just closing an fd */
  51. #if !HAVE_CLOSESOCKET
  52. #define closesocket close
  53. #endif
  54. #if !HAVE_POLL_H
  55. typedef unsigned long nfds_t;
  56. struct pollfd {
  57. int fd;
  58. short events; /* events to look for */
  59. short revents; /* events that occurred */
  60. };
  61. /* events & revents */
  62. #define POLLIN 0x0001 /* any readable data available */
  63. #define POLLOUT 0x0002 /* file descriptor is writeable */
  64. #define POLLRDNORM POLLIN
  65. #define POLLWRNORM POLLOUT
  66. #define POLLRDBAND 0x0008 /* priority readable data */
  67. #define POLLWRBAND 0x0010 /* priority data can be written */
  68. #define POLLPRI 0x0020 /* high priority readable data */
  69. /* revents only */
  70. #define POLLERR 0x0004 /* errors pending */
  71. #define POLLHUP 0x0080 /* disconnected */
  72. #define POLLNVAL 0x1000 /* invalid file descriptor */
  73. int poll(struct pollfd *fds, nfds_t numfds, int timeout);
  74. #endif /* HAVE_POLL_H */
  75. #endif /* CONFIG_NETWORK */
  76. #endif /* AVFORMAT_OS_SUPPORT_H */