2
* Modifications Copyright 1993, 1994, 1995, 1996, 1999, 2000, 2001, 2002,
3
* 2003, 2004, 2005, 2006 by Paul Mattes.
4
* RPQNAMES modifications copyright 2005 by Don Russell.
5
* Copyright 1990 by Jeff Sparkes.
6
* Permission to use, copy, modify, and distribute this software and its
7
* documentation for any purpose and without fee is hereby granted,
8
* provided that the above copyright notice appear in all copies and that
9
* both that copyright notice and this permission notice appear in
10
* supporting documentation.
12
* x3270, c3270, s3270 and tcl3270 are distributed in the hope that they will
13
* be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
14
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the file LICENSE
2
* Copyright (c) 1993-2009, Paul Mattes.
3
* Copyright (c) 2005, Don Russell.
4
* Copyright (c) 1990, Jeff Sparkes.
7
* Redistribution and use in source and binary forms, with or without
8
* modification, are permitted provided that the following conditions are met:
9
* * Redistributions of source code must retain the above copyright
10
* notice, this list of conditions and the following disclaimer.
11
* * Redistributions in binary form must reproduce the above copyright
12
* notice, this list of conditions and the following disclaimer in the
13
* documentation and/or other materials provided with the distribution.
14
* * Neither the names of Paul Mattes, Don Russell, Jeff Sparkes nor the
15
* names of their contributors may be used to endorse or promote
16
* products derived from this software without specific prior written
19
* THIS SOFTWARE IS PROVIDED BY PAUL MATTES, DON RUSSELL AND JEFF SPARKES
20
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
21
* TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
22
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL PAUL MATTES, DON RUSSELL OR JEFF
23
* SPARKES BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY,
24
* OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
25
* SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
26
* INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
27
* CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
28
* ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
29
* POSSIBILITY OF SUCH DAMAGE.
50
64
* Compiler-specific #defines.
53
/* 'unused' explicitly flags an unused parameter */
67
/* '_is_unused' explicitly flags an unused parameter */
54
68
#if defined(__GNUC__) /*[*/
55
#define unused __attribute__((__unused__))
69
#define _is_unused __attribute__((__unused__))
56
70
#define printflike(s,f) __attribute__ ((__format__ (__printf__, s, f)))
58
#define unused /* nothing */
72
#define _is_unused /* nothing */
59
73
#define printflike(s, f) /* nothing */
65
77
* Prerequisite #includes.
67
79
#include <stdio.h> /* Unix standard I/O library */
68
80
#include <stdlib.h> /* Other Unix library functions */
81
#if !defined(_MSC_VER) /*[*/
69
82
#include <unistd.h> /* Unix system calls */
70
84
#include <ctype.h> /* Character classes */
71
85
#include <string.h> /* String manipulations */
72
86
#include <sys/types.h> /* Basic system data types */
87
#if !defined(_MSC_VER) /*[*/
73
88
#include <sys/time.h> /* System time-related data types */
74
90
#include <time.h> /* C library time functions */
75
91
#include "localdefs.h" /* {s,tcl,c}3270-specific defines */
96
#if defined(_MSC_VER) /*[*/
97
#include <winsock2.h> /* for struct timeval */
98
extern int gettimeofday(struct timeval *, void *);
100
#define strcasecmp _stricmp
101
#define strncasecmp _strnicmp
105
* Locale-related definitions.
106
* Note that USE_ICONV can be used to override __STDC_ISO_10646__, so that
107
* development of iconv-based logic can be done on 10646-compliant systems.
109
#if defined(__STDC_ISO_10646__) && !defined(USE_ICONV) /*[*/
110
#define UNICODE_WCHAR 1
112
#if !defined(_WIN32) && !defined(UNICODE_WCHAR) /*[*/
119
* Unicode UCS-4 characters are (hopefully) 32 bits.
120
* EBCDIC (including DBCS) is (hopefully) 16 bits.
122
typedef unsigned int ucs4_t;
123
typedef unsigned short ebc_t;
78
126
* Cancel out contradictory parts.
80
128
#if !defined(X3270_DISPLAY) /*[*/
81
129
#undef X3270_KEYPAD
82
130
#undef X3270_MENUS
132
#if defined(C3270) && defined(X3270_DBCS) && !defined(CURSES_WIDE) /*[*/
85
136
/* Local process (-e) header files. */
86
#if defined(X3270_LOCAL_PROCESS) && defined(HAVE_LIBUTIL) /*[*/
137
#if defined(X3270_LOCAL_PROCESS) && defined(HAVE_FORKPTY) /*[*/
87
138
#define LOCAL_PROCESS 1
88
139
#include <termios.h>
89
140
#if defined(HAVE_PTY_H) /*[*/
108
159
/* Simple global variables */
161
extern int COLS; /* current */
163
extern int maxCOLS; /* maximum */
165
extern int defROWS; /* default (EraseWrite) */
167
extern int altROWS; /* alternate (EraseWriteAlternate) */
112
169
#if defined(X3270_DISPLAY) /*[*/
113
170
extern Atom a_3270, a_registry, a_encoding;
114
171
extern XtAppContext appcontext;