#include "mbs_define.h"
#include "mbs_message.h"
#include <stdio.h>
#include <stdlib.h>
#include <stdarg.h>
Functions | |
void | mbs_msg_default (const char *msg) |
void | mbs_warning_msg_default (const char *msg) |
void | mbs_error_msg_default (int err, const char *msg) |
Low-level error function terminating the process if an error is raised. More... | |
void | mbs_error_msg_continue (int err, const char *msg) |
Low-level error function allowing process to continue if an error is raised. More... | |
void | mbs_set_msg_fct_ptr (mbs_msg_fct_ptr msg_fct) |
Set the function that send messages. More... | |
void | mbs_set_warning_msg_fct_ptr (mbs_msg_fct_ptr msg_fct) |
Set the function that send warning messages. More... | |
void | mbs_set_error_msg_fct_ptr (mbs_err_fct_ptr msg_fct) |
Set the function that send error messages. More... | |
char * | mbs_concatenate_to_char (const char *msg, va_list arg) |
Generate a string containing the message and the optionnal formatted value. More... | |
void | mbs_msg (const char *msg,...) |
Send a message. More... | |
void | mbs_warning_msg (const char *msg,...) |
Send a warning message. More... | |
void | mbs_error_msg_v (int v_opt, int err, const char *msg,...) |
Send an error message except if error message are disabled. More... | |
void | mbs_error_msg (int err, const char *msg,...) |
Send an error message. More... | |
void | mbs_msg_v (int v_opt, int v_lvl, const char *msg,...) |
Send a message only of the message level is lower than the verbosity option. More... | |
Variables | |
mbs_msg_fct_ptr | mbs_msg_ptr = mbs_msg_default |
mbs_msg_fct_ptr | mbs_warning_msg_ptr = mbs_warning_msg_default |
mbs_err_fct_ptr | mbs_error_msg_ptr = mbs_error_msg_default |
char* mbs_concatenate_to_char | ( | const char * | msg, |
va_list | arg | ||
) |
Generate a string containing the message and the optionnal formatted value.
The returned char* must be freed.
msg | the string containing the message to send. It can optionally contain format tag (with %). The corresponding additional parameters must be passed to the function. |
void mbs_error_msg | ( | int | err, |
const char * | msg, | ||
... | |||
) |
Send an error message.
Send the error message passed by the user. Then it calls the setted error message function. The default behaviour of the error function is to print the message prefixed with MBS-ERROR to the console and to stop the application.
This behaviour may be overidden using the mbs_set_error_msg_fct_ptr() function.
err | The error code that will be returned by the executable.
|
void mbs_error_msg_continue | ( | int | err, |
const char * | msg | ||
) |
Low-level error function allowing process to continue if an error is raised.
This function is not used by default, to use it assign it as default with the function mbs_set_error_msg_fct_ptr().
err | The error code value. |
msg | the string containing the message to send. |
void mbs_error_msg_default | ( | int | err, |
const char * | msg | ||
) |
Low-level error function terminating the process if an error is raised.
This function is used by default.
[in] | err | The error code value, the raised signal depends of the error code:
|
This is done to raise MBsysC default error code (max -1, min -999) in the 1->127 range required by most system. Such simplification still provide module and middle error level information.
msg | the string containing the message to send. |
void mbs_error_msg_v | ( | int | v_opt, |
int | err, | ||
const char * | msg, | ||
... | |||
) |
Send an error message except if error message are disabled.
Send the error message passed by the user if the verbosity option is high enough (greather or equal to 0). Then it calls the setted error message function. The default behaviour of the error function is to print the message prefixed with MBS-ERROR to the console and to stop the application.
This behaviour may be overidden using the mbs_set_error_msg_fct_ptr() function.
[in] | v_opt | The verbosity level option of the caller, must be at least 0 for the error function to be called. |
[in] | err | The error code to be returned by the executable. As executable must return value between 0 and 256, the error code may be altered. |
[in] | msg | The string containing the message to send. It can optionally contains format tag (with %). The corresponding additional parameters must be passed to the function. |
void mbs_msg | ( | const char * | msg, |
... | |||
) |
Send a message.
Send the message passed by the user. Default behaviour is to print the message to the console. This behaviour may be overidden using the mbs_set_msg_fct function.
msg
the string containing the message to send. It can optionally contain format tag (with %). The corresponding additional parameters must be passed to the function. void mbs_msg_default | ( | const char * | msg | ) |
void mbs_msg_v | ( | int | v_opt, |
int | v_lvl, | ||
const char * | msg, | ||
... | |||
) |
Send a message only of the message level is lower than the verbosity option.
Lowest level are error, higest levels are chatting.
This function avoid multiple testing line in caller source file.
[in] | v_opt | The verbosity option of the caller module. |
[in] | v_lvl | The level of the message. |
[in] | msg | The string containing the message to send. It can contain format tag (with %). |
[in] | ... | The arguments for format specification in the msg . |
void mbs_set_error_msg_fct_ptr | ( | mbs_err_fct_ptr | msg_fct | ) |
Set the function that send error messages.
msg_fct
the new message function void mbs_set_msg_fct_ptr | ( | mbs_msg_fct_ptr | msg_fct | ) |
Set the function that send messages.
msg_fct
the new message function void mbs_set_warning_msg_fct_ptr | ( | mbs_msg_fct_ptr | msg_fct | ) |
Set the function that send warning messages.
msg_fct
the new message function void mbs_warning_msg | ( | const char * | msg, |
... | |||
) |
Send a warning message.
Send the message passed by the user. Default behaviour is to print the message prefixed with MBS-WARNING to the console. This behaviour may be overidden using the mbs_set_warning_msg_fct function.
msg
the string containing the message to send. It can optionally contain format tag (with %). The corresponding additional parameters must be passed to the function. void mbs_warning_msg_default | ( | const char * | msg | ) |
mbs_err_fct_ptr mbs_error_msg_ptr = mbs_error_msg_default |
mbs_msg_fct_ptr mbs_msg_ptr = mbs_msg_default |
mbs_msg_fct_ptr mbs_warning_msg_ptr = mbs_warning_msg_default |