(FEA) More macros for Status
This commit is contained in:
@@ -63,6 +63,16 @@ typedef struct _Status {
|
||||
struct _Status *prev;
|
||||
} Status;
|
||||
|
||||
# define DEFSTATUS(i, v, d, c, p)\
|
||||
static const Status i = {\
|
||||
.identity = nameof(i),\
|
||||
.value = v,\
|
||||
.description = d,\
|
||||
.characteristic = c,\
|
||||
.loc = __GLOBAL__,\
|
||||
.prev = (Status *)p\
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
{value "description" characteristic prev}
|
||||
@@ -123,7 +133,7 @@ typedef struct {
|
||||
char *initiator;
|
||||
time_t time;
|
||||
ReportSendingPriority priority;
|
||||
ReportSendingTaskStatus task_status;
|
||||
ReportSendingTaskStatus taskprint_status;
|
||||
FILE *dest; // The destination where the report is sending to.
|
||||
} Report;
|
||||
|
||||
@@ -256,310 +266,139 @@ Status ReportSenderManager_RemoveTask(ReportSendingManager *inst,
|
||||
|
||||
// ---------------------ELEMENTARY-------------------------
|
||||
|
||||
/*
|
||||
typedef struct _Status {
|
||||
char *identity;
|
||||
int value;
|
||||
char *description;
|
||||
int characteristic;
|
||||
Location loc;
|
||||
struct _Status *prev;
|
||||
} Status;
|
||||
*/
|
||||
|
||||
static const Status UnknownStatus = {
|
||||
.identity = nameof(UnknownStatus),
|
||||
.value = -1,
|
||||
.description = "An unknown status.",
|
||||
.characteristic = STATUS_UNKNOWN,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = NULL
|
||||
};
|
||||
|
||||
static const Status NormalStatus = {
|
||||
.identity = nameof(NormalStatus),
|
||||
.value = 0,
|
||||
.description = "A normal status.",
|
||||
.characteristic = STATUS_NORMAL,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = NULL
|
||||
};
|
||||
|
||||
static const Status ErrorStatus = {
|
||||
.identity = nameof(ErrorStatus),
|
||||
.value = 1,
|
||||
.description = "An error status.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = NULL
|
||||
};
|
||||
DEFSTATUS(UnknownStatus, -1, "An unknown status.", STATUS_UNKNOWN, NULL);
|
||||
DEFSTATUS(NormalStatus, 0, "A normal status.", STATUS_NORMAL, NULL);
|
||||
DEFSTATUS(ErrorStatus, 1, "An error status.", STATUS_ERROR, NULL);
|
||||
|
||||
// ----------------------EXTENDED--------------------------
|
||||
|
||||
static const Status MemoryViolation = (Status){
|
||||
.identity = nameof(MemoryViolation),
|
||||
.value = 1,
|
||||
.description = "Illegal access on certain memory address.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = (Status *)&ErrorStatus
|
||||
};
|
||||
DEFSTATUS(MemoryViolation, 1,
|
||||
"Illegal access on certain memory address.",
|
||||
STATUS_ERROR, &ErrorStatus);
|
||||
|
||||
static const Status NullPointerAccounted = (Status){
|
||||
.identity = nameof(NullPointerAccounted),
|
||||
.value = 1,
|
||||
.description = "An involving null pointer was not accepted.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = (Status *)&MemoryViolation
|
||||
};
|
||||
DEFSTATUS(NullPointerAccounted, 1,
|
||||
"An involving null pointer was not accepted.",
|
||||
STATUS_ERROR, &MemoryViolation);
|
||||
|
||||
static const Status InvalidObject = (Status){
|
||||
.identity = nameof(InvalidObject),
|
||||
.value = 1,
|
||||
.description = "An invalid object was presented.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = (Status *)&ErrorStatus
|
||||
};
|
||||
DEFSTATUS(InvalidObject, 1,
|
||||
"An invalid object was presented.",
|
||||
STATUS_ERROR, &ErrorStatus);
|
||||
|
||||
static const Status UnavailableObject = (Status){
|
||||
.identity = nameof(UnavailableObject),
|
||||
.value = 1,
|
||||
.description = "An unavailable object was presented.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = (Status *)&ErrorStatus
|
||||
};
|
||||
DEFSTATUS(UnavailableObject, 1,
|
||||
"An unavailable object was presented.",
|
||||
STATUS_ERROR, &ErrorStatus);
|
||||
|
||||
static const Status InstanceStillAlive = (Status){
|
||||
.identity = nameof(InstanceStillAlive),
|
||||
.value = 1,
|
||||
.description = "Given instance was yet alive.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = (Status *)&ErrorStatus
|
||||
};
|
||||
DEFSTATUS(InstanceStillAlive, 1,
|
||||
"Given instance was yet alive.",
|
||||
STATUS_ERROR, &ErrorStatus);
|
||||
|
||||
static const Status InstanceNotAlive = (Status){
|
||||
.identity = nameof(InstanceNotAlive),
|
||||
.value = 1,
|
||||
.description = "Given instance for reallocation was not alive.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = (Status *)&ErrorStatus
|
||||
};
|
||||
DEFSTATUS(InstanceNotAlive, 1,
|
||||
"Given instance for reallocation was not alive.",
|
||||
STATUS_ERROR, &ErrorStatus);
|
||||
|
||||
static const Status InvalidParameter = (Status){
|
||||
.identity = nameof(InvalidParameter),
|
||||
.value = 1,
|
||||
.description = "An invalid parameter was presented.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = (Status *)&InvalidObject
|
||||
};
|
||||
DEFSTATUS(InvalidParameter, 1,
|
||||
"An invalid parameter was presented.",
|
||||
STATUS_ERROR, &InvalidObject);
|
||||
|
||||
static const Status InsufficientMemory = (Status){
|
||||
.identity = nameof(InsufficientMemory),
|
||||
.value = 1,
|
||||
.description = "Not enough room for further memory allocations.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = (Status *)&ErrorStatus
|
||||
};
|
||||
DEFSTATUS(InsufficientMemory, 1,
|
||||
"Not enough room for further memory allocations.",
|
||||
STATUS_ERROR, &ErrorStatus);
|
||||
|
||||
static const Status ArithmeticError = (Status){
|
||||
.identity = nameof(ArithmeticError),
|
||||
.value = 1,
|
||||
.description = "An arithmetic error occurred.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = (Status *)&ErrorStatus
|
||||
};
|
||||
DEFSTATUS(ArithmeticError, 1,
|
||||
"An arithmetic error occurred.",
|
||||
STATUS_ERROR, &ErrorStatus);
|
||||
|
||||
static const Status IntegerOverFlow = (Status){
|
||||
.identity = nameof(IntegerOverFlow),
|
||||
.value = 1,
|
||||
.description = "An integer had overflowed.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = (Status *)&ArithmeticError
|
||||
};
|
||||
DEFSTATUS(IntegerOverFlow, 1,
|
||||
"An integer had overflowed.",
|
||||
STATUS_ERROR, &ArithmeticError);
|
||||
|
||||
static const Status RuntimeError = (Status){
|
||||
.identity = nameof(RuntimeError),
|
||||
.value = 1,
|
||||
.description = "A runtime error occurred.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = (Status *)&ErrorStatus
|
||||
};
|
||||
DEFSTATUS(RuntimeError, 1,
|
||||
"A runtime error occurred.",
|
||||
STATUS_ERROR, &ErrorStatus);
|
||||
|
||||
static const Status ArrayLengthError = (Status){
|
||||
.identity = nameof(ArrayLengthError),
|
||||
.value = 1,
|
||||
.description = "Given array length does not meet the requirement.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = (Status *)&ErrorStatus
|
||||
};
|
||||
DEFSTATUS(ArrayLengthError, 1,
|
||||
"Given array length does not meet the requirement.",
|
||||
STATUS_ERROR, &ErrorStatus);
|
||||
|
||||
static const Status VariableFormatMismatch = (Status){
|
||||
.identity = nameof(VariableFormatMismatch),
|
||||
.value = 1,
|
||||
.description = "Given format does not match with given subjects.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = (Status *)&ErrorStatus
|
||||
};
|
||||
DEFSTATUS(VariableFormatMismatch, 1,
|
||||
"Given format does not match with given subjects.",
|
||||
STATUS_ERROR, &ErrorStatus);
|
||||
|
||||
DEFSTATUS(ImprecisionError, 1,
|
||||
"Precision was not enough for handling the calculation.",
|
||||
STATUS_ERROR, &RuntimeError);
|
||||
|
||||
static const Status ImprecisionError = (Status){
|
||||
.identity = nameof(ImprecisionError),
|
||||
.value = 1,
|
||||
.description = "Precision was not enough for handling the calculation.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = (Status *)&RuntimeError
|
||||
};
|
||||
|
||||
// ---------------------USER DEFINED-----------------------
|
||||
|
||||
static const Status UnavailableInstance = (Status){
|
||||
.identity = nameof(UnavailableInstance),
|
||||
.value = 1,
|
||||
.description = "An unavailable instance was given for initialisation.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = (Status *)&NullPointerAccounted
|
||||
};
|
||||
DEFSTATUS(UnavailableInstance, 1,
|
||||
"An unavailable instance was given for initialisation.",
|
||||
STATUS_ERROR, &NullPointerAccounted);
|
||||
|
||||
static const Status RecreationOnInstanceStillAlive = (Status){
|
||||
.identity = nameof(RecreationOnInstanceStillAlive),
|
||||
.value = 1,
|
||||
.description = "Given instance was still alive, yet, was sent for another "
|
||||
"session of recreation.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = (Status *)&InstanceStillAlive\
|
||||
};
|
||||
DEFSTATUS(RecreationOnInstanceStillAlive, 1,
|
||||
"Given instance was still alive, yet, was sent for another session of recreation.",
|
||||
STATUS_ERROR, &InstanceStillAlive);
|
||||
|
||||
static const Status UnavailableParameter = (Status){
|
||||
.identity = nameof(UnavailableParameter),
|
||||
.value = 1,
|
||||
.description = "An unavailable instance was given as a parameter.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = (Status *)&UnavailableInstance
|
||||
};
|
||||
DEFSTATUS(UnavailableParameter, 1,
|
||||
"An unavailable instance was given as a parameter.",
|
||||
STATUS_ERROR, &UnavailableInstance);
|
||||
|
||||
static const Status InvalidReportTask = (Status){
|
||||
.identity = nameof(InvalidReportTask),
|
||||
.value = 1,
|
||||
.description = "An unavailable or illegal report task was given.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = (Status *)&InvalidParameter
|
||||
};
|
||||
DEFSTATUS(InvalidReportTask, 1,
|
||||
"An unavailable or illegal report task was given.",
|
||||
STATUS_ERROR, &InvalidParameter);
|
||||
|
||||
static const Status UnableToThrowError = (Status){
|
||||
.identity = nameof(UnableToThrowError),
|
||||
.value = 1,
|
||||
.description = "Unable to report an exceptional situation.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = (Status *)&RuntimeError
|
||||
};
|
||||
DEFSTATUS(UnableToThrowError, 1,
|
||||
"Unable to report an exceptional situation.",
|
||||
STATUS_ERROR, &RuntimeError);
|
||||
|
||||
static const Status ReadWriteError = (Status){
|
||||
.identity = nameof(ReadWriteError),
|
||||
.value = 1,
|
||||
.description = "Error occurred during IO session.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = (Status *)&RuntimeError
|
||||
};
|
||||
DEFSTATUS(ReadWriteError, 1,
|
||||
"Error occurred during IO session.",
|
||||
STATUS_ERROR, &RuntimeError);
|
||||
|
||||
static const Status FileNotFound = (Status){
|
||||
.identity = nameof(FileNotFound),
|
||||
.value = 1,
|
||||
.description = "Target file was unavailable and unable to find.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = (Status *)&ReadWriteError
|
||||
};
|
||||
DEFSTATUS(FileNotFound, 1,
|
||||
"Target file was unavailable and unable to find.",
|
||||
STATUS_ERROR, &ReadWriteError);
|
||||
|
||||
static const Status InvalidFileName = (Status){
|
||||
.identity = nameof(InvalidFileName),
|
||||
.value = 1,
|
||||
.description = "Given file name was invalid.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = (Status *)&ReadWriteError
|
||||
};
|
||||
DEFSTATUS(InvalidFileName, 1,
|
||||
"Given file name was invalid.",
|
||||
STATUS_ERROR, &ReadWriteError);
|
||||
|
||||
static const Status UnavailableFileName = (Status){
|
||||
.identity = nameof(UnavailableFileName),
|
||||
.value = 1,
|
||||
.description = "Given file name was unavailable",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = (Status *)&UnavailableObject
|
||||
};
|
||||
DEFSTATUS(UnavailableFileName, 1,
|
||||
"Given file name was unavailable.",
|
||||
STATUS_ERROR, &UnavailableObject);
|
||||
|
||||
static const Status ReportThrown = (Status){
|
||||
.identity = nameof(ReportThrown),
|
||||
.value = 1,
|
||||
.description = "This function has thrown a report, "
|
||||
"following instructions aborted.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = (Status *)&RuntimeError\
|
||||
};
|
||||
DEFSTATUS(UnavailableFileAccessMode, 1,
|
||||
"Given file accessing mode was unavailable.",
|
||||
STATUS_ERROR, &UnavailableObject);
|
||||
|
||||
static const Status ReportMessageTooLong = (Status){
|
||||
.identity = nameof(ReportMessageTooLong),
|
||||
.value = 1,
|
||||
.description = "Given message is too long.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = (Status *)&ArrayLengthError
|
||||
};
|
||||
DEFSTATUS(InsufficientAccessPermission, 1,
|
||||
"Given permission does not suffice to access.",
|
||||
STATUS_ERROR, &ReadWriteError);
|
||||
|
||||
static const Status MaximumLengthExceeded = (Status){
|
||||
.identity = nameof(MaximumLengthExceeded),
|
||||
.value = 1,
|
||||
.description = "Buffer was too long.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = (Status *)&ArrayLengthError
|
||||
};
|
||||
DEFSTATUS(ReportThrown, 1,
|
||||
"This function has thrown a report, following instructions aborted.",
|
||||
STATUS_ERROR, &RuntimeError);
|
||||
|
||||
static const Status MaximumLiteralisationLengthExceeded = (Status){
|
||||
.identity = nameof(MaximumLiteralisationLengthExceeded),
|
||||
.value = 1,
|
||||
.description = "Literalisation was too long.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = (Status *)&MaximumLengthExceeded
|
||||
};
|
||||
DEFSTATUS(ReportMessageTooLong, 1,
|
||||
"Given message is too long.",
|
||||
STATUS_ERROR, &ArrayLengthError);
|
||||
|
||||
static const Status UnavailableBuffer = (Status){
|
||||
.identity = nameof(UnavailableBuffer),
|
||||
.value = 1,
|
||||
.description = "Given buffer was unavailable.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = (Status *)&UnavailableInstance
|
||||
};
|
||||
DEFSTATUS(MaximumLengthExceeded, 1,
|
||||
"Maximum length had exceeded",
|
||||
STATUS_ERROR, &ArrayLengthError);
|
||||
|
||||
DEFSTATUS(MaximumLiteralisationLengthExceeded, 1,
|
||||
"Literalisation was too long",
|
||||
STATUS_ERROR, &MaximumLengthExceeded);
|
||||
|
||||
DEFSTATUS(UnavailableBuffer, 1,
|
||||
"Given buffer was unavailable.",
|
||||
STATUS_ERROR, &UnavailableInstance);
|
||||
|
||||
DEFSTATUS(InvalidLiteralisingBuffer, 1,
|
||||
"Given buffer does not have a good integrity on its length.",
|
||||
STATUS_ERROR, &InvalidObject);
|
||||
|
||||
static const Status InvalidLiteralisingBuffer = (Status){
|
||||
.identity = nameof(InvalidLiteralisingBuffer),
|
||||
.value = 1,
|
||||
.description = "Given buffer does not have a good integrity on its length.",
|
||||
.characteristic = STATUS_ERROR,
|
||||
.loc = __GLOBAL__,
|
||||
.prev = (Status *)&InvalidObject
|
||||
};
|
||||
|
||||
// ========================================================
|
||||
|
||||
|
Reference in New Issue
Block a user