Kevin Day [Wed, 23 Jun 2021 03:43:57 +0000 (22:43 -0500)]
Update: Restructure enum non-alphabetically and detect empty version for a specified version target.
If version_target is set to something, then that something should not be empty.
Detect this requirement.
In the case of the major/minor/micro/nano versioning, having the enum match the major/minor/micro/nano order makes more sense than alphabetical.
This then allows for using the enum as a relative position when detecting if one of these is required to not be empty.
Kevin Day [Wed, 23 Jun 2021 02:57:47 +0000 (21:57 -0500)]
Bugfix: Properly build version string.
The previous commit didn't properly to this.
When a version prefix is provided, the resulting name overwrites the string with the nano version at the wrong location in the string.
Kevin Day [Wed, 9 Jun 2021 02:01:29 +0000 (21:01 -0500)]
Progress: Incorrect linkage, not handling default values well, add version_nano, add version prefixes, and out of date documentation.
The documentation has version_target described as the target to build but the C source for Featureless Make is using it for the link file name.
Change this behavior to be consistent with the documentation.
Update all build settings to now be set to micro to be consistent with this change.
The default values should only be assigned if the Object is not provided at all.
This allows for the value to be set to empty (aka NULL).
The version_major, version_minor, and version_micro all are currently required to be defined and if empty will be set to 0.
Some projects use four versions and others like to add things like "-dev" or "-rc1".
Provide a way to do this by adding a version_nano as well as adding version prefixes.
For each version there is now a version_X_prefix such as version_major now has version_major_prefix.
For all version prefixes, except version_major_prefix, the prefix will be in place of the '.' in the version name.
The major version is an exception case as there is no value by default.
For example "1.2.3" would have version_major = "1", version_minor_prefix = ".", version_minor = "2", version_micro_prefix = "." version_micro = "3".
The default version continues to be a version_target of micro, such as "1.2.3".
The build settings documentation is out of date and needed some corrections to be made.
There is still more work to do in adding the prefixes and making the bootstrap.sh script and the fake program more consistent with the version numbers.
I simply ran out of time.
Kevin Day [Mon, 31 May 2021 22:43:44 +0000 (17:43 -0500)]
Update: Redesign FSS Identify to be more consistent with FSS Read and FSS Write programs.
This is not strictly required, but I believe making it as closely consistent with how FSS Read and FSS Write operate makes a lot of sense.
The FSS Identify and FSS Read/Write programs operate differently and not everything can be the same.
Summary of Redesign:
- The "name" and "type" are now renamed to "Object" and "Content".
- The parameter "-n/--name" is now "-o/--object".
- The parameter "-t/--type" is now "-c/--content".
- The parameter "-T/--total" is now "-t/--total".
- Add new parameter "-n/--name" that accepts a name to filter by (This selects an Object just like it does in FSS Read/Write).
- Add additional documentation to the "-h/--help" parameter message.
- The "-t/--total" parameter should could across all files and not the individual files/pipe (this provides a single total).
Kevin Day [Mon, 31 May 2021 05:02:58 +0000 (00:02 -0500)]
Update: Attempt to avoid libc/POSIX character array length limitations.
Define f_string_t_length to handle the special case max length.
Make the f_utf_string_t also operate in the same way (even it it might avoid the problem by being a different type than char).
The f_utf_string_t is changed in this way for consistency reasons.
Kevin Day [Mon, 31 May 2021 04:07:18 +0000 (23:07 -0500)]
Bugfix: FLL/FSS Identifier problems.
The strtol() function is being incorrectly used.
Redesign the code to accomodate the particular nature of that function.
Instead of doing math, just create a special structure that is friendly for strtol() and read str
The status is being incorrectly checked against F_false when the check should be against F_true (oops!).
Make sure the id->used is correctly calculated.
The calculation is truncating the name because the i variable is incremented in a start/stop range and not in a buffer used (start/stop ranges are inclusive and a buffer.used more akin to exclusive).
I forgot to allocate the FLL Identifiers array.
There are some cases where found_fss is not and should be tested for.
Kevin Day [Sun, 30 May 2021 18:09:51 +0000 (13:09 -0500)]
Progress: FLL/FSS related changes, populate more ASCII characters.
It occurred to me that I should follow the same practices as the FSS process where I use range for the FLL/FSS Identifier processing.
Change the behavior to do so.
It also occurred to me that I should try to avoid processing both a dynamic string's used as well as the range.
The FLL/FSS Identifier code only accepts a string for this reason.
It will likely be a good idea to change the other FSS code to accept a f_string_t instead of a f_string_static_t.
Add the initial support for FSS header processing with support for multiple FLL/FSS Identifiers.
Add and use the FSS specific default memory allocators.
Complete more of the hardcoded ASCII strings.
Unless I missed something, all that is left now is to consider adding the extended ASCII.
Kevin Day [Sun, 30 May 2021 03:22:45 +0000 (22:22 -0500)]
Update: Additional FLL Identifier changes along with type fixes.
I didn't like manually specifying the id.name[X] for all 64 X when clearing the f_fll_id_t.
Instead, take a minimalistic approach and set id.name[0] to NULL.
This is not a complete clear, but it is simple for use in macros.
Document that memset() should be used for a more complete/correct clear.
I completely forgot to implement the array and array of arrays support as is standard practice now.
While doing this I then noticed that the other type arrays and array of arrays were not fully migrated to having functions rather than be pure macros.
This further exposed some bugs being hidden by the macros.
There were some resize (or similar) macros that were using the wrong macro to initialize.
When macros were changed to expand to a function, this exposed that the wrong types were being used and there is a likelihood of incorrect allocations or deallocations.
Things may have previously worked due to the sizes potentially being coincidentally identical.
There is also a bug where some macros expanded the *_increase_by() macro to a *_increase() function.
These should instead expand to an appropriate *_increase_by() function.
Kevin Day [Sat, 29 May 2021 23:12:21 +0000 (18:12 -0500)]
Revert: Partially revert unsigned to signed change in "Bugfix: Compilation/Portability problems exposed when building against musl-libc.".
There were problems with the console parameter size, so switching that to signed seems fine.
However, switching the more general standard approach from unsigned to signed is more dangerous.
Signed operations are much more fickle when overflowing or when using bitwise operations.
In fact, the C standards leave a lot of this behavior as undefined.
Much of the logic used in operating and manipulating array lengths (as counters or with bitwise operations such as << or >>) is affected by the previous change from signed to unsigned.
Avoid these signed problems by reverting this behavario.
The console parameter length will remain as a signed.
Kevin Day [Sat, 29 May 2021 23:00:02 +0000 (18:00 -0500)]
Feature: Provide and implement f_fll_id_t and fl_string_fll_identify().
The Featureless Settings Specification identifiers are a decent format.
Make a more generalized structure for processing these for the entire project and not just FSS.
Kevin Day [Sat, 29 May 2021 16:29:49 +0000 (11:29 -0500)]
Feature: Allow controller program to run as a non-init (and then do so by default).
The controller program is written more generally.
Take one step further and make the default to run generally.
Then provide the option to operate as an init program.
This frees up the controller program's default behavior to just be a "controller" rather than an "init controller".
Furthermore, provide options to change easily override the "init controller" paths at compile time without redefining all of the other defines in the "_di_controller_defines_" block.
Kevin Day [Wed, 26 May 2021 02:42:46 +0000 (21:42 -0500)]
Update: Rewrite the enabled/disabled logic for the install.sh script.
The --disable-shared/--disable-static should override --enable-shared-program/--enable-static-program (and similar).
Apply build_shared and build_static if and only if shared/static parameters are not specified.
Fix minor bug where wrong string is printed when an error is supposed to be printed.
The code is printing $build_shared when it should be printing $path_shared.
The code is printing 'library' in cases that should print 'program'.
$build_shared and $build_static no longer need to be directly tested for.
This testing happens when checking and guaranteeing the individual program/library shared/static state.
Kevin Day [Wed, 26 May 2021 01:45:00 +0000 (20:45 -0500)]
Feature: The install.sh script should support disabling installation of headers.
If any headers exist, there still may be a desire to not install headers.
One such example is separately install static files to one location and shared to another using separate calls.
The headers may also be installed in only one of those or another separate call.
Kevin Day [Tue, 25 May 2021 23:27:30 +0000 (18:27 -0500)]
Feature: Add Unicode to/from UTF-8 translations and fix usage of function that should be private.
This logic has not actually been tested yet.
This needs to be reviewed for endianess correctness.
All of the UTF-8 processing code, in fact, needs to be reviewed for endianess so I decided to not test this further until I can review and correct the big vs little endianness support.
Kevin Day [Thu, 20 May 2021 02:39:45 +0000 (21:39 -0500)]
Regression: "fake skeleton" no longer works due to "file not found".
ERROR: Unable to create file 'data/build/defines', could not find file.
This error message is a bit nonsensical because it is supposed to create a file if it does not exist.
This is a regression in that at some point f_file_is() started returning F_file_found_not with error bit set and the skeleton program is only expecting F_file_found_not without the error bit set.
Make the test error-bit neutral.
Kevin Day [Wed, 19 May 2021 03:48:26 +0000 (22:48 -0500)]
Progress: Interrupt and memory allocation related changes.
I've noticed that when processing large files, the FSS programs cannot be interrupted using controlled interrupts rather than the standard interrupt signals.
The POSIX standard structure of interrupts, particularly in threads, is very poorly defined.
When a threaded program wishes to be triggered for an exit, the pthread_cancel() function works by immediately exiting the program rather than aborting.
This prevents proper deallocated and shutting down of programs, particularly those that handle interrupts.
This introduces a new f_state_t structure that allows passing a generalized state around that accepts (void *) arguments so that it is not tied to any particular implementation beyond the basic structure.
The FLL/FSS and IKI processing functions then take advantage of this and utilize the state.
There are performance concerns with this, but the need to have controlled interrupts is deemed far more important.
Furthermore, the generic function is open ended so that the caller can potentially implement some sort of optimization.
Now that an f_state_t structure exists I am finally compelled to move the allocation step functionality into this structure.
This will allow for more performance improvements (such as determining allocation step according to file size).
For large files (megabytes, gigabytes, etc..) the allocation step can be set to something large, such as 16384.
Doing so should reduce the amount of memory I/O needed for resize operations.
I have opted to use uint16_t, so there is a max step of 64k at this time.
This entire process needs additional reviewing before releasing.
I designed this with the intent to move the function parameters into the (void *) data property on the f_state_t structure.
This will allow for reducing the parameters passed.
This design will also allow for me to later on add additional state information that can be passed to the caller.
This also allows for better or more granular error handling and reporting.
More work is needed in this regard because many of the functions currently written need to utilize this (such as the recursive directory functions).
This focuses on the most basic utilization in the programs but I would like to perform file size tests so that I can at least have a very basic heuristic for determining the default allocation size for large (or small) files.
A new project fl_signal is provided with a basic interrupt callback for f_state_t as I believe a dirt simple callback will be commonly used.
The default allocation step is now broken up into large and small allocation steps.
Kevin Day [Tue, 11 May 2021 23:11:59 +0000 (18:11 -0500)]
Feature: The install.sh should helper script should allow more granular installations between shared and static.
Add new parameters "--disable-shared-programs", "--disable-shared-libraries", "--disable-static-programs", and "--disable-static-libraries".
These parameters will enable/disable shared/static libraries/programs.
Both shared and static may be compiled and this allows for choosing to install which of those to install.
Kevin Day [Sat, 8 May 2021 01:11:19 +0000 (20:11 -0500)]
Feature: Add support for determining columns in FSS Read programs.
Implement a new feature for determining how many columns total are available for some Content.
Update the specifications accordingly.
The term "columns" has been added to designate this concept of the now of column sets within some Content.
Previously, this was weakly named.
The select functionality "--select" allows for selecting these columns but there has been no way to know how many columns exist.
This is not a good design for scripting and similar usage.
By providing a total number of columns, the select function becomes more complete and useful.
When columns is specified without any particular Object specified, then the maximum columns length for all Content is printed.
Kevin Day [Fri, 7 May 2021 22:11:00 +0000 (17:11 -0500)]
Bugfix: The install.sh should allow for -w to be used when destination_prefix is invalid.
While buildin a system from scratch, the default destination does not exist.
This exposed a bug where the script complains about the destination directory even when the destination directory is not to be used (because the work directory is being used).
Kevin Day [Fri, 7 May 2021 05:22:33 +0000 (00:22 -0500)]
Update: Provide defines for disabling less-portable code exposed as a problem when using musl-libc.
The f_thread project utilizes several pthread functions that are non-portable.
Add some initial support for disabling these and do disable these by default.
I intend to expand upon this and adding more defines.
The current ones might be renamed.
Kevin Day [Fri, 7 May 2021 04:33:08 +0000 (23:33 -0500)]
Bugfix: Compilation/Portability problems exposed when building against musl-libc.
Some headers are missing.
Change the length types: f_console_parameter_size and f_array_length_t.
I have seen problems where the max allowed size is reached in f_array_length_t.
Compiling against musl-libc further exposes this problem and so I have reduced the practice to using a set length of 2^63 (aka: signed long).
Kevin Day [Fri, 7 May 2021 00:12:32 +0000 (19:12 -0500)]
Bugfix: Fix problems revealed when working on FSS Extended List Read.
Be sure to explicitly check data->objects.used is non-zero when counting total.
The Basic List and Extended List Object names, when being selected (via the --select parameter), should be trimmed by default.
This is because the Basic List nd Extended List standards define an Object name as beginning after on the first non-whitespace and ending at the last non-whitespace.
Minor syntax cleanups such as replaced "if (X > 0)" with "if (X)".
Kevin Day [Fri, 7 May 2021 00:09:32 +0000 (19:09 -0500)]
Security: FSS Read functions should check range before buffer.
The range may have exceeded the buffer or the stop point.
There is a string test that happens before this is checked.
If this string is checked with an out of range address, then a segfault could occur.
Kevin Day [Thu, 6 May 2021 22:40:43 +0000 (17:40 -0500)]
Bugfix: FSS Extended List is not detecting end properly.
If the content is something like:
example {
}
There is no Content.
This is not being detected correctly an the '}' is being included.
There are two problems here:
1) The current position at the end should be after the eol and not that last newline.
2) If the current position matches the start position, then it needs to be explicitly designated as empty.
Kevin Day [Thu, 6 May 2021 01:09:43 +0000 (20:09 -0500)]
Bugfix: FSS Basic Read and FSS Basic List Read problems and cleanups.
The delimit is not being calculated correctly.
The fss_basic_read_load() and fss_basic_list_read_load functions are out of place.
The parameter order for some functions like fss_basic_read_print_at() are not adhering to the ordering practices (constants on the left).
The total is not consistently being counted.
The FSS Basic Read is not taking into consideration when Content is empty and --object is or is not selected for some line specific processing.
When there is only --content, then whether or not Content is empty matters.
When there is --object (or both --object and --content), then whether or not Content is empty does not matter because Object is already taking up a given line.
Kevin Day [Wed, 5 May 2021 05:24:12 +0000 (00:24 -0500)]
Cleanup: Use number instead of word in FSS Basic Read help.
While committing the FSS Basic List changes to be in sync with this, I noticed that I had "..start at 0 instead of one..".
This is inconsistent.
I either need to use both words ("zero" and "one") or both numbers ("0" and "1").
I opted to use the numbers.
Kevin Day [Wed, 5 May 2021 05:13:35 +0000 (00:13 -0500)]
Update: Improvements and tweaks in FSS Basic Read.
Add additional help information.
Cleanup comments.
In some cases the total printing is inverted by accident.
The print_object function pointer doesn't really need to exist anymore.
Add missing print for when both total and line parameters are specified.
Kevin Day [Wed, 5 May 2021 05:00:40 +0000 (00:00 -0500)]
Bugfix: UTF-8 characters buffer is incorrectly returning an error.
The previous commit: "Bugfix: UTF-8 characters are not being fully printed" exposed that for UTF-8 characters (width 2 or greater), an error is always returned.
When the width properly fits in the requested range, return the appropriate success code instead of an error.
The previous implementation is weak in that there is no good way to just delimit Object or just delimit Content.
Redesign to allow for specifying the delimit parameter multiple times and therefore allow for customizing what to specify.
Rename "depth" to "content" in the delimit enum to better communicate that this is for "content" delimiting.
Examples:
- "fss_basic_read --delimit object": Results in delimited Objects but not Content.
- "fss_basic_read --delimit 0+": Results in delimited Content (position 0 and greater) but not Objects.
- "fss_basic_read --delimit object --delimit 1-": Results in delimited Objects and delimit Content (position 1 or less).
For this standard, there is no delimit support in Content so the use of the numeric range is superfluous.
Having this functionality, however, makes it consistent with the rest of the FSS Read programs.
Kevin Day [Mon, 3 May 2021 02:51:54 +0000 (21:51 -0500)]
Regression: FSS Basic read --select is always returning empty sting or 0.
After changing the code structure, the check to see if the select number is non-zero was lost.
As a result the code is always operating as if the select number is non-zero.
When the select number is zero, all existing operations should continue.
I seem to have forgotten to wrap these macro checks in parenthesis.
As a result something like "!macro_f_file_type_is_block()" would expand to "!macro_f_file_type_get(mode) == f_file_type_block".
What it should expand to should be logically equivalent to "macro_f_file_type_get(mode) != f_file_type_block".
The expansion with the parenthesis would be: "!(macro_f_file_type_get(mode) == f_file_type_block)" and that is indeed logically equivalent.
Kevin Day [Mon, 3 May 2021 02:10:40 +0000 (21:10 -0500)]
Cleanup: Disable parenthesis warning in GCC.
This is another case where the compiler is overstepping itself.
The programmer should understand the language and the order of operations.
Disable the warning by passing -Wno-parentheses.
(The warning only appears if -Wall is given, but if -Wall is passed then -Wno-parentheses should be already in place.)
Kevin Day [Mon, 3 May 2021 02:07:21 +0000 (21:07 -0500)]
Cleanup: Sloppy use of "main" inside of "main()", oops.
I cannot believe I let this one slip through (and so did the compilers).
When I refactored "data" to be "main" this included the refactor in the function called "main".
This is dangerous at worst and at best bad practice.
Given that "data" is no longer to be used in the main(), just rename the uses of "main" back to "data" for the variable name only (not the typedef structure name).
Kevin Day [Mon, 3 May 2021 01:53:48 +0000 (20:53 -0500)]
Cleanup: FSS Basic Read parameter processing, file variable related, and some ++/--.
Simplify the parameter processing using an array to avoid repeating similar code.
Relocate the file variable so that it goes out of scope and is removed from the stack before processing.
The file variable is no longer needed during processing with the current design so don't hold it in memory after it is no longer needed.
Relocate the file stream close so that it doesn't need to be specified as many times in the code.
There are some ++/-- postfixes in use that would be better as prefixes (such as changing i++ to ++i).
Kevin Day [Sun, 2 May 2021 22:09:43 +0000 (17:09 -0500)]
Update: Implement data structure in FSS Read.
This is the designated follow up commit for resolving the need for a "data" structure.
The parameters are now extracted into a bitwise "option" property on the "data" structure.
The process is now broken up into multiple functions.
Kevin Day [Sun, 2 May 2021 05:12:42 +0000 (00:12 -0500)]
Update: Remove the "amount" from file stream functions.
The "amount" is present to support the parameters that fread() and fwrite() utilize.
This makes no sense to me and it is annoying and confusing.
I end up having to just put 1.
Get rid of it and just use the file.size_read and file.size_write to specify the buffer size to read/write.
The only things that I can thing of might be atomic operations, locking, and calling the function multiple times.
These are good reasons to have an "amount".
If I end up wanting o needing an "amount", I may add additional functions later on.
Kevin Day [Sat, 1 May 2021 22:31:49 +0000 (17:31 -0500)]
Cleanup: Always have private-common.h and private-common.c for programs.
I am now introducing a new standard practice of always having a private-common.h and private-common.c for programs.
The private data types shared across the program will be stored in these.
These will also provide any functions for allocating, deallocating, or otherwise managing those private structures.
This makes no effort to move over or implement any of the allocation/deallocation functions.
Individual programs will be updated on an as able basis to address this.
The Controller program already has this but it has a bit more than this practice.
The Controller program will see some structural cleanup in the future.
Kevin Day [Sat, 1 May 2021 22:00:27 +0000 (17:00 -0500)]
Refactor: Relocate 'macro' prefix in names for macros.
Placing 'macro' after the project name, such as 'fll_' or 'fake_', is a good idea for keeping the function names consistent and contained within the project naming structure.
For short names like 'f_' and 'f_string_t' this is not a problem.
For complex and usually longer names, such as 'fake_' and 'fake_main_t', this becomes confusing quickly,
I have decided to favor the less consistent macro as a prefix to the project name, to make the code a bit more readable.
For example: 'fake_main_macro_delete' would become 'macro_fake_main_delete".
Kevin Day [Sat, 1 May 2021 21:46:35 +0000 (16:46 -0500)]
Refactor: Use 'main' instead of 'data'.
The original goal of 'data' is to be used as the main store of data for the program.
A program using the programs as a library are also expected to get and use this structure.
The problem is that the programs are designed such that the caller to the program (as a library) should not have access to internal details.
Refactor 'data' to 'main'.
This is a more precise name in that it is the structure passed as if it were called from 'main(argc, argv)'.
This also frees up 'data' for internal use such that 'data' can now be the more generalized 'data' without exposing anything to 'main'.
The Controller program is already using 'main', so that 'main' was refactored to 'global'.
There are still more changes to do, such as restructuring the 'main' types to ensure nothing unwanted is exposed to a caller.
These additional changes, however, are beyond this scope of this commit.
Kevin Day [Sat, 1 May 2021 19:46:21 +0000 (14:46 -0500)]
Bugfix: Several of the parameters are not handling the desired set of possible combinations.
With recent changes, more parameters may be used together than before.
This exposed how several combinations simply did nothing or did not do what was expected.
Redesign and even simplify the code to allow these parameters to work together.
Some of the code is abstracted out into their own functions.
There is a goal to have a data structure for passing setting, but before that is done I want to make other significant changes FLL-wide.
For this reason, I am putting in place a temporary 'print_this' bitwise variable.
Kevin Day [Sat, 1 May 2021 16:23:56 +0000 (11:23 -0500)]
Update: Redesign Basic List loading logic to load all files into a single buffer.
Upon further use and review I believe that it is better to treat all input sources as a single buffer.
This allows for all of the parameters to work closer to what feels like normal logic.
If I want to get the total lines for all listed files, then I should get that.
If I want to get the total lines for each listed file, then I can call this program once for each file to get that.
I am working on Basic List first but this will be repeated for all of the other FSS read projects as well (likely in a single commit).
One of the downsides of this is that it exposes a current design limitation where the max buffer size is more likely to be reached.
Future work will most likely address this in some manner.
Kevin Day [Sat, 1 May 2021 03:46:02 +0000 (22:46 -0500)]
Regression: Incorrect char type resulted in SIGPIPE.
The uint8_t/int8_t was changed into char recently.
This change appears to have be incomplete for the Byte Dump program.
Update the code to be aware of PIPE by passing a NULL string to represent a PIPE instead of a file.
While fixing this, go ahead and replace read() with fgetc().
This is more efficient due to the use of a file stream.
The use of read() is originally done for testing some of the lower-level FLL design.
This testing is no longer necessary so it is worth switching to fgetc().
Future design may merit reading larger chunks than 1 character at a time.
The use of fseek() is now available and in use (for non-PIPEs).
Kevin Day [Wed, 28 Apr 2021 23:57:36 +0000 (18:57 -0500)]
Update: Replace static strings with extern defined in common file.
This makes the controller program more consistent with the FLL projects.
This should make it easier to use the controller program as a library as well.
Kevin Day [Wed, 28 Apr 2021 23:08:29 +0000 (18:08 -0500)]
Update: Fix problems and make changes after testing LLVM's Clang compiler.
Add flags "-Wno-logical-not-parentheses" "-Wno-logical-op-parentheses".
Programmers should be expected to understand the language they are working.
Having the compiler for a style is bad practice.
The cap_to_text() needs ssize_t, do not use f_array_length_t.
The project is inconsistently using int8_t and uint8_t for character types.
Furthermore, clang likes to complain about uint8_t being converted to char.
(I believe uint8_t is supposed to be of type unsigned char and char by default is supposed to be unsigned.)
Fix the inconsistency and just use char, which happens to make clang happy without any complaints from gcc.
Clang does a much better job at detecting some problems than GCC.
Compiling with clang resulted in revealing several printf related problems that now should be fixed.
The f_gcc_attribute_visibility_internal (and related) have the "_gcc" removed because these seem to exist beyond just gcc (such as with clang).
Make sure something is always returned.
There are some functions that didn't have a return.
One of the UTF processing functions has an accidental hex character in the condition.
Remove the extra character, which I am pretty sure is the leading "d".
I have not validated the correct sequence and so further investigation in the proper sequence for U+1D7CE to U+1D7D7 may be warranted.
The clang compiler claims that int main() should only be an integer for the argc.
This is unfortunate but that is fine, switch to use an int instead of an unsigned long.
Kevin Day [Tue, 27 Apr 2021 23:49:35 +0000 (18:49 -0500)]
Bugfix: PID and PID file should account for multiples during process execution.
I forgot all about needing to do this so I am considering this a bug.
Each process may execute multiple Actions.
Each Action has its own PID.
In the case of foreground (synchronous) execution, having only a single PID and PID file path on the Process structure is not a problem.
When with PID file (asynchronous) execution operates, multiple PIDs (and respective PID files) may exist for any single Process structure.
Kevin Day [Tue, 27 Apr 2021 04:09:09 +0000 (23:09 -0500)]
Regression: Entry error after failure or during validation is not propogating.
When an Entry fails and successfully executes a failsafe, the failure is not propagated.
The failsafe is meant to bail out and not continue onward, so after a successful or failed failsafe, return F_failure (with error bit as appropriate).
When passing --validate without --test, the program is not exiting as it should.
This is because the state is not being handled just like the status is not being handled.
When joining threads, be sure to reset the identifiers.
Remove now extra Exit processing block.
This is now handled fully by the cancellation function.
Restore the thread enabled state after operating failsafe.
Get rid of simulate variable, instead use the console parameter directly.
This saves memory by a trivial amount.
Kevin Day [Mon, 26 Apr 2021 23:45:23 +0000 (18:45 -0500)]
Update: Implement "execute" support and fix bugs.
Provide new feature for executing into another program.
This is provided via the new Item Action "execute".
The function controller_perform_ready() is being called and the status is being checked but the status is not being assigned.
There are a few cases where thread.enabled needs to be checked and a few cases it does not need to be checked.
Several of the threads need to be aware of the normal/other status to properly determine the thread.eneabled situation.
Without this, they make incorrect decisions that result in bugs.
I did not want to implement a new structure to resolve this so instead provide custom wrapper functions to call that set the appropriate normal/other state.
The functon controller_thread_process_cancel() now needs to be caller aware so that the caller does not get cancelled.
Kevin Day [Sun, 25 Apr 2021 17:13:54 +0000 (12:13 -0500)]
Update: Improve entry/exit verbose messages, display exit with -tv, and wait all with read lock fix.
The verbose messages should be distinguishing between an entry and an exit now.
When both --simulate and --test are specified, the printout should include both the entry and the exit.
Previously, only the entry was printed.
The wait all should only be triggered to wait for all processes at the current moment in time.
Furthermore, the read lock is being held too long (for the entire loop).
Maintain the read lock long enough to build a list of all processes to wait for.
Kevin Day [Fri, 23 Apr 2021 01:49:21 +0000 (20:49 -0500)]
Progress: redesign processing logic to accommodate different process Rule Actions and update dependency design accordingly.
When I implemented the "exit" support (opposite of an "entry") I noticed a oversight in the design whereas there was no way to distinguish between a process that successfully started via the "entry" or the "exit".
Change the design to now utilize unique Rule Processes for each Rule Action requested.
This required further changes to the status handling.
A rule status is now an array of all possible Rule Actions.
This is utilized using a static array for simplicity purposes (there is no need for a dynamic array here).
All of the recent changes introduced a lot more complex code.
There are now helper functions to help facility common tasks.
This should also make updating easier as there is only one place to update.
The downside is the introduction of an additional function call (which is a tiny runtime cost).
To facility this new design, the Rule files must also be aware of the different Rule Actions.
The "need", "want", and "wish" have been relocated into a new Rule Action called "on".
Additional parameters for an "on" allow for describing the Rule Action in which the dependency applies to.
This allows, for example, a "stop" Action to operate in a different order than a "start" Action.
An example of this is provided.
Look at the data/settings/example/rules/serial/*.rule files.
An example syntax is:
on start need serial s_1
on stop need serial s_3
When validate is passed, do not wait for asynchronous processes because they are not run.
Normally this is not noticeable but is exposed when 'script/fail' failed to execute and return ('script/fail' should execute, fail, and return).
This bug is caused by the wait functions not checking to see if the caller is the same as the current process (it was waiting for itself).
This may have been introduced as a result of the redesign.
Kevin Day [Wed, 21 Apr 2021 22:12:00 +0000 (17:12 -0500)]
Progress: Redesign enty/exit rule handling, now requiring Action instead of "rule".
The Entry and Exit files are using "rule" to designate a Rule to operate.
This is designed on the assumption that an Entry always runs a "start" and Exit always runs a "stop".
This behavior is changed such that "rule" is no longer specified and one of the 9 supported Actions may be used.
Such as "start" or "stop", for example.
There is still more work to do as this change doesn't fix the Exit in terms of dependency handling.
Currently, the process structure does not distinguish the Rule action, such as "start" or "stop".
Additional changes to the process structure are needed.
Kevin Day [Tue, 20 Apr 2021 23:16:45 +0000 (18:16 -0500)]
Progress: controller program, add exit support.
This implements the initial work needed to get exit files working.
A new thread is added to handle both "entry" and "exit" to free up the "rule" thread and allow for the "exit" to start will the "rule" thread exists.
The thread enabled process is now more complex given that there needs to be stages so that "exit" threads can work while "entry" or "control" operations begin terminating.
Add several helper functions to help simplify the detection.
Add an "alert" lock to send/receive alerts.
This is a more general purpose lock that tells something waiting on the alert to wake up and see if anything you care about changed.
The file loading now needs to be aware of "optional" files, namely the exit files.
If the named exit file does not exist, then do not care as it is not required (unlike entry and rule files).
Many of the read and write locks are now timed so that they can check to see if the controller is enabled or not.
While working on this I noticed some oversights and things that I did not previously consider.
I need to follow this up with a redesign in the entry/exit rule handling.
Instead of "rule", I should have the rule actions like "start" and "stop".
There needs to be support for default behaviors, such as allow for "stop" to not have a parameter and to correctly find and terminate a service.
There needs to be consideration on dependencies when exiting, perhaps there needs to be an exit-specific dependency management.