diff options
| author | Ben Straub <bs@github.com> | 2013-01-08 19:55:59 -0800 |
|---|---|---|
| committer | Ben Straub <bs@github.com> | 2013-01-09 13:31:17 -0800 |
| commit | 520dcc1c000c7c29058d6ae56982461e782210fe (patch) | |
| tree | 4d0a25b2dd626e1e832e52c8a067877851738200 /src | |
| parent | ffb02b1630da85e063a816cc6dddcdc004a8ff72 (diff) | |
| download | libgit2-520dcc1c000c7c29058d6ae56982461e782210fe.tar.gz | |
Move credential helpers to their own (optional) header
Diffstat (limited to 'src')
| -rw-r--r-- | src/transports/cred.c | 21 | ||||
| -rw-r--r-- | src/transports/cred_helpers.c | 28 |
2 files changed, 29 insertions, 20 deletions
diff --git a/src/transports/cred.c b/src/transports/cred.c index 5ecb8a4b9..ecb026062 100644 --- a/src/transports/cred.c +++ b/src/transports/cred.c @@ -7,6 +7,7 @@ #include "git2.h" #include "smart.h" +#include "git2/cred_helpers.h" static void plaintext_free(struct git_cred *cred) { @@ -57,23 +58,3 @@ int git_cred_userpass_plaintext_new( *cred = &c->parent; return 0; } - -int git_cred_stock_userpass_plaintext( - git_cred **cred, - const char *url, - unsigned int allowed_types, - void *payload) -{ - git_cred_stock_userpass_plaintext_payload *userpass = - (git_cred_stock_userpass_plaintext_payload*)payload; - - GIT_UNUSED(url); - - if (!userpass || !userpass->username || !userpass->password) return -1; - - if ((GIT_CREDTYPE_USERPASS_PLAINTEXT & allowed_types) == 0 || - git_cred_userpass_plaintext_new(cred, userpass->username, userpass->password) < 0) - return -1; - - return 0; -} diff --git a/src/transports/cred_helpers.c b/src/transports/cred_helpers.c new file mode 100644 index 000000000..8d8eb9990 --- /dev/null +++ b/src/transports/cred_helpers.c @@ -0,0 +1,28 @@ +/* + * Copyright (C) the libgit2 contributors. All rights reserved. + * + * This file is part of libgit2, distributed under the GNU GPL v2 with + * a Linking Exception. For full terms see the included COPYING file. + */ + +#include "common.h" +#include "git2/cred_helpers.h" + +int git_cred_userpass( + git_cred **cred, + const char *url, + unsigned int allowed_types, + void *payload) +{ + git_cred_userpass_payload *userpass = (git_cred_userpass_payload*)payload; + + GIT_UNUSED(url); + + if (!userpass || !userpass->username || !userpass->password) return -1; + + if ((GIT_CREDTYPE_USERPASS_PLAINTEXT & allowed_types) == 0 || + git_cred_userpass_plaintext_new(cred, userpass->username, userpass->password) < 0) + return -1; + + return 0; +} |
