From: Kevin Day Date: Sun, 28 Jan 2024 06:32:13 +0000 (-0600) Subject: Progress: Improve FSS program processing and fix related bugs. X-Git-Url: https://git.kevux.org/?a=commitdiff_plain;h=f71195801aaea4f1c58fd19875cd8a04d2cbd8bd;p=fll Progress: Improve FSS program processing and fix related bugs. Clean up the logic in the fll_fss functions, removing redundant code. Improve handling of F_fss_found_object_content_not cases in a more consistent manner. Improve logic of the fll_fss payload functions. Remove dead code that does nothing. Have the payload processing properly determine and communicate when the "payload" section is missing. Update the documentation comments. Improve the FSS read programs relating to the above changes. Fix problems in the FSS read programs where sometimes the EOL string is directly printed rather than calling the appropriate object/content end callbacks. The callbacks handle the uses cases for when the pipe is used but the direct EOL string printing does not. Rename the FSS read progams print functions to have the "data", "message", "error", and such practice be more consistently followed. This fixes several of the problems in the FSS Read programs where the "-e/--empty" parameter is not being properly respected in many cases. I am not sure I got all of the situations and the logic from all of the changes that I made needs some review. For the FSS payload read program, add a new special parameter called "--payload". This allows giving the user more control over how to handle the cases where the payload section does not exist. Specifically, there is a payload "create" mode that allows for ensuring that the "payload" section always exists. This should ideally help make scripting simpler and therefore easier. The parameters must be re-processed once the '-A" is passed for the fss_read combined program. I added a print_content_empty callback and then commented it out in this commit. This seems like it would be practical to have but I am not certain any FSS specification would need this at this time. Further investigation is needed in this regard. Add some more TODO and FIXME comments so that when I come back to this code and can better resume where I left off. I did very little testing of these changes. --- diff --git a/level_2/fll_fss/c/fss/basic.c b/level_2/fll_fss/c/fss/basic.c index e900861..8dd3369 100644 --- a/level_2/fll_fss/c/fss/basic.c +++ b/level_2/fll_fss/c/fss/basic.c @@ -47,24 +47,9 @@ extern "C" { if (range->start >= range->stop || range->start >= buffer.used) { if (state->status == F_fss_found_object || state->status == F_fss_found_object_content_not) { - ++objects->used; - - if (objects_quoted) { - ++objects_quoted->used; - } - - status = f_memory_array_increase(state->step_small, sizeof(f_range_t), (void **) &contents->array[contents->used].array, &contents->array[contents->used].used, &contents->array[contents->used].size); - - if (F_status_is_error(status)) { - state->status = status; - - return; - } - - contents->array[contents->used++].used = 0; state->status = F_fss_found_object_content_not; - return; + break; } if (state->status == F_data_not) return; @@ -90,19 +75,7 @@ extern "C" { break; } - if (state->status == F_fss_found_object_content_not) { - found_data = F_true; - - status = f_memory_array_increase(state->step_small, sizeof(f_range_t), (void **) &contents->array[contents->used].array, &contents->array[contents->used].used, &contents->array[contents->used].size); - - if (F_status_is_error(status)) { - state->status = status; - - return; - } - - break; - } + if (state->status == F_fss_found_object_content_not) break; } while (state->status == F_fss_found_object_not); @@ -131,14 +104,23 @@ extern "C" { return; } + if (state->status == F_fss_found_object_content_not) { + found_data = F_true; + + status = f_memory_array_increase(state->step_small, sizeof(f_range_t), (void **) &contents->array[contents->used].array, &contents->array[contents->used].used, &contents->array[contents->used].size); + + if (F_status_is_error(status)) { + state->status = status; + + return; + } + + contents->array[contents->used].used = 0; + } + // When content is found, the range->start is incremented, if content is found at range->stop, then range->start will be > range.stop. if (range->start >= range->stop || range->start >= buffer.used) { if (state->status == F_fss_found_object || state->status == F_fss_found_content || state->status == F_fss_found_content_not || state->status == F_fss_found_object_content_not) { - - if (state->status == F_fss_found_object_content_not) { - contents->array[contents->used].used = 0; - } - ++objects->used; ++contents->used; @@ -152,10 +134,6 @@ extern "C" { return; } - if (state->status == F_fss_found_object_content_not) { - contents->array[contents->used].used = 0; - } - ++objects->used; ++contents->used; diff --git a/level_2/fll_fss/c/fss/basic_list.c b/level_2/fll_fss/c/fss/basic_list.c index f3cb7a4..e7a65c4 100644 --- a/level_2/fll_fss/c/fss/basic_list.c +++ b/level_2/fll_fss/c/fss/basic_list.c @@ -36,20 +36,9 @@ extern "C" { if (range->start >= range->stop || range->start >= buffer.used) { if (state->status == F_fss_found_object || state->status == F_fss_found_object_content_not) { - ++objects->used; - - status = f_memory_array_increase(state->step_small, sizeof(f_range_t), (void **) &contents->array[contents->used].array, &contents->array[contents->used].used, &contents->array[contents->used].size); - - if (F_status_is_error(status)) { - state->status = status; - - return; - } - - contents->array[contents->used++].used = 0; state->status = F_fss_found_object_content_not; - return; + break; } if (state->status == F_data_not) return; @@ -66,7 +55,6 @@ extern "C" { if (state->status == F_fss_found_object) { found_data = F_true; - contents->array[contents->used].used = 0; fl_fss_basic_list_content_read(buffer, range, &contents->array[contents->used], contents_delimits ? contents_delimits : objects_delimits, comments, state); @@ -75,19 +63,7 @@ extern "C" { break; } - if (state->status == F_fss_found_object_content_not) { - found_data = F_true; - - status = f_memory_array_increase(state->step_small, sizeof(f_range_t), (void **) &contents->array[contents->used].array, &contents->array[contents->used].used, &contents->array[contents->used].size); - - if (F_status_is_error(status)) { - state->status = status; - - return; - } - - break; - } + if (state->status == F_fss_found_object_content_not) break; } while (state->status == F_fss_found_object_not); @@ -112,15 +88,24 @@ extern "C" { return; } + if (state->status == F_fss_found_object_content_not) { + found_data = F_true; + + status = f_memory_array_increase(state->step_small, sizeof(f_range_t), (void **) &contents->array[contents->used].array, &contents->array[contents->used].used, &contents->array[contents->used].size); + + if (F_status_is_error(status)) { + state->status = status; + + return; + } + + contents->array[contents->used].used = 0; + } + if (range->start >= range->stop || range->start >= buffer.used) { // When content is found, the range->start is incremented, if content is found at range->stop, then range->start will be > range.stop. if (state->status == F_fss_found_object || state->status == F_fss_found_content || state->status == F_fss_found_content_not || state->status == F_fss_found_object_content_not) { - - if (state->status == F_fss_found_object_content_not) { - contents->array[contents->used].used = 0; - } - ++objects->used; ++contents->used; } @@ -130,10 +115,6 @@ extern "C" { return; } - if (state->status == F_fss_found_object_content_not) { - contents->array[contents->used].used = 0; - } - ++objects->used; ++contents->used; diff --git a/level_2/fll_fss/c/fss/extended.c b/level_2/fll_fss/c/fss/extended.c index e610b35..6b83f21 100644 --- a/level_2/fll_fss/c/fss/extended.c +++ b/level_2/fll_fss/c/fss/extended.c @@ -55,27 +55,9 @@ extern "C" { if (range->start >= range->stop || range->start >= buffer.used) { if (state->status == F_fss_found_object || state->status == F_fss_found_object_content_not) { - ++objects->used; - - if (objects_quoted) { - ++objects_quoted->used; - } - - status = f_memory_array_increase(state->step_small, sizeof(f_range_t), (void **) &contents->array[contents->used].array, &contents->array[contents->used].used, &contents->array[contents->used].size); - if (F_status_is_error(status)) return; - - contents->array[contents->used++].used = 0; - - if (contents_quoted) { - status = f_memory_array_increase(state->step_small, sizeof(uint8_t), (void **) &contents_quoted->array[contents_quoted->used].array, &contents_quoted->array[contents_quoted->used].used, &contents_quoted->array[contents_quoted->used].size); - if (F_status_is_error(status)) return; - - contents_quoted->array[contents_quoted->used++].used = 0; - } - state->status = F_fss_found_object_content_not; - return; + break; } if (state->status == F_data_not) return; @@ -92,13 +74,9 @@ extern "C" { if (state->status == F_fss_found_object) { found_data = F_true; - contents->array[contents->used].used = 0; if (contents_quoted) { - state->status = f_memory_array_increase(state->step_small, sizeof(uint8_t), (void **) &contents_quoted->array[contents_quoted->used].array, &contents_quoted->array[contents_quoted->used].used, &contents_quoted->array[contents_quoted->used].size); - if (F_status_is_error(state->status)) return; - quoted_content = &contents_quoted->array[contents_quoted->used]; quoted_content->used = 0; } @@ -109,11 +87,7 @@ extern "C" { break; } - if (state->status == F_fss_found_object_content_not) { - found_data = F_true; - - break; - } + if (state->status == F_fss_found_object_content_not) break; } while (state->status == F_fss_found_object_not); @@ -147,15 +121,23 @@ extern "C" { return; } + if (state->status == F_fss_found_object_content_not) { + found_data = F_true; + contents->array[contents->used].used = 0; + + status = f_memory_array_increase(state->step_small, sizeof(f_range_t), (void **) &contents->array[contents->used].array, &contents->array[contents->used].used, &contents->array[contents->used].size); + + if (F_status_is_error(status)) { + state->status = status; + + return; + } + } + if (range->start >= range->stop || range->start >= buffer.used) { // When content is found, the range->start is incremented, if content is found at range->stop, then range->start will be > range.stop. if (state->status == F_fss_found_object || state->status == F_fss_found_content || state->status == F_fss_found_content_not || state->status == F_fss_found_object_content_not || state->status == F_end_not_group) { - - if (state->status == F_fss_found_object_content_not) { - contents->array[contents->used].used = 0; - } - ++objects->used; ++contents->used; @@ -179,10 +161,6 @@ extern "C" { return; } - if (state->status == F_fss_found_object_content_not) { - contents->array[contents->used].used = 0; - } - ++objects->used; ++contents->used; diff --git a/level_2/fll_fss/c/fss/extended_list.c b/level_2/fll_fss/c/fss/extended_list.c index ab2e4ab..c28d302 100644 --- a/level_2/fll_fss/c/fss/extended_list.c +++ b/level_2/fll_fss/c/fss/extended_list.c @@ -36,20 +36,9 @@ extern "C" { if (range->start >= range->stop || range->start >= buffer.used) { if (state->status == F_fss_found_object || state->status == F_fss_found_object_content_not) { - ++objects->used; - - status = f_memory_array_increase(state->step_small, sizeof(f_range_t), (void **) &contents->array[contents->used].array, &contents->array[contents->used].used, &contents->array[contents->used].size); - - if (F_status_is_error(state->status)) { - state->status = status; - - return; - } - - contents->array[contents->used++].used = 0; state->status = F_fss_found_object_content_not; - return; + break; } if (state->status == F_data_not) return; @@ -74,19 +63,7 @@ extern "C" { break; } - if (state->status == F_fss_found_object_content_not) { - found_data = F_true; - - status = f_memory_array_increase(state->step_small, sizeof(f_range_t), (void **) &contents->array[contents->used].array, &contents->array[contents->used].used, &contents->array[contents->used].size); - - if (F_status_is_error(status)) { - state->status = status; - - return; - } - - break; - } + if (state->status == F_fss_found_object_content_not) break; } while (state->status == F_fss_found_object_not); @@ -101,7 +78,7 @@ extern "C" { // If at least some valid object was found, then return F_okay equivalents. if (objects->used > initial_used) { - state->status = state->status == F_data_not_eos ? F_okay_eos : F_okay_stop; + state->status = (state->status == F_data_not_eos) ? F_okay_eos : F_okay_stop; } return; @@ -111,15 +88,24 @@ extern "C" { return; } + if (state->status == F_fss_found_object_content_not) { + found_data = F_true; + + status = f_memory_array_increase(state->step_small, sizeof(f_range_t), (void **) &contents->array[contents->used].array, &contents->array[contents->used].used, &contents->array[contents->used].size); + + if (F_status_is_error(status)) { + state->status = status; + + return; + } + + contents->array[contents->used].used = 0; + } + if (range->start >= range->stop || range->start >= buffer.used) { // When content is found, the range->start is incremented, if content is found at range->stop, then range->start will be > range.stop. if (state->status == F_fss_found_object || state->status == F_fss_found_content || state->status == F_fss_found_content_not || state->status == F_fss_found_object_content_not) { - - if (state->status == F_fss_found_object_content_not) { - contents->array[contents->used].used = 0; - } - ++objects->used; ++contents->used; } @@ -129,10 +115,6 @@ extern "C" { return; } - if (state->status == F_fss_found_object_content_not) { - contents->array[contents->used].used = 0; - } - ++objects->used; ++contents->used; diff --git a/level_2/fll_fss/c/fss/payload.c b/level_2/fll_fss/c/fss/payload.c index 8b90042..e26a444 100644 --- a/level_2/fll_fss/c/fss/payload.c +++ b/level_2/fll_fss/c/fss/payload.c @@ -16,10 +16,17 @@ extern "C" { } #endif // _di_level_2_parameter_checking_ + if (!buffer.used) { + state->status = F_data_not; + + return; + } + f_status_t status = F_okay; f_number_unsigned_t initial_used = objects->used; - bool found_data = F_false; + // 0x1 = found data, 0x2 = found payload object. + uint8_t found_data = 0; do { state->status = f_memory_array_increase(state->step_small, sizeof(f_range_t), (void **) &objects->array, &objects->used, &objects->size); @@ -34,40 +41,18 @@ extern "C" { fl_fss_basic_list_object_read(buffer, range, &objects->array[objects->used], objects_delimits, state); if (F_status_is_error(state->status)) return; + if (f_compare_dynamic_partial_string(f_fss_payload_s.string, buffer, f_fss_payload_s.used, objects->array[objects->used]) == F_equal_to) { + found_data |= 0x2; + } + if (range->start >= range->stop || range->start >= buffer.used) { if (state->status == F_fss_found_object || state->status == F_fss_found_object_content_not) { - if (f_compare_dynamic_partial_string(f_fss_payload_s.string, buffer, f_fss_payload_s.used, objects->array[objects->used]) == F_equal_to) { - state->status = F_fss_found_object_content_not; - } - - // Returning without a "payload" is an error. - else { - state->status = F_status_set_error(F_fss_found_object_content_not); - } - - ++objects->used; - - status = f_memory_array_increase(state->step_small, sizeof(f_range_t), (void **) &contents->array[contents->used].array, &contents->array[contents->used].used, &contents->array[contents->used].size); - - if (F_status_is_error(status)) { - state->status = status; - - return; - } - - contents->array[contents->used++].used = 0; - - return; - } + state->status = F_fss_found_object_content_not; - // Returning without a "payload" is an error. - if (state->status == F_data_not) { - state->status = F_status_set_error(F_data_not); - - return; + break; } - if (found_data) { + if (found_data & 0x1) { state->status = F_status_set_error((range->start >= buffer.used) ? F_okay_eos : F_okay_stop); } else { @@ -78,8 +63,7 @@ extern "C" { } if (state->status == F_fss_found_object) { - found_data = F_true; - + found_data |= 0x1; contents->array[contents->used].used = 0; if (f_compare_dynamic_partial_string(f_fss_payload_s.string, buffer, f_fss_payload_s.used, objects->array[objects->used]) == F_equal_to) { @@ -118,34 +102,7 @@ extern "C" { } if (state->status == F_fss_found_object_content_not) { - found_data = F_true; - - status = f_memory_array_increase(state->step_small, sizeof(f_range_t), (void **) &contents->array[contents->used].array, &contents->array[contents->used].used, &contents->array[contents->used].size); - - if (F_status_is_error(status)) { - state->status = status; - - return; - } - - contents->array[contents->used].used = 0; - - if (f_compare_dynamic_partial_string(f_fss_payload_s.string, buffer, f_fss_payload_s.used, objects->array[objects->used]) == F_equal_to) { - ++objects->used; - - status = f_memory_array_increase(state->step_small, sizeof(f_range_t), (void **) &contents->array[contents->used].array, &contents->array[contents->used].used, &contents->array[contents->used].size); - - if (F_status_is_error(status)) { - state->status = status; - - return; - } - - contents->array[contents->used++].used = 0; - state->status = F_okay; - - return; - } + found_data |= 0x1; break; } @@ -157,7 +114,9 @@ extern "C" { ++contents->used; // Returning without a "payload" is an error. - state->status = F_status_set_error(state->status); + if (!(found_data & 0x2)) { + state->status = F_status_set_error(state->status); + } return; } @@ -168,7 +127,12 @@ extern "C" { if (objects->used > initial_used) { // Returning without a "payload" is an error. - state->status = (state->status == F_data_not_eos) ? F_status_set_error(F_okay_eos) : F_status_set_error(F_okay_stop); + if (found_data & 0x2) { + state->status = (state->status == F_data_not_eos) ? F_okay_eos : F_okay_stop; + } + else { + state->status = F_status_set_error((state->status == F_data_not_eos) ? F_okay_eos : F_okay_stop); + } } else { state->status = F_status_set_error(state->status); @@ -181,29 +145,39 @@ extern "C" { return; } + if (state->status == F_fss_found_object_content_not) { + found_data |= 0x1; + + status = f_memory_array_increase(state->step_small, sizeof(f_range_t), (void **) &contents->array[contents->used].array, &contents->array[contents->used].used, &contents->array[contents->used].size); + + if (F_status_is_error(status)) { + state->status = status; + + return; + } + + contents->array[contents->used].used = 0; + } + if (range->start >= range->stop || range->start >= buffer.used) { // When content is found, the range->start is incremented, if content is found at range->stop, then range->start will be > range.stop. if (state->status == F_fss_found_object || state->status == F_fss_found_content || state->status == F_fss_found_content_not || state->status == F_fss_found_object_content_not) { - - if (state->status == F_fss_found_object_content_not) { - contents->array[contents->used].used = 0; - } - ++objects->used; ++contents->used; } // Returning without a "payload" is an error. - state->status = F_status_set_error((range->start >= buffer.used) ? F_okay_eos : F_okay_stop); + if (found_data & 0x2) { + state->status = (range->start >= buffer.used) ? F_okay_eos : F_okay_stop; + } + else { + state->status = F_status_set_error((range->start >= buffer.used) ? F_okay_eos : F_okay_stop); + } return; } - if (state->status == F_fss_found_object_content_not) { - contents->array[contents->used].used = 0; - } - ++objects->used; ++contents->used; diff --git a/level_2/fll_fss/c/fss/payload.h b/level_2/fll_fss/c/fss/payload.h index 2ba2d64..2b9e42b 100644 --- a/level_2/fll_fss/c/fss/payload.h +++ b/level_2/fll_fss/c/fss/payload.h @@ -33,7 +33,7 @@ extern "C" { * This processes only the outermost part and specially handles the payload. * The inner data, such as the fss-0001 inside of the "header", should be directly processed via the appropriate function. * - * The "payload" Object is required and if it is not file, this function returns with the error flag set. + * The "payload" Object is required and if it is not found, this function returns with the error flag set. * * @param buffer * The buffer to read from. @@ -72,11 +72,9 @@ extern "C" { * F_data_not_stop no data to read due start location being greater than stop location. * * F_fss_found_object_content_not (with error bit) When payload Content is missing. - * F_data_not_eos (with error bit) no data to read due start location being greater than or equal to buffer size, except that no "payload" is found. - * F_data_not_stop (with error bit) no data to read due start location being greater than stop location, except that no "payload" is found. * F_okay (with error bit) on success, except that no "payload" is found. - * F_okay_eos (with error bit) on success after reaching the end of the buffer, except that no "payload" is found. - * F_okay_stop (with error bit) on success after reaching stopping point, except that no "payload" is found. + * F_okay_eos (with error bit) on success, but no "payload" is found and start location is now greater than or equal to buffer size. + * F_okay_stop (with error bit) on success, but no "payload" is found and start location is now greater than stop location. * F_number_overflow (with error bit) if the maximum buffer size is reached. * F_parameter (with error bit) if a parameter is invalid. * diff --git a/level_3/fss_read/c/basic/fss_read.c b/level_3/fss_read/c/basic/fss_read.c index 14acecf..bf351a1 100644 --- a/level_3/fss_read/c/basic/fss_read.c +++ b/level_3/fss_read/c/basic/fss_read.c @@ -10,7 +10,7 @@ extern "C" { if (!void_main) return; - fss_read_basic_print_help(&((fss_read_main_t *) void_main)->program.message); + fss_read_basic_print_message_help(&((fss_read_main_t *) void_main)->program.message); } #endif // _di_fss_read_basic_process_help_ diff --git a/level_3/fss_read/c/basic/main.c b/level_3/fss_read/c/basic/main.c index 26c0f1f..04dc1b3 100644 --- a/level_3/fss_read/c/basic/main.c +++ b/level_3/fss_read/c/basic/main.c @@ -36,15 +36,16 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.callback.print_at = &fss_read_print_at; data.callback.print_content = &fss_read_print_content; + //data.callback.print_content_empty = 0; + data.callback.print_content_empty_set = &fss_read_print_content_empty_set_end; data.callback.print_content_ignore = 0; data.callback.print_content_next = 0; data.callback.print_object = &fss_read_print_object; - data.callback.print_object_end = &fss_read_basic_print_object_end; + data.callback.print_object_end = &fss_read_basic_print_data_object_end; data.callback.print_set_end = &fss_read_print_set_end; f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; data.program.parameters.array = parameters; - data.program.parameters.array[fss_read_parameter_as_e].flag |= f_console_flag_disable_e; data.program.parameters.used = fss_read_parameter_total_d; data.program.environment = envp; diff --git a/level_3/fss_read/c/basic/print.c b/level_3/fss_read/c/basic/print.c index 103dea4..83a5a82 100644 --- a/level_3/fss_read/c/basic/print.c +++ b/level_3/fss_read/c/basic/print.c @@ -4,8 +4,28 @@ extern "C" { #endif -#ifndef _di_fss_read_basic_print_help_ - f_status_t fss_read_basic_print_help(fl_print_t * const print) { +#ifndef _di_fss_read_basic_print_data_object_end_ + f_status_t fss_read_basic_print_data_object_end(fl_print_t * const print) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + + fss_read_main_t * const main = (fss_read_main_t *) print->custom; + + if (main->setting.flag & fss_read_main_flag_content_e) { + if (main->setting.flag & fss_read_main_flag_pipe_format_e) { + fll_print_dynamic_raw(fss_read_pipe_content_start_s, print->to); + } + else { + fll_print_dynamic_raw(f_fss_basic_open_s, print->to); + } + } + + return F_okay; + } +#endif // _di_fss_read_basic_print_data_object_end_ + +#ifndef _di_fss_read_basic_print_message_help_ + f_status_t fss_read_basic_print_message_help(fl_print_t * const print) { if (!print) return F_status_set_error(F_output_not); @@ -32,27 +52,7 @@ extern "C" { return F_okay; } -#endif // _di_fss_read_basic_print_help_ - -#ifndef _di_fss_read_basic_print_object_end_ - f_status_t fss_read_basic_print_object_end(fl_print_t * const print) { - - if (!print || !print->custom) return F_status_set_error(F_output_not); - - fss_read_main_t * const main = (fss_read_main_t *) print->custom; - - if (main->setting.flag & fss_read_main_flag_content_e) { - if (main->setting.flag & fss_read_main_flag_pipe_format_e) { - fll_print_dynamic_raw(fss_read_pipe_content_start_s, print->to); - } - else { - fll_print_dynamic_raw(f_fss_basic_open_s, print->to); - } - } - - return F_okay; - } -#endif // _di_fss_read_basic_print_object_end_ +#endif // _di_fss_read_basic_print_message_help_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/fss_read/c/basic/print.h b/level_3/fss_read/c/basic/print.h index c3e7932..e738351 100644 --- a/level_3/fss_read/c/basic/print.h +++ b/level_3/fss_read/c/basic/print.h @@ -13,46 +13,46 @@ extern "C" { #endif /** - * Print help for FSS-0000 (Basic). + * Print the end of an Object (which is often the start of Content). + * + * This locks, uses, and unlocks the file stream. * * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * * @return * F_okay on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if setting is NULL. + * F_output_not (with error bit) if a parameter is NULL. + * + * @see fll_print_dynamic_raw() */ -#ifndef _di_fss_read_basic_print_help_ - extern f_status_t fss_read_basic_print_help(fl_print_t * const print); -#endif // _di_fss_read_basic_print_help_ +#ifndef _di_fss_read_basic_print_data_object_end_ + extern f_status_t fss_read_basic_print_data_object_end(fl_print_t * const print); +#endif // _di_fss_read_basic_print_data_object_end_ /** - * Print the end of an Object (which is often the start of Content). - * - * This locks, uses, and unlocks the file stream. + * Print help for FSS-0000 (Basic). * * @param print * The output structure to print to. * - * The print.custom is expected to be of type fss_read_main_t. - * * This does not alter print.custom.setting.state.status. * * @return * F_okay on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if a parameter is NULL. - * - * @see fll_print_dynamic_raw() + * F_output_not (with error bit) if setting is NULL. */ -#ifndef _di_fss_read_basic_print_object_end_ - extern f_status_t fss_read_basic_print_object_end(fl_print_t * const print); -#endif // _di_fss_read_basic_print_object_end_ +#ifndef _di_fss_read_basic_print_message_help_ + extern f_status_t fss_read_basic_print_message_help(fl_print_t * const print); +#endif // _di_fss_read_basic_print_message_help_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/fss_read/c/basic_list/fss_read.c b/level_3/fss_read/c/basic_list/fss_read.c index 6d1f477..74dac22 100644 --- a/level_3/fss_read/c/basic_list/fss_read.c +++ b/level_3/fss_read/c/basic_list/fss_read.c @@ -10,7 +10,7 @@ extern "C" { if (!void_main) return; - fss_read_basic_list_print_help(&((fss_read_main_t *) void_main)->program.message); + fss_read_basic_list_print_message_help(&((fss_read_main_t *) void_main)->program.message); } #endif // _di_fss_read_basic_list_process_help_ diff --git a/level_3/fss_read/c/basic_list/main.c b/level_3/fss_read/c/basic_list/main.c index 412e07f..d928aa8 100644 --- a/level_3/fss_read/c/basic_list/main.c +++ b/level_3/fss_read/c/basic_list/main.c @@ -35,15 +35,16 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.callback.print_at = &fss_read_print_at; data.callback.print_content = &fss_read_print_content; + //data.callback.print_content_empty = 0; + data.callback.print_content_empty_set = 0; data.callback.print_content_ignore = &fss_read_print_content_ignore; data.callback.print_content_next = 0; data.callback.print_object = &fss_read_print_object; - data.callback.print_object_end = &fss_read_basic_list_print_object_end; + data.callback.print_object_end = &fss_read_basic_list_print_data_object_end; data.callback.print_set_end = &fss_read_print_set_end_no_eol; f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; data.program.parameters.array = parameters; - data.program.parameters.array[fss_read_parameter_as_e].flag |= f_console_flag_disable_e; data.program.parameters.used = fss_read_parameter_total_d; data.program.environment = envp; diff --git a/level_3/fss_read/c/basic_list/print.c b/level_3/fss_read/c/basic_list/print.c index 9e89e2d..9d55d95 100644 --- a/level_3/fss_read/c/basic_list/print.c +++ b/level_3/fss_read/c/basic_list/print.c @@ -4,8 +4,36 @@ extern "C" { #endif -#ifndef _di_fss_read_basic_list_print_help_ - f_status_t fss_read_basic_list_print_help(fl_print_t * const print) { +#ifndef _di_fss_read_basic_list_print_data_object_end_ + f_status_t fss_read_basic_list_print_data_object_end(fl_print_t * const print) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + + fss_read_main_t * const main = (fss_read_main_t *) print->custom; + + f_file_stream_lock(print->to); + + if (main->setting.flag & fss_read_main_flag_pipe_format_e) { + f_print_dynamic_raw(fss_read_pipe_content_start_s, print->to); + } + else { + if (main->setting.flag & fss_read_main_flag_content_e) { + f_print_dynamic_raw(f_fss_basic_list_open_s, print->to); + f_print_dynamic_raw(f_fss_basic_list_open_end_s, print->to); + } + else { + f_print_dynamic_raw(f_fss_eol_s, print->to); + } + } + + f_file_stream_unlock(print->to); + + return F_okay; + } +#endif // _di_fss_read_basic_list_print_data_object_end_ + +#ifndef _di_fss_read_basic_list_print_message_help_ + f_status_t fss_read_basic_list_print_message_help(fl_print_t * const print) { if (!print) return F_status_set_error(F_output_not); @@ -32,35 +60,7 @@ extern "C" { return F_okay; } -#endif // _di_fss_read_basic_list_print_help_ - -#ifndef _di_fss_read_basic_list_print_object_end_ - f_status_t fss_read_basic_list_print_object_end(fl_print_t * const print) { - - if (!print || !print->custom) return F_status_set_error(F_output_not); - - fss_read_main_t * const main = (fss_read_main_t *) print->custom; - - f_file_stream_lock(print->to); - - if (main->setting.flag & fss_read_main_flag_pipe_format_e) { - f_print_dynamic_raw(fss_read_pipe_content_start_s, print->to); - } - else { - if (main->setting.flag & fss_read_main_flag_content_e) { - f_print_dynamic_raw(f_fss_basic_list_open_s, print->to); - f_print_dynamic_raw(f_fss_basic_list_open_end_s, print->to); - } - else { - f_print_dynamic_raw(f_fss_eol_s, print->to); - } - } - - f_file_stream_unlock(print->to); - - return F_okay; - } -#endif // _di_fss_read_basic_list_print_object_end_ +#endif // _di_fss_read_basic_list_print_message_help_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/fss_read/c/basic_list/print.h b/level_3/fss_read/c/basic_list/print.h index 029055e..2a7ffa9 100644 --- a/level_3/fss_read/c/basic_list/print.h +++ b/level_3/fss_read/c/basic_list/print.h @@ -13,48 +13,48 @@ extern "C" { #endif /** - * Print help for FSS-0002 (Basic List). + * Print the end of an Object (which is often the start of Content). + * + * This locks, uses, and unlocks the file stream. * * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * * @return * F_okay on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if setting is NULL. + * F_output_not (with error bit) if a parameter is NULL. + * + * @see f_file_stream_lock() + * @see f_file_stream_unlock() + * @see f_print_dynamic_raw() */ -#ifndef _di_fss_read_basic_list_print_help_ - extern f_status_t fss_read_basic_list_print_help(fl_print_t * const print); -#endif // _di_fss_read_basic_list_print_help_ +#ifndef _di_fss_read_basic_list_print_data_object_end_ + extern f_status_t fss_read_basic_list_print_data_object_end(fl_print_t * const print); +#endif // _di_fss_read_basic_list_print_data_object_end_ /** - * Print the end of an Object (which is often the start of Content). - * - * This locks, uses, and unlocks the file stream. + * Print help for FSS-0002 (Basic List). * * @param print * The output structure to print to. * - * The print.custom is expected to be of type fss_read_main_t. - * * This does not alter print.custom.setting.state.status. * * @return * F_okay on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if a parameter is NULL. - * - * @see f_file_stream_lock() - * @see f_file_stream_unlock() - * @see f_print_dynamic_raw() + * F_output_not (with error bit) if setting is NULL. */ -#ifndef _di_fss_read_basic_list_print_object_end_ - extern f_status_t fss_read_basic_list_print_object_end(fl_print_t * const print); -#endif // _di_fss_read_basic_list_print_object_end_ +#ifndef _di_fss_read_basic_list_print_message_help_ + extern f_status_t fss_read_basic_list_print_message_help(fl_print_t * const print); +#endif // _di_fss_read_basic_list_print_message_help_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/fss_read/c/embedded_list/fss_read.c b/level_3/fss_read/c/embedded_list/fss_read.c index 326d306..34a8d86 100644 --- a/level_3/fss_read/c/embedded_list/fss_read.c +++ b/level_3/fss_read/c/embedded_list/fss_read.c @@ -10,7 +10,7 @@ extern "C" { if (!void_main) return; - fss_read_embedded_list_print_help(&((fss_read_main_t *) void_main)->program.message); + fss_read_embedded_list_print_message_help(&((fss_read_main_t *) void_main)->program.message); } #endif // _di_fss_read_embedded_list_process_help_ diff --git a/level_3/fss_read/c/embedded_list/main.c b/level_3/fss_read/c/embedded_list/main.c index 5f8e323..c1ff6f2 100644 --- a/level_3/fss_read/c/embedded_list/main.c +++ b/level_3/fss_read/c/embedded_list/main.c @@ -36,15 +36,16 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.callback.print_at = &fss_read_print_at; data.callback.print_content = &fss_read_print_content; + //data.callback.print_content_empty = 0; + data.callback.print_content_empty_set = 0; data.callback.print_content_ignore = &fss_read_print_content_ignore; data.callback.print_content_next = 0; data.callback.print_object = &fss_read_print_object; - data.callback.print_object_end = &fss_read_embedded_list_print_object_end; + data.callback.print_object_end = &fss_read_embedded_list_print_data_object_end; data.callback.print_set_end = &fss_read_print_set_end; f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; data.program.parameters.array = parameters; - data.program.parameters.array[fss_read_parameter_as_e].flag |= f_console_flag_disable_e; data.program.parameters.used = fss_read_parameter_total_d; data.program.environment = envp; diff --git a/level_3/fss_read/c/embedded_list/print.c b/level_3/fss_read/c/embedded_list/print.c index bdf29b5..3e1f7a8 100644 --- a/level_3/fss_read/c/embedded_list/print.c +++ b/level_3/fss_read/c/embedded_list/print.c @@ -4,38 +4,8 @@ extern "C" { #endif -#ifndef _di_fss_read_embedded_list_print_help_ - f_status_t fss_read_embedded_list_print_help(fl_print_t * const print) { - - if (!print) return F_status_set_error(F_output_not); - - f_file_stream_lock(print->to); - - fll_program_print_help_header(print, fss_read_embedded_list_program_name_long_s, fss_read_program_version_s); - - fss_read_print_message_help(print); - - f_print_dynamic_raw(f_string_eol_s, print->to); - - fll_program_print_help_usage(print, fss_read_embedded_list_program_name_s, f_string_empty_s); - - f_print_dynamic_raw(f_string_eol_s, print->to); - - fss_read_print_message_help_note_header(print, fss_read_format_code_short_0008_s, fss_read_format_code_name_0008_s); - - fss_read_print_message_help_pipe(print); - - fss_read_print_message_help_note(print, F_true); - - f_file_stream_flush(print->to); - f_file_stream_unlock(print->to); - - return F_okay; - } -#endif // _di_fss_read_embedded_list_print_help_ - -#ifndef _di_fss_read_embedded_list_print_object_end_ - f_status_t fss_read_embedded_list_print_object_end(fl_print_t * const print) { +#ifndef _di_fss_read_embedded_list_print_data_object_end_ + f_status_t fss_read_embedded_list_print_data_object_end(fl_print_t * const print) { if (!print || !print->custom) return F_status_set_error(F_output_not); @@ -60,10 +30,10 @@ extern "C" { return F_okay; } -#endif // _di_fss_read_embedded_list_print_object_end_ +#endif // _di_fss_read_embedded_list_print_data_object_end_ -#ifndef _di_fss_read_embedded_list_print_set_end_ - f_status_t fss_read_embedded_list_print_set_end(fl_print_t * const print) { +#ifndef _di_fss_read_embedded_list_print_data_set_end_ + f_status_t fss_read_embedded_list_print_data_set_end(fl_print_t * const print) { if (!print || !print->custom) return F_status_set_error(F_output_not); @@ -76,7 +46,37 @@ extern "C" { return F_okay; } -#endif // _di_fss_read_embedded_list_print_set_end_ +#endif // _di_fss_read_embedded_list_print_data_set_end_ + +#ifndef _di_fss_read_embedded_list_print_message_help_ + f_status_t fss_read_embedded_list_print_message_help(fl_print_t * const print) { + + if (!print) return F_status_set_error(F_output_not); + + f_file_stream_lock(print->to); + + fll_program_print_help_header(print, fss_read_embedded_list_program_name_long_s, fss_read_program_version_s); + + fss_read_print_message_help(print); + + f_print_dynamic_raw(f_string_eol_s, print->to); + + fll_program_print_help_usage(print, fss_read_embedded_list_program_name_s, f_string_empty_s); + + f_print_dynamic_raw(f_string_eol_s, print->to); + + fss_read_print_message_help_note_header(print, fss_read_format_code_short_0008_s, fss_read_format_code_name_0008_s); + + fss_read_print_message_help_pipe(print); + + fss_read_print_message_help_note(print, F_true); + + f_file_stream_flush(print->to); + f_file_stream_unlock(print->to); + + return F_okay; + } +#endif // _di_fss_read_embedded_list_print_message_help_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/fss_read/c/embedded_list/print.h b/level_3/fss_read/c/embedded_list/print.h index 4c62c4d..3afa41c 100644 --- a/level_3/fss_read/c/embedded_list/print.h +++ b/level_3/fss_read/c/embedded_list/print.h @@ -13,25 +13,33 @@ extern "C" { #endif /** - * Print help for FSS-0008 (Embedded List). + * Print the end of an Object (which is often the start of Content). + * + * This locks, uses, and unlocks the file stream. * * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * * @return * F_okay on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if setting is NULL. + * F_output_not (with error bit) if a parameter is NULL. + * + * @see f_file_stream_lock() + * @see f_file_stream_unlock() + * @see f_print_dynamic_raw() */ -#ifndef _di_fss_read_embedded_list_print_help_ - extern f_status_t fss_read_embedded_list_print_help(fl_print_t * const print); -#endif // _di_fss_read_embedded_list_print_help_ +#ifndef _di_fss_read_embedded_list_print_data_object_end_ + extern f_status_t fss_read_embedded_list_print_data_object_end(fl_print_t * const print); +#endif // _di_fss_read_embedded_list_print_data_object_end_ /** - * Print the end of an Object (which is often the start of Content). + * Print the end of an Object/Content set. * * This locks, uses, and unlocks the file stream. * @@ -52,35 +60,27 @@ extern "C" { * @see f_file_stream_unlock() * @see f_print_dynamic_raw() */ -#ifndef _di_fss_read_embedded_list_print_object_end_ - extern f_status_t fss_read_embedded_list_print_object_end(fl_print_t * const print); -#endif // _di_fss_read_embedded_list_print_object_end_ +#ifndef _di_fss_read_embedded_list_print_data_set_end_ + extern f_status_t fss_read_embedded_list_print_data_set_end(fl_print_t * const print); +#endif // _di_fss_read_embedded_list_print_data_set_end_ /** - * Print the end of an Object/Content set. - * - * This locks, uses, and unlocks the file stream. + * Print help for FSS-0008 (Embedded List). * * @param print * The output structure to print to. * - * The print.custom is expected to be of type fss_read_main_t. - * * This does not alter print.custom.setting.state.status. * * @return * F_okay on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if a parameter is NULL. - * - * @see f_file_stream_lock() - * @see f_file_stream_unlock() - * @see f_print_dynamic_raw() + * F_output_not (with error bit) if setting is NULL. */ -#ifndef _di_fss_read_embedded_list_print_set_end_ - extern f_status_t fss_read_embedded_list_print_set_end(fl_print_t * const print); -#endif // _di_fss_read_embedded_list_print_set_end_ +#ifndef _di_fss_read_embedded_list_print_message_help_ + extern f_status_t fss_read_embedded_list_print_message_help(fl_print_t * const print); +#endif // _di_fss_read_embedded_list_print_message_help_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/fss_read/c/extended/fss_read.c b/level_3/fss_read/c/extended/fss_read.c index 213add1..f78ef74 100644 --- a/level_3/fss_read/c/extended/fss_read.c +++ b/level_3/fss_read/c/extended/fss_read.c @@ -10,7 +10,7 @@ extern "C" { if (!void_main) return; - fss_read_extended_print_help(&((fss_read_main_t *) void_main)->program.message); + fss_read_extended_print_message_help(&((fss_read_main_t *) void_main)->program.message); } #endif // _di_fss_read_extended_process_help_ diff --git a/level_3/fss_read/c/extended/main.c b/level_3/fss_read/c/extended/main.c index 5cf0ed4..44940b5 100644 --- a/level_3/fss_read/c/extended/main.c +++ b/level_3/fss_read/c/extended/main.c @@ -36,15 +36,16 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.callback.print_at = &fss_read_print_at; data.callback.print_content = &fss_read_print_content; + //data.callback.print_content_empty = 0; + data.callback.print_content_empty_set = &fss_read_print_content_empty_set_end; data.callback.print_content_ignore = &fss_read_print_content_ignore; - data.callback.print_content_next = &fss_read_extended_print_content_next; + data.callback.print_content_next = &fss_read_extended_print_data_content_next; data.callback.print_object = &fss_read_print_object; - data.callback.print_object_end = &fss_read_extended_print_object_end; + data.callback.print_object_end = &fss_read_extended_print_data_object_end; data.callback.print_set_end = &fss_read_print_set_end; f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; data.program.parameters.array = parameters; - data.program.parameters.array[fss_read_parameter_as_e].flag |= f_console_flag_disable_e; data.program.parameters.used = fss_read_parameter_total_d; data.program.environment = envp; diff --git a/level_3/fss_read/c/extended/print.c b/level_3/fss_read/c/extended/print.c index 9cec070..5236b9c 100644 --- a/level_3/fss_read/c/extended/print.c +++ b/level_3/fss_read/c/extended/print.c @@ -4,8 +4,8 @@ extern "C" { #endif -#ifndef _di_fss_read_extended_print_content_next_ - f_status_t fss_read_extended_print_content_next(fl_print_t * const print) { +#ifndef _di_fss_read_extended_print_data_content_next_ + f_status_t fss_read_extended_print_data_content_next(fl_print_t * const print) { if (!print || !print->custom) return F_status_set_error(F_output_not); @@ -17,10 +17,30 @@ extern "C" { return F_okay; } -#endif // _di_fss_read_extended_print_content_next_ +#endif // _di_fss_read_extended_print_data_content_next_ -#ifndef _di_fss_read_extended_print_help_ - f_status_t fss_read_extended_print_help(fl_print_t * const print) { +#ifndef _di_fss_read_extended_print_data_object_end_ + f_status_t fss_read_extended_print_data_object_end(fl_print_t * const print) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + + fss_read_main_t * const main = (fss_read_main_t *) print->custom; + + if (main->setting.flag & fss_read_main_flag_content_e) { + if (main->setting.flag & fss_read_main_flag_pipe_format_e) { + fll_print_dynamic_raw(fss_read_pipe_content_start_s, print->to); + } + else { + fll_print_dynamic_raw(f_fss_extended_open_s, print->to); + } + } + + return F_okay; + } +#endif // _di_fss_read_extended_print_data_object_end_ + +#ifndef _di_fss_read_extended_print_message_help_ + f_status_t fss_read_extended_print_message_help(fl_print_t * const print) { if (!print) return F_status_set_error(F_output_not); @@ -47,27 +67,7 @@ extern "C" { return F_okay; } -#endif // _di_fss_read_extended_print_help_ - -#ifndef _di_fss_read_extended_print_object_end_ - f_status_t fss_read_extended_print_object_end(fl_print_t * const print) { - - if (!print || !print->custom) return F_status_set_error(F_output_not); - - fss_read_main_t * const main = (fss_read_main_t *) print->custom; - - if (main->setting.flag & fss_read_main_flag_content_e) { - if (main->setting.flag & fss_read_main_flag_pipe_format_e) { - fll_print_dynamic_raw(fss_read_pipe_content_start_s, print->to); - } - else { - fll_print_dynamic_raw(f_fss_extended_open_s, print->to); - } - } - - return F_okay; - } -#endif // _di_fss_read_extended_print_object_end_ +#endif // _di_fss_read_extended_print_message_help_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/fss_read/c/extended/print.h b/level_3/fss_read/c/extended/print.h index f8b10a2..e9b5197 100644 --- a/level_3/fss_read/c/extended/print.h +++ b/level_3/fss_read/c/extended/print.h @@ -34,51 +34,51 @@ extern "C" { * * @see fll_print_dynamic_raw() */ -#ifndef _di_fss_read_extended_print_content_next_ - extern f_status_t fss_read_extended_print_content_next(fl_print_t * const print); -#endif // _di_fss_read_extended_print_content_next_ +#ifndef _di_fss_read_extended_print_data_content_next_ + extern f_status_t fss_read_extended_print_data_content_next(fl_print_t * const print); +#endif // _di_fss_read_extended_print_data_content_next_ /** - * Print help for FSS-0001 (Extended). + * Print the end of an Object (which is often the start of Content). + * + * This locks, uses, and unlocks the file stream. * * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * * @return * F_okay on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if setting is NULL. + * F_output_not (with error bit) if a parameter is NULL. + * + * @see fll_print_dynamic_raw() */ -#ifndef _di_fss_read_extended_print_help_ - extern f_status_t fss_read_extended_print_help(fl_print_t * const print); -#endif // _di_fss_read_extended_print_help_ +#ifndef _di_fss_read_extended_print_data_object_end_ + extern f_status_t fss_read_extended_print_data_object_end(fl_print_t * const print); +#endif // _di_fss_read_extended_print_data_object_end_ /** - * Print the end of an Object (which is often the start of Content). - * - * This locks, uses, and unlocks the file stream. + * Print help for FSS-0001 (Extended). * * @param print * The output structure to print to. * - * The print.custom is expected to be of type fss_read_main_t. - * * This does not alter print.custom.setting.state.status. * * @return * F_okay on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if a parameter is NULL. - * - * @see fll_print_dynamic_raw() + * F_output_not (with error bit) if setting is NULL. */ -#ifndef _di_fss_read_extended_print_object_end_ - extern f_status_t fss_read_extended_print_object_end(fl_print_t * const print); -#endif // _di_fss_read_extended_print_object_end_ +#ifndef _di_fss_read_extended_print_message_help_ + extern f_status_t fss_read_extended_print_message_help(fl_print_t * const print); +#endif // _di_fss_read_extended_print_message_help_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/fss_read/c/extended_list/fss_read.c b/level_3/fss_read/c/extended_list/fss_read.c index adb75b2..825187c 100644 --- a/level_3/fss_read/c/extended_list/fss_read.c +++ b/level_3/fss_read/c/extended_list/fss_read.c @@ -10,7 +10,7 @@ extern "C" { if (!void_main) return; - fss_read_extended_list_print_help(&((fss_read_main_t *) void_main)->program.message); + fss_read_extended_list_print_message_help(&((fss_read_main_t *) void_main)->program.message); } #endif // _di_fss_read_extended_list_process_help_ diff --git a/level_3/fss_read/c/extended_list/main.c b/level_3/fss_read/c/extended_list/main.c index c6d3929..eafebe0 100644 --- a/level_3/fss_read/c/extended_list/main.c +++ b/level_3/fss_read/c/extended_list/main.c @@ -35,15 +35,16 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.callback.print_at = &fss_read_print_at; data.callback.print_content = &fss_read_print_content; + //data.callback.print_content_empty = 0; + data.callback.print_content_empty_set = 0; data.callback.print_content_ignore = &fss_read_print_content_ignore; data.callback.print_content_next = 0; data.callback.print_object = &fss_read_print_object; - data.callback.print_object_end = &fss_read_extended_list_print_object_end; - data.callback.print_set_end = &fss_read_extended_list_print_set_end; + data.callback.print_object_end = &fss_read_extended_list_print_data_object_end; + data.callback.print_set_end = &fss_read_extended_list_print_data_set_end; f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; data.program.parameters.array = parameters; - data.program.parameters.array[fss_read_parameter_as_e].flag |= f_console_flag_disable_e; data.program.parameters.used = fss_read_parameter_total_d; data.program.environment = envp; diff --git a/level_3/fss_read/c/extended_list/print.c b/level_3/fss_read/c/extended_list/print.c index f3c2fc0..ccf2afd 100644 --- a/level_3/fss_read/c/extended_list/print.c +++ b/level_3/fss_read/c/extended_list/print.c @@ -4,38 +4,8 @@ extern "C" { #endif -#ifndef _di_fss_read_extended_list_print_help_ - f_status_t fss_read_extended_list_print_help(fl_print_t * const print) { - - if (!print) return F_status_set_error(F_output_not); - - f_file_stream_lock(print->to); - - fll_program_print_help_header(print, fss_read_extended_list_program_name_long_s, fss_read_program_version_s); - - fss_read_print_message_help(print); - - f_print_dynamic_raw(f_string_eol_s, print->to); - - fll_program_print_help_usage(print, fss_read_extended_list_program_name_s, f_string_empty_s); - - f_print_dynamic_raw(f_string_eol_s, print->to); - - fss_read_print_message_help_note_header(print, fss_read_format_code_short_0003_s, fss_read_format_code_name_0003_s); - - fss_read_print_message_help_pipe(print); - - fss_read_print_message_help_note(print, F_true); - - f_file_stream_flush(print->to); - f_file_stream_unlock(print->to); - - return F_okay; - } -#endif // _di_fss_read_extended_list_print_help_ - -#ifndef _di_fss_read_extended_list_print_object_end_ - f_status_t fss_read_extended_list_print_object_end(fl_print_t * const print) { +#ifndef _di_fss_read_extended_list_print_data_object_end_ + f_status_t fss_read_extended_list_print_data_object_end(fl_print_t * const print) { if (!print || !print->custom) return F_status_set_error(F_output_not); @@ -60,10 +30,10 @@ extern "C" { return F_okay; } -#endif // _di_fss_read_extended_list_print_object_end_ +#endif // _di_fss_read_extended_list_print_data_object_end_ -#ifndef _di_fss_read_extended_list_print_set_end_ - f_status_t fss_read_extended_list_print_set_end(fl_print_t * const print) { +#ifndef _di_fss_read_extended_list_print_data_set_end_ + f_status_t fss_read_extended_list_print_data_set_end(fl_print_t * const print) { if (!print || !print->custom) return F_status_set_error(F_output_not); @@ -76,7 +46,37 @@ extern "C" { return F_okay; } -#endif // _di_fss_read_extended_list_print_set_end_ +#endif // _di_fss_read_extended_list_print_data_set_end_ + +#ifndef _di_fss_read_extended_list_print_message_help_ + f_status_t fss_read_extended_list_print_message_help(fl_print_t * const print) { + + if (!print) return F_status_set_error(F_output_not); + + f_file_stream_lock(print->to); + + fll_program_print_help_header(print, fss_read_extended_list_program_name_long_s, fss_read_program_version_s); + + fss_read_print_message_help(print); + + f_print_dynamic_raw(f_string_eol_s, print->to); + + fll_program_print_help_usage(print, fss_read_extended_list_program_name_s, f_string_empty_s); + + f_print_dynamic_raw(f_string_eol_s, print->to); + + fss_read_print_message_help_note_header(print, fss_read_format_code_short_0003_s, fss_read_format_code_name_0003_s); + + fss_read_print_message_help_pipe(print); + + fss_read_print_message_help_note(print, F_true); + + f_file_stream_flush(print->to); + f_file_stream_unlock(print->to); + + return F_okay; + } +#endif // _di_fss_read_extended_list_print_message_help_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/fss_read/c/extended_list/print.h b/level_3/fss_read/c/extended_list/print.h index bb30dc0..8aa3b0d 100644 --- a/level_3/fss_read/c/extended_list/print.h +++ b/level_3/fss_read/c/extended_list/print.h @@ -13,25 +13,31 @@ extern "C" { #endif /** - * Print help for FSS-0003 (Extended List). + * Print the end of an Object (which is often the start of Content). + * + * This locks, uses, and unlocks the file stream. * * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * * @return * F_okay on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if setting is NULL. + * F_output_not (with error bit) if a parameter is NULL. + * + * @see fll_print_dynamic_raw() */ -#ifndef _di_fss_read_extended_list_print_help_ - extern f_status_t fss_read_extended_list_print_help(fl_print_t * const print); -#endif // _di_fss_read_extended_list_print_help_ +#ifndef _di_fss_read_extended_list_print_data_object_end_ + extern f_status_t fss_read_extended_list_print_data_object_end(fl_print_t * const print); +#endif // _di_fss_read_extended_list_print_data_object_end_ /** - * Print the end of an Object (which is often the start of Content). + * Print the end of an Object/Content set. * * This locks, uses, and unlocks the file stream. * @@ -48,37 +54,31 @@ extern "C" { * * F_output_not (with error bit) if a parameter is NULL. * - * @see fll_print_dynamic_raw() + * @see f_file_stream_lock() + * @see f_file_stream_unlock() + * @see f_print_dynamic_raw() */ -#ifndef _di_fss_read_extended_list_print_object_end_ - extern f_status_t fss_read_extended_list_print_object_end(fl_print_t * const print); -#endif // _di_fss_read_extended_list_print_object_end_ +#ifndef _di_fss_read_extended_list_print_data_set_end_ + extern f_status_t fss_read_extended_list_print_data_set_end(fl_print_t * const print); +#endif // _di_fss_read_extended_list_print_data_set_end_ /** - * Print the end of an Object/Content set. - * - * This locks, uses, and unlocks the file stream. + * Print help for FSS-0003 (Extended List). * * @param print * The output structure to print to. * - * The print.custom is expected to be of type fss_read_main_t. - * * This does not alter print.custom.setting.state.status. * * @return * F_okay on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if a parameter is NULL. - * - * @see f_file_stream_lock() - * @see f_file_stream_unlock() - * @see f_print_dynamic_raw() + * F_output_not (with error bit) if setting is NULL. */ -#ifndef _di_fss_read_extended_list_print_set_end_ - extern f_status_t fss_read_extended_list_print_set_end(fl_print_t * const print); -#endif // _di_fss_read_extended_list_print_set_end_ +#ifndef _di_fss_read_extended_list_print_message_help_ + extern f_status_t fss_read_extended_list_print_message_help(fl_print_t * const print); +#endif // _di_fss_read_extended_list_print_message_help_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/fss_read/c/main/common.c b/level_3/fss_read/c/main/common.c index cd4862c..8a410c7 100644 --- a/level_3/fss_read/c/main/common.c +++ b/level_3/fss_read/c/main/common.c @@ -316,7 +316,7 @@ extern "C" { return; } - if (f_compare_dynamic(fss_read_delimit_mode_name_none_s, parameters->arguments.array[index]) == F_equal_to) { + if (f_compare_dynamic(fss_read_string_none_s, parameters->arguments.array[index]) == F_equal_to) { main->setting.delimit_mode = fss_read_delimit_mode_none_e; } else if (f_compare_dynamic(fss_read_delimit_mode_name_all_s, parameters->arguments.array[index]) == F_equal_to) { diff --git a/level_3/fss_read/c/main/common/enumeration.h b/level_3/fss_read/c/main/common/enumeration.h index 59695ba..5bd7227 100644 --- a/level_3/fss_read/c/main/common/enumeration.h +++ b/level_3/fss_read/c/main/common/enumeration.h @@ -39,6 +39,9 @@ extern "C" { * - object_as_line: The Object is counted as its own line for the purpose of -l/--line or any other similar behavior. * - object_trim: Empty space before an after Objects are ignored while processing without affecting printing behavior. * - original: Enable original printing, where the quotes are printed and no delimits are applied. + * - payload_create: Create the payload Object with empty Content if the payload Object is missing (when using FSS Payload and related). + * - payload_error: Treat missing or invalid payload as an error (when using FSS Payload and related). + * - payload_warn: Treat missing or invalid payload as a warning (when using FSS Payload and related). * - pipe: Use the input pipe. * - pipe_format: Print using the special pipe format. * - print_first: When set, print new line to message output on program begin after loading settings. @@ -72,17 +75,20 @@ extern "C" { fss_read_main_flag_object_as_line_e = 0x8000, fss_read_main_flag_object_trim_e = 0x10000, fss_read_main_flag_original_e = 0x20000, - fss_read_main_flag_pipe_e = 0x40000, - fss_read_main_flag_pipe_format_e = 0x80000, - fss_read_main_flag_print_first_e = 0x100000, - fss_read_main_flag_print_last_e = 0x200000, - fss_read_main_flag_quote_content_e = 0x400000, - fss_read_main_flag_quote_object_e = 0x800000, - fss_read_main_flag_select_e = 0x1000000, - fss_read_main_flag_total_e = 0x2000000, - fss_read_main_flag_trim_e = 0x4000000, - fss_read_main_flag_trim_object_e = 0x8000000, - fss_read_main_flag_version_e = 0x10000000, + fss_read_main_flag_payload_create_e = 0x40000, + fss_read_main_flag_payload_error_e = 0x80000, + fss_read_main_flag_payload_warn_e = 0x100000, + fss_read_main_flag_pipe_e = 0x200000, + fss_read_main_flag_pipe_format_e = 0x400000, + fss_read_main_flag_print_first_e = 0x800000, + fss_read_main_flag_print_last_e = 0x1000000, + fss_read_main_flag_quote_content_e = 0x2000000, + fss_read_main_flag_quote_object_e = 0x4000000, + fss_read_main_flag_select_e = 0x8000000, + fss_read_main_flag_total_e = 0x10000000, + fss_read_main_flag_trim_e = 0x20000000, + fss_read_main_flag_trim_object_e = 0x40000000, + fss_read_main_flag_version_e = 0x80000000, }; // enum #endif // _di_fss_read_main_flag_e_ @@ -101,6 +107,7 @@ extern "C" { fss_read_parameter_line_e, fss_read_parameter_name_e, fss_read_parameter_object_e, + fss_read_parameter_payload_e, fss_read_parameter_pipe_e, fss_read_parameter_original_e, fss_read_parameter_select_e, @@ -112,7 +119,7 @@ extern "C" { { \ macro_fll_program_console_parameter_standard_initialize, \ \ - macro_f_console_parameter_t_initialize_3(fss_read_short_as_s, fss_read_long_as_s, 1, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_3(fss_read_short_as_s, fss_read_long_as_s, 1, f_console_flag_normal_e | f_console_flag_disable_e), \ macro_f_console_parameter_t_initialize_3(fss_read_short_at_s, fss_read_long_at_s, 1, f_console_flag_normal_e), \ macro_f_console_parameter_t_initialize_3(fss_read_short_content_s, fss_read_long_content_s, 0, f_console_flag_normal_e), \ macro_f_console_parameter_t_initialize_3(fss_read_short_columns_s, fss_read_long_columns_s, 0, f_console_flag_normal_e), \ @@ -122,6 +129,7 @@ extern "C" { macro_f_console_parameter_t_initialize_3(fss_read_short_line_s, fss_read_long_line_s, 1, f_console_flag_normal_e), \ macro_f_console_parameter_t_initialize_3(fss_read_short_name_s, fss_read_long_name_s, 1, f_console_flag_normal_e), \ macro_f_console_parameter_t_initialize_3(fss_read_short_object_s, fss_read_long_object_s, 0, f_console_flag_normal_e), \ + macro_f_console_parameter_t_initialize_5( fss_read_long_payload_s, 1, f_console_flag_normal_e | f_console_flag_disable_e), \ macro_f_console_parameter_t_initialize_3(fss_read_short_pipe_s, fss_read_long_pipe_s, 0, f_console_flag_normal_e), \ macro_f_console_parameter_t_initialize_3(fss_read_short_original_s, fss_read_long_original_s, 0, f_console_flag_normal_e), \ macro_f_console_parameter_t_initialize_3(fss_read_short_select_s, fss_read_long_select_s, 1, f_console_flag_normal_e), \ @@ -129,7 +137,7 @@ extern "C" { macro_f_console_parameter_t_initialize_3(fss_read_short_trim_s, fss_read_long_trim_s, 0, f_console_flag_normal_e), \ } - #define fss_read_parameter_total_d 28 + #define fss_read_parameter_total_d 29 #endif // _di_fss_read_parameter_e_ /** diff --git a/level_3/fss_read/c/main/common/print.c b/level_3/fss_read/c/main/common/print.c index befaa41..c43a7ae 100644 --- a/level_3/fss_read/c/main/common/print.c +++ b/level_3/fss_read/c/main/common/print.c @@ -7,6 +7,7 @@ extern "C" { #ifndef _di_fss_read_f_a_ const f_string_t fss_read_f_a[] = { "f_console_parameter_process", + "f_console_parameter_reset", "f_file_read_block", "f_file_size", "f_file_stream_open", diff --git a/level_3/fss_read/c/main/common/print.h b/level_3/fss_read/c/main/common/print.h index 12aad9e..92e3932 100644 --- a/level_3/fss_read/c/main/common/print.h +++ b/level_3/fss_read/c/main/common/print.h @@ -40,6 +40,7 @@ extern "C" { #ifndef _di_fss_read_f_e_ enum { fss_read_f_f_console_parameter_process_e, + fss_read_f_f_console_parameter_reset_e, fss_read_f_f_file_read_block_e, fss_read_f_f_file_size_e, fss_read_f_f_file_stream_open_e, diff --git a/level_3/fss_read/c/main/common/string.c b/level_3/fss_read/c/main/common/string.c index 987a896..80bf4b5 100644 --- a/level_3/fss_read/c/main/common/string.c +++ b/level_3/fss_read/c/main/common/string.c @@ -20,11 +20,14 @@ extern "C" { #endif // _di_fss_read_pipe_s_ #ifndef _di_fss_read_s_ + const f_string_static_t fss_read_string_create_s = macro_f_string_static_t_initialize_1(FSS_READ_string_create_s, 0, FSS_READ_string_create_s_length); + const f_string_static_t fss_read_string_error_s = macro_f_string_static_t_initialize_1(FSS_READ_string_error_s, 0, FSS_READ_string_error_s_length); + const f_string_static_t fss_read_string_none_s = macro_f_string_static_t_initialize_1(FSS_READ_string_none_s, 0, FSS_READ_string_none_s_length); const f_string_static_t fss_read_string_two_s = macro_f_string_static_t_initialize_1(FSS_READ_string_two_s, 0, FSS_READ_string_two_s_length); + const f_string_static_t fss_read_string_warn_s = macro_f_string_static_t_initialize_1(FSS_READ_string_warn_s, 0, FSS_READ_string_warn_s_length); #endif // _di_fss_read_s_ #ifndef _di_fss_read_delimit_mode_s_ - const f_string_static_t fss_read_delimit_mode_name_none_s = macro_f_string_static_t_initialize_1(FSS_READ_delimit_mode_name_none_s, 0, FSS_READ_delimit_mode_name_none_s_length); const f_string_static_t fss_read_delimit_mode_name_all_s = macro_f_string_static_t_initialize_1(FSS_READ_delimit_mode_name_all_s, 0, FSS_READ_delimit_mode_name_all_s_length); const f_string_static_t fss_read_delimit_mode_name_object_s = macro_f_string_static_t_initialize_1(FSS_READ_delimit_mode_name_object_s, 0, FSS_READ_delimit_mode_name_object_s_length); const f_string_static_t fss_read_delimit_mode_name_greater_s = macro_f_string_static_t_initialize_1(FSS_READ_delimit_mode_name_greater_s, 0, FSS_READ_delimit_mode_name_greater_s_length); @@ -58,6 +61,7 @@ extern "C" { const f_string_static_t fss_read_long_line_s = macro_f_string_static_t_initialize_1(FSS_READ_long_line_s, 0, FSS_READ_long_line_s_length); const f_string_static_t fss_read_long_name_s = macro_f_string_static_t_initialize_1(FSS_READ_long_name_s, 0, FSS_READ_long_name_s_length); const f_string_static_t fss_read_long_object_s = macro_f_string_static_t_initialize_1(FSS_READ_long_object_s, 0, FSS_READ_long_object_s_length); + const f_string_static_t fss_read_long_payload_s = macro_f_string_static_t_initialize_1(FSS_READ_long_payload_s, 0, FSS_READ_long_payload_s_length); const f_string_static_t fss_read_long_pipe_s = macro_f_string_static_t_initialize_1(FSS_READ_long_pipe_s, 0, FSS_READ_long_pipe_s_length); const f_string_static_t fss_read_long_original_s = macro_f_string_static_t_initialize_1(FSS_READ_long_original_s, 0, FSS_READ_long_original_s_length); const f_string_static_t fss_read_long_select_s = macro_f_string_static_t_initialize_1(FSS_READ_long_select_s, 0, FSS_READ_long_select_s_length); diff --git a/level_3/fss_read/c/main/common/string.h b/level_3/fss_read/c/main/common/string.h index 154ea9a..e265147 100644 --- a/level_3/fss_read/c/main/common/string.h +++ b/level_3/fss_read/c/main/common/string.h @@ -92,11 +92,23 @@ extern "C" { * A collection of static strings associated with FSS Read. */ #ifndef _di_fss_read_s_ - #define FSS_READ_string_two_s "two" - - #define FSS_READ_string_two_s_length 3 - + #define FSS_READ_string_create_s "create" + #define FSS_READ_string_error_s "error" + #define FSS_READ_string_none_s "none" + #define FSS_READ_string_two_s "two" + #define FSS_READ_string_warn_s "warn" + + #define FSS_READ_string_create_s_length 6 + #define FSS_READ_string_error_s_length 5 + #define FSS_READ_string_none_s_length 4 + #define FSS_READ_string_two_s_length 3 + #define FSS_READ_string_warn_s_length 4 + + extern const f_string_static_t fss_read_string_create_s; + extern const f_string_static_t fss_read_string_error_s; + extern const f_string_static_t fss_read_string_none_s; extern const f_string_static_t fss_read_string_two_s; + extern const f_string_static_t fss_read_string_warn_s; #endif // _di_fss_read_s_ /** @@ -113,19 +125,16 @@ extern "C" { * - object: Objects arre to have delimits applied. */ #ifndef _di_fss_read_delimit_mode_s_ - #define FSS_READ_delimit_mode_name_none_s "none" #define FSS_READ_delimit_mode_name_all_s "all" #define FSS_READ_delimit_mode_name_object_s "object" #define FSS_READ_delimit_mode_name_greater_s "+" #define FSS_READ_delimit_mode_name_lesser_s "-" - #define FSS_READ_delimit_mode_name_none_s_length 4 #define FSS_READ_delimit_mode_name_all_s_length 3 #define FSS_READ_delimit_mode_name_object_s_length 6 #define FSS_READ_delimit_mode_name_greater_s_length 1 #define FSS_READ_delimit_mode_name_lesser_s_length 1 - extern const f_string_static_t fss_read_delimit_mode_name_none_s; extern const f_string_static_t fss_read_delimit_mode_name_all_s; extern const f_string_static_t fss_read_delimit_mode_name_object_s; extern const f_string_static_t fss_read_delimit_mode_name_greater_s; @@ -162,6 +171,7 @@ extern "C" { #define FSS_READ_long_line_s "line" #define FSS_READ_long_name_s "name" #define FSS_READ_long_object_s "object" + #define FSS_READ_long_payload_s "payload" #define FSS_READ_long_pipe_s "pipe" #define FSS_READ_long_original_s "original" #define FSS_READ_long_select_s "select" @@ -194,6 +204,7 @@ extern "C" { #define FSS_READ_long_line_s_length 4 #define FSS_READ_long_name_s_length 4 #define FSS_READ_long_object_s_length 6 + #define FSS_READ_long_payload_s_length 7 #define FSS_READ_long_pipe_s_length 4 #define FSS_READ_long_original_s_length 8 #define FSS_READ_long_select_s_length 6 @@ -226,6 +237,7 @@ extern "C" { extern const f_string_static_t fss_read_long_line_s; extern const f_string_static_t fss_read_long_name_s; extern const f_string_static_t fss_read_long_object_s; + extern const f_string_static_t fss_read_long_payload_s; extern const f_string_static_t fss_read_long_pipe_s; extern const f_string_static_t fss_read_long_original_s; extern const f_string_static_t fss_read_long_select_s; diff --git a/level_3/fss_read/c/main/common/type.h b/level_3/fss_read/c/main/common/type.h index c31643c..3fe6b37 100644 --- a/level_3/fss_read/c/main/common/type.h +++ b/level_3/fss_read/c/main/common/type.h @@ -128,13 +128,15 @@ extern "C" { * process_name: Process name parameter, usually called by the process_normal() callback. * process_total: Process total parameter, usually called by the process_normal() callback. * - * print_at: Print at the given location, usually called by the process_normal() callback. - * print_object: Print the Object, usually called by the process_normal() callback. - * print_content: Print the Content, usually called by the process_normal() callback. - * print_content_ignore: Print the Content ignore character, usually called by several callbacks within the process_normal() callback for a pipe. - * print_content_next: Print the Content next (content separator), usually called by several callbacks within the process_normal() callback. - * print_object_end: Print the Object end, usually called by several callbacks within the process_normal() callback. - * print_set_end: Print the Content set end, usually called by several callbacks within the process_normal() callback. + * print_at: Print at the given location, usually called by the process_normal() callback. + * print_object: Print the Object, usually called by the process_normal() callback. + * print_content: Print the Content, usually called by the process_normal() callback. + * print_content_empty: Print something when the individual Content is empty (this is not about the Content set). + * print_content_empty_set: Print something when the entire Content set is empty for the entire Content set. + * print_content_ignore: Print the Content ignore character, usually called by several callbacks within the process_normal() callback for a pipe. + * print_content_next: Print the Content next (content separator), usually called by several callbacks within the process_normal() callback. + * print_object_end: Print the Object end, usually called by several callbacks within the process_normal() callback. + * print_set_end: Print the Content set end, usually called by several callbacks within the process_normal() callback. */ #ifndef _di_fss_read_callback_t_ typedef struct { @@ -152,6 +154,8 @@ extern "C" { f_status_t (*print_at)(fl_print_t * const print, const f_number_unsigned_t at, const f_number_unsigneds_t delimits_object, const f_number_unsigneds_t delimits_content); f_status_t (*print_object)(fl_print_t * const print, const f_number_unsigned_t at, const f_number_unsigneds_t delimits); f_status_t (*print_content)(fl_print_t * const print, const f_range_t range, const uint8_t quote, const f_number_unsigneds_t delimits); + //f_status_t (*print_content_empty)(fl_print_t * const print); + f_status_t (*print_content_empty_set)(fl_print_t * const print); f_status_t (*print_content_ignore)(fl_print_t * const print); f_status_t (*print_content_next)(fl_print_t * const print); f_status_t (*print_object_end)(fl_print_t * const print); @@ -176,6 +180,7 @@ extern "C" { 0, \ 0, \ 0, \ + 0, \ } #endif // _di_fss_read_callback_t_ diff --git a/level_3/fss_read/c/main/main.c b/level_3/fss_read/c/main/main.c index 0594054..ce7fece 100644 --- a/level_3/fss_read/c/main/main.c +++ b/level_3/fss_read/c/main/main.c @@ -28,6 +28,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; data.program.parameters.array = parameters; + data.program.parameters.array[fss_read_parameter_as_e].flag &= ~f_console_flag_disable_e; data.program.parameters.used = fss_read_parameter_total_d; data.program.environment = envp; @@ -87,7 +88,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { if (!void_main) return; - fss_read_main_print_help(&((fss_read_main_t *) void_main)->program.message); + fss_read_main_print_message_help(&((fss_read_main_t *) void_main)->program.message); } #endif // _di_fss_read_main_process_help_ @@ -96,6 +97,7 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { if (!main || F_status_is_error(main->setting.state.status) || (main->setting.flag & fss_read_main_flag_version_e)) return; + // Use the default standard of: FSS-0000 (Basic) main->callback.process_help = &fss_read_main_process_help; main->callback.process_last_line = &fss_read_process_last_line; main->callback.process_normal = &fss_read_process_normal; @@ -103,14 +105,20 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->callback.process_at = &fss_read_process_normal_at; main->callback.process_at_line = &fss_read_process_normal_at_line; main->callback.process_columns = &fss_read_process_normal_columns; + main->callback.process_load = &fss_read_basic_process_load; main->callback.process_name = &fss_read_process_normal_name; + main->callback.process_total = &fss_read_process_normal_total; main->callback.print_at = &fss_read_print_at; main->callback.print_content = &fss_read_print_content; - main->callback.print_content_ignore = &fss_read_print_content_ignore; + //main->callback.print_content_empty = 0; + main->callback.print_content_empty_set = &fss_read_print_content_empty_set_end; + main->callback.print_content_ignore = 0; + main->callback.print_content_next = 0; main->callback.print_object = &fss_read_print_object; + main->callback.print_object_end = &fss_read_basic_print_data_object_end; + main->callback.print_set_end = &fss_read_print_set_end; - // Setup default standard (except for process_help): FSS-0000 (Basic). main->setting.standard = fss_read_basic_standard_s; main->setting.flag &= ~fss_read_main_flag_content_has_close_e; @@ -118,201 +126,266 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { main->setting.flag &= ~fss_read_main_flag_depth_multiple_e; main->setting.flag &= ~fss_read_main_flag_object_as_line_e; main->setting.flag &= ~fss_read_main_flag_object_trim_e; + main->setting.flag &= ~fss_read_main_flag_payload_error_e; + main->setting.flag &= ~fss_read_main_flag_payload_warn_e; main->setting.flag &= ~fss_read_main_flag_trim_object_e; main->setting.flag |= fss_read_main_flag_line_single_e; main->setting.flag |= fss_read_main_flag_quote_content_e | fss_read_main_flag_quote_object_e; - main->setting.flag |= fss_read_main_flag_line_single_e; - main->setting.flag |= fss_read_main_flag_quote_content_e | fss_read_main_flag_quote_object_e; - - main->callback.process_load = &fss_read_basic_process_load; - main->callback.process_total = &fss_read_process_normal_total; - - main->callback.print_content_next = 0; - main->callback.print_object_end = &fss_read_basic_print_object_end; - main->callback.print_set_end = &fss_read_print_set_end; - if (main->program.parameters.array[fss_read_parameter_as_e].result & f_console_result_value_e && main->program.parameters.array[fss_read_parameter_as_e].values.used) { + const f_number_unsigned_t index = main->program.parameters.array[fss_read_parameter_as_e].values.array[main->program.parameters.array[fss_read_parameter_as_e].values.used - 1]; + const f_string_static_t as = main->program.parameters.arguments.array[index]; + + if (f_compare_dynamic(as, fss_read_format_code_short_0000_s) == F_equal_to || + f_compare_dynamic(as, fss_read_format_code_long_0000_s) == F_equal_to || + f_compare_dynamic(as, fss_read_format_code_human_0000_s) == F_equal_to || + f_compare_dynamic(as, fss_read_format_code_machine_0000_s) == F_equal_to) { + + main->setting.standard = fss_read_basic_standard_s; + + // Remove flags not supported for this standard. + main->setting.flag &= ~fss_read_main_flag_content_has_close_e; + main->setting.flag &= ~fss_read_main_flag_content_multiple_e; + main->setting.flag &= ~fss_read_main_flag_depth_multiple_e; + main->setting.flag &= ~fss_read_main_flag_object_as_line_e; + main->setting.flag &= ~fss_read_main_flag_object_trim_e; + main->setting.flag &= ~fss_read_main_flag_payload_error_e; + main->setting.flag &= ~fss_read_main_flag_payload_warn_e; + main->setting.flag &= ~fss_read_main_flag_trim_object_e; + + main->setting.flag |= fss_read_main_flag_line_single_e; + main->setting.flag |= fss_read_main_flag_quote_content_e | fss_read_main_flag_quote_object_e; + + main->program.parameters.array[fss_read_parameter_payload_e].flag |= f_console_flag_disable_e; + + main->callback.process_help = &fss_read_basic_process_help; + main->callback.process_load = &fss_read_basic_process_load; + main->callback.process_total = &fss_read_process_normal_total; + + main->callback.print_content = &fss_read_print_content; + //main->callback.print_content_empty = 0; + main->callback.print_content_empty_set = &fss_read_print_content_empty_set_end; + main->callback.print_content_ignore = 0; + main->callback.print_content_next = 0; + main->callback.print_object = &fss_read_print_object; + main->callback.print_object_end = &fss_read_basic_print_data_object_end; + main->callback.print_set_end = &fss_read_print_set_end; + } + else if (f_compare_dynamic(as, fss_read_format_code_short_0001_s) == F_equal_to || + f_compare_dynamic(as, fss_read_format_code_long_0001_s) == F_equal_to || + f_compare_dynamic(as, fss_read_format_code_human_0001_s) == F_equal_to || + f_compare_dynamic(as, fss_read_format_code_machine_0001_s) == F_equal_to) { + + main->setting.standard = fss_read_extended_standard_s; + + // Remove flags not supported for this standard. + main->setting.flag &= ~fss_read_main_flag_content_has_close_e; + main->setting.flag &= ~fss_read_main_flag_depth_multiple_e; + main->setting.flag &= ~fss_read_main_flag_object_as_line_e; + main->setting.flag &= ~fss_read_main_flag_object_trim_e; + main->setting.flag &= ~fss_read_main_flag_payload_error_e; + main->setting.flag &= ~fss_read_main_flag_payload_warn_e; + main->setting.flag &= ~fss_read_main_flag_trim_object_e; + + main->setting.flag |= fss_read_main_flag_line_single_e | fss_read_main_flag_content_multiple_e; + main->setting.flag |= fss_read_main_flag_quote_content_e | fss_read_main_flag_quote_object_e; + + main->program.parameters.array[fss_read_parameter_payload_e].flag |= f_console_flag_disable_e; + + main->callback.process_help = &fss_read_extended_process_help; + main->callback.process_load = &fss_read_extended_process_load; + main->callback.process_total = &fss_read_process_normal_total; + + //main->callback.print_content_empty = 0; + main->callback.print_content_empty_set = &fss_read_print_content_empty_set_end; + main->callback.print_content_next = &fss_read_extended_print_data_content_next; + main->callback.print_object_end = &fss_read_extended_print_data_object_end; + main->callback.print_set_end = &fss_read_print_set_end; + } + else if (f_compare_dynamic(as, fss_read_format_code_short_0002_s) == F_equal_to || + f_compare_dynamic(as, fss_read_format_code_long_0002_s) == F_equal_to || + f_compare_dynamic(as, fss_read_format_code_human_0002_s) == F_equal_to || + f_compare_dynamic(as, fss_read_format_code_machine_0002_s) == F_equal_to) { + + main->setting.standard = fss_read_basic_list_standard_s; + + // Remove flags not supported for this standard. + main->setting.flag &= ~fss_read_main_flag_content_has_close_e; + main->setting.flag &= ~fss_read_main_flag_content_multiple_e; + main->setting.flag &= ~fss_read_main_flag_depth_multiple_e; + main->setting.flag &= ~fss_read_main_flag_line_single_e; + main->setting.flag &= ~fss_read_main_flag_payload_error_e; + main->setting.flag &= ~fss_read_main_flag_payload_warn_e; + main->setting.flag &= ~fss_read_main_flag_quote_content_e; + main->setting.flag &= ~fss_read_main_flag_quote_object_e; + + main->setting.flag |= fss_read_main_flag_object_as_line_e | fss_read_main_flag_object_trim_e; + + main->program.parameters.array[fss_read_parameter_payload_e].flag |= f_console_flag_disable_e; + + main->callback.process_help = &fss_read_basic_list_process_help; + main->callback.process_load = &fss_read_basic_list_process_load; + main->callback.process_total = &fss_read_process_normal_total_multiple; + + //main->callback.print_content_empty = 0; + main->callback.print_content_empty_set = 0; + main->callback.print_content_next = 0; + main->callback.print_object_end = &fss_read_basic_list_print_data_object_end; + main->callback.print_set_end = &fss_read_print_set_end_no_eol; + } + else if (f_compare_dynamic(as, fss_read_format_code_short_0003_s) == F_equal_to || + f_compare_dynamic(as, fss_read_format_code_long_0003_s) == F_equal_to || + f_compare_dynamic(as, fss_read_format_code_human_0003_s) == F_equal_to || + f_compare_dynamic(as, fss_read_format_code_machine_0003_s) == F_equal_to) { + + main->setting.standard = fss_read_extended_list_standard_s; + + // Remove flags not supported for this standard. + main->setting.flag &= ~fss_read_main_flag_line_single_e; + main->setting.flag &= ~fss_read_main_flag_content_multiple_e; + main->setting.flag &= ~fss_read_main_flag_depth_multiple_e; + main->setting.flag &= ~fss_read_main_flag_payload_error_e; + main->setting.flag &= ~fss_read_main_flag_payload_warn_e; + main->setting.flag &= ~fss_read_main_flag_quote_content_e; + main->setting.flag &= ~fss_read_main_flag_quote_object_e; + + main->setting.flag |= fss_read_main_flag_content_has_close_e; + main->setting.flag |= fss_read_main_flag_object_as_line_e | fss_read_main_flag_object_trim_e; + + main->program.parameters.array[fss_read_parameter_payload_e].flag |= f_console_flag_disable_e; + + main->callback.process_help = &fss_read_extended_list_process_help; + main->callback.process_load = &fss_read_extended_list_process_load; + main->callback.process_total = &fss_read_process_normal_total_multiple; + + //main->callback.print_content_empty = 0; + main->callback.print_content_empty_set = 0; + main->callback.print_content_next = 0; + main->callback.print_object_end = &fss_read_extended_list_print_data_object_end; + main->callback.print_set_end = &fss_read_extended_list_print_data_set_end; + } + else if (f_compare_dynamic(as, fss_read_format_code_short_0008_s) == F_equal_to || + f_compare_dynamic(as, fss_read_format_code_long_0008_s) == F_equal_to || + f_compare_dynamic(as, fss_read_format_code_human_0008_s) == F_equal_to || + f_compare_dynamic(as, fss_read_format_code_machine_0008_s) == F_equal_to) { + + main->setting.standard = fss_read_embedded_list_standard_s; + + // Remove flags not supported for this standard. + main->setting.flag &= ~fss_read_main_flag_content_has_close_e; + main->setting.flag &= ~fss_read_main_flag_line_single_e; + main->setting.flag &= ~fss_read_main_flag_payload_error_e; + main->setting.flag &= ~fss_read_main_flag_payload_warn_e; + main->setting.flag &= ~fss_read_main_flag_quote_content_e; + main->setting.flag &= ~fss_read_main_flag_quote_object_e; + + main->setting.flag |= fss_read_main_flag_content_has_close_e | fss_read_main_flag_content_multiple_e; + main->setting.flag |= fss_read_main_flag_depth_multiple_e; + main->setting.flag |= fss_read_main_flag_object_as_line_e | fss_read_main_flag_object_trim_e; + + main->program.parameters.array[fss_read_parameter_payload_e].flag |= f_console_flag_disable_e; + + main->callback.process_help = &fss_read_embedded_list_process_help; + main->callback.process_load = &fss_read_embedded_list_process_load; + main->callback.process_total = &fss_read_process_normal_total_multiple; + + //main->callback.print_content_empty = 0; + main->callback.print_content_empty_set = 0; + main->callback.print_content_next = 0; + main->callback.print_object_end = &fss_read_embedded_list_print_data_object_end; + main->callback.print_set_end = &fss_read_embedded_list_print_data_set_end; + } + else if (f_compare_dynamic(as, fss_read_format_code_short_000e_s) == F_equal_to || + f_compare_dynamic(as, fss_read_format_code_long_000e_s) == F_equal_to || + f_compare_dynamic(as, fss_read_format_code_human_000e_s) == F_equal_to || + f_compare_dynamic(as, fss_read_format_code_machine_000e_s) == F_equal_to) { + + main->setting.standard = fss_read_payload_standard_s; + + // Remove flags not supported for this standard. + main->setting.flag &= ~fss_read_main_flag_content_has_close_e; + main->setting.flag &= ~fss_read_main_flag_content_multiple_e; + main->setting.flag &= ~fss_read_main_flag_depth_multiple_e; + main->setting.flag &= ~fss_read_main_flag_line_single_e; + main->setting.flag &= ~fss_read_main_flag_quote_content_e; + main->setting.flag &= ~fss_read_main_flag_quote_object_e; + + main->setting.flag |= fss_read_main_flag_object_as_line_e | fss_read_main_flag_object_trim_e; + main->setting.flag |= fss_read_main_flag_payload_error_e; + + main->program.parameters.array[fss_read_parameter_payload_e].flag &= ~f_console_flag_disable_e; + + main->callback.process_help = &fss_read_payload_process_help; + main->callback.process_load = &fss_read_payload_process_load; + main->callback.process_total = &fss_read_process_normal_total_multiple; + + //main->callback.print_content_empty = 0; + main->callback.print_content_empty_set = 0; + main->callback.print_content_next = 0; + main->callback.print_object_end = &fss_read_payload_print_data_object_end; + main->callback.print_set_end = &fss_read_print_set_end_no_eol; + } + else { + main->setting.state.status = F_status_set_error(F_parameter); - f_number_unsigned_t index = 0; - f_string_static_t *argv = main->program.parameters.arguments.array; - - for (f_number_unsigned_t i = 0; i < main->program.parameters.array[fss_read_parameter_as_e].values.used; ++i) { - - index = main->program.parameters.array[fss_read_parameter_as_e].values.array[i]; - - if (f_compare_dynamic(argv[index], fss_read_format_code_short_0000_s) == F_equal_to || - f_compare_dynamic(argv[index], fss_read_format_code_long_0000_s) == F_equal_to || - f_compare_dynamic(argv[index], fss_read_format_code_human_0000_s) == F_equal_to || - f_compare_dynamic(argv[index], fss_read_format_code_machine_0000_s) == F_equal_to) { - - main->setting.standard = fss_read_basic_standard_s; + if (main->setting.flag & fss_read_main_flag_help_e) { + fss_read_main_process_help((void *) main); + } + else { + fss_read_main_print_error_format_unknown(&main->program.error, as); + } - // Remove flags not supported for this standard. - main->setting.flag &= ~fss_read_main_flag_content_has_close_e; - main->setting.flag &= ~fss_read_main_flag_content_multiple_e; - main->setting.flag &= ~fss_read_main_flag_depth_multiple_e; - main->setting.flag &= ~fss_read_main_flag_object_as_line_e; - main->setting.flag &= ~fss_read_main_flag_object_trim_e; - main->setting.flag &= ~fss_read_main_flag_trim_object_e; + return; + } - main->setting.flag |= fss_read_main_flag_line_single_e; - main->setting.flag |= fss_read_main_flag_quote_content_e | fss_read_main_flag_quote_object_e; + main->setting.state.step_small = fss_read_allocation_console_d; - main->callback.process_help = &fss_read_basic_process_help; - main->callback.process_load = &fss_read_basic_process_load; - main->callback.process_total = &fss_read_process_normal_total; + main->setting.state.status = f_console_parameter_reset(&main->program.parameters); - main->callback.print_content_next = 0; - main->callback.print_object_end = &fss_read_basic_print_object_end; - main->callback.print_set_end = &fss_read_print_set_end; - } - else if (f_compare_dynamic(argv[index], fss_read_format_code_short_0001_s) == F_equal_to || - f_compare_dynamic(argv[index], fss_read_format_code_long_0001_s) == F_equal_to || - f_compare_dynamic(argv[index], fss_read_format_code_human_0001_s) == F_equal_to || - f_compare_dynamic(argv[index], fss_read_format_code_machine_0001_s) == F_equal_to) { - - main->setting.standard = fss_read_extended_standard_s; - - // Remove flags not supported for this standard. - main->setting.flag &= ~fss_read_main_flag_content_has_close_e; - main->setting.flag &= ~fss_read_main_flag_depth_multiple_e; - main->setting.flag &= ~fss_read_main_flag_object_as_line_e; - main->setting.flag &= ~fss_read_main_flag_object_trim_e; - main->setting.flag &= ~fss_read_main_flag_trim_object_e; - - main->setting.flag |= fss_read_main_flag_line_single_e | fss_read_main_flag_content_multiple_e; - main->setting.flag |= fss_read_main_flag_quote_content_e | fss_read_main_flag_quote_object_e; - - main->callback.process_help = &fss_read_extended_process_help; - main->callback.process_load = &fss_read_extended_process_load; - main->callback.process_total = &fss_read_process_normal_total; - - main->callback.print_content_next = &fss_read_extended_print_content_next; - main->callback.print_object_end = &fss_read_extended_print_object_end; - main->callback.print_set_end = &fss_read_print_set_end; - } - else if (f_compare_dynamic(argv[index], fss_read_format_code_short_0002_s) == F_equal_to || - f_compare_dynamic(argv[index], fss_read_format_code_long_0002_s) == F_equal_to || - f_compare_dynamic(argv[index], fss_read_format_code_human_0002_s) == F_equal_to || - f_compare_dynamic(argv[index], fss_read_format_code_machine_0002_s) == F_equal_to) { - - main->setting.standard = fss_read_basic_list_standard_s; - - // Remove flags not supported for this standard. - main->setting.flag &= ~fss_read_main_flag_content_has_close_e; - main->setting.flag &= ~fss_read_main_flag_content_multiple_e; - main->setting.flag &= ~fss_read_main_flag_depth_multiple_e; - main->setting.flag &= ~fss_read_main_flag_line_single_e; - main->setting.flag &= ~fss_read_main_flag_quote_content_e; - main->setting.flag &= ~fss_read_main_flag_quote_object_e; - - main->setting.flag |= fss_read_main_flag_object_as_line_e | fss_read_main_flag_object_trim_e; - - main->callback.process_help = &fss_read_basic_list_process_help; - main->callback.process_load = &fss_read_basic_list_process_load; - main->callback.process_total = &fss_read_process_normal_total_multiple; - - main->callback.print_content_next = 0; - main->callback.print_object_end = &fss_read_basic_list_print_object_end; - main->callback.print_set_end = &fss_read_print_set_end_no_eol; - } - else if (f_compare_dynamic(argv[index], fss_read_format_code_short_0003_s) == F_equal_to || - f_compare_dynamic(argv[index], fss_read_format_code_long_0003_s) == F_equal_to || - f_compare_dynamic(argv[index], fss_read_format_code_human_0003_s) == F_equal_to || - f_compare_dynamic(argv[index], fss_read_format_code_machine_0003_s) == F_equal_to) { - - main->setting.standard = fss_read_extended_list_standard_s; - - // Remove flags not supported for this standard. - main->setting.flag &= ~fss_read_main_flag_line_single_e; - main->setting.flag &= ~fss_read_main_flag_content_multiple_e; - main->setting.flag &= ~fss_read_main_flag_depth_multiple_e; - main->setting.flag &= ~fss_read_main_flag_quote_content_e; - main->setting.flag &= ~fss_read_main_flag_quote_object_e; - - main->setting.flag |= fss_read_main_flag_content_has_close_e; - main->setting.flag |= fss_read_main_flag_object_as_line_e | fss_read_main_flag_object_trim_e; - - main->callback.process_help = &fss_read_extended_list_process_help; - main->callback.process_load = &fss_read_extended_list_process_load; - main->callback.process_total = &fss_read_process_normal_total_multiple; - - main->callback.print_content_next = 0; - main->callback.print_object_end = &fss_read_extended_list_print_object_end; - main->callback.print_set_end = &fss_read_extended_list_print_set_end; - } - else if (f_compare_dynamic(argv[index], fss_read_format_code_short_0008_s) == F_equal_to || - f_compare_dynamic(argv[index], fss_read_format_code_long_0008_s) == F_equal_to || - f_compare_dynamic(argv[index], fss_read_format_code_human_0008_s) == F_equal_to || - f_compare_dynamic(argv[index], fss_read_format_code_machine_0008_s) == F_equal_to) { - - main->setting.standard = fss_read_embedded_list_standard_s; - - // Remove flags not supported for this standard. - main->setting.flag &= ~fss_read_main_flag_content_has_close_e; - main->setting.flag &= ~fss_read_main_flag_line_single_e; - main->setting.flag &= ~fss_read_main_flag_quote_content_e; - main->setting.flag &= ~fss_read_main_flag_quote_object_e; - - main->setting.flag |= fss_read_main_flag_content_has_close_e | fss_read_main_flag_content_multiple_e; - main->setting.flag |= fss_read_main_flag_depth_multiple_e; - main->setting.flag |= fss_read_main_flag_object_as_line_e | fss_read_main_flag_object_trim_e; - - main->callback.process_help = &fss_read_embedded_list_process_help; - main->callback.process_load = &fss_read_embedded_list_process_load; - main->callback.process_total = &fss_read_process_normal_total_multiple; - - main->callback.print_content_next = 0; - main->callback.print_object_end = &fss_read_embedded_list_print_object_end; - main->callback.print_set_end = &fss_read_embedded_list_print_set_end; - } - else if (f_compare_dynamic(argv[index], fss_read_format_code_short_000e_s) == F_equal_to || - f_compare_dynamic(argv[index], fss_read_format_code_long_000e_s) == F_equal_to || - f_compare_dynamic(argv[index], fss_read_format_code_human_000e_s) == F_equal_to || - f_compare_dynamic(argv[index], fss_read_format_code_machine_000e_s) == F_equal_to) { - - main->setting.standard = fss_read_payload_standard_s; - - // Remove flags not supported for this standard. - main->setting.flag &= ~fss_read_main_flag_content_has_close_e; - main->setting.flag &= ~fss_read_main_flag_content_multiple_e; - main->setting.flag &= ~fss_read_main_flag_depth_multiple_e; - main->setting.flag &= ~fss_read_main_flag_line_single_e; - main->setting.flag &= ~fss_read_main_flag_quote_content_e; - main->setting.flag &= ~fss_read_main_flag_quote_object_e; - - main->setting.flag |= fss_read_main_flag_object_as_line_e | fss_read_main_flag_object_trim_e; - - main->callback.process_help = &fss_read_payload_process_help; - main->callback.process_load = &fss_read_payload_process_load; - main->callback.process_total = &fss_read_process_normal_total_multiple; - - main->callback.print_content_next = 0; - main->callback.print_object_end = &fss_read_payload_print_object_end; - main->callback.print_set_end = &fss_read_print_set_end_no_eol; + if (F_status_is_error(main->setting.state.status)) { + if (main->setting.flag & fss_read_main_flag_help_e) { + fss_read_main_process_help((void *) main); } else { - if (main->setting.flag & fss_read_main_flag_help_e) { - main->setting.state.status = F_status_set_error(F_parameter); - - break; - } + fss_read_print_error(&main->program.error, macro_fss_read_f(f_console_parameter_reset)); + } - main->setting.state.status = F_status_set_error(F_parameter); + return; + } - fss_read_main_print_error_format_unknown(&main->program.error, argv[index]); - } - } // for + f_console_parameter_process(arguments, &main->program.parameters, &main->setting.state, 0); if (F_status_is_error(main->setting.state.status)) { if (main->setting.flag & fss_read_main_flag_help_e) { fss_read_main_process_help((void *) main); } + else { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_console_parameter_process)); + } return; } + + main->setting.state.step_small = fss_read_allocation_small_d; + + // If the --as parameter changed as a result of the re-run of the parameter processing, then something is wrong with the parameters. + { + const f_number_unsigned_t index_new = main->program.parameters.array[fss_read_parameter_as_e].values.array[main->program.parameters.array[fss_read_parameter_as_e].values.used - 1]; + + if (f_compare_dynamic(as, main->program.parameters.arguments.array[index_new]) != F_equal_to) { + main->setting.state.status = F_status_set_error(F_parameter); + + if (main->setting.flag & fss_read_main_flag_help_e) { + fss_read_main_process_help((void *) main); + } + else { + fss_read_main_print_error_parameter_as_changed(&main->program.error, as, main->program.parameters.arguments.array[index_new]); + } + + return; + } + } } else if (main->program.parameters.array[fss_read_parameter_as_e].result & f_console_result_found_e) { main->setting.state.status = F_status_set_error(F_parameter); diff --git a/level_3/fss_read/c/main/main/print.c b/level_3/fss_read/c/main/main/print.c index 95453f8..66e133d 100644 --- a/level_3/fss_read/c/main/main/print.c +++ b/level_3/fss_read/c/main/main/print.c @@ -31,8 +31,30 @@ extern "C" { } #endif // _di_fss_read_main_print_error_format_unknown_ +#ifndef _di_fss_read_main_print_error_parameter_as_changed_ + f_status_t fss_read_main_print_error_parameter_as_changed(fl_print_t * const print, const f_string_static_t previous, const f_string_static_t current) { + + if (!print) return F_status_set_error(F_output_not); + if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not; + + f_file_stream_lock(print->to); + + fl_print_format("%[%QThe parameter '%]", print->to, print->set->error, print->prefix, print->set->error); + fl_print_format(f_string_format_QQ_single_s.string, print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_as_s, print->set->notable); + fl_print_format("%[' value changed from '%]", print->to, print->set->error, print->set->error); + fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, previous, print->set->notable); + fl_print_format("%[' to %] ", print->to, print->set->error, print->set->error); + fl_print_format(f_string_format_Q_single_s.string, print->to, print->set->notable, current, print->set->notable); + fl_print_format(f_string_format_sentence_end_quote_s.string, print->to, print->set->error, print->set->error, f_string_eol_s); + + f_file_stream_unlock(print->to); + + return F_okay; + } +#endif // _di_fss_read_main_print_error_parameter_as_changed_ + #ifndef _di_fss_read_main_main_print_help_ - f_status_t fss_read_main_print_help(fl_print_t * const print) { + f_status_t fss_read_main_print_message_help(fl_print_t * const print) { if (!print) return F_status_set_error(F_output_not); @@ -58,8 +80,6 @@ extern "C" { f_print_dynamic_raw(f_string_eol_s, print->to); - // @todo everything below needs to be reviewed and updated as appropriate. - fl_print_format(" The '%[%r%r%]' parameter supports the following standards with the specified possible case-sensitive values:%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_as_s, print->set->notable, f_string_eol_s); // FSS-0000 (Basic) diff --git a/level_3/fss_read/c/main/main/print.h b/level_3/fss_read/c/main/main/print.h index 0cb6aba..85efb28 100644 --- a/level_3/fss_read/c/main/main/print.h +++ b/level_3/fss_read/c/main/main/print.h @@ -33,6 +33,28 @@ extern "C" { #endif // _di_fss_read_main_print_error_format_unknown_ /** + * Print an error message about a value given to the --as parameter changed after re-loading. + * + * @param print + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. + * @param previous + * A string representing the value of the previous --as parameter. + * @param current + * A string representing the value of the current --as parameter. + * + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + */ +#ifndef _di_fss_read_main_print_error_parameter_as_changed_ + extern f_status_t fss_read_main_print_error_parameter_as_changed(fl_print_t * const print, const f_string_static_t previous, const f_string_static_t current); +#endif // _di_fss_read_main_print_error_parameter_as_changed_ + +/** * Print help for "main" fss_read. * * @param print @@ -46,9 +68,9 @@ extern "C" { * * F_output_not (with error bit) if setting is NULL. */ -#ifndef _di_fss_read_print_main_help_ - extern f_status_t fss_read_main_print_help(fl_print_t * const print); -#endif // _di_fss_read_print_main_help_ +#ifndef _di_fss_read_print_main_message_help_ + extern f_status_t fss_read_main_print_message_help(fl_print_t * const print); +#endif // _di_fss_read_print_main_message_help_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/fss_read/c/main/print/data.c b/level_3/fss_read/c/main/print/data.c index e24ffaa..2cc2323 100644 --- a/level_3/fss_read/c/main/print/data.c +++ b/level_3/fss_read/c/main/print/data.c @@ -29,14 +29,28 @@ extern "C" { } if (main->setting.flag & fss_read_main_flag_content_e) { - if(main->setting.flag & fss_read_main_flag_select_e) { - if (main->setting.select < main->setting.contents.array[at].used && main->setting.contents.array[at].array[main->setting.select].start <= main->setting.contents.array[at].array[main->setting.select].stop) { - print_set_end = F_true; + if (main->setting.flag & fss_read_main_flag_select_e) { + if (main->setting.contents.array[at].used) { + if (main->setting.select < main->setting.contents.array[at].used) { + if (main->setting.contents.array[at].array[main->setting.select].start <= main->setting.contents.array[at].array[main->setting.select].stop) { + print_set_end = F_true; + + if (main->callback.print_content) { + main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[main->setting.select], main->setting.quotes_content.array[at].used ? main->setting.quotes_content.array[at].array[main->setting.select] : 0, delimits_content); + } + } + else { + print_set_end = F_true; - if (main->callback.print_content) { - main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[main->setting.select], main->setting.quotes_content.array[at].used ? main->setting.quotes_content.array[at].array[main->setting.select] : 0, delimits_content); + //if (main->callback.print_content_empty) { + // main->callback.print_content_empty(&main->program.output); + //} + } } } + else if (main->callback.print_content_empty_set && !main->setting.select) { + main->callback.print_content_empty_set(&main->program.output); + } } else if (main->setting.contents.array[at].used) { print_set_end = F_true; @@ -52,6 +66,9 @@ extern "C" { } // for } } + else if (main->callback.print_content_empty_set) { + main->callback.print_content_empty_set(&main->program.output); + } } if (print_set_end && main->callback.print_set_end) { @@ -96,6 +113,21 @@ extern "C" { } #endif // _di_fss_read_print_content_ +#ifndef _di_fss_read_print_content_empty_set_end_ + f_status_t fss_read_print_content_empty_set_end(fl_print_t * const print) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + + fss_read_main_t * const main = (fss_read_main_t *) print->custom; + + if (main->callback.print_set_end && (main->setting.flag & fss_read_main_flag_empty_e)) { + main->callback.print_set_end(print); + } + + return F_okay; + } +#endif // _di_fss_read_print_content_empty_set_end_ + #ifndef _di_fss_read_print_content_ignore_ f_status_t fss_read_print_content_ignore(fl_print_t * const print) { diff --git a/level_3/fss_read/c/main/print/data.h b/level_3/fss_read/c/main/print/data.h index c938ab4..aa24aa3 100644 --- a/level_3/fss_read/c/main/print/data.h +++ b/level_3/fss_read/c/main/print/data.h @@ -95,6 +95,30 @@ extern "C" { #endif // _di_fss_read_print_content_ /** + * Print the set end via the set end callback when Content is empty and the empty flag is set. + * + * This locks, uses, and unlocks the file stream. + * + * @param print + * The output structure to print to. + * + * The print.custom is expected to be of type fss_read_main_t. + * + * This does not alter print.custom.setting.state.status. + * + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if a parameter is NULL. + * + * @see fll_print_dynamic_raw() + */ +#ifndef _di_fss_read_print_content_empty_set_end_ + extern f_status_t fss_read_print_content_empty_set_end(fl_print_t * const print); +#endif // _di_fss_read_print_content_empty_set_end_ + +/** * Print the ignore character for Content. * * This locks, uses, and unlocks the file stream. diff --git a/level_3/fss_read/c/main/print/message.c b/level_3/fss_read/c/main/print/message.c index 9f7f282..2e45f23 100644 --- a/level_3/fss_read/c/main/print/message.c +++ b/level_3/fss_read/c/main/print/message.c @@ -110,7 +110,7 @@ extern "C" { } fl_print_format(" The parameter %[%r%r%] accepts the following:%r", print->to, set->notable, f_console_symbol_long_normal_s, fss_read_long_delimit_s, set->notable, f_string_eol_s); - fl_print_format(" - %[%r%]: Do not apply delimits.%r", print->to, set->notable, fss_read_delimit_mode_name_none_s, set->notable, f_string_eol_s); + fl_print_format(" - %[%r%]: Do not apply delimits.%r", print->to, set->notable, fss_read_string_none_s, set->notable, f_string_eol_s); fl_print_format(" - %[%r%]: (default) Apply all delimits.%r", print->to, set->notable, fss_read_delimit_mode_name_all_s, set->notable, f_string_eol_s); fl_print_format(" - %[%r%]: Apply delimits for Objects.%r", print->to, set->notable, fss_read_delimit_mode_name_object_s, set->notable, f_string_eol_s); // @todo this isn't in embedded_list print, confirm/deny if this is intended or not. fl_print_format(" - A number, 0 or greater: apply delimits for Content at the specified depth.%r", print->to, f_string_eol_s); @@ -120,7 +120,7 @@ extern "C" { fl_print_format(" The %[%r%r%] parameter may be specified multiple times to customize the delimit behavior.%r", print->to, set->notable, f_console_symbol_long_normal_s, fss_read_long_delimit_s, set->notable, f_string_eol_s); fl_print_format(" The %[%r%r%]", print->to, set->notable, f_console_symbol_long_normal_s, fss_read_long_delimit_s, set->notable); - fl_print_format(" values %[%r%]", print->to, set->notable, fss_read_delimit_mode_name_none_s, set->notable); + fl_print_format(" values %[%r%]", print->to, set->notable, fss_read_string_none_s, set->notable); fl_print_format(" and %[%r%],", print->to, set->notable, fss_read_delimit_mode_name_all_s, set->notable); fl_print_format(" overrule all other delimit values.%r%r", print->to, f_string_eol_s, f_string_eol_s); diff --git a/level_3/fss_read/c/main/process_normal.c b/level_3/fss_read/c/main/process_normal.c index 3bdde50..84a582c 100644 --- a/level_3/fss_read/c/main/process_normal.c +++ b/level_3/fss_read/c/main/process_normal.c @@ -161,7 +161,7 @@ extern "C" { } } else if (main->setting.flag & fss_read_main_flag_columns_e) { - fss_read_print_number(&main->program.output, main->setting.contents.array[i].used); + fss_read_print_number(&main->program.output, main->setting.contents.array[i].used); // @todo review and consider what to do when empty flag is set. } else if (main->callback.print_at) { main->callback.print_at(&main->program.output, i, delimits_object, delimits_content); @@ -206,7 +206,9 @@ extern "C" { if (!(main->setting.flag & fss_read_main_flag_content_e)) { if (!(main->setting.flag & fss_read_main_flag_object_as_line_e)) { - f_print_dynamic_raw(f_string_eol_s, main->program.output.to); + if (main->callback.print_set_end) { + main->callback.print_set_end(&main->program.output); + } } main->setting.state.status = F_success; @@ -221,19 +223,23 @@ extern "C" { } if (main->setting.flag & fss_read_main_flag_content_e) { + + // Must process/count line when both Object and Content share the same line but Content is empty. @todo review this block. if (!main->setting.contents.array[at].used) { + if (main->setting.flag & (fss_read_main_flag_empty_e | fss_read_main_flag_object_e)) { + if (!(main->setting.flag & fss_read_main_flag_object_e) || !(main->setting.flag & fss_read_main_flag_object_as_line_e) && (main->setting.flag & fss_read_main_flag_line_single_e)) { + if (*line == main->setting.line) { + if (main->callback.print_set_end) { + main->callback.print_set_end(&main->program.output); + } - // Must process/count line when both Object and Content share the same line but Content is empty. - if ((main->setting.flag & fss_read_main_flag_object_e) && !(main->setting.flag & fss_read_main_flag_object_as_line_e) && (main->setting.flag & fss_read_main_flag_line_single_e)) { - if (*line == main->setting.line) { - f_print_dynamic_raw(f_string_eol_s, main->program.output.to); + main->setting.state.status = F_success; - main->setting.state.status = F_success; + return; + } - return; + ++(*line); } - - ++(*line); } main->setting.state.status = F_okay; @@ -244,19 +250,29 @@ extern "C" { f_number_unsigned_t i = 0; if (main->setting.flag & fss_read_main_flag_line_single_e) { + // @fixme review this for when the line is empty. if (*line == main->setting.line) { - while (main->setting.contents.array[at].used) { + if (main->setting.contents.array[at].used) { + while (main->setting.contents.array[at].used) { - fss_read_print_content(&main->program.output, main->setting.contents.array[at].array[i], main->setting.quotes_content.array[at].array[i], delimits_content); + if (main->callback.print_content) { + main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[i], main->setting.quotes_content.array[at].array[i], delimits_content); + } - if (++i >= main->setting.contents.array[at].used) break; + if (++i >= main->setting.contents.array[at].used) break; - if (main->callback.print_content_next) { - main->callback.print_content_next(&main->program.output); - } - } // while + if (main->callback.print_content_next) { + main->callback.print_content_next(&main->program.output); + } + } // while - f_print_dynamic_raw(f_string_eol_s, main->program.output.to); + if (main->callback.print_set_end) { + main->callback.print_set_end(&main->program.output); + } + } + else if (main->callback.print_content_empty_set) { + main->callback.print_content_empty_set(&main->program.output); + } main->setting.state.status = F_success; @@ -270,63 +286,54 @@ extern "C" { f_number_unsigned_t j = 0; f_number_unsigned_t k = 0; - for (; i < main->setting.contents.array[at].used; ++i) { + if (main->setting.contents.array[at].used) { + for (; i < main->setting.contents.array[at].used; ++i) { - if (fss_read_signal_check(main)) return; + if (fss_read_signal_check(main)) return; - line_original = *line; - main->setting.range = main->setting.contents.array[at].array[i]; - k = 0; + line_original = *line; + main->setting.range = main->setting.contents.array[at].array[i]; + k = 0; - for (j = main->setting.range.start; j <= main->setting.range.stop; ++j) { + for (j = main->setting.range.start; j <= main->setting.range.stop; ++j) { - if (fss_read_signal_check(main)) return; + if (fss_read_signal_check(main)) return; - if (k < main->setting.comments.used) { - while (main->setting.comments.array[k].stop < j) ++k; + if (k < main->setting.comments.used) { + while (main->setting.comments.array[k].stop < j) ++k; - if (j >= main->setting.comments.array[k].start && j <= main->setting.comments.array[k].stop) { - j = main->setting.comments.array[k++].stop + 1; + if (j >= main->setting.comments.array[k].start && j <= main->setting.comments.array[k].stop) { + j = main->setting.comments.array[k++].stop + 1; - if (j > main->setting.range.stop) break; + if (j > main->setting.range.stop) break; + } } - } - if (main->setting.buffer.string[j] == f_string_eol_s.string[0]) { - if (*line == main->setting.line) { - main->setting.range.stop = j; + if (main->setting.buffer.string[j] == f_string_eol_s.string[0]) { + if (*line == main->setting.line) { + main->setting.range.stop = j; - fss_read_print_content(&main->program.output, main->setting.range, main->setting.quotes_content.array[at].array[i], delimits_content); + if (main->callback.print_content) { + main->callback.print_content(&main->program.output, main->setting.range, main->setting.quotes_content.array[at].array[i], delimits_content); + } - main->setting.state.status = F_success; + main->setting.state.status = F_success; - return; - } + return; + } - main->setting.range.start = j + 1; + main->setting.range.start = j + 1; - if (j <= main->setting.range.stop) { - ++(*line); + if (j <= main->setting.range.stop) { + ++(*line); + } } - } + } // for } // for - - // If Content does not end with a newline, it still must be treated as the last line. - if ((main->setting.flag & fss_read_main_flag_line_single_e) && *line == line_original) { - ++(*line); - - if (*line == main->setting.line) { - main->setting.range.stop = main->setting.contents.array[at].array[i].stop; - - fss_read_print_content(&main->program.output, main->setting.range, main->setting.quotes_content.array[at].array[i], delimits_content); - f_print_dynamic_raw(f_string_eol_s, main->program.output.to); - - main->setting.state.status = F_success; - - return; - } - } - } // for + } + else if (main->callback.print_content_empty_set) { + main->callback.print_content_empty_set(&main->program.output); + } } // @fixme The fll_fss_*_read functions do not have a store of the set closing ranges but should. @@ -368,15 +375,23 @@ extern "C" { f_number_unsigned_t max = 0; if (main->setting.flag & fss_read_main_flag_content_multiple_e) { + uint8_t has_at = F_false; + for (f_number_unsigned_t at = 0; at < main->setting.contents.used; ++at) { if (!names[at]) continue; if (fss_read_signal_check(main)) return; + has_at = F_true; + if (main->setting.contents.array[at].used > max) { max = main->setting.contents.array[at].used; } } // for + + if (!max && has_at && (main->setting.flag & fss_read_main_flag_empty_e)) { + max = 1; + } } else { for (f_number_unsigned_t at = 0; at < main->setting.contents.used; ++at) { @@ -458,7 +473,14 @@ extern "C" { if (main->setting.depths.array[0].value_at != i) continue; } - if (main->setting.select < main->setting.contents.array[i].used && main->setting.contents.array[i].array[main->setting.select].start <= main->setting.contents.array[i].array[main->setting.select].stop) { + if (main->setting.contents.array[i].used) { + if (main->setting.select < main->setting.contents.array[i].used) { + if ((main->setting.flag & fss_read_main_flag_empty_e) || main->setting.contents.array[i].array[main->setting.select].start <= main->setting.contents.array[i].array[main->setting.select].stop) { + ++total; + } + } + } + else if (!main->setting.select && (main->setting.flag & fss_read_main_flag_empty_e)) { ++total; } } // for @@ -519,7 +541,6 @@ extern "C" { } if (main->setting.flag & fss_read_main_flag_content_e) { - if (!main->setting.contents.array[at].used) continue; for (i = 0; i < main->setting.contents.array[at].used; ++i) { @@ -528,7 +549,7 @@ extern "C" { range.stop = main->setting.contents.array[at].array[i].stop; // This content has no data, do not even check "include empty" because it cannot be counted as a line. - if (range.start > range.stop) continue; + if (range.start > range.stop) continue; // @fixme review this check for when include empty is set (basic list might not count but extended list might). for (j = range.start; j <= range.stop; ++j) { diff --git a/level_3/fss_read/c/payload/common.c b/level_3/fss_read/c/payload/common.c index b5fd25d..11ba67d 100644 --- a/level_3/fss_read/c/payload/common.c +++ b/level_3/fss_read/c/payload/common.c @@ -5,8 +5,6 @@ extern "C" { #endif #ifndef _di_fss_read_payload_s_ - const f_string_static_t fss_read_payload_s = macro_f_string_static_t_initialize_1(FSS_READ_payload_s, 0, FSS_READ_payload_s_length); - const f_string_static_t fss_read_payload_standard_s = macro_f_string_static_t_initialize_1(FSS_READ_payload_standard_s, 0, FSS_READ_payload_standard_s_length); const f_string_static_t fss_read_payload_program_name_s = macro_f_string_static_t_initialize_1(FSS_READ_payload_program_name_s, 0, FSS_READ_payload_program_name_s_length); diff --git a/level_3/fss_read/c/payload/common.h b/level_3/fss_read/c/payload/common.h index bf3fe87..24c8d37 100644 --- a/level_3/fss_read/c/payload/common.h +++ b/level_3/fss_read/c/payload/common.h @@ -20,8 +20,6 @@ extern "C" { * The FSS-000E (Payload) specific strings. */ #ifndef _di_fss_read_payload_s_ - #define FSS_READ_payload_s "payload" - #define FSS_READ_payload_standard_s "FSS-000E (Payload)" #define FSS_READ_payload_program_name_s "fss_payload_read" @@ -33,8 +31,6 @@ extern "C" { #define FSS_READ_format_code_machine_000e_s "payload" #define FSS_READ_format_code_name_000e_s "Payload" - #define FSS_READ_payload_s_length 7 - #define FSS_READ_payload_standard_s_length 18 #define FSS_READ_payload_program_name_s_length 16 @@ -46,8 +42,6 @@ extern "C" { #define FSS_READ_format_code_machine_000e_s_length 7 #define FSS_READ_format_code_name_000e_s_length 7 - extern const f_string_static_t fss_read_payload_s; - extern const f_string_static_t fss_read_payload_standard_s; extern const f_string_static_t fss_read_payload_program_name_s; diff --git a/level_3/fss_read/c/payload/fss_read.c b/level_3/fss_read/c/payload/fss_read.c index cb56b3e..73c40fe 100644 --- a/level_3/fss_read/c/payload/fss_read.c +++ b/level_3/fss_read/c/payload/fss_read.c @@ -10,7 +10,7 @@ extern "C" { if (!void_main) return; - fss_read_payload_print_help(&((fss_read_main_t *) void_main)->program.message); + fss_read_payload_print_message_help(&((fss_read_main_t *) void_main)->program.message); } #endif // _di_fss_read_payload_process_help_ @@ -44,17 +44,75 @@ extern "C" { if (F_status_is_error(main->setting.state.status)) { if (F_status_set_fine(main->setting.state.status) == F_interrupt) return; - fll_error_file_print( - &main->program.error, - F_status_set_fine(main->setting.state.status), - macro_fss_read_f(fll_fss_payload_read), - fll_error_file_flag_fallback_e, - fss_read_file_identify(main->setting.range.start, main->setting.files), - f_file_operation_process_s, - fll_error_file_type_file_e - ); + if (main->setting.state.status == F_status_set_error(F_okay_stop) || main->setting.state.status == F_status_set_error(F_okay_eos)) { + if (main->setting.flag & fss_read_main_flag_payload_error_e) { + fss_read_payload_print_problem_payload_missing(&main->program.error); - return; + return; + } + + if (main->setting.flag & (fss_read_main_flag_payload_error_e | fss_read_main_flag_payload_warn_e)) { + if (main->program.warning.verbosity > f_console_verbosity_normal_e) { + fss_read_payload_print_problem_payload_missing(&main->program.warning); + } + + main->setting.state.status = F_okay; + } + else if (main->setting.flag & fss_read_main_flag_payload_create_e) { + main->setting.state.status = f_string_dynamic_append_assure(f_string_eol_s, &main->setting.buffer); + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append_assure)); + } + else { + main->setting.state.status = f_memory_array_increase(main->setting.state.step_small, sizeof(f_range_t), (void **) &main->setting.objects.array, &main->setting.objects.used, &main->setting.objects.size); + + if (F_status_is_error_not(main->setting.state.status)) { + main->setting.state.status = f_memory_array_increase(main->setting.state.step_small, sizeof(f_ranges_t), (void **) &main->setting.contents.array, &main->setting.contents.used, &main->setting.contents.size); + } + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_memory_array_increase)); + } + else { + main->setting.objects.array[main->setting.objects.used].start = main->setting.buffer.used; + + main->setting.state.status = f_string_dynamic_append(f_fss_payload_s, &main->setting.buffer); + + if (F_status_is_error_not(main->setting.state.status)) { + main->setting.state.status = f_string_dynamic_append(f_fss_payload_list_open_s, &main->setting.buffer); + } + + if (F_status_is_error_not(main->setting.state.status)) { + main->setting.state.status = f_string_dynamic_append(f_fss_payload_list_open_end_s, &main->setting.buffer); + } + + if (F_status_is_error(main->setting.state.status)) { + fss_read_print_error(&main->program.error, macro_fss_read_f(f_string_dynamic_append)); + } + else { + main->setting.objects.array[main->setting.objects.used++].stop = main->setting.objects.array[main->setting.objects.used].start + f_fss_payload_s.used - 1; + main->setting.contents.array[main->setting.contents.used++].used = 0; + + main->setting.state.status = F_okay; + } + } + } + } + } + else { + fll_error_file_print( + &main->program.error, + F_status_set_fine(main->setting.state.status), + macro_fss_read_f(fll_fss_payload_read), + fll_error_file_flag_fallback_e, + fss_read_file_identify(main->setting.range.start, main->setting.files), + f_file_operation_process_s, + fll_error_file_type_file_e + ); + + return; + } } if (main->setting.state.status == F_data_not_stop || main->setting.state.status == F_data_not_eos) { @@ -93,22 +151,32 @@ extern "C" { if (!main) return; - f_number_unsigneds_t * const values = &main->program.parameters.array[fss_read_parameter_object_e].values; - f_string_static_t * const argv = main->program.parameters.arguments.array; - - if ((main->program.parameters.array[fss_read_parameter_object_e].result & f_console_result_value_e) && values->used) { - for (f_number_unsigned_t i = 0; i < values->used; ++i) { - - if (fss_read_signal_check(main)) return; + f_number_unsigneds_t * const values = &main->program.parameters.array[fss_read_parameter_payload_e].values; - if (f_compare_dynamic(argv[values->array[i]], fss_read_payload_s) == F_equal_to && i + 1 < values->used) { - main->setting.state.status = F_status_set_error(F_parameter); + if ((main->program.parameters.array[fss_read_parameter_payload_e].result & f_console_result_value_e) && values->used) { + f_string_static_t * const argv = main->program.parameters.arguments.array; - fss_read_payload_print_error_payload_not_last(&main->program.error); + if (f_compare_dynamic(argv[values->array[values->used - 1]], fss_read_string_create_s) == F_equal_to) { + main->setting.flag |= fss_read_main_flag_payload_create_e; + main->setting.flag &= ~(fss_read_main_flag_payload_error_e | fss_read_main_flag_payload_warn_e); + } + else if (f_compare_dynamic(argv[values->array[values->used - 1]], fss_read_string_none_s) == F_equal_to) { + main->setting.flag |= fss_read_main_flag_payload_error_e; + main->setting.flag &= ~(fss_read_main_flag_payload_create_e | fss_read_main_flag_payload_error_e | fss_read_main_flag_payload_warn_e); + } + else if (f_compare_dynamic(argv[values->array[values->used - 1]], fss_read_string_error_s) == F_equal_to) { + main->setting.flag |= fss_read_main_flag_payload_error_e; + main->setting.flag &= ~(fss_read_main_flag_payload_create_e | fss_read_main_flag_payload_warn_e); + } + else if (f_compare_dynamic(argv[values->array[values->used - 1]], fss_read_string_warn_s) == F_equal_to) { + main->setting.flag |= fss_read_main_flag_payload_warn_e; + main->setting.flag &= ~(fss_read_main_flag_payload_create_e | fss_read_main_flag_payload_error_e); + } + else { + main->setting.state.status = F_status_set_error(F_parameter); - return; - } - } // for + fss_read_payload_print_error_parameter_value_payload(&main->program.error, argv[values->array[values->used - 1]]); + } } } #endif // _di_fss_read_payload_setting_load_ diff --git a/level_3/fss_read/c/payload/main.c b/level_3/fss_read/c/payload/main.c index 1df1aec..e73ca61 100644 --- a/level_3/fss_read/c/payload/main.c +++ b/level_3/fss_read/c/payload/main.c @@ -35,15 +35,17 @@ int main(const int argc, const f_string_t *argv, const f_string_t *envp) { data.callback.print_at = &fss_read_print_at; data.callback.print_content = &fss_read_print_content; + //data.callback.print_content_empty = 0; + data.callback.print_content_empty_set = 0; data.callback.print_content_ignore = &fss_read_print_content_ignore; data.callback.print_content_next = 0; data.callback.print_object = &fss_read_print_object; - data.callback.print_object_end = &fss_read_payload_print_object_end; + data.callback.print_object_end = &fss_read_payload_print_data_object_end; data.callback.print_set_end = &fss_read_print_set_end_no_eol; f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize; data.program.parameters.array = parameters; - data.program.parameters.array[fss_read_parameter_as_e].flag |= f_console_flag_disable_e; + data.program.parameters.array[fss_read_parameter_payload_e].flag &= ~f_console_flag_disable_e; data.program.parameters.used = fss_read_parameter_total_d; data.program.environment = envp; diff --git a/level_3/fss_read/c/payload/print.c b/level_3/fss_read/c/payload/print.c index fa91a73..cb3fafb 100644 --- a/level_3/fss_read/c/payload/print.c +++ b/level_3/fss_read/c/payload/print.c @@ -4,20 +4,64 @@ extern "C" { #endif -#ifndef _di_fss_read_payload_print_error_payload_not_last_ - f_status_t fss_read_payload_print_error_payload_not_last(fl_print_t * const print) { +#ifndef _di_fss_read_payload_print_data_object_end_ + f_status_t fss_read_payload_print_data_object_end(fl_print_t * const print) { + + if (!print || !print->custom) return F_status_set_error(F_output_not); + + fss_read_main_t * const main = (fss_read_main_t *) print->custom; + + f_file_stream_lock(print->to); + + if (main->setting.flag & fss_read_main_flag_pipe_format_e) { + f_print_dynamic_raw(fss_read_pipe_content_start_s, print->to); + } + else { + if (main->setting.flag & fss_read_main_flag_content_e) { + f_print_dynamic_raw(f_fss_payload_list_open_s, print->to); + f_print_dynamic_raw(f_fss_payload_list_open_end_s, print->to); + } + else { + f_print_dynamic_raw(f_fss_eol_s, print->to); + } + } + + f_file_stream_unlock(print->to); + + return F_okay; + } +#endif // _di_fss_read_payload_print_data_object_end_ + +#ifndef _di_fss_read_payload_print_error_parameter_value_payload_ + f_status_t fss_read_payload_print_error_parameter_value_payload(fl_print_t * const print, const f_string_static_t value) { if (!print) return F_status_set_error(F_output_not); - if (!print || print->verbosity == f_console_verbosity_quiet_e) return F_output_not; + if (print->verbosity == f_console_verbosity_quiet_e) return F_output_not; + + f_file_stream_lock(print->to); + + fl_print_format("%[%QThe parameter '%]", print->to, print->context, print->prefix, print->context); + fl_print_format(f_string_format_rr_single_s.string, print->to, print->notable, f_console_symbol_long_normal_s, fss_read_long_payload_s, print->notable); + fl_print_format("%[' has the value '%]", print->to, print->context, print->context); + fl_print_format("%[%Q%]", print->to, print->notable, value, print->notable); + fl_print_format("%[' but must only be one of: '%]", print->to, print->context, print->context); + fl_print_format("%[%Q%]", print->to, print->notable, fss_read_string_create_s, print->notable); + fl_print_format("%[', '%]", print->to, print->context, print->context); + fl_print_format("%[%Q%]", print->to, print->notable, fss_read_string_error_s, print->notable); + fl_print_format("%[', '%]", print->to, print->context, print->context); + fl_print_format("%[%Q%]", print->to, print->notable, fss_read_string_none_s, print->notable); + fl_print_format("%[', and '%]", print->to, print->context, print->context); + fl_print_format("%[%Q%]", print->to, print->notable, fss_read_string_warn_s, print->notable); + fl_print_format(f_string_format_sentence_end_quote_s.string, print->to, print->context, print->context, f_string_eol_s); - fll_print_format("%r%[%QThe payload may only be specified last.%]%r", print->to, f_string_eol_s, print->set->error, print->prefix, print->set->error, f_string_eol_s); + f_file_stream_unlock(print->to); return F_okay; } -#endif // _di_fss_read_payload_print_error_payload_not_last_ +#endif // _di_fss_read_payload_print_error_parameter_value_payload_ -#ifndef _di_fss_read_payload_print_help_ - f_status_t fss_read_payload_print_help(fl_print_t * const print) { +#ifndef fss_read_payload_print_message_help + f_status_t fss_read_payload_print_message_help(fl_print_t * const print) { if (!print) return F_status_set_error(F_output_not); @@ -31,6 +75,8 @@ extern "C" { fll_program_print_help_usage(print, fss_read_payload_program_name_s, f_string_empty_s); + fss_read_payload_print_message_help_special(print); + fss_read_print_message_help_pipe(print); fss_read_print_message_help_note(print, F_true); @@ -45,41 +91,59 @@ extern "C" { fl_print_format(" will not contain any Content close pipe control codes when using", print->to); fl_print_format(" %[%r%r%].%r", print->to, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_pipe_s, print->set->notable, f_string_eol_s); + fss_read_payload_print_message_help_payload(print); + f_file_stream_flush(print->to); f_file_stream_unlock(print->to); return F_okay; } -#endif // _di_fss_read_payload_print_help_ +#endif // _di_fss_read_payload_print_message_help_ -#ifndef _di_fss_read_payload_print_object_end_ - f_status_t fss_read_payload_print_object_end(fl_print_t * const print) { +#ifndef _di_fss_read_payload_print_message_help_payload_ + f_status_t fss_read_payload_print_message_help_payload(fl_print_t * const print) { - if (!print || !print->custom) return F_status_set_error(F_output_not); + if (!print || !print->set) return F_status_set_error(F_output_not); - fss_read_main_t * const main = (fss_read_main_t *) print->custom; + fl_print_format("%r The parameter %[%r%r%] accepts the following:%r", print->to, f_string_eol_s, print->set->notable, f_console_symbol_long_normal_s, fss_read_long_payload_s, print->set->notable, f_string_eol_s); + fl_print_format(" - %[%r%]: Create the payload Object if it is missing, but with empty Content.%r", print->to, print->set->notable, fss_read_string_create_s, print->set->notable, f_string_eol_s); + fl_print_format(" - %[%r%]: Do nothing special with payload Object is missing.%r", print->to, print->set->notable, fss_read_string_none_s, print->set->notable, f_string_eol_s); + fl_print_format(" - %[%r%]: Print error and exit as an error when payload Object is missing.%r", print->to, print->set->notable, fss_read_string_error_s, print->set->notable, f_string_eol_s); + fl_print_format(" - %[%r%]: Print warning but continue when payload Object is missing.%r", print->to, print->set->notable, fss_read_string_warn_s, print->set->notable, f_string_eol_s); + + return F_okay; + } +#endif // _di_fss_read_payload_print_message_help_payload_ + +#ifndef _di_fss_read_payload_print_message_help_special_ + f_status_t fss_read_payload_print_message_help_special(fl_print_t * const print) { + + if (!print || !print->set) return F_status_set_error(F_output_not); + + fl_print_format("%r %[Special Options:%] %r", print->to, f_string_eol_s, print->set->important, print->set->important, f_string_eol_s); + + fll_program_print_help_option_long(print, fss_read_long_payload_s, f_console_symbol_long_normal_s, "Specify custom actions to perform when payload Object is missing."); + + return F_okay; + } +#endif // _di_fss_read_payload_print_message_help_special_ +#ifndef fss_read_payload_print_problem_payload_missing + f_status_t fss_read_payload_print_problem_payload_missing(fl_print_t * const print) { + + if (!print || print->verbosity == f_console_verbosity_quiet_e) return F_output_not; f_file_stream_lock(print->to); - if (main->setting.flag & fss_read_main_flag_pipe_format_e) { - f_print_dynamic_raw(fss_read_pipe_content_start_s, print->to); - } - else { - if (main->setting.flag & fss_read_main_flag_content_e) { - f_print_dynamic_raw(f_fss_payload_list_open_s, print->to); - f_print_dynamic_raw(f_fss_payload_list_open_end_s, print->to); - } - else { - f_print_dynamic_raw(f_fss_eol_s, print->to); - } - } + fl_print_format("%[%QDid not find the required %]", print->to, print->context, print->prefix, print->context); + fl_print_format(f_string_format_r_single_s.string, print->to, print->notable, f_fss_payload_s, print->notable); + fl_print_format(" %[Object.%]%r", print->to, print->context, print->context, f_string_eol_s); f_file_stream_unlock(print->to); return F_okay; } -#endif // _di_fss_read_payload_print_object_end_ +#endif // _di_fss_read_payload_print_problem_payload_missing_ #ifdef __cplusplus } // extern "C" diff --git a/level_3/fss_read/c/payload/print.h b/level_3/fss_read/c/payload/print.h index c67b5f0..4d5c4df 100644 --- a/level_3/fss_read/c/payload/print.h +++ b/level_3/fss_read/c/payload/print.h @@ -13,24 +13,52 @@ extern "C" { #endif /** - * Print error message about the "payload" not being specified last (when it is specified at all). + * Print the end of an Object (which is often the start of Content). + * + * This locks, uses, and unlocks the file stream. * * @param print * The output structure to print to. * + * The print.custom is expected to be of type fss_read_main_t. + * * This does not alter print.custom.setting.state.status. * * @return * F_okay on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if setting is NULL. + * F_output_not (with error bit) if a parameter is NULL. * - * @see fll_error_print() + * @see f_file_stream_lock() + * @see f_file_stream_unlock() + * @see f_print_dynamic_raw() */ -#ifndef _di_fss_read_payload_print_error_payload_not_last_ - extern f_status_t fss_read_payload_print_error_payload_not_last(fl_print_t * const print); -#endif // _di_fss_read_payload_print_error_payload_not_last_ +#ifndef _di_fss_read_payload_print_data_object_end_ + extern f_status_t fss_read_payload_print_data_object_end(fl_print_t * const print); +#endif // _di_fss_read_payload_print_data_object_end_ + +/** + * Print an error message about the payload parameter not having a valid value. + * + * @param print + * The output structure to print to. + * + * The print.custom is expected to be of type fss_read_main_t. + * + * This does not alter print.custom.setting.state.status. + * @param value + * The parameter value that is invalid. + * + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if a parameter is NULL. + */ +#ifndef _di_fss_read_payload_print_error_parameter_value_payload_ + extern f_status_t fss_read_payload_print_error_parameter_value_payload(fl_print_t * const print, const f_string_static_t value); +#endif // _di_fss_read_payload_print_error_parameter_value_payload_ /** * Print help for FSS-000E (Payload). @@ -46,19 +74,51 @@ extern "C" { * * F_output_not (with error bit) if setting is NULL. */ -#ifndef _di_fss_read_payload_print_help_ - extern f_status_t fss_read_payload_print_help(fl_print_t * const print); -#endif // _di_fss_read_payload_print_help_ +#ifndef _di_fss_read_payload_print_message_help_ + extern f_status_t fss_read_payload_print_message_help(fl_print_t * const print); +#endif // _di_fss_read_payload_print_message_help_ /** - * Print the end of an Object (which is often the start of Content). + * Print payload-specific help parameters details for FSS-000E (Payload). * - * This locks, uses, and unlocks the file stream. + * @param print + * The output structure to print to. + * + * This does not alter print.custom.setting.state.status. + * + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + */ +#ifndef _di_fss_read_payload_print_message_help_payload_ + extern f_status_t fss_read_payload_print_message_help_payload(fl_print_t * const print); +#endif // _di_fss_read_payload_print_message_help_payload_ + +/** + * Print payload-specific help special parameters for FSS-000E (Payload). * * @param print * The output structure to print to. * - * The print.custom is expected to be of type fss_read_main_t. + * This does not alter print.custom.setting.state.status. + * + * @return + * F_okay on success. + * F_output_not on success, but no printing is performed. + * + * F_output_not (with error bit) if setting is NULL. + */ +#ifndef _di_fss_read_payload_print_message_help_special_ + extern f_status_t fss_read_payload_print_message_help_special(fl_print_t * const print); +#endif // _di_fss_read_payload_print_message_help_special_ + +/** + * Print error or warning message about the "payload" not being found. + * + * @param print + * The output structure to print to. * * This does not alter print.custom.setting.state.status. * @@ -66,15 +126,13 @@ extern "C" { * F_okay on success. * F_output_not on success, but no printing is performed. * - * F_output_not (with error bit) if a parameter is NULL. + * F_output_not (with error bit) if setting is NULL. * - * @see f_file_stream_lock() - * @see f_file_stream_unlock() - * @see f_print_dynamic_raw() + * @see fll_error_print() */ -#ifndef _di_fss_read_payload_print_object_end_ - extern f_status_t fss_read_payload_print_object_end(fl_print_t * const print); -#endif // _di_fss_read_payload_print_object_end_ +#ifndef _di_fss_read_payload_print_problem_payload_missing_ + extern f_status_t fss_read_payload_print_problem_payload_missing(fl_print_t * const print); +#endif // _di_fss_read_payload_print_problem_payload_missing_ #ifdef __cplusplus } // extern "C"