Debian Codegraph @

src/oidc-gen/promptAndSet/certpath.c

raw
1 #include "_helper.h"
2 #include "account/account.h"
3 #include "promptAndSet.h"
4 #include "utils/string/stringUtils.h"
5
6 void askOrNeedCertPath(struct oidc_account* account,
7 const struct arguments* arguments, int optional) {
8 if (readCertPath(account, arguments)) {
9 return;
10 }
11 if (strValid(account_getCertPath(account))) {
12 optional = 1;
13 }
14 ERROR_IF_NO_PROMPT(optional, ERROR_MESSAGE("cert path", OPT_LONG_CERTPATH));
15 char* res =
16 _gen_prompt("Cert Path", account_getCertPath(account), 0, optional);
17 if (res) {
18 account_setCertPath(account, res);
19 }
20 }
21
22 int readCertPath(struct oidc_account* account,
23 const struct arguments* arguments) {
24 if (arguments->cert_path) {
25 account_setCertPath(account, oidc_strcopy(arguments->cert_path));
26 return 1;
27 }
28 if (prompt_mode() == 0 && strValid(account_getCertPath(account))) {
29 return 1;
30 }
31 if (account_getCertPath(account) == NULL) {
32 account_setOSDefaultCertPath(account);
33 }
34 return 0;
35 }
36
37 void askCertPath(struct oidc_account* account,
38 const struct arguments* arguments) {
39 return askOrNeedCertPath(account, arguments, 1);
40 }
41
42 void needCertPath(struct oidc_account* account,
43 const struct arguments* arguments) {
44 return askOrNeedCertPath(account, arguments, 0);
45 }