AERN: Authenticated Encrypted Relay Network 1.0.0.0a (A1)
A post quantum authenticated and encrypted proxy chain network
menu.h File Reference

The AERN console menu functions. More...

#include "aerncommon.h"
#include "commands.h"

Go to the source code of this file.

Functions

AERN_EXPORT_API const char * aern_menu_get_prompt (aern_console_modes mode)
 Returns the console prompt string.
AERN_EXPORT_API void aern_menu_print_error (aern_protocol_errors error, aern_console_modes mode, const char *host)
 Print an error message to the console.
AERN_EXPORT_API void aern_menu_print_message (const char *message, aern_console_modes mode, const char *host)
 Print a message to the console.
AERN_EXPORT_API bool aern_menu_print_message_confirm (const char *message, aern_console_modes mode, const char *host)
 Print a message to the console and wait for confirmation.
AERN_EXPORT_API void aern_menu_print_predefined_message (aern_application_messages msgnum, aern_console_modes mode, const char *host)
 Print a predefined message to the console.
AERN_EXPORT_API bool aern_menu_print_predefined_message_confirm (aern_application_messages msgnum, aern_console_modes mode, const char *host)
 Print a predefined message to the console and wait for confirmation.
AERN_EXPORT_API void aern_menu_print_prompt (aern_console_modes mode, const char *host)
 Print the application prompt.
AERN_EXPORT_API void aern_menu_print_prompt_text (const char *message, aern_console_modes mode, const char *host)
 Print a prompt and text with no line terminator.
AERN_EXPORT_API void aern_menu_print_predefined_text (aern_application_messages msgnum, aern_console_modes mode, const char *host)
 Print a predefined message with no line terminator.
AERN_EXPORT_API void aern_menu_print_text (const char *message)
 Print a text string to the console without a newline.
AERN_EXPORT_API void aern_menu_print_text_line (const char *message)
 Print a text string to the console with a newline.
AERN_EXPORT_API void aern_menu_print_prompt_empty (void)
 Print the application prompt on an empty line.

Detailed Description

The AERN console menu functions.

This module provides functions for printing prompts, messages, and errors to the AERN console. These functions are used to interact with the user by displaying status messages, predefined texts, and user confirmations.

The functions include:

  • Retrieving the prompt string for a given console mode.
  • Printing error messages derived from protocol error codes.
  • Printing plain text messages and predefined messages.
  • Printing prompts (with or without text) to the console.

All messages are printed in plain ASCII. No Unicode characters are used.

Example usage:

// Get and print the console prompt for configuration mode.
qsc_consoleutils_print_safe(prompt);
// Print an error message based on a protocol error.
// Print a predefined message and wait for confirmation.
if (aern_menu_print_predefined_message_confirm(aern_application_log_backup, aern_console_mode_config, "Host1"))
{
// Proceed with backup...
}
@ aern_protocol_error_invalid_request
Definition aern.h:1263
@ aern_console_mode_config
Definition commands.h:335
AERN_EXPORT_API void aern_menu_print_error(aern_protocol_errors error, aern_console_modes mode, const char *host)
Print an error message to the console.
Definition menu.c:14
AERN_EXPORT_API bool aern_menu_print_predefined_message_confirm(aern_application_messages msgnum, aern_console_modes mode, const char *host)
Print a predefined message to the console and wait for confirmation.
Definition menu.c:115
AERN_EXPORT_API const char * aern_menu_get_prompt(aern_console_modes mode)
Returns the console prompt string.
Definition menu.c:9

Function Documentation

◆ aern_menu_get_prompt()

AERN_EXPORT_API const char * aern_menu_get_prompt ( aern_console_modes mode)

Returns the console prompt string.

This function returns the appropriate prompt string based on the specified console mode. The prompt is selected from an internal array of mode strings.

Parameters
modeThe current console mode.
Returns
A pointer to the prompt string.

◆ aern_menu_print_error()

AERN_EXPORT_API void aern_menu_print_error ( aern_protocol_errors error,
aern_console_modes mode,
const char * host )

Print an error message to the console.

This function converts a protocol error code into a descriptive string and prints it to the console. It prints the prompt first (based on the mode and host) and then the error message.

Parameters
errorThe protocol error enumerator.
modeThe current console mode.
hostThe host name.

◆ aern_menu_print_message()

AERN_EXPORT_API void aern_menu_print_message ( const char * message,
aern_console_modes mode,
const char * host )

Print a message to the console.

This function prints the given message string to the console. It first prints the prompt (using the current mode and host) and then the message on a new line.

Parameters
messageThe message string to print.
modeThe current console mode.
hostThe host name.

◆ aern_menu_print_message_confirm()

AERN_EXPORT_API bool aern_menu_print_message_confirm ( const char * message,
aern_console_modes mode,
const char * host )

Print a message to the console and wait for confirmation.

This function prints a message and then waits for the user to input a single character. If the user enters 'y' or 'Y', the function returns true.

Parameters
messageThe message string.
modeThe current console mode.
hostThe host name.
Returns
True if the user confirms (answers 'y' or 'Y'); false otherwise.

◆ aern_menu_print_predefined_message()

AERN_EXPORT_API void aern_menu_print_predefined_message ( aern_application_messages msgnum,
aern_console_modes mode,
const char * host )

Print a predefined message to the console.

This function prints a message that is predefined in the AERN application. The message is chosen based on the msgnum parameter.

Parameters
msgnumThe predefined message enumerator.
modeThe current console mode.
hostThe host name.

◆ aern_menu_print_predefined_message_confirm()

AERN_EXPORT_API bool aern_menu_print_predefined_message_confirm ( aern_application_messages msgnum,
aern_console_modes mode,
const char * host )

Print a predefined message to the console and wait for confirmation.

This function prints a predefined message and then waits for the user to provide confirmation. A response of 'y' or 'Y' returns true.

Parameters
msgnumThe predefined message enumerator.
modeThe current console mode.
hostThe host name.
Returns
True if the user confirms; false otherwise.

◆ aern_menu_print_predefined_text()

AERN_EXPORT_API void aern_menu_print_predefined_text ( aern_application_messages msgnum,
aern_console_modes mode,
const char * host )

Print a predefined message with no line terminator.

This function prints a predefined message (as defined in the AERN application messages) without a newline at the end.

Parameters
msgnumThe predefined message enumerator.
modeThe current console mode.
hostThe host name.

◆ aern_menu_print_prompt()

AERN_EXPORT_API void aern_menu_print_prompt ( aern_console_modes mode,
const char * host )

Print the application prompt.

This function prints the application prompt string to the console using the current console mode and host name.

Parameters
modeThe current console mode.
hostThe host name.

◆ aern_menu_print_prompt_empty()

AERN_EXPORT_API void aern_menu_print_prompt_empty ( void )

Print the application prompt on an empty line.

This function prints the default application prompt on a new line.

◆ aern_menu_print_prompt_text()

AERN_EXPORT_API void aern_menu_print_prompt_text ( const char * message,
aern_console_modes mode,
const char * host )

Print a prompt and text with no line terminator.

This function prints a prompt followed by a message string. The message is printed without appending a newline character.

Parameters
messageThe message string to print.
modeThe current console mode.
hostThe host name.

◆ aern_menu_print_text()

AERN_EXPORT_API void aern_menu_print_text ( const char * message)

Print a text string to the console without a newline.

This function prints the specified text string using a safe console print, without appending a newline.

Parameters
messageThe message string to print.

◆ aern_menu_print_text_line()

AERN_EXPORT_API void aern_menu_print_text_line ( const char * message)

Print a text string to the console with a newline.

This function prints the specified text string and then appends a newline.

Parameters
messageThe message string to print.