Refactor webbw
[hcoop/zz_old/domtool.git] / src / util.sig
CommitLineData
182a2654
AC
1(*
2Domtool (http://hcoop.sf.net/)
3Copyright (C) 2004 Adam Chlipala
4
5This program is free software; you can redistribute it and/or
6modify it under the terms of the GNU General Public License
7as published by the Free Software Foundation; either version 2
8of the License, or (at your option) any later version.
9
10This program is distributed in the hope that it will be useful,
11but WITHOUT ANY WARRANTY; without even the implied warranty of
12MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13GNU General Public License for more details.
14
15You should have received a copy of the GNU General Public License
16along with this program; if not, write to the Free Software
17Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
18*)
19
20(* Utility functions *)
21
22signature UTIL =
23sig
24 val impLoop : (unit -> 'a) -> ('a -> bool) -> ('a * 'b -> 'b) -> 'b -> unit
25 (* (impLoop next stop body init) repeatedly executes next until stop returns
26 * true on the result. Running state is kept in the style of foldl, with
27 * the state for the next iteration being determiend by calling body with
28 * the most recent next return and the current state.
29 *)
30
182a2654
AC
31 val ioOptLoop : (unit -> string option) -> (string * 'b -> 'b) -> 'b -> unit
32 (* Like ioLoop, but with NONE as sentinel value. *)
33
34 val isIdent : char -> bool
35 (* Is the character a valid part of an identifier? (lowercase letter or
36 * digit?
37 *)
38
05060d16
AC
39 val isInt : string -> bool
40 (* Does the string stand for a valid integer? *)
41 val isNat : string -> bool
42 (* Does the string stand for a valid nonnegative integer? *)
43
44 val chop : string -> string
45 (* Remove the last character of a string *)
46
182a2654
AC
47 val validHost : string -> bool
48 (* Valid Internet hostname with no periods? *)
4d3abed7
AC
49 val validVhostFilename : string -> bool
50 (* Either a validHost or a validHost followed by .ssl? *)
182a2654
AC
51 val validDomain : string -> bool
52 (* Valid domain name? *)
53 val validUser : string -> bool
05060d16
AC
54 (* Valid UNIX username? (only lowercase letters) *)
55 val validEmailUser : string -> bool
56 (* Valid e-mail username? *)
182a2654
AC
57 val validEmail : string -> bool
58 (* Valid e-mail address? *)
59 val isTmp : string -> bool
60 (* Is the name of a temporary file generated by an editor? *)
61 val validIp : string -> bool
62 (* Is a valid IPv4 address? *)
63
64 val trimLast : string -> string
65 (* Remove the last character from a string *)
66
67 val toDir : string -> string
68 (* Translates a domain name into a fileystem path *)
69
70 val checkPath : StringSet.set * string -> bool
71 (* Given a set of valid path bases and a path, is it allowable? *)
72 val resolveAddr : string StringMap.map * string -> string
73 (* Determine the value of an address field that may include variables.
74 * Check that the final result is a validIp. *)
75 val resolveDomain : string StringMap.map * string -> string
76 (* Determine the value of a domain field that may include variables.
77 * Check that the final result is a validDomain. *)
874b616a
AC
78
79 val enrichSetFromFile : string * StringSet.set -> StringSet.set
80 (* Add the entries in the file to the set.
81 * A "CLEAR" entry clears the set. *)
4471dd55
AC
82
83 val mergeSort : ('a * int) list -> ('a * int) list
84 (* Sort the argument list in descending integer order. *)
182a2654 85end