Debian Codegraph @

src/oidc-gen/promptAndSet/clientid.c

raw
1 #include "_helper.h"
2 #include "account/account.h"
3 #include "promptAndSet.h"
4 #include "utils/string/stringUtils.h"
5
6 void askOrNeedClientId(struct oidc_account* account,
7 const struct arguments* arguments, int optional) {
8 if (readClientId(account, arguments)) {
9 return;
10 }
11 ERROR_IF_NO_PROMPT(optional, ERROR_MESSAGE("client id", OPT_LONG_CLIENTID));
12 char* cid =
13 _gen_prompt("Client_id", account_getClientId(account), 0, optional);
14 if (cid) {
15 account_setClientId(account, cid);
16 }
17 }
18
19 int readClientId(struct oidc_account* account,
20 const struct arguments* arguments) {
21 if (arguments->client_id) {
22 account_setClientId(account, oidc_strcopy(arguments->client_id));
23 return 1;
24 }
25 if (prompt_mode() == 0 && strValid(account_getClientId(account))) {
26 return 1;
27 }
28 return 0;
29 }
30
31 void askClientId(struct oidc_account* account,
32 const struct arguments* arguments) {
33 return askOrNeedClientId(account, arguments, 1);
34 }
35
36 void needClientId(struct oidc_account* account,
37 const struct arguments* arguments) {
38 return askOrNeedClientId(account, arguments, 0);
39 }