commit-inetutils
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-252-gca858


From: Mats Erik Andersson
Subject: [SCM] GNU Inetutils branch, master, updated. inetutils-1_9_1-252-gca8585c
Date: Wed, 13 Mar 2013 14:50:42 +0000

This is an automated email from the git hooks/post-receive script. It was
generated because a ref change was pushed to the repository containing
the project "GNU Inetutils ".

The branch, master has been updated
       via  ca8585c47b89e199b359e867854802faab5b4c74 (commit)
      from  baf8f5de12986c0d943ce012ea0b7e9e6d4c1940 (commit)

Those revisions listed above that are new to this repository have
not appeared on any other notification email; so we list those
revisions in full, below.

- Log -----------------------------------------------------------------
http://git.savannah.gnu.org/cgit/inetutils.git/commit/?id=ca8585c47b89e199b359e867854802faab5b4c74


commit ca8585c47b89e199b359e867854802faab5b4c74
Author: Mats Erik Andersson <address@hidden>
Date:   Mon Mar 11 00:43:02 2013 +0100

    rcp: Implement directory switch.

diff --git a/ChangeLog b/ChangeLog
index cab6285..6091d80 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,24 @@
+2013-03-11  Mats Erik Andersson  <address@hidden>
+
+       rcp: Functional option `--target-directory'.
+       Implement the missing case where `-d' is given
+       an argument.
+
+       * src/rcp.c (target): New variable.
+       (parse_opt) <'d'>: If `arg' has contents, copy it
+       to `target'.
+       (main): Only one command line argument is needed for
+       calls with set `target'.  If `target' is not set,
+       extract it from the very last command line argument,
+       and decrease `argc' to reflect this action.  Apply
+       colon() and verify() to `target'.
+       (toremote): Extract host and user name from `target'.
+       Let I loop until `argc', since `argc' no longer includes
+       the target directory.
+       (tolocal): New variable VECT.  Loop I until `argc'.
+       Exchange `target' for `argv[argc - 1]'.  Fix VECT to
+       be a short array with `target', and apply it to sink().
+
 2013-03-09  Mats Erik Andersson  <address@hidden>
 
        rcp: Portability fixes.
diff --git a/src/rcp.c b/src/rcp.c
index 37fb8e6..6172804 100644
--- a/src/rcp.c
+++ b/src/rcp.c
@@ -145,6 +145,7 @@ const char arg_doc[] = "SOURCE DEST\n"
                        "SOURCE... DIRECTORY\n"
                        "--target-directory=DIRECTORY SOURCE...";
 
+char *target = NULL;
 int preserve_option;
 int from_option, to_option;
 int iamremote, iamrecursive, targetshouldbedirectory;
@@ -243,6 +244,8 @@ parse_opt (int key, char *arg, struct argp_state *state 
_GL_UNUSED_PARAMETER)
       /* Server options. */
     case 'd':
       targetshouldbedirectory = 1;
+      if (arg && strlen (arg))
+       target = xstrdup (arg); /* Client side use.  */
       break;
 
     case 'f':          /* "from" */
@@ -356,7 +359,7 @@ main (int argc, char *argv[])
       exit (errs);
     }
 
-  if (argc < 2)
+  if (argc < 1 || (argc < 2 && !(target && strlen (target))))
     error (EXIT_FAILURE, 0, "not enough arguments");
 
   if (argc > 2)
@@ -388,14 +391,23 @@ main (int argc, char *argv[])
   rem = -1;
   signal (SIGPIPE, lostconn);
 
-  targ = colon (argv[argc - 1]);
+  /* Without a specified target, the last argument
+   * is extracted to serve as target.
+   */
+  if (!target || !strlen (target))
+    {
+      target = xstrdup (argv[argc - 1]);
+      argc--;                  /* Do not count target directory.  */
+    }
+
+  targ = colon (target);
   if (targ)                    /* Dest is remote host. */
     toremote (targ, argc, argv);
   else
     {
       tolocal (argc, argv);    /* Dest is local host. */
       if (targetshouldbedirectory)
-       verifydir (argv[argc - 1]);
+       verifydir (target);
     }
   exit (errs);
 }
@@ -414,12 +426,12 @@ toremote (char *targ, int argc, char *argv[])
   if (*targ == 0)
     targ = ".";
 
-  thost = strchr (argv[argc - 1], '@');
+  thost = strchr (target, '@');
   if (thost)
     {
       /* address@hidden */
       *thost++ = 0;
-      tuser = argv[argc - 1];
+      tuser = target;
       if (*tuser == '\0')
        tuser = NULL;
       else if (!okname (tuser))
@@ -427,11 +439,11 @@ toremote (char *targ, int argc, char *argv[])
     }
   else
     {
-      thost = argv[argc - 1];
+      thost = target;
       tuser = NULL;
     }
 
-  for (i = 0; i < argc - 1; i++)
+  for (i = 0; i < argc; i++)
     {
       src = colon (argv[i]);
       if (src)
@@ -567,24 +579,24 @@ void
 tolocal (int argc, char *argv[])
 {
   int i, len, tos;
-  char *bp, *host, *src, *suser;
+  char *bp, *host, *src, *suser, *vect[1];
 #if defined IP_TOS && defined IPPROTO_IP && defined IPTOS_THROUGHPUT
   struct sockaddr_storage ss;
   socklen_t sslen;
 #endif
 
-  for (i = 0; i < argc - 1; i++)
+  for (i = 0; i < argc; i++)
     {
       src = colon (argv[i]);
       if (!src)
        {                       /* Local to local. */
          len = strlen (PATH_CP) + strlen (argv[i]) +
-           strlen (argv[argc - 1]) + 20;
+               strlen (target) + 20;
          if (asprintf (&bp, "exec %s%s%s %s %s",
                        PATH_CP,
                        iamrecursive ? " -R" : "",
                        preserve_option ? " -p" : "",
-                       argv[i], argv[argc - 1]) < 0)
+                       argv[i], target) < 0)
            xalloc_die ();
          if (susystem (bp, userid))
            ++errs;
@@ -643,7 +655,8 @@ tolocal (int argc, char *argv[])
        if (errno != ENOPROTOOPT)
          error (0, errno, "TOS (ignored)");
 #endif
-      sink (1, argv + argc - 1);
+      vect[0] = target;
+      sink (1, vect);
       seteuid (effuid);
       close (rem);
       rem = -1;

-----------------------------------------------------------------------

Summary of changes:
 ChangeLog |   21 +++++++++++++++++++++
 src/rcp.c |   37 +++++++++++++++++++++++++------------
 2 files changed, 46 insertions(+), 12 deletions(-)


hooks/post-receive
-- 
GNU Inetutils 



reply via email to

[Prev in Thread] Current Thread [Next in Thread]