27 lines
578 B
OCaml
27 lines
578 B
OCaml
type name = string
|
|
|
|
type userinfo = {
|
|
username : string;
|
|
realname : string;
|
|
hostname : string;
|
|
}
|
|
|
|
let pp_userinfo ppf { username; realname; hostname } =
|
|
ignore realname;
|
|
Format.fprintf ppf "!%s@%s" username hostname
|
|
|
|
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
|