From 85a85659d19ab495b389428eb22bde8a924e9435 Mon Sep 17 00:00:00 2001 From: ygrek Date: Mon, 4 Sep 2017 10:11:50 +0100 Subject: [PATCH] + CURLOPT_USERNAME CURLOPT_PASSWORD (close #26) --- config.h.in | 8 ++++++++ configure | 26 ++++++++++++++++++++++++++ configure.ac | 1 + curl-helper.c | 20 ++++++++++++++++++++ curl.ml | 8 ++++++++ curl.mli | 6 ++++++ 6 files changed, 69 insertions(+) diff --git a/config.h.in b/config.h.in index 7883993..446a8ba 100644 --- a/config.h.in +++ b/config.h.in @@ -831,6 +831,10 @@ and to 0 if you don't. */ #undef HAVE_DECL_CURLOPT_OPENSOCKETFUNCTION +/* Define to 1 if you have the declaration of `CURLOPT_PASSWORD', and to 0 if + you don't. */ +#undef HAVE_DECL_CURLOPT_PASSWORD + /* Define to 1 if you have the declaration of `CURLOPT_PIPEWAIT', and to 0 if you don't. */ #undef HAVE_DECL_CURLOPT_PIPEWAIT @@ -1063,6 +1067,10 @@ you don't. */ #undef HAVE_DECL_CURLOPT_USERAGENT +/* Define to 1 if you have the declaration of `CURLOPT_USERNAME', and to 0 if + you don't. */ +#undef HAVE_DECL_CURLOPT_USERNAME + /* Define to 1 if you have the declaration of `CURLOPT_USERPWD', and to 0 if you don't. */ #undef HAVE_DECL_CURLOPT_USERPWD diff --git a/configure b/configure index fd22924..8974941 100755 --- a/configure +++ b/configure @@ -6697,6 +6697,32 @@ fi cat >>confdefs.h <<_ACEOF #define HAVE_DECL_CURLOPT_CERTINFO $ac_have_decl _ACEOF +ac_fn_c_check_decl "$LINENO" "CURLOPT_USERNAME" "ac_cv_have_decl_CURLOPT_USERNAME" " +#include \"curl/curl.h\" + +" +if test "x$ac_cv_have_decl_CURLOPT_USERNAME" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_CURLOPT_USERNAME $ac_have_decl +_ACEOF +ac_fn_c_check_decl "$LINENO" "CURLOPT_PASSWORD" "ac_cv_have_decl_CURLOPT_PASSWORD" " +#include \"curl/curl.h\" + +" +if test "x$ac_cv_have_decl_CURLOPT_PASSWORD" = xyes; then : + ac_have_decl=1 +else + ac_have_decl=0 +fi + +cat >>confdefs.h <<_ACEOF +#define HAVE_DECL_CURLOPT_PASSWORD $ac_have_decl +_ACEOF ac_fn_c_check_decl "$LINENO" "CURLINFO_EFFECTIVE_URL" "ac_cv_have_decl_CURLINFO_EFFECTIVE_URL" " #include \"curl/curl.h\" diff --git a/configure.ac b/configure.ac index ceb98bd..6a3af03 100644 --- a/configure.ac +++ b/configure.ac @@ -132,6 +132,7 @@ CURLOPT_SSH_HOST_PUBLIC_KEY_MD5, CURLOPT_COPYPOSTFIELDS, CURLOPT_PROXY_TRANSFER_MODE, CURLOPT_SEEKFUNCTION, CURLOPT_OPENSOCKETFUNCTION, CURLOPT_PROTOCOLS, CURLOPT_REDIR_PROTOCOLS, CURLOPT_RESOLVE, CURLOPT_DNS_SERVERS, CURLOPT_MAIL_FROM, CURLOPT_MAIL_RCPT, CURLOPT_PIPEWAIT, CURLOPT_CERTINFO, +CURLOPT_USERNAME, CURLOPT_PASSWORD, CURLINFO_EFFECTIVE_URL, CURLINFO_RESPONSE_CODE, CURLINFO_TOTAL_TIME, CURLINFO_NAMELOOKUP_TIME, CURLINFO_CONNECT_TIME, CURLINFO_PRETRANSFER_TIME, diff --git a/curl-helper.c b/curl-helper.c index 104753d..feaff72 100644 --- a/curl-helper.c +++ b/curl-helper.c @@ -129,6 +129,8 @@ typedef enum OcamlValues Ocaml_MAIL_FROM, Ocaml_MAIL_RCPT, Ocaml_RESOLVE, + Ocaml_USERNAME, + Ocaml_PASSWORD, /* Not used, last for size */ OcamlValuesSize @@ -2600,6 +2602,14 @@ SETOPT_SLIST( MAIL_RCPT) SETOPT_BOOL( PIPEWAIT) #endif +#if HAVE_DECL_CURLOPT_USERNAME +SETOPT_STRING( USERNAME) +#endif + +#if HAVE_DECL_CURLOPT_PASSWORD +SETOPT_STRING( PASSWORD) +#endif + /** ** curl_easy_setopt helper function **/ @@ -2979,6 +2989,16 @@ CURLOptionMapping implementedOptionMap[] = #else IMM_NO(CERTINFO), #endif +#if HAVE_DECL_CURLOPT_USERNAME + MAP(USERNAME), +#else + MAP_NO(USERNAME), +#endif +#if HAVE_DECL_CURLOPT_PASSWORD + MAP(PASSWORD), +#else + MAP_NO(PASSWORD), +#endif }; static Connection *duplicateConnection(Connection *original) diff --git a/curl.ml b/curl.ml index a28c12d..d1e6686 100644 --- a/curl.ml +++ b/curl.ml @@ -412,6 +412,8 @@ type curlOption = | CURLOPT_MAIL_RCPT of string list | CURLOPT_PIPEWAIT of bool | CURLOPT_CERTINFO of bool + | CURLOPT_USERNAME of string + | CURLOPT_PASSWORD of string type initOption = | CURLINIT_GLOBALALL @@ -954,6 +956,12 @@ let set_mailrcpt conn l = let set_pipewait conn b = setopt conn (CURLOPT_PIPEWAIT b) +let set_username conn s = + setopt conn (CURLOPT_USERNAME s) + +let set_password conn s = + setopt conn (CURLOPT_PASSWORD s) + let get_effectiveurl conn = match (getinfo conn CURLINFO_EFFECTIVE_URL) with | CURLINFO_String s -> s diff --git a/curl.mli b/curl.mli index fdad25c..a80b789 100644 --- a/curl.mli +++ b/curl.mli @@ -420,6 +420,8 @@ type curlOption = | CURLOPT_MAIL_RCPT of string list | CURLOPT_PIPEWAIT of bool | CURLOPT_CERTINFO of bool + | CURLOPT_USERNAME of string + | CURLOPT_PASSWORD of string type initOption = | CURLINIT_GLOBALALL @@ -666,6 +668,10 @@ val set_dns_servers : t -> string list -> unit val set_mailfrom : t -> string -> unit val set_mailrcpt : t -> string list -> unit val set_pipewait : t -> bool -> unit +val set_username : t -> string -> unit +(** @since 0.8.0 *) +val set_password : t -> string -> unit +(** @since 0.8.0 *) (** {2 Get transfer properties} *) -- 2.11.4.GIT