aboutsummaryrefslogtreecommitdiffstats
path: root/lib/ftp
diff options
context:
space:
mode:
authorPéter Dimitrov <[email protected]>2018-03-09 13:30:40 +0100
committerPéter Dimitrov <[email protected]>2018-03-28 10:19:38 +0200
commit99dada0ab68e663b26e24e2363c4613c36aa717f (patch)
tree80615bef0b359135df505d85ceae0aa753cc3336 /lib/ftp
parent347a39468180c1410cedaee465821cfb10c2fcd7 (diff)
downloadotp-99dada0ab68e663b26e24e2363c4613c36aa717f.tar.gz
otp-99dada0ab68e663b26e24e2363c4613c36aa717f.tar.bz2
otp-99dada0ab68e663b26e24e2363c4613c36aa717f.zip
ftp: Remove references to inets
Change-Id: I19bd2f1d4a35cbc5c233ebc8b2a9d52bbd37f047
Diffstat (limited to 'lib/ftp')
-rw-r--r--lib/ftp/doc/src/Makefile2
-rw-r--r--lib/ftp/doc/src/ftp.xml51
-rw-r--r--lib/ftp/doc/src/ftp_client.xml12
-rw-r--r--lib/ftp/doc/src/part.xml2
-rw-r--r--lib/ftp/doc/src/ref_man.xml4
-rw-r--r--lib/ftp/src/ftp.erl14
-rw-r--r--lib/ftp/test/Makefile2
-rw-r--r--lib/ftp/test/ftp.config2
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
<url href="http://www.ietf.org/rfc/rfc959.txt">RFC 959</url>.</p>
- <p>As from <c>Inets</c> 4.4.1, the FTP
- client always tries to use passive FTP mode and only resort
+ <p>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 <seealso marker="#mode">mode</seealso>.</p>
<marker id="two_start"></marker>
<p>An FTP client can be started in two ways. One is using the
- <seealso marker="#service_start">Inets service framework</seealso>,
- the other is to start it directly as a standalone process
+ <seealso marker="#service_start">service_start</seealso> function,
+ the other is to start it directly as a standalone process
using function <seealso marker="#open">open</seealso>.</p>
<p>For a simple example of an FTP session, see
- <seealso marker="ftp_client">Inets User's Guide</seealso>.</p>
+ <seealso marker="ftp_client">FTP User's Guide</seealso>.</p>
<p>In addition to the ordinary functions for receiving and sending
files (see <c>recv/2</c>, <c>recv/3</c>, <c>send/2</c>, and
@@ -82,11 +81,9 @@
<title>FTP CLIENT SERVICE START/STOP</title>
<p>The FTP client can be started and stopped dynamically in runtime by
- calling the <c>Inets</c> application API
- <c>inets:start(ftpc, ServiceConfig)</c>,
- or <c>inets:start(ftpc, ServiceConfig, How)</c>, and
- <c>inets:stop(ftpc, Pid)</c>.
- For details, see <seealso marker="inets">inets(3)</seealso>.</p>
+ calling the <c>ftp</c> application API
+ <c>ftp:start_service(ServiceConfig)</c> and
+ <c>ftp:stop_service(Pid)</c>.</p>
<p>The available configuration options are as follows:</p>
@@ -273,6 +270,7 @@
</section>
<funcs>
+
<func>
<name>account(Pid, Account) -> ok | {error, Reason}</name>
<fsummary>Specifies which account to use.</fsummary>
@@ -564,7 +562,7 @@
<desc>
<p>Starts a standalone FTP client process
- (without the <c>Inets</c> service framework) and
+ (without the <c>ftp</c> service framework) and
opens a session with the FTP server at <c>Host</c>. </p>
<p>If option <c>{tls, tls_options()}</c> is present, the FTP session
@@ -797,6 +795,37 @@
</func>
<func>
+ <name>start_service(ServiceConfig) -> {ok, Pid} | {error, Reason}</name>
+ <fsummary>Dynamically starts an <c>FTP</c>
+ session after the <c>ftp</c> application has been started.</fsummary>
+ <type>
+ <v>ServiceConfig = [{Option, Value}]</v>
+ <v>Option = property()</v>
+ <v>Value = term()</v>
+ </type>
+ <desc>
+ <p>Dynamically starts an <c>FTP</c> session after the <c>ftp</c>
+ application has been started.</p>
+ <note>
+ <p>As long as the <c>ftp</c> application is operational,
+ the FTP sessions are supervised and can be soft code upgraded.</p>
+ </note>
+ </desc>
+ </func>
+
+ <func>
+ <name>stop_service(Reference) -> ok | {error, Reason} </name>
+ <fsummary>Stops an FTP session.</fsummary>
+ <type>
+ <v>Reference = pid() | term() - service-specified reference</v>
+ <v>Reason = term()</v>
+ </type>
+ <desc>
+ <p>Stops a started FTP session.</p>
+ </desc>
+ </func>
+
+ <func>
<name>type(Pid, Type) -> ok | {error, Reason}</name>
<fsummary>Sets transfer type to <c>ascii</c>or <c>binary</c>.</fsummary>
<type>
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 @@
<chapter>
<header>
<copyright>
- <year>2004</year><year>2016</year>
+ <year>2004</year><year>2018</year>
<holder>Ericsson AB. All Rights Reserved.</holder>
</copyright>
<legalnotice>
@@ -23,7 +23,7 @@
</legalnotice>
<title>FTP Client</title>
- <prepared>Ingela Anderton Andin</prepared>
+ <prepared>Péter Dimitrov</prepared>
<responsible></responsible>
<docno></docno>
<approved></approved>
@@ -53,9 +53,9 @@
the user <c>guest</c> with password <c>password</c> logs on to
the remote host <c>erlang.org</c>:</p>
<code type="erl"><![CDATA[
- 1> 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
]]></code>
<p> 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 @@
</legalnotice>
- <title>Inets User's Guide</title>
+ <title>FTP User's Guide</title>
<prepared>Péter Dimitrov</prepared>
<docno></docno>
<date>2018-02-26</date>
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 @@
</legalnotice>
- <title>Inets Reference Manual</title>
+ <title>FTP Reference Manual</title>
<prepared>Péter Dimitrov</prepared>
<docno></docno>
- <date>2018-02-26</date>
+ <date>2018-03-09</date>
<rev>1.0</rev>
<file>ref_man.xml</file>
</header>
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