]> git.ipfire.org Git - thirdparty/git.git/blame - credential.h
credential: detect unrepresentable values when parsing urls
[thirdparty/git.git] / credential.h
CommitLineData
abca927d
JK
1#ifndef CREDENTIAL_H
2#define CREDENTIAL_H
3
4#include "string-list.h"
5
6struct credential {
7 struct string_list helpers;
11825072 8 unsigned approved:1,
a78fbb4f 9 configured:1,
59b38652 10 quit:1,
a78fbb4f 11 use_http_path:1;
abca927d
JK
12
13 char *username;
14 char *password;
15 char *protocol;
16 char *host;
17 char *path;
18};
19
20#define CREDENTIAL_INIT { STRING_LIST_INIT_DUP }
21
22void credential_init(struct credential *);
23void credential_clear(struct credential *);
24
25void credential_fill(struct credential *);
26void credential_approve(struct credential *);
27void credential_reject(struct credential *);
28
29int credential_read(struct credential *, FILE *);
2d6dc182 30void credential_write(const struct credential *, FILE *);
c716fe4b
JK
31
32/*
33 * Parse a url into a credential struct, replacing any existing contents.
34 *
35 * Ifthe url can't be parsed (e.g., a missing "proto://" component), the
36 * resulting credential will be empty but we'll still return success from the
37 * "gently" form.
38 *
39 * If we encounter a component which cannot be represented as a credential
40 * value (e.g., because it contains a newline), the "gently" form will return
41 * an error but leave the broken state in the credential object for further
42 * examination. The non-gentle form will issue a warning to stderr and return
43 * an empty credential.
44 */
d3e847c1 45void credential_from_url(struct credential *, const char *url);
c716fe4b
JK
46int credential_from_url_gently(struct credential *, const char *url, int quiet);
47
11825072
JK
48int credential_match(const struct credential *have,
49 const struct credential *want);
abca927d
JK
50
51#endif /* CREDENTIAL_H */