2008-02-28 22:00:24 -07:00
|
|
|
let name = ref "irc.test"
|
2008-03-02 21:30:37 -07:00
|
|
|
let version = "0.1"
|
2008-02-27 22:50:27 -07:00
|
|
|
|
|
|
|
let newline_re = Pcre.regexp "\n\r?"
|
|
|
|
let argsep_re = Pcre.regexp " :"
|
|
|
|
let space_re = Pcre.regexp " "
|
|
|
|
|
|
|
|
let dbg msg a =
|
|
|
|
prerr_endline ("[" ^ msg ^ "]");
|
|
|
|
a
|
|
|
|
|
|
|
|
let string_map f s =
|
|
|
|
let l = String.length s in
|
|
|
|
if l = 0 then
|
|
|
|
s
|
|
|
|
else
|
|
|
|
let r = String.create l in
|
|
|
|
for i = 0 to l - 1 do
|
|
|
|
String.unsafe_set r i (f (String.unsafe_get s i))
|
|
|
|
done;
|
|
|
|
r
|
|
|
|
|
|
|
|
let lowercase_char c =
|
|
|
|
if (c >= 'A' && c <= '^') then
|
|
|
|
Char.unsafe_chr(Char.code c + 32)
|
|
|
|
else
|
|
|
|
c
|
|
|
|
|
|
|
|
let uppercase_char c =
|
|
|
|
if (c >= 'a' && c <= '~') then
|
|
|
|
Char.unsafe_chr(Char.code c - 32)
|
|
|
|
else
|
|
|
|
c
|
|
|
|
|
|
|
|
let uppercase s = string_map uppercase_char s
|
|
|
|
let lowercase s = string_map lowercase_char s
|
|
|
|
|
2008-02-28 22:00:24 -07:00
|
|
|
let truncate s len =
|
|
|
|
let slen = String.length s in
|
|
|
|
if len >= slen then
|
|
|
|
s
|
|
|
|
else
|
|
|
|
Str.string_before s (min slen len)
|