16 if (!prompt || !password || max_len < 2) {
21 if (!platform_is_interactive()) {
30 if (prompt_width < 0) {
35 int separator_width = (prompt_width > 40) ? prompt_width : 40;
36 char separator[BUFFER_SIZE_SMALL];
37 if (separator_width > (
int)
sizeof(separator) - 1) {
38 separator_width =
sizeof(separator) - 1;
40 for (
int i = 0; i < separator_width; i++) {
43 separator[separator_width] =
'\0';
46 log_plain(
"\n%s", separator);
47 log_plain(
"%s", prompt);
48 log_plain(
"%s", separator);
54 prompt_opts_t opts = PROMPT_OPTS_PASSWORD;
55 int result = platform_prompt_question(
"", password, max_len, opts);
59 log_warn(
"Password contains invalid UTF-8 sequence, input may be corrupted");
64 log_plain(
"%s\n", separator);
71 if (!prompt || !password || max_len < 2) {
76 if (!platform_is_interactive()) {
81 char full_prompt[BUFFER_SIZE_SMALL];
82 size_t prompt_byte_len = strlen(prompt);
83 if (prompt_byte_len >=
sizeof(full_prompt) - 2) {
84 prompt_byte_len =
sizeof(full_prompt) - 3;
86 memcpy(full_prompt, prompt, prompt_byte_len);
87 full_prompt[prompt_byte_len] =
':';
88 full_prompt[prompt_byte_len + 1] =
'\0';
91 prompt_opts_t opts = PROMPT_OPTS_PASSWORD;
92 int result = platform_prompt_question(full_prompt, password, max_len, opts);
96 log_warn(
"Password contains invalid UTF-8 sequence, input may be corrupted");