Kevin Day [Tue, 23 Jan 2024 03:42:07 +0000 (21:42 -0600)]
Progress: Add "works" unit test for basic object read and basic content read.
My goal is to get to writing the payload tests but getting these other unit tests figured out first will make that process easier.
These "works" unit tests are intended to be very simple at this time.
There are no checks for comments.
The NULL data is not checked, partially due to the use of getline() and string comparison.
This also adds the beginnings of unit tests for the fl_fss project, specifically for the fl_fss_payload_header_map() function.
The tests for fl_fss_payload_header_map() will be rather complex and so I will likely break the tests for fl_fss_payload_header_map() into multiple files.
Kevin Day [Fri, 19 Jan 2024 03:08:51 +0000 (21:08 -0600)]
Cleanup: Invalid environment define "CMOCKA_TEST_ABORT" in testfiles.
This invalid configuration doesn't break anything unless someone uncomments it.
Then, the expected functionality does not happen.
The fix is easy, just add "define " at the start of that line to the right of the comment character.
Kevin Day [Thu, 18 Jan 2024 02:49:00 +0000 (20:49 -0600)]
Bugfix: Function private_fl_fss_basic_write() is missing "const".
The function implementations for private_fl_fss_basic_write() is missing the "const" type attribute in some parameters.
The declaration of these has the "const" type attribute as expected.
I did a lot of cleaning up and reorganization.
This adds a several flags that I intended to use but the current state of these is highly subject to change.
There are still a lot of incomplete changes, especially regarding existing code and the newly added flags.
Kevin Day [Tue, 16 Jan 2024 14:22:03 +0000 (08:22 -0600)]
Feature: Add f_string_dynamic_strip_null() and f_string_dynamic_strip_null_range().
The ability to strip out NULLs from a given string as a common function is needed.
Provide two similar but different functions.
The f_string_dynamic_strip_null() moves the NULLs to the end of the string and the shrinks the string used length as appropriate.
The f_string_dynamic_strip_null_range() shifts all of the NULLs found to the end of the given range without modifying the array used length.
Unit tests are added.
Only basic logic is applied and so there is no especially focused optimization in the parsing logic.
Kevin Day [Mon, 15 Jan 2024 18:34:10 +0000 (12:34 -0600)]
Refactor: The backtick into the grave.
Both the Unicode standard uses the word "grave" rather than the word "backtick" to commonly refer to the U+0060 character.
Change the use of the word from backtick to the word grave throughout the project.
This is a breaking change for the relevant programs, such as fss_write and iki_write.
Documentation, such as the website documentation and specifications, will need to be updated following this change.
Kevin Day [Mon, 15 Jan 2024 03:18:46 +0000 (21:18 -0600)]
Progress: Make control program at least compile.
I just did some quick tests and getting the control program to compile is just this simple change.
I believe there are still several programs, like the control program, that still need to be migrated from the 0.6 style to the 0.7 style.
Kevin Day [Mon, 15 Jan 2024 03:13:47 +0000 (21:13 -0600)]
Update: Switch to using the common format string structure where possible.
There may be other cases, but these are the ones I was able to quickly find.
After glancing over this I would also note that the common parameter argument printing could also be made common strings.
These would be common strings that are specific to something like fll_program.
Kevin Day [Sun, 31 Dec 2023 02:33:20 +0000 (20:33 -0600)]
Update: Explicitly cast UTF conversion to/from and simple packet bit operations to a uint32_t.
If the type is changed or the defines are used with different types, then the shift operators may become problematic.
Prevent this potential problem from happening through explicit casts to uint32_t.
Kevin Day [Sat, 16 Dec 2023 01:37:50 +0000 (19:37 -0600)]
Bugfix: Fix incorrect wording regarding negative times and add some clarification regarding defaults.
The time specification is mistakenly using the word "after" when it should be the word "before" for the example "2022:-5".
I decided that I needed to better clarify what I meant by default and not make it sound so strict.
Add additional language to better communicate that when the year is not specified, it is not specified.
There is no required interpretation and a default is simply a recommendation.
I am going to start trying to establish a habit of using UTC for my timestamps.
My local time zone, the date of the specification is still the 15 of December, 2023.
However, to stick with UTC for records purpose I need to the start doing this now.
There may be occasional inconsistencies for a while until I establish the habit of using UTC.
Kevin Day [Thu, 14 Dec 2023 02:27:54 +0000 (20:27 -0600)]
Refactor: The fss extract functions to be fss decode functions.
The commit 4713c80244fe1bc00da097eb27987e77c98601f0 introduced f_fss_simple_packet_encode().
Rename the f_fss_simple_packet_extract() and similar functions to f_fss_simple_packet_decode().
This makes the language more consistent between the two different functions.
Kevin Day [Tue, 12 Dec 2023 02:18:03 +0000 (20:18 -0600)]
Update: Strip NULLs from the payload number converters.
Add logic to strip the NULLs from the numbers.
The FSS functions use NULLs to reduce reallocations but the payload sends everything.
Don't introduce unexpected NULLs when writing the numbers.
I need to review the logic for any mistakes which I find is often best after sleeping on it.
Even better, I should write some unit tests to expose any potential logic flaws more easily.
Kevin Day [Mon, 11 Dec 2023 06:26:27 +0000 (00:26 -0600)]
Update: Socket size_read/size_write checks, result == -1, and explicit passing .generic.
Make sure size_read and size_write are not 0.
If either is 0, then return F_data_not.
Make sure the result checks are "== -1" rather than "< 0".
Explicitly pass .generic for the address union.
This probably isn't necessary but being explicit seems safer.
The memory address of the address union, regardless of the union type being used, is cast to 'struct sockaddr' in most cases.
This makes the use of ".generic" very practical.
Add documentation comment about F_pipe being returned.
Problems with the address unions ".sin_family" must be set or unclear F_pipe errors are returned.
I may in a future commit perform this assignment during setup because the "form" parameter makes this practical and reasonable to do.
Kevin Day [Fri, 8 Dec 2023 04:46:53 +0000 (22:46 -0600)]
Update: Re-design f_socket to better support handling of different struct sockaddr types.
The networking types are already in use, such as address family (AF_*) and protocol family (PF_*).
The known and supported socket address structures (struct sockaddr) do not directly relate to either.
Create a new enumeration that directly maps to these socket address structures (struct sockaddr), called an address form.
A 16-bit integer is hopefully more than is ever needed for this.
Rewrite f_socket_bind() and f_socket_connect() to use the socket.form enumeration.
The custom *_inet4(), *_inet6(), and *_local() functions are removed.
Add a generic, or fallback aka failsafe, type for handling the most basic socket address tructure (struct sockaddr).
Kevin Day [Fri, 8 Dec 2023 02:28:02 +0000 (20:28 -0600)]
Update: The fss-000e (Payload) specification should allow for the "payload" Section to be optional.
In cases where packets that are being sent only need to send the "header", then it makes sense to not have a "payload" Section.
This should help reduce network traffic by avoiding the extra "payload:\n" characters when the payload Section is to be ignored.
Add additional tests.
Fix bad test data, such as where the string lengths are incorrect.
Perform tests when "where" parameter both is NULL or is a valid pointer.
The tests now handle validating the "where" parameter, when specified.
Add additional comments to better communicate the logic in f_network_is_ip_address().
Properly handle the "where" parameter assignment.
Kevin Day [Mon, 4 Dec 2023 04:13:06 +0000 (22:13 -0600)]
Update: Unit tests for f_network().
The commit 309f2625e983ef164c52543b492365fe92eed6d5 did not update the unit tests.
The tests currently do not pass due to a regression that will be addressed in a follow up commit.
The referenced commit was rushed so that I could get to the f_string_range_t and related migration.
I didn't bother to review the code or run the unit tests.
I will now have to follow up with a more extensive review and fix any problems.
The unit tests need to also be updated to handle all of the new behavior of the changed function.
Kevin Day [Mon, 4 Dec 2023 01:50:55 +0000 (19:50 -0600)]
Update: The f_network_is_ip_address() to use f_string_range_double_t (soon to be f_range_double_t).
This allows for getting both the address and port range positions.
The POSIX/libc functions do not support the bracket notation in an IPV6 address.
The string detected by this must then have the brackets filtered out.
This new structure allows for saving the range.
I did a quick run-through write-up of the logic for these changes but I have not spent any time reviewing or testing the logic.
Hopefully there are not logic bugs or mistakes.
Kevin Day [Mon, 4 Dec 2023 01:43:11 +0000 (19:43 -0600)]
Feature: Add f_string_range_double_t, updating build settings and unit tests appropriately.
I need a string range structure that has two ranges for some given string for the network related code.
The unit tests are updated or added as appropriate.
Any bugs discovered in the related unit tests are fixed.
The build data is rebuilt.
I originally wrote f_string_range_t to be specific to strings.
I now think that this needs to be conceptually more generalized.
The purpose of such a generalization is to simplify the code logic and design.
Renaming f_string_range_t to f_range_t and now renaming f_string_range_double_t into f_range_double_t is the intended change.
This would then be moved out of the f_string project and into the f_type project.
This is too much to do in the scope of this commit.
Instead, the f_string_range_double_t is being added under f_string_range_double_t.
I will then follow up this commit with a refactor of the f_string_range_t and f_string_range_double_t.
Kevin Day [Thu, 30 Nov 2023 03:01:02 +0000 (21:01 -0600)]
Bugfix: f_network_from_ip_string() and f_network_to_ip_string() design problems.
Change the inet_pton() and inet_ntop() function calls to use the explicit .v4 and .v6 union members.
Being explicit is much safer.
The inet_pton() function also returns zero without the errno set when the address is invalid.
Handle this case, returning F_address_not (with error bit) when zero is returned by inet_pton().
The unit tests for these functions are incorrect and are not all called (which is why their incorrectness was not previously discovered).
Make sure to use h_errno where appropriate.
Make sure the mock function for inet_pton() allows for returning zero or non-zero.
Make sure the family type is set so that the expected return codes are returned.
Make sure the ip string is set so that the expected return codes are returned.
Handle the newly added F_address_not case.
Add the missing unit test function calls:
- test__f_network_from_ip_address__fails
- test__f_network_from_ip_name__fails
- test__f_network_from_ip_string__fails
- test__f_network_to_ip_string__fails
This could use more review and testing.
Such extra review will be performed while I continue to write TacocaT.
Kevin Day [Thu, 30 Nov 2023 02:57:43 +0000 (20:57 -0600)]
Bugfix: f_socket_connect() should require non-negative socket.id.
I seem to have this one backwards.
The socket.id must be something other than -1.
If the socket.id is -1, then just return F_file_descriptor without error bit to designate that no descriptor is available to connect with.
Kevin Day [Tue, 14 Nov 2023 23:56:43 +0000 (17:56 -0600)]
Update: Specifications for Payload and Simple Packet.
Add "type" as a recommended Object in the header section for the Payload.
Change the size units being used in Simple Packet.
The numbers used in some areas are completely wrong 2^4 is not 32-bits.
Instead use the word "bytes" or "bits" and update the units.
The Payload Block Structure uses "bytes" rather than bits as that is the general focus of that section.
All others use "bits".
Kevin Day [Wed, 1 Nov 2023 02:58:58 +0000 (21:58 -0500)]
Progress: Resume working on custom payload functions.
I'm getting more back into things and this is a small step towards pickup up where I left off.
There are several todos that I will consider and either implement or not.
This performs the work that I mentioned in the previous commit in regards to redesigning the approach in fl_fss_payload_header_write() (now called fl_fss_payload_header_map()).
I started doing some re-designing to improve the approach and prepare for signatures/checksums.
I realized somewhere during that process that I wanted to eventually control or even randomize the header order for integrity, organization, or security reasons.
The current approach makes that impractical.
I decided to save the current state so that I can then pivot to a better approach that will accommodate the above needs.
Appropriate todo notes are added to this end.
A lot of the existing payload code will be re-designed, again, as a result of this.
I decided to use two caches.
One for the main cache.
The other for a smaller, multi-purpose cache.
The second cache should be smaller and so re-allocations should be cheaper.
Use re-allocations on this as much as possible.
There are some code changes that I was indecisive around and jumped around on implementation.
I think I cleaned that all up but I may have missed something.
Kevin Day [Thu, 5 Oct 2023 04:19:44 +0000 (23:19 -0500)]
Progress: Begin adding FSS Payload processing code.
This will use the f_abstruse project.
This is very incomplete and is mostly drafted out.
Update the Featureless Make stand alone build with the latest changes.
Apply the related cleanups from 4ced1b0ba41334ce94d0a9b511b363a6031da136 (Cleanup: Have enumeration types support "none" and have the "// enum" comment at the end.).
Kevin Day [Thu, 5 Oct 2023 03:11:38 +0000 (22:11 -0500)]
Update: Simplify the f_abstruse types a little.
Being a union, the single valued integer types provide very little gain and introduce a cost in complexity.
Remove the integer types that overlap and just stick with the f_number_signed_t and f_number_unsigned_t for single value number types.
Multiple valued number types remain because there is potential for design differences due to the memory allocation and size differences.
The f_char_t type is removed.
Just stick with f_string_t.
Provide an optional "signature" Object and associated Content rules to the specification.
This better separates defining how the "header" and "payload" can be signed or have checksums applied.
The actual rules are left rather vague and flexible for implementation specific decisions.
A suggested strategy for using the "signature" is provided within the example.
Kevin Day [Wed, 4 Oct 2023 02:00:19 +0000 (21:00 -0500)]
Feature: Add f_abstruse project.
This is the initial design and may be subject to significant change as I begin to use it more.
The idea here is to provide a type that can act as a catch all for any sort of header of any specific type.
I use standard types and provide void pointer types for everything else.
I have some concerns about supporting void pointer types due to the special case of how to handle this allocation actions.
I have decided to withhold the "append" and similar standard functions for now until I get a better grasp on how this should be used.
A union is used to use the same memory space at the cost of the largest size.
A dynamic string is likely the most common case.
The resize and similar functions provide warnings that the caller needs to be careful about allocation and de-allocation.
This poses extra security concerns for when callers of these functions do not properly or safely handle the data.
I intend to use this in the FSS Simple Packet processing code, such as writing (building) the Simple Packet string.
Kevin Day [Tue, 19 Sep 2023 22:20:42 +0000 (17:20 -0500)]
Update: Restructure f_type files and add missing f_number_signed_t.
Break apart the f_type headers into multiple header files by major type groups.
This should make navigating the files a little easier.
Some of the header files are order sensitive.
The f_number_signed_t is now implemented.
Added appropriate unit tests.
I manually added the disable defines in the fake stand alone configuration file.
Kevin Day [Mon, 4 Sep 2023 20:04:37 +0000 (15:04 -0500)]
Update: Replace f_fss_simple_packet_identify() with f_fss_simple_packet_extract() and f_fss_simple_packet_extract_range().
The implementation of f_fss_simple_packet_identify() appears to be some sort of hybrid between actual code and brainstorming.
This appears to be by accident and the resulting logic of the function is nonsense.
Fix the logic in f_fss_simple_packet_identify().
I also see no reason to perform an identify call.
The FSS Packet design is so simple that I could just add 1, 4, or 5 to determine any of the parts.
Therefore, instead implement f_fss_simple_packet_extract() and f_fss_simple_packet_extract_range() to extract the Control bits and the Size integer.
The Payload part is not extracted but for the f_fss_simple_packet_extract_range(), the range for the Payload is determined.
This allows for the caller to determine how they want to manage the memory allocation.
This is a case where object-oriented would shine had I used C++ or some other object-oriented language.
I don't have this option available and so I am going to only have f_fss_simple_packet_t and f_fss_simple_packet_range_t with their respective f_fss_simple_packet_extract() and f_fss_simple_packet_extract_range() functions.
Unit tests are now provided for these two new functions.
Several unit checks did as little as necessary to perform the tests when it comes to mocking.
The additional sanity checks impose additional restrictions.
Kevin Day [Thu, 31 Aug 2023 04:19:28 +0000 (23:19 -0500)]
Update: Take advantage of lucky convenience where F_okay could be bumped from 197 to 200 thereby matching HTTP 200 status code.
I recently noticed that the F_okay is very close to being a 200 code after swapping F_none with F_okay.
This was never planned but it is incredibly convenient.
HTTP Status 200 code now matches FLL Status Code 200.
What luck!
Kevin Day [Thu, 31 Aug 2023 03:21:50 +0000 (22:21 -0500)]
Update: Relocate some of the more common or expected to be common format strings to global statics.
This is a minor resource optimization.
There will hopefully be more optimizations in the future where several of the commonly used strings (within individual projects) are moved into a single location for that given project.
Kevin Day [Mon, 28 Aug 2023 02:59:03 +0000 (21:59 -0500)]
Feature: Add -U/--under parameter to Featureless Make.
I discovered that the data build directory customization is incomplete while working on the Kevux Tools TacocaT program.
A new parameter to specify a sub-directory within the data directory, called "under", represented by -U and --under is now added.
This provides the ability to change the "build" part of the "data/build" directory.
This can even be an empty string.
The fakefile documentation and specification is updated because this parameter must now be reserved and exposed to IKI expansion.
I have not yet done a thorough test of this feature and I will hopefully do this before the next release.
I have performed a basic test and I can now compile the TacocaT program easily using this parameter.
Kevin Day [Sun, 27 Aug 2023 21:52:26 +0000 (16:52 -0500)]
Update: Wrap up re-designing the memory logic.
Update the unit tests and stand alone builds as needed.
Also clear out the stand alone builds that are out of date and require being rebuilt from the ground up.
Kevin Day [Sat, 19 Aug 2023 04:19:37 +0000 (23:19 -0500)]
Progress: Continue re-designing of the memory logic.
I would note that I am leaving the append() and append_all() for the IKI structures because they are complex.
In the long term I may end up adding back the append() and append_all() functions for each type.
At this time it is more advantageous for me to not have that consistency for easier maintainability while the project is evolving and refactoring.
I still need to look over the string and UTF string memory related functionality.
This will be more delicate and given the size of these two projects will be a bit time consuming.
Kevin Day [Thu, 17 Aug 2023 23:44:27 +0000 (18:44 -0500)]
Update: Use F_okay instead of F_none as the first status code.
This change is in two parts.
This part is just changing the status codes.
The next part will be changing all code using the status code F_none as the standard return to instead use F_okay.
I believe that F_okay makes more semantic sense than F_none when providing a standard code.
The original idea of F_none is that there are no errors.
I think "okay" is even more accurate.
Furthermore, the F_okay better matches the return code of the HTTP standard "HTTP 200 Okay".
Kevin Day [Thu, 17 Aug 2023 23:24:14 +0000 (18:24 -0500)]
Update: Simplify disable defines for status codes.
I like the idea of having the pre-created disable defines for each group.
The problem is that this is extra maintenance and I do not see significant use for this functionality.
Remove these to make my life slightly easier.
Kevin Day [Thu, 17 Aug 2023 03:48:37 +0000 (22:48 -0500)]
Progress: Continue re-designing of the memory logic, mostly getting tests back in synchronization.
Get the tests working.
Some of the tests I am not mocking the allocation and performing the real allocation actions.
This allows for the unit test to also test memory if run with valgrind.
I did this after getting much of the work done and so I ended up not consistently doing this on all of the "works" tests.
Generally, the tests for functions with the double 's' have the actual memory allocations.
Kevin Day [Sun, 13 Aug 2023 22:11:13 +0000 (17:11 -0500)]
Progress: Continue re-designing of the memory logic also removing *_append() and *_append_all().
In some cases *_append() and *_append_all() functions are removed.
This is a lot to manage at this time so remove it.
At some future point in time I need to implement a good generic append and append all design.
This is likely to use some sort of callback that performs the individual copy calls.
Many of the existing *_append() and *_append_all() are left alone but may eventually be removed.
The dynamic string based ones, however, will remain as an exception case.
The names I originally chose for the callbacks are misleading.
Rename them to be "delete" and "destroy" rather than "resize" and "adjust", respectively.
Half way through changing this I came across the more complex cases for resizing.
These I need callbacks both both array of arrays and arrays of arrays.
I did not finish the process of converting this.
The f_type_array needs more work.
In particular, the arrays of arrays in f_type_array can be moved into a common f_memory function, such as f_memory_arrayss_resize().
The unit tests have not been updated but I did manage to get the unit test for the f_account done.
The stand alone build config.h files are not update to date either.
These changes have shown a significant improvement in the resulting binary size.
The current size is actually just barely smaller than the 0.6.7 equivalent build (when compiled using the same compiler for both).
The changes are not complete and so I anticipate the 0.7.0 branch to be smaller than the 0.6.7 branch as of this change set despite the 0.7.0 development branch having more functionality.
Kevin Day [Sat, 12 Aug 2023 03:28:09 +0000 (22:28 -0500)]
Update: Ensure pointers passed to the function are constant.
The function should never be allowed to change the pointer itself.
A double pointer is used so that the value of the pointer can be another pointer which can then be changed.
After trying to figure out why the tests were failing, I finally discovered that the wrong file is being used.
The settings-mocks needs to be used to pull in the mocked data.
I felt this fix deserved its own distinct commit rather than being part of another Progress commit.