Moved no_status to Job; disabling status reporting is a generic Job
thing, I think, not really specific to CopyJobs. (It's still handled by
individual ShowRunStatus implementations, though, and I didn't implement
it for the others.)
Added 'parent' to FileCopyPeer. This is used to disable the status line.
(Sanity measure: parent type of FileCopyPeer is CopyJob.)
Added GrabOutput(perm). Clears the status line (to allow outputting);
perm also sets no_status (ie. grabs output perminantly.) This
propagates upward like vfprintf(); perm doesn't. (I'm not sure of the
logic here, since I'm not sure exactly when a job will be multiple
levels deep--I followed the example of the others, which just set the
actual low-level Job's no_status.)
Made FileCopyPeerFDStream call GrabOutput(true) on the first write, if
fd is stdout or stderr.
Reenabled "-q" for cls.
The special casing for NoStatus()ing in other CopyJobs can probably go
away, since FileCopyPeerFDStream will do it automatically at the last
possible time.
(By the way, that previous patch seems to be working, though I'll
probably be leaving use-abor off all the time from now on; I just use
too many broken servers. Hate Windows FTP servers.)
--
Glenn Maynard
Index: CmdExec.cc
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/CmdExec.cc,v
retrieving revision 1.82
diff -u -r1.82 CmdExec.cc
--- CmdExec.cc 2001/10/05 06:26:49 1.82
+++ CmdExec.cc 2001/10/17 01:47:49
@@ -958,6 +958,13 @@
::vfprintf(file,f,v);
}
+void CmdExec::GrabOutput(bool perm)
+{
+ Job::GrabOutput(perm);
+
+ pre_stdout();
+}
+
void CmdExec::SetCmdFeeder(CmdFeeder *new_feeder)
{
new_feeder->prev=feeder;
Index: CmdExec.h
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/CmdExec.h,v
retrieving revision 1.42
diff -u -r1.42 CmdExec.h
--- CmdExec.h 2001/07/26 09:57:18 1.42
+++ CmdExec.h 2001/10/17 01:47:49
@@ -198,6 +198,7 @@
FDStream *default_output;
void top_vfprintf(FILE *file,const char *f,va_list v);
+ void GrabOutput(bool perm = false);
void SetInteractive(bool i);
void SetTopLevel()
Index: CopyJob.cc
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/CopyJob.cc,v
retrieving revision 1.22
diff -u -r1.22 CopyJob.cc
--- CopyJob.cc 2000/09/07 18:51:38 1.22
+++ CopyJob.cc 2001/10/17 01:47:50
@@ -108,7 +108,6 @@
name=xstrdup(name1);
op=xstrdup(op1);
done=false;
- no_status=false;
}
CopyJob::~CopyJob()
{
@@ -144,7 +143,6 @@
count=0;
bytes=0;
time_spent=0;
- no_status=false;
cont=cont1;
ascii=false;
cwd=xgetcwd();
Index: CopyJob.h
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/CopyJob.h,v
retrieving revision 1.13
diff -u -r1.13 CopyJob.h
--- CopyJob.h 2000/07/19 07:24:15 1.13
+++ CopyJob.h 2001/10/17 01:47:50
@@ -33,13 +33,10 @@
bool done;
char *name; // file name
char *op; // command name
- bool no_status;
public:
CopyJob(FileCopy *c1,const char *n,const char *op1);
~CopyJob();
-
- void NoStatus() { no_status=true; }
int Do();
int Done();
Index: FileCopy.cc
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/FileCopy.cc,v
retrieving revision 1.71
diff -u -r1.71 FileCopy.cc
--- FileCopy.cc 2001/02/03 11:37:35 1.71
+++ FileCopy.cc 2001/10/17 01:47:50
@@ -41,6 +41,7 @@
#include <fcntl.h>
#include <math.h>
#include "FileCopy.h"
+#include "CopyJob.h"
#include "url.h"
#include "log.h"
#include "misc.h"
@@ -658,6 +659,7 @@
range_limit=FILE_END;
removing=false;
use_cache=true;
+ parent=0;
Suspend(); // don't do anything too early
}
FileCopyPeer::~FileCopyPeer()
@@ -1181,6 +1183,7 @@
delete_stream=true;
create_fg_data=true;
need_seek=false;
+ put_data = false;
can_seek = can_seek0 = stream->can_seek();
if(can_seek && stream->fd!=-1)
{
@@ -1293,6 +1296,13 @@
}
if(seek_pos==0)
return m;
+ }
+
+ if(!put_data) {
+ put_data = true;
+ if(parent && (getfd() == fileno(stdout) || getfd() == fileno(stderr))) {
+ parent->GrabOutput(true);
+ }
}
res=Put_LL(buffer+buffer_ptr,in_buffer);
if(res>0)
Index: FileCopy.h
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/FileCopy.h,v
retrieving revision 1.39
diff -u -r1.39 FileCopy.h
--- FileCopy.h 2001/02/03 11:37:50 1.39
+++ FileCopy.h 2001/10/17 01:47:50
@@ -37,9 +37,12 @@
#include "buffer.h"
#include "FileAccess.h"
#include "Speedometer.h"
+#include "Job.h"
#define FILE_END (-1L)
+class CopyJob;
+
class FileCopyPeer : public Buffer
{
protected:
@@ -67,6 +70,7 @@
protected:
enum direction mode;
+ CopyJob *parent; /* used for status bar disabling */
~FileCopyPeer();
@@ -88,6 +92,7 @@
void SetDate(time_t d);
void SetSize(off_t s);
void SetEntitySize(off_t s) { e_size=s; }
+ void SetParent(CopyJob *j) { parent=j; }
void DontCopyDate() { do_set_date=false; }
bool NeedDate() { return do_set_date; }
@@ -296,6 +301,7 @@
bool delete_stream;
bool create_fg_data;
bool need_seek;
+ bool put_data;
protected:
~FileCopyPeerFDStream();
Index: Job.cc
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/Job.cc,v
retrieving revision 1.21
diff -u -r1.21 Job.cc
--- Job.cc 2001/07/26 09:57:18 1.21
+++ Job.cc 2001/10/17 01:47:50
@@ -41,6 +41,7 @@
jobno=-1;
fg=false;
fg_data=0;
+ no_status=false;
}
void Job::AllocJobno()
@@ -441,6 +442,12 @@
void Job::top_vfprintf(FILE *file,const char *fmt,va_list v)
{
::vfprintf(file,fmt,v);
+}
+
+void Job::GrabOutput(bool perm = false)
+{
+ NoStatus();
+ if(parent) parent->GrabOutput(false);
}
void Job::perror(const char *f)
Index: Job.h
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/Job.h,v
retrieving revision 1.15
diff -u -r1.15 Job.h
--- Job.h 2001/05/29 06:22:59 1.15
+++ Job.h 2001/10/17 01:47:50
@@ -43,6 +43,7 @@
protected:
bool fg;
FgData *fg_data;
+ bool no_status;
virtual ~Job();
@@ -76,6 +77,7 @@
virtual int AcceptSig(int);
virtual void Bg();
virtual void Fg();
+ void NoStatus() { no_status=true; }
char *cmdline;
virtual void ListJobs(int verbose_level,int indent=0);
@@ -105,6 +107,10 @@
void vfprintf(FILE *file,const char *fmt,va_list v);
// CmdExec redefines this, and traps all messages of its children.
virtual void top_vfprintf(FILE *file,const char *fmt,va_list v);
+
+ /* clear any status line for output to stdout or stderr; if perm = true,
+ * disable the status line */
+ virtual void GrabOutput(bool perm = false);
// C-like functions calling vfprintf
void eprintf(const char *fmt,...) PRINTF_LIKE(2,3);
Index: commands.cc
===================================================================
RCS file: /home/lav/cvsroot/lftp/src/commands.cc,v
retrieving revision 1.144
diff -u -r1.144 commands.cc
--- commands.cc 2001/10/15 14:14:10 1.144
+++ commands.cc 2001/10/17 01:47:51
@@ -1282,8 +1282,6 @@
ArgV arg("", ResMgr::Query("cmd:cls-default", 0));
fso.parse_argv(&arg);
- fso.quiet=true;
-
char *a=args->Combine(0);
FileCopyPeer *src_peer=0;
@@ -1304,6 +1302,8 @@
CopyJob *j=new CopyJob(c,a,op);
if(fso.quiet)
j->NoStatus();
+
+ dst_peer->SetParent(j);
xfree(a);
output=0;