Re: [PATCH] Add xfer:log-dir parameter to write transfer_log in arbitrary dir.

2011-02-10 Thread Alexander V. Lukyanov
On Thu, Feb 10, 2011 at 02:07:35PM +0300, Timur Sufiev wrote:
 On Tue, Feb 01, 2011 at 10:42:22AM +0300, Timur Sufiev wrote:
 I think it would be convenient to specify arbitrary directory for
 storing transfer_log (it is useful when several processes using lftp
 I think it is better to specify a file name rather than a directory.
 Use xfer:log-file setting name.
 
 Here it is.

Thanks! I have applied the patch with some modifications.

-- 
   Alexander.


Re: [PATCH] Add xfer:log-dir parameter to write transfer_log in arbitrary dir.

2011-02-07 Thread Alexander V. Lukyanov
On Tue, Feb 01, 2011 at 10:42:22AM +0300, Timur Sufiev wrote:
 I think it would be convenient to specify arbitrary directory for
 storing transfer_log (it is useful when several processes using lftp

I think it is better to specify a file name rather than a directory.
Use xfer:log-file setting name.

-- 
   Alexander.


[PATCH] Add xfer:log-dir parameter to write transfer_log in arbitrary dir.

2011-01-31 Thread Timur Sufiev

Hello!

I think it would be convenient to specify arbitrary directory for 
storing transfer_log (it is useful when several processes using lftp are 
launched simultaneously, and we need to analyze transfer_log for each 
process separately). Here is the patch, feel free to make 
suggestions/corrections etc.


---
 src/FileCopy.cc |   10 +-
 src/ResMgr.cc   |4 
 src/ResMgr.h|1 +
 src/resource.cc |1 +
 4 files changed, 15 insertions(+), 1 deletions(-)

diff --git a/src/FileCopy.cc b/src/FileCopy.cc
index a462cca..ab34959 100644
--- a/src/FileCopy.cc
+++ b/src/FileCopy.cc
@@ -629,7 +629,15 @@ void FileCopy::LogTransfer()
   return;
if(!transfer_log)
{
-  int 
fd=open(dir_file(get_lftp_home(),transfer_log),O_WRONLY|O_APPEND|O_CREAT,0600);

+  const char *dirname = ResMgr::Query(xfer:log-dir, 0);
+  int fd;
+
+  if ( dirname  strcmp(dirname, ) ) {
+
fd=open(dir_file(dirname,transfer_log),O_WRONLY|O_APPEND|O_CREAT,0600);

+  }
+  else
+
fd=open(dir_file(get_lftp_home(),transfer_log),O_WRONLY|O_APPEND|O_CREAT,0600);

+
   if(fd==-1)
  return;
   transfer_log=new Log;
diff --git a/src/ResMgr.cc b/src/ResMgr.cc
index 18f98fb..30b3e99 100644
--- a/src/ResMgr.cc
+++ b/src/ResMgr.cc
@@ -880,6 +880,10 @@ const char *ResMgr::DirReadable(xstring_c *value)
 {
return FileAccessible(value,R_OK|X_OK,1);
 }
+const char *ResMgr::DirWritable(xstring_c *value)
+{
+   return FileAccessible(value,R_OK|X_OK|W_OK,1);
+}

 #ifdef HAVE_ICONV
 CDECL_BEGIN
diff --git a/src/ResMgr.h b/src/ResMgr.h
index 98ae105..ee0b8de 100644
--- a/src/ResMgr.h
+++ b/src/ResMgr.h
@@ -112,6 +112,7 @@ public:
static const char *FileReadable(xstring_c *value);
static const char *FileExecutable(xstring_c *value);
static const char *DirReadable(xstring_c *value);
+   static const char *DirWritable(xstring_c *value);
static const char *CharsetValidate(xstring_c *value);
static const char *NoClosure(xstring_c *);
static bool str2bool(const char *value);
diff --git a/src/resource.cc b/src/resource.cc
index 213b7a7..a89de5a 100644
--- a/src/resource.cc
+++ b/src/resource.cc
@@ -341,6 +341,7 @@ static ResType lftp_vars[] = {
{xfer:verify-command, ,  ResMgr::FileExecutable,0},
{xfer:log, yes,  
ResMgr::BoolValidate,ResMgr::NoClosure},
{xfer:auto-rename, no,  
ResMgr::BoolValidate,ResMgr::NoClosure},

+   {xfer:log-dir,  ,  ResMgr::DirWritable,0},

 #if USE_SSL
{ssl:ca-file, ,  
ResMgr::FileReadable,ResMgr::NoClosure},

--
1.7.3.5

--
С уважением,
Суфиев Тимур