DKTP: Dual Key Tunneling Protocol 1.0.0.0a (A1)
A quantum secure dual-key encrypted tunneling protocol
|
DKTP logging functions. More...
#include "dktpcommon.h"
Go to the source code of this file.
Macros | |
#define | DKTP_LOGGING_MESSAGE_MAX 256U |
Maximum length of a log message. |
Functions | |
bool | dktp_logger_exists (void) |
Check if the DKTP log file exists. | |
void | dktp_logger_initialize (const char *path) |
Initialize the DKTP logger. | |
void | dktp_logger_print (void) |
Print the contents of the DKTP log file. | |
void | dktp_logger_read (char *output, size_t otplen) |
Read the DKTP log file into a provided buffer. | |
void | dktp_logger_reset (void) |
Reset the DKTP log. | |
size_t | dktp_logger_size (void) |
Get the current size of the DKTP log file. | |
bool | dktp_logger_write (const char *message) |
Write a message to the DKTP log file. | |
bool | dktp_logger_test (void) |
Run a manual test of the DKTP logger functions. |
DKTP logging functions.
This header file defines the internal logging functions for the Dual Key Tunneling Protocol (DKTP). The logging subsystem provides basic functionality to create, manage, and inspect log files. These functions allow the DKTP system to record operational events, errors, and other informational messages which can be used for debugging and monitoring purposes.
The following constants are defined:
DKTP_LOGGING_MESSAGE_MAX:
Maximum length allowed for a single log message.DKTP_LOGGER_PATH:
The default directory path for DKTP log files.DKTP_LOGGER_FILE:
The default filename for the DKTP log.DKTP_LOGGER_HEAD:
The header string for the log file, which typically includes version information.#define DKTP_LOGGING_MESSAGE_MAX 256U |
Maximum length of a log message.
This macro defines the maximum number of characters that a single log message may contain.
bool dktp_logger_exists | ( | void | ) |
Check if the DKTP log file exists.
This function checks for the existence of the DKTP log file in the configured logging directory.
void dktp_logger_initialize | ( | const char * | path | ) |
Initialize the DKTP logger.
This function initializes the logging subsystem by setting the log file path and creating the log file if it does not already exist. The default header (DKTP_LOGGER_HEAD
) is written to the log file upon initialization.
path | The file path or directory where the log file should be created. |
void dktp_logger_print | ( | void | ) |
Print the contents of the DKTP log file.
This function outputs the entire contents of the DKTP log file to the standard output or designated debug stream. It is useful for real-time monitoring and debugging purposes.
void dktp_logger_read | ( | char * | output, |
size_t | otplen ) |
Read the DKTP log file into a provided buffer.
This function reads the content of the DKTP log file and copies it into the specified output buffer. The caller must ensure that the output buffer is large enough to hold the log data, up to otplen
bytes.
output | A pointer to the buffer where the log content will be stored. |
otplen | The size, in bytes, of the output buffer. |
void dktp_logger_reset | ( | void | ) |
Reset the DKTP log.
This function erases all the contents of the DKTP log file, effectively resetting it to an empty state. This operation is useful for clearing old log data before starting a new session.
size_t dktp_logger_size | ( | void | ) |
Get the current size of the DKTP log file.
This function returns the size of the log file in bytes. It can be used to monitor log growth and manage log rotation.
bool dktp_logger_test | ( | void | ) |
Run a manual test of the DKTP logger functions.
This function performs a series of tests on the DKTP logging subsystem. The test routine includes:
The function returns true if all logger operations work as expected.
bool dktp_logger_write | ( | const char * | message | ) |
Write a message to the DKTP log file.
This function writes the specified log message to the DKTP log file. The message should be a null-terminated string, and its length should not exceed DKTP_LOGGING_MESSAGE_MAX
characters.
message | [const] The log message to be written. |