Robotran C Documentation
Functions | Variables
mbs_message.c File Reference
#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
 

Function Documentation

◆ mbs_concatenate_to_char()

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.

Parameters
msgthe string containing the message to send. It can optionally contain format tag (with %). The corresponding additional parameters must be passed to the function.
Returns
A string containing the message and all the formatted variable.

◆ mbs_error_msg()

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.

Parameters
errThe error code that will be returned by the executable.
  • 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.

◆ mbs_error_msg_continue()

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().

Parameters
errThe error code value.
msgthe string containing the message to send.

◆ mbs_error_msg_default()

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.

Parameters
[in]errThe error code value, the raised signal depends of the error code:
  • For error codes in [-1; -9] the defaut 1 value is raised.
  • For negative error code (lower than -9), the integer division -err / 10 is raised
  • Other error code are raised unmodified.

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.

Parameters
msgthe string containing the message to send.

◆ mbs_error_msg_v()

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.

Parameters
[in]v_optThe verbosity level option of the caller, must be at least 0 for the error function to be called.
[in]errThe error code to be returned by the executable. As executable must return value between 0 and 256, the error code may be altered.
[in]msgThe string containing the message to send. It can optionally contains format tag (with %). The corresponding additional parameters must be passed to the function.

◆ mbs_msg()

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.

◆ mbs_msg_default()

void mbs_msg_default ( const char *  msg)

◆ mbs_msg_v()

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.

Parameters
[in]v_optThe verbosity option of the caller module.
[in]v_lvlThe level of the message.
[in]msgThe string containing the message to send. It can contain format tag (with %).
[in]...The arguments for format specification in the msg.

◆ mbs_set_error_msg_fct_ptr()

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

◆ mbs_set_msg_fct_ptr()

void mbs_set_msg_fct_ptr ( mbs_msg_fct_ptr  msg_fct)

Set the function that send messages.

  • msg_fct the new message function

◆ mbs_set_warning_msg_fct_ptr()

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

◆ mbs_warning_msg()

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.

◆ mbs_warning_msg_default()

void mbs_warning_msg_default ( const char *  msg)

Variable Documentation

◆ mbs_error_msg_ptr

◆ mbs_msg_ptr

◆ mbs_warning_msg_ptr