kibi-swipl-linux-x64-gnu 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +29 -0
- package/bin/swipl +0 -0
- package/bin/swipl-win +0 -0
- package/build-manifest.json +70 -0
- package/lib/cmake/swipl/SWIPLConfig.cmake +21 -0
- package/lib/cmake/swipl/SWIPLConfigVersion.cmake +65 -0
- package/lib/cmake/swipl/SWIPLTargets-release.cmake +28 -0
- package/lib/cmake/swipl/SWIPLTargets.cmake +109 -0
- package/lib/swipl/ABI +1 -0
- package/lib/swipl/LICENSE +41 -0
- package/lib/swipl/README.md +116 -0
- package/lib/swipl/app/README.md +25 -0
- package/lib/swipl/app/app.pl +87 -0
- package/lib/swipl/app/pack.pl +350 -0
- package/lib/swipl/app/qlf.pl +521 -0
- package/lib/swipl/app/splfr.pl +177 -0
- package/lib/swipl/app/sys.pl +310 -0
- package/lib/swipl/bin/swipl.home +1 -0
- package/lib/swipl/boot/apply.pl +73 -0
- package/lib/swipl/boot/attvar.pl +344 -0
- package/lib/swipl/boot/autoload.pl +1226 -0
- package/lib/swipl/boot/bags.pl +283 -0
- package/lib/swipl/boot/dcg.pl +388 -0
- package/lib/swipl/boot/dicts.pl +193 -0
- package/lib/swipl/boot/dwim.pl +485 -0
- package/lib/swipl/boot/engines.pl +152 -0
- package/lib/swipl/boot/expand.pl +1628 -0
- package/lib/swipl/boot/gc.pl +65 -0
- package/lib/swipl/boot/history.pl +304 -0
- package/lib/swipl/boot/init.pl +4682 -0
- package/lib/swipl/boot/iri.pl +64 -0
- package/lib/swipl/boot/license.pl +390 -0
- package/lib/swipl/boot/load.pl +81 -0
- package/lib/swipl/boot/messages.pl +2521 -0
- package/lib/swipl/boot/packs.pl +306 -0
- package/lib/swipl/boot/predopts.pl +154 -0
- package/lib/swipl/boot/qlf.pl +141 -0
- package/lib/swipl/boot/rc.pl +263 -0
- package/lib/swipl/boot/syspred.pl +1634 -0
- package/lib/swipl/boot/tabling.pl +2321 -0
- package/lib/swipl/boot/threads.pl +42 -0
- package/lib/swipl/boot/toplevel.pl +2248 -0
- package/lib/swipl/boot/topvars.pl +261 -0
- package/lib/swipl/boot.prc +0 -0
- package/lib/swipl/cmake/swipl.cmake +131 -0
- package/lib/swipl/customize/README.md +23 -0
- package/lib/swipl/customize/edit +101 -0
- package/lib/swipl/customize/init.pl +164 -0
- package/lib/swipl/demo/README.md +33 -0
- package/lib/swipl/demo/likes.pl +44 -0
- package/lib/swipl/doc/packages/examples/chr/bool.chr +281 -0
- package/lib/swipl/doc/packages/examples/chr/chrdif.chr +87 -0
- package/lib/swipl/doc/packages/examples/chr/chrfreeze.chr +6 -0
- package/lib/swipl/doc/packages/examples/chr/family.chr +116 -0
- package/lib/swipl/doc/packages/examples/chr/fib.chr +24 -0
- package/lib/swipl/doc/packages/examples/chr/fibonacci.chr +31 -0
- package/lib/swipl/doc/packages/examples/chr/gcd.chr +28 -0
- package/lib/swipl/doc/packages/examples/chr/leq.chr +34 -0
- package/lib/swipl/doc/packages/examples/chr/listdom.chr +138 -0
- package/lib/swipl/doc/packages/examples/chr/primes.chr +29 -0
- package/lib/swipl/doc/packages/examples/http/README.md +98 -0
- package/lib/swipl/doc/packages/examples/http/calc.pl +92 -0
- package/lib/swipl/doc/packages/examples/http/demo_body.pl +232 -0
- package/lib/swipl/doc/packages/examples/http/demo_client.pl +165 -0
- package/lib/swipl/doc/packages/examples/http/demo_daemon.pl +38 -0
- package/lib/swipl/doc/packages/examples/http/demo_files.pl +50 -0
- package/lib/swipl/doc/packages/examples/http/demo_hello.pl +15 -0
- package/lib/swipl/doc/packages/examples/http/demo_login.pl +280 -0
- package/lib/swipl/doc/packages/examples/http/demo_openid.pl +177 -0
- package/lib/swipl/doc/packages/examples/http/demo_pwp.pl +20 -0
- package/lib/swipl/doc/packages/examples/http/demo_rest.pl +56 -0
- package/lib/swipl/doc/packages/examples/http/demo_threads.pl +52 -0
- package/lib/swipl/doc/packages/examples/http/linux-init-script +126 -0
- package/lib/swipl/doc/packages/examples/http/pwp/context.pwp +23 -0
- package/lib/swipl/doc/packages/examples/http/pwp/index.pwp +25 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp1.pwp +12 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp2.pwp +10 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp3.pwp +25 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp4.pwp +23 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp5.pwp +11 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp6.pwp +3 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp7.pwp +3 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwp8.pwp +3 -0
- package/lib/swipl/doc/packages/examples/http/pwp/pwpdb.pl +12 -0
- package/lib/swipl/doc/packages/examples/http/systemd-script.service +18 -0
- package/lib/swipl/doc/packages/examples/http/upstart-script.conf +20 -0
- package/lib/swipl/doc/packages/examples/plunit/read.pl +17 -0
- package/lib/swipl/doc/packages/examples/plunit/simple.pl +33 -0
- package/lib/swipl/doc/packages/examples/ssl/client.pl +83 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/README +52 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/client/client-cert.p12 +0 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/client/client-cert.pem +85 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/client/client-key.pem +30 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/cacert.pem +82 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/careq.pem +18 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/crlnumber +1 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/index.txt +3 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/index.txt.attr +1 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/newcerts/9DC08797A0F63F7C.pem +85 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/newcerts/9DC08797A0F63F7D.pem +85 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/private/cakey.pem +30 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/demoCA/serial +1 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/server/server-cert.pem +85 -0
- package/lib/swipl/doc/packages/examples/ssl/etc/server/server-key.pem +30 -0
- package/lib/swipl/doc/packages/examples/ssl/https.pl +267 -0
- package/lib/swipl/doc/packages/examples/ssl/server.pl +106 -0
- package/lib/swipl/include/SWI-Prolog.h +1544 -0
- package/lib/swipl/include/SWI-Stream.h +537 -0
- package/lib/swipl/include/Yap/YapInterface.h +283 -0
- package/lib/swipl/include/sicstus/sicstus.h +452 -0
- package/lib/swipl/lib/x86_64-linux/cgi.so +0 -0
- package/lib/swipl/lib/x86_64-linux/crypt.so +0 -0
- package/lib/swipl/lib/x86_64-linux/crypto4pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/double_metaphone.so +0 -0
- package/lib/swipl/lib/x86_64-linux/files.so +0 -0
- package/lib/swipl/lib/x86_64-linux/hashstream.so +0 -0
- package/lib/swipl/lib/x86_64-linux/http_stream.so +0 -0
- package/lib/swipl/lib/x86_64-linux/isub.so +0 -0
- package/lib/swipl/lib/x86_64-linux/json.so +0 -0
- package/lib/swipl/lib/x86_64-linux/libswipl.so.10 +0 -0
- package/lib/swipl/lib/x86_64-linux/mallocinfo.so +0 -0
- package/lib/swipl/lib/x86_64-linux/md54pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/memfile.so +0 -0
- package/lib/swipl/lib/x86_64-linux/ntriples.so +0 -0
- package/lib/swipl/lib/x86_64-linux/pcre4pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/porter_stem.so +0 -0
- package/lib/swipl/lib/x86_64-linux/process.so +0 -0
- package/lib/swipl/lib/x86_64-linux/prolog_stream.so +0 -0
- package/lib/swipl/lib/x86_64-linux/rdf_db.so +0 -0
- package/lib/swipl/lib/x86_64-linux/readutil.so +0 -0
- package/lib/swipl/lib/x86_64-linux/rlimit.so +0 -0
- package/lib/swipl/lib/x86_64-linux/sched.so +0 -0
- package/lib/swipl/lib/x86_64-linux/sgml2pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/sha4pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/snowball.so +0 -0
- package/lib/swipl/lib/x86_64-linux/socket.so +0 -0
- package/lib/swipl/lib/x86_64-linux/ssl4pl.so +0 -0
- package/lib/swipl/lib/x86_64-linux/streaminfo.so +0 -0
- package/lib/swipl/lib/x86_64-linux/syslog.so +0 -0
- package/lib/swipl/lib/x86_64-linux/time.so +0 -0
- package/lib/swipl/lib/x86_64-linux/turtle.so +0 -0
- package/lib/swipl/lib/x86_64-linux/uid.so +0 -0
- package/lib/swipl/lib/x86_64-linux/unix.so +0 -0
- package/lib/swipl/lib/x86_64-linux/uri.so +0 -0
- package/lib/swipl/lib/x86_64-linux/websocket.so +0 -0
- package/lib/swipl/lib/x86_64-linux/zlib4pl.so +0 -0
- package/lib/swipl/library/INDEX.pl +1020 -0
- package/lib/swipl/library/aggregate.pl +755 -0
- package/lib/swipl/library/ansi_term.pl +653 -0
- package/lib/swipl/library/apply.pl +426 -0
- package/lib/swipl/library/apply_macros.pl +497 -0
- package/lib/swipl/library/arithmetic.pl +320 -0
- package/lib/swipl/library/assoc.pl +522 -0
- package/lib/swipl/library/atom.pl +169 -0
- package/lib/swipl/library/backcomp.pl +688 -0
- package/lib/swipl/library/base32.pl +291 -0
- package/lib/swipl/library/base64.pl +441 -0
- package/lib/swipl/library/broadcast.pl +161 -0
- package/lib/swipl/library/build/cmake.pl +137 -0
- package/lib/swipl/library/build/conan.pl +232 -0
- package/lib/swipl/library/build/make.pl +168 -0
- package/lib/swipl/library/build/tools.pl +825 -0
- package/lib/swipl/library/charsio.pl +195 -0
- package/lib/swipl/library/check.pl +1097 -0
- package/lib/swipl/library/check_installation.pl +912 -0
- package/lib/swipl/library/clp/INDEX.pl +157 -0
- package/lib/swipl/library/clp/bounds.pl +2036 -0
- package/lib/swipl/library/clp/clp_distinct.pl +263 -0
- package/lib/swipl/library/clp/clp_events.pl +92 -0
- package/lib/swipl/library/clp/clpb.pl +1896 -0
- package/lib/swipl/library/clp/clpfd.pl +7906 -0
- package/lib/swipl/library/clp/simplex.pl +1580 -0
- package/lib/swipl/library/codesio.pl +182 -0
- package/lib/swipl/library/coinduction.pl +183 -0
- package/lib/swipl/library/console_input.pl +289 -0
- package/lib/swipl/library/csv.pl +611 -0
- package/lib/swipl/library/ctypes.pl +161 -0
- package/lib/swipl/library/date.pl +370 -0
- package/lib/swipl/library/dcg/INDEX.pl +35 -0
- package/lib/swipl/library/dcg/basics.pl +514 -0
- package/lib/swipl/library/dcg/high_order.pl +227 -0
- package/lib/swipl/library/debug.pl +499 -0
- package/lib/swipl/library/dialect/bim.pl +186 -0
- package/lib/swipl/library/dialect/commons.pl +77 -0
- package/lib/swipl/library/dialect/eclipse/test_util_iso.pl +355 -0
- package/lib/swipl/library/dialect/hprolog/format.pl +44 -0
- package/lib/swipl/library/dialect/hprolog.pl +314 -0
- package/lib/swipl/library/dialect/ifprolog.pl +1317 -0
- package/lib/swipl/library/dialect/iso/iso_predicates.pl +277 -0
- package/lib/swipl/library/dialect/sicstus/README.TXT +1 -0
- package/lib/swipl/library/dialect/sicstus/arrays.pl +121 -0
- package/lib/swipl/library/dialect/sicstus/block.pl +278 -0
- package/lib/swipl/library/dialect/sicstus/lists.pl +167 -0
- package/lib/swipl/library/dialect/sicstus/ordsets.pl +52 -0
- package/lib/swipl/library/dialect/sicstus/sockets.pl +174 -0
- package/lib/swipl/library/dialect/sicstus/system.pl +262 -0
- package/lib/swipl/library/dialect/sicstus/terms.pl +57 -0
- package/lib/swipl/library/dialect/sicstus/timeout.pl +92 -0
- package/lib/swipl/library/dialect/sicstus.pl +582 -0
- package/lib/swipl/library/dialect/sicstus4/aggregate.pl +60 -0
- package/lib/swipl/library/dialect/sicstus4/between.pl +62 -0
- package/lib/swipl/library/dialect/sicstus4/clpfd.pl +75 -0
- package/lib/swipl/library/dialect/sicstus4/file_systems.pl +413 -0
- package/lib/swipl/library/dialect/sicstus4/lists.pl +274 -0
- package/lib/swipl/library/dialect/sicstus4/ordsets.pl +54 -0
- package/lib/swipl/library/dialect/sicstus4/samsort.pl +86 -0
- package/lib/swipl/library/dialect/sicstus4/sets.pl +124 -0
- package/lib/swipl/library/dialect/sicstus4/sockets.pl +164 -0
- package/lib/swipl/library/dialect/sicstus4/system.pl +80 -0
- package/lib/swipl/library/dialect/sicstus4/terms.pl +89 -0
- package/lib/swipl/library/dialect/sicstus4/timeout.pl +43 -0
- package/lib/swipl/library/dialect/sicstus4/types.pl +103 -0
- package/lib/swipl/library/dialect/sicstus4.pl +200 -0
- package/lib/swipl/library/dialect/swi/syspred_options.pl +250 -0
- package/lib/swipl/library/dialect/xsb/README.md +20 -0
- package/lib/swipl/library/dialect/xsb/basics.pl +318 -0
- package/lib/swipl/library/dialect/xsb/consult.pl +87 -0
- package/lib/swipl/library/dialect/xsb/curr_sym.pl +57 -0
- package/lib/swipl/library/dialect/xsb/error_handler.pl +111 -0
- package/lib/swipl/library/dialect/xsb/gensym.pl +53 -0
- package/lib/swipl/library/dialect/xsb/gpp.pl +138 -0
- package/lib/swipl/library/dialect/xsb/intern.pl +48 -0
- package/lib/swipl/library/dialect/xsb/lists.pl +47 -0
- package/lib/swipl/library/dialect/xsb/machine.pl +295 -0
- package/lib/swipl/library/dialect/xsb/ordsets.pl +53 -0
- package/lib/swipl/library/dialect/xsb/setof.pl +54 -0
- package/lib/swipl/library/dialect/xsb/source.pl +308 -0
- package/lib/swipl/library/dialect/xsb/standard.pl +169 -0
- package/lib/swipl/library/dialect/xsb/storage.pl +70 -0
- package/lib/swipl/library/dialect/xsb/string.pl +76 -0
- package/lib/swipl/library/dialect/xsb/thread.pl +62 -0
- package/lib/swipl/library/dialect/xsb/timed_call.pl +158 -0
- package/lib/swipl/library/dialect/xsb.pl +688 -0
- package/lib/swipl/library/dialect/yap/README.TXT +8 -0
- package/lib/swipl/library/dialect/yap.pl +283 -0
- package/lib/swipl/library/dialect.pl +123 -0
- package/lib/swipl/library/dicts.pl +399 -0
- package/lib/swipl/library/dif.pl +426 -0
- package/lib/swipl/library/edinburgh.pl +138 -0
- package/lib/swipl/library/edit.pl +783 -0
- package/lib/swipl/library/error.pl +495 -0
- package/lib/swipl/library/exceptions.pl +231 -0
- package/lib/swipl/library/explain.pl +543 -0
- package/lib/swipl/library/ext/RDF/INDEX.pl +25 -0
- package/lib/swipl/library/ext/RDF/rdf.pl +450 -0
- package/lib/swipl/library/ext/RDF/rdf_parser.pl +649 -0
- package/lib/swipl/library/ext/RDF/rdf_triple.pl +448 -0
- package/lib/swipl/library/ext/RDF/rdf_write.pl +701 -0
- package/lib/swipl/library/ext/RDF/rewrite_term.pl +177 -0
- package/lib/swipl/library/ext/chr/chr/a_star.pl +80 -0
- package/lib/swipl/library/ext/chr/chr/binomialheap.pl +142 -0
- package/lib/swipl/library/ext/chr/chr/builtins.pl +629 -0
- package/lib/swipl/library/ext/chr/chr/chr_compiler_errors.pl +179 -0
- package/lib/swipl/library/ext/chr/chr/chr_compiler_options.pl +382 -0
- package/lib/swipl/library/ext/chr/chr/chr_compiler_utility.pl +338 -0
- package/lib/swipl/library/ext/chr/chr/chr_debug.pl +59 -0
- package/lib/swipl/library/ext/chr/chr/chr_hashtable_store.pl +425 -0
- package/lib/swipl/library/ext/chr/chr/chr_integertable_store.pl +139 -0
- package/lib/swipl/library/ext/chr/chr/chr_messages.pl +176 -0
- package/lib/swipl/library/ext/chr/chr/chr_op.pl +53 -0
- package/lib/swipl/library/ext/chr/chr/chr_runtime.pl +1016 -0
- package/lib/swipl/library/ext/chr/chr/chr_translate.pl +25424 -0
- package/lib/swipl/library/ext/chr/chr/clean_code.pl +252 -0
- package/lib/swipl/library/ext/chr/chr/find.pl +78 -0
- package/lib/swipl/library/ext/chr/chr/guard_entailment.pl +19432 -0
- package/lib/swipl/library/ext/chr/chr/listmap.pl +108 -0
- package/lib/swipl/library/ext/chr/chr/pairlist.pl +78 -0
- package/lib/swipl/library/ext/chr/chr.pl +686 -0
- package/lib/swipl/library/ext/clib/INDEX.pl +158 -0
- package/lib/swipl/library/ext/clib/cgi.pl +86 -0
- package/lib/swipl/library/ext/clib/crypt.pl +44 -0
- package/lib/swipl/library/ext/clib/filesex.pl +644 -0
- package/lib/swipl/library/ext/clib/hash_stream.pl +119 -0
- package/lib/swipl/library/ext/clib/mallocinfo.pl +138 -0
- package/lib/swipl/library/ext/clib/md5.pl +68 -0
- package/lib/swipl/library/ext/clib/memfile.pl +61 -0
- package/lib/swipl/library/ext/clib/process.pl +573 -0
- package/lib/swipl/library/ext/clib/prolog_server.pl +157 -0
- package/lib/swipl/library/ext/clib/prolog_stream.pl +80 -0
- package/lib/swipl/library/ext/clib/rlimit.pl +54 -0
- package/lib/swipl/library/ext/clib/sched.pl +85 -0
- package/lib/swipl/library/ext/clib/sha.pl +162 -0
- package/lib/swipl/library/ext/clib/socket.pl +1102 -0
- package/lib/swipl/library/ext/clib/streaminfo.pl +103 -0
- package/lib/swipl/library/ext/clib/streampool.pl +136 -0
- package/lib/swipl/library/ext/clib/syslog.pl +180 -0
- package/lib/swipl/library/ext/clib/time.pl +194 -0
- package/lib/swipl/library/ext/clib/udp_broadcast.pl +975 -0
- package/lib/swipl/library/ext/clib/uid.pl +220 -0
- package/lib/swipl/library/ext/clib/unix.pl +317 -0
- package/lib/swipl/library/ext/clib/uri.pl +530 -0
- package/lib/swipl/library/ext/clib/uuid.pl +207 -0
- package/lib/swipl/library/ext/http/http/INDEX.pl +266 -0
- package/lib/swipl/library/ext/http/http/README.md +34 -0
- package/lib/swipl/library/ext/http/http/ax.pl +189 -0
- package/lib/swipl/library/ext/http/http/dcg_basics.pl +49 -0
- package/lib/swipl/library/ext/http/http/graphql.pl +1367 -0
- package/lib/swipl/library/ext/http/http/html_decl.pl +416 -0
- package/lib/swipl/library/ext/http/http/html_head.pl +654 -0
- package/lib/swipl/library/ext/http/http/html_quasiquotations.pl +120 -0
- package/lib/swipl/library/ext/http/http/html_write.pl +1425 -0
- package/lib/swipl/library/ext/http/http/htmx.pl +139 -0
- package/lib/swipl/library/ext/http/http/http_authenticate.pl +364 -0
- package/lib/swipl/library/ext/http/http/http_client.pl +412 -0
- package/lib/swipl/library/ext/http/http/http_cookie.pl +245 -0
- package/lib/swipl/library/ext/http/http/http_cors.pl +176 -0
- package/lib/swipl/library/ext/http/http/http_digest.pl +820 -0
- package/lib/swipl/library/ext/http/http/http_dirindex.pl +296 -0
- package/lib/swipl/library/ext/http/http/http_dispatch.pl +1552 -0
- package/lib/swipl/library/ext/http/http/http_dyn_workers.pl +214 -0
- package/lib/swipl/library/ext/http/http/http_error.pl +126 -0
- package/lib/swipl/library/ext/http/http/http_exception.pl +225 -0
- package/lib/swipl/library/ext/http/http/http_files.pl +163 -0
- package/lib/swipl/library/ext/http/http/http_header.pl +2820 -0
- package/lib/swipl/library/ext/http/http/http_hook.pl +106 -0
- package/lib/swipl/library/ext/http/http/http_host.pl +204 -0
- package/lib/swipl/library/ext/http/http/http_load.pl +113 -0
- package/lib/swipl/library/ext/http/http/http_log.pl +738 -0
- package/lib/swipl/library/ext/http/http/http_multipart_plugin.pl +232 -0
- package/lib/swipl/library/ext/http/http/http_open.pl +1821 -0
- package/lib/swipl/library/ext/http/http/http_openid.pl +1561 -0
- package/lib/swipl/library/ext/http/http/http_parameters.pl +504 -0
- package/lib/swipl/library/ext/http/http/http_path.pl +380 -0
- package/lib/swipl/library/ext/http/http/http_proxy.pl +80 -0
- package/lib/swipl/library/ext/http/http/http_pwp.pl +351 -0
- package/lib/swipl/library/ext/http/http/http_redis_plugin.pl +332 -0
- package/lib/swipl/library/ext/http/http/http_server.pl +105 -0
- package/lib/swipl/library/ext/http/http/http_server_files.pl +126 -0
- package/lib/swipl/library/ext/http/http/http_server_health.pl +186 -0
- package/lib/swipl/library/ext/http/http/http_session.pl +1040 -0
- package/lib/swipl/library/ext/http/http/http_sgml_plugin.pl +137 -0
- package/lib/swipl/library/ext/http/http/http_stream.pl +376 -0
- package/lib/swipl/library/ext/http/http/http_unix_daemon.pl +989 -0
- package/lib/swipl/library/ext/http/http/http_wrapper.pl +559 -0
- package/lib/swipl/library/ext/http/http/hub.pl +600 -0
- package/lib/swipl/library/ext/http/http/js_write.pl +461 -0
- package/lib/swipl/library/ext/http/http/mimepack.pl +224 -0
- package/lib/swipl/library/ext/http/http/mimetype.pl +276 -0
- package/lib/swipl/library/ext/http/http/term_html.pl +797 -0
- package/lib/swipl/library/ext/http/http/thread_httpd.pl +1181 -0
- package/lib/swipl/library/ext/http/http/web/css/dirindex.css +24 -0
- package/lib/swipl/library/ext/http/http/web/css/openid.css +57 -0
- package/lib/swipl/library/ext/http/http/web/icons/back.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/c.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/compressed.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/folder.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/generic.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/layout.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/openid-logo-square.png +0 -0
- package/lib/swipl/library/ext/http/http/web/icons/openid-logo-tiny.png +0 -0
- package/lib/swipl/library/ext/http/http/websocket.pl +729 -0
- package/lib/swipl/library/ext/http/http/yadis.pl +205 -0
- package/lib/swipl/library/ext/json/INDEX.pl +36 -0
- package/lib/swipl/library/ext/json/http/INDEX.pl +16 -0
- package/lib/swipl/library/ext/json/http/http_json.pl +490 -0
- package/lib/swipl/library/ext/json/http/js_grammar.pl +53 -0
- package/lib/swipl/library/ext/json/http/json.pl +48 -0
- package/lib/swipl/library/ext/json/http/json_convert.pl +48 -0
- package/lib/swipl/library/ext/json/json.pl +1215 -0
- package/lib/swipl/library/ext/json/json_convert.pl +681 -0
- package/lib/swipl/library/ext/json/json_grammar.pl +349 -0
- package/lib/swipl/library/ext/json/json_rpc_client.pl +423 -0
- package/lib/swipl/library/ext/json/json_rpc_common.pl +104 -0
- package/lib/swipl/library/ext/json/json_rpc_server.pl +489 -0
- package/lib/swipl/library/ext/json/json_schema.pl +2111 -0
- package/lib/swipl/library/ext/nlp/INDEX.pl +15 -0
- package/lib/swipl/library/ext/nlp/double_metaphone.pl +86 -0
- package/lib/swipl/library/ext/nlp/isub.pl +162 -0
- package/lib/swipl/library/ext/nlp/porter_stem.pl +50 -0
- package/lib/swipl/library/ext/nlp/snowball.pl +97 -0
- package/lib/swipl/library/ext/pcre/INDEX.pl +17 -0
- package/lib/swipl/library/ext/pcre/pcre.pl +974 -0
- package/lib/swipl/library/ext/plunit/INDEX.pl +20 -0
- package/lib/swipl/library/ext/plunit/plunit.pl +2631 -0
- package/lib/swipl/library/ext/plunit/test_wizard.pl +249 -0
- package/lib/swipl/library/ext/semweb/semweb/INDEX.pl +288 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf11.pl +2106 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf11_containers.pl +299 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_cache.pl +278 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_compare.pl +132 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_db.pl +3468 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_edit.pl +1145 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_http_plugin.pl +274 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_library.pl +1021 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_litindex.pl +1035 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_ntriples.pl +422 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_persistency.pl +1576 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_portray.pl +182 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_prefixes.pl +681 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_sandbox.pl +153 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_turtle.pl +54 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_turtle_write.pl +1587 -0
- package/lib/swipl/library/ext/semweb/semweb/rdf_zlib_plugin.pl +52 -0
- package/lib/swipl/library/ext/semweb/semweb/rdfa.pl +1510 -0
- package/lib/swipl/library/ext/semweb/semweb/rdfs.pl +475 -0
- package/lib/swipl/library/ext/semweb/semweb/sparql_client.pl +643 -0
- package/lib/swipl/library/ext/semweb/semweb/turtle.pl +455 -0
- package/lib/swipl/library/ext/sgml/DTD/HTML4.dcl +88 -0
- package/lib/swipl/library/ext/sgml/DTD/HTML4.dtd +1092 -0
- package/lib/swipl/library/ext/sgml/DTD/HTML4.soc +6 -0
- package/lib/swipl/library/ext/sgml/DTD/HTML5.dtd +906 -0
- package/lib/swipl/library/ext/sgml/DTD/HTMLlat1.ent +195 -0
- package/lib/swipl/library/ext/sgml/DTD/HTMLspec.ent +77 -0
- package/lib/swipl/library/ext/sgml/DTD/HTMLsym.ent +241 -0
- package/lib/swipl/library/ext/sgml/INDEX.pl +64 -0
- package/lib/swipl/library/ext/sgml/c14n2.pl +203 -0
- package/lib/swipl/library/ext/sgml/iso_639.pl +631 -0
- package/lib/swipl/library/ext/sgml/pwp.pl +705 -0
- package/lib/swipl/library/ext/sgml/sgml.pl +815 -0
- package/lib/swipl/library/ext/sgml/sgml_write.pl +1003 -0
- package/lib/swipl/library/ext/sgml/xpath.pl +620 -0
- package/lib/swipl/library/ext/sgml/xsdp_types.pl +232 -0
- package/lib/swipl/library/ext/ssl/INDEX.pl +60 -0
- package/lib/swipl/library/ext/ssl/crypto.pl +1015 -0
- package/lib/swipl/library/ext/ssl/http/INDEX.pl +5 -0
- package/lib/swipl/library/ext/ssl/http/http_ssl_plugin.pl +296 -0
- package/lib/swipl/library/ext/ssl/saml.pl +609 -0
- package/lib/swipl/library/ext/ssl/ssl.pl +647 -0
- package/lib/swipl/library/ext/ssl/xmldsig.pl +391 -0
- package/lib/swipl/library/ext/ssl/xmlenc.pl +354 -0
- package/lib/swipl/library/ext/zlib/INDEX.pl +8 -0
- package/lib/swipl/library/ext/zlib/zlib.pl +112 -0
- package/lib/swipl/library/fastrw.pl +105 -0
- package/lib/swipl/library/files.pl +80 -0
- package/lib/swipl/library/gensym.pl +111 -0
- package/lib/swipl/library/git.pl +1027 -0
- package/lib/swipl/library/hashtable.pl +365 -0
- package/lib/swipl/library/heaps.pl +252 -0
- package/lib/swipl/library/hotfix.pl +239 -0
- package/lib/swipl/library/http/jquery.pl +103 -0
- package/lib/swipl/library/http/web/js/jquery-3.6.0.min.js +2 -0
- package/lib/swipl/library/increval.pl +217 -0
- package/lib/swipl/library/intercept.pl +263 -0
- package/lib/swipl/library/iostream.pl +237 -0
- package/lib/swipl/library/iri_scheme/file.pl +70 -0
- package/lib/swipl/library/lazy_lists.pl +481 -0
- package/lib/swipl/library/listing.pl +1362 -0
- package/lib/swipl/library/lists.pl +860 -0
- package/lib/swipl/library/lynx/INDEX.pl +14 -0
- package/lib/swipl/library/lynx/format.pl +380 -0
- package/lib/swipl/library/lynx/html_style.pl +129 -0
- package/lib/swipl/library/lynx/html_text.pl +865 -0
- package/lib/swipl/library/lynx/pldoc_style.pl +87 -0
- package/lib/swipl/library/macros.pl +451 -0
- package/lib/swipl/library/main.pl +1200 -0
- package/lib/swipl/library/make.pl +197 -0
- package/lib/swipl/library/modules.pl +129 -0
- package/lib/swipl/library/nb_rbtrees.pl +267 -0
- package/lib/swipl/library/nb_set.pl +203 -0
- package/lib/swipl/library/obfuscate.pl +115 -0
- package/lib/swipl/library/occurs.pl +241 -0
- package/lib/swipl/library/operators.pl +182 -0
- package/lib/swipl/library/option.pl +388 -0
- package/lib/swipl/library/optparse.pl +966 -0
- package/lib/swipl/library/ordsets.pl +518 -0
- package/lib/swipl/library/oset.pl +160 -0
- package/lib/swipl/library/pairs.pl +187 -0
- package/lib/swipl/library/persistency.pl +713 -0
- package/lib/swipl/library/pio.pl +47 -0
- package/lib/swipl/library/portray_text.pl +277 -0
- package/lib/swipl/library/pprint.pl +940 -0
- package/lib/swipl/library/predicate_options.pl +975 -0
- package/lib/swipl/library/prolog_autoload.pl +233 -0
- package/lib/swipl/library/prolog_breakpoints.pl +396 -0
- package/lib/swipl/library/prolog_clause.pl +1104 -0
- package/lib/swipl/library/prolog_code.pl +416 -0
- package/lib/swipl/library/prolog_codewalk.pl +1248 -0
- package/lib/swipl/library/prolog_colour.pl +3301 -0
- package/lib/swipl/library/prolog_colour.qlf +0 -0
- package/lib/swipl/library/prolog_config.pl +154 -0
- package/lib/swipl/library/prolog_coverage.pl +1333 -0
- package/lib/swipl/library/prolog_debug.pl +404 -0
- package/lib/swipl/library/prolog_deps.pl +675 -0
- package/lib/swipl/library/prolog_evaluable.pl +234 -0
- package/lib/swipl/library/prolog_format.pl +219 -0
- package/lib/swipl/library/prolog_history.pl +161 -0
- package/lib/swipl/library/prolog_jiti.pl +333 -0
- package/lib/swipl/library/prolog_locale.pl +61 -0
- package/lib/swipl/library/prolog_metainference.pl +307 -0
- package/lib/swipl/library/prolog_pack.pl +3906 -0
- package/lib/swipl/library/prolog_profile.pl +346 -0
- package/lib/swipl/library/prolog_qlfmake.pl +533 -0
- package/lib/swipl/library/prolog_source.pl +1188 -0
- package/lib/swipl/library/prolog_stack.pl +794 -0
- package/lib/swipl/library/prolog_trace.pl +365 -0
- package/lib/swipl/library/prolog_versions.pl +347 -0
- package/lib/swipl/library/prolog_wrap.pl +164 -0
- package/lib/swipl/library/prolog_xref.pl +3090 -0
- package/lib/swipl/library/prolog_xref.qlf +0 -0
- package/lib/swipl/library/pure_input.pl +266 -0
- package/lib/swipl/library/qpforeign.pl +695 -0
- package/lib/swipl/library/qsave.pl +1516 -0
- package/lib/swipl/library/quasi_quotations.pl +300 -0
- package/lib/swipl/library/quintus.pl +437 -0
- package/lib/swipl/library/random.pl +459 -0
- package/lib/swipl/library/rbtrees.pl +1153 -0
- package/lib/swipl/library/readln.pl +256 -0
- package/lib/swipl/library/readutil.pl +304 -0
- package/lib/swipl/library/record.pl +544 -0
- package/lib/swipl/library/rwlocks.pl +172 -0
- package/lib/swipl/library/sandbox.pl +1384 -0
- package/lib/swipl/library/semweb/dc.rdfs +198 -0
- package/lib/swipl/library/semweb/eor.rdfs +95 -0
- package/lib/swipl/library/semweb/owl.owl +287 -0
- package/lib/swipl/library/semweb/rdf_library.ttl +90 -0
- package/lib/swipl/library/semweb/rdfs.rdfs +251 -0
- package/lib/swipl/library/settings.pl +755 -0
- package/lib/swipl/library/shell.pl +462 -0
- package/lib/swipl/library/shlib.pl +670 -0
- package/lib/swipl/library/solution_sequences.pl +439 -0
- package/lib/swipl/library/sort.pl +119 -0
- package/lib/swipl/library/statistics.pl +541 -0
- package/lib/swipl/library/streams.pl +118 -0
- package/lib/swipl/library/strings.pl +469 -0
- package/lib/swipl/library/system.pl +95 -0
- package/lib/swipl/library/tables.pl +381 -0
- package/lib/swipl/library/tableutil.pl +771 -0
- package/lib/swipl/library/tabling.pl +42 -0
- package/lib/swipl/library/terms.pl +457 -0
- package/lib/swipl/library/theme/auto.pl +61 -0
- package/lib/swipl/library/theme/dark.pl +455 -0
- package/lib/swipl/library/theme/light.pl +45 -0
- package/lib/swipl/library/thread.pl +810 -0
- package/lib/swipl/library/thread_pool.pl +508 -0
- package/lib/swipl/library/threadutil.pl +574 -0
- package/lib/swipl/library/tty.pl +316 -0
- package/lib/swipl/library/ugraphs.pl +644 -0
- package/lib/swipl/library/unicode/INDEX.pl +6 -0
- package/lib/swipl/library/unicode/blocks.pl +414 -0
- package/lib/swipl/library/url.pl +1129 -0
- package/lib/swipl/library/utf8.pl +145 -0
- package/lib/swipl/library/varnumbers.pl +221 -0
- package/lib/swipl/library/vm.pl +251 -0
- package/lib/swipl/library/wfs.pl +205 -0
- package/lib/swipl/library/when.pl +263 -0
- package/lib/swipl/library/writef.pl +278 -0
- package/lib/swipl/library/www_browser.pl +251 -0
- package/lib/swipl/library/yall.pl +574 -0
- package/lib/swipl/library/zip.pl +211 -0
- package/lib/swipl/swipl.home +1 -0
- package/lib/vendor/libcrypto.so.3 +0 -0
- package/lib/vendor/libpcre2-8.so.0 +0 -0
- package/lib/vendor/libssl.so.3 +0 -0
- package/lib/vendor/libz.so.1 +0 -0
- package/licenses/OpenSSL-LICENSE.txt +177 -0
- package/licenses/PCRE2-COPYING +5 -0
- package/licenses/README.md +12 -0
- package/licenses/SWI-Prolog-LICENSE +41 -0
- package/licenses/zlib-LICENSE +22 -0
- package/package.json +27 -0
|
@@ -0,0 +1,1129 @@
|
|
|
1
|
+
/* Part of SWI-Prolog
|
|
2
|
+
|
|
3
|
+
Author: Jan Wielemaker
|
|
4
|
+
E-mail: J.Wielemaker@vu.nl
|
|
5
|
+
WWW: http://www.swi-prolog.org
|
|
6
|
+
Copyright (c) 2000-2015, University of Amsterdam
|
|
7
|
+
All rights reserved.
|
|
8
|
+
|
|
9
|
+
Redistribution and use in source and binary forms, with or without
|
|
10
|
+
modification, are permitted provided that the following conditions
|
|
11
|
+
are met:
|
|
12
|
+
|
|
13
|
+
1. Redistributions of source code must retain the above copyright
|
|
14
|
+
notice, this list of conditions and the following disclaimer.
|
|
15
|
+
|
|
16
|
+
2. Redistributions in binary form must reproduce the above copyright
|
|
17
|
+
notice, this list of conditions and the following disclaimer in
|
|
18
|
+
the documentation and/or other materials provided with the
|
|
19
|
+
distribution.
|
|
20
|
+
|
|
21
|
+
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
|
22
|
+
"AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
|
23
|
+
LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
|
24
|
+
FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
|
25
|
+
COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
|
26
|
+
INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
|
27
|
+
BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
|
|
28
|
+
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
|
|
29
|
+
CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
30
|
+
LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
|
31
|
+
ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
|
32
|
+
POSSIBILITY OF SUCH DAMAGE.
|
|
33
|
+
*/
|
|
34
|
+
|
|
35
|
+
:- module(url,
|
|
36
|
+
[ parse_url/2, % +URL, -Parts | -URL +Parts
|
|
37
|
+
parse_url/3, % +URL|URI, +BaseURL, -Parts
|
|
38
|
+
% -URL, +BaseURL, +Parts
|
|
39
|
+
is_absolute_url/1, % +URL
|
|
40
|
+
global_url/3, % +Local, +Base, -Global
|
|
41
|
+
http_location/2, % ?Parts, ?Location
|
|
42
|
+
www_form_encode/2, % Value <-> Encoded
|
|
43
|
+
parse_url_search/2, % Form-data <-> Form fields
|
|
44
|
+
|
|
45
|
+
url_iri/2, % ?URL, ?IRI
|
|
46
|
+
|
|
47
|
+
file_name_to_url/2, % ?FileName, ?URL
|
|
48
|
+
|
|
49
|
+
set_url_encoding/2 % ?Old, +New
|
|
50
|
+
]).
|
|
51
|
+
:- autoload(library(error),[must_be/2,representation_error/1]).
|
|
52
|
+
:- autoload(library(lists),[append/3,select/3,delete/3]).
|
|
53
|
+
:- autoload(library(utf8),[utf8_codes/3]).
|
|
54
|
+
|
|
55
|
+
|
|
56
|
+
/** <module> Analysing and constructing URL
|
|
57
|
+
|
|
58
|
+
This library deals with the analysis and construction of a URL,
|
|
59
|
+
Universal Resource Locator. URL is the basis for communicating locations
|
|
60
|
+
of resources (data) on the web. A URL consists of a protocol identifier
|
|
61
|
+
(e.g. HTTP, FTP, and a protocol-specific syntax further defining the
|
|
62
|
+
location. URLs are standardized in RFC-1738.
|
|
63
|
+
|
|
64
|
+
The implementation in this library covers only a small portion of the
|
|
65
|
+
defined protocols. Though the initial implementation followed RFC-1738
|
|
66
|
+
strictly, the current is more relaxed to deal with frequent violations
|
|
67
|
+
of the standard encountered in practical use.
|
|
68
|
+
|
|
69
|
+
@author Jan Wielemaker
|
|
70
|
+
@author Lukas Faulstich
|
|
71
|
+
@deprecated New code should use library(uri), provided by the =clib=
|
|
72
|
+
package.
|
|
73
|
+
*/
|
|
74
|
+
|
|
75
|
+
/*******************************
|
|
76
|
+
* GLOBALISE *
|
|
77
|
+
*******************************/
|
|
78
|
+
|
|
79
|
+
%! global_url(+URL, +Base, -Global) is det.
|
|
80
|
+
%
|
|
81
|
+
% Translate a possibly relative URL into an absolute one.
|
|
82
|
+
%
|
|
83
|
+
% @error syntax_error(illegal_url) if URL is not legal.
|
|
84
|
+
|
|
85
|
+
global_url(URL, BaseURL, Global) :-
|
|
86
|
+
( is_absolute_url(URL),
|
|
87
|
+
\+ sub_atom(URL, _, _, _, '%') % may have escape, use general
|
|
88
|
+
-> Global = URL
|
|
89
|
+
; sub_atom(URL, 0, _, _, '//')
|
|
90
|
+
-> parse_url(BaseURL, [], Attributes),
|
|
91
|
+
memberchk(protocol(Proto), Attributes),
|
|
92
|
+
atomic_list_concat([Proto, :, URL], Global)
|
|
93
|
+
; sub_atom(URL, 0, _, _, #)
|
|
94
|
+
-> ( sub_atom(BaseURL, _, _, 0, #)
|
|
95
|
+
-> sub_atom(URL, 1, _, 0, NoHash),
|
|
96
|
+
atom_concat(BaseURL, NoHash, Global)
|
|
97
|
+
; atom_concat(BaseURL, URL, Global)
|
|
98
|
+
)
|
|
99
|
+
; parse_url(URL, BaseURL, Attributes)
|
|
100
|
+
-> phrase(curl(Attributes), Chars),
|
|
101
|
+
atom_codes(Global, Chars)
|
|
102
|
+
; throw(error(syntax_error(illegal_url), URL))
|
|
103
|
+
).
|
|
104
|
+
|
|
105
|
+
%! is_absolute_url(+URL)
|
|
106
|
+
%
|
|
107
|
+
% True if URL is an absolute URL. That is, a URL that starts with
|
|
108
|
+
% a protocol identifier.
|
|
109
|
+
|
|
110
|
+
is_absolute_url(URL) :-
|
|
111
|
+
sub_atom(URL, 0, _, _, 'http://'),
|
|
112
|
+
!.
|
|
113
|
+
is_absolute_url(URL) :-
|
|
114
|
+
sub_atom(URL, 0, _, _, 'https://'),
|
|
115
|
+
!.
|
|
116
|
+
is_absolute_url(URL) :-
|
|
117
|
+
sub_atom(URL, 0, _, _, 'ftp://'),
|
|
118
|
+
!.
|
|
119
|
+
is_absolute_url(URL) :-
|
|
120
|
+
sub_atom(URL, 0, _, _, 'file://'),
|
|
121
|
+
!.
|
|
122
|
+
is_absolute_url(URL) :-
|
|
123
|
+
atom_codes(URL, Codes),
|
|
124
|
+
phrase(absolute_url, Codes, _),
|
|
125
|
+
!.
|
|
126
|
+
|
|
127
|
+
|
|
128
|
+
/*******************************
|
|
129
|
+
* CREATE URL/URI *
|
|
130
|
+
*******************************/
|
|
131
|
+
|
|
132
|
+
%! http_location(?Parts, ?Location)
|
|
133
|
+
%
|
|
134
|
+
% Construct or analyze an HTTP location. This is similar to
|
|
135
|
+
% parse_url/2, but only deals with the location part of an HTTP
|
|
136
|
+
% URL. That is, the path, search and fragment specifiers. In the
|
|
137
|
+
% HTTP protocol, the first line of a message is
|
|
138
|
+
%
|
|
139
|
+
% ==
|
|
140
|
+
% <Action> <Location> HTTP/<version>
|
|
141
|
+
% ==
|
|
142
|
+
%
|
|
143
|
+
% @param Location Atom or list of character codes.
|
|
144
|
+
|
|
145
|
+
http_location(Parts, Location) :- % Parts --> Location
|
|
146
|
+
nonvar(Parts),
|
|
147
|
+
!,
|
|
148
|
+
phrase(curi(Parts), String),
|
|
149
|
+
!,
|
|
150
|
+
atom_codes(Location, String).
|
|
151
|
+
http_location(Parts, Location) :- % Location --> Parts
|
|
152
|
+
atom(Location),
|
|
153
|
+
!,
|
|
154
|
+
atom_codes(Location, Codes),
|
|
155
|
+
phrase(http_location(Parts), Codes).
|
|
156
|
+
http_location(Parts, Codes) :- % LocationCodes --> Parts
|
|
157
|
+
is_list(Codes),
|
|
158
|
+
phrase(http_location(Parts), Codes).
|
|
159
|
+
|
|
160
|
+
|
|
161
|
+
curl(A) -->
|
|
162
|
+
{ memberchk(protocol(Protocol), A)
|
|
163
|
+
},
|
|
164
|
+
!,
|
|
165
|
+
catomic(Protocol),
|
|
166
|
+
":",
|
|
167
|
+
curl(Protocol, A).
|
|
168
|
+
curl(A) -->
|
|
169
|
+
curl(http, A).
|
|
170
|
+
|
|
171
|
+
curl(file, A) -->
|
|
172
|
+
!,
|
|
173
|
+
( "//"
|
|
174
|
+
-> cpath(A)
|
|
175
|
+
; cpath(A)
|
|
176
|
+
).
|
|
177
|
+
curl(_, A) -->
|
|
178
|
+
"//",
|
|
179
|
+
cuser(A),
|
|
180
|
+
chost(A),
|
|
181
|
+
cport(A),
|
|
182
|
+
cpath(A),
|
|
183
|
+
csearch(A),
|
|
184
|
+
cfragment(A).
|
|
185
|
+
|
|
186
|
+
curi(A) -->
|
|
187
|
+
cpath(A),
|
|
188
|
+
csearch(A).
|
|
189
|
+
|
|
190
|
+
cpath(A) -->
|
|
191
|
+
( { memberchk(path(Path), A) }
|
|
192
|
+
-> { atom_codes(Path, Codes) },
|
|
193
|
+
www_encode(Codes, [0'/, 0'+, 0':, 0',])
|
|
194
|
+
; ""
|
|
195
|
+
).
|
|
196
|
+
|
|
197
|
+
cuser(A) -->
|
|
198
|
+
( { memberchk(user(User), A) }
|
|
199
|
+
-> { atom_codes(User, Codes) },
|
|
200
|
+
www_encode(Codes, [0':]),
|
|
201
|
+
"@"
|
|
202
|
+
; ""
|
|
203
|
+
).
|
|
204
|
+
|
|
205
|
+
chost(A) -->
|
|
206
|
+
( { memberchk(host(Host), A) }
|
|
207
|
+
-> { atom_codes(Host, Codes) },
|
|
208
|
+
www_encode(Codes, [])
|
|
209
|
+
; ""
|
|
210
|
+
).
|
|
211
|
+
|
|
212
|
+
cport(A) -->
|
|
213
|
+
( { memberchk(port(Port), A), Port \== 80 }
|
|
214
|
+
-> { number_codes(Port, Codes) },
|
|
215
|
+
":",
|
|
216
|
+
www_encode(Codes, [])
|
|
217
|
+
; ""
|
|
218
|
+
).
|
|
219
|
+
|
|
220
|
+
|
|
221
|
+
catomic(A, In, Out) :-
|
|
222
|
+
atom_codes(A, Codes),
|
|
223
|
+
append(Codes, Out, In).
|
|
224
|
+
|
|
225
|
+
%! csearch(+Attributes)//
|
|
226
|
+
|
|
227
|
+
csearch(A)-->
|
|
228
|
+
( { memberchk(search(Parameters), A) }
|
|
229
|
+
-> csearch(Parameters, [0'?])
|
|
230
|
+
; []
|
|
231
|
+
).
|
|
232
|
+
|
|
233
|
+
csearch([], _) -->
|
|
234
|
+
[].
|
|
235
|
+
csearch([Parameter|Parameters], Sep) -->
|
|
236
|
+
!,
|
|
237
|
+
codes(Sep),
|
|
238
|
+
cparam(Parameter),
|
|
239
|
+
csearch(Parameters, [0'&]).
|
|
240
|
+
|
|
241
|
+
cparam(Name=Value) -->
|
|
242
|
+
!,
|
|
243
|
+
cname(Name),
|
|
244
|
+
"=",
|
|
245
|
+
cvalue(Value).
|
|
246
|
+
cparam(NameValue) --> % allow to feed Name(Value)
|
|
247
|
+
{ compound(NameValue),
|
|
248
|
+
!,
|
|
249
|
+
NameValue =.. [Name,Value]
|
|
250
|
+
},
|
|
251
|
+
cname(Name),
|
|
252
|
+
"=",
|
|
253
|
+
cvalue(Value).
|
|
254
|
+
cparam(Name)-->
|
|
255
|
+
cname(Name).
|
|
256
|
+
|
|
257
|
+
codes([]) --> [].
|
|
258
|
+
codes([H|T]) --> [H], codes(T).
|
|
259
|
+
|
|
260
|
+
cname(Atom) -->
|
|
261
|
+
{ atom_codes(Atom, Codes) },
|
|
262
|
+
www_encode(Codes, []).
|
|
263
|
+
|
|
264
|
+
%! cvalue(+Value)// is det.
|
|
265
|
+
%
|
|
266
|
+
% Construct a string from Value. Value is either atomic or a
|
|
267
|
+
% code-list.
|
|
268
|
+
|
|
269
|
+
cvalue(Value) -->
|
|
270
|
+
{ atomic(Value),
|
|
271
|
+
!,
|
|
272
|
+
atom_codes(Value, Codes)
|
|
273
|
+
},
|
|
274
|
+
www_encode(Codes, []).
|
|
275
|
+
cvalue(Codes) -->
|
|
276
|
+
{ must_be(codes, Codes)
|
|
277
|
+
},
|
|
278
|
+
www_encode(Codes, []).
|
|
279
|
+
|
|
280
|
+
|
|
281
|
+
%! cfragment(+Attributes)//
|
|
282
|
+
|
|
283
|
+
cfragment(A) -->
|
|
284
|
+
{ memberchk(fragment(Frag), A),
|
|
285
|
+
!,
|
|
286
|
+
atom_codes(Frag, Codes)
|
|
287
|
+
},
|
|
288
|
+
"#",
|
|
289
|
+
www_encode(Codes, []).
|
|
290
|
+
cfragment(_) -->
|
|
291
|
+
"".
|
|
292
|
+
|
|
293
|
+
|
|
294
|
+
/*******************************
|
|
295
|
+
* PARSING *
|
|
296
|
+
*******************************/
|
|
297
|
+
|
|
298
|
+
%! parse_url(?URL, ?Attributes) is det.
|
|
299
|
+
%
|
|
300
|
+
% Construct or analyse a URL. URL is an atom holding a URL or a
|
|
301
|
+
% variable. Attributes is a list of components. Each component is
|
|
302
|
+
% of the format Name(Value). Defined components are:
|
|
303
|
+
%
|
|
304
|
+
% * protocol(Protocol)
|
|
305
|
+
% The used protocol. This is, after the optional =|url:|=, an
|
|
306
|
+
% identifier separated from the remainder of the URL using :.
|
|
307
|
+
% parse_url/2 assumes the =http= protocol if no protocol is
|
|
308
|
+
% specified and the URL can be parsed as a valid HTTP url. In
|
|
309
|
+
% addition to the RFC-1738 specified protocols, the =file=
|
|
310
|
+
% protocol is supported as well.
|
|
311
|
+
%
|
|
312
|
+
% * host(Host)
|
|
313
|
+
% Host-name or IP-address on which the resource is located.
|
|
314
|
+
% Supported by all network-based protocols.
|
|
315
|
+
%
|
|
316
|
+
% * port(Port)
|
|
317
|
+
% Integer port-number to access on the \arg{Host}. This only
|
|
318
|
+
% appears if the port is explicitly specified in the URL.
|
|
319
|
+
% Implicit default ports (e.g., 80 for HTTP) do _not_ appear
|
|
320
|
+
% in the part-list.
|
|
321
|
+
%
|
|
322
|
+
% * path(Path)
|
|
323
|
+
% (File-) path addressed by the URL. This is supported for the
|
|
324
|
+
% =ftp=, =http= and =file= protocols. If no path appears, the
|
|
325
|
+
% library generates the path =|/|=.
|
|
326
|
+
%
|
|
327
|
+
% * search(ListOfNameValue)
|
|
328
|
+
% Search-specification of HTTP URL. This is the part after the
|
|
329
|
+
% =|?|=, normally used to transfer data from HTML forms that
|
|
330
|
+
% use the HTTP GET method. In the URL it consists of a
|
|
331
|
+
% www-form-encoded list of Name=Value pairs. This is mapped to
|
|
332
|
+
% a list of Prolog Name=Value terms with decoded names and
|
|
333
|
+
% values.
|
|
334
|
+
%
|
|
335
|
+
% * fragment(Fragment)
|
|
336
|
+
% Fragment specification of HTTP URL. This is the part after
|
|
337
|
+
% the =|#|= character.
|
|
338
|
+
%
|
|
339
|
+
% The example below illustrates all of this for an HTTP URL.
|
|
340
|
+
%
|
|
341
|
+
% ==
|
|
342
|
+
% ?- parse_url('http://www.xyz.org/hello?msg=Hello+World%21#x',
|
|
343
|
+
% P).
|
|
344
|
+
%
|
|
345
|
+
% P = [ protocol(http),
|
|
346
|
+
% host('www.xyz.org'),
|
|
347
|
+
% fragment(x),
|
|
348
|
+
% search([ msg = 'Hello World!'
|
|
349
|
+
% ]),
|
|
350
|
+
% path('/hello')
|
|
351
|
+
% ]
|
|
352
|
+
% ==
|
|
353
|
+
%
|
|
354
|
+
% By instantiating the parts-list this predicate can be used to
|
|
355
|
+
% create a URL.
|
|
356
|
+
|
|
357
|
+
parse_url(URL, Attributes) :-
|
|
358
|
+
nonvar(URL),
|
|
359
|
+
!,
|
|
360
|
+
atom_codes(URL, Codes),
|
|
361
|
+
phrase(url(Attributes), Codes).
|
|
362
|
+
parse_url(URL, Attributes) :-
|
|
363
|
+
phrase(curl(Attributes), Codes),
|
|
364
|
+
!,
|
|
365
|
+
atom_codes(URL, Codes).
|
|
366
|
+
|
|
367
|
+
%! parse_url(+URL, +BaseURL, -Attributes) is det.
|
|
368
|
+
%
|
|
369
|
+
% Similar to parse_url/2 for relative URLs. If URL is relative,
|
|
370
|
+
% it is resolved using the absolute URL BaseURL.
|
|
371
|
+
|
|
372
|
+
parse_url(URL, BaseURL, Attributes) :-
|
|
373
|
+
nonvar(URL),
|
|
374
|
+
!,
|
|
375
|
+
atom_codes(URL, Codes),
|
|
376
|
+
( phrase(absolute_url, Codes, _)
|
|
377
|
+
-> phrase(url(Attributes), Codes)
|
|
378
|
+
; ( atomic(BaseURL)
|
|
379
|
+
-> parse_url(BaseURL, BaseA0)
|
|
380
|
+
; BaseA0 = BaseURL
|
|
381
|
+
),
|
|
382
|
+
select(path(BasePath), BaseA0, BaseA1),
|
|
383
|
+
delete(BaseA1, search(_), BaseA2),
|
|
384
|
+
delete(BaseA2, fragment(_), BaseA3),
|
|
385
|
+
phrase(relative_uri(URIA0), Codes),
|
|
386
|
+
select(path(LocalPath), URIA0, URIA1),
|
|
387
|
+
!,
|
|
388
|
+
globalise_path(LocalPath, BasePath, Path),
|
|
389
|
+
append(BaseA3, [path(Path)|URIA1], Attributes)
|
|
390
|
+
).
|
|
391
|
+
parse_url(URL, BaseURL, Attributes) :-
|
|
392
|
+
parse_url(BaseURL, BaseAttributes),
|
|
393
|
+
memberchk(path(BasePath), BaseAttributes),
|
|
394
|
+
( memberchk(path(LocalPath), Attributes)
|
|
395
|
+
-> globalise_path(LocalPath, BasePath, Path)
|
|
396
|
+
; Path = BasePath
|
|
397
|
+
),
|
|
398
|
+
append([path(Path)|Attributes], BaseAttributes, GlobalAttributes),
|
|
399
|
+
phrase(curl(GlobalAttributes), Chars),
|
|
400
|
+
atom_codes(URL, Chars).
|
|
401
|
+
|
|
402
|
+
|
|
403
|
+
%! globalise_path(+LocalPath, +RelativeTo, -FullPath) is det.
|
|
404
|
+
%
|
|
405
|
+
% The first clause deals with the standard URL /... global paths.
|
|
406
|
+
% The second with file://drive:path on MS-Windows. This is a bit
|
|
407
|
+
% of a cludge, but unfortunately common practice is -especially on
|
|
408
|
+
% Windows- not always following the standard
|
|
409
|
+
|
|
410
|
+
globalise_path(LocalPath, _, LocalPath) :-
|
|
411
|
+
sub_atom(LocalPath, 0, _, _, /),
|
|
412
|
+
!.
|
|
413
|
+
globalise_path(LocalPath, _, LocalPath) :-
|
|
414
|
+
is_absolute_file_name(LocalPath),
|
|
415
|
+
!.
|
|
416
|
+
globalise_path(Local, Base, Path) :-
|
|
417
|
+
base_dir(Base, BaseDir),
|
|
418
|
+
make_path(BaseDir, Local, Path).
|
|
419
|
+
|
|
420
|
+
base_dir(BasePath, BaseDir) :-
|
|
421
|
+
( atom_concat(BaseDir, /, BasePath)
|
|
422
|
+
-> true
|
|
423
|
+
; file_directory_name(BasePath, BaseDir)
|
|
424
|
+
).
|
|
425
|
+
|
|
426
|
+
make_path(Dir, Local, Path) :-
|
|
427
|
+
atom_concat('../', L2, Local),
|
|
428
|
+
file_directory_name(Dir, Parent),
|
|
429
|
+
Parent \== Dir,
|
|
430
|
+
!,
|
|
431
|
+
make_path(Parent, L2, Path).
|
|
432
|
+
make_path(/, Local, Path) :-
|
|
433
|
+
!,
|
|
434
|
+
atom_concat(/, Local, Path).
|
|
435
|
+
make_path(Dir, Local, Path) :-
|
|
436
|
+
atomic_list_concat([Dir, /, Local], Path).
|
|
437
|
+
|
|
438
|
+
|
|
439
|
+
%! absolute_url//
|
|
440
|
+
%
|
|
441
|
+
% True if the input describes an absolute URL. This means it
|
|
442
|
+
% starts with a URL schema. We demand a schema of length > 1 to
|
|
443
|
+
% avoid confusion with Windows drive letters.
|
|
444
|
+
|
|
445
|
+
absolute_url -->
|
|
446
|
+
lwalpha(_First),
|
|
447
|
+
schema_chars(Rest),
|
|
448
|
+
{ Rest \== [] },
|
|
449
|
+
":",
|
|
450
|
+
!.
|
|
451
|
+
|
|
452
|
+
|
|
453
|
+
/*******************************
|
|
454
|
+
* SEQUENCES *
|
|
455
|
+
*******************************/
|
|
456
|
+
|
|
457
|
+
digits(L) -->
|
|
458
|
+
digits(L, []).
|
|
459
|
+
|
|
460
|
+
digits([C|T0], T) -->
|
|
461
|
+
digit(C),
|
|
462
|
+
!,
|
|
463
|
+
digits(T0, T).
|
|
464
|
+
digits(T, T) -->
|
|
465
|
+
[].
|
|
466
|
+
|
|
467
|
+
|
|
468
|
+
digit(C, [C|T], T) :- code_type(C, digit).
|
|
469
|
+
|
|
470
|
+
/*******************************
|
|
471
|
+
* RFC-3986 *
|
|
472
|
+
*******************************/
|
|
473
|
+
|
|
474
|
+
%! uri(-Parts)//
|
|
475
|
+
|
|
476
|
+
url([protocol(Schema)|Parts]) -->
|
|
477
|
+
schema(Schema),
|
|
478
|
+
":",
|
|
479
|
+
!,
|
|
480
|
+
hier_part(Schema, Parts, P2),
|
|
481
|
+
query(P2, P3),
|
|
482
|
+
fragment(P3, []).
|
|
483
|
+
url([protocol(http)|Parts]) --> % implicit HTTP
|
|
484
|
+
authority(Parts, [path(Path)]),
|
|
485
|
+
path_abempty(Path).
|
|
486
|
+
|
|
487
|
+
relative_uri(Parts) -->
|
|
488
|
+
relative_part(Parts, P2),
|
|
489
|
+
query(P2, P3),
|
|
490
|
+
fragment(P3, []).
|
|
491
|
+
|
|
492
|
+
relative_part(Parts, Tail) -->
|
|
493
|
+
"//",
|
|
494
|
+
!,
|
|
495
|
+
authority(Parts, [path(Path)|Tail]),
|
|
496
|
+
path_abempty(Path).
|
|
497
|
+
relative_part([path(Path)|T], T) -->
|
|
498
|
+
( path_absolute(Path)
|
|
499
|
+
; path_noschema(Path)
|
|
500
|
+
; path_empty(Path)
|
|
501
|
+
),
|
|
502
|
+
!.
|
|
503
|
+
|
|
504
|
+
http_location([path(Path)|P2]) -->
|
|
505
|
+
path_abempty(Path),
|
|
506
|
+
query(P2, P3),
|
|
507
|
+
fragment(P3, []).
|
|
508
|
+
|
|
509
|
+
%! schema(-Atom)//
|
|
510
|
+
%
|
|
511
|
+
% Schema is case-insensitive and the canonical version is
|
|
512
|
+
% lowercase.
|
|
513
|
+
%
|
|
514
|
+
% ==
|
|
515
|
+
% Schema ::= ALPHA *(ALPHA|DIGIT|"+"|"-"|".")
|
|
516
|
+
% ==
|
|
517
|
+
|
|
518
|
+
schema(Schema) -->
|
|
519
|
+
lwalpha(C0),
|
|
520
|
+
schema_chars(Codes),
|
|
521
|
+
{ atom_codes(Schema, [C0|Codes]) }.
|
|
522
|
+
|
|
523
|
+
schema_chars([H|T]) -->
|
|
524
|
+
schema_char(H),
|
|
525
|
+
!,
|
|
526
|
+
schema_chars(T).
|
|
527
|
+
schema_chars([]) -->
|
|
528
|
+
[].
|
|
529
|
+
|
|
530
|
+
schema_char(H) -->
|
|
531
|
+
[C],
|
|
532
|
+
{ C < 128,
|
|
533
|
+
( code_type(C, alpha)
|
|
534
|
+
-> code_type(H, to_lower(C))
|
|
535
|
+
; code_type(C, digit)
|
|
536
|
+
-> H = C
|
|
537
|
+
; schema_extra(C)
|
|
538
|
+
-> H = C
|
|
539
|
+
)
|
|
540
|
+
}.
|
|
541
|
+
|
|
542
|
+
schema_extra(0'+).
|
|
543
|
+
schema_extra(0'-).
|
|
544
|
+
schema_extra(0'.). % 0'
|
|
545
|
+
|
|
546
|
+
|
|
547
|
+
%! hier_part(+Schema, -Parts, ?Tail)//
|
|
548
|
+
|
|
549
|
+
hier_part(file, [path(Path)|Tail], Tail) -->
|
|
550
|
+
!,
|
|
551
|
+
"//",
|
|
552
|
+
( win_drive_path(Path)
|
|
553
|
+
; path_absolute(Path)
|
|
554
|
+
; path_rootless(Path)
|
|
555
|
+
; path_empty(Path)
|
|
556
|
+
),
|
|
557
|
+
!.
|
|
558
|
+
hier_part(_, Parts, Tail) -->
|
|
559
|
+
"//",
|
|
560
|
+
!,
|
|
561
|
+
authority(Parts, [path(Path)|Tail]),
|
|
562
|
+
path_abempty(Path).
|
|
563
|
+
hier_part(_, [path(Path)|T], T) -->
|
|
564
|
+
( path_absolute(Path)
|
|
565
|
+
; path_rootless(Path)
|
|
566
|
+
; path_empty(Path)
|
|
567
|
+
),
|
|
568
|
+
!.
|
|
569
|
+
|
|
570
|
+
authority(Parts, Tail) -->
|
|
571
|
+
user_info_chars(UserChars),
|
|
572
|
+
"@",
|
|
573
|
+
!,
|
|
574
|
+
{ atom_codes(User, UserChars),
|
|
575
|
+
Parts = [user(User),host(Host)|T0]
|
|
576
|
+
},
|
|
577
|
+
host(Host),
|
|
578
|
+
port(T0,Tail).
|
|
579
|
+
authority([host(Host)|T0], Tail) -->
|
|
580
|
+
host(Host),
|
|
581
|
+
port(T0, Tail).
|
|
582
|
+
|
|
583
|
+
user_info_chars([H|T]) -->
|
|
584
|
+
user_info_char(H),
|
|
585
|
+
!,
|
|
586
|
+
user_info_chars(T).
|
|
587
|
+
user_info_chars([]) -->
|
|
588
|
+
[].
|
|
589
|
+
|
|
590
|
+
user_info_char(_) --> "@", !, {fail}.
|
|
591
|
+
user_info_char(C) --> pchar(C).
|
|
592
|
+
|
|
593
|
+
%host(Host) --> ip_literal(Host), !. % TBD: IP6 addresses
|
|
594
|
+
host(Host) --> ip4_address(Host), !.
|
|
595
|
+
host(Host) --> reg_name(Host).
|
|
596
|
+
|
|
597
|
+
ip4_address(Atom) -->
|
|
598
|
+
i256_chars(Chars, [0'.|T0]),
|
|
599
|
+
i256_chars(T0, [0'.|T1]),
|
|
600
|
+
i256_chars(T1, [0'.|T2]),
|
|
601
|
+
i256_chars(T2, []),
|
|
602
|
+
{ atom_codes(Atom, Chars) }.
|
|
603
|
+
|
|
604
|
+
i256_chars(Chars, T) -->
|
|
605
|
+
digits(Chars, T),
|
|
606
|
+
{ \+ \+ ( T = [],
|
|
607
|
+
Chars \== [],
|
|
608
|
+
number_codes(I, Chars),
|
|
609
|
+
I < 256
|
|
610
|
+
)
|
|
611
|
+
}.
|
|
612
|
+
|
|
613
|
+
reg_name(Host) -->
|
|
614
|
+
reg_name_chars(Chars),
|
|
615
|
+
{ atom_codes(Host, Chars) }.
|
|
616
|
+
|
|
617
|
+
reg_name_chars([H|T]) -->
|
|
618
|
+
reg_name_char(H),
|
|
619
|
+
!,
|
|
620
|
+
reg_name_chars(T).
|
|
621
|
+
reg_name_chars([]) -->
|
|
622
|
+
[].
|
|
623
|
+
|
|
624
|
+
reg_name_char(C) -->
|
|
625
|
+
pchar(C),
|
|
626
|
+
{ C \== 0':,
|
|
627
|
+
C \== 0'@
|
|
628
|
+
}.
|
|
629
|
+
|
|
630
|
+
port([port(Port)|T], T) -->
|
|
631
|
+
":",
|
|
632
|
+
!,
|
|
633
|
+
digit(D0),
|
|
634
|
+
digits(Ds),
|
|
635
|
+
{ number_codes(Port, [D0|Ds]) }.
|
|
636
|
+
port(T, T) -->
|
|
637
|
+
[].
|
|
638
|
+
|
|
639
|
+
path_abempty(Path) -->
|
|
640
|
+
segments_chars(Chars, []),
|
|
641
|
+
{ Chars == []
|
|
642
|
+
-> Path = '/'
|
|
643
|
+
; atom_codes(Path, Chars)
|
|
644
|
+
}.
|
|
645
|
+
|
|
646
|
+
|
|
647
|
+
win_drive_path(Path) -->
|
|
648
|
+
drive_letter(C0),
|
|
649
|
+
":",
|
|
650
|
+
( "/"
|
|
651
|
+
-> {Codes = [C0, 0':, 0'/|Chars]}
|
|
652
|
+
; {Codes = [C0, 0':|Chars]}
|
|
653
|
+
),
|
|
654
|
+
segment_nz_chars(Chars, T0),
|
|
655
|
+
segments_chars(T0, []),
|
|
656
|
+
{ atom_codes(Path, Codes) }.
|
|
657
|
+
|
|
658
|
+
|
|
659
|
+
path_absolute(Path) -->
|
|
660
|
+
"/",
|
|
661
|
+
segment_nz_chars(Chars, T0),
|
|
662
|
+
segments_chars(T0, []),
|
|
663
|
+
{ atom_codes(Path, [0'/| Chars]) }.
|
|
664
|
+
|
|
665
|
+
path_noschema(Path) -->
|
|
666
|
+
segment_nz_nc_chars(Chars, T0),
|
|
667
|
+
segments_chars(T0, []),
|
|
668
|
+
{ atom_codes(Path, Chars) }.
|
|
669
|
+
|
|
670
|
+
path_rootless(Path) -->
|
|
671
|
+
segment_nz_chars(Chars, T0),
|
|
672
|
+
segments_chars(T0, []),
|
|
673
|
+
{ atom_codes(Path, Chars) }.
|
|
674
|
+
|
|
675
|
+
path_empty('/') -->
|
|
676
|
+
"".
|
|
677
|
+
|
|
678
|
+
segments_chars([0'/|Chars], T) --> % 0'
|
|
679
|
+
"/",
|
|
680
|
+
!,
|
|
681
|
+
segment_chars(Chars, T0),
|
|
682
|
+
segments_chars(T0, T).
|
|
683
|
+
segments_chars(T, T) -->
|
|
684
|
+
[].
|
|
685
|
+
|
|
686
|
+
segment_chars([H|T0], T) -->
|
|
687
|
+
pchar(H),
|
|
688
|
+
!,
|
|
689
|
+
segment_chars(T0, T).
|
|
690
|
+
segment_chars(T, T) -->
|
|
691
|
+
[].
|
|
692
|
+
|
|
693
|
+
segment_nz_chars([H|T0], T) -->
|
|
694
|
+
pchar(H),
|
|
695
|
+
segment_chars(T0, T).
|
|
696
|
+
|
|
697
|
+
segment_nz_nc_chars([H|T0], T) -->
|
|
698
|
+
segment_nz_nc_char(H),
|
|
699
|
+
!,
|
|
700
|
+
segment_nz_nc_chars(T0, T).
|
|
701
|
+
segment_nz_nc_chars(T, T) -->
|
|
702
|
+
[].
|
|
703
|
+
|
|
704
|
+
segment_nz_nc_char(_) --> ":", !, {fail}.
|
|
705
|
+
segment_nz_nc_char(C) --> pchar(C).
|
|
706
|
+
|
|
707
|
+
|
|
708
|
+
%! query(-Parts, ?Tail)// is det.
|
|
709
|
+
%
|
|
710
|
+
% Extract &Name=Value, ...
|
|
711
|
+
|
|
712
|
+
query([search(Params)|T], T) -->
|
|
713
|
+
"?",
|
|
714
|
+
!,
|
|
715
|
+
search(Params).
|
|
716
|
+
query(T,T) -->
|
|
717
|
+
[].
|
|
718
|
+
|
|
719
|
+
search([Parameter|Parameters])-->
|
|
720
|
+
parameter(Parameter),
|
|
721
|
+
!,
|
|
722
|
+
( search_sep
|
|
723
|
+
-> search(Parameters)
|
|
724
|
+
; { Parameters = [] }
|
|
725
|
+
).
|
|
726
|
+
search([]) -->
|
|
727
|
+
[].
|
|
728
|
+
|
|
729
|
+
parameter(Param)-->
|
|
730
|
+
!,
|
|
731
|
+
search_chars(NameS),
|
|
732
|
+
{ atom_codes(Name, NameS)
|
|
733
|
+
},
|
|
734
|
+
( "="
|
|
735
|
+
-> search_value_chars(ValueS),
|
|
736
|
+
{ atom_codes(Value, ValueS),
|
|
737
|
+
Param = (Name = Value)
|
|
738
|
+
}
|
|
739
|
+
; { Param = Name
|
|
740
|
+
}
|
|
741
|
+
).
|
|
742
|
+
|
|
743
|
+
search_chars([C|T]) -->
|
|
744
|
+
search_char(C),
|
|
745
|
+
!,
|
|
746
|
+
search_chars(T).
|
|
747
|
+
search_chars([]) -->
|
|
748
|
+
[].
|
|
749
|
+
|
|
750
|
+
search_char(_) --> search_sep, !, { fail }.
|
|
751
|
+
search_char(_) --> "=", !, { fail }.
|
|
752
|
+
search_char(C) --> fragment_char(C).
|
|
753
|
+
|
|
754
|
+
search_value_chars([C|T]) -->
|
|
755
|
+
search_value_char(C),
|
|
756
|
+
!,
|
|
757
|
+
search_value_chars(T).
|
|
758
|
+
search_value_chars([]) -->
|
|
759
|
+
[].
|
|
760
|
+
|
|
761
|
+
search_value_char(_) --> search_sep, !, { fail }.
|
|
762
|
+
search_value_char(C) --> fragment_char(C).
|
|
763
|
+
|
|
764
|
+
%! search_sep// is semidet.
|
|
765
|
+
%
|
|
766
|
+
% Matches a search-parameter separator. Traditionally, this is the
|
|
767
|
+
% &-char, but these days there are `newstyle' ;-char separators.
|
|
768
|
+
%
|
|
769
|
+
% @see http://perldoc.perl.org/CGI.html
|
|
770
|
+
% @tbd This should be configurable
|
|
771
|
+
|
|
772
|
+
search_sep --> "&", !.
|
|
773
|
+
search_sep --> ";".
|
|
774
|
+
|
|
775
|
+
|
|
776
|
+
%! fragment(-Fragment, ?Tail)//
|
|
777
|
+
%
|
|
778
|
+
% Extract the fragment (after the =#=)
|
|
779
|
+
|
|
780
|
+
fragment([fragment(Fragment)|T], T) -->
|
|
781
|
+
"#",
|
|
782
|
+
!,
|
|
783
|
+
fragment_chars(Codes),
|
|
784
|
+
{ atom_codes(Fragment, Codes) }.
|
|
785
|
+
fragment(T, T) -->
|
|
786
|
+
[].
|
|
787
|
+
|
|
788
|
+
fragment_chars([H|T]) -->
|
|
789
|
+
fragment_char(H),
|
|
790
|
+
!,
|
|
791
|
+
fragment_chars(T).
|
|
792
|
+
fragment_chars([]) -->
|
|
793
|
+
[].
|
|
794
|
+
|
|
795
|
+
|
|
796
|
+
%! fragment_char(-Char)
|
|
797
|
+
%
|
|
798
|
+
% Find a fragment character.
|
|
799
|
+
|
|
800
|
+
fragment_char(C) --> pchar(C), !.
|
|
801
|
+
fragment_char(0'/) --> "/", !.
|
|
802
|
+
fragment_char(0'?) --> "?", !.
|
|
803
|
+
fragment_char(0'[) --> "[", !. % Not according RDF3986!
|
|
804
|
+
fragment_char(0']) --> "]", !.
|
|
805
|
+
|
|
806
|
+
|
|
807
|
+
/*******************************
|
|
808
|
+
* CHARACTER CLASSES *
|
|
809
|
+
*******************************/
|
|
810
|
+
|
|
811
|
+
%! pchar(-Code)//
|
|
812
|
+
%
|
|
813
|
+
% unreserved|pct_encoded|sub_delim|":"|"@"
|
|
814
|
+
%
|
|
815
|
+
% Performs UTF-8 decoding of percent encoded strings.
|
|
816
|
+
|
|
817
|
+
pchar(0'\s) --> "+", !.
|
|
818
|
+
pchar(C) -->
|
|
819
|
+
[C],
|
|
820
|
+
{ unreserved(C)
|
|
821
|
+
; sub_delim(C)
|
|
822
|
+
; C == 0':
|
|
823
|
+
; C == 0'@
|
|
824
|
+
},
|
|
825
|
+
!.
|
|
826
|
+
pchar(C) -->
|
|
827
|
+
percent_coded(C).
|
|
828
|
+
|
|
829
|
+
%! lwalpha(-C)//
|
|
830
|
+
%
|
|
831
|
+
% Demand alpha, return as lowercase
|
|
832
|
+
|
|
833
|
+
lwalpha(H) -->
|
|
834
|
+
[C],
|
|
835
|
+
{ C < 128,
|
|
836
|
+
code_type(C, alpha),
|
|
837
|
+
code_type(H, to_lower(C))
|
|
838
|
+
}.
|
|
839
|
+
|
|
840
|
+
drive_letter(C) -->
|
|
841
|
+
[C],
|
|
842
|
+
{ C < 128,
|
|
843
|
+
code_type(C, alpha)
|
|
844
|
+
}.
|
|
845
|
+
|
|
846
|
+
|
|
847
|
+
/*******************************
|
|
848
|
+
* RESERVED CHARACTERS *
|
|
849
|
+
*******************************/
|
|
850
|
+
|
|
851
|
+
%! sub_delim(?Code)
|
|
852
|
+
%
|
|
853
|
+
% Sub-delimiters
|
|
854
|
+
|
|
855
|
+
sub_delim(0'!).
|
|
856
|
+
sub_delim(0'$).
|
|
857
|
+
sub_delim(0'&).
|
|
858
|
+
sub_delim(0'').
|
|
859
|
+
sub_delim(0'().
|
|
860
|
+
sub_delim(0')).
|
|
861
|
+
sub_delim(0'*).
|
|
862
|
+
sub_delim(0'+).
|
|
863
|
+
sub_delim(0',).
|
|
864
|
+
sub_delim(0';).
|
|
865
|
+
sub_delim(0'=).
|
|
866
|
+
|
|
867
|
+
|
|
868
|
+
%! unreserved(+C)
|
|
869
|
+
%
|
|
870
|
+
% Characters that can be represented without percent escaping
|
|
871
|
+
% RFC 3986, section 2.3
|
|
872
|
+
|
|
873
|
+
term_expansion(unreserved(map), Clauses) :-
|
|
874
|
+
findall(unreserved(C), unreserved_(C), Clauses).
|
|
875
|
+
|
|
876
|
+
unreserved_(C) :-
|
|
877
|
+
between(1, 128, C),
|
|
878
|
+
code_type(C, alnum).
|
|
879
|
+
unreserved_(0'-).
|
|
880
|
+
unreserved_(0'.).
|
|
881
|
+
unreserved_(0'_).
|
|
882
|
+
unreserved_(0'~). % 0'
|
|
883
|
+
|
|
884
|
+
unreserved(map). % Expanded
|
|
885
|
+
|
|
886
|
+
|
|
887
|
+
/*******************************
|
|
888
|
+
* FORMS *
|
|
889
|
+
*******************************/
|
|
890
|
+
|
|
891
|
+
/* - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
|
|
892
|
+
Encoding/decoding of form-fields using the popular www-form-encoded
|
|
893
|
+
encoding used with the HTTP GET.
|
|
894
|
+
- - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - */
|
|
895
|
+
|
|
896
|
+
%! www_form_encode(+Value, -XWWWFormEncoded) is det.
|
|
897
|
+
%! www_form_encode(-Value, +XWWWFormEncoded) is det.
|
|
898
|
+
%
|
|
899
|
+
% En/decode to/from application/x-www-form-encoded. Encoding
|
|
900
|
+
% encodes all characters except RFC 3986 _unreserved_ (ASCII
|
|
901
|
+
% =alnum= (see code_type/2)), and one of "-._~" using percent
|
|
902
|
+
% encoding. Newline is mapped to =|%OD%OA|=. When decoding,
|
|
903
|
+
% newlines appear as a single newline (10) character.
|
|
904
|
+
%
|
|
905
|
+
% Note that a space is encoded as =|%20|= instead of =|+|=.
|
|
906
|
+
% Decoding decodes both to a space.
|
|
907
|
+
%
|
|
908
|
+
% @deprecated Use uri_encoded/3 for new code.
|
|
909
|
+
|
|
910
|
+
www_form_encode(Value, Encoded) :-
|
|
911
|
+
atomic(Value),
|
|
912
|
+
!,
|
|
913
|
+
atom_codes(Value, Codes),
|
|
914
|
+
phrase(www_encode(Codes, []), EncCodes),
|
|
915
|
+
atom_codes(Encoded, EncCodes).
|
|
916
|
+
www_form_encode(Value, Encoded) :-
|
|
917
|
+
atom_codes(Encoded, EncCodes),
|
|
918
|
+
phrase(www_decode(Codes), EncCodes),
|
|
919
|
+
atom_codes(Value, Codes).
|
|
920
|
+
|
|
921
|
+
%! www_encode(+Codes, +ExtraUnescaped)//
|
|
922
|
+
|
|
923
|
+
www_encode([0'\r, 0'\n|T], Extra) -->
|
|
924
|
+
!,
|
|
925
|
+
"%0D%0A",
|
|
926
|
+
www_encode(T, Extra).
|
|
927
|
+
www_encode([0'\n|T], Extra) -->
|
|
928
|
+
!,
|
|
929
|
+
"%0D%0A",
|
|
930
|
+
www_encode(T, Extra).
|
|
931
|
+
www_encode([H|T], Extra) -->
|
|
932
|
+
percent_encode(H, Extra),
|
|
933
|
+
www_encode(T, Extra).
|
|
934
|
+
www_encode([], _) -->
|
|
935
|
+
"".
|
|
936
|
+
|
|
937
|
+
percent_encode(C, _Extra) -->
|
|
938
|
+
{ unreserved(C) },
|
|
939
|
+
!,
|
|
940
|
+
[C].
|
|
941
|
+
percent_encode(C, Extra) -->
|
|
942
|
+
{ memberchk(C, Extra) },
|
|
943
|
+
!,
|
|
944
|
+
[C].
|
|
945
|
+
%percent_encode(0' , _) --> !, "+". % Deprecated: use %20
|
|
946
|
+
percent_encode(C, _) -->
|
|
947
|
+
{ C =< 127 },
|
|
948
|
+
!,
|
|
949
|
+
percent_byte(C).
|
|
950
|
+
percent_encode(C, _) --> % Unicode characters
|
|
951
|
+
{ current_prolog_flag(url_encoding, utf8),
|
|
952
|
+
!,
|
|
953
|
+
phrase(utf8_codes([C]), Bytes)
|
|
954
|
+
},
|
|
955
|
+
percent_bytes(Bytes).
|
|
956
|
+
percent_encode(C, _) -->
|
|
957
|
+
{ C =< 255 },
|
|
958
|
+
!,
|
|
959
|
+
percent_byte(C).
|
|
960
|
+
percent_encode(_C, _) -->
|
|
961
|
+
{ representation_error(url_character)
|
|
962
|
+
}.
|
|
963
|
+
|
|
964
|
+
percent_bytes([]) -->
|
|
965
|
+
"".
|
|
966
|
+
percent_bytes([H|T]) -->
|
|
967
|
+
percent_byte(H),
|
|
968
|
+
percent_bytes(T).
|
|
969
|
+
|
|
970
|
+
percent_byte(C) -->
|
|
971
|
+
[0'%, D1, D2],
|
|
972
|
+
{ nonvar(C)
|
|
973
|
+
-> Dv1 is (C>>4 /\ 0xf),
|
|
974
|
+
Dv2 is (C /\ 0xf),
|
|
975
|
+
code_type(D1, xdigit(Dv1)),
|
|
976
|
+
code_type(D2, xdigit(Dv2))
|
|
977
|
+
; code_type(D1, xdigit(Dv1)),
|
|
978
|
+
code_type(D2, xdigit(Dv2)),
|
|
979
|
+
C is ((Dv1)<<4) + Dv2
|
|
980
|
+
}.
|
|
981
|
+
|
|
982
|
+
percent_coded(C) -->
|
|
983
|
+
percent_byte(C0),
|
|
984
|
+
!,
|
|
985
|
+
( { C0 == 13 % %0D%0A --> \n
|
|
986
|
+
},
|
|
987
|
+
"%0",
|
|
988
|
+
( "A" ; "a" )
|
|
989
|
+
-> { C = 10
|
|
990
|
+
}
|
|
991
|
+
; { C0 >= 0xc0 }, % UTF-8 lead-in
|
|
992
|
+
utf8_cont(Cs),
|
|
993
|
+
{ phrase(utf8_codes([C]), [C0|Cs]) }
|
|
994
|
+
-> []
|
|
995
|
+
; { C = C0
|
|
996
|
+
}
|
|
997
|
+
).
|
|
998
|
+
|
|
999
|
+
%! www_decode(-Codes)//
|
|
1000
|
+
|
|
1001
|
+
www_decode([0' |T]) -->
|
|
1002
|
+
"+",
|
|
1003
|
+
!,
|
|
1004
|
+
www_decode(T).
|
|
1005
|
+
www_decode([C|T]) -->
|
|
1006
|
+
percent_coded(C),
|
|
1007
|
+
!,
|
|
1008
|
+
www_decode(T).
|
|
1009
|
+
www_decode([C|T]) -->
|
|
1010
|
+
[C],
|
|
1011
|
+
!,
|
|
1012
|
+
www_decode(T).
|
|
1013
|
+
www_decode([]) -->
|
|
1014
|
+
[].
|
|
1015
|
+
|
|
1016
|
+
utf8_cont([H|T]) -->
|
|
1017
|
+
percent_byte(H),
|
|
1018
|
+
{ between(0x80, 0xbf, H) },
|
|
1019
|
+
!,
|
|
1020
|
+
utf8_cont(T).
|
|
1021
|
+
utf8_cont([]) -->
|
|
1022
|
+
[].
|
|
1023
|
+
|
|
1024
|
+
|
|
1025
|
+
%! set_url_encoding(?Old, +New) is semidet.
|
|
1026
|
+
%
|
|
1027
|
+
% Query and set the encoding for URLs. The default is =utf8=.
|
|
1028
|
+
% The only other defined value is =iso_latin_1=.
|
|
1029
|
+
%
|
|
1030
|
+
% @tbd Having a global flag is highly inconvenient, but a
|
|
1031
|
+
% work-around for old sites using ISO Latin 1 encoding.
|
|
1032
|
+
|
|
1033
|
+
:- create_prolog_flag(url_encoding, utf8, [type(atom)]).
|
|
1034
|
+
|
|
1035
|
+
set_url_encoding(Old, New) :-
|
|
1036
|
+
current_prolog_flag(url_encoding, Old),
|
|
1037
|
+
( Old == New
|
|
1038
|
+
-> true
|
|
1039
|
+
; must_be(oneof([utf8, iso_latin_1]), New),
|
|
1040
|
+
set_prolog_flag(url_encoding, New)
|
|
1041
|
+
).
|
|
1042
|
+
|
|
1043
|
+
|
|
1044
|
+
/*******************************
|
|
1045
|
+
* IRI PROCESSING *
|
|
1046
|
+
*******************************/
|
|
1047
|
+
|
|
1048
|
+
%! url_iri(+Encoded, -Decoded) is det.
|
|
1049
|
+
%! url_iri(-Encoded, +Decoded) is det.
|
|
1050
|
+
%
|
|
1051
|
+
% Convert between a URL, encoding in US-ASCII and an IRI. An IRI
|
|
1052
|
+
% is a fully expanded Unicode string. Unicode strings are first
|
|
1053
|
+
% encoded into UTF-8, after which %-encoding takes place.
|
|
1054
|
+
|
|
1055
|
+
url_iri(Encoded, Decoded) :-
|
|
1056
|
+
nonvar(Encoded),
|
|
1057
|
+
!,
|
|
1058
|
+
( sub_atom(Encoded, _, _, _, '%')
|
|
1059
|
+
-> atom_codes(Encoded, Codes),
|
|
1060
|
+
unescape_precent(Codes, UTF8),
|
|
1061
|
+
phrase(utf8_codes(Unicodes), UTF8),
|
|
1062
|
+
atom_codes(Decoded, Unicodes)
|
|
1063
|
+
; Decoded = Encoded
|
|
1064
|
+
).
|
|
1065
|
+
url_iri(URL, IRI) :-
|
|
1066
|
+
atom_codes(IRI, IRICodes),
|
|
1067
|
+
atom_codes('/:?#&=', ExtraEscapes),
|
|
1068
|
+
phrase(www_encode(IRICodes, ExtraEscapes), UrlCodes),
|
|
1069
|
+
atom_codes(URL, UrlCodes).
|
|
1070
|
+
|
|
1071
|
+
|
|
1072
|
+
unescape_precent([], []).
|
|
1073
|
+
unescape_precent([0'%,C1,C2|T0], [H|T]) :- %'
|
|
1074
|
+
!,
|
|
1075
|
+
code_type(C1, xdigit(D1)),
|
|
1076
|
+
code_type(C2, xdigit(D2)),
|
|
1077
|
+
H is D1*16 + D2,
|
|
1078
|
+
unescape_precent(T0, T).
|
|
1079
|
+
unescape_precent([H|T0], [H|T]) :-
|
|
1080
|
+
unescape_precent(T0, T).
|
|
1081
|
+
|
|
1082
|
+
|
|
1083
|
+
/*******************************
|
|
1084
|
+
* FORM DATA *
|
|
1085
|
+
*******************************/
|
|
1086
|
+
|
|
1087
|
+
%! parse_url_search(?Spec, ?Fields:list(Name=Value)) is det.
|
|
1088
|
+
%
|
|
1089
|
+
% Construct or analyze an HTTP search specification. This deals
|
|
1090
|
+
% with form data using the MIME-type
|
|
1091
|
+
% =application/x-www-form-urlencoded= as used in HTTP GET
|
|
1092
|
+
% requests.
|
|
1093
|
+
|
|
1094
|
+
parse_url_search(Spec, Fields) :-
|
|
1095
|
+
atomic(Spec),
|
|
1096
|
+
!,
|
|
1097
|
+
atom_codes(Spec, Codes),
|
|
1098
|
+
phrase(search(Fields), Codes).
|
|
1099
|
+
parse_url_search(Codes, Fields) :-
|
|
1100
|
+
is_list(Codes),
|
|
1101
|
+
!,
|
|
1102
|
+
phrase(search(Fields), Codes).
|
|
1103
|
+
parse_url_search(Codes, Fields) :-
|
|
1104
|
+
must_be(list, Fields),
|
|
1105
|
+
phrase(csearch(Fields, []), Codes).
|
|
1106
|
+
|
|
1107
|
+
|
|
1108
|
+
/*******************************
|
|
1109
|
+
* FILE URLs *
|
|
1110
|
+
*******************************/
|
|
1111
|
+
|
|
1112
|
+
%! file_name_to_url(+File, -URL) is det.
|
|
1113
|
+
%! file_name_to_url(-File, +URL) is semidet.
|
|
1114
|
+
%
|
|
1115
|
+
% Translate between a filename and a file:// URL.
|
|
1116
|
+
%
|
|
1117
|
+
% @tbd Current implementation does not deal with paths that
|
|
1118
|
+
% need special encoding.
|
|
1119
|
+
|
|
1120
|
+
file_name_to_url(File, FileURL) :-
|
|
1121
|
+
nonvar(File),
|
|
1122
|
+
!,
|
|
1123
|
+
absolute_file_name(File, Path),
|
|
1124
|
+
atom_concat('file://', Path, FileURL),
|
|
1125
|
+
!.
|
|
1126
|
+
file_name_to_url(File, FileURL) :-
|
|
1127
|
+
atom_concat('file://', File, FileURL),
|
|
1128
|
+
!.
|
|
1129
|
+
|