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

« back to all changes in this revision

Viewing changes to wc3270/ft.c

  • 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
1
/*
2
 
 * Modifications Copyright 1996, 1999, 2000, 2001, 2002, 2003, 2004, 2005 by
3
 
 *  Paul Mattes.
4
 
 * Copyright October 1995 by Dick Altenbern.
5
 
 * Based in part on code Copyright 1993, 1994, 1995 by Paul Mattes.
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.
11
 
 *
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
15
 
 * for more details.
 
2
 * Copyright (c) 1996-2009, Paul Mattes.
 
3
 * Copyright (c) 1995, Dick Altenbern.
 
4
 * All rights reserved.
 
5
 *
 
6
 * Redistribution and use in source and binary forms, with or without
 
7
 * modification, are permitted provided that the following conditions are met:
 
8
 *     * Redistributions of source code must retain the above copyright
 
9
 *       notice, this list of conditions and the following disclaimer.
 
10
 *     * Redistributions in binary form must reproduce the above copyright
 
11
 *       notice, this list of conditions and the following disclaimer in the
 
12
 *       documentation and/or other materials provided with the distribution.
 
13
 *     * Neither the names of Paul Mattes, Dick Altenbern nor the names of
 
14
 *       their contributors may be used to endorse or promote products derived
 
15
 *       from this software without specific prior written permission.
 
16
 *
 
17
 * THIS SOFTWARE IS PROVIDED BY PAUL MATTES AND DICK ALTENBERN "AS IS" AND ANY
 
18
 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
 
19
 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
 
20
 * DISCLAIMED. IN NO EVENT SHALL PAUL MATTES OR DICK ALTENBERN BE LIABLE FOR
 
21
 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
 
22
 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
 
23
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
 
24
 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
 
25
 * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
 
26
 * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH
 
27
 * DAMAGE.
16
28
 */
17
29
 
18
30
/*
40
52
 
41
53
#include "appres.h"
42
54
#include "actionsc.h"
 
55
#include "charsetc.h"
43
56
#include "ft_cutc.h"
44
57
#include "ft_dftc.h"
45
58
#include "ftc.h"
56
69
#include "tablesc.h"
57
70
#include "telnetc.h"
58
71
#include "utilc.h"
 
72
#if defined(_MSC_VER) /*[*/
 
73
#include "Msc/deprecated.h"
 
74
#endif /*]*/
59
75
 
60
76
/* Macros. */
61
77
#define eos(s)  strchr((s), '\0')
116
132
#endif /*]*/
117
133
 
118
134
static enum recfm {
119
 
        DEFAULT_RECFM, FIXED, VARIABLE, UNDEFINED
 
135
        DEFAULT_RECFM, RECFM_FIXED, RECFM_VARIABLE, RECFM_UNDEFINED
120
136
} recfm = DEFAULT_RECFM;
121
137
#if defined(X3270_DISPLAY) && defined(X3270_MENUS) /*[*/
122
138
static Boolean recfm_default = True;
123
139
static enum recfm r_default_recfm = DEFAULT_RECFM;
124
 
static enum recfm r_fixed = FIXED;
125
 
static enum recfm r_variable = VARIABLE;
126
 
static enum recfm r_undefined = UNDEFINED;
 
140
static enum recfm r_fixed = RECFM_FIXED;
 
141
static enum recfm r_variable = RECFM_VARIABLE;
 
142
static enum recfm r_undefined = RECFM_UNDEFINED;
127
143
#endif /*]*/
128
144
 
129
145
static enum units {
148
164
static struct timeval t0;               /* Starting time */
149
165
static Boolean ft_is_cut;               /* File transfer is CUT-style */
150
166
 
 
167
/* Translation table: "ASCII" to EBCDIC, as seen by IND$FILE. */
 
168
unsigned char i_asc2ft[256] = {
 
169
0x00,0x01,0x02,0x03,0x37,0x2d,0x2e,0x2f,0x16,0x05,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
 
170
0x10,0x11,0x12,0x13,0x3c,0x3d,0x32,0x26,0x18,0x19,0x3f,0x27,0x1c,0x1d,0x1e,0x1f,
 
171
0x40,0x5a,0x7f,0x7b,0x5b,0x6c,0x50,0x7d,0x4d,0x5d,0x5c,0x4e,0x6b,0x60,0x4b,0x61,
 
172
0xf0,0xf1,0xf2,0xf3,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,0x7a,0x5e,0x4c,0x7e,0x6e,0x6f,
 
173
0x7c,0xc1,0xc2,0xc3,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,0xd1,0xd2,0xd3,0xd4,0xd5,0xd6,
 
174
0xd7,0xd8,0xd9,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,0xe8,0xe9,0x4a,0xe0,0x4f,0x5f,0x6d,
 
175
0x79,0x81,0x82,0x83,0x84,0x85,0x86,0x87,0x88,0x89,0x91,0x92,0x93,0x94,0x95,0x96,
 
176
0x97,0x98,0x99,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0xa9,0xc0,0x6a,0xd0,0xa1,0x07,
 
177
0x20,0x21,0x22,0x23,0x24,0x15,0x06,0x17,0x28,0x29,0x2a,0x2b,0x2c,0x09,0x0a,0x1b,
 
178
0x30,0x31,0x1a,0x33,0x34,0x35,0x36,0x08,0x38,0x39,0x3a,0x3b,0x04,0x14,0x3e,0xe1,
 
179
0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x51,0x52,0x53,0x54,0x55,0x56,0x57,
 
180
0x58,0x59,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0x70,0x71,0x72,0x73,0x74,0x75,
 
181
0x76,0x77,0x78,0x80,0x8a,0x8b,0x8c,0x8d,0x8e,0x8f,0x90,0x9a,0x9b,0x9c,0x9d,0x9e,
 
182
0x9f,0xa0,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,
 
183
0xb8,0xb9,0xba,0xbb,0xbc,0xbd,0xbe,0xbf,0xca,0xcb,0xcc,0xcd,0xce,0xcf,0xda,0xdb,
 
184
0xdc,0xdd,0xde,0xdf,0xea,0xeb,0xec,0xed,0xee,0xef,0xfa,0xfb,0xfc,0xfd,0xfe,0xff};
 
185
 
 
186
/* Translation table: EBCDIC to "ASCII", as seen by IND$FILE. */
 
187
unsigned char i_ft2asc[256] = {
 
188
0x00,0x01,0x02,0x03,0x9c,0x09,0x86,0x7f,0x97,0x8d,0x0a,0x0b,0x0c,0x0d,0x0e,0x0f,
 
189
0x10,0x11,0x12,0x13,0x9d,0x85,0x08,0x87,0x18,0x19,0x92,0x8f,0x1c,0x1d,0x1e,0x1f,
 
190
0x80,0x81,0x82,0x83,0x84,0x00,0x17,0x1b,0x88,0x89,0x8a,0x8b,0x8c,0x05,0x06,0x07,
 
191
0x90,0x91,0x16,0x93,0x94,0x95,0x96,0x04,0x98,0x99,0x9a,0x9b,0x14,0x15,0x9e,0x1a,
 
192
0x20,0xa0,0xa1,0xa2,0xa3,0xa4,0xa5,0xa6,0xa7,0xa8,0x5b,0x2e,0x3c,0x28,0x2b,0x5d,
 
193
0x26,0xa9,0xaa,0xab,0xac,0xad,0xae,0xaf,0xb0,0xb1,0x21,0x24,0x2a,0x29,0x3b,0x5e,
 
194
0x2d,0x2f,0xb2,0xb3,0xb4,0xb5,0xb6,0xb7,0xb8,0xb9,0x7c,0x2c,0x25,0x5f,0x3e,0x3f,
 
195
0xba,0xbb,0xbc,0xbd,0xbe,0xbf,0xc0,0xc1,0xc2,0x60,0x3a,0x23,0x40,0x27,0x3d,0x22,
 
196
0xc3,0x61,0x62,0x63,0x64,0x65,0x66,0x67,0x68,0x69,0xc4,0xc5,0xc6,0xc7,0xc8,0xc9,
 
197
0xca,0x6a,0x6b,0x6c,0x6d,0x6e,0x6f,0x70,0x71,0x72,0xcb,0xcc,0xcd,0xce,0xcf,0xd0,
 
198
0xd1,0x7e,0x73,0x74,0x75,0x76,0x77,0x78,0x79,0x7a,0xd2,0xd3,0xd4,0xd5,0xd6,0xd7,
 
199
0xd8,0xd9,0xda,0xdb,0xdc,0xdd,0xde,0xdf,0xe0,0xe1,0xe2,0xe3,0xe4,0xe5,0xe6,0xe7,
 
200
0x7b,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0xe8,0xe9,0xea,0xeb,0xec,0xed,
 
201
0x7d,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0xee,0xef,0xf0,0xf1,0xf2,0xf3,
 
202
0x5c,0x9f,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,0xf4,0xf5,0xf6,0xf7,0xf8,0xf9,
 
203
0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0xfa,0xfb,0xfc,0xfd,0xfe,0xff};
 
204
 
 
205
#if defined(X3270_DBCS) /*[*/
 
206
enum ftd ft_dbcs_state = FT_DBCS_NONE;
 
207
unsigned char ft_dbcs_byte1;
 
208
Boolean ft_last_dbcs = False;
 
209
#endif /*]*/
 
210
 
151
211
#if defined(X3270_DISPLAY) && defined(X3270_MENUS) /*[*/
152
212
static Widget overwrite_shell;
153
213
#endif /*]*/
154
214
static Boolean ft_is_action;
 
215
static unsigned long ft_start_id = 0;
155
216
 
156
217
#if defined(X3270_DISPLAY) && defined(X3270_MENUS) /*[*/
157
218
static void ft_cancel(Widget w, XtPointer client_data, XtPointer call_data);
208
269
        int nr = 0;
209
270
 
210
271
        ret[nr++] = receive_flag? (append_flag? 'a': 'w' ): 'r';
211
 
#if defined(_WIN32) /*[*/
212
272
        if (!ascii_flag)
213
273
                ret[nr++] = 'b';
214
 
#endif /*]*/
215
274
        ret[nr] = '\0';
216
275
        return ret;
217
276
}
218
277
 
 
278
/* Timeout function for stalled transfers. */
 
279
static void
 
280
ft_didnt_start(void)
 
281
{
 
282
        if (ft_local_file != NULL) {
 
283
                fclose(ft_local_file);
 
284
                ft_local_file = NULL;
 
285
                if (receive_flag && !append_flag)
 
286
                    unlink(ft_local_filename);
 
287
        }
 
288
        allow_overwrite = False;
 
289
 
 
290
        ft_complete(get_message("ftStartTimeout"));
 
291
        sms_continue();
 
292
}
 
293
 
219
294
#if defined(X3270_DISPLAY) && defined(X3270_MENUS) /*[*/
220
295
/* "File Transfer" dialog. */
221
296
 
224
299
 * Called back from the "File Transfer" option on the File menu.
225
300
 */
226
301
void
227
 
popup_ft(Widget w unused, XtPointer call_parms unused,
228
 
        XtPointer call_data unused)
 
302
popup_ft(Widget w _is_unused, XtPointer call_parms _is_unused,
 
303
        XtPointer call_data _is_unused)
229
304
{
230
305
        /* Initialize it. */
231
306
        if (ft_shell == (Widget)NULL)
425
500
            XtNborderWidth, 0,
426
501
            NULL);
427
502
        dialog_apply_bitmap(recfm_options[1],
428
 
            (recfm == FIXED) ? diamond : no_diamond);
 
503
            (recfm == RECFM_FIXED) ? diamond : no_diamond);
429
504
        XtAddCallback(recfm_options[1], XtNcallback, recfm_callback,
430
505
            (XtPointer)&r_fixed);
431
506
        dialog_register_sensitivity(recfm_options[1],
441
516
            XtNborderWidth, 0,
442
517
            NULL);
443
518
        dialog_apply_bitmap(recfm_options[2],
444
 
            (recfm == VARIABLE) ? diamond : no_diamond);
 
519
            (recfm == RECFM_VARIABLE) ? diamond : no_diamond);
445
520
        XtAddCallback(recfm_options[2], XtNcallback, recfm_callback,
446
521
            (XtPointer)&r_variable);
447
522
        dialog_register_sensitivity(recfm_options[2],
457
532
            XtNborderWidth, 0,
458
533
            NULL);
459
534
        dialog_apply_bitmap(recfm_options[3],
460
 
            (recfm == UNDEFINED) ? diamond : no_diamond);
 
535
            (recfm == RECFM_UNDEFINED) ? diamond : no_diamond);
461
536
        XtAddCallback(recfm_options[3], XtNcallback, recfm_callback,
462
537
            (XtPointer)&r_undefined);
463
538
        dialog_register_sensitivity(recfm_options[3],
813
888
 
814
889
/* Transfer pop-up popping up. */
815
890
static void
816
 
ft_popup_callback(Widget w unused, XtPointer client_data unused,
817
 
        XtPointer call_data unused)
 
891
ft_popup_callback(Widget w _is_unused, XtPointer client_data _is_unused,
 
892
        XtPointer call_data _is_unused)
818
893
{
819
894
        /* Set the focus to the local file widget. */
820
895
        PA_dialog_focus_action(local_file, (XEvent *)NULL, (String *)NULL,
826
901
 
827
902
/* Cancel button pushed. */
828
903
static void
829
 
ft_cancel(Widget w unused, XtPointer client_data unused,
830
 
        XtPointer call_data unused)
 
904
ft_cancel(Widget w _is_unused, XtPointer client_data _is_unused,
 
905
        XtPointer call_data _is_unused)
831
906
{
832
907
        XtPopdown(ft_shell);
833
908
}
834
909
 
835
910
/* recfm options. */
836
911
static void
837
 
recfm_callback(Widget w, XtPointer user_data, XtPointer call_data unused)
 
912
recfm_callback(Widget w, XtPointer user_data, XtPointer call_data _is_unused)
838
913
{
839
914
        recfm = *(enum recfm *)user_data;
840
915
        recfm_default = (recfm == DEFAULT_RECFM);
844
919
 
845
920
/* Units options. */
846
921
static void
847
 
units_callback(Widget w, XtPointer user_data, XtPointer call_data unused)
 
922
units_callback(Widget w, XtPointer user_data, XtPointer call_data _is_unused)
848
923
{
849
924
        units = *(enum units *)user_data;
850
925
        units_default = (units == DEFAULT_UNITS);
854
929
 
855
930
/* OK button pushed. */
856
931
static void
857
 
ft_start_callback(Widget w unused, XtPointer call_parms unused,
858
 
        XtPointer call_data unused)
 
932
ft_start_callback(Widget w _is_unused, XtPointer call_parms _is_unused,
 
933
        XtPointer call_data _is_unused)
859
934
{
860
935
        if (ft_start()) {
861
936
                XtPopdown(ft_shell);
865
940
 
866
941
/* Send/receive options. */
867
942
static void
868
 
toggle_receive(Widget w unused, XtPointer client_data,
869
 
        XtPointer call_data unused)
 
943
toggle_receive(Widget w _is_unused, XtPointer client_data,
 
944
        XtPointer call_data _is_unused)
870
945
{
871
946
        /* Toggle the flag */
872
947
        receive_flag = *(Boolean *)client_data;
879
954
 
880
955
/* Ascii/binary options. */
881
956
static void
882
 
toggle_ascii(Widget w unused, XtPointer client_data, XtPointer call_data unused)
 
957
toggle_ascii(Widget w _is_unused, XtPointer client_data, XtPointer call_data _is_unused)
883
958
{
884
959
        /* Toggle the flag. */
885
960
        ascii_flag = *(Boolean *)client_data;
896
971
 
897
972
/* CR option. */
898
973
static void
899
 
toggle_cr(Widget w, XtPointer client_data unused, XtPointer call_data unused)
 
974
toggle_cr(Widget w, XtPointer client_data _is_unused, XtPointer call_data _is_unused)
900
975
{
901
976
        /* Toggle the cr flag */
902
977
        cr_flag = !cr_flag;
906
981
 
907
982
/* Append option. */
908
983
static void
909
 
toggle_append(Widget w, XtPointer client_data unused,
910
 
        XtPointer call_data unused)
 
984
toggle_append(Widget w, XtPointer client_data _is_unused,
 
985
        XtPointer call_data _is_unused)
911
986
{
912
987
        /* Toggle Append Flag */
913
988
        append_flag = !append_flag;
917
992
 
918
993
/* Remap option. */
919
994
static void
920
 
toggle_remap(Widget w, XtPointer client_data unused,
921
 
        XtPointer call_data unused)
 
995
toggle_remap(Widget w, XtPointer client_data _is_unused,
 
996
        XtPointer call_data _is_unused)
922
997
{
923
998
        /* Toggle Remap Flag */
924
999
        remap_flag = !remap_flag;
928
1003
 
929
1004
/* TSO/VM option. */
930
1005
static void
931
 
toggle_vm(Widget w unused, XtPointer client_data unused,
932
 
    XtPointer call_data unused)
 
1006
toggle_vm(Widget w _is_unused, XtPointer client_data _is_unused,
 
1007
    XtPointer call_data _is_unused)
933
1008
{
934
1009
        /* Toggle the flag. */
935
1010
        vm_flag = *(Boolean *)client_data;
939
1014
        dialog_mark_toggle(tso_toggle, vm_flag ? no_diamond : diamond);
940
1015
 
941
1016
        if (vm_flag) {
942
 
                if (recfm == UNDEFINED) {
 
1017
                if (recfm == RECFM_UNDEFINED) {
943
1018
                        recfm = DEFAULT_RECFM;
944
1019
                        recfm_default = True;
945
1020
                        dialog_flip_toggles(&recfm_toggles,
962
1037
        String buffersize, lrecl, blksize, primspace, secspace;
963
1038
        char updated_buffersize[128];
964
1039
        unsigned flen;
965
 
        char *ft_command;
966
1040
 
967
1041
        ft_is_action = False;
968
1042
 
 
1043
#if defined(X3270_DBCS) /*[*/
 
1044
        ft_dbcs_state = FT_DBCS_NONE;
 
1045
#endif /*]*/
 
1046
 
969
1047
        /* Get the DFT buffer size. */
970
1048
        XtVaGetValues(buffersize_widget, XtNstring, &buffersize, NULL);
971
1049
        if (*buffersize)
1003
1081
        ft_local_file = fopen(ft_local_filename, local_fflag());
1004
1082
        if (ft_local_file == (FILE *)NULL) {
1005
1083
                allow_overwrite = False;
1006
 
                popup_an_errno(errno, "Open(%s)", ft_local_filename);
 
1084
                popup_an_errno(errno, "Local file '%s'", ft_local_filename);
1007
1085
                return 0;
1008
1086
        }
1009
1087
 
1021
1099
                                /* RECFM Entered, process */
1022
1100
                                strcat(op, " recfm(");
1023
1101
                                switch (recfm) {
1024
 
                                    case FIXED:
 
1102
                                    case RECFM_FIXED:
1025
1103
                                        strcat(op, "f");
1026
1104
                                        break;
1027
 
                                    case VARIABLE:
 
1105
                                    case RECFM_VARIABLE:
1028
1106
                                        strcat(op, "v");
1029
1107
                                        break;
1030
 
                                    case UNDEFINED:
 
1108
                                    case RECFM_UNDEFINED:
1031
1109
                                        strcat(op, "u");
1032
1110
                                        break;
1033
1111
                                    default:
1079
1157
                        if (recfm != DEFAULT_RECFM) {
1080
1158
                                strcat(op, " recfm ");
1081
1159
                                switch (recfm) {
1082
 
                                    case FIXED:
 
1160
                                    case RECFM_FIXED:
1083
1161
                                        strcat(op, "f");
1084
1162
                                        break;
1085
 
                                    case VARIABLE:
 
1163
                                    case RECFM_VARIABLE:
1086
1164
                                        strcat(op, "v");
1087
1165
                                        break;
1088
1166
                                    default:
1105
1183
                op = opts;
1106
1184
        }
1107
1185
 
1108
 
        /*
1109
 
         * Unless the user specified a particular file transfer command,
1110
 
         * translate 'ind$file' so that it will have the proper EBCDIC value,
1111
 
         * regardless of the local character set.
1112
 
         */
1113
 
        if (appres.ft_command != CN) {
1114
 
                ft_command = appres.ft_command;
1115
 
        } else {
1116
 
                char *s = "ind$file";
1117
 
                char *t;
1118
 
                unsigned char c;
1119
 
 
1120
 
                ft_command = Malloc(strlen(s) + 1);
1121
 
                t = ft_command;
1122
 
 
1123
 
                while ((c = *s++)) {
1124
 
                        *t++ = ebc2asc[asc2ebc0[c & 0xff]];
1125
 
                }
1126
 
                *t = '\0';
1127
 
        }
1128
 
 
1129
1186
        /* Build the whole command. */
1130
 
        cmd = xs_buffer("%s %s %s%s\\n",
1131
 
            ft_command,
 
1187
        cmd = xs_buffer("ind\\e005Bfile %s %s%s\\n",
1132
1188
            receive_flag ? "get" : "put", ft_host_filename, op);
1133
 
        if (appres.ft_command == CN)
1134
 
                Free(ft_command);
1135
1189
 
1136
1190
        /* Erase the line and enter the command. */
1137
1191
        flen = kybd_prime();
1143
1197
                        if (receive_flag && !append_flag)
1144
1198
                            unlink(ft_local_filename);
1145
1199
                }
1146
 
                popup_an_error(get_message("ftUnable"));
 
1200
                popup_an_error("%s", get_message("ftUnable"));
1147
1201
                allow_overwrite = False;
1148
1202
                return 0;
1149
1203
        }
1154
1208
        ft_state = FT_AWAIT_ACK;
1155
1209
        ft_is_cut = False;
1156
1210
        ft_last_cr = False;
 
1211
#if defined(X3270_DBCS) /*[*/
 
1212
        ft_last_dbcs = False;
 
1213
#endif /*]*/
1157
1214
 
1158
1215
        return 1;
1159
1216
}
1271
1328
 
1272
1329
/* In-progress pop-up popped up. */
1273
1330
static void
1274
 
progress_popup_callback(Widget w unused, XtPointer client_data unused,
1275
 
        XtPointer call_data unused)
 
1331
progress_popup_callback(Widget w _is_unused, XtPointer client_data _is_unused,
 
1332
        XtPointer call_data _is_unused)
1276
1333
{
1277
1334
        XtVaSetValues(from_file, XtNlabel,
1278
1335
            receive_flag ? ft_host_filename : ft_local_filename, NULL);
1303
1360
 
1304
1361
/* In-progress "cancel" button. */
1305
1362
static void
1306
 
progress_cancel_callback(Widget w unused, XtPointer client_data unused,
1307
 
        XtPointer call_data unused)
 
1363
progress_cancel_callback(Widget w _is_unused, XtPointer client_data _is_unused,
 
1364
        XtPointer call_data _is_unused)
1308
1365
{
1309
1366
        if (ft_state == FT_RUNNING) {
1310
1367
                ft_state = FT_ABORT_WAIT;
1397
1454
 
1398
1455
/* Overwrite "okay" button. */
1399
1456
static void
1400
 
overwrite_okay_callback(Widget w unused, XtPointer client_data unused,
1401
 
        XtPointer call_data unused)
 
1457
overwrite_okay_callback(Widget w _is_unused, XtPointer client_data _is_unused,
 
1458
        XtPointer call_data _is_unused)
1402
1459
{
1403
1460
        XtPopdown(overwrite_shell);
1404
1461
 
1411
1468
 
1412
1469
/* Overwrite "cancel" button. */
1413
1470
static void
1414
 
overwrite_cancel_callback(Widget w unused, XtPointer client_data unused,
1415
 
        XtPointer call_data unused)
 
1471
overwrite_cancel_callback(Widget w _is_unused, XtPointer client_data _is_unused,
 
1472
        XtPointer call_data _is_unused)
1416
1473
{
1417
1474
        XtPopdown(overwrite_shell);
1418
1475
}
1419
1476
 
1420
1477
/* Overwrite pop-up popped down. */
1421
1478
static void
1422
 
overwrite_popdown(Widget w unused, XtPointer client_data unused,
1423
 
        XtPointer call_data unused)
 
1479
overwrite_popdown(Widget w _is_unused, XtPointer client_data _is_unused,
 
1480
        XtPointer call_data _is_unused)
1424
1481
{
1425
1482
        XtDestroyWidget(overwrite_shell);
1426
1483
        overwrite_shell = (Widget)NULL;
1460
1517
                        if (s > msg_copy)
1461
1518
                                *s = '\n';      /* yikes! */
1462
1519
                }
1463
 
                popup_an_error(msg_copy);
 
1520
#if defined(C3270) /*[*/
 
1521
                printf("\r%79s\n", "");
 
1522
                fflush(stdout);
 
1523
#endif /*]*/
 
1524
                popup_an_error("%s", msg_copy);
1464
1525
                Free(msg_copy);
1465
1526
        } else {
1466
1527
                struct timeval t1;
1467
 
                double kbytes_sec;
 
1528
                double bytes_sec;
1468
1529
                char *buf;
 
1530
                char kbuf[256];
1469
1531
 
1470
1532
                (void) gettimeofday(&t1, (struct timezone *)NULL);
1471
 
                kbytes_sec = (double)ft_length / 1024.0 /
 
1533
                bytes_sec = (double)ft_length /
1472
1534
                        ((double)(t1.tv_sec - t0.tv_sec) + 
1473
1535
                         (double)(t1.tv_usec - t0.tv_usec) / 1.0e6);
1474
1536
                buf = Malloc(256);
1475
1537
                (void) sprintf(buf, get_message("ftComplete"), ft_length,
1476
 
                    kbytes_sec, ft_is_cut ? "CUT" : "DFT");
 
1538
                        display_scale(bytes_sec, kbuf, sizeof(kbuf)),
 
1539
                        ft_is_cut ? "CUT" : "DFT");
1477
1540
                if (ft_is_action) {
 
1541
#if defined(C3270) /*[*/
 
1542
                        printf("\r%79s\n", "");
 
1543
                        fflush(stdout);
 
1544
#endif /*]*/
1478
1545
                        sms_info("%s", buf);
1479
1546
                        sms_continue();
1480
1547
                }
1481
1548
#if defined(X3270_DISPLAY) && defined(X3270_MENUS) /*[*/
1482
1549
                else
1483
 
                        popup_an_info(buf);
 
1550
                        popup_an_info("%s", buf);
1484
1551
#endif /*]*/
1485
1552
                Free(buf);
1486
1553
        }
1500
1567
                XtVaSetValues(ft_status, XtNlabel, text_string, NULL);
1501
1568
        }
1502
1569
#endif /*]*/
 
1570
#if defined(C3270) /*[*/
 
1571
        printf("\r%79s\rTransferred %lu bytes. ", "", ft_length);
 
1572
        fflush(stdout);
 
1573
#endif /*]*/
1503
1574
}
1504
1575
 
1505
1576
/* Process a transfer acknowledgement. */
1506
1577
void
1507
1578
ft_running(Boolean is_cut)
1508
1579
{
1509
 
        if (ft_state == FT_AWAIT_ACK)
 
1580
        if (ft_state == FT_AWAIT_ACK) {
1510
1581
                ft_state = FT_RUNNING;
 
1582
                if (ft_start_id) {
 
1583
                        RemoveTimeOut(ft_start_id);
 
1584
                        ft_start_id = 0;
 
1585
                }
 
1586
        }
1511
1587
        ft_is_cut = is_cut;
1512
1588
        (void) gettimeofday(&t0, (struct timezone *)NULL);
1513
1589
        ft_length = 0;
1519
1595
                XtMapWidget(ft_status);
1520
1596
        }
1521
1597
#endif /*]*/
 
1598
#if defined(C3270) /*[*/
 
1599
        ft_update_length();
 
1600
#endif /*]*/
1522
1601
}
1523
1602
 
1524
1603
/* Process a protocol-generated abort. */
1539
1618
 
1540
1619
/* Process a disconnect abort. */
1541
1620
static void
1542
 
ft_connected(Boolean ignored unused)
 
1621
ft_connected(Boolean ignored _is_unused)
1543
1622
{
1544
1623
        if (!CONNECTED && ft_state != FT_NONE)
1545
1624
                ft_complete(get_message("ftDisconnected"));
1547
1626
 
1548
1627
/* Process an abort from no longer being in 3270 mode. */
1549
1628
static void
1550
 
ft_in3270(Boolean ignored unused)
 
1629
ft_in3270(Boolean ignored _is_unused)
1551
1630
{
1552
1631
        if (!IN_3270 && ft_state != FT_NONE)
1553
1632
                ft_complete(get_message("ftNot3270"));
1563
1642
 *   Host=[tso|vm]              default tso
1564
1643
 *   Mode=[ascii|binary]        default ascii
1565
1644
 *   Cr=[add|remove|keep]       default add/remove
 
1645
 *   Remap=[yes|no]             default yes
1566
1646
 *   Exist=[keep|replace|append]        default keep
1567
1647
 *   Recfm=[default|fixed|variable|undefined] default default
1568
1648
 *   Lrecl=n                    no default
1582
1662
        { "Host",               CN, { "tso", "vm" } },
1583
1663
        { "Mode",               CN, { "ascii", "binary" } },
1584
1664
        { "Cr",                 CN, { "auto", "remove", "add", "keep" } },
 
1665
        { "Remap",              CN, { "yes", "no" } },
1585
1666
        { "Exist",              CN, { "keep", "replace", "append" } },
1586
1667
        { "Recfm",              CN, { "default", "fixed", "variable",
1587
1668
                                      "undefined" } },
1601
1682
        PARM_HOST,
1602
1683
        PARM_MODE,
1603
1684
        PARM_CR,
 
1685
        PARM_REMAP,
1604
1686
        PARM_EXIST,
1605
1687
        PARM_RECFM,
1606
1688
        PARM_LRECL,
1613
1695
};
1614
1696
 
1615
1697
void  
1616
 
Transfer_action(Widget w unused, XEvent *event, String *params,
 
1698
Transfer_action(Widget w _is_unused, XEvent *event, String *params,
1617
1699
    Cardinal *num_params)
1618
1700
{
1619
1701
        int i, k;
1620
1702
        Cardinal j;
1621
1703
        long l;
1622
1704
        char *ptr;
1623
 
        char *ft_command = CN;
1624
1705
 
1625
1706
        char opts[80];
1626
1707
        char *op = opts + 1;
1644
1725
        /* Check for interactive mode. */
1645
1726
        if (xnparams == 0 && escaped) {
1646
1727
                if (interactive_transfer(&xparams, &xnparams) < 0) {
 
1728
                        printf("\n");
 
1729
                        fflush(stdout);
 
1730
                        action_output("Aborted");
1647
1731
                        return;
1648
1732
                }
1649
1733
        }
1745
1829
                cr_flag = !strcasecmp(tp[PARM_CR].value, "remove") ||
1746
1830
                          !strcasecmp(tp[PARM_CR].value, "add");
1747
1831
        }
 
1832
        if (ascii_flag)
 
1833
                remap_flag = !strcasecmp(tp[PARM_REMAP].value, "yes");
1748
1834
        vm_flag = !strcasecmp(tp[PARM_HOST].value, "vm");
1749
1835
        recfm = DEFAULT_RECFM;
1750
1836
        for (k = 0; tp[PARM_RECFM].keyword[k] != CN && k < 4; k++) {
1780
1866
        /* Open the local file. */
1781
1867
        ft_local_file = fopen(ft_local_filename, local_fflag());
1782
1868
        if (ft_local_file == (FILE *)NULL) {
1783
 
                popup_an_errno(errno, "Open(%s)", ft_local_filename);
 
1869
                popup_an_errno(errno, "Local file '%s'", ft_local_filename);
1784
1870
                return;
1785
1871
        }
1786
1872
 
1798
1884
                                /* RECFM Entered, process */
1799
1885
                                strcat(op, " recfm(");
1800
1886
                                switch (recfm) {
1801
 
                                    case FIXED:
 
1887
                                    case RECFM_FIXED:
1802
1888
                                        strcat(op, "f");
1803
1889
                                        break;
1804
 
                                    case VARIABLE:
 
1890
                                    case RECFM_VARIABLE:
1805
1891
                                        strcat(op, "v");
1806
1892
                                        break;
1807
 
                                    case UNDEFINED:
 
1893
                                    case RECFM_UNDEFINED:
1808
1894
                                        strcat(op, "u");
1809
1895
                                        break;
1810
1896
                                    default:
1846
1932
                        if (recfm != DEFAULT_RECFM) {
1847
1933
                                strcat(op, " recfm ");
1848
1934
                                switch (recfm) {
1849
 
                                    case FIXED:
 
1935
                                    case RECFM_FIXED:
1850
1936
                                        strcat(op, "f");
1851
1937
                                        break;
1852
 
                                    case VARIABLE:
 
1938
                                    case RECFM_VARIABLE:
1853
1939
                                        strcat(op, "v");
1854
1940
                                        break;
1855
1941
                                    default:
1870
1956
                op = opts;
1871
1957
        }
1872
1958
 
1873
 
        /*
1874
 
         * Unless the user specified a particular file transfer command,
1875
 
         * translate 'ind$file' so that it will have the proper EBCDIC value,
1876
 
         * regardless of the local character set.
1877
 
         */
1878
 
        if (appres.ft_command != CN) {
1879
 
                ft_command = appres.ft_command;
1880
 
        } else {
1881
 
                char *s = "ind$file";
1882
 
                char *t;
1883
 
                unsigned char c;
1884
 
 
1885
 
                ft_command = Malloc(strlen(s) + 1);
1886
 
                t = ft_command;
1887
 
 
1888
 
                while ((c = *s++)) {
1889
 
                        *t++ = ebc2asc[asc2ebc0[c & 0xff]];
1890
 
                }
1891
 
                *t = '\0';
1892
 
        }
1893
 
 
1894
1959
        /* Build the whole command. */
1895
 
        cmd = xs_buffer("%s %s %s%s\\n",
1896
 
            ft_command,
 
1960
        cmd = xs_buffer("ind\\e005Bfile %s %s%s\\n",
1897
1961
            receive_flag ? "get" : "put", ft_host_filename, op);
1898
 
        if (appres.ft_command == CN)
1899
 
                Free(ft_command);
1900
1962
 
1901
1963
        /* Erase the line and enter the command. */
1902
1964
        flen = kybd_prime();
1908
1970
                        if (receive_flag && !append_flag)
1909
1971
                            unlink(ft_local_filename);
1910
1972
                }
1911
 
                popup_an_error(get_message("ftUnable"));
 
1973
                popup_an_error("%s", get_message("ftUnable"));
1912
1974
                return;
1913
1975
        }
1914
1976
        (void) emulate_input(cmd, strlen(cmd), False);
1915
1977
        Free(cmd);
 
1978
#if defined(C3270) /*[*/
 
1979
        if (!escaped)
 
1980
                screen_suspend();
 
1981
        printf("Awaiting start of transfer... ");
 
1982
        fflush(stdout);
 
1983
#endif /*]*/
1916
1984
 
1917
1985
        /* Get this thing started. */
 
1986
        ft_start_id = AddTimeOut(10 * 1000, ft_didnt_start);
1918
1987
        ft_state = FT_AWAIT_ACK;
1919
1988
        ft_is_cut = False;
1920
1989
}