OpenVPN
console.h
Go to the documentation of this file.
1/*
2 * OpenVPN -- An application to securely tunnel IP networks
3 * over a single UDP port, with support for SSL/TLS-based
4 * session authentication and key exchange,
5 * packet encryption, packet authentication, and
6 * packet compression.
7 *
8 * Copyright (C) 2002-2024 OpenVPN Inc <sales@openvpn.net>
9 * Copyright (C) 2014-2015 David Sommerseth <davids@redhat.com>
10 * Copyright (C) 2016-2024 David Sommerseth <davids@openvpn.net>
11 *
12 * This program is free software; you can redistribute it and/or modify
13 * it under the terms of the GNU General Public License version 2
14 * as published by the Free Software Foundation.
15 *
16 * This program is distributed in the hope that it will be useful,
17 * but WITHOUT ANY WARRANTY; without even the implied warranty of
18 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
19 * GNU General Public License for more details.
20 *
21 * You should have received a copy of the GNU General Public License along
22 * with this program; if not, write to the Free Software Foundation, Inc.,
23 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24 */
25
26#ifndef CONSOLE_H
27#define CONSOLE_H
28
29#include "basic.h"
30
35 char *prompt;
36 size_t prompt_len;
37 char *response;
38 size_t response_len;
39 bool echo;
40};
41
42#define QUERY_USER_NUMSLOTS 10
43extern struct _query_user query_user[];
49void query_user_clear(void);
50
51
62void query_user_add(char *prompt, size_t prompt_len,
63 char *resp, size_t resp_len,
64 bool echo);
65
66
75
76
77#if defined(ENABLE_SYSTEMD)
86bool query_user_exec_systemd(void);
87
94static inline bool
96{
97 return query_user_exec_systemd();
98}
99
100#else /* ENABLE_SYSTEMD not defined */
106static inline bool
108{
110}
111#endif /* defined(ENABLE_SYSTEMD) */
112
113
121static inline bool
123 char *resp, size_t resp_len,
124 bool echo)
125{
127 query_user_add(prompt, prompt_len, resp, resp_len, echo);
128 return query_user_exec();
129}
130
131#endif /* ifndef CONSOLE_H */
void query_user_clear(void)
Wipes all data put into all of the query_user structs.
Definition console.c:45
bool query_user_exec_builtin(void)
Loop through configured query_user slots, using the built-in method for querying the user.
struct _query_user query_user[]
Global variable, declared in console.c.
Definition console.c:41
static bool query_user_exec(void)
Wrapper function enabling query_user_exec() if no alternative methods have been enabled.
Definition console.h:107
static bool query_user_SINGLE(char *prompt, size_t prompt_len, char *resp, size_t resp_len, bool echo)
A plain "make Gert happy" wrapper.
Definition console.h:122
void query_user_add(char *prompt, size_t prompt_len, char *resp, size_t resp_len, bool echo)
Adds an item to ask the user for.
Definition console.c:57
Configuration setup for declaring what kind of information to ask a user for.
Definition console.h:34
char * prompt
Prompt to present to the user.
Definition console.h:35
size_t prompt_len
Length of the prompt string.
Definition console.h:36
size_t response_len
Length the of the user response.
Definition console.h:38
char * response
The user's response.
Definition console.h:37
bool echo
True: The user should see what is being typed, otherwise mask it.
Definition console.h:39