1 (* Copyright (C) 2000, HELM Team.
3 * This file is part of HELM, an Hypertextual, Electronic
4 * Library of Mathematics, developed at the Computer Science
5 * Department, University of Bologna, Italy.
7 * HELM is free software; you can redistribute it and/or
8 * modify it under the terms of the GNU General Public License
9 * as published by the Free Software Foundation; either version 2
10 * of the License, or (at your option) any later version.
12 * HELM is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
17 * You should have received a copy of the GNU General Public License
18 * along with HELM; if not, write to the Free Software
19 * Foundation, Inc., 59 Temple Place - Suite 330, Boston,
22 * For details, see the HELM World-Wide-Web page,
23 * http://cs.unibo.it/helm/.
26 (******************************************************************************)
30 (* Claudio Sacerdoti Coen <sacerdot@cs.unibo.it> *)
33 (******************************************************************************)
36 (*CSC: il getter _DEVE_ diventare un semplice "binding" a quello in Perl *)
39 (* deliver update request to http_getter *)
40 ClientHTTP.send (Configuration.getter_url ^ "update")
43 (* url_of_uri : uri -> url *)
45 let dbm = Dbm.opendbm Configuration.uris_dbm [Dbm.Dbm_rdonly] 0o660 in
46 let url = Dbm.find dbm (UriManager.string_of_uri uri) in
51 let filedir_of_uri uri =
52 let fn = UriManager.buri_of_uri uri in
53 let fn' = Str.replace_first (Str.regexp ".*:") Configuration.dest fn in
57 let name_and_ext_of_uri uri =
58 let str = UriManager.string_of_uri uri in
59 Str.replace_first (Str.regexp ".*/") "" str
62 let raw_get = ClientHTTP.get_and_save
64 (* get_file : uri -> filename *)
66 let dir = filedir_of_uri uri in
67 let fn = dir ^ "/" ^ name_and_ext_of_uri uri ^ ".xml" in
68 if not (Sys.file_exists fn) then
70 let url = url_of_uri uri in
72 (Configuration.getter_url ^ "getxml?uri=" ^
73 UriManager.string_of_uri uri ^ "&format=normal&patch_dtd=no"
79 (* get : uri -> filename *)
80 (* If uri is the URI of an annotation, the annotated object is processed *)
82 let module U = UriManager in
85 (Str.replace_first (Str.regexp "\.types$") ""
86 (Str.replace_first (Str.regexp "\.ann$") "" (U.string_of_uri uri))))
89 (* get_ann : uri -> filename *)
90 (* If uri is the URI of an annotation, the annotation file is processed *)
91 let get_ann = get_file;;
93 (* get_ann_file_name_and_uri : uri -> filename * annuri *)
94 (* If given an URI, it returns the name of the corresponding *)
95 (* annotation file and the annotation uri *)
96 let get_ann_file_name_and_uri uri =
97 let module U = UriManager in
98 let uri = U.string_of_uri uri in
101 if Str.string_match (Str.regexp ".*\.ann$") uri 0 then
107 let dir = filedir_of_uri annuri in
108 let fn = dir ^ "/" ^ name_and_ext_of_uri annuri ^ ".xml" in