From 52f849cb3deaa58c2dd3fccce6eed2febc6a520e Mon Sep 17 00:00:00 2001 From: Joseph Wayne Norton Date: Sat, 11 Apr 2009 23:50:30 +0900 Subject: [PATCH] import ubf-1.9.tgz --- #ball.erl# | 74 ------------ #irc_plugin.erl# | 188 ------------------------------ Makefile | 2 +- ball.erl | 68 ----------- client.beam | Bin 3580 -> 3580 bytes contract_lex.beam | Bin 11624 -> 11624 bytes contract_manager.beam | Bin 2612 -> 2612 bytes contract_parser.beam | Bin 6240 -> 6240 bytes contract_yecc.beam | Bin 10764 -> 10764 bytes contracts.beam | Bin 2780 -> 2780 bytes doc/site/downloads.html | 171 ++++++++++++++++++++++++++++ doc/site/eserve.html | 233 ++++++++++++++++++++++++++++++++++++++ doc/site/home.html | 21 +++- doc/site/javac.html | 171 ++++++++++++++++++++++++++++ doc/site/messagebox.html | 169 +++++++++++++++++++++++++++ doc/src/Makefile | 3 +- doc/src/Makefile~ | 2 +- doc/src/downloads.ehtml | 21 ++++ doc/src/downloads.ehtml~ | 35 ++++++ doc/src/eserve.ehtml | 24 ++++ doc/src/eserver.ehtml | 24 ++++ doc/src/eserver.ehtml~ | 75 ++++++++++++ doc/src/home.ehtml | 10 +- doc/src/home.ehtml~ | 83 +++++++------- doc/src/javac.ehtml | 22 ++++ doc/src/javac.ehtml~ | 24 ++++ doc/src/messagebox.ehtml | 20 ++++ doc/src/messagebox.ehtml~ | 35 ++++++ file_client.beam | Bin 1340 -> 1432 bytes file_plugin.beam | Bin 2432 -> 2432 bytes find.beam | Bin 1996 -> 1996 bytes irc_client | 3 +- irc_client.beam | Bin 3128 -> 3128 bytes irc_client.erl | 2 - irc_client_gs.beam | Bin 4200 -> 5408 bytes irc_client_gs.erl | 85 ++++++++++---- irc_client_gs.erl~ | 170 +++++++++++++++++++++++++++ irc_plugin.beam | Bin 5516 -> 5516 bytes leex.beam | Bin 14068 -> 14068 bytes plugin_handler.beam | Bin 2772 -> 2772 bytes proc_socket_server.beam | Bin 2288 -> 2288 bytes server.beam | Bin 2476 -> 2476 bytes server_plugin.beam | Bin 3048 -> 3048 bytes test.beam | Bin 2356 -> 2356 bytes test_plugin.beam | Bin 3184 -> 3184 bytes ubf.beam | Bin 6068 -> 6068 bytes ubf_driver.beam | Bin 1620 -> 1520 bytes ubf_driver.erl | 4 +- ubf_test.beam | Bin 1720 -> 1720 bytes ubf_utils.beam | Bin 1124 -> 1124 bytes 50 files changed, 1337 insertions(+), 402 deletions(-) delete mode 100644 #ball.erl# delete mode 100644 #irc_plugin.erl# delete mode 100644 ball.erl create mode 100644 doc/site/downloads.html create mode 100644 doc/site/eserve.html create mode 100644 doc/site/javac.html create mode 100644 doc/site/messagebox.html create mode 100644 doc/src/downloads.ehtml create mode 100644 doc/src/downloads.ehtml~ create mode 100644 doc/src/eserve.ehtml create mode 100644 doc/src/eserver.ehtml create mode 100644 doc/src/eserver.ehtml~ create mode 100644 doc/src/javac.ehtml create mode 100644 doc/src/javac.ehtml~ create mode 100644 doc/src/messagebox.ehtml create mode 100644 doc/src/messagebox.ehtml~ create mode 100644 irc_client_gs.erl~ diff --git a/#ball.erl# b/#ball.erl# deleted file mode 100644 index 3cdf56e..0000000 --- a/#ball.erl# +++ /dev/null @@ -1,74 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings -%% AB. All Rights Reserved.'' -%% -%% $Id$ -%% -%% ------------------------------------------------------------ -%% A simple demo showing a ball -%% bouncing in a window. -%% ------------------------------------------------------------ - --module(ball). - --export([start/0,init/0]). - -start() -> - spawn(ball,init,[]). - -init() -> - I= gs:start(), - W= gs:window(I,[{title,"Ball"},{width,300},{height,300},{map,true}]), - C= gs:canvas(W,[{width,300},{height,300},{bg,yellow}]), - B= gs:button(W,[{label, {text,"Quit Demo"}},{x,100}]), - Ball = gs:oval(C,[{coords,[{0,0},{50,50}]},{fill,red}]), - ball(Ball,0,0,5.5,4.1). - -ball(Ball,X,Y,DX,DY) -> - {NX,NDX} = cc(X,DX), - {NY,NDY} = cc(Y,DY), - gs:config(Ball,{move,{DX,DY}}), - receive - {gs,Id,click,_,_} -> exit(normal); - {gs,_,destroy,_,_} -> exit(normal) - after 20 -> - true - end, - ball(Ball,NX,NY,NDX,NDY). - -cc(X,DX) -> - if - DX>0 -> - if - X=<250 -> - {X+DX,DX}; - x>250 -> - {X-DX,-DX} - end; - DX<0 -> - if - X>=0 -> - {X+DX,DX}; - X<0 -> - {X-DX,-DX} - end - end. - -%% ------------------------------------------------------------ - - - - - - diff --git a/#irc_plugin.erl# b/#irc_plugin.erl# deleted file mode 100644 index 4ed5b19..0000000 --- a/#irc_plugin.erl# +++ /dev/null @@ -1,188 +0,0 @@ --module(irc_plugin). - --export([manager_start/2, client_stop/3, - managerStartState/0, handlerStartState/0, - manager_rpc/2, handle_rpc/4]). - --import(server, [sendEvent/2, ask_manager/2]). --import(lists, [delete/2, map/2, member/2, foreach/2]). - -%% NOTE the following two lines - --compile({parse_transform,contract_parser}). --add_contract("irc_plugin"). - --define(S(X), {'#S',X}). -s(X) -> {'#S', X}. - -managerStartState() -> new_seed(), ets:new(irc, []). - -handlerStartState() -> myHandlerState. - -%% manager_start(Args, State) is called every time a session is started -%% Args comes from client:start(Host,Port,Service,Args) -%% Service in the rcp:start must match name() -%% manager_start(Args, State) -> {accept, Reply, State} | {reject, Why, State} -%% State is the manager state. - -manager_start(_, ManagerState) -> - {accept, yes, start, [], ManagerState}. - -client_stop(Pid, Reason, Ets) -> - io:format("Client stopped:~p ~p~n",[Pid, Reason]), - {Nick, Groups} = facts(Ets, Pid), - io:format("Pid has nick~p is in groups~p~n",[Nick, Groups]), - ets:delete(Ets, {facts, Pid}), - ets:delete(Ets, {pid, Nick}), - foreach(fun(G) -> - Pids = pids(Ets, G), - Pids1 = delete(Pid, Pids), - ets:insert(Ets, {{group,G}, Pids1}), - broadcast_to_group(Pids1, {leaves, s(Nick), s(G)}) - end, Groups), - Ets. - -%% The manager state -%% Is what ?? -%% We know the Pid of the Client -%% The Nick of the client on the Pid -%% The set of groups that the client is joined to - -%% This is all in one ets table -%% {group, Name} => [Pids] (all the Pids in a group) -%% {group, "erlang"} => [Pid1, Pid2, ...] -%% {facts, Pid} => {Nick, [Group]} -%% The nick and the List of joined groups -%% for Pid -%% {pid, Nick} => Pid - -%% When somebody joins or leaves a group broadcast that -%% they have joined or leaved the group -%% When somebody dies remove their nick -%% and remove them from all groups - -pids(Ets, Name) -> - case ets:lookup(Ets, {group, Name}) of - [{_,L}] -> L; - [] -> [] - end. - -facts(Ets, Pid) -> - case ets:lookup(Ets, {facts, Pid}) of - [{_,L}] -> L; - [] -> [] - end. - -manager_rpc({join, Pid, Group}, Ets) -> - %% Nick (Pid) joins the group G - {Nick, Gs} = facts(Ets, Pid), - case member(Group, Gs) of - true -> {ok, Ets}; - false -> - ets:insert(Ets, {{facts, Pid}, {Nick,[Group|Gs]}}), - Pids = [Pid|pids(Ets, Group)], - ets:insert(Ets, {{group,Group}, Pids}), - broadcast_to_group(Pids, {joins, s(Nick), s(Group)}), - {ok, Ets} - end; -manager_rpc({leave, Pid, Group}, Ets) -> - {Nick, Gs} = facts(Ets, Pid), - case member(Group, Gs) of - false -> {ok, Ets}; - true -> - ets:insert(Ets, {{facts, Pid}, {Nick,delete(Group, Gs)}}), - Pids = delete(Pid, pids(Ets, Group)), - ets:insert(Ets, {{group,Group}, Pids}), - broadcast_to_group(Pids, {leaves, s(Nick), s(Group)}), - {ok, Ets} - end; -manager_rpc({msg, Pid, Group, Msg}, Ets) -> - {Nick, Gs} = facts(Ets, Pid), - case member(Group, Gs) of - false -> {notJoined, Ets}; - true -> - broadcast_to_group(pids(Ets, Group), - {msg, s(Nick), s(Group), s(Msg)}), - {ok, Ets} - end; -manager_rpc(groups, Ets) -> - M = ets:match(Ets, {{group,'$1'},'_'}), - io:format("Here Groups=~p~n",[M]), - Strs = map(fun([I]) -> s(I) end, M), - {Strs, Ets}; -manager_rpc(P={logon, Pid}, Ets) -> - Nick = random_nick(6), - case ets:lookup(Ets, {pid, Nick}) of - [] -> - ets:insert(Ets, {{pid, Nick}, Pid}), - ets:insert(Ets, {{facts,Pid}, {Nick, []}}), - {Nick, Ets}; - _ -> - manager_rpc(P, Ets) - end; -manager_rpc({change_nick,Old,New,Pid}, Ets) -> - case ets:lookup(Ets, {pid, New}) of - [] -> - ets:insert(Ets, {{pid, New}, Pid}), - ets:delete(Ets, {pid,Old}), - {_, Groups} = facts(Ets, Pid), - ets:insert(Ets, {{facts,Pid},{New, Groups}}), - %% Now tell all groups about the name change - foreach(fun(G) -> - Pids = pids(Ets, G), - broadcast_to_group(Pids, {changesName, - s(Old), s(New), - s(G)}) - end, Groups), - {ok, Ets}; - _ -> - {error, Ets} - end. - -broadcast_to_group(L, Msg) -> - foreach(fun(Pid) -> sendEvent(Pid, Msg) end, L). - -handle_rpc(start, logon, State, Manager) -> - R = ask_manager(Manager, {logon, self()}), - {{ok, s(R)}, active, R}; -handle_rpc(active, {join, ?S(Group)}, Nick, Manager) -> - ask_manager(Manager, {join, self(), Group}), - {ok, active, Nick}; -handle_rpc(active, {leave, ?S(Group)}, Nick, Manager) -> - ask_manager(Manager, {leave, self(), Group}), - {ok, active, Nick}; -handle_rpc(active, {msg, ?S(Group), ?S(Msg)}, Nick, Manager) -> - ask_manager(Manager, {msg, self(), Group, Msg}), - {ok, active, Nick}; -handle_rpc(active, {nick, ?S(New)}, Nick, Manager) -> - case ask_manager(Manager, {change_nick,Nick,New,self()}) of - ok -> - {nickChanged, active, New}; - error -> - {nickInUse, active, Nick} - end; -handle_rpc(active, groups, Nick, Manager) -> - Groups = ask_manager(Manager, groups), - {Groups, active, Nick}. - -random_nick(0) -> - []; -random_nick(N) -> - [$a + random:uniform(26) - 1|random_nick(N-1)]. - -new_seed() -> - {_,_,X} = erlang:now(), - {H,M,S} = time(), - H1 = H * X rem 32767, - M1 = M * X rem 32767, - S1 = S * X rem 32767, - put(random_seed, {H1,M1,S1}). - - - - - - - - - diff --git a/Makefile b/Makefile index 3bf5603..3a815ea 100644 --- a/Makefile +++ b/Makefile @@ -12,7 +12,7 @@ ERL = ubf proc_socket_server find server\ test ubf_driver ubf_test file_client\ contracts contract_manager client plugin_handler\ - leex contract_lex contract_yecc irc_client ubf_utils + leex contract_lex contract_yecc irc_client irc_client_gs ubf_utils PLUGINS = test_plugin file_plugin irc_plugin server_plugin diff --git a/ball.erl b/ball.erl deleted file mode 100644 index 1aa0df5..0000000 --- a/ball.erl +++ /dev/null @@ -1,68 +0,0 @@ -%% ``The contents of this file are subject to the Erlang Public License, -%% Version 1.1, (the "License"); you may not use this file except in -%% compliance with the License. You should have received a copy of the -%% Erlang Public License along with this software. If not, it can be -%% retrieved via the world wide web at http://www.erlang.org/. -%% -%% Software distributed under the License is distributed on an "AS IS" -%% basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See -%% the License for the specific language governing rights and limitations -%% under the License. -%% -%% The Initial Developer of the Original Code is Ericsson Utvecklings AB. -%% Portions created by Ericsson are Copyright 1999, Ericsson Utvecklings -%% AB. All Rights Reserved.'' -%% -%% $Id$ -%% -%% ------------------------------------------------------------ -%% A simple demo showing a ball -%% bouncing in a window. -%% ------------------------------------------------------------ - --module(ball). - --export([start/0,init/0]). - -start() -> - spawn(ball,init,[]). - -init() -> - I= gs:start(), - W= gs:window(I,[{title,"Ball"},{width,300},{height,300},{map,true}]), - C= gs:canvas(W,[{width,300},{height,300},{bg,yellow}]), - B= gs:button(W,[{label, {text,"Quit Demo"}},{x,100}]), - Ball = gs:oval(C,[{coords,[{0,0},{50,50}]},{fill,red}]), - ball(Ball,0,0,5.5,4.1). - -ball(Ball,X,Y,DX,DY) -> - {NX,NDX} = cc(X,DX), - {NY,NDY} = cc(Y,DY), - gs:config(Ball,{move,{DX,DY}}), - receive - {gs,Id,click,_,_} -> exit(normal); - {gs,_,destroy,_,_} -> exit(normal) - after 20 -> - true - end, - ball(Ball,NX,NY,NDX,NDY). - -cc(X,DX) -> - if - DX>0 -> - if - X=<250 -> - {X+DX,DX}; - x>250 -> - {X-DX,-DX} - end; - DX<0 -> - if - X>=0 -> - {X+DX,DX}; - X<0 -> - {X-DX,-DX} - end - end. - -%% ------------------------------------------------------------ diff --git a/client.beam b/client.beam index 928897a03ab2236583e85ac08491aa6f7ddb8683..b092761eade58e175dad356dbf1f36d34846311b 100644 GIT binary patch delta 37 qcmew({YQGkbY4cw$uoF$faFnLH9@vS;Y7Jar7Q-=q~a0=AOHaG8VY9s delta 37 qcmew({YQGkbY4dD$uoF$faFnLH9^)yzC@lx#w-TMq~a0=AOHaD0SYPr diff --git a/contract_lex.beam b/contract_lex.beam index 4f3cd6e490558e6b33962f8c992d8a38f27391a2..855d048d778e468d944cf8fa74627b7babe2195b 100644 GIT binary patch delta 46 zcmaD6^&)Bmvo4oq22%k~%H#(+%8Zti4RzH7*%E~lk~%H#(+%8cfd4RzH7SrhpZc@kN(7#x#|OBjFv09uC( Ab^rhX diff --git a/contract_manager.beam b/contract_manager.beam index 7ecc5ce8ebb23ac0eb94758c31054be63f20dfc1..28b1c773e1c63c173aa6acc600acf7ca2cbda20a 100644 GIT binary patch delta 37 qcmdlYvPERWc}_;l$rm_vfaG6JH9@vS;Y7Ja#ViKLq~a0=AOHaAF$!b= delta 37 qcmdlYvPERWc}_<2$rm_vfaG6JH9^)yzC@lxhAalhq~a0=AOHa77z!r< diff --git a/contract_parser.beam b/contract_parser.beam index 29ecd4e043d81ca7e9ee3ac9b80a33b35330e668..c6cc192de511d4ae21212f3618ec60916d084af3 100644 GIT binary patch delta 37 qcmaE0@W5chZ*fM;$$!LkfTX5`njl-EaH3qIau$PQQgI0b5C8!BSqh~9 delta 37 qcmaE0@W5chZ*fNR$$!LkfTX5`njmW;Um{N;a~6YRQgI0b5C8!8OA2WK diff --git a/contract_yecc.beam b/contract_yecc.beam index 67da64eefb2ef82b5e65e478ed854dfa335fd4bb..5d69b305a1958adafffb3a3353a2e61aaccb4690 100644 GIT binary patch delta 37 pcmeAP=?U4eT$9mq@(N8IAbC|&O^_{7I8iQ9J&VCHsknpz2mtKU3W5Lt delta 37 pcmeAP=?U4eT$9m!@(N8IAbC|&O^`K_FOesaEsMc1sknpz2mtB23Pk__ diff --git a/contracts.beam b/contracts.beam index e27890e7a88af5478c9e91058980c23e19036b85..b8ccfd4701ae98030005581c5f156db5907ca6d6 100644 GIT binary patch delta 36 ocmca3dPj6aHW#Di + + + +Site + +

  + + + + + +
+ + + + + + + + +
Documents
+ + + + + + + + + + + + +
+ + +
+Home +
White paper +
UBF(A) spec +
UBF(B) spec +
+
+

+ + + + + + + + +
Tutorials
+ + + + + + + + + + + + +
+ + +
+Quick start +
Erlang servers +
Java clients +
+
+

+ + + + + + + + +
Services
+ + + + + + + + + + + + +
+ + +
+IRC +
Message Box +
File server +
+
+

+ + + + + + + + +
Downloads
+ + + + + + + + + + + + +
+ + +
+Downloads +
+
+

+

+

+ + +
UBF(B)
+ + + + +
2002-03-05
+
+

Downloads

+ +
+ +
+
(  + +)
+
+ + diff --git a/doc/site/eserve.html b/doc/site/eserve.html new file mode 100644 index 0000000..e733892 --- /dev/null +++ b/doc/site/eserve.html @@ -0,0 +1,233 @@ + + + + +Site + +

  + + + + + +
+ + + + + + + + +
Documents
+ + + + + + + + + + + + +
+ + +
+Home +
White paper +
UBF(A) spec +
UBF(B) spec +
+
+

+ + + + + + + + +
Tutorials
+ + + + + + + + + + + + +
+ + +
+Quick start +
Erlang servers +
Java clients +
+
+

+ + + + + + + + +
Services
+ + + + + + + + + + + + +
+ + +
+IRC +
Message Box +
File server +
+
+

+ + + + + + + + +
Downloads
+ + + + + + + + + + + + +
+ + +
+Downloads +
+
+

+

+

+ + +
Quick start
+ + + + +
2002-03-05
+
+ + +
Erlang servers
+

an example of a server plugin +

-module(file_plugin).
+
+-export([manager_start/2, client_stop/3,
+	 managerStartState/0, handlerStartState/0, 
+	 manager_rpc/2, handle_rpc/4]).
+
+-import(lists, [map/2, member/2]).
+
+%% NOTE the following two lines
+
+-compile({parse_transform,contract_parser}).
+-add_contract("file_plugin").
+
+-define(S(X), {'#S',X}).
+s(X) -> {'#S', X}.
+
+%% The initial state of the manager
+
+managerStartState() -> myManagerState.
+
+handlerStartState() -> myHandlerState.
+    
+%% manager_start(Args, State) is called every time a session is started
+%% Args comes from client:start(Host,Port,Service,Args)
+%% Service in the rcp:start must match name()
+%% manager_start(Args, State) -> {accept, Reply, State} | {reject, Why, State}
+%% State is the manager state.
+
+manager_start(_, ManagerState) ->
+    Reply = yesOffWeGo,
+    HandlerState = start,
+    HandlerData = myInitailData0,
+    {accept, Reply, HandlerState, HandlerData, ManagerState}.
+
+client_stop(Pid, Reason, State) ->
+    io:format("Client stopped:~p ~p~n",[Pid, Reason]),
+    State.
+
+manager_rpc(secret, State) ->
+    {accept, welcomeToFTP, State};
+manager_rpc(_, State) ->
+    {reject, badPassword, State}.
+
+handle_rpc(start, {logon, ?S("jimmy")}, State, Env) ->
+    {ok, active, State};
+handle_rpc(active, ls, State, Env) ->
+    {ok, Files} = file:list_dir("."),
+    Ret = map(fun(I) -> s(I) end, Files),
+    {{files, Ret}, active, State};
+handle_rpc(active, {get, ?S(File)}, State, Env) ->
+    {ok, Files} = file:list_dir("."),
+    case member(File, Files) of
+	true ->
+	    {ok, Bin} = file:read_file(File),
+	    {Bin, active, State};
+	false ->
+	    {noSuchFile, stop, State}
+    end.
+
+
+
+
+

+ +
+
(  + +)
+
+ + diff --git a/doc/site/home.html b/doc/site/home.html index 1c1265d..9f9f4ba 100644 --- a/doc/site/home.html +++ b/doc/site/home.html @@ -145,7 +145,26 @@ SIZE=-1>Downloads - + +
White paper
Warning
+ + + + +
2002-03-05
+
+

+Pre-release. Be warned. Things change frequently +

+ +
+
(  + +)
+

+ +
UBF Home
diff --git a/doc/site/javac.html b/doc/site/javac.html new file mode 100644 index 0000000..df2a856 --- /dev/null +++ b/doc/site/javac.html @@ -0,0 +1,171 @@ + + + + +Site + +

  +

2002-03-05
+ + + + +
+ + + + + + + + +
Documents
+ + + + + + + + + + + + +
+ + +
+Home +
White paper +
UBF(A) spec +
UBF(B) spec +
+
+

+ + + + + + + + +
Tutorials
+ + + + + + + + + + + + +
+ + +
+Quick start +
Erlang servers +
Java clients +
+
+

+ + + + + + + + +
Services
+ + + + + + + + + + + + +
+ + +
+IRC +
Message Box +
File server +
+
+

+ + + + + + + + +
Downloads
+ + + + + + + + + + + + +
+ + +
+Downloads +
+
+

+

+

+ + +
Quick start
+ + + + +
2002-03-05
+
+ + +
Java clients
+

Not yet written. +

+ +
+
(  + +)
+
+ + diff --git a/doc/site/messagebox.html b/doc/site/messagebox.html new file mode 100644 index 0000000..06d83f3 --- /dev/null +++ b/doc/site/messagebox.html @@ -0,0 +1,169 @@ + + + + +Site + +

  + + + + + +
+ + + + + + + + +
Documents
+ + + + + + + + + + + + +
+ + +
+Home +
White paper +
UBF(A) spec +
UBF(B) spec +
+
+

+ + + + + + + + +
Tutorials
+ + + + + + + + + + + + +
+ + +
+Quick start +
Erlang servers +
Java clients +
+
+

+ + + + + + + + +
Services
+ + + + + + + + + + + + +
+ + +
+IRC +
Message Box +
File server +
+
+

+ + + + + + + + +
Downloads
+ + + + + + + + + + + + +
+ + +
+Downloads +
+
+

+

+

+ + +
UBF(B)
+ + + + +
2002-03-05
+
+

Message box

+

Not yet wrtten - will be something like nntp. +

+ +
+
(  + +)
+
+ + diff --git a/doc/src/Makefile b/doc/src/Makefile index 0f21ed1..fd60ca8 100644 --- a/doc/src/Makefile +++ b/doc/src/Makefile @@ -1,7 +1,8 @@ ## Add your modules here -EHTML = home white irc file ubfb ubfb_quick ubfa ubfa_quick quick +EHTML = downloads eserve messagebox \ + javac home white irc file ubfb ubfb_quick ubfa ubfa_quick quick ## Do not change below this line diff --git a/doc/src/Makefile~ b/doc/src/Makefile~ index ddc92a5..0f21ed1 100644 --- a/doc/src/Makefile~ +++ b/doc/src/Makefile~ @@ -1,7 +1,7 @@ ## Add your modules here -EHTML = home white irc ftp ubfb ubfb_quick ubfa ubfa_quick quick +EHTML = home white irc file ubfb ubfb_quick ubfa ubfa_quick quick ## Do not change below this line diff --git a/doc/src/downloads.ehtml b/doc/src/downloads.ehtml new file mode 100644 index 0000000..0339f34 --- /dev/null +++ b/doc/src/downloads.ehtml @@ -0,0 +1,21 @@ +layout.mac + + +

+ + + + + + + diff --git a/doc/src/downloads.ehtml~ b/doc/src/downloads.ehtml~ new file mode 100644 index 0000000..34155e5 --- /dev/null +++ b/doc/src/downloads.ehtml~ @@ -0,0 +1,35 @@ +layout.mac + + + + + + + + + + diff --git a/doc/src/eserve.ehtml b/doc/src/eserve.ehtml new file mode 100644 index 0000000..e7a1b08 --- /dev/null +++ b/doc/src/eserve.ehtml @@ -0,0 +1,24 @@ +layout.mac + + +
+ +Erlang servers + + + +

an example of a server plugin + +../../file_plugin.erl + +

+ + + + + + + diff --git a/doc/src/eserver.ehtml b/doc/src/eserver.ehtml new file mode 100644 index 0000000..e7a1b08 --- /dev/null +++ b/doc/src/eserver.ehtml @@ -0,0 +1,24 @@ +layout.mac + + +
+ +Erlang servers + + + +

an example of a server plugin + +../../file_plugin.erl + +

+ + + + + + + diff --git a/doc/src/eserver.ehtml~ b/doc/src/eserver.ehtml~ new file mode 100644 index 0000000..c2145fb --- /dev/null +++ b/doc/src/eserver.ehtml~ @@ -0,0 +1,75 @@ +layout.mac + + +
+ +Quick start with UBF + +

This will jump start you with UBF. + +

All you need is an internet connection and Telnet to get started. +

First read the contract - in the next section. Then +fire up Telnet and investigate the server (by hand) - then you can see +what's really going on +The Contract +

+../../file_plugin.con +

+A telnet session + +

+The following is a telnet session. + +

User input is in red. Server output is in black, some lines have +been omitted: + +

+ +telnet enfield.sics.se 2000 +Trying 127.0.0.1... +Connected to localhost.localdomain. +Escape character is '^]'. +{'ubf1.0',"meta_server","I am a meta server +See http://www.sics.se/~joe/ubf.html +This server speaks Universal Binary Format 1.0 +For more information type 'description'$ at the dollar prompt +Remember the $ and quote marks :-) +"}$ +{'rpc',{'startService',"file_server",#}}$ + +{'rpcReply',{'ok','yesOffWeGo'},'start'}$ + +{'rpc',{'logon',"jimmy"}}$ + +{'rpcReply','ok','active'}$ + +{'rpc','ls'}$ + +{'rpcReply',{'files',#"ubf.erl"&"client.erl"& + ... + +{'rpc',{'get',"ubf.erl"}}$ + +{'rpcReply',7852~-module(ubf). + +-compile(export_all). + +-export([decode_init/0, decode/1, decode/2, encode/1, encode/2]). +-export([encode_print/1, ubf2term/1, deabstract/1]). + +... + +Connection closed by foreign host. +[joe@enfield joe]$ exit + +

+ + + + + + + diff --git a/doc/src/home.ehtml b/doc/src/home.ehtml index 9606600..515e9fc 100644 --- a/doc/src/home.ehtml +++ b/doc/src/home.ehtml @@ -1,7 +1,15 @@ layout.mac -
+

+Pre-release. Be warned. Things change frequently +

+

+

diff --git a/doc/src/home.ehtml~ b/doc/src/home.ehtml~ index d1d4a1b..9606600 100644 --- a/doc/src/home.ehtml~ +++ b/doc/src/home.ehtml~ @@ -1,53 +1,54 @@ layout.mac -
-

Magna virtus tua et vivebam etiam Et quoniam cum me, formasti mihi quasi -necesse esset nisi vero; illa prior. Item si cum in quam me urgeret -quod non est, innocentia est, fit, ut eam ut vides, haec ipsa tamen -loqui quoniam itaque. -

Iactabam domine, et confiteri me delicta mea, -deus, es domine, non servientibus (et magistris a paedagogis et mineris -ingentes miserias)? Salus tua, relicto te vult homo circumferens -mortalitem suam, circumferens mortalitem inrisormeus, cui loquor.

- -

Hocadum i et confiteri me delicta mea, -deus, es domine, non servientibus (et magistris a paedagogis et mineris -ingentes miserias)? Salus tua, relicto te vult homo circumferens -www.dedicated-servers.co.uk -ingentes miserias)? Salus tua, relicto te vult homo circumferens. - -

- -

- -

-

- -

+

UBF is a language for transporting and describing complex data structures across a network. It has two components:

    -
  • Recode this using a nice red color - done -
  • Make sure it passes html_check -
  • Change ehtml to write the output files in a different -directory -
  • Write a makefile for this. -
+
  • +UBF(A) is a data transport format, roughly +equivalent to well-formed XML. + +
  • UBF(B) is a programming langauge +for describing types in UBF(A) and protocols between clients +and servers. +UBF(B) is roughly equivalent to to Verified XML, +XML-schemas, SOAP and WDSL. + + + +

    While the XML series of languages had the goal of having a human +readable format the UBF languages take the opposite view and provide a +"machine friendly" format. + +

    UBF is designed to be easy to implement. As a proof of concept - UBF drivers +For Erlang, Oz, Java and TCL can be found in the download area. +Implementors are welcome to add new languages. + +

    UBF is designed to be "language neutral" - UBF(A) defines a +language neutral binary format for transporting data across a +network. UBF(B) is a type system for describing client/server +interactions which use UBF(A). + +

    Programming by Contract

    +
    + +
    + +

    Central to UBF is the idea of a "contract" which regulates the +set of legal conversations that can take place between a client and a server. + +

    A software component (the contract checker) is place between a client and server which checks that all interactions between thew client and server are legal. + +

    The digram shows a Java client talking to a C++ server. + + +

  • diff --git a/doc/src/javac.ehtml b/doc/src/javac.ehtml new file mode 100644 index 0000000..b6f3516 --- /dev/null +++ b/doc/src/javac.ehtml @@ -0,0 +1,22 @@ +layout.mac + + +
    + +Java clients + + + +

    Not yet written. + +

    + + + + + + + diff --git a/doc/src/javac.ehtml~ b/doc/src/javac.ehtml~ new file mode 100644 index 0000000..e7a1b08 --- /dev/null +++ b/doc/src/javac.ehtml~ @@ -0,0 +1,24 @@ +layout.mac + + +
    + +Erlang servers + + + +

    an example of a server plugin + +../../file_plugin.erl + +

    + + + + + + + diff --git a/doc/src/messagebox.ehtml b/doc/src/messagebox.ehtml new file mode 100644 index 0000000..aaa4ce5 --- /dev/null +++ b/doc/src/messagebox.ehtml @@ -0,0 +1,20 @@ +layout.mac + + +
    + +

    Message box

    + +

    Not yet wrtten - will be something like nntp. + +

    + + + + + + + diff --git a/doc/src/messagebox.ehtml~ b/doc/src/messagebox.ehtml~ new file mode 100644 index 0000000..34155e5 --- /dev/null +++ b/doc/src/messagebox.ehtml~ @@ -0,0 +1,35 @@ +layout.mac + + +
    + +

    File server

    + +

    Description

    +

    The contract

    + +../../file_plugin.con + +

    A telnet session

    + +

    A full telnet session using the server can be found in the +quick start tutorial + +

    An Erlang client

    +../../file_client.erl + +

    The Erlang file server plugin

    + +../../file_plugin.erl + +
    + + + + + + + diff --git a/file_client.beam b/file_client.beam index 4c274e23d3c8a190a0b2659430c16e13639257de..b59ebeb97451b56607f5248be96ac777bb64bb3c 100644 GIT binary patch delta 164 zcmdnPHG`YO%|FPHfq`|xMvluY^;?>A7#J9sGni5s*z*fYGV}9_K>{o(3`}LlAW^pb z(vp2A!kN}X&RAxLml+~1< SFOervJBz_Fskj6v!2kdw>JLKz diff --git a/file_plugin.beam b/file_plugin.beam index 447cea3950cba491d44d3cb0d6c45f72637a413a..a38bce6123273beb72b60c3d19b75d4e384c51d1 100644 GIT binary patch delta 46 zcmZn=ZV=w^nS;wRgDHi9Ik`L~W%30MWk$=%ikyCe!ijQ;T3HMX430^~B|wS+05_%! AeEF*8XMl7ECVU4rMf-e1cmCNPguu U7GO=}OXNvp&vHyEE@1!y0Q;a78vp end, io:format("client stops~n"). - - loop(Pid, Group, Gs, Nick) -> io:format("Status: Nick=~s Group=~s Joined groups=~p~n",[Nick, Group, Gs]), case io:get_line('> ') of diff --git a/irc_client_gs.beam b/irc_client_gs.beam index d2e1e64e6044100cd1a84de2b2fe57314a38289e..58490c5ae70c54c2ce265252b65824a72fd3f4e9 100644 GIT binary patch literal 5408 zcmb7IO>ErO5hj=1)e|GuTyf=}_>VSaThdw*t(AWySq`;7qV3p@omJ7CD$%>tYONKy zAt}j514C$#bJL(jZ-s-REl?nZ5wtxQDSGJ5D3H66Kml6hU=+}$$f4hmyQ{Sv8#RF; z=e;*?-pst2dGk2`&b#M0Zs1_PG}_UpAF*0&|7TOgD@F{wv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#hP&g?9| zV>Ngny5!yA047y83H_?z7= zpF8e02OryZ11$x=4(EY4eBE<5`!4XMt0CYLemgskB;DBTV4U!-Jq#2FN&sO81yX=w zJ^o0KN107`7t1rL4IO@=L5XavTp zVSg6rV<5zs0xI@+4&P~@1kh2S3=qm7W)cV=96N~3L3|N2w%m2lhDLAvCVcU^9DP7> z^XLBr{ss_YqMtZVPW<`b8hoz^gqjDGDiRa diff --git a/irc_client_gs.erl b/irc_client_gs.erl index cf1e8b0..be97562 100644 --- a/irc_client_gs.erl +++ b/irc_client_gs.erl @@ -7,21 +7,34 @@ -define(S(X), {'#S',X}). s(X) -> {'#S', X}. -start() -> - spawn(fun() -> init1() end). +batch([Nick]) -> + start(atom_to_list(Nick)). + +start(Nick) -> + spawn(fun() -> init1(Nick) end). -init1() -> - {ok, Pid, Name} = client:start("localhost", 2000), - {reply, {ok,yes}, start} = rpc(Pid, {startService, s("irc"), []}), - Self = self(), - client:install_handler(Pid, fun(M) -> - send_self(M, Self) - end), - case rpc(Pid, logon) of - {reply, {ok,?S(Nick)}, active} -> - init(Pid, Nick); - _ -> - exit(connect) +init1(Nick) -> + case client:start("enfield.sics.se", 2000) of + {ok, Pid, Name} -> + {reply, {ok,yes}, start} = rpc(Pid, {startService, s("irc"), []}), + client:install_handler(Pid, fun print_msg/1), + {reply, _, _} = rpc(Pid, logon), + Self = self(), + client:install_handler(Pid, fun(M) -> + send_self(M, Self) + end), + case rpc(Pid, {nick, s(Nick)}) of + {reply, nickInUse, _} -> + client:stop(Pid), + io:format("Nick was in use try again~n"), + erlang:halt(); + {reply, nickChanged, active} -> + init(Pid, Nick) + end, + io:format("client stops~n"); + {error, socket} -> + io:format("Cannot make TCP connection~n"), + erlang:halt() end. init(Pid, Nick) -> @@ -32,6 +45,7 @@ init(Pid, Nick) -> L1 = gs:label(W, [{x,10},{y,10},{label,{text,"Nick:" ++ Nick}}]), E1=gs:entry(W, [{x,10},{y,40},{width, 120}]), gs:button(W,[{x,130},{y,40},{data, join},{label,{text,"Join Group"}}]), + gs:config(E1, {text, "erlang"}), E2=gs:entry(W, [{x,10},{y,70},{width, 120}]), gs:button(W,[{x,130},{y,70}, {data,nick},{label,{text,"Change Nick"}}]), gs:button(W,[{x,10},{y,110}, {data,quit}, {label,{text,"Quit"}}]), @@ -52,6 +66,17 @@ loop(S, Dict, Pid, L1, E1, E2) -> loop(S, Dict, Pid, L1, E1, E2) end, loop(S, Dict, Pid, L1, E1, E2); + {gs,_,click,{leave,Group},_} -> + io:format("I leave: ~s~n",[Group]), + case dict:find(Group, Dict) of + {ok, {W,_}} -> + gs:destroy(W), + Dict1 = dict:erase(Group, Dict), + rpc(Pid, {leave, s(Group)}), + loop(S, Dict1, Pid, L1, E1, E2); + error -> + loop(S, Dict, Pid, L1, E1, E2) + end; {gs,_,click,join,_} -> Group = gs:read(E1, text), io:format("Join:~s~n",[Group]), @@ -70,25 +95,40 @@ loop(S, Dict, Pid, L1, E1, E2) -> end end; {gs,_,click,quit,_} -> - exit(1); + erlang:halt(); {gs,Obj,keypress,G,['Return'|_]} -> Str = gs:read(Obj, text), + gs:config(Obj, {text, ""}), io:format("Send: ~s to ~s~n",[Str, G]), rpc(Pid, {msg, s(G), s(Str ++ "\n")}), loop(S, Dict, Pid, L1, E1, E2); + {gs,Obj,keypress,G,_} -> + loop(S, Dict, Pid, L1, E1, E2); + {event, {leaves, Who, Group}} -> + display(Group, Dict, Who ++ " leaves the group\n"), + loop(S, Dict, Pid, L1, E1, E2); + {event, {joins, Who, Group}} -> + display(Group, Dict, Who ++ " joins the group\n"), + loop(S, Dict, Pid, L1, E1, E2); + {event, {changesName, Old, New, Group}} -> + display(Group, Dict, Old ++ " changes name to " ++ New ++ "\n"), + loop(S, Dict, Pid, L1, E1, E2); {event, {msg, From, Group, Msg}} -> - case dict:find(Group, Dict) of - {ok, {W, Txt}} -> - gs:config(Txt, {insert, {'end', From ++ " > " ++ Msg}}); - error -> - io:format("Msg:~s ~s ~s~n",[From, Group, Msg]) - end, + display(Group, Dict, From ++ " > " ++ Msg), loop(S, Dict, Pid, L1, E1, E2); X -> io:format("man: got other: ~w~n",[X]), loop(S, Dict, Pid, L1, E1, E2) end. +display(Group, Dict, Str) -> + case dict:find(Group, Dict) of + {ok, {W, Txt}} -> + gs:config(Txt, {insert, {'end', Str}}); + error -> + io:format("Cannot display:~s ~s~n",[Group, Str]) + end. + new_group(S, Name) -> Width=450,Height=350, W = gs:window(S,[{title,"Name"}, @@ -125,3 +165,6 @@ print_msg(X) -> io:format("==> ~p~n",[Other]) end, fun print_msg/1. + + + diff --git a/irc_client_gs.erl~ b/irc_client_gs.erl~ new file mode 100644 index 0000000..5e3fad5 --- /dev/null +++ b/irc_client_gs.erl~ @@ -0,0 +1,170 @@ +-module(irc_client_gs). + +-compile(export_all). + +-import(client, [rpc/2]). + +-define(S(X), {'#S',X}). +s(X) -> {'#S', X}. + +batch([Nick]) -> + start(atom_to_list(Nick)). + +start(Nick) -> + spawn(fun() -> init1(Nick) end). + +init1(Nick) -> + case client:start("localhost", 2000) of + {ok, Pid, Name} -> + {reply, {ok,yes}, start} = rpc(Pid, {startService, s("irc"), []}), + client:install_handler(Pid, fun print_msg/1), + {reply, _, _} = rpc(Pid, logon), + Self = self(), + client:install_handler(Pid, fun(M) -> + send_self(M, Self) + end), + case rpc(Pid, {nick, s(Nick)}) of + {reply, nickInUse, _} -> + client:stop(Pid), + io:format("Nick was in use try again~n"), + erlang:halt(); + {reply, nickChanged, active} -> + init(Pid, Nick) + end, + io:format("client stops~n"); + {error, socket} -> + io:format("Cannot make TCP connection~n"), + erlang:halt() + end. + +init(Pid, Nick) -> + S=gs:start(), + Width=250,Height=170, + W= gs:window(S,[{title,"IRC client"}, + {width,Width},{height,Height},{map,true}]), + L1 = gs:label(W, [{x,10},{y,10},{label,{text,"Nick:" ++ Nick}}]), + E1=gs:entry(W, [{x,10},{y,40},{width, 120}]), + gs:button(W,[{x,130},{y,40},{data, join},{label,{text,"Join Group"}}]), + gs:config(E1, {text, "erlang"}), + E2=gs:entry(W, [{x,10},{y,70},{width, 120}]), + gs:button(W,[{x,130},{y,70}, {data,nick},{label,{text,"Change Nick"}}]), + gs:button(W,[{x,10},{y,110}, {data,quit}, {label,{text,"Quit"}}]), + loop(S, dict:new(), Pid, L1, E1,E2). + +loop(S, Dict, Pid, L1, E1, E2) -> + receive + {gs,_,click,nick,_} -> + Nick = gs:read(E2, text), + io:format("Change nick to:~s~n",[Nick]), + case rpc(Pid, {nick, s(Nick)}) of + {reply, nickInUse, _} -> + gs:config(E2, {text, "** bad nick **"}), + loop(S, Dict, Pid, L1, E1, E2); + {reply, nickChanged, active} -> + io:format("nick was changed~n"), + gs:config(L1, {label, {text, "Nick: " ++ Nick}}), + loop(S, Dict, Pid, L1, E1, E2) + end, + loop(S, Dict, Pid, L1, E1, E2); + {gs,_,click,{leave,Group},_} -> + io:format("I leave: ~s~n",[Group]), + case dict:find(Group, Dict) of + {ok, {W,_}} -> + gs:destroy(W), + Dict1 = dict:erase(Group, Dict), + rpc(Pid, {leave, s(Group)}), + loop(S, Dict1, Pid, L1, E1, E2); + error -> + loop(S, Dict, Pid, L1, E1, E2) + end; + {gs,_,click,join,_} -> + Group = gs:read(E1, text), + io:format("Join:~s~n",[Group]), + case Group of + "" -> + loop(S, Dict, Pid, L1, E1, E2); + _ -> + case dict:find(Group, Dict) of + {ok, W} -> + loop(S, Dict, Pid, L1, E1, E2); + error -> + W = new_group(S, Group), + rpc(Pid, {join, s(Group)}), + loop(S, dict:store(Group, W, Dict), Pid, + L1, E1, E2) + end + end; + {gs,_,click,quit,_} -> + erlang:halt(); + {gs,Obj,keypress,G,['Return'|_]} -> + Str = gs:read(Obj, text), + gs:config(Obj, {text, ""}), + io:format("Send: ~s to ~s~n",[Str, G]), + rpc(Pid, {msg, s(G), s(Str ++ "\n")}), + loop(S, Dict, Pid, L1, E1, E2); + {gs,Obj,keypress,G,_} -> + loop(S, Dict, Pid, L1, E1, E2); + {event, {leaves, Who, Group}} -> + display(Group, Dict, Who ++ " leaves the group\n"), + loop(S, Dict, Pid, L1, E1, E2); + {event, {joins, Who, Group}} -> + display(Group, Dict, Who ++ " joins the group\n"), + loop(S, Dict, Pid, L1, E1, E2); + {event, {changesName, Old, New, Group}} -> + display(Group, Dict, Old ++ " changes name to " ++ New ++ "\n"), + loop(S, Dict, Pid, L1, E1, E2); + {event, {msg, From, Group, Msg}} -> + display(Group, Dict, From ++ " > " ++ Msg), + loop(S, Dict, Pid, L1, E1, E2); + X -> + io:format("man: got other: ~w~n",[X]), + loop(S, Dict, Pid, L1, E1, E2) + end. + +display(Group, Dict, Str) -> + case dict:find(Group, Dict) of + {ok, {W, Txt}} -> + gs:config(Txt, {insert, {'end', Str}}); + error -> + io:format("Cannot display:~s ~s~n",[Group, Str]) + end. + +new_group(S, Name) -> + Width=450,Height=350, + W = gs:window(S,[{title,"Name"}, + {width,Width},{height,Height},{map,true}]), + L1 = gs:label(W, [{x,10},{y,10},{label,{text,"Group:" ++ Name}}]), + T1 = gs:editor(W, [{x,10},{y,40}, + {width,Width-20}, + {height,Height-120}, + {vscroll, right}]), + E1 = gs:entry(W, [{x,10},{y,Height-70},{width, Width-20}, + {data, Name}, + {keypress,true}]), + gs:button(W,[{x,10},{y,Height-35}, + {data, {leave, Name}},{label,{text,"Leave Group"}}]), + {W, T1}. + +send_self(Msg, Pid) -> + Pid ! {event, ubf:deabstract(Msg)}, + fun(I) -> send_self(I, Pid) end. + + +print_msg(X) -> + case ubf:deabstract(X) of + {joins, Who, Group} -> + io:format("~s joins the group ~s~n",[Who, Group]); + {leaves, Who, Group} -> + io:format("~s leaves the group ~s~n",[Who, Group]); + {msg, Who, Group, Msg} -> + io:format("Msg from ~s to ~s => ~s~n",[Who, Group,Msg]); + {changesName, Old, New, Group} -> + io:format("~s is now called ~s in group ~s~n", + [Old, New, Group]); + Other -> + io:format("==> ~p~n",[Other]) + end, + fun print_msg/1. + + + diff --git a/irc_plugin.beam b/irc_plugin.beam index 67f692e8872a2f27844ce1ffc26e3c9ce3de280f..4bc49d124c06a94dc31051aa22f344fbaef6a2f4 100644 GIT binary patch delta 38 scmeCt?$O@xUxd+elBf=&Px# diff --git a/leex.beam b/leex.beam index a8090764ac9c1699615e42e9075221d1bcd81d9a..612f501a776187cffde4f0d460f11ddb8a10ad6e 100644 GIT binary patch delta 37 qcmey8`z3cnzZs+D$3IYHC diff --git a/server.beam b/server.beam index 316bbd9fa6dc2334550aea23dfb668ce5dde0f91..c7b62715289f24351eca371e693216639283bf84 100644 GIT binary patch delta 37 pcmZ1@yheC~J13*%WDiaqAX&<(Cdig3oG6zlpT*#qR9wOU1OU7h2)FDDa4j2oG6#5oyEZ5m{eTC00aQtk_nao delta 38 qcmaDM{z80%KR2WKDDa4w{m&lXImBql|m{eTC00aQqJPBC< diff --git a/test.beam b/test.beam index 08828ae89857e79ffadfefcbee578e9aaa69e2d4..5a6ba5a82378a4529b05af2231c0296be444fec6 100644 GIT binary patch delta 45 zcmdlYv_)vcVGb_K45kzY=H&8}l*tP?lo>52f8;P0U`rHEluMM)a!e{NVE_UEL#7Op delta 45 zcmdlYv_)vcVGb_y45kzY=H&8}l*tP?lo`z@f8;P0U`^ypk~%47v`Wk$=%h2o}s!ijQ;vRRHv#U%_t000pP3lIPR delta 43 xcmdm@zeRt8vpAP|22%k~%47v`Wk&PKh2o}se2J`yB3X_}#U%_t000io3grL* diff --git a/ubf_driver.beam b/ubf_driver.beam index 3e26f346b18a37a1e20eb2895a0822f571eb8029..cf2b8181b9b6d58193b1ba0fc1a9b90f08c777ac 100644 GIT binary patch delta 400 zcmcb@^MRYg%|FPHfr0hKM2`B26T`WfGV|He@{4j4OD4XsW=x-~!nldsz`#M7#X(ra zfmvnpV@73D5m5(aW_AGw2WDXh6=rsY00$9a2Nq=@o7Lc|0V9WiHm|5Kmk^LtRuOgJ z5@zNQNHCZjz$8^K$}4nGnfm<5!bm=%l-fJ&@|c}2w? zxWsvdF7XO8atJ{+7y~VA5a6%_T38RXQI10#Zl#E@0}IefK@oO^2_Q?EA(rw=0F4(G zbudP82FL--TvDPSSBeO#2%4}9EO6kGfx1RifWuEf)P+Np!&KRonaS8y1*jY7SD?ob zzG1rRF!?G|17{Sot1^?YpF+UoIA&ej;F6*c1_p-Y(xkNbl%mYC)FOrA)V!3;ymYI& z;<`MbumV)LC^b11D4(KGlvr+CQ&(J5mp6F|v;O2G%;AngKqG{KmHx`| VtQ!1$iGqo`SqzRz#U((E3;>dYV%Pux diff --git a/ubf_driver.erl b/ubf_driver.erl index 48bd12a..899ab79 100644 --- a/ubf_driver.erl +++ b/ubf_driver.erl @@ -35,7 +35,7 @@ loop(Socket, Pid, Cont) -> {Pid, Term} -> %% io:format("ubf_driver sending:~p~n",[Term]), Data = ubf:encode(Term), - io:format("ubf_driver sending:~s~n",[Data]), + %% io:format("ubf_driver sending:~s~n",[Data]), gen_tcp:send(Socket, Data), loop(Socket, Pid, Cont); stop -> @@ -49,7 +49,7 @@ loop(Socket, Pid, Cont) -> exit(socket_closed); {tcp, Socket, Data} -> T = binary_to_list(Data), - io:format("ubf driver received raw=|~s|~n",[T]), + %% io:format("ubf driver received raw=|~s|~n",[T]), Cont1 = ubf:decode(T, Cont), %% io:format("Cont1=~p~n",[Cont1]), handle_data(Socket, Pid, Cont1); diff --git a/ubf_test.beam b/ubf_test.beam index 6a2c1964e59e279619b4e7013b08f14a1324f7d7..7e86e8fb7bee4fec3dac4a0a7c929b85e0348f4e 100644 GIT binary patch delta 36 ocmdnNyMuRwI~$|rWDhnSAX&<0EWnm1oG6#5kmZ