Skip to content
This repository
Fetching contributors…

Octocat-spinner-32-eaf2f5

Cannot retrieve contributors at this time

file 59 lines (48 sloc) 1.579 kb
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58

<erl>

prebox(Str) ->
    {'div',[{class,"man"}],
     {pre,[], yaws_api:htmlize(Str)}}.


out(A) ->
    H = {ssi, "TAB.inc", [],[]},
    L = case queryvar(A,"page") of
            {ok, Page} ->
                %% only allow regular chars in Page
                case lists:all(fun(C) ->
                                       if
                                           $a =< C, C =< $z ->
                                               true;
                                           $A =< C, C =< $Z ->
                                               true;
                                           C == $_ ->
                                               true;
                                           C == $. ->
                                               true;
                                           true ->
                                               false
                                       end
                               end, Page) of
                    true ->
%os:cmd("man " ++ Page ++ " | col -b -p -x");
unesc(os:cmd("man " ++ Page));
                    false ->
                        "illegal character detected in query arg"
                end;
            undefined ->
                "no man page found in query arg "
        end,

    Man = {ehtml, {'div', [{id, "entry"}], prebox(L)}},
    Trail = {ssi, "END2",[],[]},
    [H, Man, Trail].


unesc([27 | T]) ->
    unesc(uptom(T));
unesc([H|T]) ->
    [H|unesc(T)];
unesc([]) ->
    [].

uptom([$m|T]) ->
    T;
uptom([H|T]) ->
    uptom(T);
uptom([]) ->
    [].


</erl>
Something went wrong with that request. Please try again.