Mercurial > hg > dml-home
view .plrc @ 9:21dbe74c63bb
Working on setup script.
author | samer |
---|---|
date | Sun, 18 Jan 2015 21:55:24 +0000 |
parents | 3255717f4e6b |
children | d75099ce5f13 |
line wrap: on
line source
:- op(200,fy,@). persistent_history(H) :- prolog_history(disable), (exists_file(H) -> rl_read_history(H); true), current_prolog_flag(argv,ARGV), get_time(Now), format_time(string(Time),'%+',Now), format(atom(Header),'% Start: ~w - argv=~w.\n',[Time,ARGV]), rl_add_history(Header), at_halt(rl_write_history(H)). colour_terminal :- stream_property(user_output, tty(true)), getenv('TERM',Term), member(Term,[xterm,screen,'screen-256color','xterm-256color','xterm-color']). :- dynamic http_proxy/3. get_http_proxy(Host,Port,basic(User,Pwd)) :- getenv(use_proxy,yes), getenv(http_proxy,Proxy), % proxy looks like http://User:Password@Host:Port atom_concat('http://',Proxy1,Proxy), % strip off protocol split_atom(Proxy1,Auth,'@',HostPort), split_atom(Auth,User,':',Pwd), split_atom(HostPort,Host,':',APort), atom_number(APort,Port). split_atom(Atom,Pre,Mid,Post) :- sub_atom(Atom,LPre,_,LPost,Mid), sub_atom(Atom,0,LPre,_,Pre), sub_atom(Atom,_,LPost,0,Post). internal_host(localhost). internal_host(Host) :- sub_atom(Host,_,_,0,'bl.uk'). :- multifile http:open_options/2. http:open_options(Parts,[proxy(Host,Port),proxy_authorization(Auth)|Opts]) :- http_proxy(Host,Port,Auth), option(host(Target),Parts), \+internal_host(Target), debug(proxy,'Using HTTP proxy ~w:~w for ~w',[Host,Port,Target]), debug(proxy,'Parts: ~w',[Parts]), ( option(scheme(https),Parts) -> debug(proxy,'Using HTTPS',[]), Opts=[cert_verify_hook(verify_certificate)] ; Opts=[] ). verify_certificate(_,_,_,_,_) :- format(user_error,'Accepting certificate\n',[]). :- %persistent_history('.swipl_history'), (colour_terminal -> load_files(library(ansi_term), [silent(true)]); true), set_prolog_flag(prompt_alternatives_on, determinism), set_prolog_flag(editor, '$EDITOR'), load_files(library(url), [silent(true)]), load_files(library(http/http_ssl_plugin), [silent(true)]), ( get_http_proxy(Host,Port,Auth) -> assert(http_proxy(Host,Port,Auth)) ; true ).