aboutsummaryrefslogtreecommitdiffstats
path: root/lib/inets/src/tftp/tftp.erl
diff options
context:
space:
mode:
authorStavros Aronis <[email protected]>2010-06-08 23:53:43 +0300
committerHenrik Nord <[email protected]>2011-10-07 17:17:07 +0200
commit3ae841405f4005b52950a74727578deea2aee209 (patch)
tree27c5bf99f58c4f83b59c8e08bf71af0053928d6d /lib/inets/src/tftp/tftp.erl
parent1d3544d9b5c4bc2cad99b220f44aa370703dbc6b (diff)
downloadotp-3ae841405f4005b52950a74727578deea2aee209.tar.gz
otp-3ae841405f4005b52950a74727578deea2aee209.tar.bz2
otp-3ae841405f4005b52950a74727578deea2aee209.zip
Add callback specs to tftp module following internet documentation
Diffstat (limited to 'lib/inets/src/tftp/tftp.erl')
-rw-r--r--lib/inets/src/tftp/tftp.erl47
1 files changed, 41 insertions, 6 deletions
diff --git a/lib/inets/src/tftp/tftp.erl b/lib/inets/src/tftp/tftp.erl
index bfdb4c0030..b33c0a98f4 100644
--- a/lib/inets/src/tftp/tftp.erl
+++ b/lib/inets/src/tftp/tftp.erl
@@ -215,8 +215,6 @@
start/0
]).
--export([behaviour_info/1]).
-
%% Application local functions
-export([
start_standalone/1,
@@ -227,13 +225,50 @@
]).
-behaviour_info(callbacks) ->
- [{prepare, 6}, {open, 6}, {read, 1}, {write, 2}, {abort, 3}];
-behaviour_info(_) ->
- undefined.
+-type peer() :: {PeerType :: inet | inet6,
+ PeerHost :: inet:ip_address(),
+ PeerPort :: port()}.
+
+-type access() :: read | write.
+
+-type options() :: [{Key :: string(), Value :: string()}].
+
+-type error_code() :: undef | enoent | eacces | enospc |
+ badop | eexist | baduser | badopt |
+ integer().
+
+-callback prepare(Peer :: peer(),
+ Access :: access(),
+ Filename :: file:name(),
+ Mode :: string(),
+ SuggestedOptions :: options(),
+ InitialState :: [] | [{root_dir, string()}]) ->
+ {ok, AcceptedOptions :: options(), NewState :: term()} |
+ {error, {Code :: error_code(), string()}}.
+
+-callback open(Peer :: peer(),
+ Access :: access(),
+ Filename :: file:name(),
+ Mode :: string(),
+ SuggestedOptions :: options(),
+ State :: [] | [{root_dir, string()}] | term()) ->
+ {ok, AcceptedOptions :: options(), NewState :: term()} |
+ {error, {Code :: error_code(), string()}}.
+
+-callback read(State :: term()) -> {more, binary(), NewState :: term()} |
+ {last, binary(), integer()} |
+ {error, {Code :: error_code(), string()}}.
+
+-callback write(binary(), State :: term()) ->
+ {more, NewState :: term()} |
+ {last, FileSize :: integer()} |
+ {error, {Code :: error_code(), string()}}.
+
+-callback abort(Code :: error_code(), string(), State :: term()) -> 'ok'.
-include("tftp.hrl").
+
%%-------------------------------------------------------------------
%% read_file(RemoteFilename, LocalFilename, Options) ->
%% {ok, LastCallbackState} | {error, Reason}