Commit 60fce8dd8a9c6519fce72049a8ca808b8998ce2d
1 parent
421856cb
Exists in
master
and in
5 other branches
Iniciando atualização do processo de transferência de arquivos
Showing
10 changed files
with
358 additions
and
187 deletions
Show diff stats
Makefile.in
... | ... | @@ -147,8 +147,6 @@ endif |
147 | 147 | |
148 | 148 | #---[ Targets ]---------------------------------------------------------------- |
149 | 149 | |
150 | -lang: $(foreach SRC, $(basename $(LANG_FILES)), $(SRC).po) | |
151 | - | |
152 | 150 | tgz: $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.gz |
153 | 151 | |
154 | 152 | rpm: $(PACKAGE_TARNAME)-$(PACKAGE_VERSION).tar.gz |
... | ... | @@ -206,6 +204,8 @@ install-app: install-locale |
206 | 204 | install-lib: |
207 | 205 | @$(MAKE) BINRLS="../../.bin/Release/lib" -C src/lib3270 install |
208 | 206 | |
207 | +locale: $(foreach SRC, $(basename $(LANG_FILES)), $(SRC).po) | |
208 | + | |
209 | 209 | install-locale: $(foreach MO, $(basename $(LANG_FILES)), $(BINDIR)/Release/$(localedir)/$(notdir $(MO))/LC_MESSAGES/$(PACKAGE_NAME).mo) |
210 | 210 | @echo -e $(foreach MO, $(notdir $(basename $(LANG_FILES))), mkdir -p $(DESTDIR)/$(localedir)/$(MO)/LC_MESSAGES\\n$(INSTALL_DATA) $(BINDIR)/Release/$(localedir)/$(MO)/LC_MESSAGES/$(PACKAGE_NAME).mo $(DESTDIR)/$(localedir)/$(MO)/LC_MESSAGES/$(PACKAGE_NAME).mo \\n ) | $(SHELL) |
211 | 211 | ... | ... |
po/pt_BR.po
... | ... | @@ -5,8 +5,8 @@ msgid "" |
5 | 5 | msgstr "" |
6 | 6 | "Project-Id-Version: pw3270 5.0\n" |
7 | 7 | "Report-Msgid-Bugs-To: \n" |
8 | -"POT-Creation-Date: 2012-05-04 10:26-0300\n" | |
9 | -"PO-Revision-Date: 2012-05-04 11:54-0300\n" | |
8 | +"POT-Creation-Date: 2012-05-04 12:01-0300\n" | |
9 | +"PO-Revision-Date: 2012-05-04 12:00-0300\n" | |
10 | 10 | "Last-Translator: Perry Werneck <perry.werneck@gmail.com>\n" |
11 | 11 | "Language-Team: Português do Brasil <>\n" |
12 | 12 | "Language: \n" |
... | ... | @@ -327,7 +327,7 @@ msgstr "Cursor mira" |
327 | 327 | #: dialog.c:111 |
328 | 328 | #, c-format |
329 | 329 | msgid "Current (%s)" |
330 | -msgstr "Current (%s)" | |
330 | +msgstr "Atual (%s)" | |
331 | 331 | |
332 | 332 | #: colors.c:335 |
333 | 333 | msgid "Custom colors" | ... | ... |
pw3270.cbp
... | ... | @@ -63,6 +63,7 @@ |
63 | 63 | <Unit filename="src/include/lib3270/action_table.h" /> |
64 | 64 | <Unit filename="src/include/lib3270/actions.h" /> |
65 | 65 | <Unit filename="src/include/lib3270/config.h.in" /> |
66 | + <Unit filename="src/include/lib3270/filetransfer.h" /> | |
66 | 67 | <Unit filename="src/include/lib3270/log.h" /> |
67 | 68 | <Unit filename="src/include/lib3270/popup.h" /> |
68 | 69 | <Unit filename="src/include/lib3270/selection.h" /> | ... | ... |
... | ... | @@ -0,0 +1,78 @@ |
1 | +/* | |
2 | + * "Software PW3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | + * (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | + * aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | + * | |
6 | + * Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | + * | |
8 | + * Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | + * os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | + * Free Software Foundation. | |
11 | + * | |
12 | + * Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | + * GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | + * A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | + * obter mais detalhes. | |
16 | + * | |
17 | + * Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | + * programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple | |
19 | + * Place, Suite 330, Boston, MA, 02111-1307, USA | |
20 | + * | |
21 | + * Este programa está nomeado como filetransfer.h e possui - linhas de código. | |
22 | + * | |
23 | + * Contatos: | |
24 | + * | |
25 | + * perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
26 | + * erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) | |
27 | + * licinio@bb.com.br (Licínio Luis Branco) | |
28 | + * kraucer@bb.com.br (Kraucer Fernandes Mazuco) | |
29 | + * macmiranda@bb.com.br (Marco Aurélio Caldas Miranda) | |
30 | + * | |
31 | + */ | |
32 | + | |
33 | +#ifndef LIB3270_FILETRANSFER_INCLUDED | |
34 | + | |
35 | + #define LIB3270_FILETRANSFER_INCLUDED 1 | |
36 | + #include <stdio.h> | |
37 | + | |
38 | + typedef enum _lib3270_FT_FLAG | |
39 | + { | |
40 | + LIB3270_FT_OPTION_RECEIVE = 0x0001, | |
41 | + LIB3270_FT_OPTION_ASCII = 0x0002, | |
42 | + LIB3270_FT_OPTION_CRLF = 0x0004, | |
43 | + LIB3270_FT_OPTION_APPEND = 0x0008, | |
44 | + LIB3270_FT_OPTION_TSO = 0x0010, | |
45 | + LIB3270_FT_OPTION_REMAP_ASCII = 0x0020 | |
46 | + } LIB3270_FT_OPTION; | |
47 | + | |
48 | + typedef struct _h3270ft | |
49 | + { | |
50 | + unsigned short sz; /**< Size of FT data structure */ | |
51 | + H3270 * host; | |
52 | + void * widget; /**< File transfer dialog handle */ | |
53 | + FILE * ft_local_file; /**< File descriptor for local file */ | |
54 | + | |
55 | + } H3270FT; | |
56 | + | |
57 | + /** | |
58 | + * Start a new file transfer session. | |
59 | + * | |
60 | + * @param session | |
61 | + * @param flags | |
62 | + * @param local | |
63 | + * @param remote | |
64 | + * @param lrecl | |
65 | + * @param blksize | |
66 | + * @param primspace | |
67 | + * @param secspace | |
68 | + * @param dft | |
69 | + * @param msg Pointer to error message. | |
70 | + * | |
71 | + * @return Filetransfer handle if ok, NULL if failed | |
72 | + * | |
73 | + */ | |
74 | + LIB3270_EXPORT H3270FT * lib3270_ft_start(H3270 *session, LIB3270_FT_OPTION flags, const char *local, const char *remote, int lrecl, int blksize, int primspace, int secspace, int dft, const char **msg); | |
75 | + | |
76 | + LIB3270_EXPORT int lib3270_ft_cancel(H3270FT *ft, int force); | |
77 | + | |
78 | +#endif // LIB3270_FILETRANSFER_INCLUDED | ... | ... |
src/lib3270/api.h
... | ... | @@ -206,12 +206,12 @@ |
206 | 206 | // LOCAL_EXTERN int set_device_buffer(struct ea *src, int el); |
207 | 207 | |
208 | 208 | /* File transfer */ |
209 | - #define FT_FLAG_RECEIVE 0x0001 | |
210 | - #define FT_FLAG_ASCII 0x0002 | |
211 | - #define FT_FLAG_CRLF 0x0004 | |
212 | - #define FT_FLAG_APPEND 0x0008 | |
213 | - #define FT_FLAG_TSO 0x0010 | |
214 | - #define FT_FLAG_REMAP_ASCII 0x0020 | |
209 | + //#define LIB3270_FT_OPTION_RECEIVE 0x0001 | |
210 | + // #define LIB3270_FT_OPTION_ASCII 0x0002 | |
211 | + // #define LIB3270_FT_OPTION_CRLF 0x0004 | |
212 | + // #define LIB3270_FT_OPTION_APPEND 0x0008 | |
213 | + // #define LIB3270_FT_OPTION_TSO 0x0010 | |
214 | + // #define LIB3270_FT_OPTION_REMAP_ASCII 0x0020 | |
215 | 215 | |
216 | 216 | #define FT_RECORD_FORMAT_FIXED 0x0100 |
217 | 217 | #define FT_RECORD_FORMAT_VARIABLE 0x0200 |
... | ... | @@ -232,7 +232,7 @@ |
232 | 232 | FT_ABORT_SENT /**< Abort sent; awaiting response */ |
233 | 233 | }; |
234 | 234 | |
235 | - LOCAL_EXTERN int BeginFileTransfer(unsigned short flags, const char *local, const char *remote, int lrecl, int blksize, int primspace, int secspace, int dft); | |
235 | +// LOCAL_EXTERN int BeginFileTransfer(unsigned short flags, const char *local, const char *remote, int lrecl, int blksize, int primspace, int secspace, int dft); | |
236 | 236 | LOCAL_EXTERN int CancelFileTransfer(int force); |
237 | 237 | LOCAL_EXTERN enum ft_state GetFileTransferState(void); |
238 | 238 | ... | ... |
src/lib3270/ft.c
... | ... | @@ -32,10 +32,9 @@ |
32 | 32 | |
33 | 33 | #include <lib3270/config.h> |
34 | 34 | #include <lib3270.h> |
35 | +#include <lib3270/filetransfer.h> | |
35 | 36 | #include "globals.h" |
36 | 37 | |
37 | -#if defined(X3270_FT) | |
38 | - | |
39 | 38 | #include <errno.h> |
40 | 39 | |
41 | 40 | #include "appres.h" |
... | ... | @@ -43,13 +42,13 @@ |
43 | 42 | #include "ft_cutc.h" |
44 | 43 | #include "ft_dftc.h" |
45 | 44 | #include "ftc.h" |
46 | -// #include "dialogc.h" | |
47 | 45 | #include "hostc.h" |
46 | +/* | |
48 | 47 | #if defined(C3270) || defined(WC3270) |
49 | 48 | #include "icmdc.h" |
50 | 49 | #endif |
50 | +*/ | |
51 | 51 | #include "kybdc.h" |
52 | -// #include "macrosc.h" | |
53 | 52 | #include "objects.h" |
54 | 53 | #include "popupsc.h" |
55 | 54 | #include "screenc.h" |
... | ... | @@ -57,8 +56,8 @@ |
57 | 56 | #include "telnetc.h" |
58 | 57 | #include "utilc.h" |
59 | 58 | |
60 | -static void ft_connected(H3270 *session, int ignored, void *dunno); | |
61 | -static void ft_in3270(H3270 *session, int ignored unused, void *dunno); | |
59 | +static void ft_connected(H3270 *session, int ignored, H3270FT *ft); | |
60 | +static void ft_in3270(H3270 *session, int ignored unused, H3270FT *ft); | |
62 | 61 | |
63 | 62 | /* Macros. */ |
64 | 63 | #define eos(s) strchr((s), '\0') |
... | ... | @@ -75,9 +74,12 @@ static void ft_in3270(H3270 *session, int ignored unused, void *dunno); |
75 | 74 | #define BN (Boolean *)NULL |
76 | 75 | |
77 | 76 | // Globals. |
77 | +H3270FT *ftsession = NULL; | |
78 | + | |
79 | +#define CHECK_FT_HANDLE(x) if(!x) x = ftsession; | |
80 | + | |
78 | 81 | enum ft_state ft_state = FT_NONE; // File transfer state |
79 | -char *ft_local_filename; // Local file to transfer to/from | |
80 | -FILE *ft_local_file = (FILE *)NULL; // File descriptor for local file | |
82 | +// char *ft_local_filename; // Local file to transfer to/from | |
81 | 83 | Boolean ft_last_cr = False; // CR was last char in local file |
82 | 84 | Boolean ascii_flag = True; // Convert to ascii |
83 | 85 | Boolean cr_flag = True; // Add crlf to each line |
... | ... | @@ -95,11 +97,14 @@ static const struct filetransfer_callbacks *callbacks = NULL; // Callbacks to m |
95 | 97 | |
96 | 98 | /*---[ Implement ]-------------------------------------------------------------------------------------------------------*/ |
97 | 99 | |
98 | - void ft_init(void) | |
100 | + void ft_init(H3270FT *h) | |
99 | 101 | { |
100 | 102 | /* Register for state changes. */ |
101 | - register_schange(ST_CONNECT, ft_connected); | |
102 | - register_schange(ST_3270_MODE, ft_in3270); | |
103 | + | |
104 | + CHECK_FT_HANDLE(h); | |
105 | + | |
106 | + lib3270_register_schange(h->host, ST_CONNECT, ( void (*)(H3270 *, int, void *)) ft_connected, h); | |
107 | + lib3270_register_schange(h->host, ST_3270_MODE, ( void (*)(H3270 *, int, void *)) ft_in3270, h); | |
103 | 108 | } |
104 | 109 | |
105 | 110 | enum ft_state QueryFTstate(void) |
... | ... | @@ -107,6 +112,7 @@ static const struct filetransfer_callbacks *callbacks = NULL; // Callbacks to m |
107 | 112 | return ft_state; |
108 | 113 | } |
109 | 114 | |
115 | +/* | |
110 | 116 | int RegisterFTCallbacks(const struct filetransfer_callbacks *cbk) |
111 | 117 | { |
112 | 118 | if(!(cbk && cbk->sz == sizeof(struct filetransfer_callbacks)) ) |
... | ... | @@ -116,20 +122,14 @@ static const struct filetransfer_callbacks *callbacks = NULL; // Callbacks to m |
116 | 122 | |
117 | 123 | return 0; |
118 | 124 | } |
119 | - | |
120 | - static int cant_start(int errcode, const char *errmsg) | |
121 | - { | |
122 | - if(callbacks && callbacks->complete) | |
123 | - callbacks->complete(errmsg,0,0,""); | |
124 | - return errcode; | |
125 | - } | |
125 | +*/ | |
126 | 126 | |
127 | 127 | enum ft_state GetFileTransferState(void) |
128 | 128 | { |
129 | 129 | return ft_state; |
130 | 130 | } |
131 | 131 | |
132 | - int CancelFileTransfer(int force) | |
132 | + LIB3270_EXPORT int lib3270_ft_cancel(H3270FT *ft, int force) | |
133 | 133 | { |
134 | 134 | if (ft_state == FT_RUNNING) |
135 | 135 | { |
... | ... | @@ -143,59 +143,72 @@ static const struct filetransfer_callbacks *callbacks = NULL; // Callbacks to m |
143 | 143 | return EBUSY; |
144 | 144 | |
145 | 145 | // Impatient user or hung host -- just clean up. |
146 | - ft_complete( _("Cancelled by user") ); | |
146 | + ft_complete(ft, _("Cancelled by user") ); | |
147 | 147 | |
148 | 148 | return ECANCELED; |
149 | 149 | } |
150 | 150 | |
151 | - int BeginFileTransfer(unsigned short flags, const char *local, const char *remote, int lrecl, int blksize, int primspace, int secspace, int dft) | |
151 | + LIB3270_EXPORT H3270FT * lib3270_ft_start(H3270 *session, LIB3270_FT_OPTION flags, const char *local, const char *remote, int lrecl, int blksize, int primspace, int secspace, int dft, const char **msg) | |
152 | 152 | { |
153 | - static const char *rec = "fvu"; | |
154 | - static const char *un[] = { "tracks", "cylinders", "avblock" }; | |
153 | + H3270FT * ftHandle = NULL; | |
154 | + static const char * rec = "fvu"; | |
155 | + static const char * un[] = { "tracks", "cylinders", "avblock" }; | |
155 | 156 | |
156 | - unsigned short recfm = (flags & FT_RECORD_FORMAT_MASK) >> 8; | |
157 | - unsigned short units = (flags & FT_ALLOCATION_UNITS_MASK) >> 12; | |
157 | + unsigned short recfm = (flags & FT_RECORD_FORMAT_MASK) >> 8; | |
158 | + unsigned short units = (flags & FT_ALLOCATION_UNITS_MASK) >> 12; | |
158 | 159 | |
159 | - char op[4096]; | |
160 | - char buffer[4096]; | |
160 | + FILE * ft_local_file = NULL; | |
161 | 161 | |
162 | - unsigned int flen; | |
162 | + char op[4096]; | |
163 | + char buffer[4096]; | |
163 | 164 | |
164 | - Trace("%s(%s)",__FUNCTION__,local); | |
165 | + unsigned int flen; | |
165 | 166 | |
166 | - if(ft_local_file) | |
167 | - return cant_start(EBUSY,_( "File transfer is already active")); | |
167 | + Trace("%s(%s)",__FUNCTION__,local); | |
168 | 168 | |
169 | + if(ftsession) | |
170 | + { | |
171 | + *msg = N_( "File transfer is already active" ); | |
172 | + errno = EBUSY; | |
173 | + return NULL; | |
174 | + } | |
169 | 175 | // Check remote file |
170 | 176 | if(!*remote) |
171 | - return cant_start(EINVAL,_( "The remote file name is invalid")); | |
177 | + { | |
178 | + *msg = N_( "The remote file name is invalid" ); | |
179 | + errno = EINVAL; | |
180 | + return NULL; | |
181 | + } | |
172 | 182 | |
173 | 183 | // Open local file |
174 | - ft_local_file = fopen(local,(flags & FT_FLAG_RECEIVE) ? ((flags & FT_FLAG_APPEND) ? "a" : "w") : "r"); | |
184 | + ft_local_file = fopen(local,(flags & LIB3270_FT_OPTION_RECEIVE) ? ((flags & LIB3270_FT_OPTION_APPEND) ? "a" : "w") : "r"); | |
175 | 185 | |
176 | 186 | if(!ft_local_file) |
177 | - return cant_start(errno,_( "Can't open local file")); | |
187 | + { | |
188 | + *msg = N_( "Can't open local file" ); | |
189 | + return NULL; | |
190 | + } | |
178 | 191 | |
179 | 192 | // Set options |
180 | 193 | dft_buffersize = dft; |
181 | 194 | set_dft_buffersize(); |
182 | 195 | |
183 | - ascii_flag = ((flags & FT_FLAG_ASCII) != 0); | |
184 | - cr_flag = ((flags & FT_FLAG_CRLF) != 0); | |
185 | - remap_flag = ((flags & FT_FLAG_REMAP_ASCII) != 0); | |
196 | + ascii_flag = ((flags & LIB3270_FT_OPTION_ASCII) != 0); | |
197 | + cr_flag = ((flags & LIB3270_FT_OPTION_CRLF) != 0); | |
198 | + remap_flag = ((flags & LIB3270_FT_OPTION_ASCII) != 0); | |
186 | 199 | |
187 | - Log("%s file \"%s\"",(flags & FT_FLAG_RECEIVE) ? "Receiving" : "Sending", local); | |
200 | + lib3270_write_log(session, "%s file \"%s\"",(flags & LIB3270_FT_OPTION_RECEIVE) ? "Receiving" : "Sending", local); | |
188 | 201 | |
189 | 202 | /* Build the ind$file command */ |
190 | 203 | snprintf(op,4095,"%s%s%s", |
191 | - (flags & FT_FLAG_ASCII) ? " ASCII" : "", | |
192 | - (flags & FT_FLAG_CRLF) ? " CRLF" : "", | |
193 | - (flags & FT_FLAG_APPEND) ? " APPEND" : "" | |
204 | + (flags & LIB3270_FT_OPTION_ASCII) ? " ASCII" : "", | |
205 | + (flags & LIB3270_FT_OPTION_CRLF) ? " CRLF" : "", | |
206 | + (flags & LIB3270_FT_OPTION_APPEND) ? " APPEND" : "" | |
194 | 207 | ); |
195 | 208 | |
196 | - if(!(flags & FT_FLAG_RECEIVE)) | |
209 | + if(!(flags & LIB3270_FT_OPTION_RECEIVE)) | |
197 | 210 | { |
198 | - if(flags & FT_FLAG_TSO) | |
211 | + if(flags & LIB3270_FT_OPTION_TSO) | |
199 | 212 | { |
200 | 213 | // TSO Host |
201 | 214 | if(recfm > 0) |
... | ... | @@ -237,12 +250,12 @@ static const struct filetransfer_callbacks *callbacks = NULL; // Callbacks to m |
237 | 250 | } |
238 | 251 | |
239 | 252 | snprintf(buffer,4095,"%s %s %s", "IND$FILE", |
240 | - (flags & FT_FLAG_RECEIVE) ? "GET" : "PUT", | |
253 | + (flags & LIB3270_FT_OPTION_RECEIVE) ? "GET" : "PUT", | |
241 | 254 | remote ); |
242 | 255 | |
243 | 256 | if(*op) |
244 | 257 | { |
245 | - if(flags & FT_FLAG_TSO) | |
258 | + if(flags & LIB3270_FT_OPTION_TSO) | |
246 | 259 | snconcat(buffer,4095," %s",op+1); |
247 | 260 | else |
248 | 261 | snconcat(buffer,4095," (%s)",op+1); |
... | ... | @@ -254,10 +267,11 @@ static const struct filetransfer_callbacks *callbacks = NULL; // Callbacks to m |
254 | 267 | flen = kybd_prime(); |
255 | 268 | if (!flen || flen < strlen(buffer) - 1) |
256 | 269 | { |
257 | - Log("Unable to send command \"%s\"",buffer); | |
270 | + lib3270_write_log(session, "Unable to send command \"%s\" (flen=%d szBuffer=%d)",buffer,flen,strlen(buffer)); | |
258 | 271 | fclose(ft_local_file); |
259 | - ft_local_file = NULL; | |
260 | - return cant_start(-1,_( "Unable to send file-transfer request")); | |
272 | + *msg = _( "Unable to send file-transfer request" ); | |
273 | + errno = EINVAL; | |
274 | + return NULL; | |
261 | 275 | } |
262 | 276 | |
263 | 277 | Trace("Command: \"%s\"",buffer); |
... | ... | @@ -268,57 +282,67 @@ static const struct filetransfer_callbacks *callbacks = NULL; // Callbacks to m |
268 | 282 | set_ft_state(FT_AWAIT_ACK); |
269 | 283 | |
270 | 284 | ft_last_cr = False; |
271 | - ft_is_cut = False; | |
285 | + ft_is_cut = False; | |
286 | + | |
287 | + ftHandle = malloc(sizeof(H3270FT)); | |
288 | + memset(ftHandle,0,sizeof(H3270FT)); | |
272 | 289 | |
273 | - if(callbacks && callbacks->begin) | |
274 | - callbacks->begin(flags,local,remote); | |
290 | + ftHandle->sz = sizeof(H3270FT); | |
291 | + ftHandle->host = session; | |
292 | + ftHandle->ft_local_file = ft_local_file; | |
275 | 293 | |
276 | - return 0; | |
294 | + return ftsession = ftHandle; | |
277 | 295 | } |
278 | 296 | |
279 | 297 | /* External entry points called by ft_dft and ft_cut. */ |
280 | 298 | |
281 | -/* Pop up a message, end the transfer. */ | |
282 | -void | |
283 | -ft_complete(const char *errmsg) | |
299 | +/** | |
300 | + * Pop up a message, end the transfer, release resources. | |
301 | + * | |
302 | + */ | |
303 | +void ft_complete(H3270FT *session, const char *errmsg) | |
284 | 304 | { |
285 | 305 | double kbytes_sec = 0; |
286 | 306 | struct timeval t1; |
287 | 307 | |
308 | + CHECK_FT_HANDLE(session); | |
309 | + | |
288 | 310 | (void) gettimeofday(&t1, (struct timezone *)NULL); |
289 | 311 | kbytes_sec = (double)ft_length / 1024.0 / |
290 | 312 | ((double)(t1.tv_sec - starting_time.tv_sec) + |
291 | 313 | (double)(t1.tv_usec - starting_time.tv_usec) / 1.0e6); |
292 | 314 | |
293 | - Trace("%s",__FUNCTION__); | |
315 | + trace("%s",__FUNCTION__); | |
294 | 316 | |
295 | 317 | // Close the local file. |
296 | - if(ft_local_file) | |
297 | - { | |
298 | - fclose(ft_local_file); | |
299 | - ft_local_file = NULL; | |
300 | - } | |
301 | - else | |
318 | + if(session->ft_local_file) | |
302 | 319 | { |
303 | - Log("Unexpected call do %s(): ft_local_file is NULL",__FUNCTION__); | |
320 | + fclose(session->ft_local_file); | |
321 | + session->ft_local_file = NULL; | |
304 | 322 | } |
305 | 323 | |
306 | 324 | // Clean up the state. |
307 | 325 | set_ft_state(FT_NONE); |
308 | 326 | |
309 | - ft_update_length(); | |
327 | + ft_update_length(session); | |
310 | 328 | |
311 | 329 | if(callbacks && callbacks->complete) |
312 | 330 | callbacks->complete(errmsg,ft_length,kbytes_sec,ft_is_cut ? "CUT" : "DFT"); |
313 | 331 | |
332 | + if(session == ftsession) | |
333 | + ftsession = NULL; | |
334 | + | |
335 | + free(session); | |
336 | + | |
314 | 337 | } |
315 | 338 | |
316 | -/* Update the bytes-transferred count on the progress pop-up. */ | |
317 | -void | |
318 | -ft_update_length(void) | |
339 | +// Update the bytes-transferred count on the progress pop-up. | |
340 | +void ft_update_length(H3270FT *session) | |
319 | 341 | { |
320 | 342 | double kbytes_sec = 0; |
321 | 343 | |
344 | + CHECK_FT_HANDLE(session); | |
345 | + | |
322 | 346 | if(ft_length > 1024.0) |
323 | 347 | { |
324 | 348 | struct timeval t1; |
... | ... | @@ -336,11 +360,12 @@ ft_update_length(void) |
336 | 360 | |
337 | 361 | } |
338 | 362 | |
339 | -/* Process a transfer acknowledgement. */ | |
340 | -void | |
341 | -ft_running(Boolean is_cut) | |
363 | +// Process a transfer acknowledgement. | |
364 | +void ft_running(H3270FT *h, Boolean is_cut) | |
342 | 365 | { |
343 | - Trace("%s",__FUNCTION__); | |
366 | + trace("%s",__FUNCTION__); | |
367 | + | |
368 | + CHECK_FT_HANDLE(h); | |
344 | 369 | |
345 | 370 | ft_is_cut = is_cut; |
346 | 371 | ft_length = 0; |
... | ... | @@ -353,16 +378,17 @@ ft_running(Boolean is_cut) |
353 | 378 | if(callbacks && callbacks->running) |
354 | 379 | callbacks->running(is_cut); |
355 | 380 | |
356 | - ft_update_length(); | |
381 | + ft_update_length(h); | |
357 | 382 | |
358 | 383 | } |
359 | 384 | |
360 | 385 | // Process a protocol-generated abort. |
361 | -void | |
362 | -ft_aborting(void) | |
386 | +void ft_aborting(H3270FT *h) | |
363 | 387 | { |
364 | 388 | Trace("%s",__FUNCTION__); |
365 | 389 | |
390 | + CHECK_FT_HANDLE(h); | |
391 | + | |
366 | 392 | if (ft_state == FT_RUNNING || ft_state == FT_ABORT_WAIT) |
367 | 393 | set_ft_state(FT_ABORT_SENT); |
368 | 394 | |
... | ... | @@ -372,17 +398,20 @@ ft_aborting(void) |
372 | 398 | } |
373 | 399 | |
374 | 400 | /* Process a disconnect abort. */ |
375 | -static void ft_connected(H3270 *session, int ignored, void *dunno) | |
401 | +static void ft_connected(H3270 *session, int ignored, H3270FT *ft) | |
376 | 402 | { |
403 | + CHECK_FT_HANDLE(ft); | |
404 | + | |
377 | 405 | if (!CONNECTED && ft_state != FT_NONE) |
378 | - ft_complete(_("Host disconnected, transfer cancelled")); | |
406 | + ft_complete(ft,_("Host disconnected, transfer cancelled")); | |
379 | 407 | } |
380 | 408 | |
381 | 409 | /* Process an abort from no longer being in 3270 mode. */ |
382 | -static void ft_in3270(H3270 *session, int ignored, void *dunno) | |
410 | +static void ft_in3270(H3270 *session, int ignored, H3270FT *ft) | |
383 | 411 | { |
412 | + CHECK_FT_HANDLE(ft); | |
413 | + | |
384 | 414 | if (!IN_3270 && ft_state != FT_NONE) |
385 | - ft_complete(_("Not in 3270 mode, transfer cancelled")); | |
415 | + ft_complete(ft,_("Not in 3270 mode, transfer cancelled")); | |
386 | 416 | } |
387 | 417 | |
388 | -#endif | ... | ... |
src/lib3270/ft_cut.c
... | ... | @@ -130,7 +130,7 @@ static void cut_retransmit(void); |
130 | 130 | static void cut_data(void); |
131 | 131 | |
132 | 132 | static void cut_ack(void); |
133 | -static void cut_abort(const char *s, unsigned short reason); | |
133 | +static void cut_abort(unsigned short code, const char *fmt, ...); | |
134 | 134 | |
135 | 135 | static unsigned from6(unsigned char c); |
136 | 136 | static int xlate_getc(void); |
... | ... | @@ -160,7 +160,7 @@ upload_convert(unsigned char *buf, int len) |
160 | 160 | break; |
161 | 161 | } |
162 | 162 | if (quadrant >= NQ) { |
163 | - cut_abort(_("Data conversion error"),SC_ABORT_XMIT); | |
163 | + cut_abort(SC_ABORT_XMIT, "%s", _("Data conversion error")); | |
164 | 164 | return -1; |
165 | 165 | } |
166 | 166 | continue; |
... | ... | @@ -168,7 +168,7 @@ upload_convert(unsigned char *buf, int len) |
168 | 168 | |
169 | 169 | /* Make sure it's in a valid range. */ |
170 | 170 | if (c < 0x40 || c > 0xf9) { |
171 | - cut_abort(_("Data conversion error"),SC_ABORT_XMIT); | |
171 | + cut_abort(SC_ABORT_XMIT, "%s", _("Data conversion error")); | |
172 | 172 | return -1; |
173 | 173 | } |
174 | 174 | |
... | ... | @@ -289,7 +289,7 @@ ft_cut_data(void) |
289 | 289 | break; |
290 | 290 | default: |
291 | 291 | trace_ds("< FT unknown 0x%02x\n", h3270.ea_buf[O_FRAME_TYPE].cc); |
292 | - cut_abort(_(" Unknown frame type from host"), SC_ABORT_XMIT); | |
292 | + cut_abort(SC_ABORT_XMIT, "%s", _("Unknown frame type from host")); | |
293 | 293 | break; |
294 | 294 | } |
295 | 295 | } |
... | ... | @@ -307,51 +307,64 @@ cut_control_code(void) |
307 | 307 | |
308 | 308 | trace_ds("< FT CONTROL_CODE "); |
309 | 309 | code = (h3270.ea_buf[O_CC_STATUS_CODE].cc << 8) | h3270.ea_buf[O_CC_STATUS_CODE + 1].cc; |
310 | - switch (code) { | |
311 | - case SC_HOST_ACK: | |
310 | + switch (code) | |
311 | + { | |
312 | + case SC_HOST_ACK: | |
312 | 313 | trace_ds("HOST_ACK\n"); |
313 | 314 | cut_xfer_in_progress = True; |
314 | 315 | expanded_length = 0; |
315 | 316 | quadrant = -1; |
316 | 317 | xlate_buffered = 0; |
317 | 318 | cut_ack(); |
318 | - ft_running(True); | |
319 | + ft_running(NULL,True); | |
319 | 320 | break; |
320 | - case SC_XFER_COMPLETE: | |
321 | + | |
322 | + case SC_XFER_COMPLETE: | |
321 | 323 | trace_ds("XFER_COMPLETE\n"); |
322 | 324 | cut_ack(); |
323 | 325 | cut_xfer_in_progress = False; |
324 | - ft_complete((String)NULL); | |
326 | + ft_complete(NULL,N_( "Complete" ) ); | |
325 | 327 | break; |
326 | - case SC_ABORT_FILE: | |
327 | - case SC_ABORT_XMIT: | |
328 | + | |
329 | + case SC_ABORT_FILE: | |
330 | + case SC_ABORT_XMIT: | |
328 | 331 | trace_ds("ABORT\n"); |
329 | 332 | cut_xfer_in_progress = False; |
330 | 333 | cut_ack(); |
331 | 334 | |
332 | - if (ft_state == FT_ABORT_SENT && saved_errmsg != CN) { | |
335 | + if (ft_state == FT_ABORT_SENT && saved_errmsg != CN) | |
336 | + { | |
333 | 337 | buf = saved_errmsg; |
334 | 338 | saved_errmsg = CN; |
335 | - } else { | |
339 | + } | |
340 | + else | |
341 | + { | |
336 | 342 | bp = buf = Malloc(81); |
343 | + | |
337 | 344 | for (i = 0; i < 80; i++) |
338 | 345 | *bp++ = ebc2asc[h3270.ea_buf[O_CC_MESSAGE + i].cc]; |
346 | + | |
339 | 347 | *bp-- = '\0'; |
348 | + | |
340 | 349 | while (bp >= buf && *bp == ' ') |
341 | 350 | *bp-- = '\0'; |
351 | + | |
342 | 352 | if (bp >= buf && *bp == '$') |
343 | 353 | *bp-- = '\0'; |
354 | + | |
344 | 355 | while (bp >= buf && *bp == ' ') |
345 | 356 | *bp-- = '\0'; |
357 | + | |
346 | 358 | if (!*buf) |
347 | - strcpy(buf, _("Transfer cancelled by host")); | |
359 | + strcpy(buf, N_( "Transfer cancelled by host" ) ); | |
348 | 360 | } |
349 | - ft_complete(buf); | |
361 | + ft_complete(NULL,buf); | |
350 | 362 | Free(buf); |
351 | 363 | break; |
352 | - default: | |
364 | + | |
365 | + default: | |
353 | 366 | trace_ds("unknown 0x%04x\n", code); |
354 | - cut_abort(_("Unknown FT control code from host"), SC_ABORT_XMIT); | |
367 | + cut_abort(SC_ABORT_XMIT, "%s", _("Unknown FT control code from host")); | |
355 | 368 | break; |
356 | 369 | } |
357 | 370 | } |
... | ... | @@ -371,7 +384,7 @@ cut_data_request(void) |
371 | 384 | |
372 | 385 | trace_ds("< FT DATA_REQUEST %u\n", from6(seq)); |
373 | 386 | if (ft_state == FT_ABORT_WAIT) { |
374 | - cut_abort(_("Transfer cancelled by user"), SC_ABORT_FILE); | |
387 | + cut_abort(SC_ABORT_FILE,"%s",_("Transfer cancelled by user")); | |
375 | 388 | return; |
376 | 389 | } |
377 | 390 | |
... | ... | @@ -383,23 +396,20 @@ cut_data_request(void) |
383 | 396 | } |
384 | 397 | |
385 | 398 | /* Check for errors. */ |
386 | - if (ferror(ft_local_file)) { | |
399 | + if (ferror(ftsession->ft_local_file)) { | |
387 | 400 | int j; |
388 | - char *msg; | |
389 | 401 | |
390 | 402 | /* Clean out any data we may have written. */ |
391 | 403 | for (j = 0; j < count; j++) |
392 | 404 | ctlr_add(O_UP_DATA + j, 0, 0); |
393 | 405 | |
394 | 406 | /* Abort the transfer. */ |
395 | - msg = xs_buffer("read(%s): %s", ft_local_filename,strerror(errno)); | |
396 | - cut_abort(msg, SC_ABORT_FILE); | |
397 | - Free(msg); | |
407 | + cut_abort(SC_ABORT_FILE,_( "Error \"%s\" reading local file (rc=%d)" ), strerror(errno), errno); | |
398 | 408 | return; |
399 | 409 | } |
400 | 410 | |
401 | 411 | /* Send special data for EOF. */ |
402 | - if (!count && feof(ft_local_file)) { | |
412 | + if (!count && feof(ftsession->ft_local_file)) { | |
403 | 413 | ctlr_add(O_UP_DATA, EOF_DATA1, 0); |
404 | 414 | ctlr_add(O_UP_DATA+1, EOF_DATA2, 0); |
405 | 415 | count = 2; |
... | ... | @@ -421,7 +431,7 @@ cut_data_request(void) |
421 | 431 | |
422 | 432 | /* Send it up to the host. */ |
423 | 433 | trace_ds("> FT DATA %u\n", from6(seq)); |
424 | - ft_update_length(); | |
434 | + ft_update_length(NULL); | |
425 | 435 | expanded_length += count; |
426 | 436 | |
427 | 437 | lib3270_enter(&h3270); |
... | ... | @@ -434,7 +444,7 @@ static void |
434 | 444 | cut_retransmit(void) |
435 | 445 | { |
436 | 446 | trace_ds("< FT RETRANSMIT\n"); |
437 | - cut_abort(_("Transmission error"), SC_ABORT_XMIT); | |
447 | + cut_abort(SC_ABORT_XMIT,"%s",_("Transmission error")); | |
438 | 448 | } |
439 | 449 | |
440 | 450 | /* |
... | ... | @@ -465,7 +475,7 @@ cut_data(void) |
465 | 475 | |
466 | 476 | trace_ds("< FT DATA\n"); |
467 | 477 | if (ft_state == FT_ABORT_WAIT) { |
468 | - cut_abort(_("Transfer cancelled by user"), SC_ABORT_FILE); | |
478 | + cut_abort(SC_ABORT_FILE,"%s",_("Transfer cancelled by user")); | |
469 | 479 | return; |
470 | 480 | } |
471 | 481 | |
... | ... | @@ -473,7 +483,7 @@ cut_data(void) |
473 | 483 | raw_length = from6(h3270.ea_buf[O_DT_LEN].cc) << 6 | |
474 | 484 | from6(h3270.ea_buf[O_DT_LEN + 1].cc); |
475 | 485 | if ((int)raw_length > O_RESPONSE - O_DT_DATA) { |
476 | - cut_abort(_("Illegal frame length"), SC_ABORT_XMIT); | |
486 | + cut_abort(SC_ABORT_XMIT,"%s",_("Illegal frame length")); | |
477 | 487 | return; |
478 | 488 | } |
479 | 489 | for (i = 0; i < (int)raw_length; i++) |
... | ... | @@ -489,16 +499,11 @@ cut_data(void) |
489 | 499 | return; |
490 | 500 | |
491 | 501 | /* Write it to the file. */ |
492 | - if (fwrite((char *)cvbuf, conv_length, 1, ft_local_file) == 0) { | |
493 | - char *msg; | |
494 | - | |
495 | - msg = xs_buffer("write(%s): %s", ft_local_filename, | |
496 | - strerror(errno)); | |
497 | - cut_abort(msg, SC_ABORT_FILE); | |
498 | - Free(msg); | |
502 | + if (fwrite((char *)cvbuf, conv_length, 1, ftsession->ft_local_file) == 0) { | |
503 | + cut_abort(SC_ABORT_FILE,_( "Error \"%s\" writing to file (rc=%d)" ),strerror(errno),errno); | |
499 | 504 | } else { |
500 | 505 | ft_length += conv_length; |
501 | - ft_update_length(); | |
506 | + ft_update_length(NULL); | |
502 | 507 | cut_ack(); |
503 | 508 | } |
504 | 509 | } |
... | ... | @@ -515,11 +520,17 @@ static void cut_ack(void) |
515 | 520 | /* |
516 | 521 | * Abort a transfer in progress. |
517 | 522 | */ |
518 | -static void | |
519 | -cut_abort(const char *s, unsigned short reason) | |
523 | +static void cut_abort(unsigned short reason, const char *fmt, ...) | |
520 | 524 | { |
525 | + va_list args; | |
526 | + | |
527 | + if(saved_errmsg) | |
528 | + free(saved_errmsg); | |
529 | + | |
521 | 530 | /* Save the error message. */ |
522 | - Replace(saved_errmsg, NewString(s)); | |
531 | + va_start(args, fmt); | |
532 | + saved_errmsg = xs_vsprintf(fmt, args); | |
533 | + va_end(args); | |
523 | 534 | |
524 | 535 | /* Send the abort sequence. */ |
525 | 536 | ctlr_add(RO_FRAME_TYPE, RFT_CONTROL_CODE, 0); |
... | ... | @@ -531,7 +542,7 @@ cut_abort(const char *s, unsigned short reason) |
531 | 542 | lib3270_pfkey(&h3270,2); |
532 | 543 | |
533 | 544 | /* Update the in-progress pop-up. */ |
534 | - ft_aborting(); | |
545 | + ft_aborting(NULL); | |
535 | 546 | } |
536 | 547 | |
537 | 548 | /* |
... | ... | @@ -556,7 +567,7 @@ xlate_getc(void) |
556 | 567 | } |
557 | 568 | |
558 | 569 | /* Get the next byte from the file. */ |
559 | - c = fgetc(ft_local_file); | |
570 | + c = fgetc(ftsession->ft_local_file); | |
560 | 571 | if (c == EOF) |
561 | 572 | return c; |
562 | 573 | ft_length++; | ... | ... |
src/lib3270/ft_dft.c
... | ... | @@ -88,7 +88,8 @@ static unsigned char *dft_savebuf = NULL; |
88 | 88 | static int dft_savebuf_len = 0; |
89 | 89 | static int dft_savebuf_max = 0; |
90 | 90 | |
91 | -static void dft_abort(const char *s, unsigned short code); | |
91 | +static void dft_abort(unsigned short code, const char *fmt, ...); | |
92 | + | |
92 | 93 | static void dft_close_request(void); |
93 | 94 | static void dft_data_insert(struct data_buffer *data_bufr); |
94 | 95 | static void dft_get_request(void); |
... | ... | @@ -162,7 +163,7 @@ dft_open_request(unsigned short len, unsigned char *cp) |
162 | 163 | GET16(recsz, recszp); |
163 | 164 | name = (char *)cp + 31; |
164 | 165 | } else { |
165 | - dft_abort( _("Uknown DFT Open type from host"), TR_OPEN_REQ); | |
166 | + dft_abort(TR_OPEN_REQ, "%s", _("Uknown DFT Open type from host") ); | |
166 | 167 | return; |
167 | 168 | } |
168 | 169 | |
... | ... | @@ -182,7 +183,7 @@ dft_open_request(unsigned short len, unsigned char *cp) |
182 | 183 | message_flag = True; |
183 | 184 | else { |
184 | 185 | message_flag = False; |
185 | - ft_running(False); | |
186 | + ft_running(NULL,False); | |
186 | 187 | } |
187 | 188 | dft_eof = False; |
188 | 189 | recnum = 1; |
... | ... | @@ -214,8 +215,9 @@ dft_data_insert(struct data_buffer *data_bufr) |
214 | 215 | int my_length; |
215 | 216 | unsigned char *cp; |
216 | 217 | |
217 | - if (!message_flag && ft_state == FT_ABORT_WAIT) { | |
218 | - dft_abort( _("Transfer cancelled by user"), TR_DATA_INSERT); | |
218 | + if (!message_flag && ft_state == FT_ABORT_WAIT) | |
219 | + { | |
220 | + dft_abort(TR_DATA_INSERT, "%s", _("Transfer cancelled by user") ); | |
219 | 221 | return; |
220 | 222 | } |
221 | 223 | |
... | ... | @@ -254,13 +256,13 @@ dft_data_insert(struct data_buffer *data_bufr) |
254 | 256 | /* If transfer completed ok, use our msg. */ |
255 | 257 | if (memcmp(msgp, END_TRANSFER, strlen(END_TRANSFER)) == 0) { |
256 | 258 | Free(msgp); |
257 | - ft_complete((String)NULL); | |
259 | + ft_complete(NULL,NULL); | |
258 | 260 | } else if (ft_state == FT_ABORT_SENT && abort_string != CN) { |
259 | 261 | Free(msgp); |
260 | - ft_complete(abort_string); | |
262 | + ft_complete(NULL,abort_string); | |
261 | 263 | Replace(abort_string, CN); |
262 | 264 | } else { |
263 | - ft_complete((char *)msgp); | |
265 | + ft_complete(NULL,(char *)msgp); | |
264 | 266 | Free(msgp); |
265 | 267 | } |
266 | 268 | } else if (my_length > 0) { |
... | ... | @@ -285,9 +287,9 @@ dft_data_insert(struct data_buffer *data_bufr) |
285 | 287 | while (len) { |
286 | 288 | unsigned l = filter_len(s, len); |
287 | 289 | |
288 | - if (l) { | |
289 | - rv = fwrite(s, l, (size_t)1, | |
290 | - ft_local_file); | |
290 | + if (l) | |
291 | + { | |
292 | + rv = fwrite(s, l, (size_t)1,ftsession->ft_local_file); | |
291 | 293 | if (rv == 0) |
292 | 294 | break; |
293 | 295 | ft_length += l; |
... | ... | @@ -298,23 +300,17 @@ dft_data_insert(struct data_buffer *data_bufr) |
298 | 300 | len -= l; |
299 | 301 | } |
300 | 302 | } else { |
301 | - rv = fwrite((char *)data_bufr->data, my_length, | |
302 | - (size_t)1, ft_local_file); | |
303 | + rv = fwrite((char *)data_bufr->data, my_length,(size_t)1, ftsession->ft_local_file); | |
303 | 304 | ft_length += my_length; |
304 | 305 | } |
305 | 306 | |
306 | 307 | if (!rv) { |
307 | 308 | /* write failed */ |
308 | - char *buf; | |
309 | - | |
310 | - buf = xs_buffer( _( "write(%s): %s" ), ft_local_filename,strerror(errno)); | |
311 | - | |
312 | - dft_abort(buf, TR_DATA_INSERT); | |
313 | - Free(buf); | |
309 | + dft_abort(TR_DATA_INSERT, _( "Error \"%s\" writing to local file (rc=%d)" ) , strerror(errno), errno); | |
314 | 310 | } |
315 | 311 | |
316 | 312 | /* Add up amount transferred. */ |
317 | - ft_update_length(); | |
313 | + ft_update_length(ftsession); | |
318 | 314 | } |
319 | 315 | |
320 | 316 | /* Send an acknowledgement frame back. */ |
... | ... | @@ -351,7 +347,7 @@ dft_get_request(void) |
351 | 347 | trace_ds(" Get\n"); |
352 | 348 | |
353 | 349 | if (!message_flag && ft_state == FT_ABORT_WAIT) { |
354 | - dft_abort(_("Transfer cancelled by user"), TR_GET_REQ); | |
350 | + dft_abort(TR_GET_REQ, _( "Transfer cancelled by user" ) ); | |
355 | 351 | return; |
356 | 352 | } |
357 | 353 | |
... | ... | @@ -365,7 +361,7 @@ dft_get_request(void) |
365 | 361 | int c; |
366 | 362 | |
367 | 363 | /* Read one byte and do CR/LF translation. */ |
368 | - c = fgetc(ft_local_file); | |
364 | + c = fgetc(ftsession->ft_local_file); | |
369 | 365 | if (c == EOF) { |
370 | 366 | break; |
371 | 367 | } |
... | ... | @@ -375,7 +371,7 @@ dft_get_request(void) |
375 | 371 | * Not enough room to expand NL to |
376 | 372 | * CR/LF. |
377 | 373 | */ |
378 | - ungetc(c, ft_local_file); | |
374 | + ungetc(c, ftsession->ft_local_file); | |
379 | 375 | break; |
380 | 376 | } |
381 | 377 | *bufptr++ = '\r'; |
... | ... | @@ -388,7 +384,7 @@ dft_get_request(void) |
388 | 384 | total_read++; |
389 | 385 | } else { |
390 | 386 | /* Binary read. */ |
391 | - numread = fread(bufptr, 1, numbytes, ft_local_file); | |
387 | + numread = fread(bufptr, 1, numbytes, ftsession->ft_local_file); | |
392 | 388 | if (numread <= 0) { |
393 | 389 | break; |
394 | 390 | } |
... | ... | @@ -406,19 +402,15 @@ dft_get_request(void) |
406 | 402 | numbytes -= numread; |
407 | 403 | total_read += numread; |
408 | 404 | } |
409 | - if (feof(ft_local_file) || ferror(ft_local_file)) { | |
405 | + if (feof(ftsession->ft_local_file) || ferror(ftsession->ft_local_file)) { | |
410 | 406 | break; |
411 | 407 | } |
412 | 408 | } |
413 | 409 | |
414 | 410 | /* Check for read error. */ |
415 | - if (ferror(ft_local_file)) { | |
416 | - char *buf; | |
417 | - | |
418 | - buf = xs_buffer("read(%s): %s", ft_local_filename, | |
419 | - strerror(errno)); | |
420 | - dft_abort(buf, TR_GET_REQ); | |
421 | - Free(buf); | |
411 | + if (ferror(ftsession->ft_local_file)) | |
412 | + { | |
413 | + dft_abort(TR_GET_REQ, _( "Error \"%s\" reading from local file (rc=%d)" ), strerror(errno), errno); | |
422 | 414 | return; |
423 | 415 | } |
424 | 416 | |
... | ... | @@ -442,9 +434,11 @@ dft_get_request(void) |
442 | 434 | |
443 | 435 | ft_length += total_read; |
444 | 436 | |
445 | - if (feof(ft_local_file)) { | |
437 | + if (feof(ftsession->ft_local_file)) | |
438 | + { | |
446 | 439 | dft_eof = True; |
447 | 440 | } |
441 | + | |
448 | 442 | } else { |
449 | 443 | trace_ds("> WriteStructuredField FileTransferData EOF\n"); |
450 | 444 | *obptr++ = HIGH8(TR_GET_REQ); |
... | ... | @@ -470,7 +464,7 @@ dft_get_request(void) |
470 | 464 | |
471 | 465 | /* Write the data. */ |
472 | 466 | net_output(); |
473 | - ft_update_length(); | |
467 | + ft_update_length(ftsession); | |
474 | 468 | } |
475 | 469 | |
476 | 470 | /* Process a Close request. */ |
... | ... | @@ -493,10 +487,16 @@ dft_close_request(void) |
493 | 487 | } |
494 | 488 | |
495 | 489 | /* Abort a transfer. */ |
496 | -static void | |
497 | -dft_abort(const char *s, unsigned short code) | |
490 | +static void dft_abort(unsigned short code, const char *fmt, ...) | |
498 | 491 | { |
499 | - Replace(abort_string, NewString(s)); | |
492 | + va_list args; | |
493 | + | |
494 | + if(abort_string) | |
495 | + free(abort_string); | |
496 | + | |
497 | + va_start(args, fmt); | |
498 | + abort_string = xs_vsprintf(fmt, args); | |
499 | + va_end(args); | |
500 | 500 | |
501 | 501 | trace_ds("> WriteStructuredField FileTransferData Error\n"); |
502 | 502 | |
... | ... | @@ -512,7 +512,7 @@ dft_abort(const char *s, unsigned short code) |
512 | 512 | net_output(); |
513 | 513 | |
514 | 514 | /* Update the pop-up and state. */ |
515 | - ft_aborting(); | |
515 | + ft_aborting(ftsession); | |
516 | 516 | } |
517 | 517 | |
518 | 518 | /* Returns the number of bytes in s, limited by len, that aren't CRs or ^Zs. */ | ... | ... |
src/lib3270/ftc.h
... | ... | @@ -20,29 +20,24 @@ |
20 | 20 | |
21 | 21 | #if defined(X3270_FT) /*[*/ |
22 | 22 | |
23 | +#include <lib3270/filetransfer.h> | |
24 | + | |
23 | 25 | LIB3270_INTERNAL Boolean ascii_flag; |
24 | 26 | LIB3270_INTERNAL Boolean cr_flag; |
25 | 27 | LIB3270_INTERNAL unsigned long ft_length; |
26 | -LIB3270_INTERNAL FILE *ft_local_file; | |
27 | -extern char *ft_local_filename; | |
28 | + | |
29 | +LIB3270_INTERNAL H3270FT * ftsession; | |
30 | + | |
31 | +// LIB3270_INTERNAL FILE *ft_local_file; | |
32 | +// extern char *ft_local_filename; | |
28 | 33 | |
29 | 34 | LIB3270_INTERNAL Boolean ft_last_cr; |
30 | 35 | LIB3270_INTERNAL Boolean remap_flag; |
31 | 36 | |
32 | -LIB3270_INTERNAL void ft_init(void); | |
33 | -LIB3270_INTERNAL void ft_aborting(void); | |
34 | -LIB3270_INTERNAL void ft_complete(const char *errmsg); | |
35 | -LIB3270_INTERNAL void ft_running(Boolean is_cut); | |
36 | -LIB3270_INTERNAL void ft_update_length(void); | |
37 | - | |
38 | -/* | |
39 | -extern void PA_dialog_focus_action(Widget w, XEvent *event, String *parms, | |
40 | - Cardinal *num_parms); | |
41 | -extern void PA_dialog_next_action(Widget w, XEvent *event, String *parms, | |
42 | - Cardinal *num_parms); | |
43 | -extern void popup_ft(Widget w, XtPointer call_parms, XtPointer call_data); | |
44 | -extern void Transfer_action(Widget w, XEvent *event, String *parms, | |
45 | - Cardinal *num_parms); | |
46 | -*/ | |
37 | +LIB3270_INTERNAL void ft_init(H3270FT *h); | |
38 | +LIB3270_INTERNAL void ft_aborting(H3270FT *h); | |
39 | +LIB3270_INTERNAL void ft_complete(H3270FT *h, const char *errmsg); | |
40 | +LIB3270_INTERNAL void ft_running(H3270FT *h, Boolean is_cut); | |
41 | +LIB3270_INTERNAL void ft_update_length(H3270FT *h); | |
47 | 42 | |
48 | 43 | #endif /*]*/ | ... | ... |
... | ... | @@ -0,0 +1,57 @@ |
1 | +# | |
2 | +# "Software pw3270, desenvolvido com base nos códigos fontes do WC3270 e X3270 | |
3 | +# (Paul Mattes Paul.Mattes@usa.net), de emulação de terminal 3270 para acesso a | |
4 | +# aplicativos mainframe. Registro no INPI sob o nome G3270. | |
5 | +# | |
6 | +# Copyright (C) <2008> <Banco do Brasil S.A.> | |
7 | +# | |
8 | +# Este programa é software livre. Você pode redistribuí-lo e/ou modificá-lo sob | |
9 | +# os termos da GPL v.2 - Licença Pública Geral GNU, conforme publicado pela | |
10 | +# Free Software Foundation. | |
11 | +# | |
12 | +# Este programa é distribuído na expectativa de ser útil, mas SEM QUALQUER | |
13 | +# GARANTIA; sem mesmo a garantia implícita de COMERCIALIZAÇÃO ou de ADEQUAÇÃO | |
14 | +# A QUALQUER PROPÓSITO EM PARTICULAR. Consulte a Licença Pública Geral GNU para | |
15 | +# obter mais detalhes. | |
16 | +# | |
17 | +# Você deve ter recebido uma cópia da Licença Pública Geral GNU junto com este | |
18 | +# programa; se não, escreva para a Free Software Foundation, Inc., 59 Temple | |
19 | +# Place, Suite 330, Boston, MA, 02111-1307, USA | |
20 | +# | |
21 | +# Contatos: | |
22 | +# | |
23 | +# perry.werneck@gmail.com (Alexandre Perry de Souza Werneck) | |
24 | +# erico.mendonca@gmail.com (Erico Mascarenhas de Mendonça) | |
25 | +# licinio@bb.com.br (Licínio Luis Branco) | |
26 | +# kraucer@bb.com.br (Kraucer Fernandes Mazuco) | |
27 | +# | |
28 | + | |
29 | +PACKAGE_NAME=@PACKAGE_NAME@ | |
30 | + | |
31 | +EXEEXT=@EXEEXT@ | |
32 | +OBJEXT=@OBJEXT@ | |
33 | +CFLAGS=@CFLAGS@ @GTK_CFLAGS@ -DDATAROOTDIR=\"$(datarootdir)\" -I../../src/include | |
34 | +LIBS=@LIBS@ @GTK_LIBS@ | |
35 | + | |
36 | +CC=@CC@ | |
37 | +LD=@CC@ | |
38 | + | |
39 | +#---[ Rules ]------------------------------------------------------------------ | |
40 | + | |
41 | +$(OBJDBG)/%.o: %.c | |
42 | + @echo " CC `basename $@`" | |
43 | + @$(CC) $(CFLAGS) -o $@ -c $< | |
44 | + | |
45 | +#---[ Targets ]---------------------------------------------------------------- | |
46 | + | |
47 | +all: xml2pot$(EXEEXT) | |
48 | + | |
49 | +xml2pot$(EXEEXT): xml2pot$(OBJEXT) | |
50 | + @echo " CCLD `basename $@`" | |
51 | + @$(LD) -o $@ $^ $(LIBS) | |
52 | + | |
53 | +clean: | |
54 | + @rm -f *.$(OBJEXT) | |
55 | + @rm -f xml2pot$(EXEEXT) | |
56 | + | |
57 | + | ... | ... |