Commits

Paweł Wieczorek committed 5d73d10 Draft

more tests pass

  • Participants
  • Parent commits 5ef1aba

Comments (0)

Files changed (3)

File src/Sip_types.ml

     | "REFER" -> REFER
     | "MESSAGE" -> MESSAGE
     | "UPDATE" -> UPDATE
-    | s -> UnknownRequestMethod s
+    | s when is_word s -> UnknownRequestMethod s
+    | _ -> failwith "sip_request_method_of_string"
 
 let string_of_sip_request_method = function
     | REGISTER -> "REGISTER"
     | i -> OtherResponse i
 
 (*********************************************************************************************************************
- * TODO: Maybe Should I use some external library for parsing URI? Eh... crazy text format ;]
+ *)
+
+
+(*********************************************************************************************************************
  *)
 
 type sip_uri_scheme
 let sip_uri_scheme_of_string = function
     | "sip"  -> URI_SCHEME_SIP
     | "sips" -> URI_SCHEME_SIPS
-    | scheme -> UnknownUriScheme scheme
+    | "tel"  -> URI_SCHEME_TEL
+    | scheme when is_word scheme -> UnknownUriScheme scheme
+    | _ -> failwith "sip_uri_scheme_of_string"
 
 (*********************************************************************************************************************
  *)
 (*********************************************************************************************************************
  *)
 
+type sip_host =
+    | SipHost of string
+
+let sip_host_of_string = function
+    | s -> SipHost s
+
+
+let string_of_sip_host = function
+    | SipHost s -> s
+
+
+
+(*********************************************************************************************************************
+ *)
+
+let sip_via_rfc3261_branch = "z9hG4bK"
+
 type sip_via =
     | SipVia of string
 

File src/Sip_utils.ml

         in
     (remember_arg find_end -| skip_seps seps buf) start
 
+
+let string_all f str =
+    let rec go = function
+        | n when n = String.length str ->
+            true
+
+        | n -> 
+            f (String.get str n) && go (succ n)
+    in
+    go 0
+
+let is_word = string_all Char.is_letter     
+        
+
 let find_word = find_sep [' '; '\r'; '\n'] 
 
 let find_endline index buf =

File tests/Test_sip_types.ml

 (*********************************************************************************************************************
  *)
 
+module Test_sip_host = struct
+
+    type t = sip_host
+
+    let converters =
+        (sip_host_of_string, string_of_sip_host)
+
+    let valid_data =
+        [
+        ]
+
+    let invalid_data =
+        [
+        ]
+
+end
+(*********************************************************************************************************************
+ *)
+
 module Test_sip_via = struct
 
     type t = sip_via