Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /trunk/teraterm/teraterm/filesys.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 9067 - (hide annotations) (download) (as text)
Sun Dec 20 12:09:26 2020 UTC (3 years, 3 months ago) by zmatsuo
File MIME type: text/x-c++src
File size: 16016 byte(s)
filesys.cpp (ファイル送信)を整理

- TFileVar を filesys.cpp ファイルローカルな構造体とした
  - filesys_send.h から filesys.cpp へ移動
  - filesys_send.h 削除
  - 不要、使用されない構造体メンバ削除、整理
- 使用されないコードなど削除
  - 未使用定数 GTF_BP に関するコードを削除
- FileTransEnd() -> FileSendEnd()
1 doda 6806 /*
2     * Copyright (C) 1994-1998 T. Teranishi
3 nmaya 9048 * (C) 2005- TeraTerm Project
4 doda 6806 * All rights reserved.
5     *
6 doda 6841 * Redistribution and use in source and binary forms, with or without
7     * modification, are permitted provided that the following conditions
8     * are met:
9 doda 6806 *
10 doda 6841 * 1. Redistributions of source code must retain the above copyright
11     * notice, this list of conditions and the following disclaimer.
12     * 2. Redistributions in binary form must reproduce the above copyright
13     * notice, this list of conditions and the following disclaimer in the
14     * documentation and/or other materials provided with the distribution.
15     * 3. The name of the author may not be used to endorse or promote products
16     * derived from this software without specific prior written permission.
17 doda 6806 *
18 doda 6841 * THIS SOFTWARE IS PROVIDED BY THE AUTHORS ``AS IS'' AND ANY EXPRESS OR
19     * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
20     * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
21     * IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY DIRECT, INDIRECT,
22     * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
23     * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
24     * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
25     * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
26     * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
27     * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 doda 6806 */
29 maya 3227
30     /* TERATERM.EXE, file transfer routines */
31 zmatsuo 7526 #include <stdio.h>
32     #include <io.h>
33     #include <process.h>
34 zmatsuo 8852 #include <windows.h>
35     #include <htmlhelp.h>
36     #include <assert.h>
37 zmatsuo 7526
38 maya 3227 #include "teraterm.h"
39     #include "tttypes.h"
40     #include "ttftypes.h"
41     #include "ftdlg.h"
42     #include "ttwinman.h"
43     #include "commlib.h"
44     #include "ttcommon.h"
45     #include "ttdde.h"
46     #include "ttlib.h"
47     #include "dlglib.h"
48 doda 3904 #include "vtterm.h"
49 zmatsuo 8852 #include "helpid.h"
50     #include "layer_for_unicode.h"
51 zmatsuo 8863 #include "codeconv.h"
52 yutakapon 5392
53 zmatsuo 8852 #include "filesys_log_res.h"
54 yutakapon 5162
55 zmatsuo 8866 #include "filesys.h"
56    
57 zmatsuo 9067 typedef struct {
58     HWND HMainWin;
59     HWND HWin;
60     char DlgCaption[40];
61    
62     char FullName[MAX_PATH];
63     int DirLen;
64    
65     HANDLE FileHandle;
66     LONG FileSize, ByteCount;
67    
68     int ProgStat;
69    
70     DWORD StartTime;
71     } TFileVar;
72     typedef TFileVar *PFileVar;
73    
74 doda 3904 #define FS_BRACKET_NONE 0
75     #define FS_BRACKET_START 1
76     #define FS_BRACKET_END 2
77    
78 zmatsuo 9057 static PFileVar SendVar = NULL;
79 maya 3227
80 doda 3904 static BOOL FileRetrySend, FileRetryEcho, FileCRSend, FileReadEOF, BinaryMode;
81 maya 3227 static BYTE FileByte;
82    
83 maya 6071 #define FILE_SEND_BUF_SIZE 8192
84     struct FileSendHandler {
85     CHAR buf[FILE_SEND_BUF_SIZE];
86     int pos;
87     int end;
88     };
89     static struct FileSendHandler FileSendHandler;
90     static int FileDlgRefresh;
91    
92 doda 3904 static int FileBracketMode = FS_BRACKET_NONE;
93     static int FileBracketPtr = 0;
94     static char BracketStartStr[] = "\033[200~";
95     static char BracketEndStr[] = "\033[201~";
96    
97 zmatsuo 9052 BOOL FSend = FALSE;
98 maya 3227
99     static PFileTransDlg SendDlg = NULL;
100    
101 zmatsuo 7526 static BOOL OpenFTDlg(PFileVar fv)
102 maya 3227 {
103     PFileTransDlg FTDlg;
104    
105     FTDlg = new CFileTransDlg();
106    
107 doda 4454 fv->StartTime = 0;
108     fv->ProgStat = 0;
109 zmatsuo 9067 cv.FilePause &= ~(OpSendFile);
110 doda 4454
111 maya 3227 if (FTDlg!=NULL)
112     {
113 zmatsuo 9056 CFileTransDlgInfo info;
114     info.UILanguageFile = ts.UILanguageFile;
115     info.OpId = OpSendFile;
116     info.DlgCaption = ToWcharA(fv->DlgCaption);
117     info.FileName = NULL;
118     info.FullName = ToWcharA(fv->FullName);
119 zmatsuo 9067 info.HideDialog = FALSE;
120 zmatsuo 9056 info.HMainWin = HVTWin;
121     FTDlg->Create(hInst, &info);
122     FTDlg->RefreshNum(0, fv->FileSize, fv->ByteCount);
123     free(info.DlgCaption);
124     free(info.FullName);
125 maya 3227 }
126    
127 zmatsuo 8894 SendDlg = FTDlg; /* File send */
128 maya 3227
129 doda 6947 fv->StartTime = GetTickCount();
130 maya 3227
131     return (FTDlg!=NULL);
132     }
133    
134 zmatsuo 9067 #if 0
135 zmatsuo 8857 static void ShowFTDlg(WORD OpId)
136 maya 3227 {
137 zmatsuo 8894 if (SendDlg != NULL) {
138     SendDlg->ShowWindow(SW_SHOWNORMAL);
139     SetForegroundWindow(SendDlg->GetSafeHwnd());
140 maya 3227 }
141     }
142 zmatsuo 9067 #endif
143 maya 3227
144 zmatsuo 9052 static BOOL NewFileVar(PFileVar *fv)
145 maya 3227 {
146     if ((*fv)==NULL)
147     {
148     *fv = (PFileVar)malloc(sizeof(TFileVar));
149     if ((*fv)!=NULL)
150     {
151 maya 7951 char FileDirExpanded[MAX_PATH];
152     ExpandEnvironmentStrings(ts.FileDir, FileDirExpanded, sizeof(FileDirExpanded));
153 maya 3227 memset(*fv, 0, sizeof(TFileVar));
154 maya 7951 strncpy_s((*fv)->FullName, sizeof((*fv)->FullName), FileDirExpanded, _TRUNCATE);
155 maya 3227 AppendSlash((*fv)->FullName,sizeof((*fv)->FullName));
156     (*fv)->DirLen = strlen((*fv)->FullName);
157 zmatsuo 9067 (*fv)->FileHandle = INVALID_HANDLE_VALUE;
158 maya 3227 (*fv)->HMainWin = HVTWin;
159     }
160     }
161    
162     return ((*fv)!=NULL);
163     }
164    
165 zmatsuo 9052 static void FreeFileVar(PFileVar *fv)
166 maya 3227 {
167     if ((*fv)!=NULL)
168     {
169 zmatsuo 9067 if ((*fv)->FileHandle != INVALID_HANDLE_VALUE) {
170     CloseHandle((*fv)->FileHandle);
171 maya 3227 }
172     free(*fv);
173     *fv = NULL;
174     }
175     }
176    
177 zmatsuo 9053 /* �_�C�A���O���������������� */
178     static void CenterCommonDialog(HWND hDlg)
179     {
180     /* hDlg���e���_�C�A���O���E�B���h�E�n���h�� */
181     HWND hWndDlgRoot = GetParent(hDlg);
182     CenterWindow(hWndDlgRoot, GetParent(hWndDlgRoot));
183     }
184    
185     static HFONT DlgFoptFont;
186     static UINT_PTR CALLBACK TransFnHook(HWND Dialog, UINT Message, WPARAM wParam, LPARAM lParam)
187     {
188     static const DlgTextInfo text_info[] = {
189     { IDC_FOPT, "DLG_FOPT" },
190     { IDC_FOPTBIN, "DLG_FOPT_BINARY" },
191     };
192     LPOPENFILENAME ofn;
193     LPWORD pw;
194     LPOFNOTIFY notify;
195     LOGFONT logfont;
196     HFONT font;
197     const char *UILanguageFile = ts.UILanguageFile;
198    
199     switch (Message) {
200     case WM_INITDIALOG:
201     ofn = (LPOPENFILENAME)lParam;
202     pw = (LPWORD)ofn->lCustData;
203     SetWindowLongPtr(Dialog, DWLP_USER, (LONG_PTR)pw);
204    
205     font = (HFONT)SendMessage(Dialog, WM_GETFONT, 0, 0);
206     GetObject(font, sizeof(LOGFONT), &logfont);
207     if (get_lang_font("DLG_TAHOMA_FONT", Dialog, &logfont, &DlgFoptFont, UILanguageFile)) {
208     SendDlgItemMessage(Dialog, IDC_FOPT, WM_SETFONT, (WPARAM)DlgFoptFont, MAKELPARAM(TRUE,0));
209     SendDlgItemMessage(Dialog, IDC_FOPTBIN, WM_SETFONT, (WPARAM)DlgFoptFont, MAKELPARAM(TRUE,0));
210     SendDlgItemMessage(Dialog, IDC_FOPTAPPEND, WM_SETFONT, (WPARAM)DlgFoptFont, MAKELPARAM(TRUE,0));
211     SendDlgItemMessage(Dialog, IDC_PLAINTEXT, WM_SETFONT, (WPARAM)DlgFoptFont, MAKELPARAM(TRUE,0));
212     SendDlgItemMessage(Dialog, IDC_TIMESTAMP, WM_SETFONT, (WPARAM)DlgFoptFont, MAKELPARAM(TRUE,0));
213     }
214     else {
215     DlgFoptFont = NULL;
216     }
217    
218     SetI18nDlgStrs("Tera Term", Dialog, text_info, _countof(text_info), UILanguageFile);
219    
220     SetRB(Dialog,*pw & 1,IDC_FOPTBIN,IDC_FOPTBIN);
221    
222     CenterCommonDialog(Dialog);
223    
224     return TRUE;
225     case WM_COMMAND: // for old style dialog
226     switch (LOWORD(wParam)) {
227     case IDOK:
228     pw = (LPWORD)GetWindowLongPtr(Dialog,DWLP_USER);
229     if (pw!=NULL)
230     GetRB(Dialog,pw,IDC_FOPTBIN,IDC_FOPTBIN);
231     if (DlgFoptFont != NULL) {
232     DeleteObject(DlgFoptFont);
233     }
234     break;
235     case IDCANCEL:
236     if (DlgFoptFont != NULL) {
237     DeleteObject(DlgFoptFont);
238     }
239     break;
240     }
241     break;
242     case WM_NOTIFY: // for Explorer-style dialog
243     notify = (LPOFNOTIFY)lParam;
244     switch (notify->hdr.code) {
245     case CDN_FILEOK:
246     pw = (LPWORD)GetWindowLongPtr(Dialog,DWLP_USER);
247     if (pw!=NULL)
248     GetRB(Dialog,pw,IDC_FOPTBIN,IDC_FOPTBIN);
249     if (DlgFoptFont != NULL) {
250     DeleteObject(DlgFoptFont);
251     }
252     break;
253     }
254     break;
255     }
256     return FALSE;
257     }
258    
259 zmatsuo 9067 static BOOL _GetTransFname(PFileVar fv, PCHAR CurDir, LPLONG Option)
260 zmatsuo 9053 {
261     char uimsg[MAX_UIMSG];
262     char *FNFilter;
263     OPENFILENAME ofn;
264     WORD optw;
265     wchar_t TempDir[MAXPATHLEN];
266     BOOL Ok;
267     char FileName[MAX_PATH];
268     const char *UILanguageFile = ts.UILanguageFile;
269    
270     /* save current dir */
271     _GetCurrentDirectoryW(_countof(TempDir), TempDir);
272    
273     memset(&ofn, 0, sizeof(OPENFILENAME));
274    
275     strncpy_s(fv->DlgCaption, sizeof(fv->DlgCaption),"Tera Term: ", _TRUNCATE);
276 zmatsuo 9067 get_lang_msg("FILEDLG_TRANS_TITLE_SENDFILE", uimsg, sizeof(uimsg), TitSendFile, UILanguageFile);
277     strncat_s(fv->DlgCaption, sizeof(fv->DlgCaption), uimsg, _TRUNCATE);
278 zmatsuo 9053
279     FNFilter = GetCommonDialogFilterA(ts.FileSendFilter, UILanguageFile);
280    
281     ExtractFileName(fv->FullName, FileName ,sizeof(FileName));
282     strncpy_s(fv->FullName, sizeof(fv->FullName), FileName, _TRUNCATE);
283     ofn.lStructSize = get_OPENFILENAME_SIZE();
284     ofn.hwndOwner = fv->HMainWin;
285     ofn.lpstrFilter = FNFilter;
286     ofn.nFilterIndex = 1;
287     ofn.lpstrFile = fv->FullName;
288     ofn.nMaxFile = sizeof(fv->FullName);
289     ofn.lpstrInitialDir = CurDir;
290    
291 zmatsuo 9067 ofn.Flags = OFN_FILEMUSTEXIST | OFN_HIDEREADONLY;
292     ofn.Flags |= OFN_ENABLETEMPLATE | OFN_ENABLEHOOK | OFN_EXPLORER | OFN_ENABLESIZING;
293     ofn.lpTemplateName = MAKEINTRESOURCE(IDD_FOPT);
294 zmatsuo 9053
295 zmatsuo 9067 ofn.lpfnHook = (LPOFNHOOKPROC)(&TransFnHook);
296     optw = (WORD)*Option;
297     ofn.lCustData = (LPARAM)&optw;
298 zmatsuo 9053
299     ofn.Flags |= OFN_SHOWHELP;
300    
301     ofn.lpstrTitle = fv->DlgCaption;
302    
303     ofn.hInstance = hInst;
304    
305     Ok = GetOpenFileName(&ofn);
306     free(FNFilter);
307    
308     if (Ok) {
309     *Option = (long)optw;
310    
311     fv->DirLen = ofn.nFileOffset;
312    
313     if (CurDir!=NULL) {
314     memcpy(CurDir,fv->FullName,fv->DirLen-1);
315     CurDir[fv->DirLen-1] = 0;
316     }
317     }
318     /* restore dir */
319     _SetCurrentDirectoryW(TempDir);
320     return Ok;
321     }
322    
323     static void _SetFileVar(PFileVar fv)
324     {
325     int i;
326     char uimsg[MAX_UIMSG];
327     char c;
328     const char *UILanguageFile = ts.UILanguageFile;
329    
330     GetFileNamePos(fv->FullName,&(fv->DirLen),&i);
331     c = fv->FullName[fv->DirLen];
332     if (c=='\\'||c=='/') fv->DirLen++;
333     strncpy_s(fv->DlgCaption, sizeof(fv->DlgCaption),"Tera Term: ", _TRUNCATE);
334 zmatsuo 9067 get_lang_msg("FILEDLG_TRANS_TITLE_SENDFILE", uimsg, sizeof(uimsg), TitSendFile, UILanguageFile);
335     strncat_s(fv->DlgCaption, sizeof(fv->DlgCaption), uimsg, _TRUNCATE);
336 zmatsuo 9053 }
337    
338 zmatsuo 8858 void FileSendStart(void)
339 maya 3227 {
340     if (! cv.Ready || FSend) return;
341     if (cv.ProtoFlag)
342     {
343     FreeFileVar(&SendVar);
344     return;
345     }
346    
347     if (! NewFileVar(&SendVar))
348     {
349     return;
350     }
351    
352     FSend = TRUE;
353    
354 maya 7951 if (strlen(&(SendVar->FullName[SendVar->DirLen])) == 0) {
355     char FileDirExpanded[MAX_PATH];
356 zmatsuo 9067 LONG Option = 0;
357 maya 7951 ExpandEnvironmentStrings(ts.FileDir, FileDirExpanded, sizeof(FileDirExpanded));
358 doda 6946 if (ts.TransBin)
359     Option |= LOGDLG_BINARY;
360 maya 3227 SendVar->FullName[0] = 0;
361 zmatsuo 9067 if (! _GetTransFname(SendVar, FileDirExpanded, &Option)) {
362     FileSendEnd();
363 maya 3227 return;
364     }
365 doda 6946 ts.TransBin = CheckFlag(Option, LOGDLG_BINARY);
366 maya 3227 }
367     else
368 zmatsuo 9053 _SetFileVar(SendVar);
369 maya 3227
370 zmatsuo 7290 SendVar->FileHandle = CreateFile(SendVar->FullName, GENERIC_READ, FILE_SHARE_READ, NULL,
371     OPEN_ALWAYS, FILE_ATTRIBUTE_NORMAL | FILE_FLAG_SEQUENTIAL_SCAN, NULL);
372 zmatsuo 9067 if (SendVar->FileHandle == INVALID_HANDLE_VALUE) {
373     FileSendEnd();
374 maya 3227 return;
375     }
376     SendVar->ByteCount = 0;
377     SendVar->FileSize = GetFSize(SendVar->FullName);
378    
379     TalkStatus = IdTalkFile;
380     FileRetrySend = FALSE;
381     FileRetryEcho = FALSE;
382     FileCRSend = FALSE;
383 doda 3904 FileReadEOF = FALSE;
384 maya 6071 FileSendHandler.pos = 0;
385     FileSendHandler.end = 0;
386     FileDlgRefresh = 0;
387 maya 3227
388 doda 3904 if (BracketedPasteMode()) {
389     FileBracketMode = FS_BRACKET_START;
390     FileBracketPtr = 0;
391     BinaryMode = TRUE;
392     }
393     else {
394     FileBracketMode = FS_BRACKET_NONE;
395     BinaryMode = ts.TransBin;
396     }
397    
398 maya 3227 if (! OpenFTDlg(SendVar))
399 zmatsuo 9067 FileSendEnd();
400 maya 3227 }
401    
402 zmatsuo 8949 BOOL FileSendStart2(const char *filename, int binary)
403     {
404     if (SendVar != NULL) {
405     return FALSE;
406     }
407     if (!NewFileVar(&SendVar)) {
408     return FALSE;
409     }
410    
411     SendVar->DirLen = 0;
412     strncpy_s(SendVar->FullName, sizeof(SendVar->FullName), filename, _TRUNCATE);
413     ts.TransBin = binary;
414     FileSendStart();
415    
416     return TRUE;
417     }
418    
419 zmatsuo 9067 void FileSendEnd(void)
420 maya 3227 {
421 zmatsuo 9067 if (FSend) {
422 maya 3227 FSend = FALSE;
423     TalkStatus = IdTalkKeyb;
424     if (SendDlg!=NULL)
425     {
426     SendDlg->DestroyWindow();
427     SendDlg = NULL;
428     }
429     FreeFileVar(&SendVar);
430     }
431    
432     EndDdeCmnd(0);
433     }
434    
435 zmatsuo 8857 void FileTransPause(WORD OpId, BOOL Pause)
436     {
437     if (Pause) {
438     cv.FilePause |= OpId;
439     }
440     else {
441     cv.FilePause &= ~OpId;
442     }
443     }
444    
445 zmatsuo 9067 static int FSOut1(BYTE b)
446 maya 3227 {
447 doda 3904 if (BinaryMode)
448 maya 3227 return CommBinaryOut(&cv,(PCHAR)&b,1);
449     else if ((b>=0x20) || (b==0x09) || (b==0x0A) || (b==0x0D))
450     return CommTextOut(&cv,(PCHAR)&b,1);
451     else
452     return 1;
453 doda 3861 }
454 maya 3227
455 zmatsuo 9067 static int FSEcho1(BYTE b)
456 maya 3227 {
457 doda 3904 if (BinaryMode)
458 maya 3227 return CommBinaryEcho(&cv,(PCHAR)&b,1);
459     else
460     return CommTextEcho(&cv,(PCHAR)&b,1);
461     }
462    
463 maya 6071 // �������������������������g��
464     // - BinaryMode == true
465     // - FileBracketMode == false
466     // - cv.TelFlag == false
467     // - ts.LocalEcho == 0
468 zmatsuo 8894 static void FileSendBinayBoost(void)
469 maya 6071 {
470     WORD c, fc;
471     LONG BCOld;
472     DWORD read_bytes;
473    
474     if ((SendDlg == NULL) ||
475     ((cv.FilePause & OpSendFile) != 0))
476     return;
477    
478     BCOld = SendVar->ByteCount;
479    
480     if (FileRetrySend)
481     {
482     c = CommRawOut(&cv, &(FileSendHandler.buf[FileSendHandler.pos]),
483     FileSendHandler.end - FileSendHandler.pos);
484     FileSendHandler.pos += c;
485     FileRetrySend = (FileSendHandler.end != FileSendHandler.pos);
486     if (FileRetrySend)
487     return;
488     }
489    
490     do {
491     if (FileSendHandler.pos == FileSendHandler.end) {
492 zmatsuo 7930 ReadFile(SendVar->FileHandle, &(FileSendHandler.buf[0]), sizeof(FileSendHandler.buf), &read_bytes, NULL);
493 maya 6071 fc = LOWORD(read_bytes);
494     FileSendHandler.pos = 0;
495     FileSendHandler.end = fc;
496     } else {
497     fc = FileSendHandler.end - FileSendHandler.end;
498     }
499    
500     if (fc != 0)
501     {
502     c = CommRawOut(&cv, &(FileSendHandler.buf[FileSendHandler.pos]),
503     FileSendHandler.end - FileSendHandler.pos);
504     FileSendHandler.pos += c;
505     FileRetrySend = (FileSendHandler.end != FileSendHandler.pos);
506     SendVar->ByteCount = SendVar->ByteCount + c;
507     if (FileRetrySend)
508     {
509 zmatsuo 9056 if (SendVar->ByteCount != BCOld) {
510     SendDlg->RefreshNum(SendVar->StartTime, SendVar->FileSize, SendVar->ByteCount);
511     }
512 maya 6071 return;
513     }
514     }
515     FileDlgRefresh = SendVar->ByteCount;
516 zmatsuo 9056 SendDlg->RefreshNum(SendVar->StartTime, SendVar->FileSize, SendVar->ByteCount);
517 maya 6071 BCOld = SendVar->ByteCount;
518     if (fc != 0)
519     return;
520     } while (fc != 0);
521    
522 zmatsuo 9067 FileSendEnd();
523 maya 6071 }
524    
525 zmatsuo 8858 void FileSend(void)
526 maya 3227 {
527     WORD c, fc;
528     LONG BCOld;
529 maya 5281 DWORD read_bytes;
530 maya 3227
531 maya 6115 if (cv.PortType == IdSerial && ts.FileSendHighSpeedMode &&
532 maya 6110 BinaryMode && !FileBracketMode && !cv.TelFlag &&
533 maya 6079 (ts.LocalEcho == 0) && (ts.Baud >= 115200)) {
534 maya 6071 return FileSendBinayBoost();
535     }
536    
537 maya 3227 if ((SendDlg==NULL) ||
538     ((cv.FilePause & OpSendFile) !=0))
539     return;
540    
541     BCOld = SendVar->ByteCount;
542    
543     if (FileRetrySend)
544     {
545     FileRetryEcho = (ts.LocalEcho>0);
546     c = FSOut1(FileByte);
547     FileRetrySend = (c==0);
548     if (FileRetrySend)
549     return;
550     }
551    
552     if (FileRetryEcho)
553     {
554     c = FSEcho1(FileByte);
555     FileRetryEcho = (c==0);
556     if (FileRetryEcho)
557     return;
558     }
559    
560     do {
561 doda 3904 if (FileBracketMode == FS_BRACKET_START) {
562     FileByte = BracketStartStr[FileBracketPtr++];
563     fc = 1;
564 maya 3227
565 doda 3904 if (FileBracketPtr >= sizeof(BracketStartStr) - 1) {
566     FileBracketMode = FS_BRACKET_END;
567     FileBracketPtr = 0;
568     BinaryMode = ts.TransBin;
569     }
570     }
571     else if (! FileReadEOF) {
572 zmatsuo 7930 ReadFile(SendVar->FileHandle, &FileByte, 1, &read_bytes, NULL);
573 maya 5281 fc = LOWORD(read_bytes);
574 maya 3227 SendVar->ByteCount = SendVar->ByteCount + fc;
575 doda 3904
576     if (FileCRSend && (fc==1) && (FileByte==0x0A)) {
577 zmatsuo 7930 ReadFile(SendVar->FileHandle, &FileByte, 1, &read_bytes, NULL);
578 maya 5281 fc = LOWORD(read_bytes);
579 doda 3904 SendVar->ByteCount = SendVar->ByteCount + fc;
580     }
581 maya 3227 }
582 doda 3904 else {
583     fc = 0;
584     }
585 maya 3227
586 doda 3904 if (fc == 0 && FileBracketMode == FS_BRACKET_END) {
587     FileReadEOF = TRUE;
588     FileByte = BracketEndStr[FileBracketPtr++];
589     fc = 1;
590     BinaryMode = TRUE;
591    
592     if (FileBracketPtr >= sizeof(BracketEndStr) - 1) {
593     FileBracketMode = FS_BRACKET_NONE;
594     FileBracketPtr = 0;
595     }
596     }
597    
598    
599 maya 3227 if (fc!=0)
600     {
601     c = FSOut1(FileByte);
602     FileCRSend = (ts.TransBin==0) && (FileByte==0x0D);
603     FileRetrySend = (c==0);
604     if (FileRetrySend)
605     {
606 zmatsuo 9056 if (SendVar->ByteCount != BCOld) {
607     SendDlg->RefreshNum(SendVar->StartTime, SendVar->FileSize, SendVar->ByteCount);
608     }
609 maya 3227 return;
610     }
611     if (ts.LocalEcho>0)
612     {
613     c = FSEcho1(FileByte);
614     FileRetryEcho = (c==0);
615     if (FileRetryEcho)
616     return;
617     }
618     }
619 doda 3904 if ((fc==0) || ((SendVar->ByteCount % 100 == 0) && (FileBracketPtr == 0))) {
620 zmatsuo 9056 SendDlg->RefreshNum(SendVar->StartTime, SendVar->FileSize, SendVar->ByteCount);
621 maya 3227 BCOld = SendVar->ByteCount;
622     if (fc!=0)
623     return;
624     }
625     } while (fc!=0);
626    
627 zmatsuo 9067 FileSendEnd();
628 maya 3227 }
629    
630 zmatsuo 8948 BOOL IsSendVarNULL()
631     {
632     return SendVar == NULL;
633     }

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26