File 0005-Add-the-wrapper-code-to-the-Makefile-in-order-to-bui.patch of Package lftp

From 6abce26def9e39e0fe3f5cd05660768d2505300b Mon Sep 17 00:00:00 2001
From: =?utf8?q?Tom=C3=A1=C5=A1=20Chv=C3=A1tal?= <tomas.chvatal@gmail.com>
Date: Wed, 28 Feb 2018 19:11:37 +0100
Subject: [PATCH 5/5] Add the wrapper code to the Makefile in order to build

---
 src/CmdExec.cc  | 32 ++++++++++++++++++++++++++++++++
 src/CmdExec.h   |  3 +++
 src/CopyJob.cc  |  3 ++-
 src/Makefile.am | 12 ++++++++++--
 4 files changed, 47 insertions(+), 3 deletions(-)

diff --git a/src/CmdExec.cc b/src/CmdExec.cc
index 7ce11699..345120ee 100644
--- a/src/CmdExec.cc
+++ b/src/CmdExec.cc
@@ -1234,6 +1234,38 @@ void CmdExec::ChangeSession(FileAccess *new_session)
       ConnectionSlot::Set(slot,session);
 }
 
+void CmdExec::RegisterCompatCommand(const char *name,cmd_creator_t creator,const char *short_desc,const char *long_desc)
+{
+   if(dyn_cmd_table==0)
+   {
+      int count=0;
+      for(const cmd_rec *c=static_cmd_table; c->name; c++)
+        count++;
+      dyn_cmd_table.nset(static_cmd_table,count);
+   }
+   for(int i=0; i<dyn_cmd_table.count(); i++)
+   {
+      cmd_rec *const c=&dyn_cmd_table[i];
+      if(!strcmp(c->name,name))
+      {
+          char *lftp_name=(char*)malloc(5+strlen(name)+1);
+          char *short_d = NULL;
+
+          if (c->short_desc) {
+              short_d = (char*)malloc(5+strlen(c->short_desc)+1);
+              sprintf(short_d, "lftp-%s", c->short_desc);
+              c->short_desc = short_d;
+          }
+
+          sprintf(lftp_name, "lftp-%s", name);
+          c->name = lftp_name;
+            break;
+       }
+   }
+   cmd_rec new_entry={name,creator,short_desc,long_desc};
+   dyn_cmd_table.append(new_entry);
+}
+
 const char *CmdExec::CmdByIndex(int i)
 {
    if(dyn_cmd_table)
diff --git a/src/CmdExec.h b/src/CmdExec.h
index 58f20157..6c004294 100644
--- a/src/CmdExec.h
+++ b/src/CmdExec.h
@@ -238,6 +238,9 @@ public:
    static void RegisterCommand(const char *name,cmd_creator_t creator,
       const char *short_name=0,const char *long_name=0);
 
+   static void RegisterCompatCommand(const char *name,cmd_creator_t creator,
+      const char *short_name=0,const char *long_name=0);
+
    Job *builtin_lcd();
    Job *builtin_cd();
    Job *builtin_open();
diff --git a/src/CopyJob.cc b/src/CopyJob.cc
index f6d76361..14f68bba 100644
--- a/src/CopyJob.cc
+++ b/src/CopyJob.cc
@@ -18,6 +18,7 @@
  */
 
 #include <config.h>
+#include <unistd.h>
 #include "CopyJob.h"
 #include "ArgV.h"
 #include "plural.h"
@@ -270,7 +271,7 @@ void CopyJobEnv::SetCopier(FileCopy *c,const char *n)
 
 xstring& CopyJobEnv::FormatFinalWithPrefix(xstring& s,const char *p)
 {
-   if(no_status)
+   if(no_status || !isatty(1))
       return s;
    if(count==errors)
       return s;
diff --git a/src/Makefile.am b/src/Makefile.am
index 3ed14a05..9054b969 100644
--- a/src/Makefile.am
+++ b/src/Makefile.am
@@ -1,6 +1,6 @@
 pkgverlibdir = $(pkglibdir)/$(VERSION)
 
-bin_PROGRAMS = lftp
+bin_PROGRAMS = lftp lftp_wrapper
 bin_SCRIPTS = lftpget
 pkgdata_SCRIPTS = import-ncftp import-netscape verify-file convert-mozilla-cookies xdg-move
 noinst_SCRIPTS = ftpget
@@ -8,9 +8,10 @@ noinst_SCRIPTS = ftpget
 EXTRA_DIST = $(pkgdata_SCRIPTS) $(bin_SCRIPTS) $(noinst_SCRIPTS)
 
 lftp_SOURCES = lftp.cc complete.h complete.cc lftp_rl.c lftp_rl.h attach.cc attach.h
+lftp_wrapper_SOURCES = lftp-wrapper.c
 
 TASK_MODULES = liblftp-pty.la liblftp-network.la proto-ftp.la proto-http.la proto-file.la proto-fish.la proto-sftp.la
-JOB_MODULES = cmd-mirror.la cmd-sleep.la cmd-torrent.la
+JOB_MODULES = cmd-mirror.la cmd-sleep.la cmd-torrent.la cmd-edit.la compat-mode.la
 if WITH_MODULES
   pkgverlib_LTLIBRARIES = $(TASK_MODULES) $(JOB_MODULES)
 else
@@ -30,6 +31,8 @@ cmd_mirror_la_SOURCES = MirrorJob.cc MirrorJob.h
 cmd_sleep_la_SOURCES  = SleepJob.cc SleepJob.h
 cmd_torrent_la_SOURCES= Torrent.cc Torrent.h TorrentTracker.cc TorrentTracker.h\
  DHT.cc DHT.h Bencode.cc Bencode.h
+cmd_edit_la_SOURCES   = cmd-edit.cc
+compat_mode_la_SOURCES= CompatMode.cc CompatMode.h
 liblftp_pty_la_SOURCES     = PtyShell.cc PtyShell.h lftp_pty.c lftp_pty.h SSH_Access.cc SSH_Access.h
 liblftp_network_la_SOURCES = NetAccess.cc NetAccess.h Resolver.cc Resolver.h\
  lftp_ssl.cc lftp_ssl.h buffer_ssl.cc buffer_ssl.h RateLimit.cc RateLimit.h\
@@ -49,6 +52,8 @@ proto_sftp_la_LDFLAGS = -module -avoid-version -rpath $(pkgverlibdir)
 cmd_mirror_la_LDFLAGS = -module -avoid-version -rpath $(pkgverlibdir)
 cmd_sleep_la_LDFLAGS  = -module -avoid-version -rpath $(pkgverlibdir)
 cmd_torrent_la_LDFLAGS= -module -avoid-version -rpath $(pkgverlibdir)
+cmd_edit_la_LDFLAGS  = -module -avoid-version -rpath $(pkgverlibdir)
+compat_mode_la_LDFLAGS  = -module -avoid-version -rpath $(pkgverlibdir)
 liblftp_pty_la_LDFLAGS     = -avoid-version -rpath $(pkgverlibdir)
 liblftp_network_la_CPPFLAGS = $(AM_CPPFLAGS) $(OPENSSL_CPPFLAGS) $(ZLIB_CPPFLAGS) $(LIBGNUTLS_CFLAGS)
 liblftp_network_la_LDFLAGS = -avoid-version -rpath $(pkgverlibdir)
@@ -98,6 +103,9 @@ lftp_LDFLAGS = -export-dynamic
 lftp_LDADD = liblftp-jobs.la liblftp-tasks.la $(READLINE_LDFLAGS) $(READLINE_LIBS)
 lftp_DEPENDENCIES = liblftp-jobs.la
 
+lftp_wrapper_LDADD = $(GNULIB)
+lftp_wrapper_DEPENDENCIES =
+
 CLEANFILES = *.la
 
 AM_CPPFLAGS = -I$(top_srcdir)/lib -I$(top_srcdir)/trio
-- 
2.16.2