Compare commits
39 Commits
95a49ebefa
...
master
Author | SHA1 | Date | |
---|---|---|---|
8c056d1a39 | |||
9f2b44bf99 | |||
310586ab86 | |||
a63063de42 | |||
8870e5e7db | |||
f5d82983a4 | |||
bc4be4e295 | |||
d19256621b | |||
8696b89c2e | |||
|
75a2b14c07 | ||
|
10b2d4e43b | ||
9f1960e297 | |||
24cd4a17df | |||
3f0907daa2 | |||
22db5f0cbc | |||
43afe62ad1 | |||
772a79ce03 | |||
5e05e24e38 | |||
b9c5bfbc00 | |||
acaa38099f | |||
5026f03692 | |||
55d9ddef39 | |||
092dddf6c4 | |||
242fcce951 | |||
bc3fd9dfad | |||
f88b2b5b02 | |||
acad934238 | |||
|
bcbec01992 | ||
|
6583335dd6 | ||
|
09076d0d00 | ||
|
31a997c170 | ||
|
794ff14602 | ||
|
b316c0e5ee | ||
|
69d827c38e | ||
|
871bab317b | ||
|
73e766eef7 | ||
1c611ec4e2 | |||
010300157e | |||
|
2eb66dbc8d |
10
.gitignore
vendored
10
.gitignore
vendored
@@ -2,7 +2,6 @@
|
|||||||
*CMakeFiles/*
|
*CMakeFiles/*
|
||||||
*CMakeCache*
|
*CMakeCache*
|
||||||
cmake_install.cmake
|
cmake_install.cmake
|
||||||
*[tT]est*
|
|
||||||
*~
|
*~
|
||||||
gitwork
|
gitwork
|
||||||
work
|
work
|
||||||
@@ -13,11 +12,14 @@ todo_stack
|
|||||||
getReady.sh
|
getReady.sh
|
||||||
base_type.c
|
base_type.c
|
||||||
sample
|
sample
|
||||||
<<<<<<< HEAD
|
|
||||||
compile
|
compile
|
||||||
=======
|
|
||||||
>>>>>>> refs/remotes/master/master
|
|
||||||
.vscode/
|
.vscode/
|
||||||
todo
|
todo
|
||||||
vsc*
|
vsc*
|
||||||
libcompound.so
|
libcompound.so
|
||||||
|
CMakeLists_default.txt
|
||||||
|
CompoundTest
|
||||||
|
ccwarn
|
||||||
|
genwarn.sh
|
||||||
|
test.sh
|
||||||
|
expansion_formatted.txt
|
||||||
|
@@ -4,53 +4,28 @@
|
|||||||
# include <Compound/var.h>
|
# include <Compound/var.h>
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
int len;
|
|
||||||
Var *members;
|
Var *members;
|
||||||
|
int len;
|
||||||
|
bool alive;
|
||||||
} Array;
|
} Array;
|
||||||
|
|
||||||
# define ArrayIndexOutOfBound = (Status){\
|
DEFSTATUS(ArrayIndexOutOfBound, 1, "Given index was accessing illegal address.", STATUS_ERROR, &MemoryViolation);
|
||||||
.identity = nameof(ArrayIndexOutOfBound),\
|
DEFSTATUS(InvalidArrayLength, 1, "Given length is invalid.", STATUS_ERROR, &ErrorStatus);
|
||||||
.value = 1,\
|
|
||||||
.description = "Given index was accessing illegal address.",\
|
|
||||||
.characteristic = STATUS_ERROR,\
|
|
||||||
.prev = &MemoryViolation\
|
|
||||||
}
|
|
||||||
|
|
||||||
# define InvalidArrayLength (Status){\
|
Status Array_Create(Array *inst, int len, size_t size);
|
||||||
.value = 1,\
|
|
||||||
.description = "Given length is invalid.",\
|
|
||||||
.characteristic = STATUS_ERROR,\
|
|
||||||
.prev = &ErrorStatus\
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Elementary. */
|
|
||||||
Status Array_Create(Array *inst, int len, size_t size)
|
|
||||||
throws(InsufficientMemory InvalidArrayLength);
|
|
||||||
Status Array_CopyOf(Array *inst, Array *other);
|
Status Array_CopyOf(Array *inst, Array *other);
|
||||||
Status Array_Delete(Array *inst);
|
Status Array_Delete(Array *inst);
|
||||||
Status Array_GetIdx(Array *inst, Var *store, int index);
|
|
||||||
throws(ArrayIndexOutOfBound);
|
|
||||||
Status Array_SetIdx(Array *inst, Var *source, int index);
|
|
||||||
throws(ArrayIndexOutOfBound);
|
|
||||||
bool Array_Equals(Array *arr1, Array *arr2);
|
bool Array_Equals(Array *arr1, Array *arr2);
|
||||||
|
|
||||||
/* Extensional. */
|
|
||||||
Status ArrayUtils_Insert(Array *inst, Var *item, int index);
|
Status ArrayUtils_Insert(Array *inst, Var *item, int index);
|
||||||
throws(ArrayIndexOutOfBound);
|
|
||||||
Status ArrayUtils_InsertArray(Array *inst, Array *items, int index);
|
Status ArrayUtils_InsertArray(Array *inst, Array *items, int index);
|
||||||
throws(ArrayIndexOutOfBound);
|
|
||||||
Status ArrayUtils_Remove(Array *inst, int index);
|
Status ArrayUtils_Remove(Array *inst, int index);
|
||||||
throws(ArrayIndexOutOfBound);
|
|
||||||
Status ArrayUtils_RemoveArray(Array *inst, int off, int len);
|
Status ArrayUtils_RemoveArray(Array *inst, int off, int len);
|
||||||
throws(ArrayIndexOutOfBound InvalidArrayLength);
|
|
||||||
Status ArrayUtils_Subarray(Array *inst, Array *store, int off, int len);
|
Status ArrayUtils_Subarray(Array *inst, Array *store, int off, int len);
|
||||||
throws(ArrayIndexOutOfBound InvalidArrayLength);
|
|
||||||
Status ArrayUtils_Fill(Array *inst, Var *elem, int off, int len);
|
Status ArrayUtils_Fill(Array *inst, Var *elem, int off, int len);
|
||||||
throws(ArrayIndexOutOfBound InvalidArrayLength);
|
|
||||||
Status ArrayUtils_Search(Array *inst, Var *item, int *store);
|
Status ArrayUtils_Search(Array *inst, Var *item, int *store);
|
||||||
Status ArrayUtils_SearchArray(Array *inst, Array *items, int *store);
|
Status ArrayUtils_SearchArray(Array *inst, Array *items, int *store);
|
||||||
Status ArrayUtils_Split(Array *inst, Array *fore, Array *rear, int index);
|
Status ArrayUtils_Split(Array *inst, Array *fore, Array *rear, int index);
|
||||||
throws(ArrayIndexOutOfBound);
|
|
||||||
Status ArrayUtils_Revert(Array *inst);
|
Status ArrayUtils_Revert(Array *inst);
|
||||||
bool ArrayUtils_IsEmpty(Array *inst);
|
bool ArrayUtils_IsEmpty(Array *inst);
|
||||||
bool ArrayUtils_IsBlank(Array *inst);
|
bool ArrayUtils_IsBlank(Array *inst);
|
||||||
|
@@ -3,155 +3,164 @@
|
|||||||
|
|
||||||
Status Array_Create(Array *inst, int len, size_t size)
|
Status Array_Create(Array *inst, int len, size_t size)
|
||||||
{
|
{
|
||||||
/* Skip unavailable inst and invalid param. */
|
nonull(inst, apply(UnavailableInstance));
|
||||||
fails(inst, apply(UnavailableInstance));
|
|
||||||
state((len < 0), apply(InvalidArrayLength));
|
|
||||||
solve((!len), { inst->len = 0; inst->members = NULL; return apply(NormalStatus); })
|
|
||||||
|
|
||||||
inst->len = len;
|
/* Skip the living instances. */
|
||||||
inst->members = calloc(len, sizeof(Var));
|
state(inst && inst->alive, apply(InstanceStillAlive));
|
||||||
|
|
||||||
|
/* Allocate for members from the inst. */
|
||||||
|
state(!(inst->members = calloc(len, sizeof(Var))), apply(InsufficientMemory));
|
||||||
|
|
||||||
|
/* Create for each item from members. */
|
||||||
int erridx = -1;
|
int erridx = -1;
|
||||||
|
Status errstat = EMPTY;
|
||||||
for (register int i = 0; i < len; i++) {
|
for (register int i = 0; i < len; i++) {
|
||||||
// TODO(william): Throw InsufficientMemory at following line.
|
notok(Var_Create(&inst->members[i], size), {
|
||||||
// DONE(william): ensure(Var_Create(&inst->members[i], size), "Failed to create a new var.");
|
|
||||||
|
|
||||||
notok((Var_Create(&inst->members[i], size)), {
|
|
||||||
#ifdef __DEBUG__
|
|
||||||
cat("Var_Create failed!\n")
|
|
||||||
#endif
|
|
||||||
erridx = i;
|
erridx = i;
|
||||||
|
errstat = apply(_);
|
||||||
break;
|
break;
|
||||||
} else {
|
|
||||||
#ifdef __DEBUG__
|
|
||||||
cat("Var_Create success!\n")
|
|
||||||
#endif
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Review on erridx. Release data that allocated. */
|
/* Got problem during allocations. */
|
||||||
if (erridx != -1) {
|
if (erridx >= 0) {
|
||||||
for (register int i = erridx; i >= 0; i--) {
|
/* Release members allocated backwardly. */
|
||||||
|
for (register int i = erridx - 1; i >= 0; i--) {
|
||||||
Var_Delete(&inst->members[i]);
|
Var_Delete(&inst->members[i]);
|
||||||
#ifdef __DEBUG__
|
|
||||||
cat("Deleted var from InsufficientMemory from Array_Create!")
|
|
||||||
#endif
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Release array itself. */
|
/* Release the array inst. */
|
||||||
free(inst->members);
|
free(inst->members);
|
||||||
|
|
||||||
return apply(InsufficientMemory);
|
return errstat;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Assign rest of the struct members. */
|
||||||
|
inst->len = len;
|
||||||
|
inst->alive = true;
|
||||||
|
|
||||||
return apply(NormalStatus);
|
return apply(NormalStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status Array_CopyOf(Array *inst, Array *other)
|
Status Array_CopyOf(Array *inst, Array *other)
|
||||||
{
|
{
|
||||||
// /* Skip unavailable inst and invalid param. */
|
/* Skip unavailble parameters. */
|
||||||
// fails(inst, apply(UnavailableInstance));
|
nonull(other,
|
||||||
// fails(other, error(InvalidParameter, "Given other was unavailable."));
|
apply(annot(UnavailableInstance,
|
||||||
|
"Given object for copying to inst was unavailable.")));
|
||||||
|
|
||||||
// /* Assign value for len. */
|
/* Skip invalid parameters and instances. */
|
||||||
// inst->len = other->len;
|
state(inst && inst->alive,
|
||||||
|
apply(annot(InstanceStillAlive,
|
||||||
|
"Given inst for being copied was still alive.")));
|
||||||
|
|
||||||
// if (inst->members == NULL) return apply(NormalStatus);
|
state(!other->alive,
|
||||||
// match(RuntimeError, Array_Create(inst, other->len), "Failed on recreating "
|
apply(annot(InstanceNotAlive,
|
||||||
// "array.");
|
"Given object for copying to inst was not alive.")));
|
||||||
|
|
||||||
// /* Copy and assign for each member from other to inst. */
|
state(!other->len,
|
||||||
// for (register int i = 0; i < inst->len; i++) {
|
apply(annot(InvalidArrayLength,
|
||||||
// inst[i] = other[i];
|
"Given object for copying to inst has length of ZERO.")));
|
||||||
// }
|
|
||||||
|
|
||||||
// return apply(NormalStatus);
|
/* Allocate for members from the inst. */
|
||||||
|
state(!(inst->members = calloc(other->len, sizeof(Var))),
|
||||||
|
apply(InsufficientMemory));
|
||||||
|
|
||||||
|
/* Create for each item from members. */
|
||||||
|
int erridx = -1;
|
||||||
|
Status errstat = EMPTY;
|
||||||
|
for (register int i = 0; i < other->len; i++) {
|
||||||
|
notok(Var_Create(&inst->members[i], other->members[0].size), {
|
||||||
|
erridx = i;
|
||||||
|
errstat = apply(_);
|
||||||
|
break;
|
||||||
|
})
|
||||||
|
|
||||||
|
notok(Var_CopyOf(&inst->members[i], &other->members[i]), {
|
||||||
|
erridx = i;
|
||||||
|
errstat = apply(_);
|
||||||
|
break;
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Got problem during allocations. */
|
||||||
/*
|
if (erridx >= 0) {
|
||||||
if (other == NULL) return 1;
|
/* Release members allocated backwardly. */
|
||||||
|
for (register int i = erridx - 1; i >= 0; i--) {
|
||||||
String_Create(inst, other->len);
|
Var_Delete(&inst->members[i]);
|
||||||
for (register int i = 0; i < other->len; i++) {
|
|
||||||
inst->arr[i] = other->arr[i];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
/* Release the array inst. */
|
||||||
|
free(inst->members);
|
||||||
|
|
||||||
|
return apply(errstat);
|
||||||
|
}
|
||||||
|
|
||||||
*/
|
/* Assign rest of the struct members. */
|
||||||
|
inst->len = other->len;
|
||||||
|
inst->alive = true;
|
||||||
|
|
||||||
|
return apply(NormalStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status Array_Delete(Array *inst)
|
Status Array_Delete(Array *inst)
|
||||||
{
|
{
|
||||||
/* Skip unavailable inst and invalid param. */
|
nonull(!inst, apply(UnavailableInstance));
|
||||||
fails(inst, apply(UnavailableInstance));
|
state(!inst->alive, apply(InstanceNotAlive));
|
||||||
solve((inst->members == NULL), return apply(NormalStatus));
|
|
||||||
|
/* Iterate through each member and delete them. */
|
||||||
|
for (register int i = 0; i < inst->len; i++) {
|
||||||
|
fail(Var_Delete(&inst->members[i]));
|
||||||
|
}
|
||||||
|
|
||||||
inst->len = 0;
|
|
||||||
free(inst->members);
|
free(inst->members);
|
||||||
inst->members = NULL;
|
inst->members = NULL;
|
||||||
|
inst->alive = false;
|
||||||
|
inst->len = 0;
|
||||||
|
|
||||||
return apply(NormalStatus);
|
return apply(NormalStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status Array_GetIdx(Array *inst, Var *store, int index)
|
bool Array_Equals(Array *arr1, Array *arr2)
|
||||||
{
|
{
|
||||||
/* Skip unavailable inst and invalid param. */
|
/* Skip unavailable instance and parameter. */
|
||||||
fails(inst, apply(UnavailableInstance));
|
state(!arr1 || !arr2, false);
|
||||||
fails(store,
|
|
||||||
apply(error(InvalidParameter, "Given reference to store was unavailable.")));
|
|
||||||
state((index < 0 || index >= inst->len), apply(ArrayIndexOutOfBound));
|
|
||||||
|
|
||||||
*store = inst->members[index];
|
/* Skip when arr1 and arr2 have different length. */
|
||||||
|
state(arr1->len != arr2->len, false);
|
||||||
|
|
||||||
return apply(NormalStatus);
|
/* Skip when operation is not supported. */
|
||||||
}
|
state(!arr1->alive || !arr2->alive, false);
|
||||||
|
|
||||||
Status Array_SetIdx(Array *inst, Var *source, int index)
|
/* Iterate through each member for comparison. */
|
||||||
{
|
for (register int i = 0; i < arr1->len; i++) {
|
||||||
/* Skip unavailable inst and invalid param. */
|
if (!Var_Equals(&arr1->members[i], &arr2->members[i])) {
|
||||||
fails(inst, apply(UnavailableInstance));
|
|
||||||
fails(source,
|
|
||||||
apply(
|
|
||||||
error(InvalidParameter, "Given reference to source was unavailable.")));
|
|
||||||
state((index < 0 || index >= inst->len), apply(ArrayIndexOutOfBound));
|
|
||||||
|
|
||||||
inst->members[index] = *source;
|
|
||||||
|
|
||||||
return apply(NormalStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Array_Equals(Array *a, Array *b)
|
|
||||||
{
|
|
||||||
/* Skip unavailable inst and invalid param. */
|
|
||||||
state((a == NULL || b == NULL), false);
|
|
||||||
state((a->len != b->len), false);
|
|
||||||
|
|
||||||
for (register int i = 0; i < a->len; i++) {
|
|
||||||
if (!Var_Equals(&a->members[i], &b->members[i])) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return true;
|
/* Compare rest of the struct member. */
|
||||||
|
return (arr1->alive == arr2->alive);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Status ArrayUtils_Insert(Array *inst, Var *item, int index);
|
||||||
|
|
||||||
|
Status ArrayUtils_InsertArray(Array *inst, Array *items, int index);
|
||||||
|
|
||||||
Status ArrayUtils_Fill(Array *inst, Var *elem, int off, int len)
|
Status ArrayUtils_Remove(Array *inst, int index);
|
||||||
{
|
|
||||||
fails(inst, apply(UnavailableInstance));
|
|
||||||
fails(elem,
|
|
||||||
apply(error(InvalidParameter, "Given reference to elem was unavailable.")));
|
|
||||||
state((off + len > inst->len) || (off < 0) || (len < 0),
|
|
||||||
apply(ArrayIndexOutOfBound));
|
|
||||||
|
|
||||||
/* Copy elem into each specified members from inst with off and len. */
|
Status ArrayUtils_RemoveArray(Array *inst, int off, int len);
|
||||||
for (register int i = off; i < (off + len); i++) {
|
|
||||||
inst->members[i] = *elem;
|
|
||||||
}
|
|
||||||
|
|
||||||
return apply(NormalStatus);
|
Status ArrayUtils_Subarray(Array *inst, Array *store, int off, int len);
|
||||||
}
|
|
||||||
|
Status ArrayUtils_Fill(Array *inst, Var *elem, int off, int len);
|
||||||
|
|
||||||
|
Status ArrayUtils_Search(Array *inst, Var *item, int *store);
|
||||||
|
|
||||||
|
Status ArrayUtils_SearchArray(Array *inst, Array *items, int *store);
|
||||||
|
|
||||||
|
Status ArrayUtils_Split(Array *inst, Array *fore, Array *rear, int index);
|
||||||
|
|
||||||
|
Status ArrayUtils_Revert(Array *inst);
|
||||||
|
|
||||||
|
bool ArrayUtils_IsEmpty(Array *inst);
|
||||||
|
@@ -2,12 +2,14 @@ cmake_minimum_required (VERSION 3.5)
|
|||||||
|
|
||||||
project (Compound)
|
project (Compound)
|
||||||
|
|
||||||
add_compile_options(-g -std=c99 -Wall -Wextra -Wformat)
|
set(CMAKE_C_COMPILER clang)
|
||||||
|
|
||||||
|
add_compile_options(-g -std=c99 -Wall -Wextra -D__DEBUG__)
|
||||||
|
|
||||||
set(SHARED_SOURCE
|
set(SHARED_SOURCE
|
||||||
MemMan/src/memman.c
|
MemMan/src/memman.c
|
||||||
Status/src/status.c
|
Status/src/status.c
|
||||||
Utils/src/utils.c
|
Array/src/array.c
|
||||||
Var/src/var.c
|
Var/src/var.c
|
||||||
catlog.c)
|
catlog.c)
|
||||||
|
|
||||||
@@ -30,5 +32,6 @@ add_executable(CompoundTest
|
|||||||
test.c
|
test.c
|
||||||
MemMan/src/memman.c
|
MemMan/src/memman.c
|
||||||
Status/src/status.c
|
Status/src/status.c
|
||||||
Utils/src/utils.c
|
Array/src/array.c
|
||||||
|
Var/src/var.c
|
||||||
catlog.c)
|
catlog.c)
|
||||||
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Status Memory_Create(Memory *inst, size_t size)
|
Status Memory_Create(Memory *inst, size_t size)
|
||||||
{
|
{
|
||||||
fails(inst, apply(UnavailableInstance));
|
nonull(inst, apply(UnavailableInstance));
|
||||||
|
|
||||||
*inst = (Memory) {
|
*inst = (Memory) {
|
||||||
.addr = NULL,
|
.addr = NULL,
|
||||||
@@ -16,7 +16,7 @@ Status Memory_Create(Memory *inst, size_t size)
|
|||||||
|
|
||||||
Status Memory_Allocate(Memory *inst)
|
Status Memory_Allocate(Memory *inst)
|
||||||
{
|
{
|
||||||
fails(inst, apply(UnavailableInstance));
|
nonull(inst, apply(UnavailableInstance));
|
||||||
state(inst->alive, apply(InstanceStillAlive));
|
state(inst->alive, apply(InstanceStillAlive));
|
||||||
|
|
||||||
/* When failed on allocating. */
|
/* When failed on allocating. */
|
||||||
@@ -28,19 +28,22 @@ Status Memory_Allocate(Memory *inst)
|
|||||||
|
|
||||||
Status Memory_Reallocate(Memory *inst, size_t size)
|
Status Memory_Reallocate(Memory *inst, size_t size)
|
||||||
{
|
{
|
||||||
fails(inst, apply(UnavailableBuffer));
|
nonull(inst, apply(UnavailableBuffer));
|
||||||
state(!inst->alive, apply(InstanceNotAlive));
|
state(!inst->alive, apply(InstanceNotAlive));
|
||||||
|
|
||||||
/* When failed on reallocating. */
|
/* When failed on reallocating. */
|
||||||
state(!(inst->addr = realloc(inst->addr, size)),
|
state(!(inst->addr = realloc(inst->addr, size)),
|
||||||
apply(error(InsufficientMemory, "Unsuccessful reallocation was received.")));
|
apply(error(InsufficientMemory, "Cannot successfully reallocate.")));
|
||||||
|
|
||||||
|
/* Update size from inst. */
|
||||||
|
inst->size = size;
|
||||||
|
|
||||||
return apply(NormalStatus);
|
return apply(NormalStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status Memory_Release(Memory *inst)
|
Status Memory_Release(Memory *inst)
|
||||||
{
|
{
|
||||||
fails(inst, apply(UnavailableInstance));
|
nonull(inst, apply(UnavailableInstance));
|
||||||
state(!inst->alive,
|
state(!inst->alive,
|
||||||
apply(error(InstanceNotAlive, "Cannot release a non-alive instance.")));
|
apply(error(InstanceNotAlive, "Cannot release a non-alive instance.")));
|
||||||
|
|
||||||
@@ -52,7 +55,7 @@ Status Memory_Release(Memory *inst)
|
|||||||
|
|
||||||
Status Memory_Delete(Memory *inst)
|
Status Memory_Delete(Memory *inst)
|
||||||
{
|
{
|
||||||
fails(inst, apply(UnavailableInstance));
|
nonull(inst, apply(UnavailableInstance));
|
||||||
state(inst->alive,
|
state(inst->alive,
|
||||||
apply(
|
apply(
|
||||||
error(InstanceStillAlive, "Cannot deinitialise a instance still alive.")));
|
error(InstanceStillAlive, "Cannot deinitialise a instance still alive.")));
|
||||||
|
28
README.md
28
README.md
@@ -5,12 +5,9 @@ Generally, Compound is a library for general-purposes programming which you will
|
|||||||
It is worth noticing that, this library is completely aimed for creating another language. That means, every feature update is supposedly to serve the language.
|
It is worth noticing that, this library is completely aimed for creating another language. That means, every feature update is supposedly to serve the language.
|
||||||
|
|
||||||
---
|
---
|
||||||
## BUILDING
|
## Building
|
||||||
|
|
||||||
To build Compound, all you need is to type as follow in a terminal:
|
|
||||||
```shell
|
```shell
|
||||||
cmake . # Generate "Makefile"
|
cmake . && make
|
||||||
make # Build
|
|
||||||
```
|
```
|
||||||
|
|
||||||
> *PLEASE NOTICE*
|
> *PLEASE NOTICE*
|
||||||
@@ -35,12 +32,25 @@ Compound, now, roughly divides platform compatibilities into 2 major parts, the
|
|||||||
This idea is ready for refinements, you can put up such suggestions and they're welcomed.
|
This idea is ready for refinements, you can put up such suggestions and they're welcomed.
|
||||||
|
|
||||||
## Installation
|
## Installation
|
||||||
To install Compound, all you need to do is to run `install`, something like below.
|
|
||||||
```shell
|
```shell
|
||||||
./install # (Require root privilege)
|
./preinstall # (Require root privilege)
|
||||||
|
./postinstall # (Require root privilege)
|
||||||
```
|
```
|
||||||
|
|
||||||
If you cannot execute ./install script, try to add permission for execution:
|
> *I TELL YOU WHAT*
|
||||||
|
> *It is for the convenience of project building automation that the installation procedure being devided into two different parts.*
|
||||||
|
> *In general, the "preinstall" copies the header files into system "include" directory,*
|
||||||
|
> *while the "postinstall" copies the compiled library into system library directory.*
|
||||||
|
|
||||||
|
|
||||||
|
And if you cannot execute the scripts, try to add permission for execution:
|
||||||
```shell
|
```shell
|
||||||
chmod +x ./install # (Require root privilege)
|
chmod +x ./the_file_lacks_of_permission_to_execute_and_to_be_honest_i_dont_know_why_do_i_have_to_put_the_name_so_long_that_none_of_you_would_like_to_read_it_through_but_since_you_have_gotten_this_far_congrats_you_are_my_big_star_now_oh_by_the_way_do_you_know_that_the_cat_of_mine_can_actually_talk_cause_last_sunday_when_i_head_to_kitchen_for_some_drinks_and_i_heard_something_mumbling_behind_the_door_and_i_went_up_to_check_what_it_was_and_it_turns_out_that_it_was_my_cat_speaking_and_what_it_said_was_meow
|
||||||
```
|
```
|
||||||
|
|
||||||
|
## Troubleshoot
|
||||||
|
For now, we wish more of you to put up issues so that the problems can be spotted.
|
||||||
|
|
||||||
|
> *NOT SO FAST*
|
||||||
|
> *If you got a problem, try to look up for similar or same issues that had been put up already,*
|
||||||
|
> *'cause you don't want to have your reply simply written something like "ah yeah yeah, we've been through that sometime earlier".*
|
||||||
|
BIN
Status/StatusTest
Executable file
BIN
Status/StatusTest
Executable file
Binary file not shown.
@@ -63,125 +63,20 @@ typedef struct _Status {
|
|||||||
struct _Status *prev;
|
struct _Status *prev;
|
||||||
} Status;
|
} Status;
|
||||||
|
|
||||||
# define DEFSTATUS(i, v, d, c, p)\
|
# define DEFSTATUS(i, v, d, c, p) \
|
||||||
static const Status i = {\
|
static const Status i = { \
|
||||||
.identity = nameof(i),\
|
.identity = nameof(i), \
|
||||||
.value = v,\
|
.value = v, \
|
||||||
.description = d,\
|
.description = d, \
|
||||||
.characteristic = c,\
|
.characteristic = c, \
|
||||||
.loc = __GLOBAL__,\
|
.loc = __GLOBAL__, \
|
||||||
.prev = (Status *)p\
|
.prev = (Status *)p \
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
{value "description" characteristic prev}
|
|
||||||
|
|
||||||
"%d \"%s\" %d %p"
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
/* line, func, file */
|
|
||||||
// # define LOCATION_LITERALISE_FORMAT "at line %d, in %s, %s"
|
|
||||||
|
|
||||||
/* file, line, func */
|
|
||||||
# define LOCATION_LITERALISE_FORMAT "at %s:%d, in function `%s\'"
|
# define LOCATION_LITERALISE_FORMAT "at %s:%d, in function `%s\'"
|
||||||
# define LOCATION_LITERALISE_FORMAT_LENGTH 20
|
|
||||||
|
|
||||||
/* value, description, characteristic, prev */
|
|
||||||
// # define STATUS_LITERALISE_FORMAT "%d \"%s\" %d %p"
|
|
||||||
/* identity, prev->identity, value, characteristic, description, <loc> */
|
|
||||||
// # define STATUS_LITERALISE_FORMAT "%s (prev: %s): $=%d @=%d\n\t\"%s\"\n\t%s"
|
|
||||||
|
|
||||||
// MaximumLiteralisationLengthExceeded (prev: MaximumLengthExceeded): $=1 @=1
|
|
||||||
|
|
||||||
/*
|
|
||||||
MaximumLengthExceeded: "Buffer was too long."
|
|
||||||
predecessor=<ArrayLengthError> value=(1) characteristic=[1]
|
|
||||||
at line 40, in Main, /home/william/Documents/Projects/Compound/test.c
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
// identity, description, prev->identity, value, characteristic, <loc>
|
|
||||||
# define STATUS_LITERALISE_FORMAT \
|
# define STATUS_LITERALISE_FORMAT \
|
||||||
"%s: \"%s\"\n\tpredecessor=<%s> value=(%d) characteristic=[%d]\n\t%s\n"
|
"%s: \"%s\"\n\tpredecessor=<%s> value=(%d) characteristic=(%d)\n\t%s\n"
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
REPORT_SENDING_PRIORITY_ALL = 0, // Highest level; least value.
|
|
||||||
REPORT_SENDING_PRIORITY_FATAL,
|
|
||||||
REPORT_SENDING_PRIORITY_EXCEPTIONAL,
|
|
||||||
REPORT_SENDING_PRIORITY_CRITICAL,
|
|
||||||
REPORT_SENDING_PRIORITY_MAJOR,
|
|
||||||
REPORT_SENDING_PRIORITY_NORMAL,
|
|
||||||
REPORT_SENDING_PRIORITY_MINOR,
|
|
||||||
REPORT_SENDING_PRIORITY_DEBUG,
|
|
||||||
REPORT_SENDING_PRIORITY_NONE, // Lowest level, greatest value.
|
|
||||||
} ReportSendingPriority;
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
REPORT_SENDING_TASK_STATUS_FINISHED = 0,
|
|
||||||
REPORT_SENDING_TASK_STATUS_PENDING,
|
|
||||||
REPORT_SENDING_TASK_STATUS_PROCEEDING,
|
|
||||||
REPORT_SENDING_TASK_STATUS_PAUSED,
|
|
||||||
REPORT_SENDING_TASK_STATUS_NOTFOUND
|
|
||||||
} ReportSendingTaskStatus;
|
|
||||||
|
|
||||||
/* "Report" recollects essential informations, included but not limited to
|
|
||||||
Status and others for making an report for debugging and such. */
|
|
||||||
typedef struct {
|
|
||||||
Status status;
|
|
||||||
char *initiator;
|
|
||||||
time_t time;
|
|
||||||
ReportSendingPriority priority;
|
|
||||||
ReportSendingTaskStatus taskprint_status;
|
|
||||||
FILE *dest; // The destination where the report is sending to.
|
|
||||||
} Report;
|
|
||||||
|
|
||||||
/*
|
|
||||||
|
|
||||||
DATETIME [PRIORITY] STATUSNAME (ORIGINATOR): STATUS.DESCRIPTION
|
|
||||||
at LOCATION.FILE:LOCATION.LINE, LOCATION.FUNC
|
|
||||||
at LOCATION.FILE:LOCATION.LINE, LOCATION.FUNC
|
|
||||||
at LOCATION.FILE:LOCATION.LINE, LOCATION.FUNC
|
|
||||||
at LOCATION.FILE:LOCATION.LINE, LOCATION.FUNC
|
|
||||||
|
|
||||||
|
|
||||||
Fri 10 May 03:02:37 CST 2024 [EXCEPTIONAL] InvalidParameter (Nullity): Given buffer was unavailable.
|
|
||||||
at /external/Documents/Projects/Compound/Status/src/status.c:104, Report_Literalise
|
|
||||||
at /external/Documents/Projects/Compound/Status/src/status.c:114, ReportSender_Send
|
|
||||||
at /external/Documents/Projects/Compound/Status/src/status.c:69, _throw
|
|
||||||
!!!!at /external/Documents/Projects/Compound/Array/src/array.c:16, array_create
|
|
||||||
at /external/Documents/Projects/Compound/test.c:24, main
|
|
||||||
|
|
||||||
*/
|
|
||||||
|
|
||||||
# define REPORT_LITERALISE_HEADER_FORMAT "%s [%s] %s (%s): %s"
|
|
||||||
# define REPORT_LITERALISE_CHAINS_FORMAT " at %s:%d, %s"
|
|
||||||
# define REPORT_LITERALISE_CHAINS_EXCLAIM_FORMAT "!!!!at %s:%d, %s"
|
|
||||||
|
|
||||||
typedef enum {
|
|
||||||
REPORT_SENDER_RESULT_FINISHED,
|
|
||||||
REPORT_SENDER_RESULT_PROGRESSING,
|
|
||||||
REPORT_SENDER_RESULT_PENDING
|
|
||||||
} ReportSenderResult;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
thrd_t thread;
|
|
||||||
Report *report; // The report for sending.
|
|
||||||
time_t elapsed; // The individual elapsed time for each report. (Array)
|
|
||||||
ReportSenderResult result;
|
|
||||||
bool successful;
|
|
||||||
} ReportSender;
|
|
||||||
|
|
||||||
typedef int (*ReportSendingTask)(Report *rep);
|
|
||||||
typedef int ReportSendingTaskID;
|
|
||||||
|
|
||||||
typedef struct {
|
|
||||||
ReportSendingTask *tasks; // Array Ref
|
|
||||||
int sendercount;
|
|
||||||
int finishedcount;
|
|
||||||
int *results; // Array
|
|
||||||
} ReportSendingManager;
|
|
||||||
|
|
||||||
// typedef thrd_start_t ArgueStart;
|
// typedef thrd_start_t ArgueStart;
|
||||||
|
|
||||||
@@ -219,30 +114,13 @@ Status Location_Literalise(Location *inst, char *buff);
|
|||||||
bool Location_Equals(Location lc1, Location lc2);
|
bool Location_Equals(Location lc1, Location lc2);
|
||||||
Status Status_Literalise(Status *inst, char *buff);
|
Status Status_Literalise(Status *inst, char *buff);
|
||||||
bool Status_Equal(Status *stat1, Status *stat2);
|
bool Status_Equal(Status *stat1, Status *stat2);
|
||||||
void StatusUtils_Dump(Status *inst, Status *store, int idx);
|
// void StatusUtils_Dump(Status *inst, Status **store, int idx);
|
||||||
|
void StatusUtils_Dump(Status *inst, Status *store);
|
||||||
bool StatusUtils_HasPrev(Status inst);
|
bool StatusUtils_HasPrev(Status inst);
|
||||||
bool StatusUtils_IsOkay(Status inst);
|
bool StatusUtils_IsOkay(Status inst);
|
||||||
bool StatusUtils_IsRecursive(Status inst);
|
bool StatusUtils_IsRecursive(Status inst);
|
||||||
int StatusUtils_Depth(Status *inst);
|
int StatusUtils_Depth(Status *inst);
|
||||||
|
|
||||||
Status Report_Create(Report *inst, Status *stat, FILE *dest, char *initiator,
|
|
||||||
int priority);
|
|
||||||
Status Report_CopyOf(Report *inst, Report *other);
|
|
||||||
Status Report_Literalise(Report *inst, char *buff);
|
|
||||||
void Report_Delete(Report *inst);
|
|
||||||
bool Report_Equals(Report repo1, Report repo2);
|
|
||||||
|
|
||||||
Status ReportSender_Create(ReportSender *inst, Report *report);
|
|
||||||
Status ReportSender_Send(ReportSender *inst, ReportSendingTask task);
|
|
||||||
// ReportSendingTaskStatus
|
|
||||||
// ReportSender_GetStatus(ReportSender *inst);
|
|
||||||
|
|
||||||
ReportSendingTaskID
|
|
||||||
ReportSenderManager_AppendTask(ReportSendingManager *inst,
|
|
||||||
ReportSendingTask task);
|
|
||||||
Status ReportSenderManager_RemoveTask(ReportSendingManager *inst,
|
|
||||||
ReportSendingTaskID taskid);
|
|
||||||
|
|
||||||
// Status
|
// Status
|
||||||
// arguestarter_create(ArgueStartParam *inst, void *external_param);
|
// arguestarter_create(ArgueStartParam *inst, void *external_param);
|
||||||
// Status
|
// Status
|
||||||
@@ -265,9 +143,9 @@ Status ReportSenderManager_RemoveTask(ReportSendingManager *inst,
|
|||||||
|
|
||||||
// ---------------------ELEMENTARY-------------------------
|
// ---------------------ELEMENTARY-------------------------
|
||||||
|
|
||||||
DEFSTATUS(UnknownStatus, -1, "An unknown status.", STATUS_UNKNOWN, NULL);
|
DEFSTATUS(UnknownStatus, -1, "An unknown status.", STATUS_UNKNOWN, &UnknownStatus);
|
||||||
DEFSTATUS(NormalStatus, 0, "A normal status.", STATUS_NORMAL, NULL);
|
DEFSTATUS(NormalStatus, 0, "A normal status.", STATUS_NORMAL, &NormalStatus);
|
||||||
DEFSTATUS(ErrorStatus, 1, "An error status.", STATUS_ERROR, NULL);
|
DEFSTATUS(ErrorStatus, 1, "An error status.", STATUS_ERROR, &ErrorStatus);
|
||||||
|
|
||||||
// ----------------------EXTENDED--------------------------
|
// ----------------------EXTENDED--------------------------
|
||||||
|
|
||||||
@@ -287,14 +165,6 @@ DEFSTATUS(UnavailableObject, 1,
|
|||||||
"An unavailable object was presented.",
|
"An unavailable object was presented.",
|
||||||
STATUS_ERROR, &ErrorStatus);
|
STATUS_ERROR, &ErrorStatus);
|
||||||
|
|
||||||
DEFSTATUS(InstanceStillAlive, 1,
|
|
||||||
"Given instance was yet alive.",
|
|
||||||
STATUS_ERROR, &ErrorStatus);
|
|
||||||
|
|
||||||
DEFSTATUS(InstanceNotAlive, 1,
|
|
||||||
"Given instance for reallocation was not alive.",
|
|
||||||
STATUS_ERROR, &ErrorStatus);
|
|
||||||
|
|
||||||
DEFSTATUS(InvalidParameter, 1,
|
DEFSTATUS(InvalidParameter, 1,
|
||||||
"An invalid parameter was presented.",
|
"An invalid parameter was presented.",
|
||||||
STATUS_ERROR, &InvalidObject);
|
STATUS_ERROR, &InvalidObject);
|
||||||
@@ -311,10 +181,30 @@ DEFSTATUS(IntegerOverFlow, 1,
|
|||||||
"An integer had overflowed.",
|
"An integer had overflowed.",
|
||||||
STATUS_ERROR, &ArithmeticError);
|
STATUS_ERROR, &ArithmeticError);
|
||||||
|
|
||||||
|
DEFSTATUS(InvalidOperation, 1,
|
||||||
|
"An invalid operation was detected.",
|
||||||
|
STATUS_ERROR, &ErrorStatus);
|
||||||
|
|
||||||
DEFSTATUS(RuntimeError, 1,
|
DEFSTATUS(RuntimeError, 1,
|
||||||
"A runtime error occurred.",
|
"A runtime error occurred.",
|
||||||
STATUS_ERROR, &ErrorStatus);
|
STATUS_ERROR, &ErrorStatus);
|
||||||
|
|
||||||
|
DEFSTATUS(InstanceStillAlive, 1,
|
||||||
|
"Given instance was still alive.",
|
||||||
|
STATUS_ERROR, &RuntimeError);
|
||||||
|
|
||||||
|
DEFSTATUS(InstanceNotAlive, 1,
|
||||||
|
"Given instance for reallocation was not alive.",
|
||||||
|
STATUS_ERROR, &RuntimeError);
|
||||||
|
|
||||||
|
DEFSTATUS(InvalidOperationBetweenAliveAndNonAlive, 1,
|
||||||
|
"Given two instances were incompatible with each other for any operation.",
|
||||||
|
STATUS_ERROR, &InvalidOperation);
|
||||||
|
|
||||||
|
DEFSTATUS(InstanceCreatingFailure, 1,
|
||||||
|
"Cannot create the instance.",
|
||||||
|
STATUS_ERROR, &RuntimeError);
|
||||||
|
|
||||||
DEFSTATUS(ArrayLengthError, 1,
|
DEFSTATUS(ArrayLengthError, 1,
|
||||||
"Given array length does not meet the requirement.",
|
"Given array length does not meet the requirement.",
|
||||||
STATUS_ERROR, &ErrorStatus);
|
STATUS_ERROR, &ErrorStatus);
|
||||||
@@ -403,72 +293,71 @@ DEFSTATUS(InvalidLiteralisingBuffer, 1,
|
|||||||
"Given buffer does not have a good integrity on its length.",
|
"Given buffer does not have a good integrity on its length.",
|
||||||
STATUS_ERROR, &InvalidObject);
|
STATUS_ERROR, &InvalidObject);
|
||||||
|
|
||||||
|
DEFSTATUS(NoBytesWereRead, 1,
|
||||||
|
"Called function had returned ZERO indicating no bytes were read.",
|
||||||
|
STATUS_ERROR, &ReadWriteError);
|
||||||
|
|
||||||
|
DEFSTATUS(NoBytesWereWritten, 1,
|
||||||
|
"Called function had returned ZERO indicating no bytes were written.",
|
||||||
|
STATUS_ERROR, &ReadWriteError);
|
||||||
|
|
||||||
|
// DEFSTATUS(ProgrammeConstructionError, 1,
|
||||||
|
// "Failed on constructing programme at the entrance.",
|
||||||
|
// STATUS_ERROR, &RuntimeError);
|
||||||
|
|
||||||
// ========================================================
|
// ========================================================
|
||||||
|
|
||||||
static inline Status PrintStatus(Status s)
|
static inline Status PrintStatus(Status s)
|
||||||
{
|
{
|
||||||
|
/* Literalise. */
|
||||||
char buff[LITERALISATION_LENGTH_MAXIMUM];
|
char buff[LITERALISATION_LENGTH_MAXIMUM];
|
||||||
(void)Status_Literalise(&s, buff);
|
|
||||||
|
|
||||||
|
/* Handle returning value. */
|
||||||
|
/* No bytes were written to buffer. */
|
||||||
|
unsure(Status_Literalise(&s, buff), !_.value, {
|
||||||
|
return apply(NoBytesWereWritten);
|
||||||
|
})
|
||||||
|
|
||||||
|
/* Output. */
|
||||||
where(fprintf(stderr, "%s\n", buff), {
|
where(fprintf(stderr, "%s\n", buff), {
|
||||||
|
/* Pass on returning value. */
|
||||||
return apply(value(TraditionalFunctionReturn, _));
|
return apply(value(TraditionalFunctionReturn, _));
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
static inline void PrintStatusDump(Status s)
|
static inline void PrintStatusDump(Status s)
|
||||||
{
|
{
|
||||||
Status stat = s;
|
/* Create dump. */
|
||||||
const int dump_len = StatusUtils_Depth(&stat);
|
/* Calculate depth for dumping. */
|
||||||
|
const int dump_len = StatusUtils_Depth(&s);
|
||||||
|
|
||||||
|
/* Skip when "s" is either unavailable or is at the buttom of status stack. */
|
||||||
|
if (dump_len == -1) {
|
||||||
|
PrintStatus(s);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
Status dump[dump_len];
|
Status dump[dump_len];
|
||||||
StatusUtils_Dump(&stat, dump, 0);
|
Status current = s;
|
||||||
/* TODO(william): Replace following line with coloured-term-output function. */
|
dump[0] = current; // Put self at leading.
|
||||||
(void)printf("\e[1m======== STATUS STACK DUMP: %s ========\e[0m\n",
|
for (register int i = 1; i < dump_len; i++) {
|
||||||
stat.identity);
|
// StatusUtils_Dump will only access (storage) the prev.
|
||||||
|
// It does not include this status itself.
|
||||||
|
StatusUtils_Dump(¤t, &dump[i]);
|
||||||
|
|
||||||
|
current = *current.prev;
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Output by iterating. */
|
||||||
for (register int i = 0; i < dump_len; i++) {
|
for (register int i = 0; i < dump_len; i++) {
|
||||||
/* TODO(william): Replace following line with coloured-term-output function. */
|
/* Print out indexer. */
|
||||||
(void)printf("\e[1m[%d/%d]\e[0m\n", (dump_len - i), dump_len);
|
(void)printf("\e[1m[%d/%d]\e[0m", (dump_len - i), dump_len);
|
||||||
seek(PrintStatus(dump[i]), {
|
|
||||||
solve(!_.value, {
|
/* Print dumped status. */
|
||||||
(void)fprintf(stderr, "\e[38;5;9m!!!!!!!! PRINT DUMP FAILED !!!!!!!!"
|
unsure(PrintStatus(dump[i]), !_.value, {
|
||||||
"\e[0m\n");
|
(void)fprintf(stderr, "Unable to literalise.\n");
|
||||||
(void)PrintStatus(_);
|
|
||||||
})
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ========================================================
|
|
||||||
|
|
||||||
/* Throw the report created with $e if $e is abnormal, commented with $c. */
|
|
||||||
# define ensure(e, c) { \
|
|
||||||
Status stat = e; \
|
|
||||||
solve(!(StatusUtils_IsOkay(stat)), { \
|
|
||||||
Report rep = stamp(error(stat, c), (char *)__func__); \
|
|
||||||
(void)throw(rep); \
|
|
||||||
return ReportThrown; \
|
|
||||||
}) \
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Throw the report created with $s if $e is abnormal, commented with $c. */
|
|
||||||
# define match(s, e, c) { \
|
|
||||||
Status stat = s; \
|
|
||||||
solve(!(StatusUtils_IsOkay(e)), { \
|
|
||||||
Report rep = stamp(error(stat, c), (char *)__func__); \
|
|
||||||
(void)throw(rep); \
|
|
||||||
return ReportThrown; \
|
|
||||||
}) \
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Add location parameter requirement in order to give proper information
|
|
||||||
* before throwing the report out. */
|
|
||||||
# define throw(report) THROW(report, __HERE__)
|
|
||||||
|
|
||||||
/* Useless in C, only for human to see.
|
|
||||||
Probably rewrite this in Classify. */
|
|
||||||
# define throws(e)
|
|
||||||
|
|
||||||
ReportSendingTaskID THROW(Report report, Location loc);
|
|
||||||
Report CATCH(ReportSendingTaskID taskid);
|
|
||||||
int HANDLER(void *report);
|
|
||||||
|
|
||||||
#endif /* COMPOUND_STATUS_H */
|
#endif /* COMPOUND_STATUS_H */
|
||||||
|
@@ -2,30 +2,14 @@
|
|||||||
|
|
||||||
Status Location_Literalise(Location *inst, char *buff)
|
Status Location_Literalise(Location *inst, char *buff)
|
||||||
{
|
{
|
||||||
fails(inst, apply(UnavailableInstance));
|
nonull(inst, apply(UnavailableInstance));
|
||||||
fails(buff, apply(UnavailableBuffer));
|
nonull(buff, apply(UnavailableBuffer));
|
||||||
|
|
||||||
/* Literalise line. */
|
where(
|
||||||
char line_buff[LITERALISATION_LENGTH_MAXIMUM];
|
snprintf(buff, LITERALISATION_LENGTH_MAXIMUM,
|
||||||
Utils_LiteraliseInteger(inst->line, line_buff);
|
LOCATION_LITERALISE_FORMAT,inst->file,inst->line,inst->func),
|
||||||
|
return apply(value(TraditionalFunctionReturn, _));
|
||||||
/* Concatenate every buff. */
|
);
|
||||||
const long total_len = strlen(strnil(inst->file)) + strlen(strnil(line_buff))
|
|
||||||
+ strlen(strnil(inst->func))
|
|
||||||
+ LOCATION_LITERALISE_FORMAT_LENGTH;
|
|
||||||
|
|
||||||
state(total_len > LITERALISATION_LENGTH_MAXIMUM,
|
|
||||||
apply(MaximumLiteralisationLengthExceeded));
|
|
||||||
|
|
||||||
/* Copy and assign. */
|
|
||||||
// return value(UnknownStatus,
|
|
||||||
// !sprintf(buff, LOCATION_LITERALISE_FORMAT,
|
|
||||||
// inst->file, inst->line, inst->func));
|
|
||||||
const int written =
|
|
||||||
sprintf(buff, LOCATION_LITERALISE_FORMAT,inst->file,inst->line,inst->func);
|
|
||||||
|
|
||||||
// written in "value" is absolutely ZERO.
|
|
||||||
state(!written, apply(value(UnknownStatus, written)));
|
|
||||||
|
|
||||||
return apply(NormalStatus);
|
return apply(NormalStatus);
|
||||||
}
|
}
|
||||||
@@ -43,25 +27,26 @@ bool Status_Equal(Status *stat1, Status *stat2)
|
|||||||
state(stat1 == NULL || stat2 == NULL, false);
|
state(stat1 == NULL || stat2 == NULL, false);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
|
!strcmp(stat1->identity, stat2->identity) &&
|
||||||
stat1->value == stat2->value &&
|
stat1->value == stat2->value &&
|
||||||
!strcmp(stat1->description, stat2->description) &&
|
!strcmp(stat1->description, stat2->description) &&
|
||||||
stat1->characteristic == stat2->characteristic &&
|
stat1->characteristic == stat2->characteristic &&
|
||||||
Location_Equal(&stat1->loc, &stat2->loc) &&
|
Location_Equal(&stat1->loc, &stat2->loc) &&
|
||||||
((StatusUtils_HasPrev(*stat1) && StatusUtils_HasPrev(*stat2))
|
stat1->prev == stat2->prev
|
||||||
? Status_Equal(stat1->prev, stat2->prev)
|
|
||||||
: true)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status Status_Literalise(Status *inst, char *buff)
|
Status Status_Literalise(Status *inst, char *buff)
|
||||||
{
|
{
|
||||||
/* Skip unavailable instance and invalid parameter. */
|
/* Skip unavailable instance and invalid parameter. */
|
||||||
fails(inst, apply(UnavailableInstance));
|
nonull(inst, apply(UnavailableInstance));
|
||||||
fails(buff, apply(UnavailableBuffer));
|
nonull(buff, apply(UnavailableBuffer));
|
||||||
|
|
||||||
/* Literalise loc. */
|
/* Literalise loc. */
|
||||||
char loc_buff[LITERALISATION_LENGTH_MAXIMUM];
|
char loc_buff[LITERALISATION_LENGTH_MAXIMUM] = EMPTY;
|
||||||
notok(Location_Literalise(&inst->loc, loc_buff), {
|
(void)printf("%s\n", loc_buff);
|
||||||
|
unsure(Location_Literalise(&inst->loc, loc_buff), !_.value, {
|
||||||
|
(void)printf("failed on loc liter.\n");
|
||||||
return apply(_);
|
return apply(_);
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -80,13 +65,13 @@ Status Status_Literalise(Status *inst, char *buff)
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Concatenate every buffer. */
|
/* Concatenate every buffer. */
|
||||||
where(sprintf(buff, fmt, inst->identity, inst->description,
|
where(
|
||||||
(!inst->prev
|
snprintf(buff, LITERALISATION_LENGTH_MAXIMUM, fmt, inst->identity,
|
||||||
? "(null)"
|
inst->description,
|
||||||
: (inst->prev->identity)),
|
(!inst->prev ? "(null)" : (inst->prev->identity)),
|
||||||
inst->value, inst->characteristic, loc_buff), {
|
inst->value, inst->characteristic, loc_buff), {
|
||||||
return apply(value(TraditionalFunctionReturn, _));
|
return apply(value(TraditionalFunctionReturn, _));
|
||||||
})
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
bool StatusUtils_HasPrev(Status stat)
|
bool StatusUtils_HasPrev(Status stat)
|
||||||
@@ -101,17 +86,18 @@ bool StatusUtils_IsOkay(Status stat)
|
|||||||
|
|
||||||
bool StatusUtils_IsRecursive(Status stat)
|
bool StatusUtils_IsRecursive(Status stat)
|
||||||
{
|
{
|
||||||
return (stat.prev && stat.prev == &stat);
|
// return (stat.prev && stat.prev == stat.prev->prev);
|
||||||
|
return (stat.prev && Status_Equal(&stat, stat.prev));
|
||||||
}
|
}
|
||||||
|
|
||||||
void StatusUtils_Dump(Status *inst, Status *store, int idx)
|
void StatusUtils_Dump(Status *inst, Status *store)
|
||||||
{
|
{
|
||||||
/* Skip when either stat or stat.prev is unavailable, or, idx is invalid. */
|
/* Skip when store is unavailable, or, inst is unavailable,
|
||||||
svoid((!inst || !store || idx < 0));
|
recursive or does not have any predecessor. */
|
||||||
|
svoid(!inst || !store
|
||||||
|
|| StatusUtils_IsRecursive(*inst) || !StatusUtils_HasPrev(*inst));
|
||||||
|
|
||||||
store[idx] = *inst;
|
*store = *inst->prev;
|
||||||
|
|
||||||
StatusUtils_Dump(inst->prev, store, ++idx);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
int StatusUtils_Depth(Status *stat)
|
int StatusUtils_Depth(Status *stat)
|
||||||
@@ -119,162 +105,22 @@ int StatusUtils_Depth(Status *stat)
|
|||||||
/* Skip unavailable stat. */
|
/* Skip unavailable stat. */
|
||||||
state((!stat || !stat->prev), -1);
|
state((!stat || !stat->prev), -1);
|
||||||
|
|
||||||
Status *p = stat; // Include this layer of Status.
|
/* Set up counter. */
|
||||||
register int cnt;
|
int cnt = 1;
|
||||||
for (cnt = 0; (!StatusUtils_IsRecursive(*p)
|
/* Set up current status indication representor. */
|
||||||
&& StatusUtils_HasPrev(*p)); cnt++) {
|
Status current = *stat;
|
||||||
p = p->prev;
|
/* Iterate to accumulate. */
|
||||||
|
while (current.prev) {
|
||||||
|
/* Skip recursive status. */
|
||||||
|
if (StatusUtils_IsRecursive(current)) break;
|
||||||
|
|
||||||
|
current = *current.prev;
|
||||||
|
cnt += 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
return cnt;
|
return cnt;
|
||||||
}
|
}
|
||||||
|
|
||||||
Status Report_Create(Report *inst, Status *stat, FILE *dest, char *initiator,
|
|
||||||
int priority)
|
|
||||||
{
|
|
||||||
/* Skip unavailable parameters. */
|
|
||||||
fails(inst, apply(UnavailableInstance));
|
|
||||||
fails(stat, apply(error(InvalidParameter, "Given stat was null.")));
|
|
||||||
fails(initiator, apply(error(InvalidParameter, "Given initiator was null.")));
|
|
||||||
state(priority < 0, apply(error(InvalidParameter, "Given priority was negative.")));
|
|
||||||
|
|
||||||
/* Copy and assign. */
|
|
||||||
inst->status = *stat;
|
|
||||||
inst->initiator = calloc(strlen(initiator), sizeof(char));
|
|
||||||
(void)strcpy(inst->initiator, initiator);
|
|
||||||
inst->time = time(NULL);
|
|
||||||
inst->priority = priority;
|
|
||||||
inst->taskprint_status = REPORT_SENDING_TASK_STATUS_PENDING;
|
|
||||||
inst->dest = (dest == NULL ? stdout : dest);
|
|
||||||
|
|
||||||
return apply(NormalStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
Status Report_CopyOf(Report *inst, Report *other)
|
|
||||||
{
|
|
||||||
fails(inst, apply(UnavailableInstance));
|
|
||||||
fails(other, apply(error(InvalidParameter, "Given report is unavailable.")));
|
|
||||||
|
|
||||||
// Status status;
|
|
||||||
// char *initiator;
|
|
||||||
// time_t time;
|
|
||||||
// ReportSendingPriority priority;
|
|
||||||
// ReportSendingTaskStatus taskprint_status;
|
|
||||||
// FILE *dest;
|
|
||||||
inst->status = other->status;
|
|
||||||
|
|
||||||
return apply(NormalStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Report_Delete(Report *inst)
|
|
||||||
{
|
|
||||||
svoid(inst);
|
|
||||||
|
|
||||||
free(inst->initiator);
|
|
||||||
inst->initiator = NULL;
|
|
||||||
inst->dest = NULL;
|
|
||||||
inst->priority = 0;
|
|
||||||
inst->status = (Status){};
|
|
||||||
inst->taskprint_status = REPORT_SENDING_TASK_STATUS_NOTFOUND;
|
|
||||||
inst->time = 0;
|
|
||||||
inst = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
Status Report_Literalise(Report *inst, char *buff)
|
|
||||||
{
|
|
||||||
fails(inst, apply(UnavailableInstance));
|
|
||||||
fails(buff, apply(UnavailableBuffer));
|
|
||||||
// state(strlen(buff) != LITERALISATION_LENGTH_MAXIMUM,
|
|
||||||
// InvalidLiteralisingBuffer);
|
|
||||||
|
|
||||||
/* Report literalisation. */
|
|
||||||
int idx = 0;
|
|
||||||
char report_literalising[LITERALISATION_LENGTH_MAXIMUM];
|
|
||||||
|
|
||||||
/** Status literalisation. **/
|
|
||||||
char status_literalising[LITERALISATION_LENGTH_MAXIMUM];
|
|
||||||
(void)Status_Literalise(&inst->status, status_literalising);
|
|
||||||
idx += strlen(status_literalising);
|
|
||||||
/** fin **/
|
|
||||||
|
|
||||||
/** Initiator literalisation. **/
|
|
||||||
idx += strlen(inst->initiator);
|
|
||||||
/** fin **/
|
|
||||||
|
|
||||||
/** Time literalisation. **/
|
|
||||||
char time_literalising[LITERALISATION_LENGTH_MAXIMUM];
|
|
||||||
idx += Utils_LiteraliseInteger(inst->time, time_literalising);
|
|
||||||
/** fin **/
|
|
||||||
|
|
||||||
/** Priority literalisation. **/
|
|
||||||
char priority_literalising[LITERALISATION_LENGTH_MAXIMUM];
|
|
||||||
idx += Utils_LiteraliseInteger(inst->priority, priority_literalising);
|
|
||||||
/** fin **/
|
|
||||||
|
|
||||||
/** Taskprint_status literalisation. **/
|
|
||||||
char taskprint_status_literalising[LITERALISATION_LENGTH_MAXIMUM];
|
|
||||||
idx += Utils_LiteraliseInteger(inst->taskprint_status, taskprint_status_literalising);
|
|
||||||
/** fin **/
|
|
||||||
|
|
||||||
/** Dest literalisation. **/
|
|
||||||
char dest_literalising[LITERALISATION_LENGTH_MAXIMUM];
|
|
||||||
idx += Utils_LiteraliseInteger((long long int)inst->dest, dest_literalising);
|
|
||||||
/** fin **/
|
|
||||||
|
|
||||||
if (idx >= LITERALISATION_LENGTH_MAXIMUM) {
|
|
||||||
buff = NULL;
|
|
||||||
return MaximumLiteralisationLengthExceeded;
|
|
||||||
}
|
|
||||||
|
|
||||||
strcpy(report_literalising, status_literalising);
|
|
||||||
strcpy(report_literalising, time_literalising);
|
|
||||||
strcpy(report_literalising, priority_literalising);
|
|
||||||
strcpy(report_literalising, taskprint_status_literalising);
|
|
||||||
strcpy(report_literalising, dest_literalising);
|
|
||||||
|
|
||||||
strcpy(buff, report_literalising);
|
|
||||||
/* fin */
|
|
||||||
|
|
||||||
return apply(NormalStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
Status ReportSender_Create(ReportSender *inst, Report *report)
|
|
||||||
{
|
|
||||||
fails(inst, apply(UnavailableInstance));
|
|
||||||
fails(report, error(UnavailableParameter, "Given report was unavailable."));
|
|
||||||
|
|
||||||
thrd_create(&inst->thread, &HANDLER, report);
|
|
||||||
notok(Report_CopyOf(inst->report, report),
|
|
||||||
return error(ErrorStatus, "Cannot copy to create new instance of report.");
|
|
||||||
) // *inst->report = *report;
|
|
||||||
inst->elapsed = 0;
|
|
||||||
inst->result = REPORT_SENDER_RESULT_PENDING;
|
|
||||||
inst->successful = false;
|
|
||||||
|
|
||||||
return apply(NormalStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
Status ReportSender_Send(ReportSender *inst, ReportSendingTask task)
|
|
||||||
{
|
|
||||||
// /* Skip when inst or task is unavailable. */
|
|
||||||
// fails(inst,
|
|
||||||
// error(UnavailableInstance, "Report sender was given unavailable."));
|
|
||||||
// fails(task, InvalidReportTask);
|
|
||||||
|
|
||||||
// /* Assign for dest. */
|
|
||||||
// const FILE *dest = (inst->report->dest == NULL ? stdout : inst->report->dest);
|
|
||||||
// // char buff[];
|
|
||||||
// // TODO(william): HERE, Report_Literalise
|
|
||||||
|
|
||||||
// /* Write/Send data. */
|
|
||||||
// inst->report->taskprint_status = REPORT_SENDING_TASK_STATUS_PROCEEDING;
|
|
||||||
// if (!fprintf(dest, buff)) {
|
|
||||||
// }
|
|
||||||
|
|
||||||
// /* Sent successfully! Mark down properties. */
|
|
||||||
return apply(NormalStatus);
|
|
||||||
}
|
|
||||||
|
|
||||||
// bool arguestarter_equal(ArgueStarter *inst1, ArgueStarter *inst2)
|
// bool arguestarter_equal(ArgueStarter *inst1, ArgueStarter *inst2)
|
||||||
// {
|
// {
|
||||||
// /* Skip when either inst1 or inst2 is unavailable. */
|
// /* Skip when either inst1 or inst2 is unavailable. */
|
||||||
@@ -283,65 +129,3 @@ Status ReportSender_Send(ReportSender *inst, ReportSendingTask task)
|
|||||||
// return (inst1->argue_start == inst2->argue_start)
|
// return (inst1->argue_start == inst2->argue_start)
|
||||||
// || (inst1->external_param == inst2->external_param);
|
// || (inst1->external_param == inst2->external_param);
|
||||||
// }
|
// }
|
||||||
|
|
||||||
ReportSendingTaskID THROW(Report report, Location loc)
|
|
||||||
{
|
|
||||||
// // /* Create new a instance of ReportSender. */
|
|
||||||
// // ReportSender sender;
|
|
||||||
// // ReportSender_Create(&sender, stderr);
|
|
||||||
|
|
||||||
// // /* Send message. */
|
|
||||||
// // /* Initialise sender's thread. */
|
|
||||||
// // thrd_t sending;
|
|
||||||
// // /* Skip on failing on creating thread. */
|
|
||||||
// // if (!thrd_create(&sending, starter, NULL)) {
|
|
||||||
|
|
||||||
// // /* Conclude the session of sender. */
|
|
||||||
// // report.status = REPORT_SENDING_TASK_STATUS_FINISHED,
|
|
||||||
// // report.result = (ARGUE_RESULT_FINALISED | ARGUE_RESULT_NEGATIVE);
|
|
||||||
|
|
||||||
// // sender.result = REPORT_SENDER_RESULT_FINISHED;
|
|
||||||
// // sender.successful = false;
|
|
||||||
|
|
||||||
// // return -1;
|
|
||||||
// // }
|
|
||||||
|
|
||||||
// // /* Perform sending. */
|
|
||||||
// // ReportSender_Send(&sender, NULL);
|
|
||||||
|
|
||||||
// /* Initialise sender. */
|
|
||||||
// ReportSender sender;
|
|
||||||
// /* Return with -1 when initialisation failed. */
|
|
||||||
// state(!(StatusUtils_IsOkay(ReportSender_Create(&sender, &report))), -1);
|
|
||||||
|
|
||||||
// /* Inject location information. Could be more elegant, though. */
|
|
||||||
// sender.report->status.loc = loc;
|
|
||||||
|
|
||||||
// /* Send. */ /* Return -1 when failed on sending. */
|
|
||||||
// state(!StatusUtils_IsOkay(ReportSender_Send(&sender, HANDLER)), -1);
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int HANDLER(void *report)
|
|
||||||
{
|
|
||||||
// /* Throw UnableToThrowError when param is unavailable. */
|
|
||||||
// if (report == NULL) {
|
|
||||||
// /* Create report on this. */
|
|
||||||
// Report e;
|
|
||||||
// Report_Create(
|
|
||||||
// &e,
|
|
||||||
// &error(UnableToThrowError, "Cannot perform throwing. Aborted."),
|
|
||||||
// stderr, nameof(DEFAULT_ARGUE_STARTER),
|
|
||||||
// REPORT_SENDING_PRIORITY_FATAL);
|
|
||||||
|
|
||||||
// /* Perform throwing. */
|
|
||||||
// (void)throw(e); // Throw the report alone.
|
|
||||||
// return 1;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// (void)throw(*(Report *)report); // Lonely throw, no catch will company.
|
|
||||||
// return 0;
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
213
Status/status_test.c
Normal file
213
Status/status_test.c
Normal file
@@ -0,0 +1,213 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
#include <time.h>
|
||||||
|
|
||||||
|
#include <Compound/status.h>
|
||||||
|
|
||||||
|
int main(void) {
|
||||||
|
|
||||||
|
Status Example1Status = {.description = "Example1 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &NormalStatus};
|
||||||
|
Status Example2Status = {.description = "Example2 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example1Status};
|
||||||
|
Status Example3Status = {.description = "Example3 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example2Status};
|
||||||
|
Status Example4Status = {.description = "Example4 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example3Status};
|
||||||
|
Status Example5Status = {.description = "Example5 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example4Status};
|
||||||
|
Status Example6Status = {.description = "Example6 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example5Status};
|
||||||
|
Status Example7Status = {.description = "Example7 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example6Status};
|
||||||
|
Status Example8Status = {.description = "Example8 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example7Status};
|
||||||
|
Status Example9Status = {.description = "Example9 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example8Status};
|
||||||
|
Status Example10Status = {.description = "Example10 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example9Status};
|
||||||
|
Status Example11Status = {.description = "Example11 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example10Status};
|
||||||
|
Status Example12Status = {.description = "Example12 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example11Status};
|
||||||
|
Status Example13Status = {.description = "Example13 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example12Status};
|
||||||
|
Status Example14Status = {.description = "Example14 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example13Status};
|
||||||
|
Status Example15Status = {.description = "Example15 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example14Status};
|
||||||
|
Status Example16Status = {.description = "Example16 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example15Status};
|
||||||
|
Status Example17Status = {.description = "Example17 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example16Status};
|
||||||
|
Status Example18Status = {.description = "Example18 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example17Status};
|
||||||
|
Status Example19Status = {.description = "Example19 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example18Status};
|
||||||
|
Status Example20Status = {.description = "Example20 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example19Status};
|
||||||
|
Status Example21Status = {.description = "Example21 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example20Status};
|
||||||
|
Status Example22Status = {.description = "Example22 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example21Status};
|
||||||
|
Status Example23Status = {.description = "Example23 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example22Status};
|
||||||
|
Status Example24Status = {.description = "Example24 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example23Status};
|
||||||
|
Status Example25Status = {.description = "Example25 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example24Status};
|
||||||
|
Status Example26Status = {.description = "Example26 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example25Status};
|
||||||
|
Status Example27Status = {.description = "Example27 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example26Status};
|
||||||
|
Status Example28Status = {.description = "Example28 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example27Status};
|
||||||
|
Status Example29Status = {.description = "Example29 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example28Status};
|
||||||
|
Status Example30Status = {.description = "Example30 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example29Status};
|
||||||
|
Status Example31Status = {.description = "Example31 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example30Status};
|
||||||
|
Status Example32Status = {.description = "Example32 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example31Status};
|
||||||
|
Status Example33Status = {.description = "Example33 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example32Status};
|
||||||
|
Status Example34Status = {.description = "Example34 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example33Status};
|
||||||
|
Status Example35Status = {.description = "Example35 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example34Status};
|
||||||
|
Status Example36Status = {.description = "Example36 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example35Status};
|
||||||
|
Status Example37Status = {.description = "Example37 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example36Status};
|
||||||
|
Status Example38Status = {.description = "Example38 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example37Status};
|
||||||
|
Status Example39Status = {.description = "Example39 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example38Status};
|
||||||
|
Status Example40Status = {.description = "Example40 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example39Status};
|
||||||
|
Status Example41Status = {.description = "Example41 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example40Status};
|
||||||
|
Status Example42Status = {.description = "Example42 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example41Status};
|
||||||
|
Status Example43Status = {.description = "Example43 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example42Status};
|
||||||
|
Status Example44Status = {.description = "Example44 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example43Status};
|
||||||
|
Status Example45Status = {.description = "Example45 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example44Status};
|
||||||
|
Status Example46Status = {.description = "Example46 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example45Status};
|
||||||
|
Status Example47Status = {.description = "Example47 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example46Status};
|
||||||
|
Status Example48Status = {.description = "Example48 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example47Status};
|
||||||
|
Status Example49Status = {.description = "Example49 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example48Status};
|
||||||
|
Status Example50Status = {.description = "Example50 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example49Status};
|
||||||
|
Status Example51Status = {.description = "Example51 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example50Status};
|
||||||
|
Status Example52Status = {.description = "Example52 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example51Status};
|
||||||
|
Status Example53Status = {.description = "Example53 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example52Status};
|
||||||
|
Status Example54Status = {.description = "Example54 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example53Status};
|
||||||
|
Status Example55Status = {.description = "Example55 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example54Status};
|
||||||
|
Status Example56Status = {.description = "Example56 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example55Status};
|
||||||
|
Status Example57Status = {.description = "Example57 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example56Status};
|
||||||
|
Status Example58Status = {.description = "Example58 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example57Status};
|
||||||
|
Status Example59Status = {.description = "Example59 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example58Status};
|
||||||
|
Status Example60Status = {.description = "Example60 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example59Status};
|
||||||
|
Status Example61Status = {.description = "Example61 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example60Status};
|
||||||
|
Status Example62Status = {.description = "Example62 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example61Status};
|
||||||
|
Status Example63Status = {.description = "Example63 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example62Status};
|
||||||
|
Status Example64Status = {.description = "Example64 Status",
|
||||||
|
.characteristic = STATUS_NORMAL,
|
||||||
|
.prev = &Example63Status};
|
||||||
|
|
||||||
|
Status statbuff[64] = {{0}};
|
||||||
|
|
||||||
|
status_dump(Example64Status, statbuff, 0);
|
||||||
|
|
||||||
|
Status *p = &Example64Status;
|
||||||
|
int cnt = 0;
|
||||||
|
while (p != NULL) {
|
||||||
|
(void)printf("%d:%d %s\n", cnt++, p->characteristic, p->description);
|
||||||
|
p = p->prev;
|
||||||
|
};
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
@@ -13,85 +13,80 @@ typedef enum {
|
|||||||
/* etc. */
|
/* etc. */
|
||||||
} StringEncoding;
|
} StringEncoding;
|
||||||
|
|
||||||
typedef Array(Char) String;
|
// typedef Array(Char) String;
|
||||||
|
typedef struct {
|
||||||
|
Array type(Char) data;
|
||||||
|
StringEncoding encoding;
|
||||||
|
} String;
|
||||||
|
|
||||||
/* Elementary. */
|
|
||||||
Status String_Create(String *inst, int len);
|
Status String_Create(String *inst, int len);
|
||||||
Status String_CopyOf(String *inst, String *other);
|
Status String_CopyOf(String *inst, String *other);
|
||||||
Status String_Delete(String *inst);
|
Status String_Delete(String *inst);
|
||||||
Status String_GetIdx(String *inst, Char *item, int index);
|
Status String_Encode(String *inst, StringEncoding encoding);
|
||||||
Status String_SetIdx(String *inst, Char *item, int index);
|
Status String_Decode(String *inst, StringEncoding encoding);
|
||||||
Status String_Literalise(String *inst, String *store);
|
Status String_Literalise(String *inst, String *store);
|
||||||
|
|
||||||
/* Extensional. */
|
Status StringUtils_FromInteger(String *inst, int value, int base);
|
||||||
Status StringUtils_FromInteger(String *inst, int value);
|
Status StringUtils_FromShortInteger(String *inst, short int value, int base);
|
||||||
Status StringUtils_FromShortInteger(String *inst, short int value);
|
Status StringUtils_FromLongInteger(String *inst, long int value, int base);
|
||||||
Status StringUtils_FromLongInteger(String *inst, long int value);
|
Status StringUtils_FromLongLongInteger(String *inst, long long int value, int base);
|
||||||
Status StringUtils_FromLongLongInteger(String *inst, long long int value);
|
Status StringUtils_FromFloat(String *inst, float value, int base);
|
||||||
Status StringUtils_FromFloat(String *inst, float value);
|
Status StringUtils_FromDouble(String *inst, double value, int base);
|
||||||
Status StringUtils_FromDouble(String *inst, double value);
|
Status StringUtils_FromLongDouble(String *inst, long double value, int base);
|
||||||
Status StringUtils_FromLongDouble(String *inst, long double value);
|
Status StringUtils_FromComplexInteger(String *inst, _Complex int value, int base);
|
||||||
Status StringUtils_FromComplexInteger(String *inst, _Complex int value);
|
Status StringUtils_FromComplexShortInteger(String *inst, _Complex short int value, int base);
|
||||||
Status StringUtils_FromComplexShortInteger(String *inst, _Complex short int value);
|
Status StringUtils_FromComplexLongInteger(String *inst, _Complex long int value, int base);
|
||||||
Status StringUtils_FromComplexLongInteger(String *inst, _Complex long int value);
|
Status StringUtils_FromComplexLongLongInteger(String *inst, _Complex long long value, int base);
|
||||||
Status StringUtils_FromComplexLongLongInteger(String *inst, _Complex long long value);
|
Status StringUtils_FromComplexFloat(String *inst, _Complex float value, int base);
|
||||||
Status StringUtils_FromComplexFloat(String *inst, _Complex float value);
|
Status StringUtils_FromComplexDouble(String *inst, _Complex double value, int base);
|
||||||
Status StringUtils_FromComplexDouble(String *inst, _Complex double value);
|
Status StringUtils_FromComplexLongDouble(String *inst, _Complex long double value, int base);
|
||||||
Status StringUtils_FromComplexLongDouble(String *inst, _Complex long double value);
|
Status StringUtils_FromUnsignedInteger(String *inst, unsigned int value, int base);
|
||||||
Status StringUtils_FromUnsignedInteger(String *inst, unsigned int value);
|
Status StringUtils_FromUnsignedShortInteger(String *inst, unsigned short int value, int base);
|
||||||
Status StringUtils_FromUnsignedShortInteger(String *inst, unsigned short int value);
|
Status StringUtils_FromUnsignedLongInteger(String *inst, unsigned long int value, int base);
|
||||||
Status StringUtils_FromUnsignedLongInteger(String *inst, unsigned long int value);
|
Status StringUtils_FromUnsignedLongLongInteger(String *inst, unsigned long long int value, int base);
|
||||||
Status StringUtils_FromUnsignedLongLongInteger(String *inst, unsigned long long int value);
|
Status StringUtils_FromUnsignedComplexInteger(String *inst, unsigned _Complex int value, int base);
|
||||||
Status StringUtils_FromUnsignedComplexInteger(String *inst, unsigned _Complex int value);
|
Status StringUtils_FromUnsignedComplexShortInteger(String *inst, unsigned _Complex short int value, int base);
|
||||||
Status StringUtils_FromUnsignedComplexShortInteger(String *inst, unsigned _Complex short int value);
|
Status StringUtils_FromUnsignedComplexLongInteger(String *inst, unsigned _Complex long int value, int base);
|
||||||
Status StringUtils_FromUnsignedComplexLongInteger(String *inst, unsigned _Complex long int value);
|
Status StringUtils_FromUnsignedComplexLongLongInteger(String *inst, unsigned _Complex long long value, int base);
|
||||||
Status StringUtils_FromUnsignedComplexLongLongInteger(String *inst, unsigned _Complex long long value);
|
|
||||||
Status StringUtils_FromAddress(String *inst, void *store);
|
Status StringUtils_FromAddress(String *inst, void *store);
|
||||||
Status StringUtils_FromCharBuff(String *inst, char const *buff, int base);
|
Status StringUtils_FromCharBuff(String *inst, char const *buff);
|
||||||
Status StringUtils_FromWideCharBuff(String *inst, wchar_t const *wbuff, int base);
|
Status StringUtils_FromWideCharBuff(String *inst, wchar_t const *wbuff);
|
||||||
Status StringUtils_ToInteger(String *inst, int *store);
|
Status StringUtils_ToInteger(String *inst, int *store, int base);
|
||||||
Status StringUtils_ToShortInteger(String *inst, short int *store);
|
Status StringUtils_ToShortInteger(String *inst, short int *store, int base);
|
||||||
Status StringUtils_ToLongInteger(String *inst, long int *store);
|
Status StringUtils_ToLongInteger(String *inst, long int *store, int base);
|
||||||
Status StringUtils_ToLongLongInteger(String *inst, long long int *store);
|
Status StringUtils_ToLongLongInteger(String *inst, long long int *store, int base);
|
||||||
Status StringUtils_ToFloat(String *inst, float *store);
|
Status StringUtils_ToFloat(String *inst, float *store, int base);
|
||||||
Status StringUtils_ToDouble(String *inst, double *store);
|
Status StringUtils_ToDouble(String *inst, double *store, int base);
|
||||||
Status StringUtils_ToLongDouble(String *inst, long double *store);
|
Status StringUtils_ToLongDouble(String *inst, long double *store, int base);
|
||||||
Status StringUtils_ToComplexInteger(String *inst, _Complex int *store);
|
Status StringUtils_ToComplexInteger(String *inst, _Complex int *store, int base);
|
||||||
Status StringUtils_ToComplexShortInteger(String *inst, _Complex short int *store);
|
Status StringUtils_ToComplexShortInteger(String *inst, _Complex short int *store, int base);
|
||||||
Status StringUtils_ToComplexLongInteger(String *inst, _Complex long int *store);
|
Status StringUtils_ToComplexLongInteger(String *inst, _Complex long int *store, int base);
|
||||||
Status StringUtils_ToComplexLongLongInteger(String *inst, _Complex long long *store);
|
Status StringUtils_ToComplexLongLongInteger(String *inst, _Complex long long *store, int base);
|
||||||
Status StringUtils_ToComplexFloat(String *inst, _Complex float *store);
|
Status StringUtils_ToComplexFloat(String *inst, _Complex float *store, int base);
|
||||||
Status StringUtils_ToComplexDouble(String *inst, _Complex double *store);
|
Status StringUtils_ToComplexDouble(String *inst, _Complex double *store, int base);
|
||||||
Status StringUtils_ToUnsignedInteger(String *inst, unsigned int *store);
|
Status StringUtils_ToUnsignedInteger(String *inst, unsigned int *store, int base);
|
||||||
Status StringUtils_ToUnsignedShortInteger(String *inst, unsigned short int *store);
|
Status StringUtils_ToUnsignedShortInteger(String *inst, unsigned short int *store, int base);
|
||||||
Status StringUtils_ToUnsignedLongInteger(String *inst, unsigned long int *store);
|
Status StringUtils_ToUnsignedLongInteger(String *inst, unsigned long int *store, int base);
|
||||||
Status StringUtils_ToUnsignedLongLongInteger(String *inst, unsigned long long int *store);
|
Status StringUtils_ToUnsignedLongLongInteger(String *inst, unsigned long long int *store, int base);
|
||||||
Status StringUtils_ToUnsignedComplexInteger(String *inst, unsigned _Complex int *store);
|
Status StringUtils_ToUnsignedComplexInteger(String *inst, unsigned _Complex int *store, int base);
|
||||||
Status StringUtils_ToUnsignedComplexShortInteger(String *inst, unsigned _Complex short int *store);
|
Status StringUtils_ToUnsignedComplexShortInteger(String *inst, unsigned _Complex short int *store, int base);
|
||||||
Status StringUtils_ToUnsignedComplexLongInteger(String *inst, unsigned _Complex long int *store);
|
Status StringUtils_ToUnsignedComplexLongInteger(String *inst, unsigned _Complex long int *store, int base);
|
||||||
Status StringUtils_ToUnsignedComplexLongLongInteger(String *inst, unsigned _Complex long long *store);
|
Status StringUtils_ToUnsignedComplexLongLongInteger(String *inst, unsigned _Complex long long *store, int base);
|
||||||
Status StringUtils_ToAddress(String *inst, void **store);
|
Status StringUtils_ToAddress(String *inst, void **store);
|
||||||
Status StringUtils_ToCharBuff(String *inst, char const *buff, int base);
|
Status StringUtils_ToCharBuff(String *inst, char const *buff);
|
||||||
Status StringUtils_ToWideCharBuff(String *inst, wchar_t const *wbuff, int base);
|
Status StringUtils_ToWideCharBuff(String *inst, wchar_t const *wbuff);
|
||||||
Status StringUtils_Format(String *inst, const String *restrict fmt, ...);
|
|
||||||
Status StringUtils_Tokenise(String *inst, const String *delim, String *store);
|
Status StringUtils_Tokenise(String *inst, const String *delim, String *store);
|
||||||
Status String_Encode(String *inst, StringEncoding encoding)
|
bool StringUtils_IsBlank(String *inst);
|
||||||
throws(UnsupportedEncoding EncodingError DecodingError);
|
|
||||||
Status String_Decode(String *inst, StringEncoding encoding);
|
|
||||||
throws(UnsupportedEncoding EncodingError DecodingError);
|
|
||||||
int StringUtils_Compare(String *a, String *b);
|
int StringUtils_Compare(String *a, String *b);
|
||||||
|
|
||||||
static Status StringConversionPrecisionError = {
|
static Status StringConversionPrecisionError = {
|
||||||
|
.identity = nameof(StringConversionPrecisionError),
|
||||||
.value = 1,
|
.value = 1,
|
||||||
.description = "Unpreventable precision loss was found during conversion "
|
.description = "Unpreventable precision loss was found during conversion "
|
||||||
"between string and raw data.",
|
"between string and raw data.",
|
||||||
.characteristic = STATUS_ERROR,
|
.characteristic = STATUS_ERROR,
|
||||||
.prev = &ImprecisionError
|
.loc = __GLOBAL__,
|
||||||
|
.prev = (Status *)&ImprecisionError
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef Array(int) InfiniteInteger;
|
|
||||||
typedef Array(double) InfiniteFloatingPoint;
|
|
||||||
typedef Array(_Complex double) InfintieComplex;
|
|
||||||
|
|
||||||
|
|
||||||
#endif /* COMPOUND_STRING_H */
|
#endif /* COMPOUND_STRING_H */
|
||||||
|
@@ -10,35 +10,35 @@ Status String_Create(String *inst, int len)
|
|||||||
|
|
||||||
Status String_CopyOf(String *inst, String *other)
|
Status String_CopyOf(String *inst, String *other)
|
||||||
{
|
{
|
||||||
fails(inst, apply(UnavailableInstance));
|
nonull(inst, apply(UnavailableInstance));
|
||||||
|
|
||||||
return apply(NormalStatus);
|
return apply(NormalStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status String_Delete(String *inst)
|
Status String_Delete(String *inst)
|
||||||
{
|
{
|
||||||
fails(inst, apply(UnavailableInstance));
|
nonull(inst, apply(UnavailableInstance));
|
||||||
|
|
||||||
return apply(NormalStatus);
|
return apply(NormalStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status String_GetAt(String *inst, Char *store, int index)
|
Status String_GetAt(String *inst, Char *store, int index)
|
||||||
{
|
{
|
||||||
fails(inst, apply(UnavailableInstance));
|
nonull(inst, apply(UnavailableInstance));
|
||||||
|
|
||||||
return apply(NormalStatus);
|
return apply(NormalStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status String_SetAt(String *inst, Char *source, int index)
|
Status String_SetAt(String *inst, Char *source, int index)
|
||||||
{
|
{
|
||||||
fails(inst, apply(UnavailableInstance));
|
nonull(inst, apply(UnavailableInstance));
|
||||||
|
|
||||||
return apply(NormalStatus);
|
return apply(NormalStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
Status String_Literalise(String *inst, String *store)
|
Status String_Literalise(String *inst, String *store)
|
||||||
{
|
{
|
||||||
fails(inst, apply(UnavailableInstance));
|
nonull(inst, apply(UnavailableInstance));
|
||||||
|
|
||||||
return apply(NormalStatus);
|
return apply(NormalStatus);
|
||||||
}
|
}
|
||||||
|
@@ -1,11 +1,9 @@
|
|||||||
#ifndef COMPOUND_UTILS_H
|
#ifndef COMPOUND_UTILS_H
|
||||||
# define COMPOUND_UTILS_H
|
# define COMPOUND_UTILS_H
|
||||||
|
|
||||||
# include <time.h>
|
|
||||||
# include <string.h>
|
|
||||||
# include <stdlib.h>
|
|
||||||
# include <math.h>
|
# include <math.h>
|
||||||
# include <stdint.h>
|
# include <string.h>
|
||||||
|
# include <time.h>
|
||||||
|
|
||||||
# include <Compound/common.h>
|
# include <Compound/common.h>
|
||||||
# include <Compound/const.h>
|
# include <Compound/const.h>
|
||||||
@@ -19,6 +17,8 @@ int Utils_CalcDigits(long long int n);
|
|||||||
|
|
||||||
int Utils_LiteraliseInteger(long long int n, char *buff);
|
int Utils_LiteraliseInteger(long long int n, char *buff);
|
||||||
|
|
||||||
int Utils_DateTimeLiteralise(time_t t, char *buff);
|
// int Utils_DateTimeLiteralise(time_t t, char *buff);
|
||||||
|
int Utils_DateTimeLiteralise(time_t timer, char *buff,
|
||||||
|
const char *__restrict format);
|
||||||
|
|
||||||
#endif /* COMPOUND_UTILS_H */
|
#endif /* COMPOUND_UTILS_H */
|
||||||
|
@@ -1,49 +1,49 @@
|
|||||||
#include <Compound/utils.h>
|
#include <Compound/utils.h>
|
||||||
|
|
||||||
int Utils_CalcDigits(long long int n)
|
// int Utils_CalcDigits(long long int n)
|
||||||
{
|
// {
|
||||||
if (n == 0) {
|
// if (n == 0) {
|
||||||
return 1;
|
// return 1;
|
||||||
}
|
// }
|
||||||
|
|
||||||
n = llabs(n);
|
// n = llabs(n);
|
||||||
|
|
||||||
/* Accumulate. */
|
// /* Accumulate. */
|
||||||
register int i;
|
// register int i;
|
||||||
for (i = 0; n; i++) n /= 10;
|
// for (i = 0; n; i++) n /= 10;
|
||||||
|
|
||||||
return i;
|
// return i;
|
||||||
}
|
// }
|
||||||
|
|
||||||
int Utils_LiteraliseInteger(long long int n, char *buff)
|
// int Utils_LiteraliseInteger(long long int n, char *buff)
|
||||||
{
|
// {
|
||||||
/* Invalid buffer was presented. */
|
// /* Invalid buffer was presented. */
|
||||||
if (strlen(buff) != LITERALISATION_LENGTH_MAXIMUM) {
|
// if (strlen(buff) != LITERALISATION_LENGTH_MAXIMUM) {
|
||||||
buff = NULL;
|
// buff = NULL;
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
|
|
||||||
if (!n) {
|
// if (!n) {
|
||||||
buff = "0";
|
// buff = "0";
|
||||||
return 1;
|
// return 1;
|
||||||
}
|
// }
|
||||||
|
|
||||||
const int literalising_len = Utils_CalcDigits(n);
|
// const int literalising_len = Utils_CalcDigits(n);
|
||||||
if (literalising_len >= LITERALISATION_LENGTH_MAXIMUM) {
|
// if (literalising_len >= LITERALISATION_LENGTH_MAXIMUM) {
|
||||||
buff = NULL;
|
// buff = NULL;
|
||||||
return 0;
|
// return 0;
|
||||||
}
|
// }
|
||||||
|
|
||||||
char literalising[literalising_len];
|
// char literalising[literalising_len];
|
||||||
for (register int i = 0; i < literalising_len; i++) {
|
// for (register int i = 0; i < literalising_len; i++) {
|
||||||
literalising[i] = (n / (int)pow(10, i));
|
// literalising[i] = (n / (int)pow(10, i));
|
||||||
}
|
// }
|
||||||
|
|
||||||
return literalising_len;
|
// return literalising_len;
|
||||||
}
|
// }
|
||||||
|
|
||||||
int Utils_DateTimeLiteralise(time_t t, char *buff)
|
// int Utils_DateTimeLiteralise(time_t timer, char *buff,
|
||||||
{
|
// const char *__restrict format)
|
||||||
return 0;
|
// {
|
||||||
}
|
|
||||||
|
|
||||||
|
// }
|
||||||
|
BIN
Var/VarTest
Executable file
BIN
Var/VarTest
Executable file
Binary file not shown.
@@ -52,9 +52,9 @@ typedef struct {
|
|||||||
|
|
||||||
Status Var_Create(Var *inst, size_t size) throws(InsufficientMemory);
|
Status Var_Create(Var *inst, size_t size) throws(InsufficientMemory);
|
||||||
Status Var_CopyOf(Var *inst, Var *other);
|
Status Var_CopyOf(Var *inst, Var *other);
|
||||||
|
Status Var_Delete(Var *inst);
|
||||||
Status Var_Literalise(Var *inst, char *buff);
|
Status Var_Literalise(Var *inst, char *buff);
|
||||||
bool Var_Equals(Var *a, Var *b);
|
bool Var_Equals(Var *a, Var *b);
|
||||||
void Var_Delete(Var *inst);
|
|
||||||
|
|
||||||
void VarUtils_Swap(Var *v1, Var *v2);
|
void VarUtils_Swap(Var *v1, Var *v2);
|
||||||
// bool VarUtils_IsIdentityLegal(char *identity);
|
// bool VarUtils_IsIdentityLegal(char *identity);
|
||||||
|
@@ -1,8 +1,9 @@
|
|||||||
|
#include <Compound/status.h>
|
||||||
#include <Compound/var.h>
|
#include <Compound/var.h>
|
||||||
|
|
||||||
Status Var_Create(Var *inst, size_t size)
|
Status Var_Create(Var *inst, size_t size)
|
||||||
{
|
{
|
||||||
fails(inst, apply(UnavailableInstance));
|
nonull(inst, apply(UnavailableInstance));
|
||||||
state(inst->alive, apply(InstanceStillAlive));
|
state(inst->alive, apply(InstanceStillAlive));
|
||||||
state(!size,
|
state(!size,
|
||||||
apply(normal(NormalStatus, "Exited with given parameter size as ZERO.")));
|
apply(normal(NormalStatus, "Exited with given parameter size as ZERO.")));
|
||||||
@@ -14,28 +15,12 @@ Status Var_Create(Var *inst, size_t size)
|
|||||||
return apply(NormalStatus);
|
return apply(NormalStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Status Var_Create(Var *inst, void *addr, size_t size, char *identity)
|
|
||||||
// {
|
|
||||||
// /* Skip when inst is unavailable. */
|
|
||||||
// fails(inst, apply(UnavailableInstance));
|
|
||||||
// /* Skip when identity is unavailable. */
|
|
||||||
// fails(identity, NullPointerAccounted);
|
|
||||||
// /* Skip when identity does not pass the examine. */
|
|
||||||
// state(!VarUtils_IsIdentityLegal(identity), IllegalVarIdentity);
|
|
||||||
|
|
||||||
// inst->addr = addr;
|
|
||||||
// inst->size = size;
|
|
||||||
// *inst->identity = *identity;
|
|
||||||
|
|
||||||
// return apply(NormalStatus);
|
|
||||||
// }
|
|
||||||
|
|
||||||
Status Var_CopyOf(Var *inst, Var *other)
|
Status Var_CopyOf(Var *inst, Var *other)
|
||||||
{
|
{
|
||||||
/* Skip when inst or other is unavailable. */
|
/* Skip when inst or other is unavailable. */
|
||||||
fails(inst, apply(UnavailableInstance));
|
nonull(inst, apply(UnavailableInstance));
|
||||||
state(inst->alive, apply(InstanceStillAlive));
|
state(inst->alive, apply(InstanceStillAlive));
|
||||||
fails(other, apply(InvalidParameter));
|
nonull(other, apply(InvalidParameter));
|
||||||
|
|
||||||
/* Copy members from other. Only has to apply size, no addr is needed. */
|
/* Copy members from other. Only has to apply size, no addr is needed. */
|
||||||
state(!((inst->addr = malloc(other->size))), apply(InsufficientMemory));
|
state(!((inst->addr = malloc(other->size))), apply(InsufficientMemory));
|
||||||
@@ -45,33 +30,17 @@ Status Var_CopyOf(Var *inst, Var *other)
|
|||||||
return apply(NormalStatus);
|
return apply(NormalStatus);
|
||||||
}
|
}
|
||||||
|
|
||||||
void Var_Delete(Var *inst)
|
Status Var_Delete(Var *inst)
|
||||||
{
|
{
|
||||||
svoid(!inst);
|
nonull(!inst, apply(UnavailableInstance));
|
||||||
|
state(!inst->alive, apply(InstanceNotAlive));
|
||||||
|
|
||||||
free(inst->addr);
|
free(inst->addr);
|
||||||
|
inst->alive = false;
|
||||||
inst->addr = NULL;
|
inst->addr = NULL;
|
||||||
inst->size = 0;
|
inst->size = 0;
|
||||||
}
|
|
||||||
|
|
||||||
// void Var_Delete(Var *inst)
|
return apply(NormalStatus);
|
||||||
// {
|
|
||||||
// /* Skip when inst or inst->addr is unavailable. */
|
|
||||||
// svoid(!inst || inst->addr == NULL);
|
|
||||||
|
|
||||||
// inst->addr = NULL;
|
|
||||||
// inst->size = 0;
|
|
||||||
// *inst->identity = 0;
|
|
||||||
// }
|
|
||||||
|
|
||||||
void VarUtils_Swap(Var *v1, Var *v2)
|
|
||||||
{
|
|
||||||
/* Skip when v1 or v2 is unavailable. */
|
|
||||||
svoid(!v1 || !v2);
|
|
||||||
|
|
||||||
Var v3 = *v1;
|
|
||||||
*v1 = *v2;
|
|
||||||
*v2 = v3;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Status Var_Literalise(Var *inst, char *buff)
|
Status Var_Literalise(Var *inst, char *buff)
|
||||||
@@ -95,32 +64,12 @@ bool Var_Equals(Var *a, Var *b)
|
|||||||
return (a->addr == b->addr && a->size == b->size);
|
return (a->addr == b->addr && a->size == b->size);
|
||||||
}
|
}
|
||||||
|
|
||||||
// bool VarUtils_IsIdentityLegal(char *identity)
|
void VarUtils_Swap(Var *v1, Var *v2)
|
||||||
// {
|
{
|
||||||
// /* Skip when identity is unavailable. */
|
/* Skip when v1 or v2 is unavailable. */
|
||||||
// state(identity == NULL, false);
|
svoid(!v1 || !v2);
|
||||||
|
|
||||||
// const int len = strlen(identity);
|
Var v3 = *v1;
|
||||||
|
*v1 = *v2;
|
||||||
// /* Skip when identity is empty. */
|
*v2 = v3;
|
||||||
// state(len == 0, false);
|
}
|
||||||
|
|
||||||
// /* Skip when the first char is not within alphabet. */
|
|
||||||
// state(ATRANGE('a', 'z', identity[0])
|
|
||||||
// || ATRANGE('A', 'Z', identity[0]), false);
|
|
||||||
|
|
||||||
// /* Skip when the length of identity is greater that VAR_IDENTITY_LENGTH. */
|
|
||||||
// state(len > VAR_IDENTITY_LENGTH, false);
|
|
||||||
|
|
||||||
// /* Skip when identity has space and illegal characters in it. */
|
|
||||||
// const int illegal_len = strlen(VAR_IDENTITY_ILLEGAL_CHAR);
|
|
||||||
// for (register int i = 0; i < len; i++) {
|
|
||||||
// for (register int j = 0; j < illegal_len; j++) {
|
|
||||||
// if (identity[i] == VAR_IDENTITY_ILLEGAL_CHAR[j]) {
|
|
||||||
// return false;
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
// }
|
|
||||||
|
|
||||||
// return true;
|
|
||||||
// }
|
|
||||||
|
26
Var/test.c
Normal file
26
Var/test.c
Normal file
@@ -0,0 +1,26 @@
|
|||||||
|
#include <Compound/var.h>
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
Var v1 = {
|
||||||
|
.addr = malloc(sizeof(int)),
|
||||||
|
.sz = sizeof(int)
|
||||||
|
};
|
||||||
|
|
||||||
|
Var v2 = (Var){v1.addr, v1.sz};
|
||||||
|
|
||||||
|
wchar_t wbuff[UINT8_MAX + 1] = {};
|
||||||
|
wchar_t *wp = wbuff;
|
||||||
|
|
||||||
|
(void)var_literalise(v1, &wp);
|
||||||
|
|
||||||
|
(void)wprintf(L"%ls\n", wp);
|
||||||
|
|
||||||
|
(void)var_literalise(v2, &wp);
|
||||||
|
|
||||||
|
(void)wprintf(L"%ls\n", wp);
|
||||||
|
|
||||||
|
free(v1.addr);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
4
attr.h
4
attr.h
@@ -3,8 +3,8 @@
|
|||||||
|
|
||||||
# include <Compound/name.h>
|
# include <Compound/name.h>
|
||||||
|
|
||||||
typedef struct _Attribute{
|
typedef struct _Attribute {
|
||||||
int serialNo;
|
Name identity; // Numeral accumulative, not literal descriptive.
|
||||||
int (*exec)(void *);
|
int (*exec)(void *);
|
||||||
struct _Attribute *prev;
|
struct _Attribute *prev;
|
||||||
} attr(Executive) Attribute;
|
} attr(Executive) Attribute;
|
||||||
|
25
catlog.c
25
catlog.c
@@ -1,4 +1,3 @@
|
|||||||
#include "Status/include/status.h"
|
|
||||||
#include <Compound/common.h>
|
#include <Compound/common.h>
|
||||||
#include <Compound/status.h>
|
#include <Compound/status.h>
|
||||||
#include <Compound/catlog.h>
|
#include <Compound/catlog.h>
|
||||||
@@ -7,7 +6,7 @@ Status CatlogMsg_Create(CatlogMsg *inst, CatlogLevel level,
|
|||||||
char *initiator, char *msg)
|
char *initiator, char *msg)
|
||||||
{
|
{
|
||||||
/* Skip unavailable instances and parameters. */
|
/* Skip unavailable instances and parameters. */
|
||||||
fails(inst, apply(UnavailableInstance));
|
nonull(inst, apply(UnavailableInstance));
|
||||||
state((initiator == NULL || msg == NULL), apply(InvalidParameter));
|
state((initiator == NULL || msg == NULL), apply(InvalidParameter));
|
||||||
|
|
||||||
inst->time = time(NULL);
|
inst->time = time(NULL);
|
||||||
@@ -21,8 +20,8 @@ Status CatlogMsg_Create(CatlogMsg *inst, CatlogLevel level,
|
|||||||
Status CatlogMsg_CopyOf(CatlogMsg *inst, CatlogMsg *other)
|
Status CatlogMsg_CopyOf(CatlogMsg *inst, CatlogMsg *other)
|
||||||
{
|
{
|
||||||
/* Skip unavailable instances and parameters. */
|
/* Skip unavailable instances and parameters. */
|
||||||
fails(inst, apply(UnavailableInstance));
|
nonull(inst, apply(UnavailableInstance));
|
||||||
fails(other, apply(InvalidParameter));
|
nonull(other, apply(InvalidParameter));
|
||||||
|
|
||||||
*inst = *other;
|
*inst = *other;
|
||||||
|
|
||||||
@@ -45,8 +44,8 @@ bool CatlogMsg_Equals(CatlogMsg *inst, CatlogMsg *other)
|
|||||||
Status CatlogSender_Create(CatlogSender *inst, CatlogMsg *msg, FILE *dst)
|
Status CatlogSender_Create(CatlogSender *inst, CatlogMsg *msg, FILE *dst)
|
||||||
{
|
{
|
||||||
/* Skip unavailable instances and parameters. */
|
/* Skip unavailable instances and parameters. */
|
||||||
fails(inst, apply(UnavailableInstance));
|
nonull(inst, apply(UnavailableInstance));
|
||||||
fails(msg, apply(InvalidParameter));
|
nonull(msg, apply(InvalidParameter));
|
||||||
|
|
||||||
/* Copy and assign. */
|
/* Copy and assign. */
|
||||||
inst->msg = *msg;
|
inst->msg = *msg;
|
||||||
@@ -60,8 +59,8 @@ Status CatlogSender_Create(CatlogSender *inst, CatlogMsg *msg, FILE *dst)
|
|||||||
Status CatlogSender_CopyOf(CatlogSender *inst, CatlogSender *other)
|
Status CatlogSender_CopyOf(CatlogSender *inst, CatlogSender *other)
|
||||||
{
|
{
|
||||||
/* Skip unavailable instances and parameters. */
|
/* Skip unavailable instances and parameters. */
|
||||||
fails(inst, apply(UnavailableInstance));
|
nonull(inst, apply(UnavailableInstance));
|
||||||
fails(other, apply(InvalidParameter));
|
nonull(other, apply(InvalidParameter));
|
||||||
|
|
||||||
/* Copy and assign */
|
/* Copy and assign */
|
||||||
inst->msg = other->msg;
|
inst->msg = other->msg;
|
||||||
@@ -89,7 +88,7 @@ bool CatlogSender_Equals(CatlogSender *inst, CatlogSender *other)
|
|||||||
Status CatlogSender_Send(CatlogSender *inst)
|
Status CatlogSender_Send(CatlogSender *inst)
|
||||||
{
|
{
|
||||||
/* Skip unavailable instances and parameters. */
|
/* Skip unavailable instances and parameters. */
|
||||||
fails(inst, apply(UnavailableInstance));
|
nonull(inst, apply(UnavailableInstance));
|
||||||
|
|
||||||
const int written = fprintf(inst->dst, "%s\n", inst->msg.content);
|
const int written = fprintf(inst->dst, "%s\n", inst->msg.content);
|
||||||
|
|
||||||
@@ -100,12 +99,12 @@ Status CatlogSender_Send(CatlogSender *inst)
|
|||||||
}
|
}
|
||||||
|
|
||||||
Status CatlogUtils_OpenFile(FILE **fileptr, const char *filepath,
|
Status CatlogUtils_OpenFile(FILE **fileptr, const char *filepath,
|
||||||
const char const *restrict mode)
|
const char *restrict mode)
|
||||||
{
|
{
|
||||||
/* Skip unavailable instances and parameters. */
|
/* Skip unavailable instances and parameters. */
|
||||||
fails(fileptr, apply(UnavailableBuffer));
|
nonull(fileptr, apply(UnavailableBuffer));
|
||||||
fails(filepath, apply(UnavailableFileName));
|
nonull(filepath, apply(UnavailableFileName));
|
||||||
fails(mode, apply(UnavailableFileAccessMode));
|
nonull(mode, apply(UnavailableFileAccessMode));
|
||||||
|
|
||||||
/* Open the file. Return CatCannotOpenFile once failed. */
|
/* Open the file. Return CatCannotOpenFile once failed. */
|
||||||
state(!(*fileptr = fopen(filepath, mode)), apply(CatCannotOpenFile));
|
state(!(*fileptr = fopen(filepath, mode)), apply(CatCannotOpenFile));
|
||||||
|
2
catlog.h
2
catlog.h
@@ -59,7 +59,7 @@ Status CatlogSender_CopyOf(CatlogSender *inst, CatlogSender *other);
|
|||||||
Status CatlogSender_Send(CatlogSender *inst);
|
Status CatlogSender_Send(CatlogSender *inst);
|
||||||
bool CatlogSender_Equals(CatlogSender *inst, CatlogSender *other);
|
bool CatlogSender_Equals(CatlogSender *inst, CatlogSender *other);
|
||||||
Status CatlogUtils_OpenFile(FILE **fileptr, const char *filepath,
|
Status CatlogUtils_OpenFile(FILE **fileptr, const char *filepath,
|
||||||
const char const *restrict mode);
|
const char *restrict mode);
|
||||||
Status CatlogUtils_CloseFile(FILE **fileptr);
|
Status CatlogUtils_CloseFile(FILE **fileptr);
|
||||||
|
|
||||||
#endif /* COMPOUND_CATLOG_H */
|
#endif /* COMPOUND_CATLOG_H */
|
||||||
|
169
common.h
169
common.h
@@ -1,47 +1,95 @@
|
|||||||
#ifndef COMPOUND_COMMON_h
|
#ifndef COMPOUND_COMMON_H
|
||||||
# define COMPOUND_COMMON_h
|
# define COMPOUND_COMMON_H
|
||||||
// # define __DEBUG__ 1
|
|
||||||
|
|
||||||
# include <stdlib.h>
|
# include <stdlib.h>
|
||||||
# include <stdbool.h>
|
# include <stdbool.h>
|
||||||
|
|
||||||
|
# define EMPTY {0}
|
||||||
|
|
||||||
|
/*
|
||||||
|
PLEASE BE NOTICE:
|
||||||
|
MAGIC MACRO CANNOT USE "APPLY" AT RETURNING.
|
||||||
|
IT SHOULD ALWAYS RETURN THE LOCATION INDICATOR WHERE
|
||||||
|
IT CAME FROM.
|
||||||
|
*/
|
||||||
|
|
||||||
/* Get the literal. */
|
/* Get the literal. */
|
||||||
# define nameof(obj) #obj
|
# define nameof(obj) #obj
|
||||||
|
|
||||||
/* Return $n as the return value, once $o is NULL. */
|
/* Return n as the return value, once o is NULL. */
|
||||||
# define fails(o, n) { if (!o) return (n); }
|
# define nonull(o, n) { if (!o) return (n); }
|
||||||
|
|
||||||
/* Return $e as the return value, once $v equals $e. */
|
/* Return e as the return value, once v equals e. */
|
||||||
# define trans(v, e) { if ((v) == (e)) return (e); }
|
# define trans(v, e) { if ((v) == (e)) return (e); }
|
||||||
|
|
||||||
/* Evaluate given statement while the ptr to $s is not NULL. */
|
/* Evaluate given statement while the ptr to s is not NULL. */
|
||||||
# define state(s, n) { if ((s)) return (n); }
|
# define state(s, n) { if ((s)) return (n); }
|
||||||
|
|
||||||
/* Evaluate given statement while the ptr to $s is not NULL. */
|
/* Evaluate given statement while the ptr to s is not NULL. */
|
||||||
# define svoid(s) { if ((s)) return; }
|
# define svoid(s) { if ((s)) return; }
|
||||||
|
|
||||||
/* Another way to handle if statements more cleanly. */
|
/* Another way to handle if statements more cleanly. */
|
||||||
# define solve(s, b) { if (s) b }
|
# define solve(s, b) { if (s) b }
|
||||||
|
|
||||||
/* Handling expression with its result. */
|
/* Handling expression with its result. */
|
||||||
# define when(expr, b) { int _ = expr; if (expr) b }
|
# define when(expr, b) { int _ = expr; if (_) b }
|
||||||
|
|
||||||
/* Handling expression with its calculated result. */
|
/* Handling expression with its precalculated result. */
|
||||||
# define where(expr, b) { int _ = expr; b }
|
# define where(expr, b) { int _ = expr; b }
|
||||||
|
|
||||||
|
/* Execute b whenever finds s is "okay". */
|
||||||
# define ok(s, b) { Status _ = s; if (StatusUtils_IsOkay(_)) b }
|
# define ok(s, b) { Status _ = s; if (StatusUtils_IsOkay(_)) b }
|
||||||
|
|
||||||
|
/* Execute b whenever finds s is "NOT okay". */
|
||||||
# define notok(s, b) { Status _ = s; if (!StatusUtils_IsOkay(_)) b }
|
# define notok(s, b) { Status _ = s; if (!StatusUtils_IsOkay(_)) b }
|
||||||
|
|
||||||
|
/* Return e when passing a failing e. */
|
||||||
|
# define fail(e) { notok(e, return _;) }
|
||||||
|
|
||||||
|
/* Return e when passing a failing e commented with c. */
|
||||||
|
# define fails(e, c) { notok(e, return annot(_, c);) }
|
||||||
|
|
||||||
|
/* Return value "v" when passing a failing e. */
|
||||||
|
# define vfail(e, v) { notok(e, return v;) }
|
||||||
|
|
||||||
|
/* Execute b for handling UnknownStatus (TraditionalFunctionReturn). */
|
||||||
|
# define unsure(s, expr, b) { Status _ = s; \
|
||||||
|
if (_.characteristic < 0 && (expr)) b }
|
||||||
|
|
||||||
|
/* Execute b whatsoever with s stored. */
|
||||||
# define seek(s, b) { Status _ = s; b }
|
# define seek(s, b) { Status _ = s; b }
|
||||||
|
|
||||||
|
/* Combinates seek and solve. */
|
||||||
|
# define settle(e, s, b) seek(e, solve(s, b))
|
||||||
|
|
||||||
|
/* Clone a new varaible "v2" with "v1". */
|
||||||
|
# define clone(v1, v2) __typeof__(v1) v2 = v1;
|
||||||
|
|
||||||
|
/* Allows different macros using "_" nested with each other. */
|
||||||
|
# define nest(v1, v2, b) { clone(v1, v2) b }
|
||||||
|
|
||||||
|
/* Cast Var "var" into builtin type in C specified with "type". */
|
||||||
|
# define cast(var, type) (*(type *)var.addr)
|
||||||
|
|
||||||
|
/* Assign var with value under type "type".
|
||||||
|
REQUIRE BOTH VAR AND VALUE TO BE ALIVE. */
|
||||||
|
# define assign(var, value, type) { cast(var, type) = cast(value, type); }
|
||||||
|
|
||||||
|
// # define lambda(param, body, capfmt, ...) {\
|
||||||
|
// /* Duplicate everything from cap. */\
|
||||||
|
// va_list ptr;\
|
||||||
|
// va_start(ptr, capfmt);\
|
||||||
|
// __typeof__(ptr) \
|
||||||
|
// va_end(ptr);\
|
||||||
|
// }
|
||||||
|
|
||||||
/* Create a new UnknownStatus on the fly. */
|
/* Create a new UnknownStatus on the fly. */
|
||||||
# define unknown(e, c, v) ((Status) {\
|
# define unknown(e, c, v) ((Status) {\
|
||||||
.identity = e.identity,\
|
.identity = e.identity,\
|
||||||
.value = v,\
|
.value = v,\
|
||||||
.description = c,\
|
.description = c,\
|
||||||
.characteristic = STATUS_UNKNOWN,\
|
.characteristic = STATUS_UNKNOWN,\
|
||||||
.loc = __HERE__,\
|
.loc = e.loc,\
|
||||||
.prev = e.prev\
|
.prev = e.prev\
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -51,7 +99,7 @@
|
|||||||
.value = 0,\
|
.value = 0,\
|
||||||
.description = c,\
|
.description = c,\
|
||||||
.characteristic = STATUS_NORMAL,\
|
.characteristic = STATUS_NORMAL,\
|
||||||
.loc = __HERE__,\
|
.loc = e.loc,\
|
||||||
.prev = e.prev\
|
.prev = e.prev\
|
||||||
})
|
})
|
||||||
|
|
||||||
@@ -61,29 +109,41 @@
|
|||||||
.value = e.value,\
|
.value = e.value,\
|
||||||
.description = c,\
|
.description = c,\
|
||||||
.characteristic = STATUS_ERROR,\
|
.characteristic = STATUS_ERROR,\
|
||||||
.loc = __HERE__,\
|
.loc = e.loc,\
|
||||||
.prev = e.prev\
|
.prev = e.prev\
|
||||||
})
|
})
|
||||||
|
|
||||||
/* Extend the Status chain by giving 'p' for "predecessor" and 'e' for "Eval-Status". */
|
/* Replace the prev of e with p. */
|
||||||
# define extend(p, e) ((Status) {\
|
# define extend(p, e) ((Status) {\
|
||||||
.identity = e.identity,\
|
.identity = e.identity,\
|
||||||
.value = p.value,\
|
.value = p.value,\
|
||||||
.description = e.description,\
|
.description = e.description,\
|
||||||
.characteristic = p.characteristic,\
|
.characteristic = p.characteristic,\
|
||||||
.loc = __HERE__,\
|
.loc = p.loc,\
|
||||||
.prev = (Status *)&p\
|
.prev = (Status *)&p\
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/* Create a new Status with v as its value. */
|
||||||
# define value(e, v) ((Status) {\
|
# define value(e, v) ((Status) {\
|
||||||
.identity = e.identity,\
|
.identity = e.identity,\
|
||||||
.value = v,\
|
.value = v,\
|
||||||
.description = e.description,\
|
.description = e.description,\
|
||||||
.characteristic = e.characteristic,\
|
.characteristic = e.characteristic,\
|
||||||
.loc = __HERE__,\
|
.loc = e.loc,\
|
||||||
.prev = (Status *)e.prev\
|
.prev = (Status *)e.prev\
|
||||||
})
|
})
|
||||||
|
|
||||||
|
/* Change the characteristic of e. */
|
||||||
|
# define shift(e, c) ((Status) {\
|
||||||
|
.identity = e.identity,\
|
||||||
|
.value = e.value,\
|
||||||
|
.description = e.description,\
|
||||||
|
.characteristic = c,\
|
||||||
|
.loc = e.loc,\
|
||||||
|
.prev= (Status *)e.prev\
|
||||||
|
})
|
||||||
|
|
||||||
|
/* Apply a new location to e where this macro is called. */
|
||||||
# define apply(e) ((Status) {\
|
# define apply(e) ((Status) {\
|
||||||
.identity = e.identity,\
|
.identity = e.identity,\
|
||||||
.value = e.value,\
|
.value = e.value,\
|
||||||
@@ -93,13 +153,24 @@
|
|||||||
.prev = (Status *)e.prev\
|
.prev = (Status *)e.prev\
|
||||||
})
|
})
|
||||||
|
|
||||||
/* Create a report in place with $e for base and $c for initiator literal. */
|
/* Replace the description from e with c. */
|
||||||
# define stamp(e, c) ((Report) {\
|
# define annot(e, c) ((Status) {\
|
||||||
.status = e,\
|
.identity = e.identity,\
|
||||||
.initiator = c,\
|
.value = e.value,\
|
||||||
|
.description = c,\
|
||||||
|
.characteristic = e.characteristic,\
|
||||||
|
.loc = e.loc,\
|
||||||
|
.prev = (Status *)e.prev\
|
||||||
|
})
|
||||||
|
|
||||||
|
/* Create a report on the fly. */
|
||||||
|
# define stamp(e, ini) ((Report) {\
|
||||||
|
.content = e,\
|
||||||
|
.initiator = ini,\
|
||||||
.time = time(NULL),\
|
.time = time(NULL),\
|
||||||
.priority = REPORT_SENDING_PRIORITY_NORMAL,\
|
.level = REPORT_SENDING_PRIORITY_NORMAL,\
|
||||||
.taskprint_status = REPORT_SENDING_TASK_STATUS_PENDING\
|
.status = REPORT_SENDING_TASK_STATUS_PENDING,\
|
||||||
|
.dst = stdout\
|
||||||
})
|
})
|
||||||
|
|
||||||
# define cat(s) {\
|
# define cat(s) {\
|
||||||
@@ -110,45 +181,6 @@
|
|||||||
CatlogSender_Send(&sender);\
|
CatlogSender_Send(&sender);\
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
|
||||||
// * @brief Forcibly return desired value $v once $s is not $k.
|
|
||||||
// * @return $v once state for $s is false.
|
|
||||||
// * @note "force" stands for "Forcible value"
|
|
||||||
// * @note 's' stands for "Statement"
|
|
||||||
// * @note 'k' stands for "Key Value", the value that is targeted to detect.
|
|
||||||
// * @note 'v' stands for "Desire Value", the value that desires.
|
|
||||||
// */
|
|
||||||
// # define force(s, k, v) solve((s) != (k), v)
|
|
||||||
|
|
||||||
// # define sforce(s, k, v) solve((!Status_Equal(s, k)), v)
|
|
||||||
|
|
||||||
// # define print_status(s) {\
|
|
||||||
// Status _ = s;\
|
|
||||||
// char buff[LITERALISATION_LENGTH_MAXIMUM];\
|
|
||||||
// notok(Status_Literalise(&_, buff), {\
|
|
||||||
// (void)printf("Failed to literalise a status\n");\
|
|
||||||
// });\
|
|
||||||
// (void)printf("%s\n", buff);\
|
|
||||||
// }
|
|
||||||
|
|
||||||
// # define print_status(s) {\
|
|
||||||
// char buff[LITERALISATION_LENGTH_MAXIMUM];\
|
|
||||||
// (void)Status_Literalise(&s, buff);\
|
|
||||||
// (void)fprintf(stderr, "%s\n", buff);\
|
|
||||||
// }
|
|
||||||
|
|
||||||
// # define print_statusdump(s) {\
|
|
||||||
// Status _ = s;\
|
|
||||||
// const int dump_len = StatusUtils_Depth(&_);\
|
|
||||||
// Status dump[dump_len];\
|
|
||||||
// StatusUtils_Dump(&_, dump, 0);\
|
|
||||||
// for (register int i = 0; i < dump_len; i++) {\
|
|
||||||
// /* TODO(william): Replace following line with coloured-term-output function. */\
|
|
||||||
// (void)printf("\e[1m[%d/%d]\e[0m\n", i, dump_len - 1);\
|
|
||||||
// print_status(dump[i]);\
|
|
||||||
// }\
|
|
||||||
// }
|
|
||||||
|
|
||||||
# define strnil(s) (!s ? ("(null)") : s)
|
# define strnil(s) (!s ? ("(null)") : s)
|
||||||
|
|
||||||
# define type(T)
|
# define type(T)
|
||||||
@@ -175,10 +207,10 @@ typedef struct {
|
|||||||
Coordination end;
|
Coordination end;
|
||||||
} Selection;
|
} Selection;
|
||||||
|
|
||||||
typedef struct {
|
// typedef struct {
|
||||||
void *addr;
|
// void *addr;
|
||||||
size_t sz;
|
// size_t sz;
|
||||||
} MemoryInst;
|
// } MemoryInst;
|
||||||
|
|
||||||
typedef Coordination ArrayIndexerRange;
|
typedef Coordination ArrayIndexerRange;
|
||||||
typedef bool _Bit;
|
typedef bool _Bit;
|
||||||
@@ -193,7 +225,6 @@ typedef bool _Bit;
|
|||||||
|
|
||||||
# define LITERALISATION_LENGTH_MAXIMUM 0xFFFFL
|
# define LITERALISATION_LENGTH_MAXIMUM 0xFFFFL
|
||||||
|
|
||||||
|
|
||||||
/* Only effect (probably) when formal Attribute is defined.
|
/* Only effect (probably) when formal Attribute is defined.
|
||||||
* __ATTRIBUTABLE indicates this field is used for further process by Attribute.
|
* __ATTRIBUTABLE indicates this field is used for further process by Attribute.
|
||||||
* Or, to put this way, this field has attributions not used so far, but
|
* Or, to put this way, this field has attributions not used so far, but
|
||||||
@@ -203,4 +234,8 @@ typedef bool _Bit;
|
|||||||
# define __ATTRIBUTABLE__
|
# define __ATTRIBUTABLE__
|
||||||
# define attr(a)
|
# define attr(a)
|
||||||
|
|
||||||
#endif /* NO COMPOUND_COMMON_h */
|
/* Useless in C, only for human to see.
|
||||||
|
Probably rewrite this in Classify. */
|
||||||
|
# define throws(e)
|
||||||
|
|
||||||
|
#endif /* COMPOUND_COMMON_H */
|
||||||
|
0
function.c
Normal file
0
function.c
Normal file
31
function.h
Normal file
31
function.h
Normal file
@@ -0,0 +1,31 @@
|
|||||||
|
#ifndef FUNCTION_H
|
||||||
|
# define FUNCTION_H
|
||||||
|
|
||||||
|
# include <Compound/string.h>
|
||||||
|
|
||||||
|
typedef Var Type;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
attr(registered 1) Type type;
|
||||||
|
attr(nullity false) String identity;
|
||||||
|
attr(alignwith 1; optional true) Type value;
|
||||||
|
} Parameter;
|
||||||
|
|
||||||
|
typedef void * Block;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
Type returns;
|
||||||
|
Array type(Parameter) params;
|
||||||
|
Var type(Block) body;
|
||||||
|
} Function;
|
||||||
|
|
||||||
|
Status Function_Create(Function *inst, Type returns,
|
||||||
|
Array type(Parameter) params, Var type(Block) body);
|
||||||
|
Status Function_CopyOf(Function *inst, Function *other);
|
||||||
|
Status Function_Delete(Function *inst);
|
||||||
|
Status Function_Literalise(Function *inst, String *buff);
|
||||||
|
Status Function_Overwrite(Function *inst, Function *other);
|
||||||
|
bool Function_Equal(Function *inst, Function *other);
|
||||||
|
bool FunctionUtils_IsVariadic(Function *inst);
|
||||||
|
|
||||||
|
#endif /* FUNCTION_H */
|
43
install
43
install
@@ -1,43 +0,0 @@
|
|||||||
#!/bin/sh
|
|
||||||
|
|
||||||
if [ "`whoami`" != "root" ]; then
|
|
||||||
echo "The script require root privilege to execute properly."
|
|
||||||
exit 1
|
|
||||||
fi
|
|
||||||
|
|
||||||
# echo "Please ensure the current work directory is the home directory to the project Compound!
|
|
||||||
# Press enter key to continue..."
|
|
||||||
# read
|
|
||||||
|
|
||||||
SRC="$PWD"
|
|
||||||
DST=/usr/include/Compound
|
|
||||||
PROJ=("Array" "Paper" "Pen" "Render" "Status" "Var" "MemMan" "Stack" "Utils"\
|
|
||||||
"String" "Object")
|
|
||||||
|
|
||||||
PROJLEN=${#PROJ[*]}
|
|
||||||
echo "======== $PROJLEN projects in total ========"
|
|
||||||
|
|
||||||
idx=0
|
|
||||||
while :; do
|
|
||||||
if [[ $idx -eq $PROJLEN || $idx -gt $PROJLEN ]]; then
|
|
||||||
break;
|
|
||||||
fi
|
|
||||||
|
|
||||||
p="${PROJ[$idx]}"
|
|
||||||
|
|
||||||
cd "$p"
|
|
||||||
echo "`date` >>> Installing $p"
|
|
||||||
cp -v include/*.h "$DST"
|
|
||||||
cd "$SRC"
|
|
||||||
((idx++))
|
|
||||||
echo
|
|
||||||
done
|
|
||||||
|
|
||||||
cp -v "common.h" "const.h" "platform.h"\
|
|
||||||
"name.h" "namescope.h" "type.h" "catlog.h"\
|
|
||||||
"attr.h" "registry.h" "class.h" "$DST"
|
|
||||||
|
|
||||||
echo "Installing libcompound:"
|
|
||||||
cp -v "libcompound.so" "/usr/lib"
|
|
||||||
|
|
||||||
printf "\nDone\n"
|
|
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
Status NameScope_Create(NameScope *inst)
|
Status NameScope_Create(NameScope *inst)
|
||||||
{
|
{
|
||||||
fails(inst, apply(UnavailableInstance));
|
nonull(inst, apply(UnavailableInstance));
|
||||||
|
|
||||||
/* Create instances for members from inst. */
|
/* Create instances for members from inst. */
|
||||||
state(StatusUtils_IsOkay(NameScope_EmptyName(&inst->latest)),
|
state(StatusUtils_IsOkay(NameScope_EmptyName(&inst->latest)),
|
||||||
@@ -17,8 +17,8 @@ Status NameScope_Create(NameScope *inst)
|
|||||||
|
|
||||||
Status NameScope_CopyOf(NameScope *inst, NameScope *other)
|
Status NameScope_CopyOf(NameScope *inst, NameScope *other)
|
||||||
{
|
{
|
||||||
fails(inst, apply(UnavailableInstance));
|
nonull(inst, apply(UnavailableInstance));
|
||||||
fails(other, apply(UnavailableParameter));
|
nonull(other, apply(UnavailableParameter));
|
||||||
|
|
||||||
/* Copy and assign. */
|
/* Copy and assign. */
|
||||||
other->latest = inst->latest;
|
other->latest = inst->latest;
|
||||||
|
11
postinstall
Executable file
11
postinstall
Executable file
@@ -0,0 +1,11 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ "$(whoami)" != "root" ]; then
|
||||||
|
echo "The script require root privilege to execute properly. Current identity: $(whoami)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install Compound library.
|
||||||
|
echo "Installing libcompound:"
|
||||||
|
cp -v "libcompound.so" "/usr/lib"
|
||||||
|
|
35
preinstall
Executable file
35
preinstall
Executable file
@@ -0,0 +1,35 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
if [ "$(whoami)" != "root" ]; then
|
||||||
|
echo "The script require root privilege to execute properly. Current identity: $(whoami)"
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
SRC="$PWD"
|
||||||
|
DST=/usr/include/Compound
|
||||||
|
set -- Array Paper Pen Render Status Var MemMan Stack Utils String Object
|
||||||
|
|
||||||
|
# Create directory.
|
||||||
|
if [ ! -d "$DST" ]; then
|
||||||
|
mkdir -pv "$DST"
|
||||||
|
fi
|
||||||
|
|
||||||
|
# Install project-like headers.
|
||||||
|
while :; do
|
||||||
|
p="$1"
|
||||||
|
if [ -z "$1" ]; then break; fi
|
||||||
|
|
||||||
|
cd "$p" || exit 1
|
||||||
|
echo "$(date) >>> Installing $p"
|
||||||
|
cp -v include/*.h "$DST"
|
||||||
|
cd "$SRC" || exit 1
|
||||||
|
shift 1
|
||||||
|
echo
|
||||||
|
done
|
||||||
|
|
||||||
|
# Install individual headers.
|
||||||
|
cp -v "common.h" "const.h" "platform.h"\
|
||||||
|
"name.h" "namescope.h" "type.h" "catlog.h"\
|
||||||
|
"attr.h" "registry.h" "class.h" "function.h" "report.h" "$DST"
|
||||||
|
|
||||||
|
printf "\nDone\n"
|
233
report.c
Normal file
233
report.c
Normal file
@@ -0,0 +1,233 @@
|
|||||||
|
#include <Compound/report.h>
|
||||||
|
|
||||||
|
Status Report_Create(Report *inst, Status *stat, FILE *dest, char *initiator,
|
||||||
|
int priority)
|
||||||
|
{
|
||||||
|
/* Skip unavailable parameters. */
|
||||||
|
nonull(inst, apply(UnavailableInstance));
|
||||||
|
nonull(stat, apply(error(InvalidParameter, "Given stat was null.")));
|
||||||
|
nonull(initiator, apply(error(InvalidParameter, "Given initiator was null.")));
|
||||||
|
state(priority < 0, apply(error(InvalidParameter, "Given priority was negative.")));
|
||||||
|
|
||||||
|
/* Copy and assign. */
|
||||||
|
inst->content = *stat;
|
||||||
|
inst->initiator = calloc(strlen(initiator), sizeof(char));
|
||||||
|
(void)strcpy(inst->initiator, initiator);
|
||||||
|
inst->time = time(NULL);
|
||||||
|
inst->level = priority;
|
||||||
|
inst->status = REPORT_SENDING_TASK_STATUS_PENDING;
|
||||||
|
inst->dst = (dest == NULL ? stdout : dest);
|
||||||
|
|
||||||
|
return apply(NormalStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status Report_CopyOf(Report *inst, Report *other)
|
||||||
|
{
|
||||||
|
nonull(inst, apply(UnavailableInstance));
|
||||||
|
nonull(other, apply(error(InvalidParameter, "Given report is unavailable.")));
|
||||||
|
|
||||||
|
// Status status;
|
||||||
|
// char *initiator;
|
||||||
|
// time_t time;
|
||||||
|
// ReportLevel priority;
|
||||||
|
// ReportTaskStatus taskprint_status;
|
||||||
|
// FILE *dest;
|
||||||
|
inst->content = other->content;
|
||||||
|
|
||||||
|
return apply(NormalStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
void Report_Delete(Report *inst)
|
||||||
|
{
|
||||||
|
svoid(inst);
|
||||||
|
|
||||||
|
free(inst->initiator);
|
||||||
|
inst->initiator = NULL;
|
||||||
|
inst->dst = NULL;
|
||||||
|
inst->level = 0;
|
||||||
|
inst->content = (Status){};
|
||||||
|
inst->status = REPORT_SENDING_TASK_STATUS_NOTFOUND;
|
||||||
|
inst->time = 0;
|
||||||
|
inst = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
/*
|
||||||
|
Status status;
|
||||||
|
char *initiator;
|
||||||
|
time_t time;
|
||||||
|
ReportLevel priority;
|
||||||
|
ReportTaskStatus taskprint_status;
|
||||||
|
FILE *dest;
|
||||||
|
*/
|
||||||
|
Status Report_Literalise(Report *inst, char *buff)
|
||||||
|
{
|
||||||
|
// nonull(inst, apply(UnavailableInstance));
|
||||||
|
// nonull(buff, apply(UnavailableBuffer));
|
||||||
|
|
||||||
|
// /* Report literalisation. */
|
||||||
|
// char report_literalising[LITERALISATION_LENGTH_MAXIMUM] = EMPTY;
|
||||||
|
|
||||||
|
// /** Status literalisation. **/
|
||||||
|
// char status_literalising[LITERALISATION_LENGTH_MAXIMUM] = EMPTY;
|
||||||
|
|
||||||
|
// /* Fault detection on status literalisation. */
|
||||||
|
// // settle(Status_LiteraliseForReport(&inst->status, status_literalising),
|
||||||
|
// // _.characteristic == STATUS_UNKNOWN, {
|
||||||
|
// // nest(_, __, {
|
||||||
|
// // /* Skip when ZERO byte were written. (failed to write) */
|
||||||
|
// // state(!__.value, apply(
|
||||||
|
// // error(value(TraditionalFunctionReturn, __.value),
|
||||||
|
// // "ZERO byte were written.")
|
||||||
|
// // ));
|
||||||
|
// // })
|
||||||
|
// // });
|
||||||
|
|
||||||
|
// /* Traditional function returning handling. */
|
||||||
|
// // settle(Status_LiteraliseForReport(&inst->content, status_literalising),
|
||||||
|
// // !_.value, {
|
||||||
|
// // return apply(annot(RuntimeError, "Failed to literalise status for report."));
|
||||||
|
// // });
|
||||||
|
|
||||||
|
// where(
|
||||||
|
// snprintf(buff, LITERALISATION_LENGTH_MAXIMUM, REPORT_LITERALISE_FORMAT_DETAIL,
|
||||||
|
// strnil(inst->content.identity), strnil(inst->content.prev->identity),
|
||||||
|
// inst->content.value, inst->content.characteristic,
|
||||||
|
// inst->content.loc.file, inst->content.loc.line,
|
||||||
|
// inst->content.loc.func), {
|
||||||
|
// return apply(value(TraditionalFunctionReturn, _));
|
||||||
|
// });
|
||||||
|
|
||||||
|
// /* Write result to buffer. */
|
||||||
|
// /* Write the report "header". */
|
||||||
|
// /* Literalise current time and date. */
|
||||||
|
// char datetime[LITERALISATION_LENGTH_MAXIMUM];
|
||||||
|
// // settle(strftime(datetime, 64, "%c", localtime(&inst->time)), )
|
||||||
|
|
||||||
|
// // DATETIME [LEVEL] STATUS.IDENTITY (INITIATOR): STATUS.DESCRIPTION
|
||||||
|
// state(!snprintf(report_literalising, LITERALISATION_LENGTH_MAXIMUM,
|
||||||
|
// REPORT_LITERALISE_FORMAT_HEADER, datetime, inst->level,
|
||||||
|
// inst->content.identity, inst->initiator, inst->content.description),
|
||||||
|
// apply(annot(NoBytesWereWritten, "Failed to literalise date and time."))
|
||||||
|
// );
|
||||||
|
|
||||||
|
// /* Write the report "detail". */
|
||||||
|
|
||||||
|
return apply(NormalStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
thrd_t thread;
|
||||||
|
Report report;
|
||||||
|
time_t elapsed;
|
||||||
|
ReportResult result;
|
||||||
|
*/
|
||||||
|
Status ReportSender_Create(ReportSender *inst, Report *report)
|
||||||
|
{
|
||||||
|
nonull(inst, apply(UnavailableInstance));
|
||||||
|
nonull(report, error(UnavailableParameter, "Given report was unavailable."));
|
||||||
|
|
||||||
|
thrd_create(&inst->thread, &HANDLER, report);
|
||||||
|
notok(Report_CopyOf(&inst->report, report),
|
||||||
|
return apply(annot(InstanceCreatingFailure,
|
||||||
|
"Cannot copy to create new instance of report."));
|
||||||
|
);
|
||||||
|
inst->report = *report;
|
||||||
|
inst->elapsed = 0;
|
||||||
|
inst->result = REPORT_RESULT_PENDING;
|
||||||
|
|
||||||
|
return apply(NormalStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status ReportSender_Send(ReportSender *inst, ReportTask task)
|
||||||
|
{
|
||||||
|
// /* Skip when inst or task is unavailable. */
|
||||||
|
// nonull(inst,
|
||||||
|
// error(UnavailableInstance, "Report sender was given unavailable."));
|
||||||
|
// nonull(task, InvalidReportTask);
|
||||||
|
|
||||||
|
// /* Assign for dest. */
|
||||||
|
// const FILE *dest = (inst->report->dest == NULL ? stdout : inst->report->dest);
|
||||||
|
// // char buff[];
|
||||||
|
// // TODO(william): HERE, Report_Literalise
|
||||||
|
|
||||||
|
// /* Write/Send data. */
|
||||||
|
// inst->report->taskprint_status = REPORT_SENDING_TASK_STATUS_PROCEEDING;
|
||||||
|
// if (!fprintf(dest, buff)) {
|
||||||
|
// }
|
||||||
|
|
||||||
|
// /* Sent successfully! Mark down properties. */
|
||||||
|
return apply(NormalStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
ReportTaskID THROW(Report report, Location loc)
|
||||||
|
{
|
||||||
|
// // /* Create new a instance of ReportSender. */
|
||||||
|
// // ReportSender sender;
|
||||||
|
// // ReportSender_Create(&sender, stderr);
|
||||||
|
|
||||||
|
// // /* Send message. */
|
||||||
|
// // /* Initialise sender's thread. */
|
||||||
|
// // thrd_t sending;
|
||||||
|
// // /* Skip on failing on creating thread. */
|
||||||
|
// // if (!thrd_create(&sending, starter, NULL)) {
|
||||||
|
|
||||||
|
// // /* Conclude the session of sender. */
|
||||||
|
// // report.status = REPORT_SENDING_TASK_STATUS_FINISHED,
|
||||||
|
// // report.result = (ARGUE_RESULT_FINALISED | ARGUE_RESULT_NEGATIVE);
|
||||||
|
|
||||||
|
// // sender.result = REPORT_SENDER_RESULT_FINISHED;
|
||||||
|
// // sender.successful = false;
|
||||||
|
|
||||||
|
// // return -1;
|
||||||
|
// // }
|
||||||
|
|
||||||
|
// // /* Perform sending. */
|
||||||
|
// // ReportSender_Send(&sender, NULL);
|
||||||
|
|
||||||
|
// /* Initialise sender. */
|
||||||
|
// ReportSender sender;
|
||||||
|
// /* Return with -1 when initialisation failed. */
|
||||||
|
// state(!(StatusUtils_IsOkay(ReportSender_Create(&sender, &report))), -1);
|
||||||
|
|
||||||
|
// /* Inject location information. Could be more elegant, though. */
|
||||||
|
// sender.report->status.loc = loc;
|
||||||
|
|
||||||
|
// /* Send. */ /* Return -1 when failed on sending. */
|
||||||
|
// state(!StatusUtils_IsOkay(ReportSender_Send(&sender, HANDLER)), -1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
int HANDLER(void *report)
|
||||||
|
{
|
||||||
|
// /* Throw UnableToThrowError when param is unavailable. */
|
||||||
|
// if (report == NULL) {
|
||||||
|
// /* Create report on this. */
|
||||||
|
// Report e;
|
||||||
|
// Report_Create(
|
||||||
|
// &e,
|
||||||
|
// &error(UnableToThrowError, "Cannot perform throwing. Aborted."),
|
||||||
|
// stderr, nameof(DEFAULT_ARGUE_STARTER),
|
||||||
|
// REPORT_SENDING_PRIORITY_FATAL);
|
||||||
|
|
||||||
|
// /* Perform throwing. */
|
||||||
|
// (void)throw(e); // Throw the report alone.
|
||||||
|
// return 1;
|
||||||
|
// }
|
||||||
|
|
||||||
|
// (void)throw(*(Report *)report); // Lonely throw, no catch will company.
|
||||||
|
// return 0;
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
100
report.h
Normal file
100
report.h
Normal file
@@ -0,0 +1,100 @@
|
|||||||
|
#ifndef COMPOUND_REPORT_H
|
||||||
|
# define COMPOUND_REPORT_H
|
||||||
|
|
||||||
|
# include <Compound/status.h>
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
REPORT_SENDING_PRIORITY_ALL = 0, // Highest level; least value.
|
||||||
|
REPORT_SENDING_PRIORITY_FATAL,
|
||||||
|
REPORT_SENDING_PRIORITY_EXCEPTIONAL,
|
||||||
|
REPORT_SENDING_PRIORITY_CRITICAL,
|
||||||
|
REPORT_SENDING_PRIORITY_MAJOR,
|
||||||
|
REPORT_SENDING_PRIORITY_NORMAL,
|
||||||
|
REPORT_SENDING_PRIORITY_MINOR,
|
||||||
|
REPORT_SENDING_PRIORITY_DEBUG,
|
||||||
|
REPORT_SENDING_PRIORITY_NONE, // Lowest level, greatest value.
|
||||||
|
} ReportLevel;
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
REPORT_SENDING_TASK_STATUS_FINISHED = 0,
|
||||||
|
REPORT_SENDING_TASK_STATUS_PENDING,
|
||||||
|
REPORT_SENDING_TASK_STATUS_PROCEEDING,
|
||||||
|
REPORT_SENDING_TASK_STATUS_PAUSED,
|
||||||
|
REPORT_SENDING_TASK_STATUS_NOTFOUND
|
||||||
|
} ReportStatus;
|
||||||
|
|
||||||
|
/* "Report" recollects essential informations, included but not limited to
|
||||||
|
Status and others for making an report for debugging and such. */
|
||||||
|
typedef struct {
|
||||||
|
Status content;
|
||||||
|
char *initiator;
|
||||||
|
time_t time;
|
||||||
|
ReportLevel level;
|
||||||
|
ReportStatus status;
|
||||||
|
FILE *dst; // The destination where the report is sending to.
|
||||||
|
} Report;
|
||||||
|
|
||||||
|
/*
|
||||||
|
DATETIME [PRIORITY] STATUSNAME (ORIGINATOR): STATUS.DESCRIPTION
|
||||||
|
at LOCATION.FILE:LOCATION.LINE, LOCATION.FUNC
|
||||||
|
at LOCATION.FILE:LOCATION.LINE, LOCATION.FUNC
|
||||||
|
at LOCATION.FILE:LOCATION.LINE, LOCATION.FUNC
|
||||||
|
at LOCATION.FILE:LOCATION.LINE, LOCATION.FUNC
|
||||||
|
|
||||||
|
|
||||||
|
Fri 10 May 03:02:37 CST 2024 [URGENT] InvalidParameter (Nullity): Given buffer was unavailable.
|
||||||
|
at /external/Documents/Projects/Compound/Status/src/status.c:104, Report_Literalise
|
||||||
|
at /external/Documents/Projects/Compound/Status/src/status.c:114, ReportSender_Send
|
||||||
|
at /external/Documents/Projects/Compound/Status/src/status.c:69, _throw
|
||||||
|
!!!!at /external/Documents/Projects/Compound/Array/src/array.c:16, array_create
|
||||||
|
at /external/Documents/Projects/Compound/test.c:24, main
|
||||||
|
|
||||||
|
*/
|
||||||
|
|
||||||
|
// DATETIME [LEVEL] STATUS.IDENTITY (INITIATOR): STATUS.DESCRIPTION
|
||||||
|
# define REPORT_LITERALISE_FORMAT_HEADER "%s [%d] %s (%s): %s\n\tat %s:%d, %s\n%s"
|
||||||
|
|
||||||
|
// STATUS.IDENTITY, STATUS.PREV.IDENTITY, STATUS.VALUE, STATUS.CHARACTERISTIC,
|
||||||
|
// FILE, LINE, FUNC
|
||||||
|
# define REPORT_LITERALISE_FORMAT_DETAIL "\t%s(%s, %d, %d) at %s:%d, %s\n"
|
||||||
|
|
||||||
|
typedef enum {
|
||||||
|
REPORT_RESULT_SUCCEEDED,
|
||||||
|
REPORT_RESULT_FAILED,
|
||||||
|
REPORT_RESULT_PROGRESSING,
|
||||||
|
REPORT_RESULT_PENDING,
|
||||||
|
} ReportResult;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
thrd_t thread;
|
||||||
|
Report report;
|
||||||
|
time_t elapsed;
|
||||||
|
ReportResult result;
|
||||||
|
} ReportSender;
|
||||||
|
|
||||||
|
typedef int (*ReportTask)(Report *);
|
||||||
|
typedef int ReportTaskID;
|
||||||
|
|
||||||
|
Status Report_Create(Report *inst, Status *stat, FILE *dest, char *initiator,
|
||||||
|
int priority);
|
||||||
|
Status Report_CopyOf(Report *inst, Report *other);
|
||||||
|
Status Report_Literalise(Report *inst, char *buff);
|
||||||
|
void Report_Delete(Report *inst);
|
||||||
|
bool Report_Equals(Report repo1, Report repo2);
|
||||||
|
|
||||||
|
// Status ReportSender_Create(ReportSender *inst, Report *report, thrd_start_t *handler);
|
||||||
|
Status ReportSender_Create(ReportSender *inst, Report *report);
|
||||||
|
Status ReportSender_Send(ReportSender *inst, ReportTask task);
|
||||||
|
|
||||||
|
// ReportTaskStatus
|
||||||
|
// ReportSender_GetStatus(ReportSender *inst);
|
||||||
|
|
||||||
|
/* Add location parameter requirement in order to give proper information
|
||||||
|
* before throwing the report out. */
|
||||||
|
// # define throw(report) THROW(report, __HERE__)
|
||||||
|
|
||||||
|
// ReportTaskID THROW(Report report, Location loc);
|
||||||
|
// Report CATCH(ReportTaskID taskid, Status (*handler)());
|
||||||
|
int HANDLER(void *report);
|
||||||
|
|
||||||
|
#endif /* COMPOUND_REPORT_H */
|
614
test.c
Normal file
614
test.c
Normal file
@@ -0,0 +1,614 @@
|
|||||||
|
#include <Compound/array.h>
|
||||||
|
#include <Compound/catlog.h>
|
||||||
|
#include <Compound/common.h>
|
||||||
|
#include <Compound/memman.h>
|
||||||
|
#include <Compound/status.h>
|
||||||
|
#include <Compound/var.h>
|
||||||
|
|
||||||
|
Status func(void)
|
||||||
|
{
|
||||||
|
return apply(
|
||||||
|
error(ErrorStatus, "This function does not accept any parameters!"));
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__((constructor))
|
||||||
|
void __CONSTRUCT__() {
|
||||||
|
cat("Hello, Compound!");
|
||||||
|
}
|
||||||
|
|
||||||
|
__attribute__((destructor))
|
||||||
|
void __DESTRUCT__() {}
|
||||||
|
|
||||||
|
Status Main(void)
|
||||||
|
{
|
||||||
|
|
||||||
|
|
||||||
|
return apply(NormalStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status MainArrayComparisonTest(void)
|
||||||
|
{
|
||||||
|
Array arr1 = EMPTY;
|
||||||
|
fail(Array_Create(&arr1, 10, 10));
|
||||||
|
|
||||||
|
Array arr2 = EMPTY;
|
||||||
|
fail(Array_Create(&arr2, 10, 10));
|
||||||
|
|
||||||
|
if (Array_Equals(&arr1, &arr2)) {
|
||||||
|
cat("Equal!");
|
||||||
|
} else {
|
||||||
|
cat("Not equal!");
|
||||||
|
}
|
||||||
|
|
||||||
|
Array_Delete(&arr2);
|
||||||
|
Array_Delete(&arr1);
|
||||||
|
|
||||||
|
return apply(NormalStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status MainMemoryOperationTest(void)
|
||||||
|
{
|
||||||
|
Memory mem = EMPTY;
|
||||||
|
fail(Memory_Create(&mem, sizeof(double)));
|
||||||
|
|
||||||
|
fail(Memory_Allocate(&mem));
|
||||||
|
|
||||||
|
(void)printf("%p:%ld\n", mem.addr, mem.size);
|
||||||
|
|
||||||
|
fail(Memory_Reallocate(&mem, sizeof(char)));
|
||||||
|
|
||||||
|
(void)printf("%p:%ld\n", mem.addr, mem.size);
|
||||||
|
|
||||||
|
fail(Memory_Release(&mem));
|
||||||
|
|
||||||
|
fail(Memory_Delete(&mem));
|
||||||
|
|
||||||
|
return apply(NormalStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
int tfunc(void)
|
||||||
|
{
|
||||||
|
vfail(apply(ErrorStatus), 1);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
Status MainMacroFailsTest(void)
|
||||||
|
{
|
||||||
|
unsure(apply(value(TraditionalFunctionReturn, tfunc())), _.value,
|
||||||
|
nest(_, __, fails(shift(__, STATUS_ERROR), "Failed on execution from tfunc.")));
|
||||||
|
|
||||||
|
return apply(NormalStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status MainArrayCreateAndDeleteWithModulatedMemberAccessing(void)
|
||||||
|
{
|
||||||
|
Array arr = EMPTY;
|
||||||
|
fail(Array_Create(&arr, 8, sizeof(int)));
|
||||||
|
|
||||||
|
for (register int i = 0; i < arr.len; i++) {
|
||||||
|
Var current = EMPTY;
|
||||||
|
|
||||||
|
// fails(Var_Create(¤t, arr.members[0].size),
|
||||||
|
// "Failed to create Var current.");
|
||||||
|
|
||||||
|
state(!current.alive || !arr.members[i].alive,
|
||||||
|
apply(InvalidOperationBetweenAliveAndNonAlive));
|
||||||
|
assign(current, arr.members[i], int);
|
||||||
|
|
||||||
|
char buff[LITERALISATION_LENGTH_MAXIMUM] = EMPTY;
|
||||||
|
unsure(Var_Literalise(¤t, buff), !_.value, {
|
||||||
|
return annot(_, "Failed to literalise Var current.");
|
||||||
|
})
|
||||||
|
|
||||||
|
(void)printf("%s\n", buff);
|
||||||
|
|
||||||
|
// Var_Delete(¤t);
|
||||||
|
}
|
||||||
|
|
||||||
|
cat("Get:");
|
||||||
|
Var get = EMPTY;
|
||||||
|
|
||||||
|
fails(Var_Create(&get, arr.members[4].size), "Failed to create Var \"get\".");
|
||||||
|
|
||||||
|
state(!get.alive || !arr.members[4].alive,
|
||||||
|
apply(InvalidOperationBetweenAliveAndNonAlive));
|
||||||
|
assign(get, arr.members[4], int);
|
||||||
|
|
||||||
|
char buff[LITERALISATION_LENGTH_MAXIMUM] = EMPTY;
|
||||||
|
unsure(Var_Literalise(&get, buff), !_.value, {
|
||||||
|
return annot(_, "Failed to literalise Var current.");
|
||||||
|
})
|
||||||
|
|
||||||
|
Var_Delete(&get);
|
||||||
|
|
||||||
|
// Array_Delete(&arr);
|
||||||
|
|
||||||
|
return apply(NormalStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status MainArrayCreateAndDeleteWithTraditionalMemberAccessing(void)
|
||||||
|
{
|
||||||
|
// const int len = 8;
|
||||||
|
|
||||||
|
// int iarr[] = {
|
||||||
|
// 1, 2, 4, 8, 16, 32, 64, 128
|
||||||
|
// };
|
||||||
|
|
||||||
|
// Array arr;
|
||||||
|
// fails(Array_Create(&arr, len, sizeof(__typeof__(iarr[0]))),
|
||||||
|
// "Failed to create an array instance.");
|
||||||
|
|
||||||
|
// /* Array member assignments with iarr. */
|
||||||
|
// for (register int i = 0; i < arr.len; i++) {
|
||||||
|
// arr.members[i].addr = &iarr[i];
|
||||||
|
// }
|
||||||
|
|
||||||
|
// for (register int i = 0; i < arr.len; i++) {
|
||||||
|
// (void)printf("%d\n", i);
|
||||||
|
|
||||||
|
// for (register int j = 0; j < *(int *)arr.members[i].addr; j++) {
|
||||||
|
// (void)printf("#");
|
||||||
|
// }
|
||||||
|
|
||||||
|
// (void)printf("\n");
|
||||||
|
// }
|
||||||
|
|
||||||
|
// // Array_Delete(&arr);
|
||||||
|
|
||||||
|
|
||||||
|
Array arr = EMPTY;
|
||||||
|
fail(Array_Create(&arr, 8, sizeof(long long)));
|
||||||
|
|
||||||
|
for (register int i = 0; i < arr.len; i++) {
|
||||||
|
cast(arr.members[i], long long) = INT64_MAX;
|
||||||
|
(void)printf("%lld\n", cast(arr.members[i], long long));
|
||||||
|
}
|
||||||
|
|
||||||
|
Array_Delete(&arr);
|
||||||
|
|
||||||
|
return apply(NormalStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
Status MainStatus(void)
|
||||||
|
{
|
||||||
|
// Memory mem1;
|
||||||
|
// seek(Memory_Create(&mem1, INT64_MAX), {
|
||||||
|
// print_status(_);
|
||||||
|
// });
|
||||||
|
// seek(Memory_Allocate(&mem1), {
|
||||||
|
// print_status(_);
|
||||||
|
// });
|
||||||
|
// seek(Memory_Allocate(&mem1), {
|
||||||
|
// print_status(_);
|
||||||
|
// });
|
||||||
|
// seek(Memory_Release(&mem1), {
|
||||||
|
// print_status(_);
|
||||||
|
// });
|
||||||
|
// seek(Memory_Release(&mem1), {
|
||||||
|
// print_status(_);
|
||||||
|
// });
|
||||||
|
// seek(Memory_Delete(&mem1), {
|
||||||
|
// print_status(_);
|
||||||
|
// });
|
||||||
|
|
||||||
|
// PrintStatusDump(unknown(normal(MaximumLiteralisationLengthExceeded, ":O"), "OMGIDKWTD", 1));
|
||||||
|
// PrintStatusDump(apply(extend(MaximumLiteralisationLengthExceeded, normal(UnavailableBuffer, "OMGIDKWTD"))));
|
||||||
|
// PrintStatusDump(MaximumLiteralisationLengthExceeded);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus0, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &MaximumLiteralisationLengthExceeded);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus1, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus0);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus2, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus1);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus3, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus2);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus4, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus3);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus5, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus4);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus6, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus5);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus7, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus6);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus8, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus7);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus9, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus8);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus10, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus9);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus11, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus10);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus12, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus11);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus13, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus12);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus14, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus13);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus15, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus14);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus16, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus15);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus17, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus16);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus18, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus17);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus19, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus18);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus20, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus19);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus21, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus20);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus22, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus21);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus23, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus22);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus24, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus23);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus25, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus24);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus26, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus25);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus27, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus26);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus28, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus27);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus29, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus28);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus30, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus29);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus31, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus30);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus32, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus31);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus33, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus32);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus34, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus33);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus35, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus34);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus36, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus35);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus37, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus36);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus38, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus37);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus39, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus38);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus40, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus39);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus41, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus40);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus42, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus41);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus43, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus42);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus44, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus43);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus45, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus44);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus46, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus45);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus47, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus46);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus48, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus47);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus49, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus48);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus50, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus49);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus51, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus50);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus52, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus51);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus53, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus52);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus54, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus53);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus55, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus54);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus56, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus55);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus57, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus56);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus58, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus57);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus59, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus58);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus60, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus59);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus61, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus60);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus62, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus61);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus63, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus62);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus64, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus63);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus65, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus64);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus66, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus65);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus67, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus66);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus68, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus67);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus69, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus68);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus70, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus69);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus71, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus70);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus72, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus71);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus73, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus72);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus74, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus73);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus75, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus74);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus76, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus75);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus77, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus76);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus78, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus77);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus79, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus78);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus80, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus79);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus81, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus80);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus82, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus81);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus83, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus82);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus84, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus83);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus85, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus84);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus86, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus85);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus87, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus86);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus88, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus87);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus89, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus88);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus90, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus89);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus91, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus90);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus92, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus91);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus93, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus92);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus94, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus93);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus95, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus94);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus96, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus95);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus97, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus96);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus98, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus97);
|
||||||
|
|
||||||
|
DEFSTATUS(TestStatus99, 1,
|
||||||
|
"This status is used for displaying multi-layer of status dumping.",
|
||||||
|
STATUS_NORMAL, &TestStatus98);
|
||||||
|
|
||||||
|
|
||||||
|
PrintStatusDump(apply(TestStatus99));
|
||||||
|
|
||||||
|
return apply(NormalStatus);
|
||||||
|
}
|
||||||
|
|
||||||
|
int main(void)
|
||||||
|
{
|
||||||
|
int rtn = 0;
|
||||||
|
notok(Main(), {
|
||||||
|
rtn = _.value;
|
||||||
|
PrintStatusDump(_);
|
||||||
|
})
|
||||||
|
|
||||||
|
return rtn;
|
||||||
|
}
|
Reference in New Issue
Block a user