~ubuntu-branches/ubuntu/natty/ibm-3270/natty

« back to all changes in this revision

Viewing changes to ws3270/globals.h

  • Committer: Bazaar Package Importer
  • Author(s): Bastian Blank
  • Date: 2009-12-14 11:48:53 UTC
  • mfrom: (1.1.4 upstream) (2.1.2 sid)
  • Revision ID: james.westby@ubuntu.com-20091214114853-mywixml32hct9jr1
Tags: 3.3.10ga4-2
* Fix section to match override.
* Use debhelper compat level 7.
* Use 3.0 (quilt) source format.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright (c) 1993-2009, Paul Mattes.
 
3
 * Copyright (c) 2005, Don Russell.
 
4
 * Copyright (c) 1990, Jeff Sparkes.
 
5
 * All rights reserved.
 
6
 *
 
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
 
17
 *       permission.
 
18
 *
 
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.
 
30
 */
 
31
 
 
32
/*
 
33
 *      globals.h
 
34
 *              Common definitions for x3270, c3270, s3270 and tcl3270.
 
35
 */
 
36
 
 
37
/* Autoconf settings. */
 
38
#include "conf.h"                       /* autoconf settings */
 
39
#if defined(X3270_TN3270E) && !defined(X3270_ANSI) /*[*/
 
40
#define X3270_ANSI      1       /* RFC2355 requires NVT mode */
 
41
#endif /*]*/
 
42
#if defined(HAVE_VASPRINTF) && !defined(_GNU_SOURCE) /*[*/
 
43
#define _GNU_SOURCE             /* vasprintf isn't POSIX */
 
44
#endif /*]*/
 
45
 
 
46
/*
 
47
 * OS-specific #defines.  Except for the blocking-connect workarounds, these
 
48
 * should be replaced with autoconf probes as soon as possible.
 
49
 */
 
50
 
 
51
/*
 
52
 * BLOCKING_CONNECT_ONLY
 
53
 *   Use only blocking sockets.
 
54
 */
 
55
#if defined(sco) /*[*/
 
56
#define BLOCKING_CONNECT_ONLY   1
 
57
#endif /*]*/
 
58
 
 
59
#if defined(apollo) /*[*/
 
60
#define BLOCKING_CONNECT_ONLY   1
 
61
#endif /*]*/
 
62
 
 
63
/*
 
64
 * Compiler-specific #defines.
 
65
 */
 
66
 
 
67
/* '_is_unused' explicitly flags an unused parameter */
 
68
#if defined(__GNUC__) /*[*/
 
69
#define _is_unused __attribute__((__unused__))
 
70
#define printflike(s,f) __attribute__ ((__format__ (__printf__, s, f)))
 
71
#else /*][*/
 
72
#define _is_unused /* nothing */
 
73
#define printflike(s, f) /* nothing */
 
74
#endif /*]*/
 
75
 
 
76
/*
 
77
 * Prerequisite #includes.
 
78
 */
 
79
#include <stdio.h>                      /* Unix standard I/O library */
 
80
#include <stdlib.h>                     /* Other Unix library functions */
 
81
#if !defined(_MSC_VER) /*[*/
 
82
#include <unistd.h>                     /* Unix system calls */
 
83
#endif /*]*/
 
84
#include <ctype.h>                      /* Character classes */
 
85
#include <string.h>                     /* String manipulations */
 
86
#include <sys/types.h>                  /* Basic system data types */
 
87
#if !defined(_MSC_VER) /*[*/
 
88
#include <sys/time.h>                   /* System time-related data types */
 
89
#endif /*]*/
 
90
#include <time.h>                       /* C library time functions */
 
91
#include "localdefs.h"                  /* {s,tcl,c}3270-specific defines */
 
92
 
 
93
/*
 
94
 * MSC glue.
 
95
 */
 
96
#if defined(_MSC_VER) /*[*/
 
97
#include <winsock2.h>                   /* for struct timeval */
 
98
extern int gettimeofday(struct timeval *, void *);
 
99
#define R_OK    4
 
100
#define strcasecmp      _stricmp
 
101
#define strncasecmp     _strnicmp
 
102
#endif /*]*/
 
103
 
 
104
/*
 
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.
 
108
 */
 
109
#if defined(__STDC_ISO_10646__) && !defined(USE_ICONV) /*[*/
 
110
#define UNICODE_WCHAR   1
 
111
#endif /*]*/
 
112
#if !defined(_WIN32) && !defined(UNICODE_WCHAR) /*[*/
 
113
#undef USE_ICONV
 
114
#define USE_ICONV 1
 
115
#include <iconv.h>
 
116
#endif /*]*/
 
117
 
 
118
/*
 
119
 * Unicode UCS-4 characters are (hopefully) 32 bits.
 
120
 * EBCDIC (including DBCS) is (hopefully) 16 bits.
 
121
 */
 
122
typedef unsigned int ucs4_t;
 
123
typedef unsigned short ebc_t;
 
124
 
 
125
/*
 
126
 * Cancel out contradictory parts.
 
127
 */
 
128
#if !defined(X3270_DISPLAY) /*[*/
 
129
#undef X3270_KEYPAD
 
130
#undef X3270_MENUS
 
131
#endif /*]*/
 
132
#if defined(C3270) && defined(X3270_DBCS) && !defined(CURSES_WIDE) /*[*/
 
133
#undef X3270_DBCS
 
134
#endif /*]*/
 
135
 
 
136
/* Local process (-e) header files. */
 
137
#if defined(X3270_LOCAL_PROCESS) && defined(HAVE_FORKPTY) /*[*/
 
138
#define LOCAL_PROCESS   1
 
139
#include <termios.h>
 
140
#if defined(HAVE_PTY_H) /*[*/
 
141
#include <pty.h>
 
142
#endif /*]*/
 
143
#if defined(HAVE_LIBUTIL_H) /*[*/
 
144
#include <libutil.h>
 
145
#endif /*]*/
 
146
#if defined(HAVE_UTIL_H) /*[*/
 
147
#include <util.h>
 
148
#endif /*]*/
 
149
#endif /*]*/
 
150
 
 
151
/* Functions we may need to supply. */
 
152
#if defined(NEED_STRTOK_R) /*[*/
 
153
extern char *strtok_r(char *str, const char *sep, char **last);
 
154
#endif /*]*/
 
155
 
 
156
/* Stop conflicting with curses' COLS, even if we don't link with it. */
 
157
#define COLS cCOLS
 
158
 
 
159
/* Simple global variables */
 
160
 
 
161
extern int              COLS;           /* current */
 
162
extern int              ROWS;
 
163
extern int              maxCOLS;        /* maximum */
 
164
extern int              maxROWS;
 
165
extern int              defROWS;        /* default (EraseWrite) */
 
166
extern int              defCOLS;
 
167
extern int              altROWS;        /* alternate (EraseWriteAlternate) */
 
168
extern int              altCOLS;
 
169
#if defined(X3270_DISPLAY) /*[*/
 
170
extern Atom             a_3270, a_registry, a_encoding;
 
171
extern XtAppContext     appcontext;
 
172
#endif /*]*/
 
173
extern const char       *build;
 
174
extern const char       *build_rpq_timestamp;
 
175
extern const char       *build_rpq_version;
 
176
extern int              children;
 
177
extern char             *connected_lu;
 
178
extern char             *connected_type;
 
179
extern char             *current_host;
 
180
extern unsigned short   current_port;
 
181
#if defined(X3270_DBCS) /*[*/
 
182
extern Boolean          dbcs;
 
183
#endif /*]*/
 
184
#if defined(X3270_FT) /*[*/
 
185
extern int              dft_buffersize;
 
186
#endif /*]*/
 
187
extern char             *efontname;
 
188
extern Boolean          ever_3270;
 
189
extern Boolean          exiting;
 
190
#if defined(X3270_DISPLAY) /*[*/
 
191
extern Boolean          *extended_3270font;
 
192
extern Font             *fid;
 
193
extern Boolean          *font_8bit;
 
194
#endif /*]*/
 
195
extern Boolean          flipped;
 
196
extern char             *full_current_host;
 
197
extern char             *full_efontname;
 
198
#if defined(X3270_DBCS) /*[*/
 
199
extern char             *full_efontname_dbcs;
 
200
#endif /*]*/
 
201
extern char             full_model_name[];
 
202
extern char             *funky_font;
 
203
extern char             *hostname;
 
204
#if defined(X3270_DBCS) /*[*/
 
205
#if defined(X3270_DISPLAY) /*[*/
 
206
extern char             *locale_name;
 
207
#endif /*]*/
 
208
#endif /*]*/
 
209
extern char             luname[];
 
210
#if defined(LOCAL_PROCESS) /*[*/
 
211
extern Boolean          local_process;
 
212
#endif /*]*/
 
213
extern char             *model_name;
 
214
extern int              model_num;
 
215
extern Boolean          no_login_host;
 
216
extern Boolean          non_tn3270e_host;
 
217
extern int              ov_cols, ov_rows;
 
218
extern Boolean          ov_auto;
 
219
extern Boolean          passthru_host;
 
220
extern const char       *programname;
 
221
extern char             *qualified_host;
 
222
extern char             *reconnect_host;
 
223
extern int              screen_depth;
 
224
extern Boolean          scroll_initted;
 
225
#if defined(HAVE_LIBSSL) /*[*/
 
226
extern Boolean          secure_connection;
 
227
#endif /*]*/
 
228
extern Boolean          shifted;
 
229
extern Boolean          ssl_host;
 
230
extern Boolean          *standard_font;
 
231
extern Boolean          std_ds_host;
 
232
extern char             *termtype;
 
233
extern Widget           toplevel;
 
234
extern Boolean          visible_control;
 
235
extern int              *xtra_width;
 
236
 
 
237
#if defined(X3270_DISPLAY) /*[*/
 
238
extern Atom             a_delete_me;
 
239
extern Atom             a_save_yourself;
 
240
extern Atom             a_state;
 
241
extern Display          *display;
 
242
extern Pixmap           gray;
 
243
extern Pixel            keypadbg_pixel;
 
244
extern XrmDatabase      rdb;
 
245
extern Window           root_window;
 
246
extern char             *user_title;
 
247
#endif /*]*/
 
248
 
 
249
#if defined(_WIN32) && (defined(C3270) || defined(S3270)) /*[*/
 
250
extern char             *instdir;
 
251
extern char             *myappdata;
 
252
#endif /*]*/
 
253
 
 
254
#if defined(_WIN32) && defined(C3270) /*[*/
 
255
extern int              is_installed;
 
256
#endif /*]*/
 
257
 
 
258
/* Data types and complex global variables */
 
259
 
 
260
/*   connection state */
 
261
enum cstate {
 
262
        NOT_CONNECTED,          /* no socket, unknown mode */
 
263
        RESOLVING,              /* resolving hostname */
 
264
        PENDING,                /* connection pending */
 
265
        CONNECTED_INITIAL,      /* connected, no mode yet */
 
266
        CONNECTED_ANSI,         /* connected in NVT ANSI mode */
 
267
        CONNECTED_3270,         /* connected in old-style 3270 mode */
 
268
        CONNECTED_INITIAL_E,    /* connected in TN3270E mode, unnegotiated */
 
269
        CONNECTED_NVT,          /* connected in TN3270E mode, NVT mode */
 
270
        CONNECTED_SSCP,         /* connected in TN3270E mode, SSCP-LU mode */
 
271
        CONNECTED_TN3270E       /* connected in TN3270E mode, 3270 mode */
 
272
};
 
273
extern enum cstate cstate;
 
274
 
 
275
#define PCONNECTED      ((int)cstate >= (int)RESOLVING)
 
276
#define HALF_CONNECTED  (cstate == RESOLVING || cstate == PENDING)
 
277
#define CONNECTED       ((int)cstate >= (int)CONNECTED_INITIAL)
 
278
#define IN_NEITHER      (cstate == CONNECTED_INITIAL)
 
279
#define IN_ANSI         (cstate == CONNECTED_ANSI || cstate == CONNECTED_NVT)
 
280
#define IN_3270         (cstate == CONNECTED_3270 || cstate == CONNECTED_TN3270E || cstate == CONNECTED_SSCP)
 
281
#define IN_SSCP         (cstate == CONNECTED_SSCP)
 
282
#define IN_TN3270E      (cstate == CONNECTED_TN3270E)
 
283
#define IN_E            (cstate >= CONNECTED_INITIAL_E)
 
284
 
 
285
/*   keyboard modifer bitmap */
 
286
#define ShiftKeyDown    0x01
 
287
#define MetaKeyDown     0x02
 
288
#define AltKeyDown      0x04
 
289
 
 
290
/*   toggle names */
 
291
struct toggle_name {
 
292
        const char *name;
 
293
        int index;
 
294
};
 
295
extern struct toggle_name toggle_names[];
 
296
 
 
297
/*   extended attributes */
 
298
struct ea {
 
299
        unsigned char cc;       /* EBCDIC or ASCII character code */
 
300
        unsigned char fa;       /* field attribute, it nonzero */
 
301
        unsigned char fg;       /* foreground color (0x00 or 0xf<n>) */
 
302
        unsigned char bg;       /* background color (0x00 or 0xf<n>) */
 
303
        unsigned char gr;       /* ANSI graphics rendition bits */
 
304
        unsigned char cs;       /* character set (GE flag, or 0..2) */
 
305
        unsigned char ic;       /* input control (DBCS) */
 
306
        unsigned char db;       /* DBCS state */
 
307
};
 
308
#define GR_BLINK        0x01
 
309
#define GR_REVERSE      0x02
 
310
#define GR_UNDERLINE    0x04
 
311
#define GR_INTENSIFY    0x08
 
312
 
 
313
#define CS_MASK         0x03    /* mask for specific character sets */
 
314
#define CS_BASE         0x00    /*  base character set (X'00') */
 
315
#define CS_APL          0x01    /*  APL character set (X'01' or GE) */
 
316
#define CS_LINEDRAW     0x02    /*  DEC line-drawing character set (ANSI) */
 
317
#define CS_DBCS         0x03    /*  DBCS character set (X'F8') */
 
318
#define CS_GE           0x04    /* cs flag for Graphic Escape */
 
319
 
 
320
/*   translation lists */
 
321
struct trans_list {
 
322
        char                    *name;
 
323
        char                    *pathname;
 
324
        Boolean                 is_temp;
 
325
        Boolean                 from_server;
 
326
        struct trans_list       *next;
 
327
};
 
328
extern struct trans_list *trans_list;
 
329
 
 
330
/*   input key type */
 
331
enum keytype { KT_STD, KT_GE };
 
332
 
 
333
/*   state changes */
 
334
#define ST_RESOLVING    1
 
335
#define ST_HALF_CONNECT 2
 
336
#define ST_CONNECT      3
 
337
#define ST_3270_MODE    4
 
338
#define ST_LINE_MODE    5
 
339
#define ST_REMODEL      6
 
340
#define ST_PRINTER      7
 
341
#define ST_EXITING      8
 
342
#define ST_CHARSET      9
 
343
#define N_ST            10
 
344
 
 
345
/* Naming convention for private actions. */
 
346
#define PA_PFX  "PA-"
 
347
 
 
348
/* Shorthand macros */
 
349
 
 
350
#define CN      ((char *) NULL)
 
351
#define PN      ((XtPointer) NULL)
 
352
#define Replace(var, value) { Free(var); var = (value); }
 
353
 
 
354
/* Configuration change masks. */
 
355
#define NO_CHANGE       0x0000  /* no change */
 
356
#define MODEL_CHANGE    0x0001  /* screen dimensions changed */
 
357
#define FONT_CHANGE     0x0002  /* emulator font changed */
 
358
#define COLOR_CHANGE    0x0004  /* color scheme or 3278/9 mode changed */
 
359
#define SCROLL_CHANGE   0x0008  /* scrollbar snapped on or off */
 
360
#define CHARSET_CHANGE  0x0010  /* character set changed */
 
361
#define ALL_CHANGE      0xffff  /* everything changed */
 
362
 
 
363
/* Portability macros */
 
364
 
 
365
/*   Equivalent of setlinebuf */
 
366
 
 
367
#if defined(_IOLBF) /*[*/
 
368
#define SETLINEBUF(s)   setvbuf(s, (char *)NULL, _IOLBF, BUFSIZ)
 
369
#else /*][*/
 
370
#define SETLINEBUF(s)   setlinebuf(s)
 
371
#endif /*]*/
 
372
 
 
373
/*   Motorola version of gettimeofday */
 
374
 
 
375
#if defined(MOTOROLA)
 
376
#define gettimeofday(tp,tz)     gettimeofday(tp)
 
377
#endif
 
378
 
 
379
/* Default DFT file transfer buffer size. */
 
380
#if defined(X3270_FT) && !defined(DFT_BUF) /*[*/
 
381
#define DFT_BUF         (4 * 1024)
 
382
#endif /*]*/
 
383
 
 
384
/* DBCS Preedit Types */
 
385
#if defined(X3270_DBCS) /*[*/
 
386
#define PT_ROOT                 "Root"
 
387
#define PT_OVER_THE_SPOT        "OverTheSpot"
 
388
#define PT_OFF_THE_SPOT         "OffTheSpot"
 
389
#define PT_ON_THE_SPOT          "OnTheSpot"
 
390
#endif /*]*/
 
391