/[svn]/cduce/trunk/parser/url.ml
ViewVC logotype

Contents of /cduce/trunk/parser/url.ml

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1228 - (hide annotations)
Tue Jul 10 18:32:50 2007 UTC (5 years, 10 months ago) by abate
Original Path: parser/url.ml
File size: 694 byte(s)
[r2004-07-06 14:16:32 by afrisch] Add string:// scheme

Original author: afrisch
Date: 2004-07-06 14:16:32+00:00
1 abate 907 type url = Filename of string | Url of string
2    
3 abate 1228 let start_with s p =
4     let l = String.length p in
5     let n = String.length s in
6     if (n >= l) && (String.sub s 0 l = p)
7     then Some (String.sub s l (n - l))
8     else None
9    
10 abate 907 let is_url s =
11     try let _ = Neturl.extract_url_scheme s in true
12     with Neturl.Malformed_URL -> false
13    
14 abate 1187 let no_load_url s =
15     let msg =
16     Printf.sprintf
17     "Error \"%s\": \nTo fetch external URLs, you need to compile CDuce with curl and/or netclient" s
18     in
19     raise (Location.Generic msg)
20 abate 907
21 abate 1187 let load_url = ref no_load_url
22    
23 abate 907 let process s =
24 abate 1228 match start_with s "string://" with
25     | None ->
26     if is_url s then Url (!load_url s)
27     else Filename s
28     | Some s ->
29     Url s

CVS Admin">CVS Admin
ViewVC Help
Powered by ViewVC 1.1.5