Kevin Day [Sun, 7 Jun 2020 14:07:06 +0000 (09:07 -0500)]
Update: support copying documents, licenses, and specifications per project and do some cleanups
Individual projects, specifically programs (level_3), may have custom documentation, licenses, and specifications.
(With custom licenses being least likely because this project in its entirety is under lgpl.)
Add support to all projects just for good practice.
Cleanup ordering of function names and add spaces before function instantiation open brace.
Kevin Day [Sun, 7 Jun 2020 03:30:17 +0000 (22:30 -0500)]
Update: Featureless Make needs to handle the -d/--define parameter
Rename the parameter from defines to define, because it acts on only a single parameter at a time.
The -d must be specified multiple times to get multiple defines.
When -d/--define is specified, the defines provided by the settings file get ignored.
Continue to pass the defines from the console parameters to the process scripts.
Kevin Day [Sun, 7 Jun 2020 02:32:27 +0000 (21:32 -0500)]
Bugfix: shared library link names are incorrect
The standard link names are:
libfake.so -> libfake.so.0
libfake.so.0 -> libfake.so.0.5.0
Instead, I had:
libfake.so.0 -> libfake.so.0.5
libfake.so.0.5 -> libfake.so.0.5.0
While I am at it, make these links reflect the version_target setting.
If target is major, then standard link names above are followed.
If target is minor, then:
libfake.so -> libfake.so.0.5
libfake.so.0.5 -> libfake.so.0.5.0
If target is micro, then:
libfake.so -> libfake.so.0.5.0
Kevin Day [Sun, 7 Jun 2020 01:21:26 +0000 (20:21 -0500)]
Feature: add version_target setting to Featureless Make and FLL generate script
I noticed that I had a different linker version string between Featureless Make and the FLL generate script.
After reviewing and fixing, I decided to make this a customizable option now called version_target.
The default, traditional behavior, is to use only the major version.
A major version target would link like "-Wl,-soname,libfake.so.0".
A minor version target would link like "-Wl,-soname,libfake.so.0.5".
A micro version target would link like "-Wl,-soname,libfake.so.0.5.0".
Kevin Day [Sun, 7 Jun 2020 00:41:06 +0000 (19:41 -0500)]
Update: change settings structure to follow the Featureless Make structure
The existing design is based on the bootstrap scripts.
The bootstrap script is now updated to the new design so these scripts can now be updated to the new design.
Kevin Day [Sun, 7 Jun 2020 00:38:06 +0000 (19:38 -0500)]
Update: redesign to follow the Featureless Make design
Use the setting names specified by Featureless Make, which are a bit more generalized than the current generate.sh design.
This does not fully follow all of the Featureless Make functions.
Only what is necessary (or already implemented) to bootstrap the entire FLL project is done.
Kevin Day [Sat, 6 Jun 2020 21:46:26 +0000 (16:46 -0500)]
Bugfix: do not consider a non-existent build directory an error during clean operation
The clean only cares about deleting all of the files in the build directory.
If that directory does not exist, then there is no issue.
When in verbose mode, print a message about the directory not existing.
Kevin Day [Sat, 6 Jun 2020 19:46:02 +0000 (14:46 -0500)]
Bugfix: filename without extension not terminated and compiled objects need subdirectories
When generating the filename without the file extension, terminate the string.
When library sources are specified using subdirectory paths, object files should have the same subdirectory structure.
This only applies to object files because they are compiled using the same naming structure as the sources.
The rest of the compiled code is compiled into a new structure, which is generally a single library or program.
Kevin Day [Sat, 6 Jun 2020 16:43:39 +0000 (11:43 -0500)]
Bugfix: invalid memory access and only process if not empty
If the path_headers is not defined, an invalid memory read was triggered.
This happens because I was only assigning path_headers variable when path_heades setting was defined but I was still attempting to copy that path regardless.
Make sure to not bother attempting any copy or compile build operations if that setting has not properties (such as build_sources_program being empty).
Kevin Day [Fri, 5 Jun 2020 00:21:30 +0000 (19:21 -0500)]
Progress: featureless make
This gets the shared library and shared program compiling working.
The fake program can compile the fake binary and that fake binary can do the same.
This is great progress.
Kevin Day [Fri, 5 Jun 2020 00:18:50 +0000 (19:18 -0500)]
Bugfix: do not embed libraries into program
The generate.sh script design seems to be adding the library sources into the program.
This effectively makes the linked library.
This is a bad compiling and linking design and a waste of space.
Instead, add a link option to the project name so that the library gets linked to by the program.
Kevin Day [Tue, 2 Jun 2020 04:43:08 +0000 (23:43 -0500)]
Progress: featureless make
Handle the script sources differently than the bash sources.
The bash sources, a scrript, is for generated/processed (and the how is yet to be defined).
The more general scripts are meant for already prepared scripts not modified by this program (unless modified by some pre-process or post-process script).
The more general scripts does not care what the file is, it just gets copied over into the build scripts program path.
Add build_script yes/no setting to conditional include the general scripts when building.
Slightly rework the logic when processing the build operation functions.
Add the planned functions as stubs, to be completed in a future commit.
Kevin Day [Sun, 31 May 2020 04:41:33 +0000 (23:41 -0500)]
Progress: featureless make
Fix a mistake in the naming conflict for with the language enum and language defines.
Implement a more generic build copy function.
Improve file copying support.
Add verbose copy messages.
Copy the C and C++ header files.
Rename fake_build_settings to fake_build_setting to properly follow this projects naming convention.
Add missing dependency for fl_directory.
Language-specific support setting "build_language" is implemented and provides a way to specific which language to use.
This will default to C.
Kevin Day [Sun, 31 May 2020 04:37:30 +0000 (23:37 -0500)]
Update: ensure string parameter tests exist and add f_file_name_base() and f_file_name_directory() functions
I seem to have forgotten that f_string is a char * and should be checked to not be NULL.
I think I removed these during a cleanup process, so add them back.
The basename() and dirname() functions need to be suppoted.
They require extra effort because as per the POSIX standard, parameters are modified.
This is undesirable so protect the parameters when calling.
Kevin Day [Sat, 30 May 2020 22:42:26 +0000 (17:42 -0500)]
Cleanup: make f_string_eol and f_string_placeholder a string instead of a char
In the back of my mind I keep reading f_string_eol as a string.
It is not.
Instead, it is a character.
To prevent this potential confusion, just make it a string and require the use of f_string_eol[0].
Make the same kind of change to f_string_placeholder as well.
Kevin Day [Sat, 30 May 2020 22:36:40 +0000 (17:36 -0500)]
Progress: featureless make
Move the print functions to their own private files (private-print.c and private-print.h).
Have the build operation create the build directory skeleton.
Have the build operation copy the settings files over, if specified in the build settings.
Update the code to be in sync with recent FLL changes.
Kevin Day [Sat, 30 May 2020 22:33:09 +0000 (17:33 -0500)]
Update: pipe and fifo, replace f_directory_mode with f_mode, f_file_copy()
Stick to only using fifo terminology in file types.
Replace f_directory_mode with f_mode, a global type to be shared between f_file, f_directory, and anything else.
Update f_file_copy() to use f_mode instead of mode_t.
This allows the caller to just send the mode.
The copy function already stats the file and processes it per file type, so it can make the decision on which mode to use.
This alleviates the need for the caller to also perform a file type stat check.
Kevin Day [Sat, 30 May 2020 01:00:41 +0000 (20:00 -0500)]
Update: todo documentation, directory copy and clone functions, update comment documentation
Update the todo.txt documentation.
There needs to be directory copy and clone functions for copy the contents of a source directory and not the directory itself.
To that end, add new *_contents() copy functions.
The comment documentation for clone was never updated and is incorrect.
Kevin Day [Fri, 29 May 2020 00:23:59 +0000 (19:23 -0500)]
Progress: add more directory and file related functions, other changes
This was started with the intention of providing all of the *_at() functions.
However, the POSIX spec seems to fall short in many areas making this more difficult than this should be.
I partially rolled back some of the planned changes and this changeset is the result.
I have observed that the function return documentation needs to be updated, but this will be done at a later time.
There will need to be some intensive testing later on but for now I am committing and moving forward.
Kevin Day [Wed, 27 May 2020 04:45:31 +0000 (23:45 -0500)]
Update: file and directory improvements, finish writing directory copy
Organize directory header structure, adding directory_type.h.
Add additional directory structures.
Directory copy needs to report what fails, so provide a structure for reporting each failure.
(There needs to be a verbose function for printing success/failure.)
Remove de-reference from numerous file functions.
POSIX denies certain operations of symlinks.
During copy operations, do not apply mode to symlink as it would now apply mode changes to the de-referenced link.
Allow block size to use default block size if set to 0 (convenience).
Add missing return statement to file copy (without it socket file types would incorrectly report F_unsupported).
Add link read functions so that symlink information may be obtained so that it can then be copied.
Add comments about poorly written umask() as per POSIX standard (at least according to manpages).
Kevin Day [Sun, 24 May 2020 03:54:53 +0000 (22:54 -0500)]
Update: minor improvements, finish f_file_copy(), add fifo file type
Finish implementing the f_file_copy(), adding support for all file types (except unknown).
The documentation for block, character, and FIFO is unclear to me at this time and my attempts to copy using mknod(2) is an educated guess.
Attempt to prevent file type from being passed via the mode_t when doing a copy (currently untested).
Add the appropriate file create functions to implement the copy operations.
Have the copy file copy only the directory itself and not the contents (to copy contents, the fl_directory_copy() function should be used).
The added fifo type is pretty much the same as pipe.
Mixing fifo with pipe terminology ended up being confusing so I opted to create redundant FIFO types to simplify the readability.
Use the word "regular" for a regular file instead of "file".
Using "regular" is a less confusing than using "file" (i.e. Regular File Type vs File File Type).
Kevin Day [Sat, 23 May 2020 20:46:19 +0000 (15:46 -0500)]
Cleanup: Replace F_file_open_not with F_file_closed, add additional status codes for consistencies
Socket was not fully converted into basic status codes (not having connect).
I can see future work in sockets whee I may actually add connect codes back, but I won't know until I spend dedicate time on it.
Add additional status codes that should probably exist for consistency purposes.
With F_file_open_not removed, split behavior into two checks:
- F_file for file descriptor errors.
- F_file_closed for file not open errors.
Kevin Day [Sat, 23 May 2020 20:13:59 +0000 (15:13 -0500)]
Cleanup: update all status codes in line with recent refactor and fix issues
This primarily puts all of the status code handling in alphabetic order.
The length sizes are updated accordingly.
Be consistent with S at the end of things, whereas S is not the traditional grammatical use but instead implies a set of.
Use the base F_* disable defines instead of using new ones for each level when they are specific to the F_* status codes.
Add additional comment documentation.
Any issues observed resulting from the refactor were also fixed during this change.
Kevin Day [Sat, 23 May 2020 15:36:05 +0000 (10:36 -0500)]
Refactor: use capital F, FL, and FLL for status codes to avoid potential conflicts
By only using the first part, the annoyance of all uppercase can be avoided.
This then allows shortening the names and removing words like "_error".
Also restructure where the "_not" are placed (placing them immediately after what they apply to).
This will be followed up by a restructuring commit.
Kevin Day [Sat, 23 May 2020 05:35:03 +0000 (00:35 -0500)]
Update: get the level_3 / programs working after major file / directory changes
This required making some fixes in the files related code.
This puts the UTF-8 file (utf_file) project notably behind an additional work is necessary to get that working correctly as well as having it be consistent with f_file.
I've decided that when written pointer is 0, then the caller is requesting to not get back the written size.
I am very likely going to do similar behavior with null pointers in other uses, which will help further simplify the design.
Other minor changes.
Of particular note is moving flags into the f_file structure.
This was effectively how the pre-file redesign worked, but it uses flags now instead of the "r", "rw", "a", etc.. string modes used by fopen.
Make sure an append flag is available.
Kevin Day [Fri, 22 May 2020 02:42:18 +0000 (21:42 -0500)]
Progress: continue redesign of file and directoy structure
This gets the code in a state where I can focus on updating all of the programs (level_3 files).
The UTF-8 related types have @todo and @fixme as I intend to come back later and finish them.
Kevin Day [Thu, 21 May 2020 05:08:09 +0000 (00:08 -0500)]
Progress: major redesigns with file and directory handling, this changeset is incomplete
In the process of writing the directory copy, I realized I needed to improve the file and directory management.
This triggered me to rethink how I was handling files and directories to some extend.
If memory serves me correctly, the POSIX 2008 was either too new or non-existent when I first wrote some of this.
Updating to use the newer POSIX functionality and changes seems worth this major change.
Add additional file functionality.
Lots of re-organization and redesign.
I still haven't finished this and would rather commit now, with incomplete code randomly throughout, than risk losing any changes.
In particular, the fl_utf_file is where I need to resume.
I need to then update all of the level 3 programs to use the new file/directory handling code.
After that I need to finish writing the directory copy, which should include investigating and implementing file copy operations for more than regular files and symbolic links.
I also need to remember to investigate copying hard links as a hard link instead of as a duplicate file.
Kevin Day [Sun, 17 May 2020 23:05:50 +0000 (18:05 -0500)]
Progress: featureless make
Add and validate modes from the build settings files.
This provides some data integrity support.
If a mode is not defined in the modes property of the build settings, then that mode is not valid and the build process is stopped.
Kevin Day [Sun, 17 May 2020 17:05:59 +0000 (12:05 -0500)]
Progress: featureless make
Snatch apart the settings strings instead of mashing them together.
Process the environment build setting to enable selecting additional environment variable to expose to the process scripts.
Kevin Day [Sun, 17 May 2020 02:56:52 +0000 (21:56 -0500)]
Update: numerous changes, most notably path and vfork to fork changes
Replace vfork() calls with fork().
- I have determined that vfork() is not safe.
- When calling clearenv() inside a vfork() child process, the parent process' environment ends up getting cleared as well!
- The child can alter the parents memory according to manpages, so stop using vfork() entirely.
Add path processing functions and related defines.
Enable path processing to allow for execvpe()-like behavior can be implemented.
- The execvpe() function is not used because it is not POSIX.
- Manually process the PATH environment to determine what to execute, even when PATH enviornment gets cleared.
Some consistency improvements in defines, such as f_console_max_size to f_console_length_size.
Fix mistake in memcpy usage, dynamic strings use char * for their string so passing & is incorrect.
The f_file_exists() is using access().
- This is misleading and incorect.
- Use stat() to determine if file exists because it doesn't require access to the file (aside from directory access) to check existence.
- Add a new function f_file_access() as the old implementation of f_file_exists().
The fll_execute programs now support additional functions for clearing environment variables.
- This effectively sandboxes the environment variables before calling the program.
Kevin Day [Fri, 15 May 2020 02:52:28 +0000 (21:52 -0500)]
Cleanup: remove f_string_eos, use 0 instead
I originally created f_string_eos, so that it could be potentially changed.
In the case of basic strings, using 0 is simpler, more consistent, and safer.
Kevin Day [Fri, 15 May 2020 02:42:01 +0000 (21:42 -0500)]
Update: add environment functions, add static strings, and other changes
Add environment project and associated functions for managing environment variables.
Add execute functions for setting environment variables.
- More work is needed to search the PATH to perform fll_execute_program_environment when PATH is not to be defined.
Provide stub define build settings files for each project.
Kevin Day [Thu, 14 May 2020 04:24:19 +0000 (23:24 -0500)]
Progress: Featureless Make
Implement skeleton operation.
Simplify parameters and enforce a more standard structure on 'build'.
The "make" operation with its "fakefile"s can be used for more flexible project structures (at least once it is written).
It occurred to me that this would make the function names more inconsistent.
This could get very confusing so just stick with "dynamic" in all the names.
"dynamic" is the original term and "static" in isolation is a reserved word.
The type names will remain as both f_string_static and f_string_dynamic.
That inconsistency is desirable due to the explicit meaning communicated by their names.
Kevin Day [Sat, 9 May 2020 22:26:41 +0000 (17:26 -0500)]
Feature: add f_string_static as a non-allocated alternative to f_string_dynamic
That is not to say that a dynamically allocated buffer cannot be placed in its string part.
Instead, it communicates that this is not never be allocated or deallocated directly.
This is implemented in such a way that f_string_dynamic is a sub-type of f_string_static.
This should allow for easy type conversions.
Kevin Day [Sat, 9 May 2020 21:47:12 +0000 (16:47 -0500)]
Update: improve color mode handling
Improve handling of color mode so that applications can consistently react to the established color code.
In the fake program, this is useful for passing the color mode to the build pre-process and build post-process scripts.
Kevin Day [Sat, 9 May 2020 04:28:31 +0000 (23:28 -0500)]
Update: add snatch apart functions and improve logic of fss snatch functions
The snatch apart is to create separate sets of strings instead of merging them.
The snatch mash apart will mash all dynamic strings for all content for a single object but use separate strings for each separate object.
I accidentally, or perhaps habitually, used break when return is better when handling errors.
Make sure to document f_string_max_size as a possible return result.
Kevin Day [Sat, 9 May 2020 01:23:46 +0000 (20:23 -0500)]
Update: switch back to lengths from inclusive ranges
Using start and stop ranges ended up being cumbersome.
Using length is simpler and a start range can be used by just adding to the source string before calling.
Kevin Day [Fri, 8 May 2020 02:47:18 +0000 (21:47 -0500)]
Update: numerous fixes and additions, mostly string related
Not sure how I let this one get through, but add missing return statement in a couple of private string functions where it is missing.
In retrospect, it seems that I was overzealous with some of the parameter checks.
Redo the parameter checks to not be as sting on string length and buffer size ranges.
Instead, just return that there is nothing to do instead of erroring out.
Add string terminate functions.
These functions are designed to guarantee that an end of string exists at the end of some dynamic string.
Add functions for appending one or more arguments to the arguments array for the execute functions.
This functionality is common enough (used extensively by firewall and soon to be used by fake).
Support providing an array of arguments to append.
This greatly simplifies long-winded code.
Minor fixes and cleanups in the execute functions:
- Add missing parameter checks.
- Rename results to result to be more accurate.
Kevin Day [Wed, 6 May 2020 04:14:13 +0000 (23:14 -0500)]
Progress: begin re-implementing fake program (Featureless Make)
The goal here will be to mimic the current FSS build scripts fist.
Then update the FSS build scripts to the more generalized design.
Then implement the traditional fakefile process (a makefile alternative).
Currently has "skeleton" mode, which may or may not be implemented.
This was added as a stub just in case I decide to implement it.
Kevin Day [Tue, 5 May 2020 05:00:50 +0000 (00:00 -0500)]
Feature: add fss snatch functions for "snatching" content for a set of object names
These are intended to be used for simple purposes.
Directly implementing these in individual projects are recommended for more advanced usage.
I intend to expand on these "snatch" functions in the near future.
Kevin Day [Tue, 5 May 2020 03:01:27 +0000 (22:01 -0500)]
Update: add back the dynamic_partial functions, add missing functions
After further review I realized that the dynamic partial behavior is going to be more common.
The rip functions are also not the same because it removes leading/trailing whitespace, which may be undesirable.
Some of the append_nulless function implementations were missing.
Kevin Day [Mon, 4 May 2020 11:47:38 +0000 (06:47 -0500)]
Feature: add fl_utf_file project
This is intended to be an f_utf_character handling version of fl_file project.
This f_utf_character is a 4-byte wide storage for a single UTF-8 character.
I accidentally committed the utf_file build settings in a previous commit: f69e57a.
Kevin Day [Mon, 4 May 2020 11:11:59 +0000 (06:11 -0500)]
Update: Redesign f_file and fl_file functions, simplifying f_file_position
Redesign the logic behind the f_file and fl_file functions to favor the buffer->used append strategy.
Remove f_file_read_range(), something similar can be added later if need be.
Povide f_file_reat_until(), that functions similar to f_file_read_at(), except the file position is not automatically set.
Using f_file_reat_until() is more efficient in array loops because it does not check the file position every execution.
Add f_macro_file_seek_data() and f_macro_file_seek_hole() to support the newer seek modes: SEEK_DATA and SEEK_HOLE.
The f_file_position structure is simplified.
The file position should only be for file related code and having buffer in there is just plain wrong.
The structure is further simplified in its property names.