You are viewing a plain text version of this content. The canonical link for it is here.
Posted to mod_ftp-commits@incubator.apache.org by wr...@apache.org on 2006/12/13 00:28:16 UTC

svn commit: r486433 - /incubator/mod_ftp/trunk/modules/ftp/ftp_commands.c

Author: wrowe
Date: Tue Dec 12 16:28:15 2006
New Revision: 486433

URL: http://svn.apache.org/viewvc?view=rev&rev=486433
Log:
PORT and PASV are defined in terms of IPV4.  RFC 2428 defines EPRT/EPSV
for IPV4/IPV6 semantics, but we will ignore that issue from the perspective
of this pair of implementations and extend those later.

Gets mod_ftp compiling to httpd-2.2/apr-1

Modified:
    incubator/mod_ftp/trunk/modules/ftp/ftp_commands.c

Modified: incubator/mod_ftp/trunk/modules/ftp/ftp_commands.c
URL: http://svn.apache.org/viewvc/incubator/mod_ftp/trunk/modules/ftp/ftp_commands.c?view=diff&rev=486433&r1=486432&r2=486433
==============================================================================
--- incubator/mod_ftp/trunk/modules/ftp/ftp_commands.c (original)
+++ incubator/mod_ftp/trunk/modules/ftp/ftp_commands.c Tue Dec 12 16:28:15 2006
@@ -22,6 +22,8 @@
 
 #include "ftp_config.h"
 #include "mod_ftp.h"
+#include "apr_version.h"
+#include "apr_network_io.h"
 
 /* seem to need this for LONG_MAX */
 #if APR_HAVE_LIMITS_H
@@ -181,7 +183,7 @@
  * Returns: 1 on error or 0 on success, a1 and a2 are modified to point
  *          to the correct values.
  */
-int ftp_parse2(apr_pool_t *pool, const char *cmd, char **a1, char **a2)
+static int ftp_parse2(apr_pool_t *pool, const char *cmd, char **a1, char **a2)
 {
     *a1 = ap_getword_white(pool, &cmd);
     *a2 = apr_pstrdup(pool, cmd);
@@ -722,7 +724,7 @@
             continue;
         }
 
-        for (test = dirp->name; sl = strchr(test, '/'); test = sl + 1)
+        for (test = dirp->name; (sl = ap_strchr_c(test, '/')); test = sl + 1)
         /* noop */ ;
 
         if (!strcmp(".", test)) {
@@ -759,7 +761,8 @@
                 fc->traffic += nbytes;
                 
                 for (decend = dirp->child; decend; decend = decend->next) {
-                    for (test = dirp->name; sl = strchr(test, '/'); test = sl + 1)
+                    for (test = dirp->name; (sl = ap_strchr_c(test, '/'));
+                                             test = sl + 1)
                     /* noop */ ;
 
                     if (!strcmp(".", test)) {
@@ -816,7 +819,7 @@
         ap_destroy_sub_req(rr);
         return FTP_REPLY_FILE_NOT_FOUND;
     }
-    apr_explode_localtime(&t, rr->finfo.mtime);
+    apr_time_exp_lt(&t, rr->finfo.mtime);
     fc->response_notes = apr_psprintf(r->pool,
                                       "%04d%02d%02d%02d%02d%02d",
                                       1900 + t.tm_year, t.tm_mon + 1,
@@ -957,7 +960,7 @@
     bb = apr_brigade_create(r->pool, c->bucket_alloc);
 
     for (dirp = direntry; dirp; dirp = dirp->next) {
-        for (test = dirp->name; sl = strchr(test, '/'); test = sl + 1)
+        for (test = dirp->name; (sl = ap_strchr_c(test, '/')); test = sl + 1)
         /* noop */ ;
 
         if (!strcmp(".", test)) {
@@ -1382,7 +1385,11 @@
         fc->passive_created = -1;
     }
 
+#if APR_MAJOR_VERSION < 1
     rv = apr_socket_create_ex(&s, APR_INET, SOCK_STREAM, APR_PROTO_TCP, c->pool);
+#else
+    rv = apr_socket_create(&s, APR_INET, SOCK_STREAM, APR_PROTO_TCP, c->pool);
+#endif
     if (rv != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_ERR, rv, c->base_server,
                      "Couldn't create passive socket");
@@ -1408,19 +1415,21 @@
     apr_socket_addr_get(&sa, APR_LOCAL, s);
 
     if (fsc->pasv_bindaddr) {
-        apr_sockaddr_ip_set(sa, fsc->pasv_bindaddr);   
+        apr_sockaddr_info_get(&sa, fsc->pasv_bindaddr, sa->family,
+                              0, APR_IPV4_ADDR_OK, r->pool);
     }
     else {
-        apr_sockaddr_ip_set(sa, c->local_ip);
+        apr_sockaddr_info_get(&sa, c->local_ip, sa->family,
+                              0, APR_IPV4_ADDR_OK, r->pool);
     }
 
     found_port = 0;
     port = fsc->pasv_min;
     while (!found_port) {
 
-        apr_sockaddr_port_set(sa, port); /* Magic here when port = 0 */
+        sa->port = port; /* Magic here when port = 0 */
 
-        rv = apr_bind(s, sa);
+        rv = apr_socket_bind(s, sa);
         if (rv == APR_SUCCESS) {
             found_port = 1;
             break;
@@ -1448,7 +1457,7 @@
          * the system by sleeping before we attempt to bind again
          */
         for (tries = 0;; tries++) {
-            rv = apr_bind(s, sa);
+            rv = apr_socket_bind(s, sa);
             if (rv == APR_SUCCESS) {
                 found_port = 1;
                 break;
@@ -1464,7 +1473,7 @@
         }
     }
 
-    rv = apr_listen(s, 1);
+    rv = apr_socket_listen(s, 1);
     if (rv != APR_SUCCESS) {
         ap_log_error(APLOG_MARK, APLOG_ERR, rv, c->base_server,
                      "Couldn't listen on passive socket");
@@ -1488,7 +1497,7 @@
         *period = ',';
     }
 
-    apr_sockaddr_port_get(&port, sa);
+    port = sa->port;
     high = ((port & 0xff00) >> 8);
     low = (port & 0x00ff); 
     fc->response_notes = apr_psprintf(r->pool,
@@ -1590,7 +1599,12 @@
     }
 #endif
         
+#if APR_MAJOR_VERSION < 1
     rv = apr_socket_create_ex(&s, APR_INET, SOCK_STREAM, APR_PROTO_TCP, c->pool);
+#else
+    rv = apr_socket_create(&s, APR_INET, SOCK_STREAM, APR_PROTO_TCP, c->pool);
+#endif
+
     if (rv != APR_SUCCESS) {
 #if !defined(WIN32) && !defined(HPUX)
         if ((fsc->active_min != -1) && (fsc->active_min < 1024)) {
@@ -1607,15 +1621,16 @@
     if (fsc->active_min != -1) {
         short port_num = fsc->active_min + 
                    ((int) (rand() % (fsc->active_max - fsc->active_min + 1)));
-        apr_sockaddr_port_set(sa, port_num);
+        sa->port = port_num;
     }
     else {
-        apr_sockaddr_port_set(sa, 0);
+        sa->port = 0;
     }
 
-    apr_sockaddr_ip_set(sa, c->local_ip);
+    apr_sockaddr_info_get(&sa, c->local_ip, sa->family,
+                          sa->port, APR_IPV4_ADDR_OK, r->pool);
     apr_socket_opt_set(s, APR_SO_REUSEADDR, 1);
-    rv = apr_bind(s, sa);
+    rv = apr_socket_bind(s, sa);
 
 #if !defined(WIN32) && !defined(HPUX)
     if ((fsc->active_min != -1) && (fsc->active_min < 1024)) {
@@ -1630,8 +1645,8 @@
     }
 
     apr_socket_addr_get(&fc->clientsa, APR_LOCAL, s);
-    apr_sockaddr_port_set(fc->clientsa, port);
-    apr_sockaddr_ip_set(fc->clientsa, ip_addr);
+    apr_sockaddr_info_get(&fc->clientsa, ip_addr, fc->clientsa->family,
+                          port, APR_IPV4_ADDR_OK, r->pool);
 
     fc->response_notes = apr_psprintf(r->pool, FTP_MSG_SUCCESS, r->method);
     fc->passive_created = -1; /* Redundant but just for clarity */