summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/ftp/ftp.c2
-rw-r--r--ext/ftp/ftp.h2
-rw-r--r--ext/ftp/php_ftp.c25
-rw-r--r--ext/ftp/php_ftp.h30
4 files changed, 55 insertions, 4 deletions
diff --git a/ext/ftp/ftp.c b/ext/ftp/ftp.c
index f8047408ca..4cd1123894 100644
--- a/ext/ftp/ftp.c
+++ b/ext/ftp/ftp.c
@@ -28,6 +28,8 @@
+----------------------------------------------------------------------+
*/
+/* $Id$ */
+
#include "php.h"
#if HAVE_FTP
diff --git a/ext/ftp/ftp.h b/ext/ftp/ftp.h
index f9a2cf549c..800a9a197f 100644
--- a/ext/ftp/ftp.h
+++ b/ext/ftp/ftp.h
@@ -28,6 +28,8 @@
+----------------------------------------------------------------------+
*/
+/* $Id$ */
+
#ifndef _FTP_H
#define _FTP_H
diff --git a/ext/ftp/php_ftp.c b/ext/ftp/php_ftp.c
index fdffdf7b15..dc7d9f5585 100644
--- a/ext/ftp/php_ftp.c
+++ b/ext/ftp/php_ftp.c
@@ -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;
diff --git a/ext/ftp/php_ftp.h b/ext/ftp/php_ftp.h
index bc46683ddc..b86b14c58e 100644
--- a/ext/ftp/php_ftp.h
+++ b/ext/ftp/php_ftp.h
@@ -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