Skip to content
Browse files

Really add ocamldoc

  • Loading branch information...
1 parent 03c6bf8 commit 68b4aaa2dc1aca3f844e032573bd60c185c0c9a3 @andrenth committed Sep 14, 2012
Showing with 87 additions and 11 deletions.
  1. +7 −0 _oasis
  2. +42 −0 lib/SPF.mli
  3. +4 −4 lib_test/test.ml
  4. +34 −7 setup.ml
View
7 _oasis
@@ -23,3 +23,10 @@ Executable spf_test
Install: false
CompiledObject: best
BuildDepends: spf, unix
+
+Document "spf"
+ Title: SPF documentation
+ Type: ocamlbuild (0.3)
+ BuildTools+: ocamldoc
+ XOCamlbuildPath: lib
+ XOCamlbuildLibraries: spf
View
42 lib/SPF.mli
@@ -1,15 +1,30 @@
+(** OCaml bindings to {{:http://www.libspf2.org/} libspf2}. It is strongly
+ recommended that a {{:https://github.com/andrenth/libspf2} patched libspf2
+ with fixes sent to the SPF-devel mailing list} is used instead of the
+ current official libspf2 release (version 1.2.9).
+*)
+
+(** The type of SPF server instances. *)
type server
+(** The DNS scheme to be used by SPF. *)
type dns = Dns_resolv
| Dns_cache
| Dns_zone
+(** The type of SPF requests. *)
type request
+
+(** The type of SPF responses. *)
type response
+(** The type of SPF comments. *)
type comments
+
+(** The type of SPF reason. *)
type reason
+(** The type of SPF results. *)
type result
= Invalid
| Neutral of comments
@@ -21,24 +36,51 @@ type result
| Permerror
exception SPF_error of string
+ (** Exception raised by SPF functions in case of errors. *)
val server : ?debug:bool -> dns -> server
+ (** Allocates a new SPF server instance. *)
+
val free_server : server -> unit
+ (** Frees memory allocated to the given {!server}. *)
val request : server -> request
+ (** Create a new SPF request. *)
+
val free_request : request -> unit
+ (** Frees memory allocated to the given {!request}. *)
val check_helo : server -> Unix.inet_addr -> string -> response
+ (** [check_helo spf addr helo] performs an SPF check on address [addr]
+ on the SPF record for the HELO name [helo] using SPF server [spf]. *)
val check_from : server -> Unix.inet_addr -> string -> response
+ (** [check_helo spf addr from] performs an SPF check on address [addr]
+ on the SPF record of the domain of the MAIL FROM address [from]. *)
val result : response -> result
+ (** Extracts an {!result} from an {!response}. *)
+
val reason : response -> reason
+ (** Extracts an {!reason} from an {!response}. *)
+
val received_spf : response -> string
+
val received_spf_value : response -> string
+ (** Extracts the [Received-SPF] header value from an {!response}. *)
+
val header_comment : response -> string
+ (** Extracts the comment part of the [Received-SPF] header value from an
+ {!response}. *)
+
val smtp_comment : comments -> string
+ (** Extracts the SMTP comment part from {!comments}. *)
+
val explanation : comments -> string
+ (** Extracts the explanation part from {!comments}. *)
val string_of_result : result -> string
+ (** Converts an {!result} to a string. *)
+
val string_of_reason : reason -> string
+ (** Converts an {!reason} to a string. *)
View
8 lib_test/test.ml
@@ -1,8 +1,8 @@
open Printf
-let check_from server client_addr helo from =
+let check_from server client_addr from =
try
- let r = SPF.check_from server client_addr helo from in
+ let r = SPF.check_from server client_addr from in
`Response r
with SPF.SPF_error e ->
`Error e
@@ -17,9 +17,9 @@ let check_helo server client_addr helo =
let () =
let server = SPF.server SPF.Dns_cache in
let client_addr = Unix.inet_addr_of_string "187.73.32.159" in
- let helo = "mta98.f1.k8.com.br" in
+ let _helo = "mta98.f1.k8.com.br" in
let from = "andre@andrenathan.com" in
- match check_from server client_addr helo from with
+ match check_from server client_addr from with
| `Error e ->
printf "SPF error: %s\n%!" e
| `Response r ->
View
41 setup.ml
@@ -1,7 +1,7 @@
(* setup.ml generated for the first time by OASIS v0.2.0 *)
(* OASIS_START *)
-(* DO NOT EDIT (digest: 4dcd45d57408d16e538c56aeb0e26852) *)
+(* DO NOT EDIT (digest: a8ba32a1f5212b1e0ac0f04f1d7e2bff) *)
(*
Regenerated by OASIS v0.3.0
Visit http://oasis.forge.ocamlcore.org for more information and
@@ -5563,12 +5563,12 @@ let setup_t =
BaseSetup.configure = InternalConfigurePlugin.configure;
build = OCamlbuildPlugin.build;
test = [];
- doc = [];
+ doc = [("spf", OCamlbuildDocPlugin.doc_build "lib")];
install = InternalInstallPlugin.install;
uninstall = InternalInstallPlugin.uninstall;
clean = [OCamlbuildPlugin.clean];
clean_test = [];
- clean_doc = [];
+ clean_doc = [("spf", OCamlbuildDocPlugin.doc_clean "lib")];
distclean = [];
distclean_test = [];
distclean_doc = [];
@@ -5686,23 +5686,50 @@ let setup_t =
bs_byteopt = [(OASISExpr.EBool true, [])];
bs_nativeopt = [(OASISExpr.EBool true, [])];
},
- {exec_custom = false; exec_main_is = "test.ml"; })
+ {exec_custom = false; exec_main_is = "test.ml"; });
+ Doc
+ ({
+ cs_name = "spf";
+ cs_data = PropList.Data.create ();
+ cs_plugin_data = [];
+ },
+ {
+ doc_type = (`Doc, "ocamlbuild", Some "0.3");
+ doc_custom =
+ {
+ pre_command = [(OASISExpr.EBool true, None)];
+ post_command = [(OASISExpr.EBool true, None)];
+ };
+ doc_build =
+ [
+ (OASISExpr.ENot (OASISExpr.EFlag "docs"), false);
+ (OASISExpr.EFlag "docs", true)
+ ];
+ doc_install = [(OASISExpr.EBool true, true)];
+ doc_install_dir = "$docdir";
+ doc_title = "SPF documentation";
+ doc_authors = [];
+ doc_abstract = None;
+ doc_format = OtherDoc;
+ doc_data_files = [];
+ doc_build_tools =
+ [ExternalTool "ocamlbuild"; ExternalTool "ocamldoc"];
+ })
];
plugins = [(`Extra, "META", Some "0.3")];
schema_data = PropList.Data.create ();
plugin_data = [];
};
oasis_fn = Some "_oasis";
oasis_version = "0.3.0";
- oasis_digest =
- Some "\238\187\161\206 \020\225\215\006\000\181\246k\227)\168";
+ oasis_digest = Some " !\167\2369\197e\021K\2547\244m$\236\"";
oasis_exec = None;
oasis_setup_args = [];
setup_update = false;
};;
let setup () = BaseSetup.setup setup_t;;
-# 5707 "setup.ml"
+# 5734 "setup.ml"
(* OASIS_STOP *)
let () = setup ();;

0 comments on commit 68b4aaa

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