// Construct the array without allocating any more memory by setting this as a static string (used > 0, size = 0).
for (index = 0; at_object < object->values.used; ) {
+ if (iki_write_signal_check(main)) return;
+
main->setting.state.status = f_memory_array_increase(main->setting.state.step_small, sizeof(f_string_dynamic_t), (void **) &objectss->array[objectss->used].array, &objectss->array[objectss->used].used, &objectss->array[objectss->used].size);
if (F_status_is_error(main->setting.state.status)) {
// Construct the array without allocating any more memory by setting this as a static string (used > 0, size = 0).
for (index = 0; main->setting.contents.used < content->values.used; ) {
+ if (iki_write_signal_check(main)) return;
+
index = content->values.array[main->setting.contents.used];
main->setting.contents.array[main->setting.contents.used].string = main->program.parameters.arguments.array[index].string;
void iki_write_eki_print_message_help_note_pipe(fl_print_t * const print) {
if (!print) return;
- fl_print_format("%r When piping main to this program, a single form-feed character (\\f) (U+000C) must be used to separate each Object set from the Content.%r", print->to, f_string_eol_s, f_string_eol_s);
- fl_print_format(" Each Object within an Object set is is separated by a single backspace character (\\b) (U+0008).%r", print->to, f_string_eol_s);
+ fl_print_format("%r When piping main to this program, a single Form-Feed character (\\f) (U+000C) must be used to separate each Object set from the Content.%r", print->to, f_string_eol_s, f_string_eol_s);
+ fl_print_format(" Each Object within an Object set is is separated by a single Backspace character (\\b) (U+0008).%r", print->to, f_string_eol_s);
fl_print_format(" Each Object set must be followed by a Content.%r", print->to, f_string_eol_s);
}
#endif // _di_iki_write_eki_print_message_help_note_pipe_
#endif
#ifndef _di_iki_write_eki_load_objects_content_pipe_
- void iki_write_eki_load_objects_content_pipe(void * const void_main, const f_range_t range, bool * const object_ended) {
+ void iki_write_eki_load_objects_content_pipe(void * const void_main, const f_range_t range, uint8_t * const pipe_state) {
if (!void_main) return;
iki_write_main_t * const main = (iki_write_main_t *) void_main;
- if (!object_ended || !main->callback.process_objects_content) {
+ if (!pipe_state || !main->callback.process_objects_content) {
main->setting.state.status = F_status_set_error(F_parameter);
iki_write_print_error(&main->program.error, macro_iki_write_f(iki_write_callback_load_objects_content_pipe));
return;
}
- if (*object_ended) {
- main->cache.content.used = 0;
-
+ if (*pipe_state) {
if (main->cache.buffer.used) {
main->setting.state.status = f_string_dynamic_partial_append_nulless(main->cache.buffer, range, &main->cache.content);
if (F_status_is_error(main->setting.state.status)) {
iki_write_print_error(&main->program.error, macro_iki_write_f(f_string_dynamic_partial_append_nulless));
- *object_ended = F_false;
-
return;
}
}
main->callback.process_objects_content((void *) main, main->cache.objects, main->cache.content);
-
- if (F_status_is_error(main->setting.state.status)) {
- *object_ended = F_false;
-
- return;
- }
+ if (F_status_is_error(main->setting.state.status)) return;
fll_print_dynamic_raw(f_string_eol_s, main->program.output.to);
- *object_ended = F_false;
+ *pipe_state = 0x0;
main->cache.objects.used = 0;
+ main->cache.content.used = 0;
}
else {
f_range_t range_object = range;
+ f_number_unsigned_t total = 0;
+
+ for (; range_object.start <= range_object.stop; ++total) {
+
+ if (iki_write_signal_check(main)) return;
+
+ main->setting.state.status = f_string_dynamic_seek_to(main->cache.buffer, f_string_ascii_space_back_s.string[0], &range_object);
- f_memory_array_increase(main->setting.state.step_small, sizeof(f_string_dynamic_t), (void **) &main->cache.objects.array, &main->cache.objects.used, &main->cache.objects.size);
+ if (F_status_is_error(main->setting.state.status)) {
+ iki_write_print_error(&main->program.error, macro_iki_write_f(f_string_dynamic_seek_to));
+
+ return;
+ }
- if (F_status_is_error(main->setting.state.status)) {
- iki_write_print_error(&main->program.error, macro_iki_write_f(f_memory_array_increase));
+ // Seek past the found colon when the end is not reached.
+ if (main->setting.state.status == F_okay) {
+ ++range_object.start;
+ }
+ } // for
- *object_ended = F_false;
+ // Designate that no Object is found.
+ if (!total) {
+ *pipe_state = 0x0;
return;
}
- main->cache.objects.array[0].used = 0;
+ if (main->cache.objects.size < total) {
+ f_memory_array_increase_by(total, sizeof(f_string_dynamic_t), (void **) &main->cache.objects.array, &main->cache.objects.used, &main->cache.objects.size);
- main->setting.state.status = f_string_dynamic_partial_append_nulless(main->cache.buffer, range, &main->cache.objects.array[0]);
+ if (F_status_is_error(main->setting.state.status)) {
+ iki_write_print_error(&main->program.error, macro_iki_write_f(f_memory_array_increase_by));
- if (F_status_is_error(main->setting.state.status)) {
- iki_write_print_error(&main->program.error, macro_iki_write_f(f_string_dynamic_partial_append_nulless));
+ return;
+ }
+ }
- *object_ended = F_false;
+ range_object = range;
- return;
- }
+ f_number_unsigned_t i = 0;
+ f_range_t range_next = range;
+
+ for (; i < total; ++i) {
+
+ if (iki_write_signal_check(main)) return;
+
+ main->cache.objects.array[main->cache.objects.used].used = 0;
+
+ main->setting.state.status = f_string_dynamic_seek_to(main->cache.buffer, f_string_ascii_space_back_s.string[0], &range_next);
+
+ if (F_status_is_error(main->setting.state.status)) {
+ iki_write_print_error(&main->program.error, macro_iki_write_f(f_string_dynamic_seek_to));
+
+ return;
+ }
+
+ range_object.stop = range_next.start - 1;
+
+ main->setting.state.status = f_string_dynamic_partial_append_nulless(main->cache.buffer, range_object, &main->cache.objects.array[main->cache.objects.used]);
+
+ if (F_status_is_error(main->setting.state.status)) {
+ iki_write_print_error(&main->program.error, macro_iki_write_f(f_string_dynamic_partial_append_nulless));
+
+ return;
+ }
+
+ ++main->cache.objects.used;
+ range_object.start = ++range_next.start;
+ } // for
- *object_ended = F_true;
- ++main->cache.objects.used;
+ *pipe_state = 0x1;
}
}
#endif // _di_iki_write_eki_load_objects_content_pipe_
* Errors (with error bit) from: f_iki_write().
*
* F_failure (with error bit) for any other failure.
- * @param objects
- * The objects to process and print.
- * @param content
- * The content to process and print.
+ * @param range
+ * The range within the buffer representing the objects.
+ * @param pipe_state
+ * Designate that the Object part of the pipe is complete.
+ * For EKI, this may represent the end of the entire set of multiple Objects.
+ *
+ * State Bits:
+ * - 0x0: No Object has been found.
+ * - 0x1: Object is found and processed.
*
* @see f_iki_write()
*/
#ifndef _di_iki_write_eki_load_objects_content_pipe_
- extern void iki_write_eki_load_objects_content_pipe(void * const main, const f_range_t range, bool * const object_ended);
+ extern void iki_write_eki_load_objects_content_pipe(void * const main, const f_range_t range, uint8_t * const pipe_state);
#endif // _di_iki_write_eki_load_objects_content_pipe_
/**
// Construct the array without allocating any more memory by setting this as a static string (used > 0, size = 0).
for (index = 0; main->setting.objectss.used < values->used; ) {
+ if (iki_write_signal_check(main)) return;
+
main->setting.state.status = f_memory_arrays_resize(1, sizeof(f_string_dynamic_t), (void **) &main->setting.objectss.array[main->setting.objectss.used].array, &main->setting.objectss.array[main->setting.objectss.used].used, &main->setting.objectss.array[main->setting.objectss.used].size, &f_string_dynamics_delete_callback);
if (F_status_is_error(main->setting.state.status)) {
// Construct the array without allocating any more memory by setting this as a static string (used > 0, size = 0).
for (index = 0; main->setting.contents.used < values->used; ) {
+ if (iki_write_signal_check(main)) return;
+
index = values->array[main->setting.contents.used];
main->setting.contents.array[main->setting.contents.used].string = main->program.parameters.arguments.array[index].string;
if (!print) return;
- fl_print_format("%r When piping main to this program, a single form-feed character (\\f) (U+000C) must be used to separate each Object from each Content.%r", print->to, f_string_eol_s, f_string_eol_s);
+ fl_print_format("%r When piping main to this program, a single Form-Feed character (\\f) (U+000C) must be used to separate each Object from each Content.%r", print->to, f_string_eol_s, f_string_eol_s);
fl_print_format(" Each Object must be followed by a Content.%r", print->to, f_string_eol_s);
}
#endif // _di_iki_write_iki_print_message_help_note_pipe_
#endif
#ifndef _di_iki_write_iki_load_objects_content_pipe_
- void iki_write_iki_load_objects_content_pipe(void * const void_main, const f_range_t range, bool * const object_ended) {
+ void iki_write_iki_load_objects_content_pipe(void * const void_main, const f_range_t range, uint8_t * const pipe_state) {
if (!void_main) return;
iki_write_main_t * const main = (iki_write_main_t *) void_main;
- if (!object_ended || !main->callback.process_objects_content) {
+ if (!pipe_state || !main->callback.process_objects_content) {
main->setting.state.status = F_status_set_error(F_parameter);
iki_write_print_error(&main->program.error, macro_iki_write_f(iki_write_callback_load_objects_content_pipe));
return;
}
- if (*object_ended) {
+ if (*pipe_state) {
main->cache.content.used = 0;
if (main->cache.buffer.used) {
if (F_status_is_error(main->setting.state.status)) {
iki_write_print_error(&main->program.error, macro_iki_write_f(f_string_dynamic_partial_append_nulless));
- *object_ended = F_false;
-
return;
}
}
main->callback.process_objects_content((void *) main, main->cache.objects, main->cache.content);
-
- if (F_status_is_error(main->setting.state.status)) {
- *object_ended = F_false;
-
- return;
- }
+ if (F_status_is_error(main->setting.state.status)) return;
fll_print_dynamic_raw(f_string_eol_s, main->program.output.to);
- *object_ended = F_false;
+ *pipe_state = 0x0;
main->cache.objects.used = 0;
}
else {
+ main->cache.objects.used = 0;
+
f_memory_array_increase(main->setting.state.step_small, sizeof(f_string_dynamic_t), (void **) &main->cache.objects.array, &main->cache.objects.used, &main->cache.objects.size);
if (F_status_is_error(main->setting.state.status)) {
iki_write_print_error(&main->program.error, macro_iki_write_f(f_memory_array_increase));
- *object_ended = F_false;
-
return;
}
if (F_status_is_error(main->setting.state.status)) {
iki_write_print_error(&main->program.error, macro_iki_write_f(f_string_dynamic_partial_append_nulless));
- *object_ended = F_false;
-
return;
}
- *object_ended = F_true;
+ *pipe_state = 0x1;
++main->cache.objects.used;
}
}
* Errors (with error bit) from: f_iki_write().
*
* F_failure (with error bit) for any other failure.
- * @param objects
- * The objects to process and print.
- * @param content
- * The content to process and print.
+ * @param range
+ * The range within the buffer representing the objects.
+ * @param pipe_state
+ * Designate that the Object part of the pipe is complete.
+ *
+ * State Bits:
+ * - 0x0: No Object has been found.
+ * - 0x1: Object is found and processed.
*
* @see f_iki_write()
*/
#ifndef _di_iki_write_iki_load_objects_content_pipe_
- extern void iki_write_iki_load_objects_content_pipe(void * const main, const f_range_t range, bool * const object_ended);
+ extern void iki_write_iki_load_objects_content_pipe(void * const main, const f_range_t range, uint8_t * const pipe_state);
#endif // _di_iki_write_iki_load_objects_content_pipe_
/**
"f_file_stream_open",
"f_iki_write",
"f_memory_array_increase",
+ "f_memory_array_increase_by",
"f_memory_arrays_resize",
"f_string_dynamic_partial_append_nulless",
"f_string_dynamic_seek_to",
iki_write_f_f_file_stream_open_e,
iki_write_f_f_iki_write_e,
iki_write_f_f_memory_array_increase_e,
+ iki_write_f_f_memory_array_increase_by_e,
iki_write_f_f_memory_arrays_resize_e,
iki_write_f_f_string_dynamic_partial_append_nulless_e,
iki_write_f_f_string_dynamic_seek_to_e,
*/
#ifndef _di_iki_write_callback_t_
typedef struct {
- void (*load_objects_content_pipe)(void * const main, const f_range_t range, bool * const object_ended);
+ void (*load_objects_content_pipe)(void * const main, const f_range_t range, uint8_t * const pipe_state);
void (*print_help)(fl_print_t * const print);
}
if (main->setting.flag & iki_write_main_flag_pipe_d) {
- bool object_ended = F_false;
+ uint8_t pipe_state = 0x0;
f_number_unsigned_t previous = 0;
f_range_t range = f_range_t_initialize;
f_status_t status = F_okay;
range.start = 0;
do {
- if (!((++main->program.signal_check) % iki_write_signal_check_d)) {
- if (fll_program_standard_signal_received(&main->program)) {
- main->setting.state.status = F_status_set_error(F_interrupt);
-
- object_ended = F_false;
-
- break;
- }
-
- main->program.signal_check = 0;
- }
+ if (iki_write_signal_check(main)) return;
if (status != F_okay_eof) {
status = f_file_read(pipe, &main->cache.buffer);
iki_write_print_error_file(&main->program.error, macro_iki_write_f(f_file_read), f_string_ascii_minus_s, f_file_operation_read_s, fll_error_file_type_pipe_e);
- object_ended = F_false;
-
break;
}
fll_program_print_error_pipe_missing_content(&main->program.error);
- object_ended = F_false;
-
break;
}
if (F_status_is_error(main->setting.state.status)) {
iki_write_print_error(&main->program.error, macro_iki_write_f(f_string_dynamic_seek_to));
- object_ended = F_false;
-
break;
}
- if (object_ended && previous == range.start) {
+ if (pipe_state && previous == range.start) {
main->setting.state.status = F_status_set_error(F_parameter);
fll_program_print_error_pipe_invalid_form_feed(&main->program.error);
- object_ended = F_false;
-
break;
}
range.start = previous;
if (main->callback.load_objects_content_pipe) {
- main->callback.load_objects_content_pipe((void *) main, range, &object_ended);
+ main->callback.load_objects_content_pipe((void *) main, range, &pipe_state);
if (F_status_is_error(main->setting.state.status)) break;
}
main->cache.buffer.used = 0;
}
- } while (status != F_okay_eof || main->cache.buffer.used || object_ended);
+ } while (status != F_okay_eof || main->cache.buffer.used || pipe_state);
- if (F_status_is_error_not(main->setting.state.status) && object_ended) {
+ if (F_status_is_error_not(main->setting.state.status) && pipe_state) {
main->setting.state.status = F_status_set_error(F_parameter);
fll_program_print_error_pipe_object_without_content(&main->program.error);
if (F_status_is_error_not(main->setting.state.status) && F_status_set_fine(main->setting.state.status) != F_interrupt) {
for (f_number_unsigned_t i = 0; i < main->setting.objectss.used; ++i) {
- if (!((++main->program.signal_check) % iki_write_signal_check_d)) {
- if (fll_program_standard_signal_received(&main->program)) {
- main->setting.state.status = F_status_set_error(F_interrupt);
-
- break;
- }
-
- main->program.signal_check = 0;
- }
+ if (iki_write_signal_check(main)) return;
main->callback.process_objects_content((void *) main, main->setting.objectss.array[i], main->setting.contents.array[i]);
if (F_status_is_error(main->setting.state.status)) break;
# fss-0001
#
-# Builds the "iki_write" program.
+# Builds the "eki_write" program.
# This must be called after the "setting".
#