Skip to content

Commit

Permalink
updated the makefile. fixed compiler errors. added rebar. added app f…
Browse files Browse the repository at this point in the history
…ile.
  • Loading branch information
OJ Reeves committed Aug 25, 2010
1 parent db9e0d8 commit f7a54bf
Show file tree
Hide file tree
Showing 4 changed files with 44 additions and 34 deletions.
45 changes: 19 additions & 26 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,34 +1,27 @@
SRC_DIR = src
EBIN_DIR = ebin
INCLUDE_DIR = include
ERL ?= erl
APP := openid

SOURCES = $(wildcard $(SRC_DIR)/*.erl)
INCLUDES = $(wildcard $(INCLUDE_DIR)/*.hrl)
TARGETS = $(patsubst $(SRC_DIR)/%.erl, $(EBIN_DIR)/%.beam,$(SOURCES))
.PHONY: deps
.PHONY: test
.PHONY: mod

ERL_EBINS = -pa $(EBIN_DIR)
all: deps
@./rebar compile

ERLC = erlc
ERLC_OPTS = -o $(EBIN_DIR) -Wall -v +debug_info
deps:
@./rebar get-deps

ERL_CMD=erl \
+W w \
$(ERL_EBINS)
clean:
@./rebar clean

all: $(TARGETS)
mod:
@./rebar create-mod app=$(APP) modid=$(MOD)

run_prereqs: all
test:
@./rebar eunit app=$(APP)

test: run_prereqs
$(ERL_CMD) -noshell -pa ../mochiweb/ebin -s openid_srv test -s init stop
distclean: clean
@./rebar delete-deps

clean: cleanlog
rm -f $(TARGETS)
rm -f $(EBIN_DIR)/*.beam

cleanlog:
rm -f auth.log report.log sasl_err.log
rm -f *.access

$(EBIN_DIR)/%.beam: $(SRC_DIR)/%.erl $(INCLUDES)
$(ERLC) $(ERLC_OPTS) $<
docs:
@erl -noshell -run edoc_run application '$(APP)' '"."' '[]'
14 changes: 14 additions & 0 deletions ebin/openid.app
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{application,
openid,
[{description, "OpenID 2.0 implementation"},
{vsn, "0.0.1"},
{modules,
[
openid,
openid_utils,
openid_srv,
yadis
]},
{registered,[]},
{applications,[kernel, stdlib]},
{env,[]}]}.
Binary file added rebar
Binary file not shown.
19 changes: 11 additions & 8 deletions src/openid_utils.erl
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,10 @@

-include("openid.hrl").

-define(GV(E, P), proplists:get_value(E, P)).
-define(GVD(E, P, D), proplists:get_value(E, P, D)).
-define(DBG(Term), io:format("~p: ~p~n", [self(), Term])).

get_tags(Content, Tag) ->
find_tags(Content, {[], Tag, none, none}).

Expand Down Expand Up @@ -39,6 +43,13 @@ skip_tag([$>|Rest], State) -> find_tags(Rest, State);
skip_tag("", State) -> find_tags("", State);
skip_tag([_|Rest], State) -> skip_tag(Rest, State).

check_attrs(PropList, Tail, {Buffer,Tag,none,none}) ->
find_tags(Tail, {[PropList|Buffer],Tag,none,none});
check_attrs(PropList, Tail, {_,_,Key,Val}=State) ->
case ?GVD(Key, PropList, none) of
none -> find_tags(Tail, State);
IVal -> check_val(string:to_lower(IVal), Val, PropList, Tail, State)
end.

get_tag_content(Rest, State) ->
{Content, Tail} = get_raw_content(Rest, []),
Expand All @@ -52,14 +63,6 @@ get_tag_content(Rest, State) ->
get_raw_content(">" ++ Tail, Content) -> {lists:reverse(Content), Tail};
get_raw_content([Char|Rest], Bits) -> get_raw_content(Rest, [Char|Bits]).

check_attrs(PropList, Tail, {Buffer,Tag,none,none}) ->
find_tags(Tail, {[PropList|Buffer],Tag,none,none});
check_attrs(PropList, Tail, {_,_,Key,Val}=State) ->
case ?GVD(Key, PropList, none) of
none -> find_tags(Tail, State);
IVal -> check_val(string:to_lower(IVal), Val, PropList, Tail, State)
end.

check_val(V, V, PropList, Tail, {Buffer,Tag,Key,Val})->
find_tags(Tail, {[PropList|Buffer],Tag,Key,Val});
check_val(_, _, _, Tail, State) ->
Expand Down

0 comments on commit f7a54bf

Please sign in to comment.