MPDC: Multi Party Domain Cryptosystem 1.0.0.0b (A0)
MPDC Interior protocol
menu.h File Reference

The MPDC console menu functions. More...

#include "common.h"
#include "commands.h"

Go to the source code of this file.

Functions

MPDC_EXPORT_API const char * mpdc_menu_get_prompt (mpdc_console_modes mode)
 Returns the console prompt string.
 
MPDC_EXPORT_API void mpdc_menu_print_error (mpdc_protocol_errors error, mpdc_console_modes mode, const char *host)
 Print an error message to the console.
 
MPDC_EXPORT_API void mpdc_menu_print_message (const char *message, mpdc_console_modes mode, const char *host)
 Print a message to the console.
 
MPDC_EXPORT_API bool mpdc_menu_print_message_confirm (const char *message, mpdc_console_modes mode, const char *host)
 Print a message to the console and wait for confirmation.
 
MPDC_EXPORT_API void mpdc_menu_print_predefined_message (mpdc_application_messages msgnum, mpdc_console_modes mode, const char *host)
 Print a predefined message to the console.
 
MPDC_EXPORT_API bool mpdc_menu_print_predefined_message_confirm (mpdc_application_messages msgnum, mpdc_console_modes mode, const char *host)
 Print a predefined message to the console and wait for confirmation.
 
MPDC_EXPORT_API void mpdc_menu_print_prompt (mpdc_console_modes mode, const char *host)
 Print the application prompt.
 
MPDC_EXPORT_API void mpdc_menu_print_prompt_text (const char *message, mpdc_console_modes mode, const char *host)
 Print a prompt and text with no line terminator.
 
MPDC_EXPORT_API void mpdc_menu_print_predefined_text (mpdc_application_messages msgnum, mpdc_console_modes mode, const char *host)
 Print a predefined message with no line terminator.
 
MPDC_EXPORT_API void mpdc_menu_print_text (const char *message)
 Print a text string to the console without a newline.
 
MPDC_EXPORT_API void mpdc_menu_print_text_line (const char *message)
 Print a text string to the console with a newline.
 
MPDC_EXPORT_API void mpdc_menu_print_prompt_empty ()
 Print the application prompt on an empty line.
 

Detailed Description

The MPDC console menu functions.

This module provides functions for printing prompts, messages, and errors to the MPDC 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 (mpdc_menu_print_predefined_message_confirm(mpdc_application_log_backup, mpdc_console_mode_config, "Host1"))
{
// Proceed with backup...
}
@ mpdc_console_mode_config
Definition commands.h:335
MPDC_EXPORT_API const char * mpdc_menu_get_prompt(mpdc_console_modes mode)
Returns the console prompt string.
Definition menu.c:9
MPDC_EXPORT_API bool mpdc_menu_print_predefined_message_confirm(mpdc_application_messages msgnum, mpdc_console_modes mode, const char *host)
Print a predefined message to the console and wait for confirmation.
Definition menu.c:115
MPDC_EXPORT_API void mpdc_menu_print_error(mpdc_protocol_errors error, mpdc_console_modes mode, const char *host)
Print an error message to the console.
Definition menu.c:14
@ mpdc_protocol_error_invalid_request
Definition mpdc.h:1238

Function Documentation

◆ mpdc_menu_get_prompt()

MPDC_EXPORT_API const char * mpdc_menu_get_prompt ( mpdc_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.

◆ mpdc_menu_print_error()

MPDC_EXPORT_API void mpdc_menu_print_error ( mpdc_protocol_errors error,
mpdc_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.

◆ mpdc_menu_print_message()

MPDC_EXPORT_API void mpdc_menu_print_message ( const char * message,
mpdc_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.

◆ mpdc_menu_print_message_confirm()

MPDC_EXPORT_API bool mpdc_menu_print_message_confirm ( const char * message,
mpdc_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.

◆ mpdc_menu_print_predefined_message()

MPDC_EXPORT_API void mpdc_menu_print_predefined_message ( mpdc_application_messages msgnum,
mpdc_console_modes mode,
const char * host )

Print a predefined message to the console.

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

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

◆ mpdc_menu_print_predefined_message_confirm()

MPDC_EXPORT_API bool mpdc_menu_print_predefined_message_confirm ( mpdc_application_messages msgnum,
mpdc_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.

◆ mpdc_menu_print_predefined_text()

MPDC_EXPORT_API void mpdc_menu_print_predefined_text ( mpdc_application_messages msgnum,
mpdc_console_modes mode,
const char * host )

Print a predefined message with no line terminator.

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

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

◆ mpdc_menu_print_prompt()

MPDC_EXPORT_API void mpdc_menu_print_prompt ( mpdc_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.

◆ mpdc_menu_print_prompt_empty()

MPDC_EXPORT_API void mpdc_menu_print_prompt_empty ( )

Print the application prompt on an empty line.

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

◆ mpdc_menu_print_prompt_text()

MPDC_EXPORT_API void mpdc_menu_print_prompt_text ( const char * message,
mpdc_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.

◆ mpdc_menu_print_text()

MPDC_EXPORT_API void mpdc_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.

◆ mpdc_menu_print_text_line()

MPDC_EXPORT_API void mpdc_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.