Merge changes from Thomas (ticket #125). Minor changes on merge.

This commit is contained in:
Vreixo Formoso 2008-02-22 21:42:17 +01:00
commit e80ae930ea
2 changed files with 111 additions and 0 deletions

View File

@ -2526,6 +2526,63 @@ int iso_set_msgs_severities(char *queue_severity, char *print_severity,
int iso_obtain_msgs(char *minimum_severity, int *error_code, int *imgid,
char msg_text[], char severity[]);
/**
* Submit a message to the libisofs queueing system. It will be queued or
* printed as if it was generated by libisofs itself.
*
* @param error_code
* The unique error code of your message.
* Submit 0 if you do not have reserved error codes within the libburnia
* project.
* @param msg_text
* Not more than ISO_MSGS_MESSAGE_LEN characters of message text.
* @param os_errno
* Eventual errno related to the message. Submit 0 if the message is not
* related to a operating system error.
* @param severity
* One of "ABORT", "FATAL", "FAILURE", "SORRY", "WARNING", "HINT", "NOTE",
* "UPDATE", "DEBUG". Defaults to "FATAL".
* @param origin
* Submit 0 for now.
* @return
* 1 if message was delivered, <=0 if failure
*
* @since 0.6.4
*/
int iso_msgs_submit(int error_code, char msg_text[], int os_errno,
char severity[], int origin);
/**
* Convert a severity name into a severity number, which gives the severity
* rank of the name.
*
* @param severity_name
* A name as with iso_msgs_submit(), e.g. "SORRY".
* @param severity_number
* The rank number: the higher, the more severe.
* @return
* >0 success, <=0 failure
*
* @since 0.6.4
*/
int iso_text_to_sev(char *severity_name, int *severity_number);
/**
* Convert a severity number into a severity name
*
* @param severity_number
* The rank number: the higher, the more severe.
* @param severity_name
* A name as with iso_msgs_submit(), e.g. "SORRY".
*
* @since 0.6.4
*/
int iso_sev_to_text(int severity_number, char **severity_name);
/**
* Get the id of an IsoImage, used for message reporting. This message id,
* retrieved with iso_obtain_msgs(), can be used to distinguish what

View File

@ -335,6 +335,60 @@ int iso_obtain_msgs(char *minimum_severity, int *error_code, int *imgid,
return ret;
}
/* ts A80222 : derived from libburn/init.c:burn_msgs_submit()
*/
int iso_msgs_submit(int error_code, char msg_text[], int os_errno,
char severity[], int origin)
{
int ret, sevno;
ret = libiso_msgs__text_to_sev(severity, &sevno, 0);
if (ret <= 0)
sevno = LIBISO_MSGS_SEV_FATAL;
if (error_code <= 0) {
switch(sevno) {
case LIBISO_MSGS_SEV_ABORT: error_code = 0x00040000;
break; case LIBISO_MSGS_SEV_FATAL: error_code = 0x00040001;
break; case LIBISO_MSGS_SEV_SORRY: error_code = 0x00040002;
break; case LIBISO_MSGS_SEV_WARNING: error_code = 0x00040003;
break; case LIBISO_MSGS_SEV_HINT: error_code = 0x00040004;
break; case LIBISO_MSGS_SEV_NOTE: error_code = 0x00040005;
break; case LIBISO_MSGS_SEV_UPDATE: error_code = 0x00040006;
break; case LIBISO_MSGS_SEV_DEBUG: error_code = 0x00040007;
break; default: error_code = 0x00040008;
}
}
ret = libiso_msgs_submit(libiso_msgr, origin, error_code,
sevno, LIBISO_MSGS_PRIO_HIGH, msg_text, os_errno, 0);
return ret;
}
/* ts A80222 : derived from libburn/init.c:burn_text_to_sev()
*/
int iso_text_to_sev(char *severity_name, int *sevno)
{
int ret;
ret = libiso_msgs__text_to_sev(severity_name, sevno, 0);
if (ret <= 0)
*sevno = LIBISO_MSGS_SEV_FATAL;
return ret;
}
/* ts A80222 : derived from libburn/init.c:burn_sev_to_text()
*/
int iso_sev_to_text(int severity_number, char **severity_name)
{
int ret;
ret = libiso_msgs__sev_to_text(severity_number, severity_name, 0);
return ret;
}
/**
* Return the messenger object handle used by libisofs. This handle
* may be used by related libraries to their own compatible