mirror of
https://github.com/php/php-src.git
synced 2024-12-01 13:54:10 +08:00
Added optional port argument to ftp_connect()
This commit is contained in:
parent
33de7a2ea4
commit
4b0707cf32
@ -28,6 +28,8 @@
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#include "php.h"
|
||||
|
||||
#if HAVE_FTP
|
||||
|
@ -28,6 +28,8 @@
|
||||
+----------------------------------------------------------------------+
|
||||
*/
|
||||
|
||||
/* $Id$ */
|
||||
|
||||
#ifndef _FTP_H
|
||||
#define _FTP_H
|
||||
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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
|
||||
|
Loading…
Reference in New Issue
Block a user