Permalink
Browse files

import ubf-1.7.tgz

  • Loading branch information...
1 parent d65b335 commit 01172799d8f5b04d5c9131d51dc90c1ec02c872e @norton norton committed Apr 11, 2009
Showing with 12,609 additions and 0 deletions.
  1. +74 −0 #ball.erl#
  2. +188 −0 #irc_plugin.erl#
  3. +1 −0 .#irc_plugin.erl
  4. +1 −0 .#plugins.erl
  5. +49 −0 Makefile
  6. +99 −0 ReadMe
  7. +22 −0 ReadMeLuke
  8. +6 −0 Todo
  9. BIN ball.beam
  10. +68 −0 ball.erl
  11. BIN bug.beam
  12. +11 −0 bug.erl
  13. BIN client.beam
  14. +175 −0 client.erl
  15. +3 −0 conc
  16. +3 −0 contract.hrl
  17. +50 −0 contract.xrl
  18. +61 −0 contract.yrl
  19. BIN contract_lex.beam
  20. +668 −0 contract_lex.erl
  21. BIN contract_manager.beam
  22. +167 −0 contract_manager.erl
  23. BIN contract_parser.beam
  24. +262 −0 contract_parser.erl
  25. BIN contract_yecc.beam
  26. +627 −0 contract_yecc.erl
  27. BIN contracts.beam
  28. +145 −0 contracts.erl
  29. 0 doc/ehtml.conf
  30. BIN doc/images/cl.png
  31. BIN doc/images/cr.png
  32. BIN doc/images/gl.png
  33. BIN doc/images/gr.png
  34. BIN doc/images/pix.gif
  35. BIN doc/images/sl.png
  36. BIN doc/images/sr.png
  37. BIN doc/images/topicapps.png
  38. BIN doc/images/ubf.gif
  39. BIN doc/images/wl.png
  40. BIN doc/images/wl_cccccc.png
  41. BIN doc/images/wr.png
  42. BIN doc/images/wr_cccccc.png
  43. +5 −0 doc/index.html
  44. +15 −0 doc/old/Makefile
  45. +25 −0 doc/old/Makefile~
  46. +76 −0 doc/old/ReadMe
  47. +63 −0 doc/old/ReadMe~
  48. +102 −0 doc/old/docs.html
  49. +52 −0 doc/old/msg1.fig
  50. BIN doc/old/msg1.gif
  51. +33 −0 doc/old/register.fig
  52. BIN doc/old/register.gif
  53. +49 −0 doc/old/start_client.fig
  54. BIN doc/old/start_client.gif
  55. +47 −0 doc/old/start_client_ubf.fig
  56. +47 −0 doc/old/start_client_ubf.fig.bak
  57. BIN doc/old/start_client_ubf.gif
  58. +60 −0 doc/old/start_erl.fig
  59. BIN doc/old/start_erl.gif
  60. +48 −0 doc/old/start_fail1.fig
  61. BIN doc/old/start_fail1.gif
  62. +42 −0 doc/old/start_fail2.fig
  63. BIN doc/old/start_fail2.gif
  64. +76 −0 doc/old/start_server_ubf.fig
  65. +76 −0 doc/old/start_server_ubf.fig.bak
  66. BIN doc/old/start_server_ubf.gif
  67. +60 −0 doc/old/start_ubf.fig
  68. +60 −0 doc/old/start_xml.fig
  69. BIN doc/old/start_xml.gif
  70. +39 −0 doc/old/termination.fig
  71. BIN doc/old/termination.gif
  72. +98 −0 doc/old/ubf.txt
  73. +292 −0 doc/site/file.html
  74. +204 −0 doc/site/ftp.html
  75. +195 −0 doc/site/home.html
  76. +240 −0 doc/site/irc.html
  77. +253 −0 doc/site/quick.html
  78. +271 −0 doc/site/ubfa.html
  79. +238 −0 doc/site/ubfa_quick.html
  80. +305 −0 doc/site/ubfb.html
  81. +238 −0 doc/site/ubfb_quick.html
  82. +374 −0 doc/site/white.html
  83. +50 −0 doc/src/#people.ehtml#
  84. +31 −0 doc/src/Makefile
  85. +31 −0 doc/src/Makefile~
  86. +35 −0 doc/src/file.ehtml
  87. +32 −0 doc/src/file.ehtml~
  88. +21 −0 doc/src/ftp.ehtml~
  89. +58 −0 doc/src/home.ehtml
  90. +57 −0 doc/src/home.ehtml~
  91. +23 −0 doc/src/index.ehtml
  92. +21 −0 doc/src/irc.ehtml
  93. +103 −0 doc/src/irc.ehtml~
  94. +146 −0 doc/src/layout.mac
  95. +128 −0 doc/src/layout.mac~
  96. +31 −0 doc/src/menus.inc
  97. +23 −0 doc/src/menus.inc~
  98. +75 −0 doc/src/quick.ehtml
  99. +212 −0 doc/src/quick.ehtml~
  100. +78 −0 doc/src/ubf.fig
  101. +149 −0 doc/src/ubfa.ehtml
  102. +149 −0 doc/src/ubfa.ehtml~
  103. +102 −0 doc/src/ubfa_quick.ehtml
  104. +20 −0 doc/src/ubfa_quick.ehtml~
  105. +20 −0 doc/src/ubfa_quick.erl
  106. +19 −0 doc/src/ubfa_quick.erl~
  107. +103 −0 doc/src/ubfb.ehtml
  108. +150 −0 doc/src/ubfb.ehtml~
  109. +102 −0 doc/src/ubfb_quick.ehtml
  110. +212 −0 doc/src/white.ehtml
  111. +179 −0 doc/src/white.ehtml~
  112. BIN file_client.beam
  113. +32 −0 file_client.erl
  114. BIN file_plugin.beam
  115. +1 −0 file_plugin.buc
  116. +23 −0 file_plugin.con
  117. +62 −0 file_plugin.erl
  118. BIN find.beam
  119. +126 −0 find.erl
  120. +2 −0 irc_client
  121. BIN irc_client.beam
  122. +99 −0 irc_client.erl
  123. BIN irc_client_gs.beam
  124. +127 −0 irc_client_gs.erl
  125. BIN irc_plugin.beam
  126. +1 −0 irc_plugin.buc
  127. +71 −0 irc_plugin.con
  128. +188 −0 irc_plugin.erl
  129. +4 −0 irc_server
  130. BIN leex.beam
  131. +578 −0 leex.erl
  132. +210 −0 leex.hrl
  133. BIN mods.beam
  134. +51 −0 mods.erl
  135. BIN plugin_handler.beam
  136. +115 −0 plugin_handler.erl
  137. BIN proc_socket_server.beam
  138. +125 −0 proc_socket_server.erl
  139. BIN server.beam
  140. +1 −0 server.buc
  141. +57 −0 server.con
  142. +149 −0 server.erl
  143. BIN server_plugin.beam
  144. +1 −0 server_plugin.buc
  145. +49 −0 server_plugin.con
  146. +57 −0 server_plugin.erl
  147. +11 −0 service_manager.erl
  148. +32 −0 sessions
  149. +15 −0 socket_test_client.erl
  150. +20 −0 socket_test_server.erl
  151. BIN test.beam
  152. +80 −0 test.erl
  153. BIN test_plugin.beam
  154. +1 −0 test_plugin.buc
  155. +46 −0 test_plugin.con
  156. +81 −0 test_plugin.erl
  157. +3 −0 todo
  158. +28 −0 ubf-java-0.2/Makefile
  159. +10 −0 ubf-java-0.2/src/ubf/InteractiveClient.java
  160. +43 −0 ubf-java-0.2/src/ubf/UBF.java
  161. +32 −0 ubf-java-0.2/src/ubf/UBFAtom.java
  162. +207 −0 ubf-java-0.2/src/ubf/UBFDecoder.java
  163. +118 −0 ubf-java-0.2/src/ubf/UBFEncoder.java
  164. +8 −0 ubf-java-0.2/src/ubf/UBFException.java
  165. +29 −0 ubf-java-0.2/src/ubf/UBFInteger.java
  166. +44 −0 ubf-java-0.2/src/ubf/UBFList.java
  167. +14 −0 ubf-java-0.2/src/ubf/UBFObject.java
  168. +28 −0 ubf-java-0.2/src/ubf/UBFString.java
  169. +60 −0 ubf-java-0.2/src/ubf/UBFTest.java
  170. +51 −0 ubf-java-0.2/src/ubf/UBFTuple.java
  171. +71 −0 ubf-java-0.2/src/ubf/irc1/IRCClient.java
  172. BIN ubf.beam
  173. +278 −0 ubf.erl
  174. +270 −0 ubf.erl.old
  175. BIN ubf_driver.beam
  176. +80 −0 ubf_driver.erl
  177. BIN ubf_test.beam
  178. +66 −0 ubf_test.erl
  179. BIN ubf_utils.beam
  180. +31 −0 ubf_utils.erl
View
@@ -0,0 +1,74 @@
+%% ``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.
+
+%% ------------------------------------------------------------
+
+
+
+
+
+
View
@@ -0,0 +1,188 @@
+-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}).
+
+
+
+
+
+
+
+
+
View
View
View
@@ -0,0 +1,49 @@
+.SUFFIXES: .beam .hrl .erl .html .ehtml .fig .gif .yrl .con .buc
+
+.erl.beam:
+ erlc -W $<
+
+.con.buc: contracts.beam
+ ./conc $<
+
+.yrl.erl:
+ echo "yecc:yecc($*,$*), halt()." | erl
+
+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
+
+PLUGINS = test_plugin file_plugin irc_plugin server_plugin
+
+CONTRACTS = test_plugin file_plugin irc_plugin server server_plugin
+
+BEAM = ${ERL:%=%.beam}
+BUC = ${CONTRACTS:%=%.buc}
+CON = ${CONTRACTS:%=%.con}
+PLUG = ${PLUGINS:%=%.beam}
+
+# make test (tests)
+# make server (starts server)
+
+all: ${BEAM} ${BUC} ${PLUG}
+
+test: ${BEAM} ${BUC} ${PLUG}
+ erl -noshell -pa ${HOME}"/p2p/new" -s test tests
+
+server: ${BEAM} ${BUC} ${PLUG}
+ erl -noshell -pa ${HOME}"/p2p/new" -s test ss
+
+
+contract_lex.erl: contract.xrl contract_parser.beam leex.beam
+ erl -noshell -s contract_parser make_lex -s erlang halt
+
+contract_yecc.erl: contract.yrl contract_parser.beam
+ erl -noshell -s contract_parser make_yecc -s erlang halt
+
+${PLUG}: contract_parser.beam contract_lex.beam contract_yecc.beam
+
+clean:
+ rm -f ${BEAM} ${BUC} ${PLUG} contract_lex.erl contract_yecc.erl
+ rm -f contract_parser.beam erl_crash.dump
+
Oops, something went wrong.

0 comments on commit 0117279

Please sign in to comment.