Use functions instead of macros to get the prio and severity of errors.

This commit is contained in:
Vreixo Formoso
2008-02-04 02:16:12 +01:00
parent 3510f56966
commit ffd5727bee
4 changed files with 69 additions and 33 deletions

View File

@ -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);
}