annotate src/uicommon/gftpui.c @ 972:e1167c901484

2008-11-30 Brian Masney <masneyb@gftp.org> * src/uicommon/gftpui.c - fixed word wrapping in the text port when the application first starts up.
author masneyb
date Sun, 30 Nov 2008 20:03:50 +0000
parents 4c7a58ef26c1
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1 /*****************************************************************************/
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
2 /* gftpui.c - UI related functions for gFTP */
885
1808cebed602 2007-3-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 879
diff changeset
3 /* Copyright (C) 1998-2007 Brian Masney <masneyb@gftp.org> */
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
4 /* */
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
5 /* This program is free software; you can redistribute it and/or modify */
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
6 /* it under the terms of the GNU General Public License as published by */
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
7 /* the Free Software Foundation; either version 2 of the License, or */
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
8 /* (at your option) any later version. */
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
9 /* */
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
10 /* This program is distributed in the hope that it will be useful, */
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
11 /* but WITHOUT ANY WARRANTY; without even the implied warranty of */
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
12 /* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the */
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
13 /* GNU General Public License for more details. */
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
14 /* */
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
15 /* You should have received a copy of the GNU General Public License */
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
16 /* along with this program; if not, write to the Free Software */
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111 USA */
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
18 /*****************************************************************************/
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
19
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
20 #include "gftpui.h"
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
21 static const char cvsid[] = "$Id$";
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
22
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
23 GStaticMutex gftpui_common_transfer_mutex = G_STATIC_MUTEX_INIT;
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
24 volatile sig_atomic_t gftpui_common_child_process_done = 0;
873
42f9ce5e4bff 2007-2-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 865
diff changeset
25 volatile sig_atomic_t gftpui_common_num_child_threads = 0;
518
c6a6e908dbaf 2004-7-27 Brian Masney <masneyb@gftp.org>
masneyb
parents: 517
diff changeset
26 static gftp_logging_func gftpui_common_logfunc;
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
27
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
28 static void *
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
29 _gftpui_common_thread_callback (void * data)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
30 {
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
31 intptr_t network_timeout, sleep_time;
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
32 gftpui_callback_data * cdata;
783
6f766002bff2 2006-7-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 775
diff changeset
33 struct timespec ts;
873
42f9ce5e4bff 2007-2-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 865
diff changeset
34 int success;
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
35
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
36 cdata = data;
873
42f9ce5e4bff 2007-2-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 865
diff changeset
37 gftpui_common_num_child_threads++;
42f9ce5e4bff 2007-2-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 865
diff changeset
38
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
39 gftp_lookup_request_option (cdata->request, "network_timeout",
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
40 &network_timeout);
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
41 gftp_lookup_request_option (cdata->request, "sleep_time",
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
42 &sleep_time);
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
43
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
44 success = GFTP_ERETRYABLE;
873
42f9ce5e4bff 2007-2-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 865
diff changeset
45 while (1)
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
46 {
873
42f9ce5e4bff 2007-2-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 865
diff changeset
47 if (network_timeout > 0)
42f9ce5e4bff 2007-2-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 865
diff changeset
48 alarm (network_timeout);
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
49
873
42f9ce5e4bff 2007-2-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 865
diff changeset
50 success = cdata->run_function (cdata);
42f9ce5e4bff 2007-2-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 865
diff changeset
51 alarm (0);
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
52
873
42f9ce5e4bff 2007-2-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 865
diff changeset
53 if (cdata->request->cancel)
42f9ce5e4bff 2007-2-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 865
diff changeset
54 {
677
8990a8a26ccf 2005-1-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 652
diff changeset
55 cdata->request->logging_function (gftp_logging_error, cdata->request,
873
42f9ce5e4bff 2007-2-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 865
diff changeset
56 _("Operation canceled\n"));
42f9ce5e4bff 2007-2-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 865
diff changeset
57 break;
42f9ce5e4bff 2007-2-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 865
diff changeset
58 }
42f9ce5e4bff 2007-2-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 865
diff changeset
59
42f9ce5e4bff 2007-2-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 865
diff changeset
60 if (success == GFTP_EFATAL || success == 0 || cdata->retries == 0)
42f9ce5e4bff 2007-2-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 865
diff changeset
61 break;
783
6f766002bff2 2006-7-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 775
diff changeset
62
873
42f9ce5e4bff 2007-2-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 865
diff changeset
63 cdata->retries--;
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
64 cdata->request->logging_function (gftp_logging_error, cdata->request,
873
42f9ce5e4bff 2007-2-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 865
diff changeset
65 _("Waiting %d seconds until trying to connect again\n"),
42f9ce5e4bff 2007-2-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 865
diff changeset
66 sleep_time);
42f9ce5e4bff 2007-2-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 865
diff changeset
67
42f9ce5e4bff 2007-2-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 865
diff changeset
68 ts.tv_sec = sleep_time;
42f9ce5e4bff 2007-2-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 865
diff changeset
69 ts.tv_nsec = 0;
42f9ce5e4bff 2007-2-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 865
diff changeset
70 nanosleep (&ts, NULL);
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
71 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
72
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
73 cdata->request->stopable = 0;
873
42f9ce5e4bff 2007-2-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 865
diff changeset
74 gftpui_common_num_child_threads--;
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
75
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
76 return (GINT_TO_POINTER (success));
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
77 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
78
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
79
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
80 int
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
81 gftpui_common_run_callback_function (gftpui_callback_data * cdata)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
82 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
83 int ret;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
84
451
83cfffb2878a 2004-3-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 442
diff changeset
85 if (!cdata->dont_check_connection && gftpui_check_reconnect (cdata) < 0)
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
86 return (0);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
87
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
88 if (gftp_protocols[cdata->request->protonum].use_threads)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
89 ret = GPOINTER_TO_INT (gftpui_generic_thread (_gftpui_common_thread_callback, cdata));
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
90 else
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
91 ret = GPOINTER_TO_INT (cdata->run_function (cdata));
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
92
511
c3ff4479a92d 2004-7-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 510
diff changeset
93 if (ret == 0 && !cdata->dont_refresh)
514
e55d8b35d809 2004-7-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 511
diff changeset
94 gftpui_refresh (cdata->uidata, !cdata->dont_clear_cache);
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
95
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
96 return (ret == 0);
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
97 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
98
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
99
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
100 static RETSIGTYPE
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
101 gftpui_common_signal_handler (int signo)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
102 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
103 signal (signo, gftpui_common_signal_handler);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
104
873
42f9ce5e4bff 2007-2-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 865
diff changeset
105 if (!gftpui_common_num_child_threads && signo == SIGINT)
766
1ad4eb5c29de 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 677
diff changeset
106 exit (EXIT_FAILURE);
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
107 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
108
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
109
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
110 static RETSIGTYPE
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
111 gftpui_common_sig_child (int signo)
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
112 {
498
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 483
diff changeset
113 int ret;
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 483
diff changeset
114
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 483
diff changeset
115 if (gftpui_common_child_process_done == -1)
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 483
diff changeset
116 {
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 483
diff changeset
117 /* Running from text port */
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 483
diff changeset
118 while (waitpid (-1, &ret, WNOHANG) > 0)
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 483
diff changeset
119 {
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 483
diff changeset
120 /* Nothing */
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 483
diff changeset
121 }
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 483
diff changeset
122 }
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 483
diff changeset
123 else
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 483
diff changeset
124 gftpui_common_child_process_done = 1;
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
125 }
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
126
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
127
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
128 void
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
129 gftpui_common_init (int *argc, char ***argv, gftp_logging_func logfunc)
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
130 {
483
4376ffeab64e 2004-6-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 469
diff changeset
131 char *share_dir;
4376ffeab64e 2004-6-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 469
diff changeset
132
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
133 gftp_locale_init ();
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
134
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
135 signal (SIGCHLD, gftpui_common_sig_child);
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
136 signal (SIGPIPE, SIG_IGN);
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
137 signal (SIGALRM, gftpui_common_signal_handler);
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
138 signal (SIGINT, gftpui_common_signal_handler);
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
139
483
4376ffeab64e 2004-6-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 469
diff changeset
140 share_dir = gftp_get_share_dir ();
4376ffeab64e 2004-6-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 469
diff changeset
141 gftp_read_config_file (share_dir);
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
142 if (gftp_parse_command_line (argc, argv) != 0)
766
1ad4eb5c29de 2006-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 677
diff changeset
143 exit (EXIT_FAILURE);
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
144
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
145 gftpui_common_logfunc = logfunc;
498
76c4e4cd108e 2004-7-12 Brian Masney <masneyb@gftp.org>
masneyb
parents: 483
diff changeset
146 gftpui_common_child_process_done = -1;
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
147 }
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
148
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
149
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
150 void
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
151 gftpui_common_about (gftp_logging_func logging_function, gpointer logdata)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
152 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
153 char *str;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
154
972
e1167c901484 2008-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 970
diff changeset
155 logging_function (gftp_logging_misc, logdata, "%s, Copyright (C) 1998-2008 Brian Masney <masneyb@gftp.org>. If you have any questions, comments, or suggestions about this program, please feel free to email them to me. You can always find out the latest news about gFTP from my website at http://www.gftp.org/\n", gftp_version);
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
156 logging_function (gftp_logging_misc, logdata, _("gFTP comes with ABSOLUTELY NO WARRANTY; for details, see the COPYING file. This is free software, and you are welcome to redistribute it under certain conditions; for details, see the COPYING file\n"));
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
157
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
158 str = _("Translated by");
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
159 if (strcmp (str, "Translated by") != 0)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
160 logging_function (gftp_logging_misc, logdata, "%s\n", str);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
161 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
162
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
163
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
164 static int
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
165 gftpui_common_cmd_about (void *uidata, gftp_request * request,
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
166 void *other_uidata, gftp_request * other_request,
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
167 const char *command)
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
168 {
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
169 gftpui_common_about (gftpui_common_logfunc, NULL);
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
170 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
171 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
172
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
173
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
174 static int
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
175 gftpui_common_cmd_ascii (void *uidata, gftp_request * request,
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
176 void *other_uidata, gftp_request * other_request,
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
177 const char *command)
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
178 {
350
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
179 gftp_set_global_option ("ascii_transfers", GINT_TO_POINTER(1));
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
180 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
181 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
182
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
183
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
184 static int
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
185 gftpui_common_cmd_binary (void *uidata, gftp_request * request,
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
186 void *other_uidata, gftp_request * other_request,
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
187 const char *command)
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
188 {
350
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
189 gftp_set_global_option ("ascii_transfers", GINT_TO_POINTER(0));
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
190 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
191 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
192
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
193
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
194 static int
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
195 gftpui_common_cmd_chmod (void *uidata, gftp_request * request,
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
196 void *other_uidata, gftp_request * other_request,
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
197 const char *command)
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
198 {
350
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
199 gftpui_callback_data * cdata;
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
200 char *pos;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
201
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
202 if (!GFTP_IS_CONNECTED (request))
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
203 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
204 request->logging_function (gftp_logging_error, request,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
205 _("Error: Not connected to a remote site\n"));
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
206
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
207 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
208 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
209
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
210 if ((pos = strchr (command, ' ')) != NULL)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
211 *pos++ = '\0';
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
212
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
213 if (*command == '\0' || pos == NULL || *pos == '\0')
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
214 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
215 request->logging_function (gftp_logging_error, request,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
216 _("usage: chmod <mode> <file>\n"));
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
217 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
218 else
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
219 {
350
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
220 cdata = g_malloc0 (sizeof (*cdata));
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
221 cdata->request = request;
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
222 cdata->uidata = uidata;
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
223 cdata->input_string = (char *) command;
350
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
224 cdata->source_string = pos;
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
225 cdata->run_function = gftpui_common_run_chmod;
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
226
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
227 gftpui_common_run_callback_function (cdata);
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
228
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
229 g_free (cdata);
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
230 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
231
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
232 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
233 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
234
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
235
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
236 static int
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
237 gftpui_common_cmd_rename (void *uidata, gftp_request * request,
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
238 void *other_uidata, gftp_request * other_request,
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
239 const char *command)
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
240 {
350
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
241 gftpui_callback_data * cdata;
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
242 char *pos;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
243
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
244 if (!GFTP_IS_CONNECTED (request))
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
245 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
246 request->logging_function (gftp_logging_error, request,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
247 _("Error: Not connected to a remote site\n"));
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
248 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
249 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
250
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
251 if ((pos = strchr (command, ' ')) != NULL)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
252 *pos++ = '\0';
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
253
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
254 if (*command == '\0' || pos == NULL || *pos == '\0')
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
255 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
256 request->logging_function (gftp_logging_error, request,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
257 _("usage: rename <old name> <new name>\n"));
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
258 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
259 else
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
260 {
350
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
261 cdata = g_malloc0 (sizeof (*cdata));
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
262 cdata->request = request;
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
263 cdata->uidata = uidata;
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
264 cdata->source_string = (char *) command;
350
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
265 cdata->input_string = pos;
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
266 cdata->run_function = gftpui_common_run_rename;
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
267
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
268 gftpui_common_run_callback_function (cdata);
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
269
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
270 g_free (cdata);
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
271 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
272
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
273 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
274 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
275
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
276
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
277 static int
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
278 gftpui_common_cmd_delete (void *uidata, gftp_request * request,
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
279 void *other_uidata, gftp_request * other_request,
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
280 const char *command)
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
281 {
350
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
282 gftpui_callback_data * cdata;
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
283
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
284 if (!GFTP_IS_CONNECTED (request))
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
285 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
286 request->logging_function (gftp_logging_error, request,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
287 _("Error: Not connected to a remote site\n"));
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
288 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
289 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
290 else if (*command == '\0')
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
291 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
292 request->logging_function (gftp_logging_error, request,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
293 _("usage: delete <file>\n"));
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
294 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
295 else
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
296 {
350
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
297 cdata = g_malloc0 (sizeof (*cdata));
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
298 cdata->request = request;
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
299 cdata->uidata = uidata;
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
300 cdata->input_string = (char *) command;
350
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
301 cdata->run_function = gftpui_common_run_delete;
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
302
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
303 gftpui_common_run_callback_function (cdata);
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
304
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
305 g_free (cdata);
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
306 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
307
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
308 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
309 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
310
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
311
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
312 static int
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
313 gftpui_common_cmd_rmdir (void *uidata, gftp_request * request,
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
314 void *other_uidata, gftp_request * other_request,
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
315 const char *command)
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
316 {
350
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
317 gftpui_callback_data * cdata;
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
318
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
319 if (!GFTP_IS_CONNECTED (request))
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
320 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
321 request->logging_function (gftp_logging_error, request,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
322 _("Error: Not connected to a remote site\n"));
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
323 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
324 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
325 else if (*command == '\0')
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
326 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
327 request->logging_function (gftp_logging_error, request,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
328 _("usage: rmdir <directory>\n"));
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
329 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
330 else
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
331 {
350
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
332 cdata = g_malloc0 (sizeof (*cdata));
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
333 cdata->request = request;
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
334 cdata->uidata = uidata;
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
335 cdata->input_string = (char *) command;
350
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
336 cdata->run_function = gftpui_common_run_rmdir;
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
337
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
338 gftpui_common_run_callback_function (cdata);
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
339
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
340 g_free (cdata);
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
341 }
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
342
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
343 return (1);
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
344 }
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
345
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
346
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
347 static int
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
348 gftpui_common_cmd_site (void *uidata, gftp_request * request,
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
349 void *other_uidata, gftp_request * other_request,
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
350 const char *command)
350
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
351 {
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
352 gftpui_callback_data * cdata;
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
353
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
354 if (!GFTP_IS_CONNECTED (request))
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
355 {
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
356 request->logging_function (gftp_logging_error, request,
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
357 _("Error: Not connected to a remote site\n"));
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
358 return (1);
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
359 }
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
360 else if (*command == '\0')
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
361 {
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
362 request->logging_function (gftp_logging_error, request,
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
363 _("usage: site <site command>\n"));
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
364 }
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
365 else
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
366 {
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
367 cdata = g_malloc0 (sizeof (*cdata));
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
368 cdata->request = request;
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
369 cdata->uidata = uidata;
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
370 cdata->input_string = (char *) command;
350
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
371 cdata->run_function = gftpui_common_run_site;
806
0807446c6f11 2006-8-10 Brian Masney <masneyb@gftp.org>
masneyb
parents: 795
diff changeset
372 cdata->toggled = 1;
350
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
373
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
374 gftpui_common_run_callback_function (cdata);
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
375
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
376 g_free (cdata);
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
377 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
378
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
379 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
380 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
381
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
382
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
383 static int
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
384 gftpui_common_cmd_mkdir (void *uidata, gftp_request * request,
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
385 void *other_uidata, gftp_request * other_request,
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
386 const char *command)
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
387 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
388 gftpui_callback_data * cdata;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
389
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
390 if (!GFTP_IS_CONNECTED (request))
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
391 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
392 request->logging_function (gftp_logging_error, request,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
393 _("Error: Not connected to a remote site\n"));
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
394 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
395 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
396 else if (*command == '\0')
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
397 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
398 request->logging_function (gftp_logging_error, request,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
399 _("usage: mkdir <new directory>\n"));
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
400 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
401 else
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
402 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
403 cdata = g_malloc0 (sizeof (*cdata));
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
404 cdata->request = request;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
405 cdata->uidata = uidata;
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
406 cdata->input_string = (char *) command;
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
407 cdata->run_function = gftpui_common_run_mkdir;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
408
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
409 gftpui_common_run_callback_function (cdata);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
410
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
411 g_free (cdata);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
412 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
413
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
414 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
415 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
416
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
417
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
418 static int
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
419 gftpui_common_cmd_chdir (void *uidata, gftp_request * request,
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
420 void *other_uidata, gftp_request * other_request,
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
421 const char *command)
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
422 {
350
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
423 gftpui_callback_data * cdata;
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
424 char *tempstr, *newdir = NULL;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
425
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
426 if (!GFTP_IS_CONNECTED (request))
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
427 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
428 request->logging_function (gftp_logging_error, request,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
429 _("Error: Not connected to a remote site\n"));
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
430 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
431 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
432 else if (*command == '\0')
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
433 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
434 request->logging_function (gftp_logging_error, request,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
435 _("usage: chdir <directory>\n"));
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
436 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
437 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
438 else if (request->protonum == GFTP_LOCAL_NUM)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
439 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
440 if (*command != '/' && request->directory != NULL)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
441 {
555
7f54d0c0edbc 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 553
diff changeset
442 tempstr = gftp_build_path (request, request->directory, command,
7f54d0c0edbc 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 553
diff changeset
443 NULL);
7f54d0c0edbc 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 553
diff changeset
444 newdir = gftp_expand_path (request, tempstr);
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
445 g_free (tempstr);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
446 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
447 else
555
7f54d0c0edbc 2004-9-17 Brian Masney <masneyb@gftp.org>
masneyb
parents: 553
diff changeset
448 newdir = gftp_expand_path (request, command);
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
449
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
450 if (newdir == NULL)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
451 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
452 request->logging_function (gftp_logging_error, request,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
453 _("usage: chdir <directory>\n"));
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
454 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
455 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
456 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
457
350
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
458 cdata = g_malloc0 (sizeof (*cdata));
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
459 cdata->request = request;
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
460 cdata->uidata = uidata;
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
461 cdata->input_string = newdir != NULL ? newdir : (char *) command;
350
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
462 cdata->run_function = gftpui_common_run_chdir;
514
e55d8b35d809 2004-7-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 511
diff changeset
463 cdata->dont_clear_cache = 1;
350
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
464
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
465 gftpui_common_run_callback_function (cdata);
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
466
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
467 g_free (cdata);
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
468
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
469 if (newdir != NULL)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
470 g_free (newdir);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
471
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
472 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
473 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
474
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
475
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
476 static int
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
477 gftpui_common_cmd_close (void *uidata, gftp_request * request,
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
478 void *other_uidata, gftp_request * other_request,
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
479 const char *command)
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
480 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
481 gftp_disconnect (request);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
482 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
483 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
484
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
485
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
486 static int
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
487 gftpui_common_cmd_pwd (void *uidata, gftp_request * request,
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
488 void *other_uidata, gftp_request * other_request,
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
489 const char *command)
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
490 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
491 if (!GFTP_IS_CONNECTED (request))
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
492 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
493 request->logging_function (gftp_logging_error, request,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
494 _("Error: Not connected to a remote site\n"));
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
495 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
496 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
497
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
498 request->logging_function (gftp_logging_misc, request,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
499 "%s\n", request->directory);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
500
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
501 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
502 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
503
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
504
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
505 static int
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
506 gftpui_common_cmd_quit (void *uidata, gftp_request * request,
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
507 void *other_uidata, gftp_request * other_request,
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
508 const char *command)
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
509 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
510 gftp_shutdown();
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
511
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
512 return (0);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
513 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
514
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
515
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
516 static int
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
517 gftpui_common_cmd_clear (void *uidata, gftp_request * request,
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
518 void *other_uidata, gftp_request * other_request,
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
519 const char *command)
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
520 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
521 if (strcasecmp (command, "cache") == 0)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
522 gftp_clear_cache_files ();
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
523 else
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
524 {
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
525 gftpui_common_logfunc (gftp_logging_error, request,
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
526 _("Invalid argument\n"));
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
527 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
528
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
529 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
530 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
531
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
532
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
533 static int
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
534 gftpui_common_clear_show_subhelp (const char *topic)
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
535 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
536 if (strcmp (topic, "cache") == 0)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
537 {
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
538 gftpui_common_logfunc (gftp_logging_misc, NULL,
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
539 _("Clear the directory cache\n"));
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
540 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
541 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
542
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
543 return (0);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
544 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
545
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
546
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
547 static int
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
548 gftpui_common_set_show_subhelp (const char *topic)
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
549 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
550 gftp_config_vars * cv;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
551
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
552 if ((cv = g_hash_table_lookup (gftp_global_options_htable, topic)) != NULL)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
553 {
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
554 gftpui_common_logfunc (gftp_logging_misc, NULL, "%s\n", cv->comment);
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
555 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
556 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
557
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
558 return (0);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
559 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
560
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
561
355
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
562 static int
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
563 gftpui_common_cmd_ls (void *uidata, gftp_request * request,
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
564 void *other_uidata, gftp_request * other_request,
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
565 const char *command)
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
566 {
355
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
567 char *startcolor, *endcolor, *tempstr;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
568 gftpui_callback_data * cdata;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
569 GList * templist;
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
570 gftp_file * fle;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
571
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
572 if (!GFTP_IS_CONNECTED (request))
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
573 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
574 request->logging_function (gftp_logging_error, request,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
575 _("Error: Not connected to a remote site\n"));
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
576 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
577 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
578
355
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
579 cdata = g_malloc0 (sizeof (*cdata));
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
580 cdata->request = request;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
581 cdata->uidata = uidata;
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
582 cdata->source_string = *command != '\0' ? (char *) command : NULL;
355
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
583 cdata->run_function = gftpui_common_run_ls;
511
c3ff4479a92d 2004-7-25 Brian Masney <masneyb@gftp.org>
masneyb
parents: 510
diff changeset
584 cdata->dont_refresh = 1;
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
585
355
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
586 gftpui_common_run_callback_function (cdata);
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
587
355
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
588 templist = cdata->files;
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
589 while (templist != NULL)
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
590 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
591 fle = templist->data;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
592
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
593 gftpui_lookup_file_colors (fle, &startcolor, &endcolor);
830
afbe37351940 2006-10-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 827
diff changeset
594 tempstr = gftp_gen_ls_string (request, fle, startcolor, endcolor);
573
a2d49bf1d2d1 2004-9-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 560
diff changeset
595 request->logging_function (gftp_logging_misc_nolog, request, "%s\n",
354
2ea37b3c0158 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 350
diff changeset
596 tempstr);
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
597 g_free (tempstr);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
598
355
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
599 templist = templist->next;
598
fa0838b22b14 2004-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 574
diff changeset
600 gftp_file_destroy (fle, 1);
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
601 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
602
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
603
355
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
604 if (cdata->files != NULL)
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
605 g_list_free (cdata->files);
60d3da6ab336 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 354
diff changeset
606 g_free (cdata);
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
607
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
608 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
609 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
610
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
611
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
612 int
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
613 gftpui_common_cmd_open (void *uidata, gftp_request * request,
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
614 void *other_uidata, gftp_request * other_request,
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
615 const char *command)
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
616 {
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
617 gftpui_callback_data * cdata;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
618 intptr_t retries;
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
619
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
620 if (GFTP_IS_CONNECTED (request))
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
621 gftpui_disconnect (uidata);
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
622
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
623 if (command != NULL)
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
624 {
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
625 if (*command == '\0')
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
626 {
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
627 request->logging_function (gftp_logging_error, request,
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
628 _("usage: open " GFTP_URL_USAGE "\n"));
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
629 return (1);
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
630 }
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
631
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
632 if (gftp_parse_url (request, command) < 0)
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
633 return (1);
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
634 }
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
635
553
b2b4f5fa8fc7 2004-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 527
diff changeset
636 if (gftp_need_username (request))
b2b4f5fa8fc7 2004-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 527
diff changeset
637 gftpui_prompt_username (uidata, request);
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
638
553
b2b4f5fa8fc7 2004-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 527
diff changeset
639 if (gftp_need_password (request))
b2b4f5fa8fc7 2004-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 527
diff changeset
640 gftpui_prompt_password (uidata, request);
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
641
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
642 gftp_lookup_request_option (request, "retries", &retries);
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
643
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
644 cdata = g_malloc0 (sizeof (*cdata));
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
645 cdata->request = request;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
646 cdata->uidata = uidata;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
647 cdata->run_function = gftpui_common_run_connect;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
648 cdata->retries = retries;
451
83cfffb2878a 2004-3-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 442
diff changeset
649 cdata->dont_check_connection = 1;
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
650
879
a41a3590d696 2007-2-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 876
diff changeset
651 if (request->refreshing)
a41a3590d696 2007-2-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 876
diff changeset
652 cdata->dont_refresh = 1;
a41a3590d696 2007-2-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 876
diff changeset
653
775
c1144630c4f4 2006-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 774
diff changeset
654 gftpui_show_busy (TRUE);
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
655 gftpui_common_run_callback_function (cdata);
775
c1144630c4f4 2006-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 774
diff changeset
656 gftpui_show_busy (FALSE);
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
657
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
658 g_free (cdata);
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
659
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
660 return (1);
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
661 }
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
662
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
663
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
664 static int
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
665 gftpui_common_cmd_set (void *uidata, gftp_request * request,
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
666 void *other_uidata, gftp_request * other_request,
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
667 const char *command)
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
668 {
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
669 char *pos, *backpos, buf[256];
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
670 gftp_config_vars * cv, newcv;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
671 GList * templist;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
672 int i;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
673
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
674 if (command == NULL || *command == '\0')
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
675 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
676 for (templist = gftp_options_list;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
677 templist != NULL;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
678 templist = templist->next)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
679 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
680 cv = templist->data;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
681
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
682 for (i=0; cv[i].key != NULL; i++)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
683 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
684 if (!(cv[i].ports_shown & GFTP_PORT_TEXT))
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
685 continue;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
686
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
687 if (*cv[i].key == '\0' ||
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
688 gftp_option_types[cv[i].otype].write_function == NULL)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
689 continue;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
690
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
691 gftp_option_types[cv[i].otype].write_function (&cv[i], buf,
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
692 sizeof (buf), 0);
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
693
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
694 gftpui_common_logfunc (gftp_logging_misc_nolog, request,
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
695 "%s = %s\n", cv[i].key, buf);
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
696 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
697 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
698 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
699 else
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
700 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
701 if ((pos = strchr (command, '=')) == NULL)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
702 {
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
703 gftpui_common_logfunc (gftp_logging_error, request,
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
704 _("usage: set [variable = value]\n"));
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
705 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
706 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
707 *pos = '\0';
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
708
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
709 for (backpos = pos - 1;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
710 (*backpos == ' ' || *backpos == '\t') && backpos > command;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
711 backpos--)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
712 *backpos = '\0';
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
713 for (++pos; *pos == ' ' || *pos == '\t'; pos++);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
714
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
715 if ((cv = g_hash_table_lookup (gftp_global_options_htable, command)) == NULL)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
716 {
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
717 gftpui_common_logfunc (gftp_logging_error, request,
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
718 _("Error: Variable %s is not a valid configuration variable.\n"), command);
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
719 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
720 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
721
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
722 if (!(cv->ports_shown & GFTP_PORT_TEXT))
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
723 {
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
724 gftpui_common_logfunc (gftp_logging_error, request,
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
725 _("Error: Variable %s is not available in the text port of gFTP\n"), command);
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
726 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
727 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
728
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
729 if (gftp_option_types[cv->otype].read_function != NULL)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
730 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
731 memcpy (&newcv, cv, sizeof (newcv));
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
732 newcv.flags &= ~GFTP_CVARS_FLAGS_DYNMEM;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
733
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
734 gftp_option_types[cv->otype].read_function (pos, &newcv, 1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
735
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
736 gftp_set_global_option (command, newcv.value);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
737
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
738 gftp_option_types[newcv.otype].write_function (&newcv, buf,
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
739 sizeof (buf), 0);
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
740
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
741 gftpui_common_logfunc (gftp_logging_misc_nolog, request,
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
742 "%s = %s\n", newcv.key, buf);
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
743
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
744 if (newcv.flags & GFTP_CVARS_FLAGS_DYNMEM)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
745 g_free (newcv.value);
574
81b957b00691 2004-9-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 573
diff changeset
746
81b957b00691 2004-9-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 573
diff changeset
747 gftp_configuration_changed = 1;
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
748 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
749 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
750
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
751 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
752 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
753
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
754
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
755 static int
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
756 gftpui_common_cmd_help (void *uidata, gftp_request * request,
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
757 void *other_uidata, gftp_request * other_request,
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
758 const char *command)
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
759 {
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
760 int i, j, ele, numrows, numcols = 6, handled, number_commands, cmdlen,
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
761 found;
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
762 char commands[128], cmdstr[30];
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
763 const char *pos;
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
764
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
765 for (number_commands=0;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
766 gftpui_common_commands[number_commands].command != NULL;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
767 number_commands++);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
768
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
769 if (command != NULL && *command != '\0')
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
770 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
771 for (pos = command; *pos != ' ' && *pos != '\0'; pos++);
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
772 cmdlen = pos - command;
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
773
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
774 for (i=0; gftpui_common_commands[i].command != NULL; i++)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
775 {
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
776 if (strncmp (gftpui_common_commands[i].command, command, cmdlen) == 0)
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
777 break;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
778 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
779
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
780 if (gftpui_common_commands[i].cmd_description != NULL)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
781 {
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
782 found = 1;
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
783
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
784 if (*pos != '\0' && *(pos + 1) != '\0' &&
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
785 gftpui_common_commands[i].subhelp_func != NULL)
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
786 handled = gftpui_common_commands[i].subhelp_func (pos + 1);
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
787 else
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
788 handled = 0;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
789
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
790 if (!handled)
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
791 gftpui_common_logfunc (gftp_logging_misc_nolog, request, "%s\n",
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
792 _(gftpui_common_commands[i].cmd_description));
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
793 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
794 else
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
795 found = 0;
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
796 }
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
797 else
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
798 found = 0;
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
799
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
800 if (!found)
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
801 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
802 numrows = number_commands / numcols;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
803 if (number_commands % numcols != 0)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
804 numrows++;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
805
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
806 gftpui_common_logfunc (gftp_logging_misc_nolog, request,
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
807 _("Supported commands:\n\n"));
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
808
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
809 for (i=0; i<numrows; i++)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
810 {
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
811 strncpy (commands, "\t", sizeof (commands));
970
4c7a58ef26c1 2008-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 941
diff changeset
812 size_t cmd_len = sizeof(commands) - strlen (commands);
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
813
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
814 for (j=0; j<numcols; j++)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
815 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
816 ele = i + j * numrows;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
817 if (ele >= number_commands)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
818 break;
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
819
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
820 g_snprintf (cmdstr, sizeof (cmdstr), "%-10s",
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
821 gftpui_common_commands[ele].command);
970
4c7a58ef26c1 2008-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 941
diff changeset
822 strncat (commands, cmdstr, cmd_len);
4c7a58ef26c1 2008-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 941
diff changeset
823 cmd_len -= strlen(cmdstr);
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
824 }
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
825 gftpui_common_logfunc (gftp_logging_misc_nolog, request, "%s\n",
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
826 commands);
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
827 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
828 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
829 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
830 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
831
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
832
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
833 static void
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
834 _gftpui_common_cmd_transfer_files (void *fromuidata, gftp_request * fromrequest,
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
835 void *touidata, gftp_request * torequest,
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
836 const char *cmd, const char *filespec)
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
837 {
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
838 gftp_transfer * tdata;
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
839 gftp_file * fle;
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
840
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
841 if (!GFTP_IS_CONNECTED (fromrequest) ||
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
842 !GFTP_IS_CONNECTED (torequest))
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
843 {
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
844 fromrequest->logging_function (gftp_logging_error, fromrequest,
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
845 _("Error: Not connected to a remote site\n"));
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
846 return;
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
847 }
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
848
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
849 if (*filespec == '\0')
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
850 {
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
851 fromrequest->logging_function (gftp_logging_error, fromrequest,
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
852 _("usage: %s <filespec>\n"), cmd);
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
853 return;
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
854 }
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
855
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
856 tdata = gftp_tdata_new ();
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
857 tdata->fromreq = fromrequest;
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
858 tdata->toreq = torequest;
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
859
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
860 if (gftp_list_files (tdata->fromreq) != 0)
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
861 {
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
862 tdata->fromreq = tdata->toreq = NULL;
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
863 free_tdata (tdata);
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
864 return;
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
865 }
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
866
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
867 fle = g_malloc0 (sizeof (*fle));
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
868 while (gftp_get_next_file (tdata->fromreq, filespec, fle) > 0)
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
869 {
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
870 if (strcmp (fle->file, ".") == 0 || strcmp (fle->file, "..") == 0)
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
871 {
598
fa0838b22b14 2004-10-29 Brian Masney <masneyb@gftp.org>
masneyb
parents: 574
diff changeset
872 gftp_file_destroy (fle, 0);
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
873 continue;
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
874 }
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
875
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
876 tdata->files = g_list_append (tdata->files, fle);
941
19b6d55e2646 2008-01-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 918
diff changeset
877 fle = g_malloc0 (sizeof (*fle));
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
878 }
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
879
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
880 g_free (fle);
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
881
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
882 gftp_end_transfer (tdata->fromreq);
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
883
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
884 if (tdata->files == NULL)
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
885 {
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
886 tdata->fromreq = tdata->toreq = NULL;
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
887 free_tdata (tdata);
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
888 return;
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
889 }
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
890
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
891 if (gftp_get_all_subdirs (tdata, NULL) != 0)
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
892 {
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
893 tdata->fromreq = tdata->toreq = NULL;
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
894 free_tdata (tdata);
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
895 return;
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
896 }
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
897
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
898 if (tdata->files == NULL)
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
899 {
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
900 tdata->fromreq = tdata->toreq = NULL;
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
901 free_tdata (tdata);
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
902 return;
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
903 }
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
904
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
905 gftpui_common_add_file_transfer (tdata->fromreq, tdata->toreq,
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
906 fromuidata, touidata, tdata->files);
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
907
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
908 g_free (tdata);
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
909
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
910 return;
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
911 }
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
912
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
913
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
914 int
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
915 gftpui_common_cmd_mget_file (void *uidata, gftp_request * request,
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
916 void *other_uidata, gftp_request * other_request,
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
917 const char *command)
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
918 {
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
919 _gftpui_common_cmd_transfer_files (uidata, request, other_uidata,
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
920 other_request, "mget", command);
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
921 return (1);
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
922 }
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
923
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
924
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
925 int
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
926 gftpui_common_cmd_mput_file (void *uidata, gftp_request * request,
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
927 void *other_uidata, gftp_request * other_request,
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
928 const char *command)
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
929 {
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
930 _gftpui_common_cmd_transfer_files (other_uidata, other_request, uidata,
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
931 request, "mput", command);
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
932 return (1);
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
933 }
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
934
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
935
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
936 gftpui_common_methods gftpui_common_commands[] = {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
937 {N_("about"), 2, gftpui_common_cmd_about, gftpui_common_request_none,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
938 N_("Shows gFTP information"), NULL},
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
939 {N_("ascii"), 2, gftpui_common_cmd_ascii, gftpui_common_request_remote,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
940 N_("Sets the current file transfer mode to Ascii (only for FTP)"), NULL},
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
941 {N_("binary"), 1, gftpui_common_cmd_binary, gftpui_common_request_remote,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
942 N_("Sets the current file transfer mode to Binary (only for FTP)"), NULL},
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
943 {N_("cd"), 2, gftpui_common_cmd_chdir, gftpui_common_request_remote,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
944 N_("Changes the remote working directory"), NULL},
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
945 {N_("chdir"), 3, gftpui_common_cmd_chdir, gftpui_common_request_remote,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
946 N_("Changes the remote working directory"), NULL},
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
947 {N_("chmod"), 3, gftpui_common_cmd_chmod, gftpui_common_request_remote,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
948 N_("Changes the permissions of a remote file"), NULL},
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
949 {N_("clear"), 3, gftpui_common_cmd_clear, gftpui_common_request_none,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
950 N_("Available options: cache"), gftpui_common_clear_show_subhelp},
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
951 {N_("close"), 3, gftpui_common_cmd_close, gftpui_common_request_remote,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
952 N_("Disconnects from the remote site"), NULL},
350
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
953 {N_("delete"), 1, gftpui_common_cmd_delete, gftpui_common_request_remote,
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
954 N_("Removes a remote file"), NULL},
651
5f2808c65e46 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 598
diff changeset
955 {N_("dir"), 3, gftpui_common_cmd_ls, gftpui_common_request_remote,
5f2808c65e46 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 598
diff changeset
956 N_("Shows the directory listing for the current remote directory"), NULL},
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
957 {N_("get"), 1, gftpui_common_cmd_mget_file, gftpui_common_request_remote,
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
958 N_("Downloads remote file(s)"), NULL},
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
959 {N_("help"), 1, gftpui_common_cmd_help, gftpui_common_request_none,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
960 N_("Shows this help screen"), NULL},
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
961 {N_("lcd"), 3, gftpui_common_cmd_chdir, gftpui_common_request_local,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
962 N_("Changes the local working directory"), NULL},
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
963 {N_("lchdir"), 4, gftpui_common_cmd_chdir, gftpui_common_request_local,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
964 N_("Changes the local working directory"), NULL},
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
965 {N_("lchmod"), 4, gftpui_common_cmd_chmod, gftpui_common_request_local,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
966 N_("Changes the permissions of a local file"), NULL},
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
967 {N_("ldelete"), 2, gftpui_common_cmd_delete, gftpui_common_request_local,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
968 N_("Removes a local file"), NULL},
651
5f2808c65e46 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 598
diff changeset
969 {N_("ldir"), 4, gftpui_common_cmd_ls, gftpui_common_request_local,
5f2808c65e46 2004-12-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 598
diff changeset
970 N_("Shows the directory listing for the current local directory"), NULL},
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
971 {N_("lls"), 2, gftpui_common_cmd_ls, gftpui_common_request_local,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
972 N_("Shows the directory listing for the current local directory"), NULL},
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
973 {N_("lmkdir"), 2, gftpui_common_cmd_mkdir, gftpui_common_request_local,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
974 N_("Creates a local directory"), NULL},
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
975 {N_("lpwd"), 2, gftpui_common_cmd_pwd, gftpui_common_request_local,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
976 N_("Show current local directory"), NULL},
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
977 {N_("lrename"), 3, gftpui_common_cmd_rename, gftpui_common_request_local,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
978 N_("Rename a local file"), NULL},
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
979 {N_("lrmdir"), 3, gftpui_common_cmd_rmdir, gftpui_common_request_local,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
980 N_("Remove a local directory"), NULL},
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
981 {N_("ls"), 2, gftpui_common_cmd_ls, gftpui_common_request_remote,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
982 N_("Shows the directory listing for the current remote directory"), NULL},
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
983 {N_("mget"), 2, gftpui_common_cmd_mget_file, gftpui_common_request_remote,
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
984 N_("Downloads remote file(s)"), NULL},
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
985 {N_("mkdir"), 2, gftpui_common_cmd_mkdir, gftpui_common_request_remote,
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
986 N_("Creates a remote directory"), NULL},
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
987 {N_("mput"), 2, gftpui_common_cmd_mput_file, gftpui_common_request_remote,
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
988 N_("Uploads local file(s)"), NULL},
356
7cb3327f96f7 2003-1-5 Brian Masney <masneyb@gftp.org>
masneyb
parents: 355
diff changeset
989 {N_("open"), 1, gftpui_common_cmd_open, gftpui_common_request_remote,
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
990 N_("Opens a connection to a remote site"), NULL},
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
991 {N_("put"), 2, gftpui_common_cmd_mput_file, gftpui_common_request_remote,
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
992 N_("Uploads local file(s)"), NULL},
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
993 {N_("pwd"), 2, gftpui_common_cmd_pwd, gftpui_common_request_remote,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
994 N_("Show current remote directory"), NULL},
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
995 {N_("quit"), 1, gftpui_common_cmd_quit, gftpui_common_request_none,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
996 N_("Exit from gFTP"), NULL},
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
997 {N_("rename"), 2, gftpui_common_cmd_rename, gftpui_common_request_remote,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
998 N_("Rename a remote file"), NULL},
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
999 {N_("rmdir"), 2, gftpui_common_cmd_rmdir, gftpui_common_request_remote,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1000 N_("Remove a remote directory"), NULL},
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1001 {N_("set"), 1, gftpui_common_cmd_set, gftpui_common_request_none,
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1002 N_("Show configuration file variables. You can also set variables by set var=val"),
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1003 gftpui_common_set_show_subhelp},
350
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
1004 {N_("site"), 2, gftpui_common_cmd_site, gftpui_common_request_remote,
e5ad008e7ea8 2003-1-4 Brian Masney <masneyb@gftp.org>
masneyb
parents: 341
diff changeset
1005 N_("Run a site specific command"), NULL},
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1006 {NULL, 0, NULL, gftpui_common_request_none,
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1007 NULL, NULL}};
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1008
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1009
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1010 int
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
1011 gftpui_common_process_command (void *locui, gftp_request * locreq,
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
1012 void *remui, gftp_request * remreq,
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
1013 const char *command)
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1014 {
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1015 gftp_request * request, * other_request;
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1016 void *uidata, *other_uidata;
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1017 char *pos, *newstr;
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1018 const char *stpos;
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1019 size_t cmdlen;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1020 int ret, i;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1021 size_t len;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1022
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1023 for (stpos = command; *stpos == ' ' || *stpos == '\t'; stpos++);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1024
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1025 newstr = g_strdup (stpos);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1026 len = strlen (newstr);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1027
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1028 if (len > 0 && newstr[len - 1] == '\n')
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1029 newstr[--len] = '\0';
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1030 if (len > 0 && newstr[len - 1] == '\r')
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1031 newstr[--len] = '\0';
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1032
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1033 for (pos = newstr + len - 1;
841
94f87e3c92b2 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 838
diff changeset
1034 (*pos == ' ' || *pos == '\t') && pos > newstr;
94f87e3c92b2 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 838
diff changeset
1035 *pos-- = '\0');
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1036
841
94f87e3c92b2 2006-11-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 838
diff changeset
1037 if (*newstr == '\0')
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1038 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1039 g_free (newstr);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1040 return (1);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1041 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1042
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1043 if ((pos = strchr (newstr, ' ')) != NULL)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1044 *pos = '\0';
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1045
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1046 cmdlen = strlen (newstr);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1047 for (i=0; gftpui_common_commands[i].command != NULL; i++)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1048 {
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1049 if (strcmp (gftpui_common_commands[i].command, newstr) == 0)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1050 break;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1051 else if (cmdlen >= gftpui_common_commands[i].minlen &&
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1052 strncmp (gftpui_common_commands[i].command, newstr, cmdlen) == 0)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1053 break;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1054 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1055
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1056 if (pos != NULL)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1057 pos++;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1058 else
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1059 pos = "";
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1060
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
1061 if (gftpui_common_commands[i].reqtype == gftpui_common_request_local)
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
1062 {
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
1063 request = locreq;
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
1064 uidata = locui;
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1065
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1066 other_request = remreq;
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1067 other_uidata = remui;
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
1068 }
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
1069 else if (gftpui_common_commands[i].reqtype == gftpui_common_request_remote)
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
1070 {
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
1071 request = remreq;
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
1072 uidata = remui;
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1073
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1074 other_request = locreq;
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1075 other_uidata = locui;
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
1076 }
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
1077 else
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
1078 {
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1079 request = other_request = NULL;
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1080 uidata = other_uidata = NULL;
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
1081 }
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
1082
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1083 if (gftpui_common_commands[i].command != NULL)
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1084 {
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1085 ret = gftpui_common_commands[i].func (uidata, request,
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1086 other_uidata, other_request, pos);
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
1087
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
1088 if (request != NULL && !GFTP_IS_CONNECTED (request))
380
05ee37a5558b 2003-1-28 Brian Masney <masneyb@gftp.org>
masneyb
parents: 377
diff changeset
1089 gftpui_disconnect (uidata);
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1090 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1091 else
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1092 {
374
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
1093 gftpui_common_logfunc (gftp_logging_error, request,
d207b8241e96 2003-1-21 Brian Masney <masneyb@gftp.org>
masneyb
parents: 368
diff changeset
1094 _("Error: Command not recognized\n"));
341
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1095 ret = 1;
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1096 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1097
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1098 g_free (newstr);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1099 return (ret);
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1100 }
eedc2c5727fa 2003-12-28 Brian Masney <masneyb@gftp.org>
masneyb
parents:
diff changeset
1101
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1102
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1103 gftp_transfer *
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1104 gftpui_common_add_file_transfer (gftp_request * fromreq, gftp_request * toreq,
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1105 void *fromuidata, void *touidata,
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1106 GList * files)
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1107 {
795
ca59edd1b04d 2006-8-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 783
diff changeset
1108 intptr_t append_transfers, one_transfer, overwrite_default;
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1109 GList * templist, *curfle;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1110 gftp_transfer * tdata;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1111 gftp_file * tempfle;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1112 int show_dialog;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1113
795
ca59edd1b04d 2006-8-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 783
diff changeset
1114 gftp_lookup_request_option (fromreq, "overwrite_default", &overwrite_default);
ca59edd1b04d 2006-8-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 783
diff changeset
1115 gftp_lookup_request_option (fromreq, "append_transfers", &append_transfers);
ca59edd1b04d 2006-8-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 783
diff changeset
1116 gftp_lookup_request_option (fromreq, "one_transfer", &one_transfer);
ca59edd1b04d 2006-8-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 783
diff changeset
1117
ca59edd1b04d 2006-8-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 783
diff changeset
1118 if (!overwrite_default)
ca59edd1b04d 2006-8-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 783
diff changeset
1119 {
ca59edd1b04d 2006-8-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 783
diff changeset
1120 for (templist = files; templist != NULL; templist = templist->next)
ca59edd1b04d 2006-8-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 783
diff changeset
1121 {
ca59edd1b04d 2006-8-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 783
diff changeset
1122 tempfle = templist->data;
918
e9f22ad1dec5 2007-4-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 895
diff changeset
1123 if (tempfle->startsize > 0 && !S_ISDIR (tempfle->st_mode))
795
ca59edd1b04d 2006-8-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 783
diff changeset
1124 break;
ca59edd1b04d 2006-8-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 783
diff changeset
1125 }
ca59edd1b04d 2006-8-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 783
diff changeset
1126
ca59edd1b04d 2006-8-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 783
diff changeset
1127 show_dialog = templist != NULL;
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1128 }
795
ca59edd1b04d 2006-8-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 783
diff changeset
1129 else
ca59edd1b04d 2006-8-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 783
diff changeset
1130 show_dialog = 0;
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1131
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1132 tdata = NULL;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1133 if (append_transfers && one_transfer && !show_dialog)
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1134 {
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1135 if (g_thread_supported ())
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1136 g_static_mutex_lock (&gftpui_common_transfer_mutex);
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1137
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1138 for (templist = gftp_file_transfers;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1139 templist != NULL;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1140 templist = templist->next)
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1141 {
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1142 tdata = templist->data;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1143
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1144 if (g_thread_supported ())
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1145 g_static_mutex_lock (&tdata->structmutex);
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1146
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1147 if (!compare_request (tdata->fromreq, fromreq, 0) ||
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1148 !compare_request (tdata->toreq, toreq, 0) ||
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1149 tdata->curfle == NULL)
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1150 {
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1151 if (g_thread_supported ())
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1152 g_static_mutex_unlock (&tdata->structmutex);
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1153
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1154 continue;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1155 }
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1156
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1157 tdata->files = g_list_concat (tdata->files, files);
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1158
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1159 for (curfle = files; curfle != NULL; curfle = curfle->next)
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1160 {
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1161 tempfle = curfle->data;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1162
499
39e9945288ea 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 498
diff changeset
1163 if (S_ISDIR (tempfle->st_mode))
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1164 tdata->numdirs++;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1165 else
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1166 tdata->numfiles++;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1167
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1168 if (tempfle->transfer_action != GFTP_TRANS_ACTION_SKIP)
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1169 tdata->total_bytes += tempfle->size;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1170
397
14ef37b62c20 2004-2-8 Brian Masney <masneyb@gftp.org>
masneyb
parents: 387
diff changeset
1171 gftpui_add_file_to_transfer (tdata, curfle);
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1172 }
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1173
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1174 if (g_thread_supported ())
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1175 g_static_mutex_unlock (&tdata->structmutex);
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1176
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1177 break;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1178 }
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1179
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1180 if (g_thread_supported ())
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1181 g_static_mutex_unlock (&gftpui_common_transfer_mutex);
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1182 }
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1183 else
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1184 templist = NULL;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1185
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1186 if (templist == NULL)
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1187 {
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1188 tdata = gftp_tdata_new ();
368
af541d789f4c 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
1189 tdata->fromreq = gftp_copy_request (fromreq);
af541d789f4c 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 367
diff changeset
1190 tdata->toreq = gftp_copy_request (toreq);
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1191
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1192 tdata->fromwdata = fromuidata;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1193 tdata->towdata = touidata;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1194
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1195 if (!show_dialog)
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1196 tdata->show = tdata->ready = 1;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1197
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1198 tdata->files = files;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1199 for (curfle = files; curfle != NULL; curfle = curfle->next)
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1200 {
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1201 tempfle = curfle->data;
499
39e9945288ea 2004-7-13 Brian Masney <masneyb@gftp.org>
masneyb
parents: 498
diff changeset
1202 if (S_ISDIR (tempfle->st_mode))
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1203 tdata->numdirs++;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1204 else
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1205 tdata->numfiles++;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1206
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1207 if (tempfle->transfer_action != GFTP_TRANS_ACTION_SKIP)
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1208 tdata->total_bytes += tempfle->size;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1209 }
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1210
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1211 if (g_thread_supported ())
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1212 g_static_mutex_lock (&gftpui_common_transfer_mutex);
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1213
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1214 gftp_file_transfers = g_list_append (gftp_file_transfers, tdata);
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1215
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1216 if (g_thread_supported ())
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1217 g_static_mutex_unlock (&gftpui_common_transfer_mutex);
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1218
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1219 if (show_dialog)
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1220 gftpui_ask_transfer (tdata);
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1221 }
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1222
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1223 gftpui_start_transfer (tdata);
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1224 return (tdata);
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1225 }
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1226
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1227
862
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1228 static ssize_t
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1229 _do_transfer_block (gftp_transfer * tdata, gftp_file * curfle, char *buf,
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1230 size_t trans_blksize)
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1231 {
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1232 ssize_t num_read, num_wrote, ret;
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1233 char *bufpos;
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1234
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1235 num_read = gftp_get_next_file_chunk (tdata->fromreq, buf, trans_blksize);
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1236 if (num_read < 0)
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1237 return (num_read);
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1238
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1239 bufpos = buf;
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1240 num_wrote = 0;
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1241 while (num_wrote < num_read)
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1242 {
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1243 if ((ret = gftp_put_next_file_chunk (tdata->toreq, bufpos,
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1244 num_read - num_wrote)) <= 0)
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1245 return (ret);
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1246
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1247 num_wrote += ret;
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1248 bufpos += ret;
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1249 }
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1250
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1251 return (num_read);
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1252 }
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1253
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1254
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1255 int
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1256 _gftpui_common_do_transfer_file (gftp_transfer * tdata, gftp_file * curfle)
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1257 {
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1258 struct timeval updatetime;
811
789ff8cb3170 2006-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 806
diff changeset
1259 intptr_t trans_blksize;
862
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1260 ssize_t num_trans;
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1261 char *buf;
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1262 int ret;
527
d0e8f8ee3b20 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 518
diff changeset
1263
d0e8f8ee3b20 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 518
diff changeset
1264 gftp_lookup_request_option (tdata->fromreq, "trans_blksize", &trans_blksize);
941
19b6d55e2646 2008-01-24 Brian Masney <masneyb@gftp.org>
masneyb
parents: 918
diff changeset
1265 buf = g_malloc0 (trans_blksize);
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1266
811
789ff8cb3170 2006-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 806
diff changeset
1267 memset (&updatetime, 0, sizeof (updatetime));
789ff8cb3170 2006-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 806
diff changeset
1268 gftpui_start_current_file_in_transfer (tdata);
789ff8cb3170 2006-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 806
diff changeset
1269
862
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1270 num_trans = 0;
811
789ff8cb3170 2006-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 806
diff changeset
1271 while (!tdata->cancel &&
862
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1272 (num_trans = _do_transfer_block (tdata, curfle, buf,
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1273 trans_blksize)) > 0)
811
789ff8cb3170 2006-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 806
diff changeset
1274 {
862
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1275 gftp_calc_kbs (tdata, num_trans);
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1276
811
789ff8cb3170 2006-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 806
diff changeset
1277 if (tdata->lasttime.tv_sec - updatetime.tv_sec >= 1 ||
789ff8cb3170 2006-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 806
diff changeset
1278 tdata->curtrans >= tdata->tot_file_trans)
789ff8cb3170 2006-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 806
diff changeset
1279 {
789ff8cb3170 2006-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 806
diff changeset
1280 gftpui_update_current_file_in_transfer (tdata);
789ff8cb3170 2006-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 806
diff changeset
1281 memcpy (&updatetime, &tdata->lasttime, sizeof (updatetime));
789ff8cb3170 2006-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 806
diff changeset
1282
862
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1283 if (tdata->current_file_retries > 0)
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1284 tdata->current_file_retries = 0;
811
789ff8cb3170 2006-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 806
diff changeset
1285 }
789ff8cb3170 2006-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 806
diff changeset
1286 }
789ff8cb3170 2006-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 806
diff changeset
1287
862
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1288 if (num_trans == GFTP_ENOTRANS)
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1289 num_trans = 0;
811
789ff8cb3170 2006-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 806
diff changeset
1290
789ff8cb3170 2006-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 806
diff changeset
1291 g_free (buf);
789ff8cb3170 2006-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 806
diff changeset
1292 gftpui_finish_current_file_in_transfer (tdata);
789ff8cb3170 2006-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 806
diff changeset
1293
862
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1294 if ((int) num_trans == 0)
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1295 {
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1296 if ((ret = gftp_end_transfer (tdata->fromreq)) < 0)
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1297 return (ret);
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1298
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1299 if ((ret = gftp_end_transfer (tdata->toreq)) < 0)
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1300 return (ret);
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1301
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1302 tdata->fromreq->logging_function (gftp_logging_misc,
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1303 tdata->fromreq,
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1304 _("Successfully transferred %s at %.2f KB/s\n"),
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1305 curfle->file, tdata->kbs);
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1306
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1307 return (0);
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1308 }
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1309 else
862
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1310 return ((int) num_trans);
811
789ff8cb3170 2006-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 806
diff changeset
1311 }
789ff8cb3170 2006-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 806
diff changeset
1312
789ff8cb3170 2006-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 806
diff changeset
1313
819
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1314 void
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1315 gftpui_common_skip_file_transfer (gftp_transfer * tdata, gftp_file * curfle)
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1316 {
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1317 g_static_mutex_lock (&tdata->structmutex);
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1318
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1319 if (tdata->started && !(curfle->transfer_action & GFTP_TRANS_ACTION_SKIP))
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1320 {
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1321 curfle->transfer_action = GFTP_TRANS_ACTION_SKIP;
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1322 if (tdata->curfle != NULL && curfle == tdata->curfle->data)
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1323 {
876
2d4e6fca8e7c 2007-2-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 873
diff changeset
1324 gftpui_cancel_file_transfer (tdata);
819
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1325 tdata->skip_file = 1;
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1326 }
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1327 else if (!curfle->transfer_done)
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1328 tdata->total_bytes -= curfle->size;
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1329 }
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1330
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1331 g_static_mutex_unlock (&tdata->structmutex);
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1332
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1333 if (curfle != NULL)
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1334 tdata->fromreq->logging_function (gftp_logging_misc, tdata->fromreq,
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1335 _("Skipping file %s on host %s\n"),
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1336 curfle->file, tdata->toreq->hostname);
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1337 }
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1338
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1339
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1340 void
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1341 gftpui_common_cancel_file_transfer (gftp_transfer * tdata)
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1342 {
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1343 g_static_mutex_lock (&tdata->structmutex);
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1344
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1345 if (tdata->started)
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1346 {
876
2d4e6fca8e7c 2007-2-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 873
diff changeset
1347 gftpui_cancel_file_transfer (tdata);
819
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1348 tdata->skip_file = 0;
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1349 }
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1350 else
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1351 tdata->done = 1;
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1352
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1353 tdata->fromreq->stopable = 0;
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1354 tdata->toreq->stopable = 0;
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1355
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1356 g_static_mutex_unlock (&tdata->structmutex);
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1357
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1358 tdata->fromreq->logging_function (gftp_logging_misc, tdata->fromreq,
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1359 _("Stopping the transfer on host %s\n"),
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1360 tdata->toreq->hostname);
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1361 }
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1362
d6fdfcbdb056 2006-10-1 Brian Masney <masneyb@gftp.org>
masneyb
parents: 811
diff changeset
1363
838
57aad6d4b304 2006-10-31 Brian Masney <masneyb@gftp.org>
masneyb
parents: 830
diff changeset
1364 static void
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1365 _gftpui_common_next_file_in_trans (gftp_transfer * tdata)
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1366 {
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1367 gftp_file * curfle;
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1368
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1369 if (g_thread_supported ())
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1370 g_static_mutex_lock (&tdata->structmutex);
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1371
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1372 tdata->curtrans = 0;
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1373 tdata->next_file = 1;
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1374
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1375 curfle = tdata->curfle->data;
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1376 curfle->transfer_done = 1;
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1377 tdata->curfle = tdata->curfle->next;
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1378
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1379 if (g_thread_supported ())
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1380 g_static_mutex_unlock (&tdata->structmutex);
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1381 }
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1382
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1383
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1384 static int
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1385 _gftpui_common_preserve_perm_time (gftp_transfer * tdata, gftp_file * curfle)
811
789ff8cb3170 2006-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 806
diff changeset
1386 {
789ff8cb3170 2006-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 806
diff changeset
1387 intptr_t preserve_permissions, preserve_time;
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1388 int ret, tmpret;
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1389
774
2adc6b8b3197 2006-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 766
diff changeset
1390 gftp_lookup_request_option (tdata->fromreq, "preserve_permissions",
2adc6b8b3197 2006-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 766
diff changeset
1391 &preserve_permissions);
2adc6b8b3197 2006-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 766
diff changeset
1392 gftp_lookup_request_option (tdata->fromreq, "preserve_time",
2adc6b8b3197 2006-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 766
diff changeset
1393 &preserve_time);
2adc6b8b3197 2006-7-19 Brian Masney <masneyb@gftp.org>
masneyb
parents: 766
diff changeset
1394
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1395 ret = 0;
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1396 if (GFTP_IS_CONNECTED (tdata->toreq) && preserve_permissions &&
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1397 curfle->st_mode != 0)
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1398 {
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1399 tmpret = gftp_chmod (tdata->toreq, curfle->destfile,
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1400 curfle->st_mode & (S_IRWXU | S_IRWXG | S_IRWXO));
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1401 if (tmpret < 0)
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1402 ret = tmpret;
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1403 }
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1404
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1405 if (GFTP_IS_CONNECTED (tdata->toreq) && preserve_time &&
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1406 curfle->datetime != 0)
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1407 {
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1408 tmpret = gftp_set_file_time (tdata->toreq, curfle->destfile,
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1409 curfle->datetime);
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1410 if (tmpret < 0)
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1411 ret = tmpret;
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1412 }
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1413
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1414 if (!GFTP_IS_CONNECTED (tdata->toreq))
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1415 return (ret);
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1416 else
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1417 return (0);
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1418 }
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1419
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1420
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1421 static int
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1422 _gftpui_common_trans_file_or_dir (gftp_transfer * tdata)
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1423 {
862
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1424 gftp_file * curfle;
894
14476a8a4d2b 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
1425 int ret;
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1426
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1427 if (g_thread_supported ())
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1428 g_static_mutex_lock (&tdata->structmutex);
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1429
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1430 curfle = tdata->curfle->data;
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1431 tdata->current_file_number++;
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1432
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1433 if (g_thread_supported ())
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1434 g_static_mutex_unlock (&tdata->structmutex);
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1435
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1436 if (curfle->transfer_action == GFTP_TRANS_ACTION_SKIP)
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1437 {
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1438 tdata->tot_file_trans = 0;
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1439 return (0);
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1440 }
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1441
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1442 if ((ret = gftp_connect (tdata->fromreq)) < 0)
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1443 return (ret);
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1444
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1445 if ((ret = gftp_connect (tdata->toreq)) < 0)
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1446 return (ret);
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1447
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1448 if (S_ISDIR (curfle->st_mode))
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1449 {
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1450 tdata->tot_file_trans = 0;
918
e9f22ad1dec5 2007-4-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 895
diff changeset
1451 if (curfle->startsize > 0)
e9f22ad1dec5 2007-4-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 895
diff changeset
1452 ret = 1;
e9f22ad1dec5 2007-4-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 895
diff changeset
1453 else
e9f22ad1dec5 2007-4-26 Brian Masney <masneyb@gftp.org>
masneyb
parents: 895
diff changeset
1454 ret = gftp_make_directory (tdata->toreq, curfle->destfile);
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1455 }
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1456 else
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1457 {
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1458 if (curfle->size == 0)
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1459 {
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1460 curfle->size = gftp_get_file_size (tdata->fromreq, curfle->file);
862
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1461 if (curfle->size < 0)
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1462 return ((int) curfle->size);
377
14da115b149b 2003-1-23 Brian Masney <masneyb@gftp.org>
masneyb
parents: 374
diff changeset
1463
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1464 tdata->total_bytes += curfle->size;
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1465 }
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1466
862
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1467 if (curfle->retry_transfer)
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1468 {
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1469 curfle->transfer_action = GFTP_TRANS_ACTION_RESUME;
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1470 curfle->startsize = gftp_get_file_size (tdata->toreq, curfle->destfile);
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1471 if (curfle->startsize < 0)
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1472 return ((int) curfle->startsize);
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1473 }
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1474
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1475 tdata->tot_file_trans = gftp_transfer_file (tdata->fromreq, curfle->file,
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1476 curfle->transfer_action == GFTP_TRANS_ACTION_RESUME ?
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1477 curfle->startsize : 0,
895
4ab11f70a7f4 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 894
diff changeset
1478 tdata->toreq, curfle->destfile,
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1479 curfle->transfer_action == GFTP_TRANS_ACTION_RESUME ?
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1480 curfle->startsize : 0);
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1481 if (tdata->tot_file_trans < 0)
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1482 ret = tdata->tot_file_trans;
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1483 else
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1484 {
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1485 if (g_thread_supported ())
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1486 g_static_mutex_lock (&tdata->structmutex);
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1487
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1488 tdata->curtrans = 0;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1489 tdata->curresumed = curfle->transfer_action == GFTP_TRANS_ACTION_RESUME ? curfle->startsize : 0;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1490 tdata->resumed_bytes += tdata->curresumed;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1491
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1492 if (g_thread_supported ())
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1493 g_static_mutex_unlock (&tdata->structmutex);
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1494
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1495 ret = _gftpui_common_do_transfer_file (tdata, curfle);
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1496 }
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1497 }
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1498
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1499 if (ret == 0)
894
14476a8a4d2b 2007-3-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 885
diff changeset
1500 ret = _gftpui_common_preserve_perm_time (tdata, curfle);
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1501 else
862
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1502 {
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1503 curfle->retry_transfer = 1;
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1504 tdata->fromreq->logging_function (gftp_logging_error, tdata->fromreq,
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1505 _("Could not download %s from %s\n"),
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1506 curfle->file, tdata->fromreq->hostname);
885038cb945b 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 858
diff changeset
1507 }
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1508
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1509 return (ret);
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1510 }
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1511
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1512
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1513 int
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1514 gftpui_common_transfer_files (gftp_transfer * tdata)
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1515 {
858
10e2ce91e26c 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 841
diff changeset
1516 int ret, skipped_files;
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1517
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1518 tdata->curfle = tdata->files;
876
2d4e6fca8e7c 2007-2-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 873
diff changeset
1519 gftpui_common_num_child_threads++;
2d4e6fca8e7c 2007-2-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 873
diff changeset
1520
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1521 gettimeofday (&tdata->starttime, NULL);
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1522 memcpy (&tdata->lasttime, &tdata->starttime, sizeof (tdata->lasttime));
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1523
858
10e2ce91e26c 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 841
diff changeset
1524 skipped_files = 0;
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1525 while (tdata->curfle != NULL)
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1526 {
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1527 ret = _gftpui_common_trans_file_or_dir (tdata);
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1528 if (tdata->cancel)
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1529 {
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1530 if (gftp_abort_transfer (tdata->toreq) != 0)
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1531 gftp_disconnect (tdata->toreq);
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1532
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1533 if (gftp_abort_transfer (tdata->fromreq) != 0)
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1534 gftp_disconnect (tdata->fromreq);
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1535 }
858
10e2ce91e26c 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 841
diff changeset
1536 else if (ret == GFTP_EFATAL)
10e2ce91e26c 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 841
diff changeset
1537 skipped_files++;
811
789ff8cb3170 2006-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 806
diff changeset
1538 else if (ret < 0)
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1539 {
811
789ff8cb3170 2006-9-14 Brian Masney <masneyb@gftp.org>
masneyb
parents: 806
diff changeset
1540 if (gftp_get_transfer_status (tdata, ret) == GFTP_ERETRYABLE)
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1541 continue;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1542
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1543 break;
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1544 }
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1545
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1546 _gftpui_common_next_file_in_trans (tdata);
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1547
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1548 if (tdata->cancel)
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1549 {
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1550 if (!tdata->skip_file)
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1551 break;
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1552
825
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1553 tdata->cancel = 0;
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1554 tdata->fromreq->cancel = 0;
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1555 tdata->toreq->cancel = 0;
73e9842e7097 2006-10-15 Brian Masney <masneyb@gftp.org>
masneyb
parents: 820
diff changeset
1556 }
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1557 }
527
d0e8f8ee3b20 2004-8-9 Brian Masney <masneyb@gftp.org>
masneyb
parents: 518
diff changeset
1558
858
10e2ce91e26c 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 841
diff changeset
1559 if (skipped_files)
10e2ce91e26c 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 841
diff changeset
1560 tdata->fromreq->logging_function (gftp_logging_error, tdata->fromreq,
10e2ce91e26c 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 841
diff changeset
1561 _("There were %d files or directories that could not be transferred. Check the log for which items were not properly transferred."),
10e2ce91e26c 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 841
diff changeset
1562 skipped_files);
10e2ce91e26c 2006-11-30 Brian Masney <masneyb@gftp.org>
masneyb
parents: 841
diff changeset
1563
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1564 tdata->done = 1;
876
2d4e6fca8e7c 2007-2-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 873
diff changeset
1565 gftpui_common_num_child_threads--;
2d4e6fca8e7c 2007-2-6 Brian Masney <masneyb@gftp.org>
masneyb
parents: 873
diff changeset
1566
387
2f5ce7fb5aad 2003-2-2 Brian Masney <masneyb@gftp.org>
masneyb
parents: 380
diff changeset
1567 return (1);
367
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1568 }
d5409bf03ff1 2003-1-18 Brian Masney <masneyb@gftp.org>
masneyb
parents: 356
diff changeset
1569
469
2ad1916dc611 2004-5-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 451
diff changeset
1570
2ad1916dc611 2004-5-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 451
diff changeset
1571 void
2ad1916dc611 2004-5-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 451
diff changeset
1572 gftpui_protocol_update_timeout (gftp_request * request)
2ad1916dc611 2004-5-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 451
diff changeset
1573 {
2ad1916dc611 2004-5-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 451
diff changeset
1574 intptr_t network_timeout;
2ad1916dc611 2004-5-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 451
diff changeset
1575
2ad1916dc611 2004-5-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 451
diff changeset
1576 gftp_lookup_request_option (request, "network_timeout", &network_timeout);
2ad1916dc611 2004-5-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 451
diff changeset
1577
2ad1916dc611 2004-5-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 451
diff changeset
1578 if (network_timeout > 0)
2ad1916dc611 2004-5-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 451
diff changeset
1579 alarm (network_timeout);
2ad1916dc611 2004-5-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 451
diff changeset
1580 }
2ad1916dc611 2004-5-16 Brian Masney <masneyb@gftp.org>
masneyb
parents: 451
diff changeset
1581