From 47ed7e5acd5fe9fd8dfc1a6b9aac7603a50da25c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carlos=20Mart=C3=ADn=20Nieto?= Date: Tue, 18 Aug 2015 20:55:59 +0200 Subject: transport: provide a way to get the callbacks libgit2 implementations of smart subtransports can simply reach through the structure, but external implementors cannot. Add these two functions as a way for the smart subtransports to get the callbacks as set by the user. --- include/git2/sys/transport.h | 22 ++++++++++++++++++++++ src/transports/smart.c | 14 ++++++++++++++ 2 files changed, 36 insertions(+) diff --git a/include/git2/sys/transport.h b/include/git2/sys/transport.h index 867fbcbce..4a75b0832 100644 --- a/include/git2/sys/transport.h +++ b/include/git2/sys/transport.h @@ -211,6 +211,28 @@ GIT_EXTERN(int) git_transport_smart( git_remote *owner, /* (git_smart_subtransport_definition *) */ void *payload); +/** + * Call the certificate check for this transport. + * + * @param transport a smart transport + * @param cert the certificate to pass to the caller + * @param valid whether we believe the certificate is valid + * @param hostname the hostname we connected to + * @return the return value of the callback + */ +GIT_EXTERN(int) git_transport_smart_certificate_check(git_transport *transport, git_cert *cert, int valid, const char *hostname); + +/** + * Call the credentials callback for this transport + * + * @param out the pointer where the creds are to be stored + * @param transport a smart transport + * @param user the user we saw on the url (if any) + * @param methods available methods for authentication + * @return the return value of the callback + */ +GIT_EXTERN(int) git_transport_smart_credentials(git_cred **out, git_transport *transport, const char *user, int methods); + /* *** End of base transport interface *** *** Begin interface for subtransports for the smart transport *** diff --git a/src/transports/smart.c b/src/transports/smart.c index 85a49e543..31a2dec7b 100644 --- a/src/transports/smart.c +++ b/src/transports/smart.c @@ -372,6 +372,20 @@ static int ref_name_cmp(const void *a, const void *b) return strcmp(ref_a->head.name, ref_b->head.name); } +int git_transport_smart_certificate_check(git_transport *transport, git_cert *cert, int valid, const char *hostname) +{ + transport_smart *t = (transport_smart *)transport; + + return t->certificate_check_cb(cert, valid, hostname, t->message_cb_payload); +} + +int git_transport_smart_credentials(git_cred **out, git_transport *transport, const char *user, int methods) +{ + transport_smart *t = (transport_smart *)transport; + + return t->cred_acquire_cb(out, t->url, user, methods, t->cred_acquire_payload); +} + int git_transport_smart(git_transport **out, git_remote *owner, void *param) { transport_smart *t; -- cgit v1.2.3