From aa4d72dd671e7274a2cc7fb240fa87d2b4ac0fd3 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Tue, 7 Nov 2023 21:08:36 -0600 Subject: [PATCH] Progress: Continue adding FSS Payload processing code. --- level_0/f_fss/c/fss/payload.c | 24 +++++++ level_0/f_fss/c/fss/payload.h | 95 +++++++++++++++++++------- level_1/fl_fss/c/fss/payload.c | 124 +++++++++++++++++----------------- level_1/fl_fss/c/fss/payload/define.h | 14 ++-- level_1/fl_fss/c/fss/payload/type.h | 14 ++-- 5 files changed, 170 insertions(+), 101 deletions(-) diff --git a/level_0/f_fss/c/fss/payload.c b/level_0/f_fss/c/fss/payload.c index 60a8a09..87e0bd5 100644 --- a/level_0/f_fss/c/fss/payload.c +++ b/level_0/f_fss/c/fss/payload.c @@ -9,10 +9,26 @@ extern "C" { const f_string_static_t f_fss_payload_comment_header_s = macro_f_string_static_t_initialize_1(F_fss_payload_comment_header_s, 0, F_fss_payload_comment_header_s_length); #endif // _di_f_fss_payload_comment_header_s_ + #ifndef _di_f_fss_payload_comment_header_end_s_ + const f_string_static_t f_fss_payload_comment_header_end_s = macro_f_string_static_t_initialize_1(F_fss_payload_comment_header_end_s, 0, F_fss_payload_comment_header_end_s_length); + #endif // _di_f_fss_payload_comment_header_end_s_ + + #ifndef _di_f_fss_payload_comment_header_begin_s_ + const f_string_static_t f_fss_payload_comment_header_begin_s = macro_f_string_static_t_initialize_1(F_fss_payload_comment_header_begin_s, 0, F_fss_payload_comment_header_begin_s_length); + #endif // _di_f_fss_payload_comment_header_begin_s_ + + #ifndef _di_f_fss_payload_object_end_s_ + const f_string_static_t f_fss_payload_object_end_s = macro_f_string_static_t_initialize_1(F_fss_payload_object_end_s, 0, F_fss_payload_object_end_s_length); + #endif // _di_f_fss_payload_object_end_s_ + #ifndef _di_f_fss_payload_object_header_s_ const f_string_static_t f_fss_payload_object_header_s = macro_f_string_static_t_initialize_1(F_fss_payload_object_header_s, 0, F_fss_payload_object_header_s_length); #endif // _di_f_fss_payload_object_header_s_ + #ifndef _di_f_fss_payload_object_length_s_ + const f_string_static_t f_fss_payload_object_length_s = macro_f_string_static_t_initialize_1(F_fss_payload_object_length_s, 0, F_fss_payload_object_length_s_length); + #endif // _di_f_fss_payload_object_length_s_ + #ifndef _di_f_fss_payload_object_payload_s_ const f_string_static_t f_fss_payload_object_payload_s = macro_f_string_static_t_initialize_1(F_fss_payload_object_payload_s, 0, F_fss_payload_object_payload_s_length); #endif // _di_f_fss_payload_object_payload_s_ @@ -20,6 +36,14 @@ extern "C" { #ifndef _di_f_fss_payload_object_signature_s_ const f_string_static_t f_fss_payload_object_signature_s = macro_f_string_static_t_initialize_1(F_fss_payload_object_signature_s, 0, F_fss_payload_object_signature_s_length); #endif // _di_f_fss_payload_object_signature_s_ + + #ifndef _di_f_fss_payload_object_status_s_ + const f_string_static_t f_fss_payload_object_status_s = macro_f_string_static_t_initialize_1(F_fss_payload_object_status_s, 0, F_fss_payload_object_status_s_length); + #endif // _di_f_fss_payload_object_status_s_ + + #ifndef _di_f_fss_payload_object_total_s_ + const f_string_static_t f_fss_payload_object_total_s = macro_f_string_static_t_initialize_1(F_fss_payload_object_total_s, 0, F_fss_payload_object_total_s_length); + #endif // _di_f_fss_payload_object_total_s_ #endif // _di_f_fss_payload_s_ #ifdef __cplusplus diff --git a/level_0/f_fss/c/fss/payload.h b/level_0/f_fss/c/fss/payload.h index 414c3ec..9fee734 100644 --- a/level_0/f_fss/c/fss/payload.h +++ b/level_0/f_fss/c/fss/payload.h @@ -17,55 +17,96 @@ extern "C" { #endif /** - * Flags used by the FSS-000E (Simple Packet) write functions. + * Flags used by the FSS-000E (Payload) header map functions. * - * Values of f_fss_payload_write_*_e: - * - none: No write flag set. + * Values of f_fss_payload_header_map_*_e: + * - none: No map flag set. * - base_2: Convert number to string using base 2. * - base_8: Convert number to string using base 8. * - base_10: Convert number to string using base 10. * - base_12: Convert number to string using base 12. * - base_16: Convert number to string using base 16. */ -#ifndef _di_f_fss_payload_write_e_ +#ifndef _di_f_fss_payload_header_map_e_ enum { - f_fss_payload_write_none_e = 0x0, - f_fss_payload_write_base_2_e = 0x1, - f_fss_payload_write_base_8_e = 0x2, - f_fss_payload_write_base_10_e = 0x4, - f_fss_payload_write_base_12_e = 0x8, - f_fss_payload_write_base_16_e = 0x10, + f_fss_payload_header_map_none_e = 0x0, + f_fss_payload_header_map_base_2_e = 0x1, + f_fss_payload_header_map_base_8_e = 0x2, + f_fss_payload_header_map_base_10_e = 0x4, + f_fss_payload_header_map_base_12_e = 0x8, + f_fss_payload_header_map_base_16_e = 0x10, }; // enum -#endif // _di_f_fss_payload_write_e_ +#endif // _di_f_fss_payload_header_map_e_ /** - * FSS Payload strings. + * FSS-000E (Payload) strings. * - * f_fss_payload_*_s: - * - header_comment: The header comment string for Payload (FSS-000E). - * - header_object: The header object. - * - payload_object: The payload object. - * - signature_object: The signature object. + * f_fss_payload_comment_*_s: + * - header: The complete header comment line for Payload (FSS-000E). + * - header_end: The complete header comment line for Payload (FSS-000E). + * - header_begin: The complete header comment line for Payload (FSS-000E). + * + * f_fss_payload_object_*_s: + * - end: The Object end characters. + * - header: The header Object or signature Content header Object. + * - length: The header Content length Object. + * - part: The header Content part Object. + * - payload: The payload Object or signature Content payload Object. + * - signature: The signature Object. + * - status: The header Content status Object. + * - total: The header Content total Object. */ #ifndef _di_f_fss_payload_s_ - #define F_fss_payload_comment_header_s "# fss-000e\n" - #define F_fss_payload_object_header_s "header:\n" - #define F_fss_payload_object_payload_s "payload:\n" - #define F_fss_payload_object_signature_s "signature:\n" + #define F_fss_payload_comment_header_s "fss-000e" + #define F_fss_payload_comment_header_end_s "\n" + #define F_fss_payload_comment_header_begin_s "# " + + #define F_fss_payload_object_end_s ":\n" + #define F_fss_payload_object_header_s "header" + #define F_fss_payload_object_length_s "length" + #define F_fss_payload_object_part_s "part" + #define F_fss_payload_object_payload_s "payload" + #define F_fss_payload_object_signature_s "signature" + #define F_fss_payload_object_status_s "status" + #define F_fss_payload_object_total_s "total" - #define F_fss_payload_comment_header_s_length 10 - #define F_fss_payload_object_header_s_length 8 - #define F_fss_payload_object_payload_s_length 9 - #define F_fss_payload_object_signature_s_length 11 + #define F_fss_payload_comment_header_s_length 8 + #define F_fss_payload_comment_header_end_s_length 1 + #define F_fss_payload_comment_header_begin_s_length 2 + + #define F_fss_payload_object_end_s_length 2 + #define F_fss_payload_object_length_s_length 6 + #define F_fss_payload_object_header_s_length 6 + #define F_fss_payload_object_part_s_length 4 + #define F_fss_payload_object_payload_s_length 7 + #define F_fss_payload_object_signature_s_length 9 + #define F_fss_payload_object_status_s_length 6 + #define F_fss_payload_object_total_s_length 5 #ifndef _di_f_fss_payload_comment_header_s_ extern const f_string_static_t f_fss_payload_comment_header_s; #endif // _di_f_fss_payload_comment_header_s_ + #ifndef _di_f_fss_payload_comment_header_end_s_ + extern const f_string_static_t f_fss_payload_comment_header_end_s; + #endif // _di_f_fss_payload_comment_header_end_s_ + + #ifndef _di_f_fss_payload_comment_header_begin_s_ + extern const f_string_static_t f_fss_payload_comment_header_begin_s; + #endif // _di_f_fss_payload_comment_header_begin_s_ + + #ifndef _di_f_fss_payload_object_end_s_ + extern const f_string_static_t f_fss_payload_object_end_s; + #endif // _di_f_fss_payload_object_end_s_ + #ifndef _di_f_fss_payload_object_header_s_ extern const f_string_static_t f_fss_payload_object_header_s; #endif // _di_f_fss_payload_object_header_s_ + #ifndef _di_f_fss_payload_object_length_s_ + extern const f_string_static_t f_fss_payload_object_length_s; + #endif // _di_f_fss_payload_object_length_s_ + #ifndef _di_f_fss_payload_object_payload_s_ extern const f_string_static_t f_fss_payload_object_payload_s; #endif // _di_f_fss_payload_object_payload_s_ @@ -73,6 +114,10 @@ extern "C" { #ifndef _di_f_fss_payload_object_signature_s_ extern const f_string_static_t f_fss_payload_object_signature_s; #endif // _di_f_fss_payload_object_signature_s_ + + #ifndef _di_f_fss_payload_object_status_s_ + extern const f_string_static_t f_fss_payload_object_status_s; + #endif // _di_f_fss_payload_object_status_s_ #endif // _di_f_fss_payload_s_ #ifdef __cplusplus diff --git a/level_1/fl_fss/c/fss/payload.c b/level_1/fl_fss/c/fss/payload.c index 14de8fd..601d562 100644 --- a/level_1/fl_fss/c/fss/payload.c +++ b/level_1/fl_fss/c/fss/payload.c @@ -9,13 +9,13 @@ extern "C" { /** * Inline helper function to reduce amount of code typed. * - * Process the signed number, converting it to a string and appending that string onto data->cache_1. - * The resulting data->cache_1 is then appended onto the destination value on success. - * If the number is not appended to data->cache_1, then nothing is appended to the destination value. + * Process the signed number, converting it to a string and appending that string onto data->cache. + * The resulting data->cache is then appended onto the destination value on success. + * If the number is not appended to data->cache, then nothing is appended to the destination value. * * @param data * The f_fss_payload_header_write_state_t pointer. - * This resets data->cache_1.used as needed. + * This resets data->cache.used as needed. * @param state * The state passed directly from the f_fss_payload_header_write() parameters. * @param internal @@ -29,16 +29,16 @@ extern "C" { */ static inline uint8_t private_inline_f_payload_header_write_number_signed(f_fss_payload_header_write_state_t * const data, f_state_t * const state, f_fss_payload_header_write_internal_t * const internal, const f_number_signed_t number) { - data->cache_1->used = 0; + data->cache->used = 0; - state->status = f_conversion_number_signed_to_string(number, data->conversion, data->cache_1); + state->status = f_conversion_number_signed_to_string(number, data->conversion, data->cache); if (F_status_is_error(state->status)) return F_true; - if (data->cache_1->used) { + if (data->cache->used) { internal->range.start = 0; - internal->range.stop = data->cache_1->used - 1; + internal->range.stop = data->cache->used - 1; - private_fl_fss_basic_write(F_false, *data->cache_1, 0, &internal->range, &internal->destinations->array[internal->destinations->used].value, state, (void * const) internal); + private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &internal->destinations->array[internal->destinations->used].value, state, (void * const) internal); if (F_status_is_error(state->status)) return F_true; } @@ -48,13 +48,13 @@ extern "C" { /** * Inline helper function to reduce amount of code typed. * - * Process the unsigned number, converting it to a string and appending that string onto data->cache_1. - * The resulting data->cache_1 is then appended onto the destination value on success. - * If the number is not appended to data->cache_1, then nothing is appended to the destination value. + * Process the unsigned number, converting it to a string and appending that string onto data->cache. + * The resulting data->cache is then appended onto the destination value on success. + * If the number is not appended to data->cache, then nothing is appended to the destination value. * * @param data * The f_fss_payload_header_write_state_t pointer. - * This resets data->cache_1.used as needed. + * This resets data->cache.used as needed. * @param state * The state passed directly from the f_fss_payload_header_write() parameters. * @param internal @@ -68,16 +68,16 @@ extern "C" { */ static inline uint8_t private_inline_f_payload_header_write_number_unsigned(f_fss_payload_header_write_state_t * const data, f_state_t * const state, f_fss_payload_header_write_internal_t * const internal, const f_number_unsigned_t number) { - data->cache_1->used = 0; + data->cache->used = 0; - state->status = f_conversion_number_unsigned_to_string(number, data->conversion, data->cache_1); + state->status = f_conversion_number_unsigned_to_string(number, data->conversion, data->cache); if (F_status_is_error(state->status)) return F_true; - if (data->cache_1->used) { + if (data->cache->used) { internal->range.start = 0; - internal->range.stop = data->cache_1->used - 1; + internal->range.stop = data->cache->used - 1; - private_fl_fss_basic_write(F_false, *data->cache_1, 0, &internal->range, &internal->destinations->array[internal->destinations->used].value, state, (void * const) internal); + private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &internal->destinations->array[internal->destinations->used].value, state, (void * const) internal); if (F_status_is_error(state->status)) return F_true; } @@ -104,7 +104,7 @@ extern "C" { f_fss_payload_header_write_state_t * const data = (f_fss_payload_header_write_state_t *) state->data; f_fss_payload_header_write_internal_t internal = macro_f_fss_payload_header_write_internal_t_initialize_2(destinations, destinations->used); - if (!data->cache_1) { + if (!data->cache) { state->status = F_status_set_error(F_parameter); if (state->handle) { @@ -246,7 +246,7 @@ extern "C" { case f_abstruse_strings_e: // @todo flag to break strings into multiple rows. - data->cache_1->used = 0; + data->cache->used = 0; if (headers.array[internal.i].value.is.a_strings) { internal.k = 0; @@ -265,7 +265,7 @@ extern "C" { internal.k += f_fss_extended_next_s.used; } // for - state->status = f_memory_array_increase_by(internal.k, sizeof(f_char_t), (void **) &data->cache_1->string, &data->cache_1->used, &data->cache_1->size); + state->status = f_memory_array_increase_by(internal.k, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size); if (F_status_is_error(state->status)) break; for (internal.j = 0; headers.array[internal.i].value.is.a_strings[internal.j]; ++internal.j) { @@ -282,19 +282,19 @@ extern "C" { internal.range.start = 0; internal.range.stop = string_static.used - 1; - private_fl_fss_basic_write(F_false, string_static, 0, &internal.range, data->cache_1, state, (void * const) &internal); + private_fl_fss_basic_write(F_false, string_static, 0, &internal.range, data->cache, state, (void * const) &internal); if (F_status_is_error(state->status)) break; - data->cache_1->string[data->cache_1->used++] = f_fss_extended_open_s.string[0]; + data->cache->string[data->cache->used++] = f_fss_extended_open_s.string[0]; } } // for if (F_status_is_error_not(state->status)) { // The f_fss_extended_next_s is always added at the end of the loop to avoid an additional condition check in the loop. - data->cache_1->used -= f_fss_extended_next_s.used; + data->cache->used -= f_fss_extended_next_s.used; - state->status = f_string_dynamic_append(*data->cache_1, &destinations->array[destinations->used].value); + state->status = f_string_dynamic_append(*data->cache, &destinations->array[destinations->used].value); } } @@ -305,7 +305,7 @@ extern "C" { break; case f_abstruse_dynamic_e: - data->cache_1->used = 0; + data->cache->used = 0; if (headers.array[internal.i].value.is.a_dynamic.used) { internal.j = headers.array[internal.i].value.is.a_dynamic.used; @@ -314,7 +314,7 @@ extern "C" { internal.j = f_string_ascii_quote_double_s.used * 2; } - state->status = f_memory_array_increase_by(internal.j, sizeof(f_char_t), (void **) &data->cache_1->string, &data->cache_1->used, &data->cache_1->size); + state->status = f_memory_array_increase_by(internal.j, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size); if (F_status_is_error(state->status)) break; macro_f_fss_payload_header_write_process_dynamic_d(data, state, internal, headers.array[internal.i].value.is.a_dynamic); @@ -322,9 +322,9 @@ extern "C" { if (F_status_is_error_not(state->status)) { // The f_fss_extended_next_s is always added at the end of the macro. - data->cache_1->used -= f_fss_extended_next_s.used; + data->cache->used -= f_fss_extended_next_s.used; - state->status = f_string_dynamic_append(*data->cache_1, &destinations->array[destinations->used].value); + state->status = f_string_dynamic_append(*data->cache, &destinations->array[destinations->used].value); } if (F_status_is_error_not(state->status)) { @@ -335,7 +335,7 @@ extern "C" { case f_abstruse_dynamics_e: // @todo flag to break dynamics into multiple rows. - data->cache_1->used = 0; + data->cache->used = 0; if (headers.array[internal.i].value.is.a_dynamics.used) { internal.k = 0; @@ -351,7 +351,7 @@ extern "C" { internal.k += f_fss_extended_next_s.used; } // for - state->status = f_memory_array_increase_by(internal.k, sizeof(f_char_t), (void **) &data->cache_1->string, &data->cache_1->used, &data->cache_1->size); + state->status = f_memory_array_increase_by(internal.k, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size); if (F_status_is_error(state->status)) break; for (internal.j = 0; internal.j < headers.array[internal.i].value.is.a_dynamics.used; ++internal.j) { @@ -368,9 +368,9 @@ extern "C" { if (F_status_is_error_not(state->status)) { // The f_fss_extended_next_s is always added at the end of the loop to avoid an additional condition check in the loop. - data->cache_1->used -= f_fss_extended_next_s.used; + data->cache->used -= f_fss_extended_next_s.used; - state->status = f_string_dynamic_append(*data->cache_1, &destinations->array[destinations->used].value); + state->status = f_string_dynamic_append(*data->cache, &destinations->array[destinations->used].value); } } @@ -381,7 +381,7 @@ extern "C" { break; case f_abstruse_map_e: - data->cache_1->used = 0; + data->cache->used = 0; internal.k = f_fss_extended_next_s.used; if (headers.array[internal.i].value.is.a_map.name.used) { @@ -395,7 +395,7 @@ extern "C" { internal.k += f_string_ascii_quote_double_s.used * 4; } - state->status = f_memory_array_increase_by(internal.k, sizeof(f_char_t), (void **) &data->cache_1->string, &data->cache_1->used, &data->cache_1->size); + state->status = f_memory_array_increase_by(internal.k, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size); if (F_status_is_error(state->status)) break; macro_f_fss_payload_header_write_process_dynamic_d(data, state, internal, headers.array[internal.i].value.is.a_map.name); @@ -406,9 +406,9 @@ extern "C" { if (F_status_is_error_not(state->status)) { // The f_fss_extended_next_s is always added at the end of the macro. - data->cache_1->used -= f_fss_extended_next_s.used; + data->cache->used -= f_fss_extended_next_s.used; - state->status = f_string_dynamic_append(*data->cache_1, &destinations->array[destinations->used].value); + state->status = f_string_dynamic_append(*data->cache, &destinations->array[destinations->used].value); } if (F_status_is_error_not(state->status)) { @@ -422,7 +422,7 @@ extern "C" { break; case f_abstruse_map_multi_e: - data->cache_1->used = 0; + data->cache->used = 0; internal.k = headers.array[internal.i].value.is.a_map_multi.name.used ? headers.array[internal.i].value.is.a_map_multi.name.used : f_string_ascii_quote_double_s.used * 2; internal.k += f_fss_extended_next_s.used; @@ -438,12 +438,12 @@ extern "C" { internal.k += f_fss_extended_next_s.used; } // for - state->status = f_memory_array_increase_by(internal.k, sizeof(f_char_t), (void **) &data->cache_1->string, &data->cache_1->used, &data->cache_1->size); + state->status = f_memory_array_increase_by(internal.k, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size); if (F_status_is_error(state->status)) break; macro_f_fss_payload_header_write_process_dynamic_d(data, state, internal, headers.array[internal.i].value.is.a_map_multi.name); - data->cache_1->string[data->cache_1->used++] = f_fss_extended_next_s.string[0]; + data->cache->string[data->cache->used++] = f_fss_extended_next_s.string[0]; for (internal.l = 0; internal.l < headers.array[internal.i].value.is.a_map_multi.value.used; ++internal.l) { @@ -453,23 +453,23 @@ extern "C" { } if (headers.array[internal.i].value.is.a_map_multi.value.array[internal.l].used) { - state->status = f_string_dynamic_append(headers.array[internal.i].value.is.a_map_multi.value.array[internal.l], data->cache_1); + state->status = f_string_dynamic_append(headers.array[internal.i].value.is.a_map_multi.value.array[internal.l], data->cache); if (F_status_is_error(state->status)) break; } else { - data->cache_1->string[data->cache_1->used++] = f_string_ascii_quote_double_s.string[0]; - data->cache_1->string[data->cache_1->used++] = f_string_ascii_quote_double_s.string[0]; + data->cache->string[data->cache->used++] = f_string_ascii_quote_double_s.string[0]; + data->cache->string[data->cache->used++] = f_string_ascii_quote_double_s.string[0]; } - data->cache_1->string[data->cache_1->used++] = f_fss_extended_next_s.string[0]; + data->cache->string[data->cache->used++] = f_fss_extended_next_s.string[0]; } // for if (F_status_is_error_not(state->status)) { // The f_fss_extended_next_s is always added at the end of the loop to avoid an additional condition check in the loop. - data->cache_1->used -= f_fss_extended_next_s.used; + data->cache->used -= f_fss_extended_next_s.used; - state->status = f_string_dynamic_append(*data->cache_1, &destinations->array[destinations->used].value); + state->status = f_string_dynamic_append(*data->cache, &destinations->array[destinations->used].value); } } else if (headers.array[internal.i].value.is.a_map_multi.name.used) { @@ -495,9 +495,9 @@ extern "C" { case f_abstruse_ranges_e: // @todo break; -/* + case f_abstruse_triple_e: - data->cache_1->used = 0; + data->cache->used = 0; if (headers.array[internal.i].value.is.a_triple.a.used) { internal.k = headers.array[internal.i].value.is.a_triple.a.used; @@ -528,31 +528,33 @@ extern "C" { internal.k = f_string_ascii_quote_double_s.used * 6; } - internal.k += f_fss_extended_open_s.used * 2; + internal.k += f_fss_extended_next_s.used * 2; - if (data->cache_1->used + internal.k > data->cache_1->size) { - state->status = f_memory_array_increase_by(state->step_small + internal.k, sizeof(f_char_t), (void **) &data->cache_1->string, &data->cache_1->used, &data->cache_1->size); - if (F_status_is_error(state->status)) break; - } + state->status = f_memory_array_increase_by(internal.k, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size); + if (F_status_is_error(state->status)) break; macro_f_fss_payload_header_write_process_dynamic_d(data, state, internal, headers.array[internal.i].value.is.a_triple.a); - - data->cache_1->string[data->cache_1->used++] = f_fss_extended_open_s.string[0]; + if (F_status_is_error(state->status)) break; macro_f_fss_payload_header_write_process_dynamic_d(data, state, internal, headers.array[internal.i].value.is.a_triple.b); - - data->cache_1->string[data->cache_1->used++] = f_fss_extended_open_s.string[0]; + if (F_status_is_error(state->status)) break; macro_f_fss_payload_header_write_process_dynamic_d(data, state, internal, headers.array[internal.i].value.is.a_triple.c); - if (F_status_is_error_not(state->status) && data->cache_1->used) { - // @todo build signature, use a callback for this so that the caller can provide an appropriate algorithm. + if (F_status_is_error_not(state->status)) { + + // The f_fss_extended_next_s is always added at the end of the macro. + data->cache->used -= f_fss_extended_next_s.used; + + state->status = f_string_dynamic_append(*data->cache, &destinations->array[destinations->used].value); + } - state->status = f_string_dynamic_append(*data->cache_1, data->cache_1); + if (F_status_is_error_not(state->status)) { + ++destinations->used; } break; -*/ + case f_abstruse_triples_e: // @todo break; diff --git a/level_1/fl_fss/c/fss/payload/define.h b/level_1/fl_fss/c/fss/payload/define.h index e4dbb68..0cd2cf9 100644 --- a/level_1/fl_fss/c/fss/payload/define.h +++ b/level_1/fl_fss/c/fss/payload/define.h @@ -27,7 +27,7 @@ extern "C" { * * macro_f_fss_payload_header_write_process_signed_numbers_d: * Process the numbers array, converting it to a string. - * The data->cache_1 is reset and used (via private_inline_f_payload_header_write_number_signed()). + * The data->cache is reset and used (via private_inline_f_payload_header_write_number_signed()). * The destinations->used is incremented on non-error. * This requires private_inline_f_payload_header_write_number_signed() from payload.c. * @@ -73,7 +73,7 @@ extern "C" { \ if (private_inline_f_payload_header_write_number_signed(data, state, &internal, (f_number_signed_t) numbers.array[internal.j])) break; \ \ - if (data->cache_1->used && internal.j + 1 < numbers.used) { \ + if (data->cache->used && internal.j + 1 < numbers.used) { \ state->status = f_string_dynamic_append(f_fss_extended_open_s, &destination); \ if (F_status_is_error(state->status)) break; \ } \ @@ -92,7 +92,7 @@ extern "C" { \ if (private_inline_f_payload_header_write_number_unsigned(data, state, &internal, (f_number_unsigned_t) numbers.array[internal.j])) break; \ \ - if (data->cache_1->used && internal.j + 1 < numbers.used) { \ + if (data->cache->used && internal.j + 1 < numbers.used) { \ state->status = f_string_dynamic_append(f_fss_extended_open_s, &destination); \ if (F_status_is_error(state->status)) break; \ } \ @@ -106,15 +106,15 @@ extern "C" { internal.range.start = 0; \ internal.range.stop = dynamic.used - 1; \ \ - private_fl_fss_basic_write(F_false, dynamic, 0, &internal.range, data->cache_1, state, (void * const) &internal); \ + private_fl_fss_basic_write(F_false, dynamic, 0, &internal.range, data->cache, state, (void * const) &internal); \ } \ else { \ - data->cache_1->string[data->cache_1->used++] = f_string_ascii_quote_double_s.string[0]; \ - data->cache_1->string[data->cache_1->used++] = f_string_ascii_quote_double_s.string[0]; \ + data->cache->string[data->cache->used++] = f_string_ascii_quote_double_s.string[0]; \ + data->cache->string[data->cache->used++] = f_string_ascii_quote_double_s.string[0]; \ } \ \ if (F_status_is_error_not(state->status)) { \ - data->cache_1->string[data->cache_1->used++] = f_fss_extended_next_s.string[0]; \ + data->cache->string[data->cache->used++] = f_fss_extended_next_s.string[0]; \ } #endif // _di_f_fss_payload_header_write_d_ diff --git a/level_1/fl_fss/c/fss/payload/type.h b/level_1/fl_fss/c/fss/payload/type.h index a4b884a..9e44986 100644 --- a/level_1/fl_fss/c/fss/payload/type.h +++ b/level_1/fl_fss/c/fss/payload/type.h @@ -82,30 +82,28 @@ extern "C" { * * Properties: * - conversion: The conversion data. - * - cache_1: A string cache to use reduce re-allocations on the destination strings (generally required to not be NULL). + * - cache: A string cache to use reduce re-allocations on the destination strings (generally required to not be NULL). */ #ifndef _di_f_fss_payload_header_write_state_t_ typedef struct { f_conversion_data_t conversion; - f_string_dynamic_t *cache_1; + f_string_dynamic_t *cache; } f_fss_payload_header_write_state_t; #define f_fss_payload_header_write_state_t_initialize { \ f_conversion_data_base_10_c, \ 0, \ - 0, \ - 0, \ } - #define macro_f_fss_payload_header_write_state_t_initialize_1(conversion, cache_1) { \ + #define macro_f_fss_payload_header_write_state_t_initialize_1(conversion, cache) { \ conversion, \ - cache_1, \ + cache, \ } - #define macro_f_fss_payload_header_write_state_t_initialize_2(cache_1) { \ + #define macro_f_fss_payload_header_write_state_t_initialize_2(cache) { \ f_conversion_data_base_10_c, \ - cache_1, \ + cache, \ } #endif // _di_f_fss_payload_header_write_state_t_ -- 1.8.3.1