12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879(****************************************************************************)(* Copyright (C) 2011,2012,2013 Ralf Treinen *)(* <ralf.treinen@pps.univ-paris-diderot.fr> *)(* *)(* This library is free software: you can redistribute it and/or modify *)(* it under the terms of the GNU Lesser General Public License as *)(* published by the Free Software Foundation, either version 3 of the *)(* License, or (at your option) any later version. A special linking *)(* exception to the GNU Lesser General Public License applies to this *)(* library, see the COPYING file for more information. *)(****************************************************************************)exceptionInvalid_urlofstringincludeUtil.Logging(structletlabel="dose_common.url"end)(***********************************************************************)(* Input schemes *******************************************************)typedebtypes=[`Edsp|`Deb|`DebSrc]typerpmtypes=[`Synthesis|`Hdlist]typeothertypes=[`Csw|`Pef|`Opam|`Npm]typefiletypes=[`Cudf|debtypes|rpmtypes|othertypes]letsupported_input_types=[`Edsp;`Deb;`DebSrc;`Synthesis;`Hdlist;`Pef;`Opam;`Csw;`Cudf;`Npm]letscheme_to_string=function|`Edsp->"edsp"|`Csw->"csw"|`Deb->"deb"|`DebSrc->"debsrc"|`Pef->"pef"|`Opam->"opam"|`Npm->"npm"|`Cudf->"cudf"|`Synthesis->"synthesis"|`Hdlist->"hdlist"letscheme_of_string=function|"edsp"->`Edsp|"csw"->`Csw|"deb"->`Deb|"opam"->`Opam|"npm"->`Npm|"debsrc"->`DebSrc|"cudf"->`Cudf|"eclipse"|"pef"->`Pef|"synthesis"->`Synthesis|"hdlist"->`Hdlist|s->letsupported=String.concat", "(List.mapscheme_to_stringsupported_input_types)infatal"unknown input scheme: \"%s\" - Must be one of: %s"ssupported(***********************************************************************)(* URLs ****************************************************************)typeurl={scheme:filetypes;path:string(* filename *)}letto_stringu=scheme_to_stringu.scheme^"://"^u.pathletof_strings=letl=String.lengthsinletpos_colon=tryString.indexs':'withNot_found->fatal"missing '://' separator %s"sinifpos_colon+2>=l||s.[pos_colon+1]<>'/'||s.[pos_colon+2]<>'/'thenfatal"missing '://' separator %s"s;letscheme=scheme_of_string(String.subs0pos_colon)andstart_rest=pos_colon+3in{scheme;path=String.subsstart_rest(l-start_rest)}