+----------------------------------------------------------------------+
*/
+/* $Id$ */
+
#include "php.h"
#if HAVE_FTP
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;
+/*
+ +----------------------------------------------------------------------+
+ | 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