Added API to set the abort severity.

This commit is contained in:
Vreixo Formoso 2008-01-22 22:24:33 +01:00
parent 3530b7d137
commit 164e97f6bc
3 changed files with 29 additions and 1 deletions

View File

@ -143,6 +143,7 @@ int main(int argc, char **argv)
iso_tree_set_ignore_hidden(image, 0);
iso_tree_set_ignore_special(image, 0);
iso_tree_set_stop_on_error(image, 0);
iso_set_abort_severity("SORRY");
result = iso_tree_add_dir_rec(image, iso_image_get_root(image), argv[optind]);
if (result < 0) {

View File

@ -1694,6 +1694,19 @@ int iso_obtain_msgs(char *minimum_severity, int *error_code,
*/
const char *iso_error_to_msg(int errcode);
/**
* Set the minimum error severity that causes a libisofs operation to
* be aborted as soon as possible.
*
* @param severity
* one of "FAILURE", "SORRY", "WARNING", "HINT", "NOTE". Severities
* greater than SORRY always cause program to abort. Severities under
* NOTE won't never cause function abort.
* @return
* Previous abort priority on success, < 0 on error.
*/
int iso_set_abort_severity(char *severity);
/**
* Return the messenger object handle used by libisofs. This handle
* may be used by related libraries to their own compatible

View File

@ -19,7 +19,7 @@ int iso_message_id = LIBISO_MSGS_ORIGIN_IMAGE_BASE;
/**
* Threshold for aborting.
*/
int abort_threshold = LIBISO_MSGS_SEV_HINT;
int abort_threshold = LIBISO_MSGS_SEV_ERROR;
#define MAX_MSG_LEN 4096
@ -41,6 +41,20 @@ void iso_finish()
libiso_msgs_destroy(&libiso_msgr, 0);
}
int iso_set_abort_severity(char *severity)
{
int ret, sevno;
ret = libiso_msgs__text_to_sev(severity, &sevno, 0);
if (ret <= 0)
return ISO_WRONG_ARG_VALUE;
if (sevno > LIBISO_MSGS_SEV_ERROR || sevno < LIBISO_MSGS_SEV_NOTE)
return ISO_WRONG_ARG_VALUE;
ret = abort_threshold;
abort_threshold = sevno;
return ret;
}
void iso_msg_debug(int imgid, const char *fmt, ...)
{
char msg[MAX_MSG_LEN];