123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111(******************************************************************************)(* Erssical *)(* *)(* Copyright (C) 2013 Institut National de Recherche en Informatique *)(* et en Automatique. All rights reserved. *)(* *)(* This program is free software; you can redistribute it and/or modify *)(* it under the terms of the GNU Lesser General Public License version *)(* 3 as published by the Free Software Foundation. *)(* *)(* This program is distributed in the hope that it will be useful, *)(* but WITHOUT ANY WARRANTY; without even the implied warranty of *)(* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *)(* GNU Library General Public License for more details. *)(* *)(* You should have received a copy of the GNU Library General Public *)(* License along with this program; if not, write to the Free Software *)(* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA *)(* 02111-1307 USA *)(* *)(* Contact: Maxence.Guesdon@inria.fr *)(* *)(* *)(******************************************************************************)(** *)typet={file:string;last_read_time:float;auth_list:Str.regexplist;}letre_sep=Str.regexp_string" //";;(*c==v=[String.strip_string]=1.0====*)letstrip_strings=letlen=String.lengthsinletreciter_firstn=ifn>=lenthenNoneelsematchs.[n]with' '|'\t'|'\n'|'\r'->iter_first(n+1)|_->Someninmatchiter_first0withNone->""|Somefirst->letreciter_lastn=ifn<=firstthenNoneelsematchs.[n]with' '|'\t'|'\n'|'\r'->iter_last(n-1)|_->Someninmatchiter_last(len-1)withNone->String.subsfirst1|Somelast->String.subsfirst((last-first)+1)(*/c==v=[String.strip_string]=1.0====*)letread_auth_linesic=letreciteracc=matchtrySome(input_lineic)withEnd_of_file->NonewithNone->List.revacc|Someline->letpat=tryletp=Str.search_forwardre_sepline0inString.subline0pwithNot_found->strip_stringlineiniter(Str.regexppat::acc)initer[];;letfile_datefile=try(Unix.statfile).Unix.st_mtimewithUnix.Unix_error(e,s1,s2)->failwith(Printf.sprintf"%s: %s %s"(Unix.error_messagee)s1s2);;letread_authfile=letic=open_infileinlettime=file_datefileinletl=read_auth_linesicinlett={file=file;last_read_time=time;auth_list=l}inclose_inic;t;;letread_if_modt=letmtime=file_datet.fileinifmtime>t.last_read_timethenread_autht.fileelset;;leturl_authturl=leturl=Types.string_of_urlurlinletpredre=Str.string_matchreurl0inList.existspredt.auth_list;;