Get the programs into better working state.
I found several problems resulting from the way in which I migrated and refactored the code.
I think the next thing to do is to instead start writing some runtime tests that can better find problems.
Of particular note, I found problems with the comments being printed properly (which generally means not printed).
Some parameter handling problems are also fixed.
The payload and embedded list need special handling and are very much not implemented.
fss_read_main_t * const main = (fss_read_main_t *) void_main;
- if (main->setting.buffer.used) {
- main->setting.range.start = 0;
- main->setting.range.stop = main->setting.buffer.used;
- }
- else {
- main->setting.range.start = 1;
- main->setting.range.stop = 0;
- }
-
- main->setting.comments.used = 0;
- main->setting.delimits_object.used = 0;
- main->setting.delimits_content.used = 0;
- main->setting.nest.used = 0;
- main->setting.quotes_object.used = 0;
- main->setting.quotes_content.used = 0;
-
fll_fss_basic_read(main->setting.buffer, &main->setting.range, &main->setting.objects, &main->setting.contents, &main->setting.quotes_object, &main->setting.delimits_object, &main->setting.delimits_content, &main->setting.state);
if (F_status_is_error(main->setting.state.status)) {
data.callback.print_at = &fss_read_print_at;
data.callback.print_content = &fss_read_print_content;
+ data.callback.print_content_next = 0;
data.callback.print_content_ignore = 0;
data.callback.print_object = &fss_read_print_object;
- data.callback.print_object_end = &fss_read_print_object_end;
+ data.callback.print_object_end = &fss_read_basic_print_object_end;
data.callback.print_set_end = &fss_read_print_set_end;
f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize;
}
#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_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_none;
+ }
+#endif // _di_fss_read_basic_print_object_end_
+
#ifdef __cplusplus
} // extern "C"
#endif
extern f_status_t fss_read_basic_print_help(fl_print_t * const print);
#endif // _di_fss_read_basic_print_help_
+/**
+ * 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_none 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_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_
+
#ifdef __cplusplus
} // extern "C"
#endif
fss_read_main_t * const main = (fss_read_main_t *) void_main;
- if (main->setting.buffer.used) {
- main->setting.range.start = 0;
- main->setting.range.stop = main->setting.buffer.used;
- }
- else {
- main->setting.range.start = 1;
- main->setting.range.stop = 0;
- }
-
- main->setting.comments.used = 0;
- main->setting.delimits_object.used = 0;
- main->setting.delimits_content.used = 0;
- main->setting.nest.used = 0;
- main->setting.quotes_object.used = 0;
- main->setting.quotes_content.used = 0;
-
fll_fss_basic_list_read(main->setting.buffer, &main->setting.range, &main->setting.objects, &main->setting.contents, &main->setting.delimits_object, &main->setting.delimits_content, &main->setting.comments, &main->setting.state);
if (F_status_is_error(main->setting.state.status)) {
data.callback.process_line = &fss_read_process_normal_line;
data.callback.process_load = &fss_read_basic_list_process_load;
data.callback.process_name = &fss_read_process_normal_name;
- data.callback.process_total = &fss_read_process_normal_total;
+ data.callback.process_total = &fss_read_process_normal_total_multiple;
data.callback.print_at = &fss_read_print_at;
data.callback.print_content = &fss_read_print_content;
+ data.callback.print_content_next = 0;
data.callback.print_content_ignore = &fss_read_print_content_ignore;
data.callback.print_object = &fss_read_print_object;
data.callback.print_object_end = &fss_read_basic_list_print_object_end;
fss_read_main_t * const main = (fss_read_main_t *) void_main;
- if (main->setting.buffer.used) {
- main->setting.range.start = 0;
- main->setting.range.stop = main->setting.buffer.used;
- }
- else {
- main->setting.range.start = 1;
- main->setting.range.stop = 0;
- }
-
- main->setting.comments.used = 0;
- main->setting.delimits_object.used = 0;
- main->setting.delimits_content.used = 0;
- main->setting.nest.used = 0;
- main->setting.quotes_object.used = 0;
- main->setting.quotes_content.used = 0;
-
fll_fss_embedded_list_read(main->setting.buffer, &main->setting.range, &main->setting.nest, &main->setting.delimits_object, &main->setting.delimits_content, &main->setting.comments, &main->setting.state);
if (F_status_is_error(main->setting.state.status)) {
data.callback.process_line = &fss_read_process_normal_line;
data.callback.process_load = &fss_read_embedded_list_process_load;
data.callback.process_name = &fss_read_process_normal_name;
- data.callback.process_total = &fss_read_process_normal_total;
+ data.callback.process_total = &fss_read_process_normal_total_multiple;
data.callback.print_at = &fss_read_print_at;
data.callback.print_content = &fss_read_print_content;
+ data.callback.print_content_next = 0;
data.callback.print_content_ignore = &fss_read_print_content_ignore;
data.callback.print_object = &fss_read_print_object;
- data.callback.print_object_end = &fss_read_print_object_end;
+ data.callback.print_object_end = &fss_read_embedded_list_print_object_end;
data.callback.print_set_end = &fss_read_print_set_end;
f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize;
}
#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) {
+
+ 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_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_embedded_list_open_s, print->to);
+ f_print_dynamic_raw(f_fss_embedded_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_none;
+ }
+#endif // _di_fss_read_embedded_list_print_object_end_
+
#ifdef __cplusplus
} // extern "C"
#endif
extern f_status_t fss_read_embedded_list_print_help(fl_print_t * const print);
#endif // _di_fss_read_embedded_list_print_help_
+/**
+ * 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_none 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()
+ */
+#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_
+
#ifdef __cplusplus
} // extern "C"
#endif
fss_read_main_t * const main = (fss_read_main_t *) void_main;
- if (main->setting.buffer.used) {
- main->setting.range.start = 0;
- main->setting.range.stop = main->setting.buffer.used;
- }
- else {
- main->setting.range.start = 1;
- main->setting.range.stop = 0;
- }
-
- main->setting.comments.used = 0;
- main->setting.delimits_object.used = 0;
- main->setting.delimits_content.used = 0;
- main->setting.nest.used = 0;
- main->setting.quotes_object.used = 0;
- main->setting.quotes_content.used = 0;
-
fll_fss_extended_read(main->setting.buffer, &main->setting.range, &main->setting.objects, &main->setting.contents, &main->setting.quotes_object, &main->setting.quotes_content, &main->setting.delimits_object, &main->setting.delimits_content, &main->setting.state);
if (F_status_is_error(main->setting.state.status)) {
data.callback.process_name = &fss_read_process_normal_name;
data.callback.process_total = &fss_read_process_normal_total;
- data.callback.print_at = &fss_read_extended_print_at;
+ data.callback.print_at = &fss_read_print_at;
data.callback.print_content = &fss_read_print_content;
data.callback.print_content_ignore = &fss_read_print_content_ignore;
+ data.callback.print_content_next = &fss_read_extended_print_content_next;
data.callback.print_object = &fss_read_print_object;
- data.callback.print_object_end = &fss_read_print_object_end;
+ data.callback.print_object_end = &fss_read_extended_print_object_end;
data.callback.print_set_end = &fss_read_print_set_end;
f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize;
extern "C" {
#endif
-#ifndef _di_fss_read_extended_print_at_
- f_status_t fss_read_extended_print_at(fl_print_t * const print, const f_array_length_t at, const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content) {
+#ifndef _di_fss_read_extended_print_content_next_
+ f_status_t fss_read_extended_print_content_next(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 (at >= main->setting.contents.used) return F_output_not;
-
- // @todo This is copied from fss_read_print_at() and needs to be updated to handle multiple content.
-
- if ((main->setting.flag & fss_read_main_flag_object_e) || (main->setting.flag & fss_read_main_flag_content_e) && (main->setting.contents.array[at].used || (main->setting.flag & fss_read_main_flag_empty_e))) {
- if (main->setting.flag & fss_read_main_flag_object_e) {
- if (main->callback.print_object) {
- main->callback.print_object(&main->program.output, at, delimits_object);
- }
-
- if (main->setting.flag & fss_read_main_flag_content_e) {
- if (main->callback.print_object_end) {
- main->callback.print_object_end(&main->program.output);
- }
- }
- }
-
- if ((main->setting.flag & fss_read_main_flag_content_e) && main->setting.contents.array[at].used) {
- if (main->callback.print_content) {
- main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[0], main->setting.quotes_content.array[at].used ? main->setting.quotes_content.array[at].array[0] : 0, delimits_content);
- }
- }
-
- if (main->callback.print_set_end) {
- main->callback.print_set_end(&main->program.output);
- }
+ if (main->setting.flag & fss_read_main_flag_content_e) {
+ fll_print_dynamic_raw((main->setting.flag & fss_read_main_flag_pipe_e) ? fss_read_pipe_content_start_s : f_fss_extended_next_s, print->to);
}
return F_none;
}
-#endif // _di_fss_read_extended_print_at_
+#endif // _di_fss_read_extended_print_content_next_
#ifndef _di_fss_read_extended_print_help_
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_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_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_none;
+ }
+#endif // _di_fss_read_extended_print_object_end_
+
#ifdef __cplusplus
} // extern "C"
#endif
#endif
/**
- * Process printing the buffer according to "at" position and given delimits.
+ * Print the next part of a Content.
*
* This locks, uses, and unlocks the file stream.
*
+ * This is not the Content set end.
+ *
* @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 at
- * The "at" position to be printed.
- * @param delimits_object
- * The delimits array representing a delimited Object.
- * This represents the positions within the current Object at the "at" position.
- * @param delimits_content
- * The delimits array representing a delimited Content.
- * This represents the positions within the current Content at the "at" position.
*
* @return
* F_none on success.
*
* F_output_not (with error bit) if a parameter is NULL.
*
- * @see fll_print_dynamic_partial()
- * @see fll_print_except_dynamic_partial()
- * @see fll_print_trim_dynamic_partial()
- * @see fll_print_trim_except_dynamic_partial()
- *
- * @see main.callback.print_object()
- * @see main.callback.print_object_end()
- * @see main.callback.print_set_end()
+ * @see fll_print_dynamic_raw()
*/
-#ifndef _di_fss_read_extended_print_at_
- extern f_status_t fss_read_extended_print_at(fl_print_t * const print, const f_array_length_t at, const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content);
-#endif // _di_fss_read_extended_print_at_
+#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_
/**
* Print help for FSS-0001 (Extended).
extern f_status_t fss_read_extended_print_help(fl_print_t * const print);
#endif // _di_fss_read_extended_print_help_
+/**
+ * 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_none 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_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_
+
#ifdef __cplusplus
} // extern "C"
#endif
fss_read_main_t * const main = (fss_read_main_t *) void_main;
- if (main->setting.buffer.used) {
- main->setting.range.start = 0;
- main->setting.range.stop = main->setting.buffer.used;
- }
- else {
- main->setting.range.start = 1;
- main->setting.range.stop = 0;
- }
-
- main->setting.comments.used = 0;
- main->setting.delimits_object.used = 0;
- main->setting.delimits_content.used = 0;
- main->setting.nest.used = 0;
- main->setting.quotes_object.used = 0;
- main->setting.quotes_content.used = 0;
-
fll_fss_extended_list_read(main->setting.buffer, &main->setting.range, &main->setting.objects, &main->setting.contents, &main->setting.delimits_object, &main->setting.delimits_content, &main->setting.comments, &main->setting.state);
if (F_status_is_error(main->setting.state.status)) {
data.callback.process_line = &fss_read_process_normal_line;
data.callback.process_load = &fss_read_extended_list_process_load;
data.callback.process_name = &fss_read_process_normal_name;
- data.callback.process_total = &fss_read_process_normal_total;
+ data.callback.process_total = &fss_read_process_normal_total_multiple;
data.callback.print_at = &fss_read_print_at;
data.callback.print_content = &fss_read_print_content;
+ data.callback.print_content_next = 0;
data.callback.print_content_ignore = &fss_read_print_content_ignore;
data.callback.print_object = &fss_read_print_object;
- data.callback.print_object_end = &fss_read_print_object_end;
+ data.callback.print_object_end = &fss_read_extended_list_print_object_end;
data.callback.print_set_end = &fss_read_extended_list_print_set_end;
f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize;
}
#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) {
+
+ 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_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_extended_list_open_s, print->to);
+ f_print_dynamic_raw(f_fss_extended_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_none;
+ }
+#endif // _di_fss_read_extended_list_print_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) {
#endif // _di_fss_read_extended_list_print_help_
/**
- * Print the end of an Object/Content set.
+ * Print the end of an Object (which is often the start of Content).
*
* This locks, uses, and unlocks the file stream.
*
*
* @see fll_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_
+
+/**
+ * Print the end of an Object/Content 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_none 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()
+ */
#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_
for (i = 0; i < 6; ++i) {
- if (parameters->array[parameter_code[i]].result & f_console_result_found_e) {
- main->setting.state.status = F_status_set_error(F_parameter);
-
- if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) {
- fll_print_dynamic_raw(f_string_eol_s, main->program.message.to);
- }
-
- fss_read_print_error_parameter_requires_message(&main->program.error, f_console_symbol_long_normal_s, parameter_name[i], parameter_message[i]);
-
- return;
- }
- else if (parameters->array[parameter_code[i]].result & f_console_result_value_e) {
- main->setting.state.flag |= parameter_flag[i];
+ if (parameters->array[parameter_code[i]].result & f_console_result_value_e) {
+ main->setting.flag |= parameter_flag[i];
if (parameter_value_digit[i]) {
- index = parameters->array[parameter_code[i]].values.array[parameters->array[parameter_code[i]].location];
+ index = parameters->array[parameter_code[i]].values.array[parameters->array[parameter_code[i]].values.used - 1];
main->setting.state.status = fl_conversion_dynamic_to_unsigned_detect(fl_conversion_data_base_10_c, parameters->arguments.array[index], parameter_value_digit[i]);
}
}
}
+ else if (parameters->array[parameter_code[i]].result & f_console_result_found_e) {
+ main->setting.state.status = F_status_set_error(F_parameter);
+
+ if ((main->setting.flag & fss_read_main_flag_print_first_e) && main->program.message.verbosity > f_console_verbosity_error_e) {
+ fll_print_dynamic_raw(f_string_eol_s, main->program.message.to);
+ }
+
+ fss_read_print_error_parameter_requires_message(&main->program.error, f_console_symbol_long_normal_s, parameter_name[i], parameter_message[i]);
+
+ return;
+ }
} // for
}
* 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.
*/
f_status_t (*print_object)(fl_print_t * const print, const f_array_length_t at, const f_fss_delimits_t delimits);
f_status_t (*print_content)(fl_print_t * const print, const f_string_range_t range, const uint8_t quote, const f_fss_delimits_t delimits);
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);
f_status_t (*print_set_end)(fl_print_t * const print);
} fss_read_callback_t;
0, \
0, \
0, \
+ 0, \
}
#endif // _di_fss_read_callback_t_
main->callback.print_object(&main->program.output, at, delimits_object);
}
- if (main->setting.flag & fss_read_main_flag_content_e) {
- if (main->callback.print_object_end) {
- main->callback.print_object_end(&main->program.output);
- }
+ if (main->callback.print_object_end) {
+ main->callback.print_object_end(&main->program.output);
}
}
main->callback.process_line = &fss_read_process_normal_line;
main->callback.process_load = 0;
main->callback.process_name = &fss_read_process_normal_name;
- main->callback.process_total = &fss_read_process_normal_total;
+ main->callback.process_total = 0;
main->callback.print_at = &fss_read_print_at;
main->callback.print_content = &fss_read_print_content;
+ main->callback.print_content_next = 0;
main->callback.print_content_ignore = &fss_read_print_content_ignore;
main->callback.print_object = &fss_read_print_object;
- main->callback.print_object_end = &fss_read_print_object_end;
- main->callback.print_set_end = &fss_read_print_set_end;
+ main->callback.print_object_end = 0;
+ main->callback.print_set_end = 0;
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) {
main->callback.process_help = &fss_read_basic_process_help;
main->callback.process_load = &fss_read_basic_process_load;
- main->callback.print_set_end = &fss_read_print_set_end;
+ main->callback.process_total = &fss_read_process_normal_total;
- main->callback.print_object_end = &fss_read_print_object_end;
+ 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 ||
main->callback.process_help = &fss_read_extended_process_help;
main->callback.process_load = &fss_read_extended_process_load;
- main->callback.print_set_end = &fss_read_print_set_end_no_eol;
+ main->callback.process_total = &fss_read_process_normal_total;
- main->callback.print_object_end = &fss_read_print_object_end;
+ 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_no_eol;
}
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 ||
main->callback.process_help = &fss_read_basic_list_process_help;
main->callback.process_load = &fss_read_basic_list_process_load;
- main->callback.print_set_end = &fss_read_print_set_end;
+ 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;
}
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 ||
main->callback.process_help = &fss_read_extended_list_process_help;
main->callback.process_load = &fss_read_extended_list_process_load;
- main->callback.print_set_end = &fss_read_print_set_end;
+ main->callback.process_total = &fss_read_process_normal_total_multiple;
- main->callback.print_object_end = &fss_read_print_object_end;
+ 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_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 ||
main->callback.process_help = &fss_read_embedded_list_process_help;
main->callback.process_load = &fss_read_embedded_list_process_load;
- main->callback.print_set_end = &fss_read_print_set_end;
+ main->callback.process_total = &fss_read_process_normal_total_multiple;
- main->callback.print_object_end = &fss_read_print_object_end;
+ 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_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 ||
main->callback.process_help = &fss_read_payload_process_help;
main->callback.process_load = &fss_read_payload_process_load;
- main->callback.print_set_end = &fss_read_print_set_end;
+ main->callback.process_total = &fss_read_process_normal_total_multiple;
- main->callback.print_object_end = &fss_read_print_object_end;
+ 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;
}
else {
if (main->setting.flag & fss_read_main_flag_help_e) {
main->callback.print_object(&main->program.output, at, delimits_object);
}
- if (main->setting.flag & fss_read_main_flag_content_e) {
- if (main->callback.print_object_end) {
- main->callback.print_object_end(&main->program.output);
- }
+ if (main->callback.print_object_end) {
+ main->callback.print_object_end(&main->program.output);
}
}
if ((main->setting.flag & fss_read_main_flag_content_e) && main->setting.contents.array[at].used) {
if (main->callback.print_content) {
- main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[0], main->setting.quotes_content.array[at].used ? main->setting.quotes_content.array[at].array[0] : 0, delimits_content);
+ for (f_array_length_t i = 0; i < main->setting.contents.array[at].used; ++i) {
+
+ main->callback.print_content(&main->program.output, main->setting.contents.array[at].array[i], main->setting.quotes_content.array[at].used ? main->setting.quotes_content.array[at].array[i] : 0, delimits_content);
+
+ if (main->callback.print_content_next && i + 1 < main->setting.contents.array[at].used) {
+ main->callback.print_content_next(&main->program.output);
+ }
+ } // for
}
}
}
#endif // _di_fss_read_print_object_
-#ifndef _di_fss_read_print_object_end_
- f_status_t fss_read_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;
-
- fll_print_dynamic_raw((main->setting.flag & fss_read_main_flag_pipe_e) ? fss_read_pipe_content_start_s : f_fss_space_s, print->to);
-
- return F_none;
- }
-#endif // _di_fss_read_print_object_end_
-
#ifndef _di_fss_read_print_quote_
f_status_t fss_read_print_quote(fl_print_t * const print, const uint8_t type) {
*
* This locks, uses, and unlocks the file stream.
*
+ * This processes multiple Content ranges and calls main.callback.print_content() for each individual Content range.
+ *
* @param print
* The output structure to print to.
*
*
* This locks, uses, and unlocks the file stream.
*
+ * This processes single Content range.
* This does not print a new line after the Content.
*
* @param print
#endif // _di_fss_read_print_object_
/**
- * 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_none 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_object_end_
- extern f_status_t fss_read_print_object_end(fl_print_t * const print);
-#endif // _di_fss_read_print_object_end_
-
-/**
* Print the Object at the given position.
*
* This locks, uses, and unlocks the file stream.
fl_print_format("%[%QThe parameter '%]", print->to, print->context, print->prefix, print->context);
fl_print_format("%[%r%r%]", print->to, print->notable, symbol, name, print->notable);
- fl_print_format("%[' requires %s.%]%r", print->to, print->context, message, print->context, f_string_eol_s);
+ fl_print_format("%[' requires %Q.%]%r", print->to, print->context, message, print->context, f_string_eol_s);
f_file_stream_unlock(print->to);
// The process_load() callback is required to be non-NULL.
if (!main->callback.process_load) return;
+ if (main->setting.buffer.used) {
+ main->setting.range.start = 0;
+ main->setting.range.stop = main->setting.buffer.used;
+ }
+ else {
+ main->setting.range.start = 1;
+ main->setting.range.stop = 0;
+ }
+
+ main->setting.objects.used = 0;
+ main->setting.contents.used = 0;
+ main->setting.comments.used = 0;
+ main->setting.delimits_object.used = 0;
+ main->setting.delimits_content.used = 0;
+ main->setting.nest.used = 0;
+ main->setting.quotes_object.used = 0;
+ main->setting.quotes_content.used = 0;
+
main->callback.process_load(main);
if (F_status_is_error(main->setting.state.status)) return;
memset(names, F_true, sizeof(bool) * main->setting.objects.used);
}
- if (main->callback.process_at) {
- main->callback.process_at(main, names, *delimits_object, *delimits_content);
+ if (main->setting.flag & fss_read_main_flag_at_e) {
+ if (main->callback.process_at) {
+ main->callback.process_at(main, names, *delimits_object, *delimits_content);
+ }
return;
}
- if ((main->setting.flag & fss_read_main_flag_columns_e) && main->callback.process_columns) {
- main->callback.process_columns(main, names);
+ if (main->setting.flag & fss_read_main_flag_columns_e) {
+ if (main->callback.process_columns) {
+ main->callback.process_columns(main, names);
+ }
return;
}
- if ((main->setting.flag & fss_read_main_flag_total_e) && main->callback.process_total) {
- main->callback.process_total(main, names);
+ if (main->setting.flag & fss_read_main_flag_total_e) {
+ if (main->callback.process_total) {
+ main->callback.process_total(main, names);
+ }
return;
}
- if ((main->setting.flag & fss_read_main_flag_line_e) && main->callback.process_line) {
- main->callback.process_line(main, names);
+ if (main->setting.flag & fss_read_main_flag_line_e) {
+ if (main->callback.process_line) {
+ main->callback.process_line(main, names);
+ }
return;
}
f_array_length_t i = 0;
f_array_length_t j = 0;
f_array_length_t k = 0;
+ f_array_length_t l = 0;
f_array_length_t at = 0;
f_array_length_t line = 0;
f_array_length_t total = 0;
+ f_string_range_t range = f_string_range_t_initialize;
for (; i < main->setting.objects.used; ++i) {
if (at == main->setting.depths.array[0].value_at) {
if (main->setting.flag & fss_read_main_flag_line_e) {
- // For standards that only support one line per Object so when using "--at", then the only valid line is line 0.
- if (main->setting.flag & fss_read_main_flag_line_single_e) break;
+ // If using "--at" for standards that only support one line per Object, then the only valid line is line 0.
+ if ((main->setting.flag & fss_read_main_flag_line_single_e) && !at) break;
line = 0;
if (main->setting.flag & fss_read_main_flag_total_e) {
+ total = 0;
+ l = 0;
+
+ for (j = 0; j < main->setting.contents.array[i].used; ++j) {
+
+ if (main->setting.contents.array[i].array[j].start > main->setting.contents.array[i].array[j].stop) continue;
- // Total is always 1 in this case because "line" parameter forces a single line.
- fss_read_print_number(&main->program.output, 1);
+ if (l < main->setting.comments.used) {
+ while (main->setting.comments.array[l].stop < k) ++l;
+
+ if (k >= main->setting.comments.array[l].start && k <= main->setting.comments.array[l].stop) {
+ k = main->setting.comments.array[l++].stop;
+
+ continue;
+ }
+ }
+
+ total = 1;
+
+ break;
+ } // for
+
+ fss_read_print_number(&main->program.output, total);
}
else {
fss_read_process_at_line(main, i, delimits_object, delimits_content, &line);
}
-
- if (main->setting.state.status == F_success) {
- main->setting.state.status = F_none;
-
- return;
- }
}
else if (main->setting.flag & fss_read_main_flag_columns_e) {
fss_read_print_number(&main->program.output, main->setting.contents.array[i].used);
}
else {
total = 0;
- k = 0;
+ l = 0;
- // Count each new line.
for (j = 0; j < main->setting.contents.array[i].used; ++j) {
- if (main->setting.contents.array[i].array[j].start > main->setting.contents.array[i].array[j].stop) continue;
- if (main->setting.contents.array[i].array[j].start > main->setting.buffer.used) continue;
+ range.start = main->setting.contents.array[i].array[j].start;
+ range.stop = main->setting.contents.array[i].array[j].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;
+
+ for (k = range.start; k <= range.stop; ++k) {
+
+ if (l < main->setting.comments.used) {
+ while (main->setting.comments.array[l].stop < k) ++l;
+
+ if (k >= main->setting.comments.array[l].start && k <= main->setting.comments.array[l].stop) {
+ k = main->setting.comments.array[l++].stop;
+
+ continue;
+ }
+ }
- for (k = main->setting.contents.array[i].array[j].start; k <= main->setting.contents.array[i].array[j].stop && k < main->setting.buffer.used; ++k) {
if (main->setting.buffer.string[k] == f_string_eol_s.string[0]) ++total;
} // for
} // for
if (!names[i]) continue;
if (fss_read_signal_check(main)) return;
- if (!(main->setting.flag & fss_read_main_flag_object_e) && main->setting.flag & fss_read_main_flag_content_e) {
+ if (!(main->setting.flag & fss_read_main_flag_object_e) && (main->setting.flag & fss_read_main_flag_content_e)) {
if (!(main->setting.contents.array[i].used || (main->setting.flag & fss_read_main_flag_empty_e))) continue;
}
}
#endif // _di_fss_read_process_normal_total_
+#ifndef _di_fss_read_process_normal_total_multiple_
+ void fss_read_process_normal_total_multiple(void * const void_main, const bool names[]) {
+
+ if (!void_main) return;
+
+ fss_read_main_t * const main = (fss_read_main_t *) void_main;
+
+ f_array_length_t total = 0;
+ f_string_range_t range = f_string_range_t_initialize;
+ f_array_length_t i = 0;
+ f_array_length_t j = 0;
+ f_array_length_t k = 0;
+
+ for (f_array_length_t at = 0; at < main->setting.contents.used; ++at) {
+
+ if (!names[at]) continue;
+ if (fss_read_signal_check(main)) return;
+
+ if (main->setting.flag & fss_read_main_flag_object_e) {
+ ++total;
+ }
+
+ 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) {
+
+ range.start = main->setting.contents.array[at].array[i].start;
+ 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;
+
+ for (j = range.start; j <= range.stop; ++j) {
+
+ 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;
+
+ continue;
+ }
+ }
+
+ if (main->setting.buffer.string[j] == f_string_eol_s.string[0]) ++total;
+ } // for
+ } // for
+
+ // If Content does not end with a newline, it still must be treated as the last line.
+ if (i) {
+ j = main->setting.contents.array[at].array[i - 1].stop;
+
+ if (main->setting.buffer.string[j] != f_string_eol_s.string[0]) ++total;
+ }
+ }
+ } // for
+
+ fss_read_print_number(
+ &main->program.output,
+ main->setting.flag & fss_read_main_flag_line_e
+ ? main->setting.line < total ? 1 : 0
+ : total
+ );
+
+ main->setting.state.status = F_none;
+ }
+#endif // _di_fss_read_process_normal_total_multiple_
+
#ifdef __cplusplus
} // extern "C"
#endif
/**
* Process buffer according to "at" parameter rules.
*
+ * This handles only a single depth (index 0 of the depth array).
+ *
* @param main
* The program and settings data.
*
/**
* Process buffer according to "total" parameter rules.
*
+ * This processes single line Content only.
+ *
* @param main
* The program and settings data.
*
extern void fss_read_process_normal_total(void * const main, const bool names[]);
#endif // _di_fss_read_process_normal_total_
+/**
+ * Process buffer according to "total" parameter rules.
+ *
+ * This processes multi-line Content only.
+ *
+ * @param main
+ * The program and settings data.
+ *
+ * Must not be NULL.
+ * Must be of type fss_read_main_t.
+ *
+ * This alters main.setting.state.status:
+ * F_none on success.
+ *
+ * Errors (with error bit) from: fss_read_signal_check().
+ * @param names
+ * An array of booleans representing if the name at a given index is enabled.
+ * (If TRUE, then the name is to be used and if FALSE, then the name is not to be used.)
+ *
+ * @see fss_read_signal_check()
+ */
+#ifndef _di_fss_read_process_normal_total_multiple_
+ extern void fss_read_process_normal_total_multiple(void * const main, const bool names[]);
+#endif // _di_fss_read_process_normal_total_multiple_
+
#ifdef __cplusplus
} // extern "C"
#endif
main->setting.range.stop = 0;
}
+ main->setting.objects.used = 0;
+ main->setting.contents.used = 0;
main->setting.comments.used = 0;
main->setting.delimits_object.used = 0;
main->setting.delimits_content.used = 0;
data.callback.print_content = &fss_read_print_content;
data.callback.print_content_ignore = &fss_read_print_content_ignore;
data.callback.print_object = &fss_read_print_object;
- data.callback.print_object_end = &fss_read_print_object_end;
+ data.callback.print_object_end = &fss_read_payload_print_object_end;
data.callback.print_set_end = &fss_read_print_set_end;
f_console_parameter_t parameters[] = fss_read_console_parameter_t_initialize;
}
#endif // _di_fss_read_payload_print_help_
+#ifndef _di_fss_read_payload_print_object_end_
+ f_status_t fss_read_payload_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_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_none;
+ }
+#endif // _di_fss_read_payload_print_object_end_
+
#ifdef __cplusplus
} // extern "C"
#endif
extern f_status_t fss_read_payload_print_help(fl_print_t * const print);
#endif // _di_fss_read_payload_print_help_
+/**
+ * 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_none 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()
+ */
+#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_
+
#ifdef __cplusplus
} // extern "C"
#endif