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.
Kevin Day [Tue, 8 Aug 2023 01:21:26 +0000 (20:21 -0500)]
Cleanup: Add explicit casts in the f_memory memset() calls.
The pointer is cast to uint8_t to perform the arithmetic.
The pointer is not cast back but the cast happens in the function call.
Be explicit and designate that the cast back to a void pointer is intentional.
Kevin Day [Sun, 6 Aug 2023 21:44:56 +0000 (16:44 -0500)]
Progress: Continue re-designing of the memory logic.
This wraps up the simple memory append all functions with added unit tests.
I anticipate that I need to do the more complex ones as well.
This adds the adjust and resize callbacks for use in more complex memory functions.
The more complex memory functions for adjust and resize are implemented with unit tests.
The unit tests for the type array callbacks are incomplete because I did not get time to finish writing them.
Those unit tests are written but are incomplete and do not yet work.
Kevin Day [Sun, 6 Aug 2023 00:43:19 +0000 (19:43 -0500)]
Progress: Begin simplifying memory design, starting with f_number_unsigned_t array structures.
I find that the use of custom per-type functions to simplify the usability of the library.
I also find that this increases the complexity and size of the code base.
I believe that over time this will become more complex and even harder to maintain.
I have decided to start changing the design to go back to simple allocation methods that just require more variables.
This simplifies the code and in theory will make it faster by having fewer function calls on the stack.
This may even reduce the resulting binary size (and I hope it does).
The down side is that the users of the library will once more have longer function call lines.
This commit is the beginning of the redesign process.
I also added the "append" and "append all" methods for f_memory_array calls.
Kevin Day [Sun, 6 Aug 2023 00:38:12 +0000 (19:38 -0500)]
Regression: Invalid type used when allocating string, f_string_t should instead be f_char_t.
I noticed odd differences between the 0.6.x and the 0.7.x in terms of memory usage.
I discovered this to be due to a bug where the f_string_t is being used when the type should be instead f_char_t.
This is likely a bug introduced in some past refactor.
Kevin Day [Sat, 5 Aug 2023 15:40:14 +0000 (10:40 -0500)]
Bugfix: The socket id is not the same descriptor for reading.
When binding and listening on some socket id, the accept call on that socket creates a new descriptor.
That descriptor is not the same as the original socket id.
Add a new id_data to the socket structure to represent the data transfer file descriptor that is created via the accept() call.
Add a new f_file_close_id() to close the file by the id in case the f_file_t is not available or in use.
This adds f_time_spec_millisecond() and f_time_spec_nanosecond() for safely handling overflow and underflow when using standard FLL f_number_unsigned_t numbers.
Unit tests are added.
A comment in the controller prrogram is added to designate that the controller-specific functions should be updated to call these functions.
Kevin Day [Sat, 5 Aug 2023 00:36:26 +0000 (19:36 -0500)]
Update: Wrap the static inline functions private_inline_f_print_to_error in custom disable macros.
As an exception case, wrap the private_inline_f_print_to_error() in _di_private_inline_private_f_print_to_error_ and _di_private_inline_f_print_to_error_ as appropriate.
Using a define condition on all of the possible cases would be difficult to manage.
An explicit define is simpler and easier in this exceptional case.
Kevin Day [Fri, 4 Aug 2023 05:00:15 +0000 (00:00 -0500)]
Cleanup: Remove the FSS Embedded List Program.
This embedded_list in fss_read should be used going forward.
The embedded_list in fss_read is not working yet and is just a copy of extended_list.
I will eventually get around to updating the embedded_list in fss_read to work as intended and expected.
Kevin Day [Fri, 4 Aug 2023 04:54:38 +0000 (23:54 -0500)]
Update: Control program to latest design practices, migrating from 0.6.x to 0.7.x design.
This gets the control program to compile under the latest design practices.
I did not to an in depth review as this program does not currently do anything.
Once the controller program is updated I will eventually come back to this.
Kevin Day [Tue, 1 Aug 2023 01:57:54 +0000 (20:57 -0500)]
Bugfix: The Byte Dump program prints extra new lines.
Migrating from the old way to the new way results in extra new lines because of the first and last new line being printed.
Remove the extra new line being printed but still print in all other cases.
Kevin Day [Wed, 26 Jul 2023 04:16:52 +0000 (23:16 -0500)]
Update: Byte Dump program structure, following newer standards.
I noticed two things while working on this that need to be addressed for all programs.
1) When using threads, the signal for piping data (such as byte_dump /bin/bash | head) does not trigger.
2) The color code modes are not being processed correctly.
These observed bugs will be fixed in some other commit.
Kevin Day [Sun, 23 Jul 2023 19:26:19 +0000 (14:26 -0500)]
Update: Finish memory array related changes.
There are still the append() and append_all() function to change but I am going to leave that for another time.
This finishes the recent set of Progress commits addressing the memory array related code.
I have observed a notable reduction in binary size but the primary goal here is reduction of duplicate code and simplification of code.
I should eventually be able to re-introduce macros to map these helper functions back to the base array type to reduce binary size by a significant amount.
This should only be done once the API has stabilized more.
Kevin Day [Sat, 22 Jul 2023 15:38:57 +0000 (10:38 -0500)]
Progress: Continue memory array related changes.
I noticed that I could also implement f_memory_array_append() and f_memory_array_append_all() methods if I used memcpy() and a multiplication over the type size.
This:
const f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_socket_t), (void **) &destination->array, &destination->used, &destination->size);
if (F_status_is_error(status)) return status;
for (f_number_unsigned_t i = 0; i < source.used; ++i) {
destination->array[destination->used++] = source.array[i];
} // for
return F_none;
Could instead become:
const f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_socket_t), (void **) &destination->array, &destination->used, &destination->size);
if (F_status_is_error(status)) return status;
This could then be logic could then be moved into something like f_memory_array_append_all(), further simplifying the code into:
return f_memory_array_append(source.array, source.used, sizeof(f_socket_t), (void **) &destination->array, &destination->used, &destination->size);
I need to think of the function structure that I want and so I only decided to comment in this commit.
Such a change is not implemented yet but may be done at some later time.
Kevin Day [Wed, 19 Jul 2023 04:11:32 +0000 (23:11 -0500)]
Progress: Continue memory array related changes, replacing the f_memory_structure entirely.
The f_memory_array set of functions now fully replaces the f_memory_structure functions and related macros.
I think those structure macros are nifty but they are not in use enough anymore and the f_memory_array structure is what I am going forward with.
There is still an enormouse amount of changes to do.
Kevin Day [Tue, 18 Jul 2023 04:56:33 +0000 (23:56 -0500)]
Progress: Add memory array allocation functionality and begin to use it where possible.
The pattern for handling the standard array structure is now well established.
Provide a memory array functionality for handling the most basic form.
This should reduce repeated code where possible.
It would be interesting if this reduces the size of the resulting binary but with inline optimizations it may be possible that this actually increases the size of the resulting binary.
Update the comments and tests.
There are a lot of files that will need to be updated to use these new functions.
Most of these are in the f_type_array project.
Kevin Day [Mon, 17 Jul 2023 05:24:37 +0000 (00:24 -0500)]
Update: Add FSS Simple Packet related functionality and remove delimit and comment types.
The FSS Simple Packet functionality is added, to provide for processing of the FSS Simple Packet.
The f_fss_simple_packet_ranges_t represents a set of ranges for designating where/how the packet is defined within some string.
The delimit and comment types are just helper type definitions for existing number types.
Simplify the design by getting rid of those, replacing them with the type that they effectively represent.
A lot of code is updated to reflect this change.
This is an encrypted variation of the FSS-000F "Simple Packet" specification.
The third control bit (from the left) represents that the Simple Packet is encrypted.
The requirements for the format of the actual contents of Payload Block is further relaxed due encrypted data needing to be private (for what should be obvious reasons).
Add "Properties: " and related styling to the documentation comments for type definition structures.
Fix capitalization and other formatting issues that I noticed.
I did not focus on any of the programs.
However, some program related files happened to be open and so I updated those out of convenience.
A follow up commit will be needed to address the programs and any other files in which I may have missed in this pass.
Kevin Day [Sat, 15 Jul 2023 03:00:11 +0000 (22:00 -0500)]
Update: Specifications, adding explicit version date and change license line format.
Add a version, which contains the date of the last change to each of the specifications.
There will eventually be a specification version number such as "1.2.3".
The license line in the comments at the top of each specification is of this form: "license: ".
Remove the colon so that the comment, if extracted, could be processed as something simple like FSS-0000.
Kevin Day [Fri, 14 Jul 2023 03:07:57 +0000 (22:07 -0500)]
Update: Conversion should return F_number_positive and F_number_negative without error bit and do some clean up.
Do not treat F_number_positive and F_number_negative as an error.
The "unsigned" concept should be internal to the function and not whether or not the user input has a sign.
If F_number_negative is returned, the value can still be of type f_number_unsigned_t.
This is because the return status designates the effective sign.
The caller can then decide whether or not this is an error.
Kevin Day [Thu, 13 Jul 2023 03:24:07 +0000 (22:24 -0500)]
Update: Use status_signal instead of status_thread.
The status_thread is being used specifically for the signal thread.
Change the standard practice to have this renamed to status_signal.
This then helps make other status names make more sense.
Rather than have status_thread, status_thread_a, and status_thread_b, instead have status_signal, status_a, and status_b.
Kevin Day [Sun, 9 Jul 2023 16:33:46 +0000 (11:33 -0500)]
Update: Network additions and improvements, minor documentation comment clean ups.
Add f_network_is_ip_address() along with appropriate unit tests.
The unit test are not as thorough as they could be.
I did not fully review the IPv6 standard, which has a rather absurd design.
There are likely things that I do not yet know about that are not supported.
Specifically do not support port number on any IPv6 address without brackets.
(The IPv6 address notation standard is horribly written.)
Kevin Day [Sat, 8 Jul 2023 03:36:17 +0000 (22:36 -0500)]
Update: Socket bind functions, socket address family enumeration, and rename max_backlog.
Change the f_socket_bind_local() bind function to not call memset() and use the new address structure.
Add f_socket_bind_inet4() and f_socket_bind_inet6() bind functions in a similar way to f_socket_bind_local().
Update the appropriate documentation.
Add the appropriate unit tests.
The name max_backlog for f_socket_listen() is better named backlog_max as per the FLL style practices.
Kevin Day [Thu, 6 Jul 2023 03:38:12 +0000 (22:38 -0500)]
Update: Socket improvements regarding structure and styling.
The f_socket_t structure has "struct sockaddr" as a pointer.
This means mass allocation becomes less practical due to needing to create the actual "struct sockaddr" as needed.
Implement an f_socket_address_t union that accepts the cost of less memory efficiency to improve the usability.
This now allows for mixed types to be stored in the array without needing complicated code to manage different arrays.
The caller will have to be responsible for properly setting the appropriate structure as needed.
Organize the code styling to be more consistent with alphabetical ordering.
I likely have some of the comments to update as well (a follow up commit will be necessary).
Kevin Day [Thu, 29 Jun 2023 04:38:30 +0000 (23:38 -0500)]
Update: Relax the requirement in the license to be less verbose.
Do not specifically use my name "Kevin Day".
Instead refer to the "original license owner" or some authorized party.
This will make the license more flexible.
This also addresses a define name design problem where I have two cases that _F_type_array_file_h would be defined.
For now, just rename the _F_type_array_file_h to _F_type_array__file_h for the top-level file.
Kevin Day [Sat, 24 Jun 2023 20:58:06 +0000 (15:58 -0500)]
Feature: Add f_file_select() for select().
This is more of a wrapper around select() (unlike f_file_poll() which is a bit more than a wrapper around poll()).
The arguments would be more difficult than worth it to simplify and normalize in the FLL typedef style.
Kevin Day [Sat, 24 Jun 2023 03:08:45 +0000 (22:08 -0500)]
Feature: Add additional network and socket related functions.
Add the following:
- f_file_poll() for poll().
- f_socket_read_stream() for recv().
- f_socket_write_stream() for send().
Add f_poll_t, f_polls_t, and f_pollss_t typedefs.
This adds the appropriate array management functions.
To be consistent with type_file.h a new type_array_file.h is created to manage these.
Update the existing f_signal_read() to use the new typdef f_poll_t.
Kevin Day [Thu, 22 Jun 2023 03:26:54 +0000 (22:26 -0500)]
Feature: Add f_network_to_ip_string() and f_network_from_ip_string() functions.
Provide support for inet_ntop() and inet_pton().
String are handling in FLL via f_string_static_t and f_string_dynamic_t.
The functions f_network_to_ip_string() and f_network_from_ip_string() are written to convert to these string types.
This implements a custom f_network_family_ip_t type to pass the digit IP address.
The idea here is to help reduce how much the FLL API is locked into the "libc" or POSIX API.
The structures are allocated using "{ 0 }" to take advantage of the supposed relatively new feature that treats this as an initialize all to NULL.