Focus on the Basic and Extended standards.
Begin working on Basic List standard.
There is already a function fss_read_process_at_line().
Cannibalize that function and turn it into a standard at line normal processor function.
Update documentation comments, clarifying the "at" parameter.
data.callback.process_normal = &fss_read_process_normal;
data.callback.process_at = &fss_read_process_normal_at;
+ data.callback.process_at_line = &fss_read_process_normal_at_line;
data.callback.process_columns = &fss_read_process_normal_columns;
- data.callback.process_line = &fss_read_process_normal_line;
data.callback.process_load = &fss_read_basic_process_load;
data.callback.process_name = &fss_read_process_normal_name;
data.callback.process_total = &fss_read_process_normal_total;
data.program.output.custom = (void *) &data;
data.program.warning.custom = (void *) &data;
+ data.setting.flag |= fss_read_main_flag_object_as_line_e;
+
data.setting.state.custom = (void *) &data;
data.setting.standard = fss_read_basic_list_standard_s;
data.callback.process_normal = &fss_read_process_normal;
data.callback.process_at = &fss_read_process_normal_at;
+ data.callback.process_at_line = &fss_read_process_normal_at_line;
data.callback.process_columns = &fss_read_process_normal_columns;
- 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_multiple;
data.program.output.custom = (void *) &data;
data.program.warning.custom = (void *) &data;
+ data.setting.flag |= fss_read_main_flag_object_as_line_e;
data.setting.flag |= fss_read_main_flag_depth_multiple_e;
data.setting.state.custom = (void *) &data;
data.callback.process_normal = &fss_read_process_normal;
data.callback.process_at = &fss_read_process_normal_at;
+ data.callback.process_at_line = &fss_read_process_normal_at_line;
data.callback.process_columns = &fss_read_process_normal_columns;
- 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_multiple;
data.callback.process_normal = &fss_read_process_normal;
data.callback.process_at = &fss_read_process_normal_at;
+ data.callback.process_at_line = &fss_read_process_normal_at_line;
data.callback.process_columns = &fss_read_process_normal_columns;
- data.callback.process_line = &fss_read_process_normal_line;
data.callback.process_load = &fss_read_extended_process_load;
data.callback.process_name = &fss_read_process_normal_name;
data.callback.process_total = &fss_read_process_normal_total;
data.program.output.custom = (void *) &data;
data.program.warning.custom = (void *) &data;
+ data.setting.flag |= fss_read_main_flag_object_as_line_e;
+
data.setting.state.custom = (void *) &data;
data.setting.standard = fss_read_extended_list_standard_s;
data.callback.process_normal = &fss_read_process_normal;
data.callback.process_at = &fss_read_process_normal_at;
+ data.callback.process_at_line = &fss_read_process_normal_at_line;
data.callback.process_columns = &fss_read_process_normal_columns;
- 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_multiple;
#ifndef _di_fss_read_ensure_quotes_length_
void fss_read_ensure_quotes_length(fss_read_main_t * const main) {
- if (main->setting.quotes_object.size < main->setting.objects.used) {
- main->setting.state.status = f_uint8s_increase_by(main->setting.objects.used - main->setting.quotes_object.size, &main->setting.quotes_object);
+ f_array_length_t i = 0;
+ f_array_length_t j = 0;
+
+ if (main->setting.quotes_object.used < main->setting.objects.used) {
+ main->setting.state.status = f_uint8s_resize(main->setting.objects.used, &main->setting.quotes_object);
if (F_status_is_error(main->setting.state.status)) return;
+
+ for (i = main->setting.quotes_object.used; i < main->setting.objects.used; ++i) {
+ main->setting.quotes_object.array[i] = 0;
+ } // for
}
- if (main->setting.quotes_content.size < main->setting.contents.used) {
- main->setting.state.status = f_uint8ss_increase_by(main->setting.contents.used - main->setting.quotes_content.size, &main->setting.quotes_content);
+ if (main->setting.quotes_content.used < main->setting.contents.used) {
+ main->setting.state.status = f_uint8ss_resize(main->setting.contents.used, &main->setting.quotes_content);
if (F_status_is_error(main->setting.state.status)) return;
+
+ for (i = main->setting.quotes_content.used; i < main->setting.contents.used; ++i) {
+
+ main->setting.state.status = f_uint8s_resize(main->setting.contents.array[i].used, &main->setting.quotes_content.array[i]);
+ if (F_status_is_error(main->setting.state.status)) return;
+
+ main->setting.quotes_content.array[i].used = 0;
+
+ for (j = 0; j < main->setting.contents.array[i].used; ++j) {
+ main->setting.quotes_content.array[i].array[j] = 0;
+ } // for
+ } // for
}
main->setting.state.status = F_none;
* This alters main.setting.state.status:
* F_none on success.
*
- * Errors (with error bit) from: f_uint8s_increase_by().
- * Errors (with error bit) from: f_uint8ss_increase_by().
+ * Errors (with error bit) from: f_uint8s_resize().
+ * Errors (with error bit) from: f_uint8ss_resize().
*
- * @see f_uint8s_increase_by()
- * @see f_uint8ss_increase_by()
+ * @see f_uint8s_resize()
+ * @see f_uint8ss_resize()
*/
#ifndef _di_fss_read_ensure_quotes_length_
extern void fss_read_ensure_quotes_length(fss_read_main_t * const main);
* - line_single: Designate that only a single line for Content is allowed for an Object for this standard rather than allowing multiple lines per Content per Object.
* - name: A specific Object name has been requested.
* - object: The Object is to be printed.
+ * - object_as_line: The Object is counted as its own line for the purpose of -l/--line or any other similar behavior.
* - original: Enable original printing, where the quotes are printed and no delimits are applied.
* - pipe: Print using the special pipe format.
* - print_first: When set, print new line to message output on program begin after loading settings.
fss_read_main_flag_line_single_e = 0x800,
fss_read_main_flag_name_e = 0x1000,
fss_read_main_flag_object_e = 0x2000,
- fss_read_main_flag_original_e = 0x4000,
- fss_read_main_flag_pipe_e = 0x8000,
- fss_read_main_flag_print_first_e = 0x10000,
- fss_read_main_flag_print_last_e = 0x20000,
- fss_read_main_flag_quote_content_e = 0x40000,
- fss_read_main_flag_quote_object_e = 0x80000,
- fss_read_main_flag_select_e = 0x100000,
- fss_read_main_flag_total_e = 0x200000,
- fss_read_main_flag_trim_e = 0x400000,
- fss_read_main_flag_trim_object_e = 0x800000,
- fss_read_main_flag_version_e = 0x1000000,
+ fss_read_main_flag_object_as_line_e = 0x4000,
+ fss_read_main_flag_original_e = 0x8000,
+ fss_read_main_flag_pipe_e = 0x10000,
+ fss_read_main_flag_print_first_e = 0x20000,
+ fss_read_main_flag_print_last_e = 0x40000,
+ fss_read_main_flag_quote_content_e = 0x80000,
+ fss_read_main_flag_quote_object_e = 0x100000,
+ fss_read_main_flag_select_e = 0x200000,
+ fss_read_main_flag_total_e = 0x400000,
+ fss_read_main_flag_trim_e = 0x800000,
+ fss_read_main_flag_trim_object_e = 0x1000000,
+ fss_read_main_flag_version_e = 0x2000000,
}; // enum
#endif // _di_fss_read_main_flag_e_
* process_normal: Process normally (data from parameters and files).
*
* process_at: Process at parameter, usually called by the process_normal() callback.
+ * process_at_line: Process line parameter for some Object index position, usually called by the process_normal() callback.
* process_columns: Process columns parameter, usually called by the process_normal() callback.
- * process_line: Process line parameter, usually called by the process_normal() callback.
* process_load: Process loading of FSS data from buffer (not to be confused with loading settings), usually called by the process_normal() callback.
* process_name: Process name parameter, usually called by the process_normal() callback.
* process_total: Process total parameter, usually called by the process_normal() callback.
void (*process_normal)(void * const main);
void (*process_at)(void * const main, const bool names[], const f_fss_delimits_t delimits_object, const f_fss_delimits_t delimits_content);
+ void (*process_at_line)(void * const void_main, const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, f_number_unsigned_t * const line);
void (*process_columns)(void * const main, const bool names[]);
- void (*process_line)(void * const main, const bool names[]);
void (*process_load)(void * const main);
void (*process_name)(void * const main, bool names[]);
void (*process_total)(void * const main, const bool names[]);
}
#endif // _di_fss_read_main_
-#ifndef _di_fss_read_process_at_line_
- void fss_read_process_at_line(fss_read_main_t * const main, const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, f_array_length_t * const line) {
-
- if (!main || !line) return;
-
- if (main->setting.flag & fss_read_main_flag_object_e) {
- if (*line == main->setting.line) {
- if (main->setting.flag & fss_read_main_flag_total_e) {
- fss_read_print_number(&main->program.output, 1);
- }
- else {
- if (main->callback.print_object) {
- main->callback.print_object(&main->program.output, at, delimits_object);
- }
-
- if (main->callback.print_object_end) {
- main->callback.print_object_end(&main->program.output);
- }
- }
-
- main->setting.state.status = F_success;
-
- return;
- }
-
- ++(*line);
- }
-
- // There is only a single Content column for this standard.
- if (main->setting.flag & fss_read_main_flag_content_e) {
- if (!main->setting.contents.array[at].used) {
- main->setting.state.status = F_none;
-
- return;
- }
-
- f_string_range_t range = main->setting.contents.array[at].array[0];
-
- // This content has no data, do not even check "include empty" because it cannot be counted as a line.
- if (range.start > range.stop) {
- main->setting.state.status = F_none;
-
- return;
- }
-
- for (f_array_length_t i = range.start; i <= range.stop; ++i) {
-
- if (fss_read_signal_check(main)) return;
-
- if (main->setting.buffer.string[i] == f_string_eol_s.string[0]) {
- if (*line == main->setting.line) {
- range.stop = i;
-
- if (main->setting.flag & fss_read_main_flag_total_e) {
- fss_read_print_number(&main->program.output, 1);
- }
- else {
- fss_read_print_content(&main->program.output, range, main->setting.quotes_content.array[at].array[0], delimits_content);
- }
-
- main->setting.state.status = F_success;
-
- return;
- }
-
- range.start = i + 1;
-
- if (i <= range.stop) {
- ++(*line);
- }
- }
- } // for
-
- // If Content does not end with a newline, it still must be treated as the last line.
- if (main->setting.buffer.string[range.stop] != f_string_eol_s.string[0]) {
- ++(*line);
-
- if (*line == main->setting.line) {
- if (main->setting.flag & fss_read_main_flag_total_e) {
- fss_read_print_number(&main->program.output, 1);
- }
- else {
- range.stop = main->setting.contents.array[at].array[0].stop;
-
- fss_read_print_content(&main->program.output, range, main->setting.quotes_content.array[at].array[0], delimits_content);
- f_print_dynamic_raw(f_string_eol_s, main->program.output.to);
- }
-
- main->setting.state.status = F_success;
-
- return;
- }
- }
- }
-
- main->setting.state.status = F_none;
- }
-#endif // _di_fss_read_process_at_line_
-
#ifndef _di_fss_read_file_identify_
f_string_static_t fss_read_file_identify(const f_array_length_t at, const fss_read_files_t files) {
#endif // _di_fss_read_main_
/**
- * Process based on at parameter for a specific line.
- *
- * @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.
- *
- * F_parameter (with error bit) if main is NULL or setting is NULL.
- *
- * Errors (with error bit) from: f_string_dynamic_append_assure().
- *
- * Errors (with error bit) from: fss_read_signal_check().
- * @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.
- * @param line
- * The current line being processed.
- * This will be incremented as necessary.
- *
- * Must not be NULL.
- *
- * @return
- * F_none on success.
- */
-#ifndef _di_fss_read_process_at_line_
- extern void fss_read_process_at_line(fss_read_main_t * const main, const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, f_array_length_t * const line);
-#endif // _di_fss_read_process_at_line_
-
-/**
* Get the name of the file the given position represents within the buffer.
*
* @param at
main->callback.process_normal = &fss_read_process_normal;
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_line = &fss_read_process_normal_line;
main->callback.process_load = 0;
main->callback.process_name = &fss_read_process_normal_name;
main->callback.process_total = 0;
// Remove flags not supported for this standard.
main->setting.flag -= main->setting.flag & fss_read_main_flag_content_multiple_e;
main->setting.flag -= main->setting.flag & fss_read_main_flag_depth_multiple_e;
+ main->setting.flag -= main->setting.flag & fss_read_main_flag_object_as_line_e;
main->setting.flag -= main->setting.flag & fss_read_main_flag_trim_object_e;
main->setting.flag |= fss_read_main_flag_line_single_e;
// Remove flags not supported for this standard.
main->setting.flag -= main->setting.flag & fss_read_main_flag_depth_multiple_e;
+ main->setting.flag -= main->setting.flag & fss_read_main_flag_object_as_line_e;
main->setting.flag -= 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 -= main->setting.flag & fss_read_main_flag_quote_content_e;
main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_object_e;
+ main->setting.flag |= fss_read_main_flag_object_as_line_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->setting.flag -= main->setting.flag & fss_read_main_flag_quote_content_e;
main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_object_e;
+ main->setting.flag |= fss_read_main_flag_object_as_line_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->setting.flag -= main->setting.flag & fss_read_main_flag_quote_object_e;
main->setting.flag |= fss_read_main_flag_content_multiple_e | fss_read_main_flag_depth_multiple_e;
+ main->setting.flag |= fss_read_main_flag_object_as_line_e;
main->callback.process_help = &fss_read_embedded_list_process_help;
main->callback.process_load = &fss_read_embedded_list_process_load;
main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_content_e;
main->setting.flag -= main->setting.flag & fss_read_main_flag_quote_object_e;
+ main->setting.flag |= fss_read_main_flag_object_as_line_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;
#endif
/**
- * Process printing the buffer according to "at" position and given delimits.
+ * Process printing the buffer according to an Object index position and given delimits.
*
* This locks, uses, and unlocks the file stream.
*
*
* This does not alter print.custom.setting.state.status.
* @param at
- * The "at" position to be printed.
+ * The Object index 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.
#endif // _di_fss_read_print_number_
/**
- * Print the Object at the given position.
+ * Print the Object at the given Object index position.
*
* This locks, uses, and unlocks the file stream.
*
*
* This does not alter print.custom.setting.state.status.
* @param at
- * The "at" position to be printed.
+ * The Object index to be printed.
* @param delimits
* The delimits array representing a delimited Object.
* This represents the positions within the current Object at the "at" position.
#endif // _di_fss_read_print_object_
/**
- * Print the Object at the given position.
+ * Print the Object at the given Object index position.
*
* This locks, uses, and unlocks the file stream.
*
*
* This does not alter print.custom.setting.state.status.
* @param at
- * The "at" position to be printed.
+ * The Object index position to be printed.
* @param delimits
* The delimits array representing a delimited Object.
* This represents the positions within the current Object at the "at" position.
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) {
+ else 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) {
+ else if (main->setting.flag & fss_read_main_flag_total_e) {
if (main->callback.process_total) {
main->callback.process_total(main, names);
}
-
- return;
}
+ else {
+ f_array_length_t i = 0;
- if (main->setting.flag & fss_read_main_flag_line_e) {
- if (main->callback.process_line) {
- main->callback.process_line(main, names);
- }
+ if (main->setting.flag & fss_read_main_flag_line_e) {
+ if (main->callback.process_at_line) {
+ f_number_unsigned_t line = 0;
- return;
- }
+ for (; i < main->setting.contents.used && main->setting.state.status != F_success; ++i) {
- if (main->callback.print_at) {
- for (f_array_length_t i = 0; i < main->setting.contents.used; ++i) {
+ if (!names[i]) continue;
+ if (fss_read_signal_check(main)) return;
- if (!names[i]) continue;
- if (fss_read_signal_check(main)) return;
+ main->callback.process_at_line(void_main, i, *delimits_object, *delimits_content, &line);
+ if (F_status_is_error(main->setting.state.status)) return;
+ } // for
+ }
+ }
+ else if (main->callback.print_at) {
+ for (; i < main->setting.contents.used; ++i) {
- main->callback.print_at(&main->program.output, i, *delimits_object, *delimits_content);
- } // for
+ if (!names[i]) continue;
+ if (fss_read_signal_check(main)) return;
+
+ main->callback.print_at(&main->program.output, i, *delimits_object, *delimits_content);
+ } // for
+ }
}
+ if (F_status_is_error(main->setting.state.status)) return;
+
main->setting.state.status = F_none;
}
#endif // _di_fss_read_process_normal_
}
// If the standard only has one line per Content, then any line value greater than 0 equates to no line to print.
- if (main->setting.flag & (fss_read_main_flag_line_e | fss_read_main_flag_line_single_e) == (fss_read_main_flag_line_e | fss_read_main_flag_line_single_e)) {
+ if ((main->setting.flag & fss_read_main_flag_line_e) && (main->setting.flag & fss_read_main_flag_line_single_e)) {
if (main->setting.line) {
if (main->setting.flag & fss_read_main_flag_total_e) {
fss_read_print_number(&main->program.output, 0);
}
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 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;
+ f_array_length_t total = 0;
+ f_array_length_t j = 0;
+ f_array_length_t k = 0;
+ f_array_length_t l = 0;
- for (j = 0; j < main->setting.contents.array[i].used; ++j) {
+ for (; 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;
fss_read_print_number(&main->program.output, total);
}
- else {
- fss_read_process_at_line(main, i, delimits_object, delimits_content, &line);
+ else if (main->callback.process_at_line) {
+ f_array_length_t line = 0;
+
+ main->callback.process_at_line(void_main, i, delimits_object, delimits_content, &line);
}
}
else if (main->setting.flag & fss_read_main_flag_columns_e) {
fss_read_print_number(&main->program.output, main->setting.contents.array[i].used ? 1 : 0);
}
else {
- total = 0;
- l = 0;
+ f_array_length_t total = 0;
+ f_string_range_t range = f_string_range_t_initialize;
+ f_array_length_t j = 0;
+ f_array_length_t k = 0;
+ f_array_length_t l = 0;
- for (j = 0; j < main->setting.contents.array[i].used; ++j) {
+ for (; j < main->setting.contents.array[i].used; ++j) {
range.start = main->setting.contents.array[i].array[j].start;
range.stop = main->setting.contents.array[i].array[j].stop;
main->callback.print_at(&main->program.output, i, delimits_object, delimits_content);
}
+ if (F_status_is_error(main->setting.state.status)) return;
+
main->setting.state.status = F_none;
return;
++at;
} // for
+ if (F_status_is_error(main->setting.state.status)) return;
+
if (main->setting.flag & fss_read_main_flag_total_e) {
fss_read_print_number(&main->program.output, 0);
}
}
#endif // _di_fss_read_process_normal_at_
+#ifndef _di_fss_read_process_normal_at_line_
+ void fss_read_process_normal_at_line(void * const void_main, const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, f_number_unsigned_t * const line) {
+
+ if (!void_main || !line) return;
+
+ fss_read_main_t * const main = (fss_read_main_t *) void_main;
+
+ if (main->setting.flag & fss_read_main_flag_object_e) {
+ if (*line == main->setting.line) {
+ if (main->callback.print_object) {
+ main->callback.print_object(&main->program.output, at, delimits_object);
+ }
+
+ if (main->callback.print_object_end) { // @todo need to handle object end only if content is not being printed or object end is not white space.
+ main->callback.print_object_end(&main->program.output);
+ }
+
+ if (!(main->setting.flag & fss_read_main_flag_content_e)) {
+ f_print_dynamic_raw(f_string_eol_s, main->program.output.to);
+
+ main->setting.state.status = F_success;
+
+ return;
+ }
+ }
+
+ if ((main->setting.flag & fss_read_main_flag_object_as_line_e) || !(main->setting.flag & fss_read_main_flag_content_e)) {
+ ++(*line);
+ }
+ }
+
+ if (main->setting.flag & fss_read_main_flag_content_e) {
+ if (!main->setting.contents.array[at].used) {
+
+ // 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;
+
+ return;
+ }
+
+ ++(*line);
+ }
+
+ main->setting.state.status = F_none;
+
+ return;
+ }
+
+ f_array_length_t i = 0;
+
+ if (main->setting.flag & fss_read_main_flag_line_single_e) {
+ if (*line == main->setting.line) {
+ 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 (++i >= main->setting.contents.array[at].used) break;
+
+ 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);
+
+ main->setting.state.status = F_success;
+
+ return;
+ }
+
+ ++(*line);
+ }
+ else {
+ f_array_length_t line_original = 0;
+ f_array_length_t j = 0;
+ f_array_length_t k = 0;
+
+ for (; i < main->setting.contents.array[at].used; ++i) {
+
+ if (fss_read_signal_check(main)) return;
+
+ 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) {
+
+ if (fss_read_signal_check(main)) return;
+
+ 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;
+
+ 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;
+
+ fss_read_print_content(&main->program.output, main->setting.range, main->setting.quotes_content.array[at].array[i], delimits_content);
+
+ main->setting.state.status = F_success;
+
+ return;
+ }
+
+ main->setting.range.start = j + 1;
+
+ if (j <= main->setting.range.stop) {
+ ++(*line);
+ }
+ }
+ } // for
+
+ // If Content does not end with a newline, it still must be treated as the last line.
+ if (*line == line_original) {
+ //if (main->setting.buffer.string[main->setting.range.stop] != f_string_eol_s.string[0]) {
+ ++(*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
+ }
+ }
+
+ main->setting.state.status = F_none;
+ }
+#endif // _di_fss_read_process_normal_at_line_
+
#ifndef _di_fss_read_process_normal_columns_
void fss_read_process_normal_columns(void * const void_main, const bool names[]) {
}
#endif // _di_fss_read_process_normal_columns_
-#ifndef _di_fss_read_process_normal_line_
- void fss_read_process_normal_line(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 line = 0;
-
- for (f_array_length_t i = 0; i < main->setting.contents.used; ++i) {
-
- 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.contents.array[i].used) {
- if (main->setting.flag & fss_read_main_flag_empty_e) {
- if (line == main->setting.line) {
- if (main->callback.print_set_end) {
- main->callback.print_set_end(&main->program.output);
- }
-
- break;
- }
-
- ++line;
- }
-
- continue;
- }
- }
-
- if (line == main->setting.line) {
- if (main->callback.print_at) {
- main->callback.print_at(
- &main->program.output,
- i,
- !(main->setting.flag & fss_read_main_flag_original_e) && fss_read_delimit_object_is(main, 0)
- ? main->setting.delimits_object
- : fss_read_except_none_c,
- !(main->setting.flag & fss_read_main_flag_original_e) && fss_read_delimit_content_is(main, 0)
- ? main->setting.delimits_content
- : fss_read_except_none_c
- );
- }
-
- break;
- }
-
- ++line;
- } // for
-
- main->setting.state.status = F_none;
- }
-#endif // _di_fss_read_process_normal_line_
-
#ifndef _di_fss_read_process_normal_name_
void fss_read_process_normal_name(void * const void_main, bool names[]) {
* F_none on success.
*
* Errors (with error bit) from: main.callback.process_at().
+ * Errors (with error bit) from: main.callback.process_at_line().
* Errors (with error bit) from: main.callback.process_columns().
- * Errors (with error bit) from: main.callback.process_line().
* Errors (with error bit) from: main.callback.process_load().
* Errors (with error bit) from: main.callback.process_name().
* Errors (with error bit) from: main.callback.print_at().
#endif // _di_fss_read_process_normal_at_
/**
- * Process buffer according to "columns" parameter rules.
+ * Process for the given Object index position for processing and ultimately printing a specific line.
*
* @param main
* The program and settings data.
* Must not be NULL.
* Must be of type fss_read_main_t.
*
+ * This alters main.setting.range.
+ *
* This alters main.setting.state.status:
- * F_none on success.
+ * F_none on success but line not yet found.
+ * F_success on success and line is found and printed.
+ *
+ * F_parameter (with error bit) if main is NULL or setting is NULL.
+ *
+ * Errors (with error bit) from: f_string_dynamic_append_assure().
*
* 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.)
+ * @param at
+ * The Object index position to be processed.
+ * @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.
+ * @param line
+ * The current line being processed.
+ * This will be incremented as necessary.
*
- * @see fss_read_signal_check()
+ * Must not be NULL.
*/
-#ifndef _di_fss_read_process_normal_columns_
- extern void fss_read_process_normal_columns(void * const main, const bool names[]);
-#endif // _di_fss_read_process_normal_columns_
+#ifndef _di_fss_read_process_normal_at_line_
+ extern void fss_read_process_normal_at_line(void * const main, const f_array_length_t at, const f_array_lengths_t delimits_object, const f_array_lengths_t delimits_content, f_number_unsigned_t * const line);
+#endif // _di_fss_read_process_normal_at_line_
/**
- * Process buffer according to "line" parameter rules.
+ * Process buffer according to "columns" parameter rules.
*
* @param main
* The program and settings data.
* (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()
- * @see main.callback.print_set_end()
*/
-#ifndef _di_fss_read_process_normal_line_
- extern void fss_read_process_normal_line(void * const main, const bool names[]);
-#endif // _di_fss_read_process_normal_line_
+#ifndef _di_fss_read_process_normal_columns_
+ extern void fss_read_process_normal_columns(void * const main, const bool names[]);
+#endif // _di_fss_read_process_normal_columns_
/**
* Process buffer according to "name" parameter rules.
data.program.output.custom = (void *) &data;
data.program.warning.custom = (void *) &data;
+ data.setting.flag |= fss_read_main_flag_object_as_line_e;
+
data.setting.state.custom = (void *) &data;
data.setting.standard = fss_read_payload_standard_s;
data.callback.process_normal = &fss_read_process_normal;
data.callback.process_at = &fss_read_process_normal_at;
+ data.callback.process_at_line = &fss_read_process_normal_at_line;
data.callback.process_columns = &fss_read_process_normal_columns;
- data.callback.process_line = &fss_read_process_normal_line;
data.callback.process_load = &fss_read_payload_process_load;
data.callback.process_name = &fss_read_process_normal_name;
data.callback.process_total = &fss_read_process_normal_total;