Skip to content
Browse files

Get rid of separator type

  • Loading branch information...
1 parent ddb840d commit 3fe6408b06e701b5d799fdfe2192ce715b1dae4e @andrenth committed
Showing with 6 additions and 29 deletions.
  1. +2 −13 lib/SRS.ml
  2. +3 −9 lib/SRS.mli
  3. +1 −7 lib/srs_stubs.c
View
15 lib/SRS.ml
@@ -1,10 +1,5 @@
type t
-type separator
- = Plus
- | Minus
- | Equals
-
exception SRS_error of string
let _ = Callback.register_exception "SRS.SRS_error" (SRS_error "")
@@ -13,8 +8,8 @@ external create : unit -> t = "caml_srs_new"
external add_secret : t -> string -> unit = "caml_srs_add_secret"
external forward : t -> string -> string -> string = "caml_srs_forward"
external reverse : t -> string -> string = "caml_srs_reverse"
-external set_separator : t -> separator -> unit = "caml_srs_set_separator"
-external get_separator : t -> separator = "caml_srs_get_separator"
+external set_separator : t -> char -> unit = "caml_srs_set_separator"
+external get_separator : t -> char = "caml_srs_get_separator"
external set_max_age : t -> int -> unit = "caml_srs_set_maxage"
external get_max_age : t -> int = "caml_srs_get_maxage"
external set_hash_length : t -> int -> unit = "caml_srs_set_hashlength"
@@ -32,9 +27,3 @@ let make secret max_age hash_len sep =
set_hash_length srs hash_len;
add_secret srs secret;
srs
-
-let separator_of_string = function
- | "+" -> Plus
- | "-" -> Minus
- | "=" -> Equals
- | _ -> invalid_arg "SRS.separator_of_string"
View
12 lib/SRS.mli
@@ -1,18 +1,13 @@
type t
-type separator
- = Plus
- | Minus
- | Equals
-
exception SRS_error of string
val create : unit -> t
val add_secret : t -> string -> unit
val forward : t -> string -> string -> string
val reverse : t -> string -> string
-val set_separator : t -> separator -> unit
-val get_separator : t -> separator
+val set_separator : t -> char -> unit
+val get_separator : t -> char
val set_max_age : t -> int -> unit
val get_max_age : t -> int
val set_hash_length : t -> int -> unit
@@ -24,5 +19,4 @@ val get_no_forward : t -> bool
val set_no_reverse : t -> bool -> unit
val get_no_reverse : t -> bool
-val make : string -> int -> int -> separator -> t
-val separator_of_string : string -> separator
+val make : string -> int -> int -> char -> t
View
8 lib/srs_stubs.c
@@ -107,19 +107,13 @@ caml_srs_reverse(value srs_val, value sender_val)
CAMLreturn(res);
}
-static const char srs_sep_table[] = {
- '+',
- '-',
- '=',
-};
-
CAMLprim value
caml_srs_set_separator(value srs_val, value sep_val)
{
CAMLparam2(srs_val, sep_val);
int ret;
srs_t *srs = (srs_t *)Data_custom_val(srs_val);
- char sep = srs_sep_table[Int_val(sep_val)];
+ char sep = Int_val(sep_val);
ret = srs_set_separator(srs, sep);
if (ret != SRS_SUCCESS)

0 comments on commit 3fe6408

Please sign in to comment.
Something went wrong with that request. Please try again.