Permalink
Browse files

Remove a bunch of unused code (and convert from reg.erl to re module)

  • Loading branch information...
1 parent 90fdbb7 commit 543f6a780a86c1ef51e424f9d1fea169cfe9650c @Vagabond committed Feb 8, 2011
Showing with 4 additions and 1,625 deletions.
  1. +4 −6 elibs/conf.erl
  2. +0 −98 elibs/pipe.erl
  3. +0 −6 elibs/receive_pack.erl
  4. +0 −1,344 elibs/reg.erl
  5. +0 −38 elibs/server.erl
  6. +0 −133 elibs/upload_pack.erl
View
@@ -10,9 +10,8 @@ read_conf(Conf) ->
convert_path(Host, Path) ->
[{Host, {Regex, Transform}}] = ets:lookup(db, Host),
- case reg:smatch(Path, Regex) of
- {match, _A, _B, _C, MatchesTuple} ->
- Matches = tuple_to_list(MatchesTuple),
+ case re:run(Path, Regex, [{capture, all_but_first, list}]) of
+ {match, Matches} ->
Binding = create_binding(Matches),
% io:format("binding = ~p~n", [Binding]),
eval_erlang_expr(Transform, Binding);
@@ -27,9 +26,8 @@ parse_conf_line(Line) ->
ets:insert(db, {Host, {Regex, Transform}}).
create_binding(Matches) ->
- Modder = fun(M, Acc) ->
+ Modder = fun(Word, Acc) ->
{I, Arr} = Acc,
- {_A, _B, Word} = M,
Mod = {I, Word},
{I + 1, lists:append(Arr, [Mod])}
end,
@@ -67,4 +65,4 @@ md5_namespace3(Name) ->
hexmod8(Name) ->
<<A:4, _:124>> = erlang:md5(Name),
- integer_to_list(A rem 8).
+ integer_to_list(A rem 8).
View
@@ -1,98 +0,0 @@
-% pipe.erl
-%
-% This module implements a pipe data structure. This pipe implementation is
-% designed as a fifo for bytes. You write bytes *to* the pipe and then can
-% read those same bytes *from* the pipe. This is useful when dealing with
-% chunked data from an external port. All of the chunked data can be written
-% to the pipe and then you can read specific numbers of bytes from the pipe.
-% This is necessary if you wish to do your own packet length management.
-%
-% (The MIT License)
-%
-% Copyright (c) 2008 Tom Preston-Werner
-%
-% Permission is hereby granted, free of charge, to any person obtaining
-% a copy of this software and associated documentation files (the
-% 'Software'), to deal in the Software without restriction, including
-% without limitation the rights to use, copy, modify, merge, publish,
-% distribute, sublicense, and/or sell copies of the Software, and to
-% permit persons to whom the Software is furnished to do so, subject to
-% the following conditions:
-%
-% The above copyright notice and this permission notice shall be
-% included in all copies or substantial portions of the Software.
-%
-% THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
-% EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
-% MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
-% IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
-% CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
-% TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
-% SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-
--module(pipe).
--export([new/0, write/2, read/2, peek/2, size/1]).
-
--record(pipe, {pos = 0, size = 0, queue = queue:new()}).
-
-new() ->
- #pipe{}.
-
-write(Bin, Pipe) ->
- #pipe{size = Size, queue = Q} = Pipe,
- {ok, Pipe#pipe{size = Size + erlang:size(Bin), queue = queue:in(Bin, Q)}}.
-
-read(Num, Pipe) ->
- #pipe{size = Size, queue = Q1} = Pipe,
- case Num =< Size of
- true ->
- {Acc, Q2} = read_internal([], Num, Q1),
- Bin = list_to_binary(Acc),
- P2 = Pipe#pipe{size = Size - Num, queue = Q2},
- {ok, Bin, P2};
- false ->
- eof
- end.
-
-peek(Num, Pipe) ->
- #pipe{size = Size, queue = Q1} = Pipe,
- case Num =< Size of
- true ->
- {Acc, _} = read_internal([], Num, Q1),
- Bin = list_to_binary(Acc),
- {ok, Bin};
- false ->
- eof
- end.
-
-read_internal(Acc, Num, Q1) ->
- {{value, Bin}, Q2} = queue:out(Q1),
- Size = erlang:size(Bin),
- case spaceship(Num, Size) of
- -1 ->
- {B1, B2} = split_binary(Bin, Num),
- Q3 = queue:in_r(B2, Q2),
- Acc2 = lists:append(Acc, [B1]),
- {Acc2, Q3};
- 0 ->
- Acc2 = lists:append(Acc, [Bin]),
- {Acc2, Q2};
- 1 ->
- Acc2 = lists:append(Acc, [Bin]),
- read_internal(Acc2, Num - Size, Q2)
- end.
-
-size(Pipe) ->
- Pipe#pipe.size.
-
-% util
-
-spaceship(A, B) ->
- case A =< B of
- true ->
- case A < B of
- true -> -1;
- false -> 0
- end;
- false -> 1
- end.
@@ -1,6 +0,0 @@
--module(receive_pack).
--export([handle/3]).
-
-handle(Sock, _Host, _Header) ->
- gen_tcp:send(Sock, "006d\n*********'\n\nYou can't push to git://github.com/user/repo.git\nUse git@github.com:user/repo.git\n\n*********"),
- ok = gen_tcp:close(Sock).
Oops, something went wrong. Retry.

0 comments on commit 543f6a7

Please sign in to comment.