]> granicus.if.org Git - php/commitdiff
Added optional port argument to ftp_connect()
authorAndrew Skalski <askalski@php.net>
Wed, 22 Sep 1999 16:07:41 +0000 (16:07 +0000)
committerAndrew Skalski <askalski@php.net>
Wed, 22 Sep 1999 16:07:41 +0000 (16:07 +0000)
ext/ftp/ftp.c
ext/ftp/ftp.h
ext/ftp/php_ftp.c
ext/ftp/php_ftp.h

index f8047408ca42f58b7ee58e07d79a1a64ce29c87b..4cd11238943a3814bbecaf88efb277f4a714c6f4 100644 (file)
@@ -28,6 +28,8 @@
    +----------------------------------------------------------------------+
  */
 
+/* $Id$ */
+
 #include "php.h"
 
 #if HAVE_FTP
index f9a2cf549c9bedb9a1758798200ce987a3d14754..800a9a197f526fbacc960112473340e193ff08a8 100644 (file)
@@ -28,6 +28,8 @@
    +----------------------------------------------------------------------+
  */
 
+/* $Id$ */
+
 #ifndef        _FTP_H
 #define        _FTP_H
 
index fdffdf7b15d41955f5b4df0064f1623885ef07f1..dc7d9f558543be15c334b879894cbbf38ed7e43c 100644 (file)
@@ -28,6 +28,8 @@
    +----------------------------------------------------------------------+
  */
 
+/* $Id$ */
+
 #include "php.h"
 
 #if HAVE_FTP
@@ -99,24 +101,39 @@ int PHP_MINIT_FUNCTION(INIT_FUNC_ARGS)
        return SUCCESS;
 }
 
-/* {{{ proto int ftp_connect(string host)
+/* {{{ proto int ftp_connect(string host [, int port])
    Open a FTP stream */
 PHP_FUNCTION(ftp_connect)
 {
-       pval            *arg1;
+       pval            *arg1, *arg2;
        int             id;
        ftpbuf_t        *ftp;
+       short           port = 0;
 
        /* arg1 - hostname
+        * arg2 - [port]
         */
-       if (ARG_COUNT(ht) != 1 || getParameters(ht, 1, &arg1) == FAILURE) {
+       switch (ARG_COUNT(ht)) {
+       case 1:
+               if (getParameters(ht, 1, &arg1) == FAILURE) {
+                       WRONG_PARAM_COUNT;
+               }
+               break;
+       case 2:
+               if (getParameters(ht, 2, &arg1, &arg2) == FAILURE) {
+                       WRONG_PARAM_COUNT;
+               }
+               convert_to_long(arg2);
+               port = arg2->value.lval;
+               break;
+       default:
                WRONG_PARAM_COUNT;
        }
 
        convert_to_string(arg1);
 
        /* connect */
-       ftp = ftp_open(arg1->value.str.val, 0);
+       ftp = ftp_open(arg1->value.str.val, htons(port));
        if (ftp == NULL)
                RETURN_FALSE;
 
index bc46683ddcab2d540b522a854eba3c7cf57b1d8c..b86b14c58e64f62d17ebc91a254a65caf49497f6 100644 (file)
@@ -1,3 +1,33 @@
+/*
+   +----------------------------------------------------------------------+
+   | PHP HTML Embedded Scripting Language Version 3.0                     |
+   +----------------------------------------------------------------------+
+   | Copyright (c) 1997-1999 PHP Development Team (See Credits file)      |
+   +----------------------------------------------------------------------+
+   | This program is free software; you can redistribute it and/or modify |
+   | it under the terms of one of the following licenses:                 |
+   |                                                                      |
+   |  A) the GNU General Public License as published by the Free Software |
+   |     Foundation; either version 2 of the License, or (at your option) |
+   |     any later version.                                               |
+   |                                                                      |
+   |  B) the PHP License as published by the PHP Development Team and     |
+   |     included in the distribution in the file: LICENSE                |
+   |                                                                      |
+   | This program is distributed in the hope that it will be useful,      |
+   | but WITHOUT ANY WARRANTY; without even the implied warranty of       |
+   | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the        |
+   | GNU General Public License for more details.                         |
+   |                                                                      |
+   | You should have received a copy of both licenses referred to here.   |
+   | If you did not, or have any questions about PHP licensing, please    |
+   | contact core@php.net.                                                |
+   +----------------------------------------------------------------------+
+   | Authors:                                                             |
+   |          Andrew Skalski      <askalski@chek.com>                     |
+   +----------------------------------------------------------------------+
+ */
+
 /* $Id$ */
 
 #ifndef        _INCLUDED_FTP_H