rtmp_sys.h 2.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182
  1. #ifndef __RTMP_SYS_H__
  2. #define __RTMP_SYS_H__
  3. /*
  4. * Copyright (C) 2010 Howard Chu
  5. *
  6. * This file is part of librtmp.
  7. *
  8. * librtmp is free software; you can redistribute it and/or modify
  9. * it under the terms of the GNU Lesser General Public License as
  10. * published by the Free Software Foundation; either version 2.1,
  11. * or (at your option) any later version.
  12. *
  13. * librtmp is distributed in the hope that it will be useful,
  14. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  15. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  16. * GNU General Public License for more details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public License
  19. * along with librtmp see the file COPYING. If not, write to
  20. * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  21. * Boston, MA 02110-1301, USA.
  22. * http://www.gnu.org/copyleft/lgpl.html
  23. */
  24. #include <stdio.h>
  25. #include <stdlib.h>
  26. #include <string.h>
  27. #include <assert.h>
  28. #include <ctype.h>
  29. #include <stddef.h>
  30. #include <errno.h>
  31. #include <stdarg.h>
  32. #include <limits.h>
  33. #include <time.h>
  34. #include <stdint.h>
  35. #ifdef _WIN32
  36. #include <winsock2.h>
  37. #include <ws2tcpip.h>
  38. #include <Mstcpip.h>
  39. #ifdef _MSC_VER /* MSVC */
  40. #define snprintf _snprintf
  41. #define strcasecmp stricmp
  42. #define strncasecmp strnicmp
  43. #define vsnprintf _vsnprintf
  44. #endif
  45. #define GetSockError() WSAGetLastError()
  46. #define SetSockError(e) WSASetLastError(e)
  47. #define setsockopt(a,b,c,d,e) (setsockopt)(a,b,c,(const char *)d,(int)e)
  48. #ifdef EWOULDBLOCK
  49. #undef EWOULDBLOCK
  50. #endif
  51. #define EWOULDBLOCK WSAETIMEDOUT /* we don't use nonblocking, but we do use timeouts */
  52. #define sleep(n) Sleep(n*1000)
  53. #define msleep(n) Sleep(n)
  54. #define SET_RCVTIMEO(tv,s) int tv = s*1000
  55. #else /* !_WIN32 */
  56. #include <sys/types.h>
  57. #include <sys/socket.h>
  58. #include <sys/times.h>
  59. #include <netdb.h>
  60. #include <unistd.h>
  61. #include <netinet/in.h>
  62. #include <netinet/tcp.h>
  63. #include <arpa/inet.h>
  64. #define GetSockError() errno
  65. #define SetSockError(e) errno = e
  66. #undef closesocket
  67. #define closesocket(s) close(s)
  68. #define msleep(n) usleep(n*1000)
  69. #define SET_RCVTIMEO(tv,s) struct timeval tv = {s,0}
  70. #ifndef INVALID_SOCKET
  71. #define INVALID_SOCKET -1
  72. #endif
  73. #endif
  74. #include "rtmp.h"
  75. #endif