OpenVPN
Functions
console_builtin.c File Reference
#include "syshead.h"
#include "console.h"
#include "error.h"
#include "buffer.h"
#include "misc.h"
#include "win32.h"
Include dependency graph for console_builtin.c:

Go to the source code of this file.

Functions

static bool get_console_input_win32 (const char *prompt, const bool echo, char *input, const int capacity)
 Get input from a Windows console. More...
 
static bool get_console_input (const char *prompt, const bool echo, char *input, const int capacity)
 Core function for getting input from console. More...
 
bool query_user_exec_builtin (void)
 Wrapper function enabling query_user_exec() if no alternative methods have been enabled. More...
 

Function Documentation

◆ get_console_input()

static bool get_console_input ( const char *  prompt,
const bool  echo,
char *  input,
const int  capacity 
)
static

Core function for getting input from console.

@params prompt The prompt to present to the user @params echo Should the user see what is being typed @params input Pointer to the buffer used to save the user input @params capacity Size of the input buffer

Returns
Returns True if user input was gathered

Definition at line 195 of file console_builtin.c.

References ASSERT, chomp(), _query_user::echo, get_console_input_win32(), M_ERRNO, M_FATAL, M_WARN, msg, and _query_user::prompt.

Referenced by query_user_exec_builtin().

◆ get_console_input_win32()

static bool get_console_input_win32 ( const char *  prompt,
const bool  echo,
char *  input,
const int  capacity 
)
static

Get input from a Windows console.

Parameters
promptPrompt to display to the user
echoShould the user input be displayed in the console
inputPointer to the buffer the user input will be saved
capacitySize of the buffer for the user input
Returns
Return false on input error, or if service exit event is signaled.

Definition at line 61 of file console_builtin.c.

References ASSERT, chomp(), _query_user::echo, get_orig_stderr(), M_ERRNO, M_WARN, msg, orig_stderr, _query_user::prompt, status, string_null_terminate(), and win32_service_interrupt().

Referenced by get_console_input().

◆ query_user_exec_builtin()

bool query_user_exec_builtin ( void  )

Wrapper function enabling query_user_exec() if no alternative methods have been enabled.

Executes a configured setup, using the built-in method for querying the user.

Default method for querying user using default stdin/stdout on a console. This needs to be available as a backup interface for the alternative implementations in case they cannot query through their implementation specific methods.

If no alternative implementation is declared, a wrapper in console.h will ensure query_user_exec() will call this function instead.

Definition at line 281 of file console_builtin.c.

References get_console_input(), query_user, QUERY_USER_NUMSLOTS, and _query_user::response.