Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Newer
Older
100644 81 lines (62 sloc) 2.524 kb
16299b3 Adding the beginning of WebDav support. The PROPFIND method has been …
Tobbe Tornquist authored
1 -module(yaws_dav).
2 %%%-------------------------------------------------------------------
3 %%% Created : 15 May 2005 by Tobbet <tobbe@tornkvist.org>
4 %%% Desc. : WebDav specifics.
5 %%%-------------------------------------------------------------------
5ef2b8a *** empty log message ***
Tobbe Tornquist authored
6 -export([parse_xml/1, xml_expand/1, xml_expand/2]).
7
ed4466e Fixed include file references.
Tobbe Tornquist authored
8 -include("../include/yaws_dav.hrl").
9 -include_lib("xmerl/include/xmerl.hrl").
16299b3 Adding the beginning of WebDav support. The PROPFIND method has been …
Tobbe Tornquist authored
10
11
12 -define(elog(X,Y), error_logger:info_msg("*elog ~p:~p: " X,
13 [?MODULE, ?LINE | Y])).
14
15
16 xml_expand(L) ->
5ef2b8a *** empty log message ***
Tobbe Tornquist authored
17 xml_expand(L, "utf-8").
18
19 xml_expand(L, Cset) ->
20 Prolog = ["<?xml version=\"1.0\" encoding=\""++Cset++"\" ?>"],
16299b3 Adding the beginning of WebDav support. The PROPFIND method has been …
Tobbe Tornquist authored
21 xmerl:export_simple(L,xmerl_xml,[{prolog,Prolog}]).
22
23
24 parse_xml([]) -> [];
25 parse_xml(L) when list(L) ->
26 case catch xmerl_scan:string(L, [{namespace_conformant, true}]) of
27 {X,_} when record(X, xmlElement) ->
28 parse_dav(X);
29 _Z ->
5ef2b8a *** empty log message ***
Tobbe Tornquist authored
30 ?elog("to_xml: error ~p~n", [_Z]),
16299b3 Adding the beginning of WebDav support. The PROPFIND method has been …
Tobbe Tornquist authored
31 {error, "xml scanner failed"}
32 end.
33
34 -define(CONTENT(X), X#xmlElement.content).
35
36 -define(IS_PROPFIND(X), #xmlElement{expanded_name = {'DAV:',propfind}} = X).
37 -define(IS_PROP(X), #xmlElement{expanded_name = {'DAV:',prop}} = X).
38 -define(IS_NAME(X), #xmlElement{expanded_name = {'DAV:',name}} = X).
39 -define(IS_PARENTNAME(X), #xmlElement{expanded_name = {'DAV:',parentname}} = X).
40 -define(IS_HREF(X), #xmlElement{expanded_name = {'DAV:',href}} = X).
41 -define(IS_ISHIDDEN(X), #xmlElement{expanded_name = {'DAV:',ishidden}} = X).
42 -define(IS_ISCOLLECTION(X), #xmlElement{expanded_name = {'DAV:',iscollection}} = X).
43
44
45 parse_dav(?IS_PROPFIND(X)) ->
46 parse_propfind(?CONTENT(X), #propfind{});
47 parse_dav(X) ->
48 %%?elog("parse_dav: GOT ~p~n", [X]),
49 {error, "parse_dav"}. % FIXME , webdav (tobbe)
50
51
52 parse_propfind([?IS_PROP(H)|T], R) ->
53 Prop = parse_prop(?CONTENT(H)),
54 parse_propfind(T, R#propfind{prop = Prop});
55 parse_propfind([H|T], R) ->
56 %%?elog("parse_propfind: ~p~n",[H]),
57 parse_propfind(T, R);
58 parse_propfind([], R) ->
59 R.
60
61 parse_prop(L) ->
62 parse_prop(L, []).
63
64 parse_prop([?IS_NAME(_H)|T], L) ->
65 parse_prop(T, [name | L]);
66 parse_prop([?IS_PARENTNAME(_H)|T], L) ->
67 parse_prop(T, [parentname | L]);
68 parse_prop([?IS_HREF(_H)|T], L) ->
69 parse_prop(T, [href | L]);
70 parse_prop([?IS_ISHIDDEN(_H)|T], L) ->
71 parse_prop(T, [ishidden | L]);
72 parse_prop([?IS_ISCOLLECTION(_H)|T], L) ->
73 parse_prop(T, [iscollection | L]);
74 parse_prop([H|T], L) ->
75 %%?elog("parse_propfind: ~p~n",[H]), % FIXME , webdav
76 parse_prop(T, L);
77 parse_prop([], L) ->
78 lists:reverse(L). % preserve order!
79
80
Something went wrong with that request. Please try again.