(INI) Initiated MemMan

(MOD) Extended abtilities of Status

(ADD) Introduced CMake building system for Compound
This commit is contained in:
William
2024-04-13 19:42:50 +08:00
parent 9877602ffa
commit 143c921a8a
29 changed files with 874 additions and 102 deletions

8
.gitignore vendored Normal file
View File

@@ -0,0 +1,8 @@
CMakeFiles/*
*CMakeCache*
cmake_install.cmake
*[tT]est*
*~
gitwork
work
Makefile

1
Array/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
obj/

View File

@@ -8,7 +8,7 @@ set(CMAKE_DEPENDS_LANGUAGES
# The set of dependency files which are needed:
set(CMAKE_DEPENDS_DEPENDENCY_FILES
"/home/william/Documents/Projects/Compound/src/test.c" "CMakeFiles/CompoundTest.dir/src/test.c.o" "gcc" "CMakeFiles/CompoundTest.dir/src/test.c.o.d"
"/home/william/Documents/Projects/Compound/test.c" "CMakeFiles/CompoundTest.dir/test.c.o" "gcc" "CMakeFiles/CompoundTest.dir/test.c.o.d"
)
# Targets to which this target links which contain Fortran sources.

View File

@@ -69,28 +69,28 @@ include CMakeFiles/CompoundTest.dir/progress.make
# Include the compile flags for this target's objects.
include CMakeFiles/CompoundTest.dir/flags.make
CMakeFiles/CompoundTest.dir/src/test.c.o: CMakeFiles/CompoundTest.dir/flags.make
CMakeFiles/CompoundTest.dir/src/test.c.o: src/test.c
CMakeFiles/CompoundTest.dir/src/test.c.o: CMakeFiles/CompoundTest.dir/compiler_depend.ts
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --green --progress-dir=/home/william/Documents/Projects/Compound/CMakeFiles --progress-num=$(CMAKE_PROGRESS_1) "Building C object CMakeFiles/CompoundTest.dir/src/test.c.o"
/usr/bin/cc $(C_DEFINES) $(C_INCLUDES) $(C_FLAGS) -MD -MT CMakeFiles/CompoundTest.dir/src/test.c.o -MF CMakeFiles/CompoundTest.dir/src/test.c.o.d -o CMakeFiles/CompoundTest.dir/src/test.c.o -c /home/william/Documents/Projects/Compound/src/test.c
CMakeFiles/CompoundTest.dir/test.c.o: CMakeFiles/CompoundTest.dir/flags.make
CMakeFiles/CompoundTest.dir/test.c.o: test.c
CMakeFiles/CompoundTest.dir/test.c.o: CMakeFiles/CompoundTest.dir/compiler_depend.ts
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --green --progress-dir=/home/william/Documents/Projects/Compound/CMakeFiles --progress-num=$(CMAKE_PROGRESS_1) "Building C object CMakeFiles/CompoundTest.dir/test.c.o"
/usr/bin/cc $(C_DEFINES) $(C_INCLUDES) $(C_FLAGS) -MD -MT CMakeFiles/CompoundTest.dir/test.c.o -MF CMakeFiles/CompoundTest.dir/test.c.o.d -o CMakeFiles/CompoundTest.dir/test.c.o -c /home/william/Documents/Projects/Compound/test.c
CMakeFiles/CompoundTest.dir/src/test.c.i: cmake_force
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --green "Preprocessing C source to CMakeFiles/CompoundTest.dir/src/test.c.i"
/usr/bin/cc $(C_DEFINES) $(C_INCLUDES) $(C_FLAGS) -E /home/william/Documents/Projects/Compound/src/test.c > CMakeFiles/CompoundTest.dir/src/test.c.i
CMakeFiles/CompoundTest.dir/test.c.i: cmake_force
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --green "Preprocessing C source to CMakeFiles/CompoundTest.dir/test.c.i"
/usr/bin/cc $(C_DEFINES) $(C_INCLUDES) $(C_FLAGS) -E /home/william/Documents/Projects/Compound/test.c > CMakeFiles/CompoundTest.dir/test.c.i
CMakeFiles/CompoundTest.dir/src/test.c.s: cmake_force
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --green "Compiling C source to assembly CMakeFiles/CompoundTest.dir/src/test.c.s"
/usr/bin/cc $(C_DEFINES) $(C_INCLUDES) $(C_FLAGS) -S /home/william/Documents/Projects/Compound/src/test.c -o CMakeFiles/CompoundTest.dir/src/test.c.s
CMakeFiles/CompoundTest.dir/test.c.s: cmake_force
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --green "Compiling C source to assembly CMakeFiles/CompoundTest.dir/test.c.s"
/usr/bin/cc $(C_DEFINES) $(C_INCLUDES) $(C_FLAGS) -S /home/william/Documents/Projects/Compound/test.c -o CMakeFiles/CompoundTest.dir/test.c.s
# Object files for target CompoundTest
CompoundTest_OBJECTS = \
"CMakeFiles/CompoundTest.dir/src/test.c.o"
"CMakeFiles/CompoundTest.dir/test.c.o"
# External object files for target CompoundTest
CompoundTest_EXTERNAL_OBJECTS =
CompoundTest: CMakeFiles/CompoundTest.dir/src/test.c.o
CompoundTest: CMakeFiles/CompoundTest.dir/test.c.o
CompoundTest: CMakeFiles/CompoundTest.dir/build.make
CompoundTest: CMakeFiles/CompoundTest.dir/link.txt
@$(CMAKE_COMMAND) -E cmake_echo_color "--switch=$(COLOR)" --green --bold --progress-dir=/home/william/Documents/Projects/Compound/CMakeFiles --progress-num=$(CMAKE_PROGRESS_2) "Linking C executable CompoundTest"

View File

@@ -1,6 +1,6 @@
file(REMOVE_RECURSE
"CMakeFiles/CompoundTest.dir/src/test.c.o"
"CMakeFiles/CompoundTest.dir/src/test.c.o.d"
"CMakeFiles/CompoundTest.dir/test.c.o"
"CMakeFiles/CompoundTest.dir/test.c.o.d"
"CompoundTest"
"CompoundTest.pdb"
)

View File

@@ -1,2 +1,85 @@
# Empty compiler generated dependencies file for CompoundTest.
# This may be replaced when dependencies are built.
# CMAKE generated file: DO NOT EDIT!
# Generated by "Unix Makefiles" Generator, CMake Version 3.29
CMakeFiles/CompoundTest.dir/test.c.o: test.c \
/usr/include/bits/floatn-common.h \
/usr/include/bits/floatn.h \
/usr/include/bits/libc-header-start.h \
/usr/include/bits/long-double.h \
/usr/include/bits/stdio_lim.h \
/usr/include/bits/time64.h \
/usr/include/bits/timesize.h \
/usr/include/bits/types.h \
/usr/include/bits/types/FILE.h \
/usr/include/bits/types/__FILE.h \
/usr/include/bits/types/__fpos64_t.h \
/usr/include/bits/types/__fpos_t.h \
/usr/include/bits/types/__mbstate_t.h \
/usr/include/bits/types/cookie_io_functions_t.h \
/usr/include/bits/types/struct_FILE.h \
/usr/include/bits/typesizes.h \
/usr/include/bits/wordsize.h \
/usr/include/features-time64.h \
/usr/include/features.h \
/usr/include/gnu/stubs-64.h \
/usr/include/gnu/stubs.h \
/usr/include/stdc-predef.h \
/usr/include/stdio.h \
/usr/include/sys/cdefs.h \
/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/include/stdarg.h \
/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/include/stddef.h
/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/include/stddef.h:
/usr/include/sys/cdefs.h:
/usr/include/stdc-predef.h:
/usr/include/stdio.h:
/usr/include/gnu/stubs.h:
/usr/include/features.h:
/usr/include/bits/types/struct_FILE.h:
/usr/include/bits/types/cookie_io_functions_t.h:
test.c:
/usr/include/bits/floatn-common.h:
/usr/include/bits/long-double.h:
/usr/include/bits/types/__mbstate_t.h:
/usr/include/bits/floatn.h:
/usr/include/bits/libc-header-start.h:
/usr/include/bits/wordsize.h:
/usr/include/bits/typesizes.h:
/usr/include/bits/stdio_lim.h:
/usr/include/bits/time64.h:
/usr/include/features-time64.h:
/usr/include/bits/types/__fpos_t.h:
/usr/include/gnu/stubs-64.h:
/usr/include/bits/timesize.h:
/usr/lib/gcc/x86_64-pc-linux-gnu/13.2.1/include/stdarg.h:
/usr/include/bits/types/__fpos64_t.h:
/usr/include/bits/types/FILE.h:
/usr/include/bits/types.h:
/usr/include/bits/types/__FILE.h:

View File

@@ -1 +1 @@
/usr/bin/cc -rdynamic CMakeFiles/CompoundTest.dir/src/test.c.o -o CompoundTest
/usr/bin/cc -rdynamic CMakeFiles/CompoundTest.dir/test.c.o -o CompoundTest

View File

@@ -11,96 +11,18 @@ set(CMAKE_MAKEFILE_DEPENDS
"CMakeFiles/3.29.0/CMakeCXXCompiler.cmake"
"CMakeFiles/3.29.0/CMakeSystem.cmake"
"CMakeLists.txt"
"/usr/share/cmake/Modules/CMakeCCompiler.cmake.in"
"/usr/share/cmake/Modules/CMakeCCompilerABI.c"
"/usr/share/cmake/Modules/CMakeCInformation.cmake"
"/usr/share/cmake/Modules/CMakeCXXCompiler.cmake.in"
"/usr/share/cmake/Modules/CMakeCXXCompilerABI.cpp"
"/usr/share/cmake/Modules/CMakeCXXInformation.cmake"
"/usr/share/cmake/Modules/CMakeCommonLanguageInclude.cmake"
"/usr/share/cmake/Modules/CMakeCompilerIdDetection.cmake"
"/usr/share/cmake/Modules/CMakeDetermineCCompiler.cmake"
"/usr/share/cmake/Modules/CMakeDetermineCXXCompiler.cmake"
"/usr/share/cmake/Modules/CMakeDetermineCompileFeatures.cmake"
"/usr/share/cmake/Modules/CMakeDetermineCompiler.cmake"
"/usr/share/cmake/Modules/CMakeDetermineCompilerABI.cmake"
"/usr/share/cmake/Modules/CMakeDetermineCompilerId.cmake"
"/usr/share/cmake/Modules/CMakeDetermineSystem.cmake"
"/usr/share/cmake/Modules/CMakeFindBinUtils.cmake"
"/usr/share/cmake/Modules/CMakeGenericSystem.cmake"
"/usr/share/cmake/Modules/CMakeInitializeConfigs.cmake"
"/usr/share/cmake/Modules/CMakeLanguageInformation.cmake"
"/usr/share/cmake/Modules/CMakeParseImplicitIncludeInfo.cmake"
"/usr/share/cmake/Modules/CMakeParseImplicitLinkInfo.cmake"
"/usr/share/cmake/Modules/CMakeParseLibraryArchitecture.cmake"
"/usr/share/cmake/Modules/CMakeSystem.cmake.in"
"/usr/share/cmake/Modules/CMakeSystemSpecificInformation.cmake"
"/usr/share/cmake/Modules/CMakeSystemSpecificInitialize.cmake"
"/usr/share/cmake/Modules/CMakeTestCCompiler.cmake"
"/usr/share/cmake/Modules/CMakeTestCXXCompiler.cmake"
"/usr/share/cmake/Modules/CMakeTestCompilerCommon.cmake"
"/usr/share/cmake/Modules/CMakeUnixFindMake.cmake"
"/usr/share/cmake/Modules/Compiler/ADSP-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/ARMCC-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/ARMClang-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/AppleClang-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/Borland-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/Bruce-C-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/CMakeCommonCompilerMacros.cmake"
"/usr/share/cmake/Modules/Compiler/Clang-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/Clang-DetermineCompilerInternal.cmake"
"/usr/share/cmake/Modules/Compiler/Compaq-C-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/Compaq-CXX-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/Cray-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/CrayClang-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/Embarcadero-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/Fujitsu-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/FujitsuClang-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/GHS-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/GNU-C-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/GNU-C.cmake"
"/usr/share/cmake/Modules/Compiler/GNU-CXX-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/GNU-CXX.cmake"
"/usr/share/cmake/Modules/Compiler/GNU-FindBinUtils.cmake"
"/usr/share/cmake/Modules/Compiler/GNU.cmake"
"/usr/share/cmake/Modules/Compiler/HP-C-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/HP-CXX-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/IAR-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/IBMCPP-C-DetermineVersionInternal.cmake"
"/usr/share/cmake/Modules/Compiler/IBMCPP-CXX-DetermineVersionInternal.cmake"
"/usr/share/cmake/Modules/Compiler/IBMClang-C-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/IBMClang-CXX-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/Intel-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/IntelLLVM-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/LCC-C-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/LCC-CXX-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/MSVC-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/NVHPC-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/NVIDIA-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/OpenWatcom-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/OrangeC-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/PGI-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/PathScale-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/SCO-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/SDCC-C-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/SunPro-C-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/SunPro-CXX-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/TI-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/TIClang-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/Tasking-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/TinyCC-C-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/VisualAge-C-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/VisualAge-CXX-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/Watcom-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/XL-C-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/XL-CXX-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/XLClang-C-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/XLClang-CXX-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/zOS-C-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Compiler/zOS-CXX-DetermineCompiler.cmake"
"/usr/share/cmake/Modules/Internal/CMakeDetermineLinkerId.cmake"
"/usr/share/cmake/Modules/Internal/FeatureTesting.cmake"
"/usr/share/cmake/Modules/Platform/Linux-Determine-CXX.cmake"
"/usr/share/cmake/Modules/Platform/Linux-GNU-C.cmake"
"/usr/share/cmake/Modules/Platform/Linux-GNU-CXX.cmake"
"/usr/share/cmake/Modules/Platform/Linux-GNU.cmake"
@@ -117,11 +39,6 @@ set(CMAKE_MAKEFILE_OUTPUTS
# Byproducts of CMake generate step:
set(CMAKE_MAKEFILE_PRODUCTS
"CMakeFiles/3.29.0/CMakeSystem.cmake"
"CMakeFiles/3.29.0/CMakeCCompiler.cmake"
"CMakeFiles/3.29.0/CMakeCXXCompiler.cmake"
"CMakeFiles/3.29.0/CMakeCCompiler.cmake"
"CMakeFiles/3.29.0/CMakeCXXCompiler.cmake"
"CMakeFiles/CMakeDirectoryInformation.cmake"
)

5
CMakeLists.txt Normal file
View File

@@ -0,0 +1,5 @@
cmake_minimum_required (VERSION 2.8)
project (Compound)
add_executable(CompoundTest test.c)

1
Paper/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
obj/

36
Paper/include/paper.h Normal file
View File

@@ -0,0 +1,36 @@
#ifndef COMPOUND_PAPER_H
# define COMPOUND_PAPER_H
# include <Compound/common.h>
# include <Compound/pen.h>
typedef struct {
wchar_t *buff;
int bufflen;
int lines;
int columns;
const int id;
} Paper;
Status paper_create(Paper *paper, int lines, int columns);
Status paper_constr(Paper *paper, wchar_t buff, int bufflen, int lines,
int columns, const int id);
Status paper_nilval(Paper *paper);
void paper_delete(Paper *paper);
Selection paper_pen_select (Paper *paper, Coordination start, Coordination end);
Selection paper_pen_selectby (Paper *paper, int *target);
Status paper_pen_copy (Paper *paper, int **buff, Selection selc);
Status paper_pen_erase (Paper *paper, Selection selc); // pen_write(pen_using, PEN_VALUE_EMPTY)
Status paper_pen_erasefrom (Paper *paper, Coordination coord); // for (...) pen_writeat(pen_using, PEN_VALUE_EMPTY, { i, j }) // Erase from coord to EOF
Status paper_pen_eraseto (Paper *paper, Coordination coord); // Erase from the beginning of file to coord
Status paper_pen_find (Paper *paper, wchar_t *target); /* Select next token found by pen_find and return it. Returns */
Status paper_pen_moveto (Paper *paper, Coordination coord);
Status paper_pen_paste (Paper *paper, wchar_t *buff);
wchar_t paper_pen_read (Paper *paper);
Status paper_pen_replace (Paper *paper, wchar_t *target, wchar_t *replacement);
Status paper_pen_selectfrom (Paper *paper, Coordination start);
Status paper_pen_selectto (Paper *paper, Coordination end);
Status paper_pen_write (Paper *paper, wchar_t value);
#endif /* COMPOUND_PAPER_H */

0
Paper/src/main.c Normal file
View File

1
Paper/src/paper.c Normal file
View File

@@ -0,0 +1 @@
#include <Compound/paper.h>

1
Pen/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
obj/

74
Pen/include/pen.h Normal file
View File

@@ -0,0 +1,74 @@
#ifndef PEN_H
# define PEN_H
# include <stdint.h>
# include <stdlib.h>
# include <stdbool.h>
# include <wchar.h>
# include <Compound/common.h>
# include <Compound/status.h>
# define PEN_BUFFER_MAX_LEN (UINT16_MAX + 1)
enum PEN_OPERATION {
MOVE = 0,
READ = 1,
WRITE = 2,
};
enum PEN_RENDER_HIGHLIGHT_METHOD {
NONE = 0b00000000,
BOLD = 0b00000001,
ITALIC = 0b00000010,
UNDERSCORE = 0b00000100,
STRIKETHROUGH = 0b00001000,
INVERT = 0b00010000,
BOX = 0b00100000,
BLINK = 0b01000000,
BLOCK = 0b10000000,
UNBOLD =-0b00000001,
UNITALIC =-0b00000010,
UNUNDERSCORE =-0b00000100,
UNSTRIKETHROUGH =-0b00001000,
UNINVERT =-0b00010000,
UNBOX =-0b00100000,
UNBLINK =-0b01000000,
UNBLOCK =-0b10000000,
};
# define PEN_CURSOR_STYLE_ACTIVATED BLOCK
# define PEN_CURSOR_STYLE_INACTIVATED BOX
# define PEN_CURSOR_STYLE_IDLE (PEN_CURSOR_STYLE_ACTIVATED | BLINK)
typedef struct {
const int id;
Coordination coord;
int value;
int operation; // -1 for UNKNOWN, tough it is not specified in enumeration,
// the detection will still consider any number that below 0
// as an valid, but unknown one.
int cursor_style; // -1 for disabling
} Pen;
# define PEN_SELECTION_DOT(x, y) (Selection){ (Coordination){ x, y }, \
(Coordination){ x, y } }
# define PEN_VALUE_EMPTY 32
# define PEN_NONULL(o, n) if (o == NULL) return (n);
enum PenError {
PEN_ERROR_FAILED_ON_PEN_NULLITY = -1,
PEN_ERROR_FAILED_ON_FUNCTION_POINTER_REFERENCE = -2
};
Status pen_create(Pen *pen, int cursor_style);
Status pen_others(Pen *pen, Pen src);
Status pen_constr(Pen *pen, const int id, Coordination coord, int value,
int operation, int cursor_style);
void pen_delete(Pen *pen);
#endif /* PEN_H */

0
Pen/src/main.c Normal file
View File

1
Pen/src/pen.c Normal file
View File

@@ -0,0 +1 @@
#include <Compound/pen.h>

1
Render/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
obj/

84
Render/include/color.h Normal file
View File

@@ -0,0 +1,84 @@
#ifndef COMPOUND_RENDER_COLOR_H
# define COMPOUND_RENDER_COLOR_H
# include <Compound/common.h>
/*
* 0 to restore default color
* 1 for brighter colors
* 4 for underlined text
* 5 for flashing text
* 30 for black foreground
* 31 for red foreground
* 32 for green foreground
* 33 for yellow (or brown) foreground
* 34 for blue foreground
* 35 for purple foreground
* 36 for cyan foreground
* 37 for white (or gray) foreground
* 40 for black background
* 41 for red background
* 42 for green background
* 43 for yellow (or brown) background
* 44 for blue background
* 45 for purple background
* 46 for cyan background
* 47 for white (or gray) background
*/
// enum Colour16 {
// COLOR16_DIM_BLACK,
// COLOR16_DIM_RED,
// COLOR16_DIM_GREEN,
// COLOR16_DIM_BLUE,
// COLOR16_DIM_YELLOW,
// COLOR16_DIM_MAGENTA,
// COLOR16_DIM_CYAN,
// COLOR16_DIM_GREY,
// COLOR16_BRIGHT_BLACK,
// COLOR16_BRIGHT_RED,
// COLOR16_BRIGHT_GREEN,
// COLOR16_BRIGHT_BLUE,
// COLOR16_BRIGHT_YELLOW,
// COLOR16_BRIGHT_MAGENTA,
// COLOR16_BRIGHT_CYAN,
// COLOR16_WHITE,
// };
# define COLOR_VALUE_MIN 0
# define COLOR_VALUE_MAX 255
typedef struct {
bool color_red;
bool color_green;
bool color_blue;
bool color_on_foreground;
bool effect_bold;
bool effect_italic;
bool effect_underline;
bool effect_box;
bool effect_strikethrough;
bool effect_invert;
} ColorProperty;
typedef struct {
int red;
int green;
int blue;
bool onfg;
} Color;
Color color(int red, int green, int blue, bool onfg);
ColorProperty color_to_property(Color color);
Color color_from_property(ColorProperty prop);
void color_wrapvalue(int *v);
# define COLOR_INRANGE(v) \
(INRANGE(COLOR_VALUE_MIN, true, COLOR_VALUE_MAX, true, v))
# define COLOR_ATRANGE(v) \
(ATRANGE(COLOR_VALUE_MIN, COLOR_VALUE_MAX, v))
#endif /* COMPOUND_RENDER_COLOR_H */

64
Render/src/color.c Normal file
View File

@@ -0,0 +1,64 @@
#include <Compound/color.h>
Color color(int red, int green, int blue, bool onfg)
{
color_wrapvalue(&red);
color_wrapvalue(&green);
color_wrapvalue(&blue);
return (Color) {
.red = red,
.green = green,
.blue = blue,
.onfg = onfg
};
}
ColorProperty color_to_property(Color color)
{
return (ColorProperty) {
.color_red = color.red,
.color_green = color.green,
.color_blue = color.blue,
.color_on_foreground = color.onfg,
.effect_bold = false,
.effect_italic = false,
.effect_underline = false,
.effect_box = false,
.effect_strikethrough = false,
.effect_invert = false
};
}
Color color_from_property(ColorProperty prop)
{
return (Color) {
.red = (prop.color_red ? (COLOR_VALUE_MAX) : (COLOR_VALUE_MIN)),
.green = (prop.color_green ? (COLOR_VALUE_MAX) : (COLOR_VALUE_MIN)),
.blue = (prop.color_blue ? (COLOR_VALUE_MAX) : (COLOR_VALUE_MIN)),
.onfg = prop.color_on_foreground
};
}
void color_wrapvalue(int *v)
{
if (v == NULL) {
return;
}
const int outrange = COLOR_ATRANGE(*v);
/* Within the range */
if (outrange == 0) {
return;
}
/* Above the range */
if (outrange > 0) {
*v = COLOR_VALUE_MAX;
return;
}
/* Below the range */
*v = COLOR_VALUE_MIN;
}

1
Status/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
obj/

86
Status/doc/STATUS Normal file
View File

@@ -0,0 +1,86 @@
#PROJECT "Compound - Status" DOCUMENTATION WRITTEN BY WILLIAM PASCAL
#
#THIS PROJECT IS COMPILED UNDER "C99 ISO/IEC 9899:1999" WITH
#"gcc (GCC) 13.2.1 20230801"
#PLEASE NOTE THAT THE VERSION TO THE COMPILER MAY CHANGE DURING PROJECT
#DEVELOPMENT, IT IS UNCERTAIN, SO FAR, THAT EVERY COMPILER OLDER/NEWER THAT
#THIS VERSION COULD COMPILE PROPERLY. MS WINDOWS SUPPORT IS UNDER
#CONSIDERATION WHILE DEVELOPMENT FOR GNU/LINUX HAS HIGHER PRIORITY.
LICENSE NOTICE:
This file is part of Compound.
Compound is free software: you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
Foundation, either version 3 of the License, or (at your option) any later
version.
Compound is distributed in the hope that it will be useful, but WITHOUT ANY
WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
details.
You should have received a copy of the GNU General Public License along
with Compound. If not, see <https://www.gnu.org/licenses/>.
BRIEF:
"STATUS" REPRESENT THE ACTUAL PROCESS STATUS OF THE FUNCTION APPLIED TO USE
THIS STRUCTURE AS THE RETURNING TYPE.
DECLARATION:
STRUCTURE - STATUS
IT COMES WITH FOLLOWING MEMBERS:
i. value: int
"VALUE" INDICATES THE VALUE THAT FUNCTION RETURNS. MORE USUALLY, THIS
VALUE IS IGNORED WHEN "CHARACTERISTIC" IS NOT "STATUS_UNKNOWN" AS AN
ALTERNATIVE FOR LEGACY FUNCTIONS WHICH DO NOT USE "int" FOR THEIR
RETURNING.
ii. description: char*
"DESCRIPTION" TELLS THE SITUATION, USUALLY NOT NORMAL, WHERE THE FUNCTION
HAD RUN INTO CERTAIN PROBLEMS DURING THE PROCESS. IT CAN BE USEFUL WHEN
DEBUGGING AND SUCH.
*PLEASE NOTE, AN EMPTY DESCRIPTION ALONG WITH A NULL DESCRIPTION IS
REGARDED AS "MEANINGLESS ONE" WHICH DOES NOT DOING ANYTHING EFFECTIVE FOR
ANYONE. DESCRIPTIONS CAN BE VALIDATED WITH FUNCTION `status_isvalid`.
iii. characteristic: int
"CHARACTERISTIC" INDICATED THE BASIC NATURE OF CURRENT "STATUS".
*GO SEE enum StatusCharacteristics FOR AVAILABLE "CHARACTERISTICS".
iv. prev: struct _Status*
"PREV" STANDS FOR "PREVIOUS STATUS". JUST AS THE NAME TELLS, THIS MEMBER
POINTS AT THE PREVIOUS STRUCTURE OF STATUS WHERE THIS STATUS IS BASED ON.
THIS MEMBER IS USUALLY USED FOR PRINTING CALLING STACKS.
IN SOME CASES, THIS MEMBER COULD POINT AT IT SELF, MEANING IT COULD MAKE
A RECURSIVE SITUATION WHERE IT REQUIRE EXTRA EXAMINATIONS BEFORE GOING TO
THE ADDRESS IT POINTS AT. THESE PROBLEMS CAN BE AVOIDED WITH FUNCTION
`status_recursive` CALLED AHEAD.
*GO SEE status_dump FOR DETAILS ABOUT DUMPING CALLING STACKS.
*GO SEE status_recursive FOR DETERRING RECURSIVE "PREV".
SYNONYM:
Status funcname1(void *param);
Status *funcname2(void);
VARIANT SYNONYM:
int funcname1(Status stat);
void funcname2(Status *stats);
typedef struct _Status {
int value; /* Traditional returning data "int". Only used when the function
called and received legacy functions that uses "int" as the
returning type that wish to have place to hold the value.
Otherwise, the function would just return the structure Status. */
char *description;
int characteristic;
struct _Status *prev;
} Status;

229
Status/include/status.h Normal file
View File

@@ -0,0 +1,229 @@
#ifndef COMPOUND_STATUS_H
# define COMPOUND_STATUS_H
# include <stdbool.h>
# include <stdint.h>
# include <stdlib.h>
# include <string.h>
# include <threads.h>
# include <time.h>
# include <stdio.h>
# define __HERE__ { .file = __FILE__, .line = __LINE__, .func = __func__ }
/* Status characteristics */
typedef enum {
STATUS_UNKNOWN = -1,
STATUS_NORMAL = 0,
STATUS_ERROR = 1
} StatusCharacteristics;
//!!! UNKNOWN ENTITY !!!
// enum {
// ARGUE_FINALISED = 0b01,
// ARGUE_UNSETTLED =-0b01,
// ARGUE_POSITIVE = 0b10,
// ARGUE_NEGATIVE = -0b10,
// };
/* Indicated the exact location where the "issue" was occurred at. */
typedef struct {
const char *file;
int line;
const char *func;
} Location;
/* Common return type for reporting functions that require to give more
information about the procedure. */
typedef struct _Status {
int value; /* Traditional returning data "int". Only used when the function
called and received legacy functions that uses "int" as the
returning type that wish to have place to hold the value.
Otherwise, the function would just return the structure Status. */
char *description;
int characteristic;
struct _Status *prev;
} Status;
/* "Report" recollects essential informations, included but not limited to
Status and others for making an report for debugging and such. */
typedef struct {
Status stat;
Location pos;
char *originator;
struct tm time;
int priority;
} Report;
typedef struct {
FILE **dests_ref;
Report **reports_ref;
int totalreports;
int reportsent;
struct timespec elapsed;
} ReportSender;
typedef Status (*ReportSendingTask) (FILE **, Report *);
typedef int ReportSendingTaskID;
typedef struct {
ReportSendingTask *tasks_ref;
int sendercount;
int finishedcount;
Status *senderreturn;
} ReportSendingManager;
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;
typedef Status (*Argue) (Report);
typedef struct {
Argue argue_start; // Implicitly converting thrd_start_t to Argue
void *external_param;
} ArgueStarter;
/* Argument levels (qualities) */
typedef enum {
ARGUMENT_NONE = 0,
ARGUMENT_MINOR,
ARGUMENT_NORMAL,
ARGUMENT_MAJOR,
ARGUMENT_CRITICAL,
ARGUMENT_SEVERE,
ARGUMENT_ALL,
} ArgumentLevel;
typedef struct {
ReportSender *streams;
ArgueStarter handler;
ArgumentLevel level;
bool muted;
} Argument;
// typedef struct {
// Argument *members;
// int (*announcer) (Argument);
// } ArgumentAnnouncer;
# define STATUS_BUFFER_MAXIMUM_LENGTH UINT32_MAX
bool
status_issueposition_compare(Location lc1, Location lc2);
bool
status_hasprev(Status stat);
bool
status_isnormal(Status stat);
bool
status_isvalid(Status stat);
bool
status_recursive(Status stat);
void
status_dump(Status stat, Status *statbuff, int idx);
bool
status_compare(Status stat1, Status stat2);
bool
report_compare(Report repo1, Report repo2);
Status
reportsender_create(ReportSender *inst, FILE **dests_ref,
ReportSendingTask *tasks_ref);
Status
reportsender_send(ReportSender sender, ReportSendingTask *tasks_ref);
ReportSendingTaskID
reportsendingmanager_appendtask(ReportSendingManager *inst,
ReportSendingTask task);
Status
reportsendingmanager_removetask(ReportSendingManager *inst,
ReportSendingTaskID taskid);
ReportSendingTaskStatus
reportsendingmanager_taskstatus(ReportSendingManager *inst,
ReportSendingTaskID taskid);
Status
arguestarter_create(ArgueStarter *inst, void *external_param);
Status
arguestarter_constr(ArgueStarter *inst, Argue argue_start,
void *external_param);
Status
arguestarter_start(ArgueStarter *inst);
static inline int
arguestarter_equal(ArgueStarter *inst1, ArgueStarter *inst2)
{
return (inst1->argue_start == inst2->argue_start)
|| (inst1->external_param == inst2->external_param);
}
Status arguestarter_current(void);
Status arguestarter_sleep(const struct timespec *time_point,
struct timespec *remaining);
void arguestarter_exit(int code) __attribute__ ((__noreturn__));
Status arguestarter_join(Argue thrd);
Status
argument_create(Argument *inst, ReportSender *streams, ArgueStarter handler);
Status
argument_constr(Argument *inst, ReportSender *streams, ArgueStarter handler,
int level, bool muted);
// --------------------------------------------------------
static Status UnknownStatus = {
.description = "An unknown status.",
.characteristic = STATUS_UNKNOWN,
.prev = NULL
};
static Status NormalStatus = {
.description = "A normal status.",
.characteristic = STATUS_NORMAL,
.prev = NULL
};
static Status ErrorStatus = {
.description = "An error status.",
.characteristic = STATUS_ERROR,
.prev = NULL
};
// --------------------------------------------------------
static Status NullPointerAccounted = {
.description = "An involving null pointer was not accepted.",
.characteristic = STATUS_ERROR,
.prev = &ErrorStatus
};
static Status InvalidParameter = {
.description = "An invalid parameter was presented.",
.characteristic = STATUS_ERROR,
.prev = &ErrorStatus
};
static Status InsufficientMemory = {
.description = "Not enough room for further memory allocations.",
.characteristic = STATUS_ERROR,
.prev = &ErrorStatus
};
static Status ArithmeticError = {
.description = "An arithmetic error occurred.",
.characteristic = STATUS_ERROR,
.prev = &ErrorStatus
};
#endif /* COMPOUND_STATUS_H */

30
Status/src/status.c Normal file
View File

@@ -0,0 +1,30 @@
#include <Compound/status.h>
bool status_issueposition_compare(Location lc1, Location lc2) {
return ((!strcmp(lc1.file, lc2.file)) && (lc1.line == lc2.line) &&
(!strcmp(lc1.func, lc2.func)));
}
bool status_hasprev(Status stat) { return (stat.prev != NULL); }
bool status_isnormal(Status stat) { return (!stat.characteristic); }
bool status_recursive(Status stat) {
return (stat.prev != NULL && stat.prev == &stat);
}
void status_dump(Status stat, Status *statbuff, int idx) {
if (statbuff == NULL || !status_hasprev(stat) || idx < 0) {
return;
}
statbuff[idx] = stat;
status_dump(*stat.prev, statbuff, ++idx);
}
bool status_compare(Status stat1, Status stat2) {
return (!strcmp(stat1.description, stat2.description) &&
(stat1.characteristic == stat2.characteristic) &&
(!status_compare(*stat1.prev, *stat2.prev)));
}

1
Var/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
obj/

19
Var/include/var.h Normal file
View File

@@ -0,0 +1,19 @@
#ifndef COMPOUND_VAR
# define COMPOUND_VAR
# include <stdio.h>
# include <stdlib.h>
# include <wchar.h>
# include <stdint.h>
# include <Compound/common.h>
typedef struct {
void *addr;
size_t sz;
} Var;
void var_swap(Var *v1, Var *v2);
int var_literalise(Var v, wchar_t **wbuff);
#endif /* COMPOUND_VAR */

17
Var/src/var.c Normal file
View File

@@ -0,0 +1,17 @@
#include <Compound/var.h>
void var_swap(Var *v1, Var *v2)
{
Var v3 = {
.addr = v1->addr,
.sz = v1->sz
};
*v1 = *v2;
*v2 = v3;
}
int var_literalise(Var v, wchar_t **wbuff)
{
return swprintf(*wbuff, (2*8 + 6), L"@[%p] +%u", v.addr, v.sz);
}

76
common.h Normal file
View File

@@ -0,0 +1,76 @@
#ifndef COMMON_H
# define COMMON_H
# include <stdlib.h>
# include <stdbool.h>
# define _buffer_definition_without_assignment(type, length) \
struct { type data[(length)]; const int len; }
# define Buffer(type, length, var) \
_buffer_definition_without_assignment(type, length) \
var = { .data = {}, .len = length }
# define Array(type, length, var) type var[(length)]
/**
* @brief Return $n as the return value, once $o is NULL
* @return given $n as the return value
* @note "fails" stands for "Fails on Null Check"
* @note 'o' stands for "Object"
* @note 'n' stands for "Numeric on Return"
*/
# define fails(o, n) {if ((o) == NULL) return (n);}
/**
* @brief Return $e as the return value, once $v equals $e
* @return given $e as the return value
* @note "trans" stands for "Transits Error Code to Caller"
* @note 'v' stands for "Value"
* @note 'e' stands for "Error Code"
*/
# define trans(v, e) {if ((v) == (e)) return (e);}
///**
// * @brief Evaluate given statement while the ptr to $s is not NULL
// * @return given $n as the return value
// * @note "state" stands for "Statement Evaluation"
// * @note 's' stands for "Statement"
// * @note 'n' stands for "Numeric on Return"
// */
//# define state(s, n) {if ((#s)) return (n);}
typedef enum {
COMMON_ERROR_NULLPTR = 1,
COMMON_ERROR_INVALID_ARGUMENT,
COMMON_ERROR_OUT_OF_MEMORY,
COMMON_ERROR_ARITHMETIC,
} CommonError;
typedef struct {
int x;
int y;
} Coordination;
typedef struct {
Coordination start;
Coordination end;
} Selection;
typedef struct {
void *addr;
size_t sz;
} MemoryInst;
typedef Coordination ArrayIndexerRange;
typedef bool _Bit;
# define WHICH_MIN(a, b)
# define INRANGE(lf, inclf, rt, incrt, v) \
(! ((lf > rt) || ((v <= lf && !inclf) || (v >= rt && !incrt))))
# define ATRANGE(lf, rt, v) \
(INRANGE(lf, true, rt, true, v)) ? 0 : ((v < lf) ? (v - lf) : (v - rt))
#endif /* NO COMMON_H */

36
install Executable file
View File

@@ -0,0 +1,36 @@
#!/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")
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" "$DST"
printf "\nDone\n"