2024-01-10 01:20:39 +00:00
|
|
|
type name = string
|
2024-01-11 03:49:07 +00:00
|
|
|
|
|
|
|
type userinfo = {
|
|
|
|
username : string;
|
|
|
|
realname : string;
|
|
|
|
hostname : string;
|
|
|
|
}
|
|
|
|
|
|
|
|
let pp_userinfo ppf { username; realname; hostname } =
|
|
|
|
ignore realname;
|
|
|
|
Format.fprintf ppf "!%s@%s" username hostname
|
2024-01-10 01:20:39 +00:00
|
|
|
|
|
|
|
let name_type s =
|
|
|
|
let rec valid i =
|
|
|
|
if i >= String.length s then true
|
|
|
|
else
|
|
|
|
match s.[i] with
|
|
|
|
| ' ' | '@' | '+' | ',' -> false
|
|
|
|
| _ -> valid (i + 1)
|
|
|
|
in
|
|
|
|
if s = "" then `invalid
|
|
|
|
else
|
|
|
|
match s.[0] with
|
|
|
|
| ':' -> `invalid
|
|
|
|
| '#' -> if valid 1 then `chan else `invalid
|
|
|
|
| _ -> if valid 0 then `nick else `invalid
|