From 99dada0ab68e663b26e24e2363c4613c36aa717f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?P=C3=A9ter=20Dimitrov?= Date: Fri, 9 Mar 2018 13:30:40 +0100 Subject: ftp: Remove references to inets Change-Id: I19bd2f1d4a35cbc5c233ebc8b2a9d52bbd37f047 --- lib/ftp/doc/src/Makefile | 2 +- lib/ftp/doc/src/ftp.xml | 51 +++++++++++++++++++++++++++++++++--------- lib/ftp/doc/src/ftp_client.xml | 12 +++++----- lib/ftp/doc/src/part.xml | 2 +- lib/ftp/doc/src/ref_man.xml | 4 ++-- lib/ftp/src/ftp.erl | 14 ++++++++++-- lib/ftp/test/Makefile | 2 +- lib/ftp/test/ftp.config | 2 +- 8 files changed, 65 insertions(+), 24 deletions(-) diff --git a/lib/ftp/doc/src/Makefile b/lib/ftp/doc/src/Makefile index 01ea2f970b..e96a9c032f 100644 --- a/lib/ftp/doc/src/Makefile +++ b/lib/ftp/doc/src/Makefile @@ -59,7 +59,7 @@ XML_FILES = \ $(XML_REF3_FILES) \ $(XML_APPLICATION_FILES) -# GIF_FILES = inets.gif +# GIF_FILES = ftp.gif # ---------------------------------------------------- diff --git a/lib/ftp/doc/src/ftp.xml b/lib/ftp/doc/src/ftp.xml index 42bece4d38..18770ebcb4 100644 --- a/lib/ftp/doc/src/ftp.xml +++ b/lib/ftp/doc/src/ftp.xml @@ -38,20 +38,19 @@ according to a subset of the File Transfer Protocol (FTP), see RFC 959.

-

As from Inets 4.4.1, the FTP - client always tries to use passive FTP mode and only resort +

The FTP client always tries to use passive FTP mode and only resort to active FTP mode if this fails. This default behavior can be changed by start option mode.

An FTP client can be started in two ways. One is using the - Inets service framework, - the other is to start it directly as a standalone process + service_start function, + the other is to start it directly as a standalone process using function open.

For a simple example of an FTP session, see - Inets User's Guide.

+ FTP User's Guide.

In addition to the ordinary functions for receiving and sending files (see recv/2, recv/3, send/2, and @@ -82,11 +81,9 @@ FTP CLIENT SERVICE START/STOP

The FTP client can be started and stopped dynamically in runtime by - calling the Inets application API - inets:start(ftpc, ServiceConfig), - or inets:start(ftpc, ServiceConfig, How), and - inets:stop(ftpc, Pid). - For details, see inets(3).

+ calling the ftp application API + ftp:start_service(ServiceConfig) and + ftp:stop_service(Pid).

The available configuration options are as follows:

@@ -273,6 +270,7 @@ + account(Pid, Account) -> ok | {error, Reason} Specifies which account to use. @@ -564,7 +562,7 @@

Starts a standalone FTP client process - (without the Inets service framework) and + (without the ftp service framework) and opens a session with the FTP server at Host.

If option {tls, tls_options()} is present, the FTP session @@ -796,6 +794,37 @@ + + start_service(ServiceConfig) -> {ok, Pid} | {error, Reason} + Dynamically starts an FTP + session after the ftp application has been started. + + ServiceConfig = [{Option, Value}] + Option = property() + Value = term() + + +

Dynamically starts an FTP session after the ftp + application has been started.

+ +

As long as the ftp application is operational, + the FTP sessions are supervised and can be soft code upgraded.

+
+
+
+ + + stop_service(Reference) -> ok | {error, Reason} + Stops an FTP session. + + Reference = pid() | term() - service-specified reference + Reason = term() + + +

Stops a started FTP session.

+
+
+ type(Pid, Type) -> ok | {error, Reason} Sets transfer type to asciior binary. diff --git a/lib/ftp/doc/src/ftp_client.xml b/lib/ftp/doc/src/ftp_client.xml index 84705c1dba..047b055be7 100644 --- a/lib/ftp/doc/src/ftp_client.xml +++ b/lib/ftp/doc/src/ftp_client.xml @@ -4,7 +4,7 @@
- 20042016 + 20042018 Ericsson AB. All Rights Reserved. @@ -23,7 +23,7 @@ FTP Client - Ingela Anderton Andin + Péter Dimitrov @@ -53,9 +53,9 @@ the user guest with password password logs on to the remote host erlang.org:

inets:start(). + 1> ftp:start(). ok - 2> {ok, Pid} = inets:start(ftpc, [{host, "erlang.org"}]). + 2> {ok, Pid} = ftp:start_service([{host, "erlang.org"}]). {ok,<0.22.0>} 3> ftp:user(Pid, "guest", "password"). ok @@ -69,7 +69,9 @@ ok 8> ftp:recv(Pid, "appl.erl"). ok - 9> inets:stop(ftpc, Pid). + 9> ftp:stop_service(Pid). + ok + 10> ftp:stop(). ok ]]>

The file diff --git a/lib/ftp/doc/src/part.xml b/lib/ftp/doc/src/part.xml index 148b588d8f..ec05f5ac76 100644 --- a/lib/ftp/doc/src/part.xml +++ b/lib/ftp/doc/src/part.xml @@ -22,7 +22,7 @@ - Inets User's Guide + FTP User's Guide Péter Dimitrov 2018-02-26 diff --git a/lib/ftp/doc/src/ref_man.xml b/lib/ftp/doc/src/ref_man.xml index a3936b02ed..925842610d 100644 --- a/lib/ftp/doc/src/ref_man.xml +++ b/lib/ftp/doc/src/ref_man.xml @@ -22,10 +22,10 @@ - Inets Reference Manual + FTP Reference Manual Péter Dimitrov - 2018-02-26 + 2018-03-09 1.0 ref_man.xml

diff --git a/lib/ftp/src/ftp.erl b/lib/ftp/src/ftp.erl index e633c9343d..7b2bbfc164 100644 --- a/lib/ftp/src/ftp.erl +++ b/lib/ftp/src/ftp.erl @@ -32,7 +32,6 @@ ]). %% Added for backward compatibility -%% Called by inets:start() -export([start_standalone/1]). -export([start_link/1, start_link/2]). @@ -2082,7 +2081,7 @@ setup_ctrl_connection(Host, Port, Timeout, State) -> {ok, IpFam, CSock} -> NewState = State#state{csock = {tcp, CSock}, ipfamily = IpFam}, activate_ctrl_connection(NewState), - case Timeout - inets_lib:millisec_passed(MsTime) of + case Timeout - millisec_passed(MsTime) of Timeout2 when (Timeout2 >= 0) -> {ok, NewState#state{caller = open}, Timeout2}; _ -> @@ -2588,3 +2587,14 @@ validate_options([{Key, Value}|Options], ValidOptions, Acc) -> end; validate_options([_|Options], ValidOptions, Acc) -> validate_options(Options, ValidOptions, Acc). + +%% Help function, elapsed milliseconds since T0 +millisec_passed({_,_,_} = T0 ) -> + %% OTP 17 and earlier + timer:now_diff(erlang:timestamp(), T0) div 1000; + +millisec_passed(T0) -> + %% OTP 18 + erlang:convert_time_unit(erlang:monotonic_time() - T0, + native, + micro_seconds) div 1000. diff --git a/lib/ftp/test/Makefile b/lib/ftp/test/Makefile index e1619e2142..147f8e5dd6 100644 --- a/lib/ftp/test/Makefile +++ b/lib/ftp/test/Makefile @@ -159,7 +159,7 @@ ERL_COMPILE_FLAGS += \ # erl -sname kalle -pa ../ebin # If you intend to run the test suite locally (private), then # there is some requirements: -# 1) INETS_PRIV_DIR must be created +# 1) FTP_PRIV_DIR must be created # ---------------------------------------------------- tests debug opt: $(BUILDTARGET) diff --git a/lib/ftp/test/ftp.config b/lib/ftp/test/ftp.config index 6c9077594d..2600237da9 100644 --- a/lib/ftp/test/ftp.config +++ b/lib/ftp/test/ftp.config @@ -1 +1 @@ -[{inets,[{services,[{httpd,"/ldisk/tests/bmk/inets/priv_dir/8099.conf"}]}]}]. +[]. \ No newline at end of file -- cgit v1.2.3