1 /* TN5250 - An implementation of the 5250 telnet protocol.
2  * Copyright (C) 1997-2008 Michael Madore
3  *
4  * This file is part of TN5250.
5  *
6  * TN5250 is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser General Public License as published by
8  * the Free Software Foundation; either version 2.1, or (at your option)
9  * any later version.
10  *
11  * TN5250 is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
14  * GNU Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with this software; see the file COPYING.  If not, write to
18  * the Free Software Foundation, Inc., 59 Temple Place, Suite 330,
19  * Boston, MA 02111-1307 USA
20  *
21  */
22 #ifndef PRIVATE_H
23 #define PRIVATE_H
24 
25 /*#include "tn5250-autoconfig.h"*/
26 #include "config.h"
27 
28 #if defined(WIN32) || defined(WINE)
29 #include <windows.h>
30 #include <winsock.h>
31 #endif
32 
33 #include <stdarg.h>
34 #include <stdlib.h>
35 #include <stdio.h>
36 #include <string.h>
37 #include <ctype.h>
38 #include <errno.h>
39 #include <signal.h>
40 
41 #ifdef HAVE_UNISTD_H
42 #include <unistd.h>
43 #endif
44 
45 #ifdef HAVE_LOCALE_H
46 #include <locale.h>
47 #endif
48 
49 #ifdef HAVE_SYS_TIME_H
50 #include <sys/time.h>
51 #endif
52 
53 #ifdef HAVE_SYS_TYPES_H
54 #include <sys/types.h>
55 #endif
56 
57 #ifdef HAVE_SYS_WAIT_H
58 #include <sys/wait.h>
59 #endif
60 
61 #ifdef HAVE_FCNTL_H
62 #include <fcntl.h>
63 #endif
64 
65 #ifdef HAVE_SYSLOG_H
66 #include <syslog.h>
67 #endif
68 
69 #ifdef HAVE_PWD_H
70 #include <pwd.h>
71 #endif
72 
73 #include "buffer.h"
74 #include "record.h"
75 #include "stream.h"
76 #include "utility.h"
77 #include "dbuffer.h"
78 #include "field.h"
79 #include "codes5250.h"
80 #include "scrollbar.h"
81 #include "session.h"
82 #include "printsession.h"
83 #include "display.h"
84 #include "macro.h"
85 #include "menu.h"
86 #include "wtd.h"
87 #include "window.h"
88 #include "terminal.h"
89 #include "debug.h"
90 #include "scs.h"
91 #include "conf.h"
92 
93 extern char *version_string;
94 
95 #if !defined(WINE) && !defined(WIN32)
96 #include <sys/time.h>
97 #include <sys/ioctl.h>
98 #include <sys/socket.h>
99 #include <netinet/in.h>
100 #include <arpa/inet.h>
101 #include <errno.h>
102 #include <netdb.h>
103 #include <unistd.h>
104 #endif
105 
106 #ifdef HAVE_SYS_FILIO_H
107 #include <sys/filio.h>
108 #endif
109 
110 /** Start of REALLY ugly network portability layer. **/
111 #if defined(WINE)
112 #define TN_SOCKET		WINSOCK_socket
113 #define TN_CONNECT		WINSOCK_connect
114 #define TN_SELECT		WINSOCK_select
115 #define TN_GETHOSTBYNAME	WINSOCK_gethostbyname
116 #define TN_GETSERVBYNAME	WINSOCK_getservbyname
117 #define TN_SEND			WINSOCK_send
118 #define TN_RECV			WINSOCK_recv
119 #define TN_CLOSE		WINSOCK_closesocket
120 #define TN_IOCTL		WINSOCK_ioctlsocket
121 
122 /* Prototypes needed by WINE's winsock implementation so that the
123  * names don't clash with system functions. */
124 struct hostent *WINAPI WINSOCK_gethostbyname(const char *name);
125 INT WINAPI WINSOCK_socket(INT af, INT type, INT protocol);
126 INT WINAPI WINSOCK_connect(SOCKET s, struct sockaddr *name, INT namelen);
127 INT WINAPI WINSOCK_recv(SOCKET s, char *buf, INT len, INT flags);
128 INT WINAPI WINSOCK_send(SOCKET s, char *buf, INT len, INT flags);
129 void WINAPI WINSOCK_closesocket(SOCKET s);
130 INT WINAPI WINSOCK_select(INT nfds, ws_fd_set32 * ws_readfds,
131 		   ws_fd_set32 * ws_writefds, ws_fd_set32 * ws_exceptfds,
132 			  struct timeval *timeout);
133 
134 #define fd_set ws_fd_set32
135 #undef FD_ZERO
136 #undef FD_SET
137 #undef FD_ISSET
138 #define FD_ZERO(x) WS_FD_ZERO((x))
139 #define FD_SET(x,y) WS_FD_SET((x),(y))
140 #define FD_ISSET(x,y) WS_FD_ISSET((x),(y))
141 /* end WINE */
142 
143 #elif defined(WIN32)
144 #define TN_SOCKET		socket
145 #define TN_CONNECT		connect
146 #define TN_SELECT		select
147 #define TN_GETHOSTBYNAME	gethostbyname
148 #define TN_GETSERVBYNAME	getservbyname
149 #define TN_SEND			send
150 #define TN_RECV		        recv
151 #define TN_CLOSE		closesocket
152 #define TN_IOCTL		ioctlsocket
153 /* end WIN32 */
154 
155 #else
156 #define TN_SOCKET		socket
157 #define TN_CONNECT		connect
158 #define TN_SELECT		select
159 #define TN_GETHOSTBYNAME	gethostbyname
160 #define TN_GETSERVBYNAME	getservbyname
161 #define TN_SEND			send
162 #define TN_RECV		        recv
163 #define TN_CLOSE		close
164 #define TN_IOCTL		ioctl
165 
166 #endif
167 
168 #if defined(WINE) || defined(WIN32)
169 /* Windows' braindead socketing */
170 #define LAST_ERROR		(WSAGetLastError ())
171 #define ERR_INTR		WSAEINTR
172 #define ERR_AGAIN 		WSAEWOULDBLOCK
173 #define WAS_ERROR_RET(r)	((r) == SOCKET_ERROR)
174 #define WAS_INVAL_SOCK(r)	((r) == INVALID_SOCKET)
175 #else
176 /* Real, UNIX socketing */
177 #define LAST_ERROR		(errno)
178 #define ERR_INTR		EINTR
179 #define ERR_AGAIN		EAGAIN
180 #define WAS_ERROR_RET(r)	((r) < 0)
181 #define WAS_INVAL_SOCK(r)	((r) < 0)
182 #endif
183 
184 #ifndef INADDR_NONE
185 #define INADDR_NONE 0xffffffff
186 #endif
187 
188 /* END: of really ugly network portability layer. */
189 
190 #endif				/* PRIVATE_H */
191 
192 /* vi:set cindent sts=3 sw=3: */
193