gnu-arch-users
[Top][All Lists]
Advanced

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

[Gnu-arch-users] [PATCH] ftp port specification in ftp archives url


From: PASTOR Michel
Subject: [Gnu-arch-users] [PATCH] ftp port specification in ftp archives url
Date: Wed, 28 Jan 2004 23:52:15 +0100
User-agent: Mutt/1.4i

Hi,
  Here are the changes to apply to be able to specify a port
  in the ftp archives urls to use a non-default ftp port
  e.g. ftp://user:address@hidden:port/...

It applies on address@hidden/tla--devo--1.2--patch-71
The code is based on the port extraction code in pfs-dav.c

Cheers,
  Michel

*************** CUT *************
--- orig/libarch/pfs-ftp.c
+++ mod/libarch/pfs-ftp.c
@@ -249,6 +249,7 @@
   t_uchar * user = 0;
   t_uchar * passwd = 0;
   t_uchar * hostname = 0;
+  int ftp_port;
   int status = -1;
   t_uchar * text = 0;
   long text_len = 0;
@@ -305,9 +306,24 @@
         }
     }
 
+  {
+    int ign;
+    t_uchar * portstr = str_chr_index(hostname, ':');
+
+    ftp_port = 21;
+    if (portstr)
+       *portstr++ = 0;
+
+    if (portstr && (0 > cvt_decimal_to_uint (&ign, &ftp_port, portstr, 
str_length (portstr))))
+      {
+       safe_printfmt (2, "illegal port number in uri -- %s\n", uri);
+       exit (2);
+      }
+  }
+
   /* hostname, user, passwd allocated strings.
    */
-  answer->in_fd = url_inet_client (&errn, hostname, 21);
+  answer->in_fd = url_inet_client (&errn, hostname, ftp_port);
 
   if (answer->in_fd < 0)
     {
@@ -365,7 +381,7 @@
 
   if (status)
     {
-      safe_printfmt (2, "ftp_client_connect: ftp error connecting to %s\n", 
hostname);
+      safe_printfmt (2, "ftp_client_connect: ftp error connecting to %s:%d\n", 
hostname, ftp_port);
       safe_printfmt (2, "    %d: %.*s\n", code, (int)text_len, text);
       exit (2);
     }
*************** CUT *************





reply via email to

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