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 25 #include <stdio.h> 26 #include <stdlib.h> 27 #include <string.h> 28 #include <assert.h> 29 #include <ctype.h> 30 #include <stddef.h> 31 #include <errno.h> 32 #include <stdarg.h> 33 #include <limits.h> 34 #include <time.h> 35 #include <stdint.h> 36 37 #ifdef _WIN32 38 39 #include <winsock2.h> 40 #include <ws2tcpip.h> 41 #include <Mstcpip.h> 42 43 44 #ifdef _MSC_VER /* MSVC */ 45 #define snprintf _snprintf 46 #define strcasecmp stricmp 47 #define strncasecmp strnicmp 48 #define vsnprintf _vsnprintf 49 #endif 50 51 #define GetSockError() WSAGetLastError() 52 #define SetSockError(e) WSASetLastError(e) 53 #define setsockopt(a,b,c,d,e) (setsockopt)(a,b,c,(const char *)d,(int)e) 54 #ifdef EWOULDBLOCK 55 #undef EWOULDBLOCK 56 #endif 57 #define EWOULDBLOCK WSAETIMEDOUT /* we don't use nonblocking, but we do use timeouts */ 58 #define sleep(n) Sleep(n*1000) 59 #define msleep(n) Sleep(n) 60 #define SET_RCVTIMEO(tv,s) int tv = s*1000 61 #else /* !_WIN32 */ 62 #include <sys/types.h> 63 #include <sys/socket.h> 64 #include <sys/times.h> 65 #include <netdb.h> 66 #include <unistd.h> 67 #include <netinet/in.h> 68 #include <netinet/tcp.h> 69 #include <arpa/inet.h> 70 #define GetSockError() errno 71 #define SetSockError(e) errno = e 72 #undef closesocket 73 #define closesocket(s) close(s) 74 #define msleep(n) usleep(n*1000) 75 #define SET_RCVTIMEO(tv,s) struct timeval tv = {s,0} 76 #ifndef INVALID_SOCKET 77 #define INVALID_SOCKET -1 78 #endif 79 #endif 80 81 #include "rtmp.h" 82 #endif 83