Use functions instead of macros to get the prio and severity of errors.
This commit is contained in:
parent
3510f56966
commit
ffd5727bee
@ -74,8 +74,7 @@ error code is associated with a given severity, either "DEBUG", "UPDATE",
|
||||
of each severity take a look at private header "libiso_msgs.h". Errors
|
||||
reported by function return value are always "FAILURE" or "FATAL". Other kind
|
||||
of errors are only reported with the message queue. You can get the severity
|
||||
of any error message with ISO_ERR_SEV() macro [TODO: we need a function to
|
||||
translate error severity to string]
|
||||
of any error message with iso_error_get_severity() function.
|
||||
|
||||
First of all, most libisofs functions return an integer. If such integer is
|
||||
a negative number, it means the function has returned an error. The error code
|
||||
|
@ -2532,6 +2532,35 @@ int iso_image_get_msg_id(IsoImage *image);
|
||||
*/
|
||||
const char *iso_error_to_msg(int errcode);
|
||||
|
||||
/**
|
||||
* Get the severity of a given error code
|
||||
* @return
|
||||
* 0x10000000 -> DEBUG
|
||||
* 0x20000000 -> UPDATE
|
||||
* 0x30000000 -> NOTE
|
||||
* 0x40000000 -> HINT
|
||||
* 0x50000000 -> WARNING
|
||||
* 0x60000000 -> SORRY
|
||||
* 0x68000000 -> FAILURE
|
||||
* 0x70000000 -> FATAL
|
||||
* 0x71000000 -> ABORT
|
||||
*
|
||||
* @since 0.6.2
|
||||
*/
|
||||
int iso_error_get_severity(int e);
|
||||
|
||||
/**
|
||||
* Get the priority of a given error.
|
||||
* @return
|
||||
* 0x00000000 -> ZERO
|
||||
* 0x10000000 -> LOW
|
||||
* 0x20000000 -> MEDIUM
|
||||
* 0x30000000 -> HIGH
|
||||
*
|
||||
* @since 0.6.2
|
||||
*/
|
||||
int iso_error_get_priority(int e);
|
||||
|
||||
/**
|
||||
* Set the minimum error severity that causes a libisofs operation to
|
||||
* be aborted as soon as possible.
|
||||
@ -2890,35 +2919,6 @@ const char *iso_image_fs_get_biblio_file_id(IsoImageFilesystem *fs);
|
||||
|
||||
/************ Error codes and return values for libisofs ********************/
|
||||
|
||||
/*
|
||||
* error codes are 32 bit numbers, that follow the following conventions:
|
||||
*
|
||||
* bit 31 (MSB) -> 1 (to make the value always negative)
|
||||
* bits 30-24 -> Encoded severity (Use ISO_ERR_SEV to translate an error code
|
||||
* to a LIBISO_MSGS_SEV_* constant)
|
||||
* = 0x10 -> DEBUG
|
||||
* = 0x20 -> UPDATE
|
||||
* = 0x30 -> NOTE
|
||||
* = 0x40 -> HINT
|
||||
* = 0x50 -> WARNING
|
||||
* = 0x60 -> SORRY
|
||||
* = 0x68 -> FAILURE
|
||||
* = 0x70 -> FATAL
|
||||
* = 0x71 -> ABORT
|
||||
* bits 23-20 -> Encoded priority (Use ISO_ERR_PRIO to translate an error code
|
||||
* to a LIBISO_MSGS_PRIO_* constant)
|
||||
* = 0x0 -> ZERO
|
||||
* = 0x1 -> LOW
|
||||
* = 0x2 -> MEDIUM
|
||||
* = 0x3 -> HIGH
|
||||
* bits 19-16 -> Reserved for future usage (maybe message ranges)
|
||||
* bits 15-0 -> Error code
|
||||
*/
|
||||
|
||||
#define ISO_ERR_SEV(e) (e & 0x7F000000)
|
||||
#define ISO_ERR_PRIO(e) ((e & 0x00F00000) << 8)
|
||||
#define ISO_ERR_CODE(e) (e & 0x0000FFFF)
|
||||
|
||||
/** successfully execution */
|
||||
#define ISO_SUCCESS 1
|
||||
|
||||
|
@ -10,9 +10,38 @@
|
||||
#include <stdio.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
#include "libiso_msgs.h"
|
||||
#include "libisofs.h"
|
||||
#include "messages.h"
|
||||
|
||||
/*
|
||||
* error codes are 32 bit numbers, that follow the following conventions:
|
||||
*
|
||||
* bit 31 (MSB) -> 1 (to make the value always negative)
|
||||
* bits 30-24 -> Encoded severity (Use ISO_ERR_SEV to translate an error code
|
||||
* to a LIBISO_MSGS_SEV_* constant)
|
||||
* = 0x10 -> DEBUG
|
||||
* = 0x20 -> UPDATE
|
||||
* = 0x30 -> NOTE
|
||||
* = 0x40 -> HINT
|
||||
* = 0x50 -> WARNING
|
||||
* = 0x60 -> SORRY
|
||||
* = 0x68 -> FAILURE
|
||||
* = 0x70 -> FATAL
|
||||
* = 0x71 -> ABORT
|
||||
* bits 23-20 -> Encoded priority (Use ISO_ERR_PRIO to translate an error code
|
||||
* to a LIBISO_MSGS_PRIO_* constant)
|
||||
* = 0x0 -> ZERO
|
||||
* = 0x1 -> LOW
|
||||
* = 0x2 -> MEDIUM
|
||||
* = 0x3 -> HIGH
|
||||
* bits 19-16 -> Reserved for future usage (maybe message ranges)
|
||||
* bits 15-0 -> Error code
|
||||
*/
|
||||
#define ISO_ERR_SEV(e) (e & 0x7F000000)
|
||||
#define ISO_ERR_PRIO(e) ((e & 0x00F00000) << 8)
|
||||
#define ISO_ERR_CODE(e) (e & 0x0000FFFF)
|
||||
|
||||
int iso_message_id = LIBISO_MSGS_ORIGIN_IMAGE_BASE;
|
||||
|
||||
/**
|
||||
@ -312,3 +341,13 @@ void *iso_get_messenger()
|
||||
{
|
||||
return libiso_msgr;
|
||||
}
|
||||
|
||||
int iso_error_get_severity(int e)
|
||||
{
|
||||
return ISO_ERR_SEV(e);
|
||||
}
|
||||
|
||||
int iso_error_get_priority(int e)
|
||||
{
|
||||
return ISO_ERR_PRIO(e);
|
||||
}
|
||||
|
@ -13,8 +13,6 @@
|
||||
#ifndef MESSAGES_H_
|
||||
#define MESSAGES_H_
|
||||
|
||||
#include "libiso_msgs.h"
|
||||
|
||||
/**
|
||||
* Take and increment this variable to get a valid identifier for message
|
||||
* origin.
|
||||
|
Loading…
Reference in New Issue
Block a user