From f2c69d03e97004cf72d1a0025dba0741c1dad6ec Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Tue, 6 Feb 2024 17:17:13 -0600 Subject: [PATCH] Progress: Actually wrap up initial pass of fl_fss_payload_header_map(). I somehow missed adding these changes for the commit 6999271214129e432376dd625f2cc6d097037d40. --- level_1/fl_fss/c/fss/payload.c | 164 ++-- level_1/fl_fss/c/fss/payload/type.h | 9 +- level_1/fl_fss/c/fss/private-payload.c | 1645 +++++++++++++++++++++++++++----- level_1/fl_fss/c/fss/private-payload.h | 264 ++++- 4 files changed, 1721 insertions(+), 361 deletions(-) diff --git a/level_1/fl_fss/c/fss/payload.c b/level_1/fl_fss/c/fss/payload.c index 9d0d7c5..62076ed 100644 --- a/level_1/fl_fss/c/fss/payload.c +++ b/level_1/fl_fss/c/fss/payload.c @@ -176,7 +176,9 @@ extern "C" { string_static.used = string_static.string ? strnlen(string_static.string, F_string_t_size_d) : 0; if (string_static.used || (data->flag & f_fss_payload_header_map_flag_null_string_e)) { - private_fl_payload_header_map_dynamic(data, state, &internal, &string_static, destinations); + if (private_fl_payload_header_map_dynamic(data, state, &internal, &string_static, destinations) == F_false) { + ++destinations->used; + } } else if (data->flag & f_fss_payload_header_map_flag_null_e) { ++destinations->used; @@ -185,15 +187,10 @@ extern "C" { break; case f_abstruse_strings_e: - if (headers.array[internal.i].value.is.a_strings) { - private_fl_payload_header_map_strings(data, state, &internal, headers.array[internal.i].value.is.a_strings, destinations); - } - else if (data->flag & f_fss_payload_header_map_flag_null_string_e) { - // @todo handle join flags. - state->status = f_string_dynamic_append(internal.quote_null, &destinations->array[destinations->used].value); - if (F_status_is_error(state->status)) break; - - ++destinations->used; + if (headers.array[internal.i].value.is.a_strings || (data->flag & f_fss_payload_header_map_flag_null_strings_e)) { + if (private_fl_payload_header_map_strings(data, state, &internal, headers.array[internal.i].value.is.a_strings, destinations) == F_false) { + ++destinations->used; + } } else if (data->flag & f_fss_payload_header_map_flag_null_e) { ++destinations->used; @@ -203,7 +200,9 @@ extern "C" { case f_abstruse_dynamic_e: if (headers.array[internal.i].value.is.a_dynamic.used || (data->flag & f_fss_payload_header_map_flag_null_dynamic_e)) { - private_fl_payload_header_map_dynamic(data, state, &internal, &headers.array[internal.i].value.is.a_dynamic, destinations); + if (private_fl_payload_header_map_dynamic(data, state, &internal, &headers.array[internal.i].value.is.a_dynamic, destinations) == F_false) { + ++destinations->used; + } } else if (data->flag & f_fss_payload_header_map_flag_null_e) { ++destinations->used; @@ -212,15 +211,10 @@ extern "C" { break; case f_abstruse_dynamics_e: - if (headers.array[internal.i].value.is.a_dynamics.used) { - private_fl_payload_header_map_dynamics(data, state, &internal, &headers.array[internal.i].value.is.a_dynamics, destinations); - } - else if (data->flag & f_fss_payload_header_map_flag_null_dynamic_e) { - // @todo handle join flags. - state->status = f_string_dynamic_append(internal.quote_null, &destinations->array[destinations->used].value); - if (F_status_is_error(state->status)) break; - - ++destinations->used; + if (headers.array[internal.i].value.is.a_dynamics.used || (data->flag & f_fss_payload_header_map_flag_null_dynamics_e)) { + if (private_fl_payload_header_map_dynamics(data, state, &internal, &headers.array[internal.i].value.is.a_dynamics, destinations) == F_false) { + ++destinations->used; + } } else if (data->flag & f_fss_payload_header_map_flag_null_e) { ++destinations->used; @@ -230,18 +224,9 @@ extern "C" { case f_abstruse_map_e: if (headers.array[internal.i].value.is.a_map.name.used || headers.array[internal.i].value.is.a_map.value.used) { - private_fl_payload_header_map_map(data, state, &internal, &headers.array[internal.i].value.is.a_map, destinations); - } - else if (data->flag & f_fss_payload_header_map_flag_null_map_name_value_e) { - if (data->flag & f_fss_payload_header_map_flag_join_map_e) { - state->status = f_string_dynamic_append(internal.quote_null, &destinations->array[destinations->used].value); - if (F_status_is_error(state->status)) break; - + if (private_fl_payload_header_map_map(data, state, &internal, &headers.array[internal.i].value.is.a_map, destinations) == F_false) { ++destinations->used; } - else { - private_fl_payload_header_map_map_name_value_null(data, state, &internal, destinations); - } } else if (data->flag & f_fss_payload_header_map_flag_null_e) { ++destinations->used; @@ -250,15 +235,10 @@ extern "C" { break; case f_abstruse_maps_e: - if (headers.array[internal.i].value.is.a_maps.used) { - private_fl_payload_header_map_maps(data, state, &internal, &headers.array[internal.i].value.is.a_maps, destinations); - } - else if (data->flag & f_fss_payload_header_map_flag_null_maps_e) { - // @todo handle join flags. - state->status = f_string_dynamic_append(internal.quote_null, &destinations->array[destinations->used].value); - if (F_status_is_error(state->status)) break; - - ++destinations->used; + if (headers.array[internal.i].value.is.a_maps.used || (data->flag & f_fss_payload_header_map_flag_null_maps_e)) { + if (private_fl_payload_header_map_maps(data, state, &internal, &headers.array[internal.i].value.is.a_maps, destinations) == F_false) { + ++destinations->used; + } } else if (data->flag & f_fss_payload_header_map_flag_null_e) { ++destinations->used; @@ -267,16 +247,51 @@ extern "C" { break; case f_abstruse_map_multi_e: - // @todo + if (headers.array[internal.i].value.is.a_map_multi.name.used || headers.array[internal.i].value.is.a_map_multi.value.used || (data->flag & f_fss_payload_header_map_flag_null_map_multi_values_name_e)) { + if (private_fl_payload_header_map_map_multi(data, state, &internal, &headers.array[internal.i].value.is.a_map_multi, destinations) == F_false) { + ++destinations->used; + } + } + else if (data->flag & f_fss_payload_header_map_flag_null_e) { + ++destinations->used; + } + break; case f_abstruse_map_multis_e: - // @todo + if (headers.array[internal.i].value.is.a_map_multis.used || (data->flag & f_fss_payload_header_map_flag_null_map_multis_e)) { + if (private_fl_payload_header_map_map_multis(data, state, &internal, &headers.array[internal.i].value.is.a_map_multis, destinations) == F_false) { + ++destinations->used; + } + } + else if (data->flag & f_fss_payload_header_map_flag_null_e) { + ++destinations->used; + } + break; case f_abstruse_quantity_e: + if (!headers.array[internal.i].value.is.a_quantity.total || (data->flag & f_fss_payload_header_map_flag_null_quantity_e)) { + if (private_fl_payload_header_map_quantity(data, state, &internal, headers.array[internal.i].value.is.a_quantity, destinations) == F_false) { + ++destinations->used; + } + } + else if (data->flag & f_fss_payload_header_map_flag_null_e) { + ++destinations->used; + } + + break; + case f_abstruse_quantitys_e: - // @todo + if (headers.array[internal.i].value.is.a_quantitys.used || (data->flag & f_fss_payload_header_map_flag_null_quantitys_e)) { + if (private_fl_payload_header_map_quantitys(data, state, &internal, headers.array[internal.i].value.is.a_quantitys, destinations) == F_false) { + ++destinations->used; + } + } + else if (data->flag & f_fss_payload_header_map_flag_null_e) { + ++destinations->used; + } + break; case f_abstruse_range_e: @@ -303,71 +318,30 @@ extern "C" { break; -// @todo resume after here. case f_abstruse_triple_e: - // @todo update this. - 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; - - if (headers.array[internal.i].value.is.a_triple.b.used) { - internal.k += headers.array[internal.i].value.is.a_triple.b.used; - internal.k += headers.array[internal.i].value.is.a_triple.c.used ? headers.array[internal.i].value.is.a_triple.c.used : internal.quote_null.used; - } - else if (headers.array[internal.i].value.is.a_triple.c.used) { - internal.k += headers.array[internal.i].value.is.a_triple.c.used + internal.quote_null.used; - } - else { - internal.k = internal.quote_null.used * 2; - } - } - else if (headers.array[internal.i].value.is.a_triple.b.used) { - if (headers.array[internal.i].value.is.a_triple.c.used) { - internal.k = internal.quote_null.used + headers.array[internal.i].value.is.a_triple.b.used + headers.array[internal.i].value.is.a_triple.c.used; - } - else { - internal.k = internal.quote_null.used * 2 + headers.array[internal.i].value.is.a_triple.b.used; + if (headers.array[internal.i].value.is.a_triple.a.used || headers.array[internal.i].value.is.a_triple.b.used || headers.array[internal.i].value.is.a_triple.c.used || (data->flag & f_fss_payload_header_map_flag_null_triple_e)) { + if (private_fl_payload_header_map_triple(data, state, &internal, headers.array[internal.i].value.is.a_triple, destinations) == F_false) { + ++destinations->used; } } - else if (headers.array[internal.i].value.is.a_triple.c.used) { - internal.k = internal.quote_null.used * 2 + headers.array[internal.i].value.is.a_triple.c.used; - } - else { - internal.k = internal.quote_null.used * 3; + else if (data->flag & f_fss_payload_header_map_flag_null_e) { + ++destinations->used; } - internal.k += f_fss_extended_next_s.used * 2; - - 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); - 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); - 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)) { - - // The f_fss_extended_next_s is always added at the end of the macro. - data->cache->used -= f_fss_extended_next_s.used; + break; - state->status = f_string_dynamic_append(*data->cache, &destinations->array[destinations->used].value); + case f_abstruse_triples_e: + if (headers.array[internal.i].value.is.a_triples.used || (data->flag & f_fss_payload_header_map_flag_null_triples_e)) { + if (private_fl_payload_header_map_triples(data, state, &internal, headers.array[internal.i].value.is.a_triples, destinations) == F_false) { + ++destinations->used; + } } - - if (F_status_is_error_not(state->status)) { + else if (data->flag & f_fss_payload_header_map_flag_null_e) { ++destinations->used; } break; - case f_abstruse_triples_e: - // @todo - break; - default: break; } diff --git a/level_1/fl_fss/c/fss/payload/type.h b/level_1/fl_fss/c/fss/payload/type.h index a4b3392..dbae37e 100644 --- a/level_1/fl_fss/c/fss/payload/type.h +++ b/level_1/fl_fss/c/fss/payload/type.h @@ -25,7 +25,8 @@ extern "C" { * - i: A counter used for the "headers" outer arrays. * - j: A counter used for the inner loop or for pre-allocation counting. * - k: A number used for converting values but also made available for use as a counter if need be. - * - l: A counter used for more complex use cases such as with multi-maps. + * - l: A counter used for more complex use cases, such as with multi-maps. + * - m: A counter used for more complex use cases, such as with multi-maps. * - range: Used for passing a given string range to the FSS write functions. * - conversion: The conversion data. * - quote_null: The string representing an empty, aka NULL, Content. This is generally double-quotes. @@ -40,6 +41,7 @@ extern "C" { f_number_unsigned_t j; f_number_unsigned_t k; f_number_unsigned_t l; + f_number_unsigned_t m; f_range_t range; f_conversion_data_t conversion; @@ -55,6 +57,7 @@ extern "C" { 0, \ 0, \ 0, \ + 0, \ f_range_t_initialize, \ f_conversion_data_base_10_c, \ f_string_static_t_initialize, \ @@ -62,13 +65,14 @@ extern "C" { 0, \ } - #define macro_f_fss_payload_header_internal_t_initialize_1(quote, step, i, j, k, l, range, conversion, destinations, quote_null, original) { \ + #define macro_f_fss_payload_header_internal_t_initialize_1(quote, step, i, j, k, l, m, range, conversion, destinations, quote_null, original) { \ quote, \ step, \ i, \ j, \ k, \ l, \ + m, \ range, \ conversion, \ destinations, \ @@ -83,6 +87,7 @@ extern "C" { 0, \ 0, \ 0, \ + 0, \ f_range_t_initialize, \ f_conversion_data_base_10_c, \ f_string_static_t_initialize, \ diff --git a/level_1/fl_fss/c/fss/private-payload.c b/level_1/fl_fss/c/fss/private-payload.c index ae09146..b147bdb 100644 --- a/level_1/fl_fss/c/fss/private-payload.c +++ b/level_1/fl_fss/c/fss/private-payload.c @@ -44,7 +44,6 @@ extern "C" { if (F_status_is_error(state->status)) return F_true; - ++destinations->used; state->status = F_okay; return F_false; @@ -54,73 +53,80 @@ extern "C" { #if !defined(_di_fl_fss_payload_header_map_) uint8_t private_fl_payload_header_map_dynamics(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, f_string_statics_t * const buffers, f_string_maps_t * const destinations) { - data->cache->used = 0; - internal->k = 0; - - state->status = f_memory_array_increase_by(buffers->used + ((f_fss_extended_next_s.used + internal->quote_null.used) * buffers->used), sizeof(f_char_t), (void **) &destinations->array[destinations->used].value.string, &destinations->array[destinations->used].value.used, &destinations->array[destinations->used].value.size); - if (F_status_is_error(state->status)) return F_true; + if (buffers->used) { + data->cache->used = 0; + internal->k = 0; - if (data->flag & f_fss_payload_header_map_flag_join_dynamics_e) { - state->status = f_memory_array_increase_by(buffers->used + ((f_fss_space_s.used + internal->quote_null.used) * buffers->used), sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size); + state->status = f_memory_array_increase_by(buffers->used + ((f_fss_extended_next_s.used + internal->quote_null.used) * buffers->used), sizeof(f_char_t), (void **) &destinations->array[destinations->used].value.string, &destinations->array[destinations->used].value.used, &destinations->array[destinations->used].value.size); if (F_status_is_error(state->status)) return F_true; - } - - for (internal->j = 0; internal->j < buffers->used; ++internal->j) { - - if (state->interrupt) { - state->interrupt((void * const) state, (void * const) internal); - if (F_status_set_fine(state->status) == F_interrupt) return F_true; - } if (data->flag & f_fss_payload_header_map_flag_join_dynamics_e) { - state->status = f_string_dynamic_append(buffers->array[internal->j], data->cache); - if (F_status_is_error(state->status)) return F_true; - - state->status = f_string_dynamic_append_assure(f_string_space_s, data->cache); + state->status = f_memory_array_increase_by(buffers->used + ((f_fss_space_s.used + internal->quote_null.used) * buffers->used), sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size); if (F_status_is_error(state->status)) return F_true; } - else { - if (buffers->array[internal->j].used) { - internal->range.start = 0; - internal->range.stop = buffers->array[internal->j].used - 1; - private_fl_fss_basic_write(F_false, buffers->array[internal->j], internal->quote, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + for (internal->j = 0; internal->j < buffers->used; ++internal->j) { + + if (state->interrupt) { + state->interrupt((void * const) state, (void * const) internal); + if (F_status_set_fine(state->status) == F_interrupt) return F_true; + } + + if (data->flag & f_fss_payload_header_map_flag_join_dynamics_e) { + state->status = f_string_dynamic_append(buffers->array[internal->j], data->cache); if (F_status_is_error(state->status)) return F_true; - state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); + state->status = f_string_dynamic_append_assure(f_string_space_s, data->cache); if (F_status_is_error(state->status)) return F_true; } - else if (data->flag & f_fss_payload_header_map_flag_null_string_e) { - state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); - if (F_status_is_error(state->status)) return F_true; + else { + if (buffers->array[internal->j].used) { + internal->range.start = 0; + internal->range.stop = buffers->array[internal->j].used - 1; + + private_fl_fss_basic_write(F_false, buffers->array[internal->j], internal->quote, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + else if (data->flag & f_fss_payload_header_map_flag_null_dynamic_e) { + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } } - } - } // for + } // for - if (data->flag & f_fss_payload_header_map_flag_join_dynamics_e) { - if (data->cache->used) { + if (data->flag & f_fss_payload_header_map_flag_join_dynamics_e) { + if (data->cache->used) { - // Remove the always added trailing space. - data->cache->used -= f_string_space_s.used; + // Remove the always added trailing space. + data->cache->used -= f_string_space_s.used; - internal->range.start = 0; - internal->range.stop = data->cache->used - 1; + internal->range.start = 0; + internal->range.stop = data->cache->used - 1; - private_fl_fss_basic_write(F_false, *data->cache, internal->quote, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); - if (F_status_is_error(state->status)) return F_true; - } - else { - if (data->flag & f_fss_payload_header_map_flag_null_string_e) { - state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); + private_fl_fss_basic_write(F_false, *data->cache, internal->quote, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); if (F_status_is_error(state->status)) return F_true; } + else { + if (data->flag & f_fss_payload_header_map_flag_null_dynamic_e) { + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + } + } + } + else { + if (data->flag & f_fss_payload_header_map_flag_null_dynamic_e) { + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; } } state->status = f_string_dynamic_strip_null(&destinations->array[destinations->used].value); if (F_status_is_error(state->status)) return F_true; - ++destinations->used; state->status = F_okay; return F_false; @@ -130,60 +136,95 @@ extern "C" { #if !defined(_di_fl_fss_payload_header_map_) uint8_t private_fl_payload_header_map_map(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, f_string_map_t * const map, f_string_maps_t * const destinations) { - if (data->flag & f_fss_payload_header_map_flag_join_map_e) { - state->status = f_memory_array_increase_by(map->name.used + map->value.used + f_string_space_s.used, sizeof(f_char_t), (void **) &destinations->array[destinations->used].value.string, &destinations->array[destinations->used].value.used, &destinations->array[destinations->used].value.size); - if (F_status_is_error(state->status)) return F_true; + state->status = f_memory_array_increase_by(map->name.used + map->value.used + f_string_space_s.used + internal->quote_null.used * 2, sizeof(f_char_t), (void **) &destinations->array[destinations->used].value.string, &destinations->array[destinations->used].value.used, &destinations->array[destinations->used].value.size); + if (F_status_is_error(state->status)) return F_true; + if (data->flag & f_fss_payload_header_map_flag_join_map_e) { data->cache->used = 0; state->status = f_memory_array_increase_by(map->name.used + map->value.used + f_string_space_s.used, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size); if (F_status_is_error(state->status)) return F_true; - if (map->name.used) { - f_string_dynamic_append(map->name, data->cache); + if (map->name.used || (data->flag & f_fss_payload_header_map_flag_null_map_name_e)) { + if (map->name.used) { + state->status = f_string_dynamic_append(map->name, data->cache); + } + else { + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + } + + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); if (F_status_is_error(state->status)) return F_true; + } + if (map->value.used || (data->flag & f_fss_payload_header_map_flag_null_map_value_e)) { if (map->value.used) { - f_string_dynamic_append_assure(f_fss_space_s, data->cache); - if (F_status_is_error(state->status)) return F_true; + state->status = f_string_dynamic_append(map->value, data->cache); + } + else { + state->status = f_string_dynamic_append(internal->quote_null, data->cache); } - } - if (map->value.used) { - f_string_dynamic_append(map->value, data->cache); if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); + if (F_status_is_error(state->status)) return F_true; + } + + // Remove the always added trailing space. + if (data->cache->used) { + data->cache->used -= f_fss_space_s.used; } private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); if (F_status_is_error(state->status)) return F_true; } else { - if (map->name.used) { - internal->range.start = 0; - internal->range.stop = map->name.used - 1; + if (map->name.used || (data->flag & f_fss_payload_header_map_flag_null_map_name_e)) { + if (map->name.used) { + internal->range.start = 0; + internal->range.stop = map->name.used - 1; + + private_fl_fss_basic_write(F_false, map->name, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + } + else { + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); + } + + if (F_status_is_error(state->status)) return F_true; - private_fl_fss_basic_write(F_false, map->name, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); if (F_status_is_error(state->status)) return F_true; + } + if (map->value.used || (data->flag & f_fss_payload_header_map_flag_null_map_value_e)) { if (map->value.used) { - f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); - if (F_status_is_error(state->status)) return F_true; + internal->range.start = 0; + internal->range.stop = map->value.used - 1; + + private_fl_fss_basic_write(F_false, map->value, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + } + else { + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); } - } - if (map->value.used) { - internal->range.start = 0; - internal->range.stop = map->value.used - 1; + if (F_status_is_error(state->status)) return F_true; - private_fl_fss_basic_write(F_false, map->value, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); if (F_status_is_error(state->status)) return F_true; } + + // Remove the always added trailing space. + if (destinations->array[destinations->used].value.used) { + destinations->array[destinations->used].value.used -= f_fss_extended_next_s.used; + } } state->status = f_string_dynamic_strip_null(&destinations->array[destinations->used].value); if (F_status_is_error(state->status)) return F_true; - ++destinations->used; state->status = F_okay; return F_false; @@ -191,85 +232,77 @@ extern "C" { #endif // !defined(_di_fl_fss_payload_header_map_) #if !defined(_di_fl_fss_payload_header_map_) - uint8_t private_fl_payload_header_map_map_name_value_null(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, f_string_maps_t * const destinations) { + uint8_t private_fl_payload_header_map_map_multi(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, f_string_map_multi_t * const map, f_string_maps_t * const destinations) { - state->status = f_memory_array_increase_by(internal->quote_null.used * 2 + f_fss_extended_next_s.used, sizeof(f_char_t), (void **) &destinations->array[destinations->used].value.string, &destinations->array[destinations->used].value.used, &destinations->array[destinations->used].value.size); - if (F_status_is_error(state->status)) return F_true; + if (map->name.used || (data->flag & f_fss_payload_header_map_flag_null_map_multi_name_e)) { + internal->k = map->name.used + internal->quote_null.used; + } + else { + internal->k = 0; + } - state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); - if (F_status_is_error(state->status)) return F_true; + if (map->value.used) { + for (internal->l = 0; internal->l < map->value.used; ++internal->l) { - state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); - if (F_status_is_error(state->status)) return F_true; + if (map->value.array[internal->l].used || (data->flag & f_fss_payload_header_map_flag_null_map_multi_values_e)) { + internal->k += f_string_space_s.used + map->value.array[internal->l].used + internal->quote_null.used; + } + } // for + } + else if (data->flag & f_fss_payload_header_map_flag_null_map_multi_values_e) { + internal->k += f_string_space_s.used + internal->quote_null.used; + } - state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); + state->status = f_memory_array_increase_by(internal->k, sizeof(f_char_t), (void **) &destinations->array[destinations->used].value.string, &destinations->array[destinations->used].value.used, &destinations->array[destinations->used].value.size); if (F_status_is_error(state->status)) return F_true; - ++destinations->used; - state->status = F_none; - - return F_false; - } -#endif // !defined(_di_fl_fss_payload_header_map_) - -#if !defined(_di_fl_fss_payload_header_maps_) - uint8_t private_fl_payload_header_map_maps(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, f_string_maps_t * const maps, f_string_maps_t * const destinations) { + if (data->flag & f_fss_payload_header_map_flag_join_map_multi_e) { + data->cache->used = 0; - internal->k = 0; + 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)) return F_true; - for (internal->l = 0; internal->l < maps->used; ++internal->k) { + if (map->name.used || (data->flag & f_fss_payload_header_map_flag_null_map_multi_name_e)) { + if (map->name.used) { + state->status = f_string_dynamic_append(map->name, data->cache); + } + else { + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + } - if (maps->array[internal->l].name.used) { - internal->k += maps->array[internal->k].name.used + f_fss_extended_next_s.used + internal->quote_null.used; - } - else if (data->flag & f_fss_payload_header_map_flag_null_map_name_e) { - internal->k += f_fss_extended_next_s.used + internal->quote_null.used; - } + if (F_status_is_error(state->status)) return F_true; - if (maps->array[internal->l].value.used) { - internal->k += maps->array[internal->l].value.used + f_fss_extended_next_s.used + internal->quote_null.used; - } - else if (data->flag & f_fss_payload_header_map_flag_null_map_value_e) { - internal->k += f_fss_extended_next_s.used + internal->quote_null.used; + state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); + if (F_status_is_error(state->status)) return F_true; } - } // for - - if (data->flag & f_fss_payload_header_map_flag_join_maps_e) { - data->cache->used = 0; - - 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)) return F_true; - for (internal->l = 0; internal->l < maps->used; ++internal->l) { + if (map->value.used || (data->flag & f_fss_payload_header_map_flag_null_map_multi_values_e)) { + if (map->value.used) { + for (internal->m = 0; internal->m < map->value.used; ++internal->m) { - if (maps->array[internal->l].name.used || (data->flag & f_fss_payload_header_map_flag_null_map_name_e)) { - if (maps->array[internal->l].name.used) { - f_string_dynamic_append(maps->array[internal->l].name, data->cache); - } - else if (data->flag & f_fss_payload_header_map_flag_null_map_name_e) { - state->status = f_string_dynamic_append(internal->quote_null, data->cache); - } + if (map->value.array[internal->m].used || (data->flag & f_fss_payload_header_map_flag_null_map_multi_values_e)) { + if (map->value.array[internal->m].used) { + state->status = f_string_dynamic_append(map->value.array[internal->m], data->cache); + } + else { + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + } - if (F_status_is_error(state->status)) return F_true; + if (F_status_is_error(state->status)) return F_true; - if (maps->array[internal->l].value.used || (data->flag & f_fss_payload_header_map_flag_null_map_value_e)) { - f_string_dynamic_append_assure(f_fss_space_s, data->cache); - if (F_status_is_error(state->status)) return F_true; + state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); + if (F_status_is_error(state->status)) return F_true; + } } } - - if (maps->array[internal->l].value.used) { - f_string_dynamic_append(maps->array[internal->l].value, data->cache); - } - else if (data->flag & f_fss_payload_header_map_flag_null_map_value_e) { + else { state->status = f_string_dynamic_append(internal->quote_null, data->cache); + if (F_status_is_error(state->status)) return F_true; } - if (F_status_is_error(state->status)) return F_true; - state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); if (F_status_is_error(state->status)) return F_true; - } // for + } // Remove the always added trailing space. if (data->cache->used) { @@ -279,121 +312,626 @@ extern "C" { private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); if (F_status_is_error(state->status)) return F_true; } - else if (data->flag & f_fss_payload_header_map_flag_join_map_e) { - data->cache->used = 0; - - 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)) return F_true; - - for (internal->l = 0; internal->l < maps->used; ++internal->l) { - - data->cache->used = 0; - - if (maps->array[internal->l].name.used || (data->flag & f_fss_payload_header_map_flag_null_map_name_e)) { - if (maps->array[internal->l].name.used) { - f_string_dynamic_append(maps->array[internal->l].name, data->cache); - } - else if (data->flag & f_fss_payload_header_map_flag_null_map_name_e) { - state->status = f_string_dynamic_append(internal->quote_null, data->cache); - } - - if (F_status_is_error(state->status)) return F_true; - - if (maps->array[internal->l].value.used || (data->flag & f_fss_payload_header_map_flag_null_map_value_e)) { - f_string_dynamic_append_assure(f_fss_space_s, data->cache); - if (F_status_is_error(state->status)) return F_true; - } - } + else { + if (map->name.used || (data->flag & f_fss_payload_header_map_flag_null_map_multi_name_e)) { + if (map->name.used) { + internal->range.start = 0; + internal->range.stop = map->name.used - 1; - if (maps->array[internal->l].value.used) { - f_string_dynamic_append(maps->array[internal->l].value, data->cache); + private_fl_fss_basic_write(F_false, map->name, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); } - else if (data->flag & f_fss_payload_header_map_flag_null_map_value_e) { - state->status = f_string_dynamic_append(internal->quote_null, data->cache); + else { + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); } if (F_status_is_error(state->status)) return F_true; - private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); if (F_status_is_error(state->status)) return F_true; + } - if (internal->l + 1 < maps->used) { - state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); - if (F_status_is_error(state->status)) return F_true; - } - } // for - } - else { - state->status = f_memory_array_increase_by(internal->k, sizeof(f_char_t), (void **) &destinations->array[destinations->used].value.string, &destinations->array[destinations->used].value.used, &destinations->array[destinations->used].value.size); - if (F_status_is_error(state->status)) return F_true; - - for (internal->l = 0; internal->l < maps->used; ++internal->l) { + if (map->value.used || (data->flag & f_fss_payload_header_map_flag_null_map_multi_values_e)) { + if (map->value.used) { - if (maps->array[internal->l].name.used || (data->flag & f_fss_payload_header_map_flag_null_map_name_e)) { - if (maps->array[internal->l].name.used) { - internal->range.start = 0; - internal->range.stop = maps->array[internal->l].name.used - 1; + for (internal->m = 0; internal->m < map->value.used; ++internal->m) { - private_fl_fss_basic_write(F_false, maps->array[internal->l].name, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); - if (F_status_is_error(state->status)) return F_true; - } - else if (data->flag & f_fss_payload_header_map_flag_null_map_name_e) { - state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); - if (F_status_is_error(state->status)) return F_true; - } + if (map->value.array[internal->m].used || (data->flag & f_fss_payload_header_map_flag_null_map_multi_values_e)) { + if (map->value.array[internal->m].used) { + internal->range.start = 0; + internal->range.stop = map->value.used - 1; - if (maps->array[internal->l].value.used) { - f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); - if (F_status_is_error(state->status)) return F_true; - } - } + private_fl_fss_basic_write(F_false, map->value.array[internal->m], 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + } + else { + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); + } - if (maps->array[internal->l].value.used) { - internal->range.start = 0; - internal->range.stop = maps->array[internal->l].value.used - 1; + if (F_status_is_error(state->status)) return F_true; - private_fl_fss_basic_write(F_true, maps->array[internal->l].value, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); - if (F_status_is_error(state->status)) return F_true; + state->status = f_string_dynamic_append_assure(f_fss_space_s, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + } // for } - else if (data->flag & f_fss_payload_header_map_flag_null_map_value_e) { + else { state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); - if (F_status_is_error(state->status)) return F_true; } - } // for + + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + + // Remove the always added trailing space. + if (destinations->array[destinations->used].value.used) { + destinations->array[destinations->used].value.used -= f_fss_extended_next_s.used; + } } state->status = f_string_dynamic_strip_null(&destinations->array[destinations->used].value); if (F_status_is_error(state->status)) return F_true; - ++destinations->used; state->status = F_okay; return F_false; } -#endif // !defined(_di_fl_fss_payload_header_maps_) +#endif // !defined(_di_fl_fss_payload_header_map_) -#if !defined(_di_fl_fss_payload_header_map_) - uint8_t private_fl_payload_header_map_number_signed(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, const f_number_signed_t number) { +#if !defined(_di_fl_fss_payload_header_maps_) + uint8_t private_fl_payload_header_map_map_multis(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, f_string_map_multis_t * const maps, f_string_maps_t * const destinations) { - if (data->cache->used) { - state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, data->cache); - if (F_status_is_error(state->status)) return F_true; - } + if (maps->used) { + internal->k = 0; + internal->l = 0; - state->status = f_conversion_number_signed_to_string(number, data->conversion, data->cache); - if (F_status_is_error(state->status)) return F_true; + for (; internal->l < maps->used; ++internal->k) { - state->status = F_okay; + if (state->interrupt) { + state->interrupt((void * const) state, (void * const) internal); + if (F_status_set_fine(state->status) == F_interrupt) return F_true; + } - return F_false; - } -#endif // !defined(_di_fl_fss_payload_header_map_) + if (maps->array[internal->l].name.used) { + internal->k += maps->array[internal->k].name.used + f_fss_extended_next_s.used + internal->quote_null.used; + } + else if (data->flag & f_fss_payload_header_map_flag_null_map_multi_name_e) { + internal->k += f_fss_extended_next_s.used + internal->quote_null.used; + } -#if !defined(_di_fl_fss_payload_header_map_) - uint8_t private_fl_payload_header_map_number_unsigned(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, const f_number_unsigned_t number) { + if (maps->array[internal->l].value.used) { + for (internal->m = 0; internal->m < maps->array[internal->l].value.used; ++internal->m) { - if (data->cache->used) { - state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, data->cache); + if (maps->array[internal->l].value.array[internal->m].used) { + internal->k += maps->array[internal->l].value.array[internal->m].used + f_fss_extended_next_s.used + internal->quote_null.used; + } + else { + internal->k += f_fss_extended_next_s.used + internal->quote_null.used; + } + } // for + } + else if (data->flag & f_fss_payload_header_map_flag_null_map_multi_values_e) { + internal->k += f_fss_extended_next_s.used + internal->quote_null.used; + } + } // for + + if (data->flag & f_fss_payload_header_map_flag_join_map_multis_e) { + data->cache->used = 0; + + 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)) return F_true; + + for (internal->l = 0; internal->l < maps->used; ++internal->l) { + + if (state->interrupt) { + state->interrupt((void * const) state, (void * const) internal); + if (F_status_set_fine(state->status) == F_interrupt) return F_true; + } + + if (maps->array[internal->l].name.used || (data->flag & f_fss_payload_header_map_flag_null_map_multi_name_e)) { + if (maps->array[internal->l].name.used) { + state->status = f_string_dynamic_append(maps->array[internal->l].name, data->cache); + } + else if (data->flag & f_fss_payload_header_map_flag_null_map_multi_name_e) { + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + } + + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); + if (F_status_is_error(state->status)) return F_true; + } + + if (maps->array[internal->l].value.used || (data->flag & f_fss_payload_header_map_flag_null_map_multi_values_e)) { + if (maps->array[internal->l].value.used) { + for (internal->m = 0; internal->m < maps->array[internal->l].value.used; ++internal->m) { + + if (maps->array[internal->l].value.array[internal->m].used || (data->flag & f_fss_payload_header_map_flag_null_map_multi_values_e)) { + if (maps->array[internal->l].value.array[internal->m].used) { + state->status = f_string_dynamic_append(maps->array[internal->l].value.array[internal->m], data->cache); + } + else if (data->flag & f_fss_payload_header_map_flag_null_map_multi_values_e) { + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + } + + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); + if (F_status_is_error(state->status)) return F_true; + } + } // for + } + else { + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + } + + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); + if (F_status_is_error(state->status)) return F_true; + } + } // for + + // Remove the always added trailing space. + if (data->cache->used) { + data->cache->used -= f_fss_space_s.used; + } + + private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + if (F_status_is_error(state->status)) return F_true; + } + else if (data->flag & f_fss_payload_header_map_flag_join_map_multi_e) { + data->cache->used = 0; + + 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)) return F_true; + + for (internal->l = 0; internal->l < maps->used; ++internal->l) { + + if (state->interrupt) { + state->interrupt((void * const) state, (void * const) internal); + if (F_status_set_fine(state->status) == F_interrupt) return F_true; + } + + data->cache->used = 0; + + if (maps->array[internal->l].name.used || (data->flag & f_fss_payload_header_map_flag_null_map_multi_name_e)) { + if (maps->array[internal->l].name.used) { + state->status = f_string_dynamic_append(maps->array[internal->l].name, data->cache); + } + else if (data->flag & f_fss_payload_header_map_flag_null_map_multi_name_e) { + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + } + + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); + if (F_status_is_error(state->status)) return F_true; + } + + if (maps->array[internal->l].value.used || (data->flag & f_fss_payload_header_map_flag_null_map_multi_values_e)) { + if (maps->array[internal->l].value.used) { + for (internal->m = 0; internal->m < maps->array[internal->l].value.used; ++internal->m) { + + if (maps->array[internal->l].value.array[internal->m].used || (data->flag & f_fss_payload_header_map_flag_null_map_multi_values_e)) { + if (maps->array[internal->l].value.array[internal->m].used) { + state->status = f_string_dynamic_append(maps->array[internal->l].value.array[internal->m], data->cache); + } + else if (data->flag & f_fss_payload_header_map_flag_null_map_multi_values_e) { + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + } + + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); + if (F_status_is_error(state->status)) return F_true; + } + } // for + } + else if (data->flag & f_fss_payload_header_map_flag_null_map_multi_values_e) { + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + } + + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); + if (F_status_is_error(state->status)) return F_true; + } + + // Remove the always added trailing space. + if (data->cache->used) { + data->cache->used -= f_fss_space_s.used; + } + + private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } // for + + // Remove the always added trailing space. + if (destinations->array[destinations->used].value.used) { + destinations->array[destinations->used].value.used -= f_fss_extended_next_s.used; + } + } + else { + state->status = f_memory_array_increase_by(internal->k, sizeof(f_char_t), (void **) &destinations->array[destinations->used].value.string, &destinations->array[destinations->used].value.used, &destinations->array[destinations->used].value.size); + if (F_status_is_error(state->status)) return F_true; + + for (internal->l = 0; internal->l < maps->used; ++internal->l) { + + if (state->interrupt) { + state->interrupt((void * const) state, (void * const) internal); + if (F_status_set_fine(state->status) == F_interrupt) return F_true; + } + + if (maps->array[internal->l].name.used || (data->flag & f_fss_payload_header_map_flag_null_map_multi_name_e)) { + if (maps->array[internal->l].name.used) { + internal->range.start = 0; + internal->range.stop = maps->array[internal->l].name.used - 1; + + private_fl_fss_basic_write(F_false, maps->array[internal->l].name, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + if (F_status_is_error(state->status)) return F_true; + } + else if (data->flag & f_fss_payload_header_map_flag_null_map_multi_name_e) { + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + + state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + + if (maps->array[internal->l].value.used || (data->flag & f_fss_payload_header_map_flag_null_map_multi_values_e)) { + for (internal->m = 0; internal->m < maps->array[internal->l].value.used; ++internal->m) { + + if (maps->array[internal->l].value.used || (data->flag & f_fss_payload_header_map_flag_null_map_multi_values_e)) { + if (maps->array[internal->l].value.used) { + internal->range.start = 0; + internal->range.stop = maps->array[internal->l].value.array[internal->m].used - 1; + + private_fl_fss_basic_write(F_true, maps->array[internal->l].value.array[internal->m], 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + if (F_status_is_error(state->status)) return F_true; + } + else if (data->flag & f_fss_payload_header_map_flag_null_map_multi_values_e) { + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + + state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + } // for + } + } // for + + // Remove the always added trailing space. + if (destinations->array[destinations->used].value.used) { + destinations->array[destinations->used].value.used -= f_fss_extended_next_s.used; + } + } + + state->status = f_string_dynamic_strip_null(&destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + else { + if (data->flag & f_fss_payload_header_map_flag_join_map_multi_e) { + if ((data->flag & f_fss_payload_header_map_flag_null_map_multi_values_name_e) == f_fss_payload_header_map_flag_null_map_multi_values_name_e) { + state->status = f_memory_array_increase_by(internal->quote_null.used * 2 + f_fss_space_s.used, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size); + if (F_status_is_error(state->status)) return F_true; + } + + if (data->flag & f_fss_payload_header_map_flag_null_map_multi_name_e) { + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + if (F_status_is_error(state->status)) return F_true; + + if (data->flag & f_fss_payload_header_map_flag_null_map_multi_values_e) { + state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); + if (F_status_is_error(state->status)) return F_true; + } + } + + if (data->flag & f_fss_payload_header_map_flag_null_map_multi_values_e) { + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + if (F_status_is_error(state->status)) return F_true; + } + + if (private_fl_payload_header_map_cache_write(data, state, internal) == F_true) return F_true; + } + else { + if ((data->flag & f_fss_payload_header_map_flag_null_map_multi_values_name_e) == f_fss_payload_header_map_flag_null_map_multi_values_name_e) { + state->status = f_memory_array_increase_by(internal->quote_null.used * 2 + f_fss_space_s.used, sizeof(f_char_t), (void **) &destinations->array[destinations->used].value.string, &destinations->array[destinations->used].value.used, &destinations->array[destinations->used].value.size); + if (F_status_is_error(state->status)) return F_true; + } + + if (data->flag & f_fss_payload_header_map_flag_null_map_multi_name_e) { + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + + if (data->flag & f_fss_payload_header_map_flag_null_map_multi_values_e) { + state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + } + + if (data->flag & f_fss_payload_header_map_flag_null_map_multi_values_e) { + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + } + } + + state->status = f_string_dynamic_strip_null(&destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + + state->status = F_okay; + + return F_false; + } +#endif // !defined(_di_fl_fss_payload_header_maps_) + +#if !defined(_di_fl_fss_payload_header_maps_) + uint8_t private_fl_payload_header_map_maps(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, f_string_maps_t * const maps, f_string_maps_t * const destinations) { + + if (maps->used) { + internal->k = 0; + + for (internal->l = 0; internal->l < maps->used; ++internal->k) { + + if (state->interrupt) { + state->interrupt((void * const) state, (void * const) internal); + if (F_status_set_fine(state->status) == F_interrupt) return F_true; + } + + if (maps->array[internal->l].name.used) { + internal->k += maps->array[internal->k].name.used + f_fss_extended_next_s.used + internal->quote_null.used; + } + else if (data->flag & f_fss_payload_header_map_flag_null_map_name_e) { + internal->k += f_fss_extended_next_s.used + internal->quote_null.used; + } + + if (maps->array[internal->l].value.used) { + internal->k += maps->array[internal->l].value.used + f_fss_extended_next_s.used + internal->quote_null.used; + } + else if (data->flag & f_fss_payload_header_map_flag_null_map_value_e) { + internal->k += f_fss_extended_next_s.used + internal->quote_null.used; + } + } // for + + if (data->flag & f_fss_payload_header_map_flag_join_maps_e) { + data->cache->used = 0; + + 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)) return F_true; + + for (internal->l = 0; internal->l < maps->used; ++internal->l) { + + if (state->interrupt) { + state->interrupt((void * const) state, (void * const) internal); + if (F_status_set_fine(state->status) == F_interrupt) return F_true; + } + + if (maps->array[internal->l].name.used || (data->flag & f_fss_payload_header_map_flag_null_map_name_e)) { + if (maps->array[internal->l].name.used) { + state->status = f_string_dynamic_append(maps->array[internal->l].name, data->cache); + } + else if (data->flag & f_fss_payload_header_map_flag_null_map_name_e) { + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + } + + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); + if (F_status_is_error(state->status)) return F_true; + } + + if (maps->array[internal->l].value.used || (data->flag & f_fss_payload_header_map_flag_null_map_value_e)) { + if (maps->array[internal->l].value.used) { + state->status = f_string_dynamic_append(maps->array[internal->l].value, data->cache); + } + else if (data->flag & f_fss_payload_header_map_flag_null_map_value_e) { + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + } + + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); + if (F_status_is_error(state->status)) return F_true; + } + } // for + + // Remove the always added trailing space. + if (data->cache->used) { + data->cache->used -= f_fss_space_s.used; + } + + private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + if (F_status_is_error(state->status)) return F_true; + } + else if (data->flag & f_fss_payload_header_map_flag_join_map_e) { + data->cache->used = 0; + + 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)) return F_true; + + for (internal->l = 0; internal->l < maps->used; ++internal->l) { + + if (state->interrupt) { + state->interrupt((void * const) state, (void * const) internal); + if (F_status_set_fine(state->status) == F_interrupt) return F_true; + } + + data->cache->used = 0; + + if (maps->array[internal->l].name.used || (data->flag & f_fss_payload_header_map_flag_null_map_name_e)) { + if (maps->array[internal->l].name.used) { + state->status = f_string_dynamic_append(maps->array[internal->l].name, data->cache); + } + else if (data->flag & f_fss_payload_header_map_flag_null_map_name_e) { + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + } + + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); + if (F_status_is_error(state->status)) return F_true; + } + + if (maps->array[internal->l].name.used || (data->flag & f_fss_payload_header_map_flag_null_map_name_e)) { + if (maps->array[internal->l].value.used) { + state->status = f_string_dynamic_append(maps->array[internal->l].value, data->cache); + } + else if (data->flag & f_fss_payload_header_map_flag_null_map_value_e) { + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + } + + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); + if (F_status_is_error(state->status)) return F_true; + } + + // Remove the always added trailing space. + if (data->cache->used) { + data->cache->used -= f_fss_space_s.used; + } + + private_fl_fss_basic_write(F_false, *data->cache, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } // for + + // Remove the always added trailing space. + data->cache->used -= f_fss_extended_next_s.used; + } + else { + state->status = f_memory_array_increase_by(internal->k, sizeof(f_char_t), (void **) &destinations->array[destinations->used].value.string, &destinations->array[destinations->used].value.used, &destinations->array[destinations->used].value.size); + if (F_status_is_error(state->status)) return F_true; + + for (internal->l = 0; internal->l < maps->used; ++internal->l) { + + if (state->interrupt) { + state->interrupt((void * const) state, (void * const) internal); + if (F_status_set_fine(state->status) == F_interrupt) return F_true; + } + + if (maps->array[internal->l].name.used || (data->flag & f_fss_payload_header_map_flag_null_map_name_e)) { + if (maps->array[internal->l].name.used) { + internal->range.start = 0; + internal->range.stop = maps->array[internal->l].name.used - 1; + + private_fl_fss_basic_write(F_false, maps->array[internal->l].name, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + if (F_status_is_error(state->status)) return F_true; + } + else if (data->flag & f_fss_payload_header_map_flag_null_map_name_e) { + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + + if (maps->array[internal->l].value.used) { + state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + } + + if (maps->array[internal->l].value.used) { + internal->range.start = 0; + internal->range.stop = maps->array[internal->l].value.used - 1; + + private_fl_fss_basic_write(F_true, maps->array[internal->l].value, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + if (F_status_is_error(state->status)) return F_true; + } + else if (data->flag & f_fss_payload_header_map_flag_null_map_value_e) { + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + } // for + } + + state->status = f_string_dynamic_strip_null(&destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + else { + if (data->flag & f_fss_payload_header_map_flag_join_map_e) { + if ((data->flag & f_fss_payload_header_map_flag_null_map_value_name_e) == f_fss_payload_header_map_flag_null_map_value_name_e) { + state->status = f_memory_array_increase_by(internal->quote_null.used * 2 + f_fss_space_s.used, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size); + if (F_status_is_error(state->status)) return F_true; + } + + if (data->flag & f_fss_payload_header_map_flag_null_map_name_e) { + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + if (F_status_is_error(state->status)) return F_true; + + if (data->flag & f_fss_payload_header_map_flag_null_map_value_e) { + state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); + if (F_status_is_error(state->status)) return F_true; + } + } + + if (data->flag & f_fss_payload_header_map_flag_null_map_value_e) { + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + if (F_status_is_error(state->status)) return F_true; + } + + if (private_fl_payload_header_map_cache_write(data, state, internal) == F_true) return F_true; + } + else { + if ((data->flag & f_fss_payload_header_map_flag_null_map_value_name_e) == f_fss_payload_header_map_flag_null_map_value_name_e) { + state->status = f_memory_array_increase_by(internal->quote_null.used * 2 + f_fss_space_s.used, sizeof(f_char_t), (void **) &destinations->array[destinations->used].value.string, &destinations->array[destinations->used].value.used, &destinations->array[destinations->used].value.size); + if (F_status_is_error(state->status)) return F_true; + } + + if (data->flag & f_fss_payload_header_map_flag_null_map_name_e) { + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + + if (data->flag & f_fss_payload_header_map_flag_null_map_value_e) { + state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + } + + if (data->flag & f_fss_payload_header_map_flag_null_map_value_e) { + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + } + } + + state->status = f_string_dynamic_strip_null(&destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + + state->status = F_okay; + + return F_false; + } +#endif // !defined(_di_fl_fss_payload_header_maps_) + +#if !defined(_di_fl_fss_payload_header_map_) + uint8_t private_fl_payload_header_map_number_signed(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, const f_number_signed_t number) { + + if (data->cache->used) { + state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, data->cache); + if (F_status_is_error(state->status)) return F_true; + } + + state->status = f_conversion_number_signed_to_string(number, data->conversion, data->cache); + if (F_status_is_error(state->status)) return F_true; + + state->status = F_okay; + + return F_false; + } +#endif // !defined(_di_fl_fss_payload_header_map_) + +#if !defined(_di_fl_fss_payload_header_map_) + uint8_t private_fl_payload_header_map_number_unsigned(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, const f_number_unsigned_t number) { + + if (data->cache->used) { + state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, data->cache); if (F_status_is_error(state->status)) return F_true; } @@ -407,6 +945,262 @@ extern "C" { #endif // !defined(_di_fl_fss_payload_header_map_) #if !defined(_di_fl_fss_payload_header_map_) + uint8_t private_fl_payload_header_map_quantity(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, const f_quantity_t quantity, f_string_maps_t * const destinations) { + + if (quantity.total) { + data->cache->used = 0; + + if (private_fl_payload_header_map_number_unsigned(data, state, internal, quantity.start) == F_true) return F_true; + + if (data->flag & f_fss_payload_header_map_flag_join_quantity_e) { + if (private_fl_payload_header_map_number_unsigned(data, state, internal, quantity.total) == F_true) return F_true; + if (private_fl_payload_header_map_cache_write(data, state, internal) == F_true) return F_true; + } + else { + if (private_fl_payload_header_map_cache_write(data, state, internal) == F_true) return F_true; + + state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + + data->cache->used = 0; + + if (private_fl_payload_header_map_number_unsigned(data, state, internal, quantity.total) == F_true) return F_true; + if (private_fl_payload_header_map_cache_write(data, state, internal) == F_true) return F_true; + } + } + else { + if (data->flag & f_fss_payload_header_map_flag_null_quantity_e) { + if (data->flag & f_fss_payload_header_map_flag_join_quantity_e) { + data->cache->used = 0; + + state->status = f_memory_array_increase_by(internal->quote_null.used * 2 + f_fss_extended_next_s.used, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size); + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + if (F_status_is_error(state->status)) return F_true; + + if (private_fl_payload_header_map_cache_write(data, state, internal) == F_true) return F_true; + } + else { + state->status = f_memory_array_increase_by(internal->quote_null.used * 2 + f_fss_extended_next_s.used, sizeof(f_char_t), (void **) &destinations->array[destinations->used].value.string, &destinations->array[destinations->used].value.used, &destinations->array[destinations->used].value.size); + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + } + } + + state->status = F_okay; + + return F_false; + } +#endif // !defined(_di_fl_fss_payload_header_map_) + +#if !defined(_di_fl_fss_payload_header_map_) + uint8_t private_fl_payload_header_map_quantitys(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, const f_quantitys_t quantitys, f_string_maps_t * const destinations) { + + if (quantitys.used) { + internal->k = 0; + + for (internal->l = 0; internal->l < quantitys.used; ++internal->l) { + + if (state->interrupt) { + state->interrupt((void * const) state, (void * const) internal); + if (F_status_set_fine(state->status) == F_interrupt) return F_true; + } + + if (quantitys.array[internal->l].total) { + internal->k += FL_payload_digit_size_2_d + f_fss_extended_next_s.used + internal->quote_null.used * 2; + } + else if (data->flag & f_fss_payload_header_map_flag_null_quantity_e) { + internal->k += f_fss_extended_next_s.used + internal->quote_null.used * 2; + } + } // for + + state->status = f_memory_array_increase_by(internal->k, sizeof(f_char_t), (void **) &destinations->array[destinations->used].value.string, &destinations->array[destinations->used].value.used, &destinations->array[destinations->used].value.size); + if (F_status_is_error(state->status)) return F_true; + + if (data->flag & f_fss_payload_header_map_flag_join_quantitys_e) { + data->cache->used = 0; + + 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)) return F_true; + + for (internal->l = 0; internal->l < quantitys.used; ++internal->l) { + + if (state->interrupt) { + state->interrupt((void * const) state, (void * const) internal); + if (F_status_set_fine(state->status) == F_interrupt) return F_true; + } + + if (quantitys.array[internal->l].total) { + if (private_fl_payload_header_map_number_unsigned(data, state, internal, quantitys.array[internal->l].start) == F_true) return F_true; + if (private_fl_payload_header_map_number_unsigned(data, state, internal, quantitys.array[internal->l].total) == F_true) return F_true; + + continue; + } + + if (data->flag & f_fss_payload_header_map_flag_null_quantity_e) { + if (data->cache->used) { + state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); + if (F_status_is_error(state->status)) return F_true; + } + + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + if (F_status_is_error(state->status)) return F_true; + } + } // for + + if (private_fl_payload_header_map_cache_write(data, state, internal) == F_true) return F_true; + } + else { + data->cache->used = 0; + + if (data->flag & f_fss_payload_header_map_flag_join_quantity_e) { + state->status = f_memory_array_increase_by(FL_payload_digit_size_2_d, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size); + if (F_status_is_error(state->status)) return F_true; + + for (internal->l = 0; internal->l < quantitys.used; ++internal->l) { + + if (state->interrupt) { + state->interrupt((void * const) state, (void * const) internal); + if (F_status_set_fine(state->status) == F_interrupt) return F_true; + } + + if (quantitys.array[internal->l].total) { + data->cache->used = 0; + + if (private_fl_payload_header_map_number_unsigned(data, state, internal, quantitys.array[internal->l].start) == F_true) return F_true; + if (private_fl_payload_header_map_number_unsigned(data, state, internal, quantitys.array[internal->l].total) == F_true) return F_true; + if (private_fl_payload_header_map_cache_write(data, state, internal) == F_true) return F_true; + + continue; + } + + if (data->flag & f_fss_payload_header_map_flag_null_quantity_e) { + data->cache->used = 0; + + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + if (F_status_is_error(state->status)) return F_true; + + if (private_fl_payload_header_map_cache_write(data, state, internal) == F_true) return F_true; + } + } // for + } + else { + state->status = f_memory_array_increase_by(FL_payload_digit_size_1_d, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size); + if (F_status_is_error(state->status)) return F_true; + + for (internal->l = 0; internal->l < quantitys.used; ++internal->l) { + + if (state->interrupt) { + state->interrupt((void * const) state, (void * const) internal); + if (F_status_set_fine(state->status) == F_interrupt) return F_true; + } + + if (quantitys.array[internal->l].total) { + data->cache->used = 0; + + if (private_fl_payload_header_map_number_unsigned(data, state, internal, quantitys.array[internal->l].start) == F_true) return F_true; + if (private_fl_payload_header_map_cache_write(data, state, internal) == F_true) return F_true; + + data->cache->used = 0; + + state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + + if (private_fl_payload_header_map_number_unsigned(data, state, internal, quantitys.array[internal->l].total) == F_true) return F_true; + if (private_fl_payload_header_map_cache_write(data, state, internal) == F_true) return F_true; + + state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + + continue; + } + + if (data->flag & f_fss_payload_header_map_flag_null_quantity_e) { + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + + state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } // for + + // Remove the always added trailing space (except when all quantitys are NULL and f_fss_payload_header_map_flag_null_quantity_e is not set). + if (destinations->array[destinations->used].value.used) { + destinations->array[destinations->used].value.used -= f_fss_extended_next_s.used; + } + } + } + } + else { + if (data->flag & f_fss_payload_header_map_flag_null_quantitys_e) { + if (data->flag & f_fss_payload_header_map_flag_join_quantitys_quantity_e) { + data->cache->used = 0; + + state->status = f_memory_array_increase_by(internal->quote_null.used * 2 + f_fss_space_s.used, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size); + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append(f_fss_space_s, data->cache); + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + if (F_status_is_error(state->status)) return F_true; + + if (private_fl_payload_header_map_cache_write(data, state, internal) == F_true) return F_true; + } + else { + state->status = f_memory_array_increase_by(internal->quote_null.used * 2 + f_fss_extended_next_s.used, sizeof(f_char_t), (void **) &destinations->array[destinations->used].value.string, &destinations->array[destinations->used].value.used, &destinations->array[destinations->used].value.size); + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append(f_fss_extended_next_s, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + } + } + + state->status = F_okay; + + return F_false; + } +#endif // !defined(_di_fl_fss_payload_header_map_) + +#if !defined(_di_fl_fss_payload_header_map_) uint8_t private_fl_payload_header_map_range(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, const f_range_t range, f_string_maps_t * const destinations) { if (range.start > range.stop) { @@ -414,7 +1208,7 @@ extern "C" { if (data->flag & f_fss_payload_header_map_flag_join_range_e) { data->cache->used = 0; - state->status = f_memory_array_increase_by(internal->quote_null.used + internal->quote_null.used + f_fss_extended_next_s.used, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size); + state->status = f_memory_array_increase_by(internal->quote_null.used * 2 + f_fss_extended_next_s.used, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size); if (F_status_is_error(state->status)) return F_true; state->status = f_string_dynamic_append(internal->quote_null, data->cache); @@ -429,7 +1223,7 @@ extern "C" { if (private_fl_payload_header_map_cache_write(data, state, internal) == F_true) return F_true; } else { - state->status = f_memory_array_increase_by(internal->quote_null.used + internal->quote_null.used + f_fss_extended_next_s.used, sizeof(f_char_t), (void **) &destinations->array[destinations->used].value.string, &destinations->array[destinations->used].value.used, &destinations->array[destinations->used].value.size); + state->status = f_memory_array_increase_by(internal->quote_null.used * 2 + f_fss_extended_next_s.used, sizeof(f_char_t), (void **) &destinations->array[destinations->used].value.string, &destinations->array[destinations->used].value.used, &destinations->array[destinations->used].value.size); if (F_status_is_error(state->status)) return F_true; state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); @@ -479,11 +1273,16 @@ extern "C" { for (internal->l = 0; internal->l < ranges.used; ++internal->l) { + if (state->interrupt) { + state->interrupt((void * const) state, (void * const) internal); + if (F_status_set_fine(state->status) == F_interrupt) return F_true; + } + if (ranges.array[internal->l].start > ranges.array[internal->l].stop) { - internal->k += FL_payload_digit_size_2_d + f_fss_extended_next_s.used + internal->quote_null.used + internal->quote_null.used; + internal->k += FL_payload_digit_size_2_d + f_fss_extended_next_s.used + internal->quote_null.used * 2; } else if (data->flag & f_fss_payload_header_map_flag_null_range_e) { - internal->k += f_fss_extended_next_s.used + internal->quote_null.used + internal->quote_null.used; + internal->k += f_fss_extended_next_s.used + internal->quote_null.used * 2; } } // for @@ -498,6 +1297,11 @@ extern "C" { for (internal->l = 0; internal->l < ranges.used; ++internal->l) { + if (state->interrupt) { + state->interrupt((void * const) state, (void * const) internal); + if (F_status_set_fine(state->status) == F_interrupt) return F_true; + } + if (ranges.array[internal->l].start > ranges.array[internal->l].stop) { if (data->flag & f_fss_payload_header_map_flag_null_range_e) { if (data->cache->used) { @@ -533,6 +1337,11 @@ extern "C" { for (internal->l = 0; internal->l < ranges.used; ++internal->l) { + if (state->interrupt) { + state->interrupt((void * const) state, (void * const) internal); + if (F_status_set_fine(state->status) == F_interrupt) return F_true; + } + if (ranges.array[internal->l].start > ranges.array[internal->l].stop) { if (data->flag & f_fss_payload_header_map_flag_null_range_e) { data->cache->used = 0; @@ -565,6 +1374,11 @@ extern "C" { for (internal->l = 0; internal->l < ranges.used; ++internal->l) { + if (state->interrupt) { + state->interrupt((void * const) state, (void * const) internal); + if (F_status_set_fine(state->status) == F_interrupt) return F_true; + } + if (ranges.array[internal->l].start > ranges.array[internal->l].stop) { if (data->flag & f_fss_payload_header_map_flag_null_range_e) { state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); @@ -603,10 +1417,10 @@ extern "C" { } else { if (data->flag & f_fss_payload_header_map_flag_null_ranges_e) { - if (data->flag & (f_fss_payload_header_map_flag_join_ranges_e | f_fss_payload_header_map_flag_join_ranges_e)) { + if (data->flag & f_fss_payload_header_map_flag_join_ranges_range_e) { data->cache->used = 0; - state->status = f_memory_array_increase_by(internal->quote_null.used + internal->quote_null.used + f_fss_space_s.used, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size); + state->status = f_memory_array_increase_by(internal->quote_null.used * 2 + f_fss_space_s.used, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size); if (F_status_is_error(state->status)) return F_true; state->status = f_string_dynamic_append(internal->quote_null, data->cache); @@ -621,6 +1435,9 @@ extern "C" { if (private_fl_payload_header_map_cache_write(data, state, internal) == F_true) return F_true; } else { + state->status = f_memory_array_increase_by(internal->quote_null.used * 2 + f_fss_extended_next_s.used, sizeof(f_char_t), (void **) &destinations->array[destinations->used].value.string, &destinations->array[destinations->used].value.used, &destinations->array[destinations->used].value.size); + if (F_status_is_error(state->status)) return F_true; + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); if (F_status_is_error(state->status)) return F_true; @@ -642,91 +1459,399 @@ extern "C" { #if !defined(_di_fl_fss_payload_header_map_) uint8_t private_fl_payload_header_map_strings(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, f_string_t * const buffers, f_string_maps_t * const destinations) { - f_string_static_t string_static = f_string_static_t_initialize; + if (buffers && buffers[0]) { + f_string_static_t string_static = f_string_static_t_initialize; - data->cache->used = 0; - internal->k = 0; + data->cache->used = 0; + internal->k = 0; + + // Pre-process the string lengths to allow for a single allocation. + for (internal->j = 0; buffers[internal->j]; ++internal->j) { + + if (state->interrupt) { + state->interrupt((void * const) state, (void * const) internal); + if (F_status_set_fine(state->status) == F_interrupt) return F_true; + } - // Pre-process the string lengths to allow for a single allocation. - for (internal->j = 0; buffers[internal->j]; ++internal->j) { + string_static.string = buffers[internal->j]; + string_static.used = string_static.string ? strnlen(string_static.string, F_string_t_size_d) : 0; + internal->k += string_static.used + f_fss_extended_next_s.used + internal->quote_null.used; + } // for + + state->status = f_memory_array_increase_by(internal->k, sizeof(f_char_t), (void **) &destinations->array[destinations->used].value.string, &destinations->array[destinations->used].value.used, &destinations->array[destinations->used].value.size); + if (F_status_is_error(state->status)) return F_true; - if (state->interrupt) { - state->interrupt((void * const) state, (void * const) internal); - if (F_status_set_fine(state->status) == F_interrupt) return F_true; + if (data->flag & f_fss_payload_header_map_flag_join_strings_e) { + 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)) return F_true; } - string_static.string = buffers[internal->j]; - string_static.used = string_static.string ? strnlen(string_static.string, F_string_t_size_d) : 0; - internal->k += string_static.used + f_fss_extended_next_s.used + internal->quote_null.used; - } // for + for (internal->l = internal->j, internal->j = 0; internal->j < internal->l; ++internal->j) { - state->status = f_memory_array_increase_by(internal->k, sizeof(f_char_t), (void **) &destinations->array[destinations->used].value.string, &destinations->array[destinations->used].value.used, &destinations->array[destinations->used].value.size); + if (state->interrupt) { + state->interrupt((void * const) state, (void * const) internal); + if (F_status_set_fine(state->status) == F_interrupt) return F_true; + } + + string_static.string = buffers[internal->j]; + string_static.used = string_static.string ? strnlen(string_static.string, F_string_t_size_d) : 0; + + if (data->flag & f_fss_payload_header_map_flag_join_strings_e) { + state->status = f_string_dynamic_append(string_static, data->cache); + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append_assure(f_string_space_s, data->cache); + if (F_status_is_error(state->status)) return F_true; + } + else { + if (string_static.used) { + internal->range.start = 0; + internal->range.stop = string_static.used - 1; + + private_fl_fss_basic_write(F_false, string_static, internal->quote, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, data->cache); + if (F_status_is_error(state->status)) return F_true; + } + else if (data->flag & f_fss_payload_header_map_flag_null_string_e) { + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + } + } // for + + if (data->flag & f_fss_payload_header_map_flag_join_strings_e) { + if (data->cache->used) { + + // Do not include the f_string_space_s that is always added at the end of the loop. + data->cache->used -= f_string_space_s.used; + + internal->range.start = 0; + internal->range.stop = data->cache->used - 1; + + private_fl_fss_basic_write(F_false, *data->cache, internal->quote, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + if (F_status_is_error(state->status)) return F_true; + } + else { + if (data->flag & f_fss_payload_header_map_flag_null_string_e) { + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + } + } + + state->status = f_string_dynamic_strip_null(&destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + else { + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + + state->status = F_okay; + + return F_false; + } +#endif // !defined(_di_fl_fss_payload_header_map_) + +#if !defined(_di_fl_fss_payload_header_map_) + uint8_t private_fl_payload_header_map_triple(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, const f_string_triple_t triple, f_string_maps_t * const destinations) { + + f_string_dynamic_t * const destination = (data->flag & f_fss_payload_header_map_flag_join_triple_e) ? data->cache : &destinations->array[destinations->used].value; + const f_string_static_t separator = (data->flag & f_fss_payload_header_map_flag_join_triple_e) ? f_string_space_s : f_fss_extended_next_s; + const f_string_static_t a = triple.a.used ? triple.a : internal->quote_null; + const f_string_static_t b = triple.b.used ? triple.b : internal->quote_null; + const f_string_static_t c = triple.c.used ? triple.c : internal->quote_null; + + data->cache->used = 0; + + state->status = f_memory_array_increase_by(a.used + b.used + c.used + separator.used * 2, sizeof(f_char_t), (void **) &destination->string, &destination->used, &destination->size); if (F_status_is_error(state->status)) return F_true; - if (data->flag & f_fss_payload_header_map_flag_join_strings_e) { - state->status = f_memory_array_increase_by(internal->k, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size); + if (triple.a.used || (data->flag & f_fss_payload_header_map_flag_null_triple_e)) { + if (data->flag & f_fss_payload_header_map_flag_join_triple_e) { + state->status = f_string_dynamic_append(a, destination); + } + else { + internal->range.start = 0; + internal->range.stop = a.used - 1; + + private_fl_fss_basic_write(F_false, a, internal->quote, &internal->range, destination, state, (void * const) internal); + } + if (F_status_is_error(state->status)) return F_true; + + if (data->flag & f_fss_payload_header_map_flag_null_triple_e) { + state->status = f_string_dynamic_append(separator, destination); + if (F_status_is_error(state->status)) return F_true; + } } - for (internal->l = internal->j, internal->j = 0; internal->j < internal->l; ++internal->j) { + if (triple.b.used || (data->flag & f_fss_payload_header_map_flag_null_triple_e)) { + if (data->flag & f_fss_payload_header_map_flag_join_triple_e) { + state->status = f_string_dynamic_append(b, destination); + } + else { + internal->range.start = 0; + internal->range.stop = b.used - 1; - if (state->interrupt) { - state->interrupt((void * const) state, (void * const) internal); - if (F_status_set_fine(state->status) == F_interrupt) return F_true; + private_fl_fss_basic_write(F_false, b, internal->quote, &internal->range, destination, state, (void * const) internal); } - string_static.string = buffers[internal->j]; - string_static.used = string_static.string ? strnlen(string_static.string, F_string_t_size_d) : 0; + if (F_status_is_error(state->status)) return F_true; - if (data->flag & f_fss_payload_header_map_flag_join_strings_e) { - state->status = f_string_dynamic_append(string_static, data->cache); + if (data->flag & f_fss_payload_header_map_flag_null_triple_e) { + state->status = f_string_dynamic_append(separator, destination); if (F_status_is_error(state->status)) return F_true; + } + } + + if (triple.c.used || (data->flag & f_fss_payload_header_map_flag_null_triple_e)) { + if (data->flag & f_fss_payload_header_map_flag_join_triple_e) { + state->status = f_string_dynamic_append(c, destination); + } + else { + internal->range.start = 0; + internal->range.stop = c.used - 1; + + private_fl_fss_basic_write(F_false, c, internal->quote, &internal->range, destination, state, (void * const) internal); + } + + if (F_status_is_error(state->status)) return F_true; + } + + if (data->flag & f_fss_payload_header_map_flag_join_triple_e) { + if (private_fl_payload_header_map_cache_write(data, state, internal) == F_true) return F_true; + } + else { + state->status = f_string_dynamic_strip_null(&destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + + state->status = F_okay; + + return F_false; + } +#endif // !defined(_di_fl_fss_payload_header_map_) + +#if !defined(_di_fl_fss_payload_header_map_) + uint8_t private_fl_payload_header_map_triples(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, const f_string_triples_t triples, f_string_maps_t * const destinations) { + + if (triples.used) { + internal->k = 0; + + for (internal->l = 0; internal->l < triples.used; ++internal->l) { + + if (state->interrupt) { + state->interrupt((void * const) state, (void * const) internal); + if (F_status_set_fine(state->status) == F_interrupt) return F_true; + } + + internal->k += (triples.array[internal->l].a.used) ? triples.array[internal->l].a.used : internal->quote_null.used; + internal->k += (triples.array[internal->l].b.used) ? triples.array[internal->l].b.used : internal->quote_null.used; + internal->k += (triples.array[internal->l].c.used) ? triples.array[internal->l].c.used : internal->quote_null.used; + internal->k += (data->flag & f_fss_payload_header_map_flag_join_triple_e) ? f_fss_space_s.used * 2 : f_fss_extended_next_s.used * 2; + } // for + + state->status = f_memory_array_increase_by(internal->k, sizeof(f_char_t), (void **) &destinations->array[destinations->used].value.string, &destinations->array[destinations->used].value.used, &destinations->array[destinations->used].value.size); + if (F_status_is_error(state->status)) return F_true; + + if (data->flag & f_fss_payload_header_map_flag_join_triples_triple_e) { + data->cache->used = 0; - state->status = f_string_dynamic_append_assure(f_string_space_s, data->cache); + 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)) return F_true; + + for (internal->l = 0; internal->l < triples.used; ++internal->l) { + + if (state->interrupt) { + state->interrupt((void * const) state, (void * const) internal); + if (F_status_set_fine(state->status) == F_interrupt) return F_true; + } + + if (!(data->flag & f_fss_payload_header_map_flag_join_triples_e)) { + if (data->cache->used) { + state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + + data->cache->used = 0; + } + else { + if (data->cache->used) { + state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); + if (F_status_is_error(state->status)) return F_true; + } + } + + if (triples.array[internal->l].a.used || (data->flag & f_fss_payload_header_map_flag_null_triple_e)) { + if (triples.array[internal->l].a.used) { + state->status = f_string_dynamic_append(triples.array[internal->l].a, data->cache); + if (F_status_is_error(state->status)) return F_true; + } + else if (data->flag & f_fss_payload_header_map_flag_null_triple_e) { + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + if (F_status_is_error(state->status)) return F_true; + } + + if (triples.array[internal->l].b.used || (data->flag & f_fss_payload_header_map_flag_null_triple_e)) { + state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); + if (F_status_is_error(state->status)) return F_true; + } + } + + if (triples.array[internal->l].b.used || (data->flag & f_fss_payload_header_map_flag_null_triple_e)) { + if (triples.array[internal->l].b.used) { + state->status = f_string_dynamic_append(triples.array[internal->l].b, data->cache); + if (F_status_is_error(state->status)) return F_true; + } + else if (data->flag & f_fss_payload_header_map_flag_null_triple_e) { + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + if (F_status_is_error(state->status)) return F_true; + } + + if (triples.array[internal->l].c.used || (data->flag & f_fss_payload_header_map_flag_null_triple_e)) { + state->status = f_string_dynamic_append_assure(f_fss_space_s, data->cache); + if (F_status_is_error(state->status)) return F_true; + } + } + + if (triples.array[internal->l].c.used || (data->flag & f_fss_payload_header_map_flag_null_triple_e)) { + if (triples.array[internal->l].c.used) { + state->status = f_string_dynamic_append(triples.array[internal->l].c, data->cache); + if (F_status_is_error(state->status)) return F_true; + } + else if (data->flag & f_fss_payload_header_map_flag_null_triple_e) { + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + if (F_status_is_error(state->status)) return F_true; + } + } + + if (!(data->flag & f_fss_payload_header_map_flag_join_triples_e)) { + if (private_fl_payload_header_map_cache_write(data, state, internal) == F_true) return F_true; + } + } // for + + if (data->flag & f_fss_payload_header_map_flag_join_triples_e) { + if (private_fl_payload_header_map_cache_write(data, state, internal) == F_true) return F_true; + } } else { - if (string_static.used) { - internal->range.start = 0; - internal->range.stop = string_static.used - 1; + data->cache->used = 0; + + for (internal->l = 0; internal->l < triples.used; ++internal->l) { + + if (state->interrupt) { + state->interrupt((void * const) state, (void * const) internal); + if (F_status_set_fine(state->status) == F_interrupt) return F_true; + } + + if (triples.array[internal->l].a.used || (data->flag & f_fss_payload_header_map_flag_null_triple_e)) { + if (triples.array[internal->l].a.used) { + internal->range.start = 0; + internal->range.stop = triples.array[internal->l].a.used - 1; + + private_fl_fss_basic_write(F_false, triples.array[internal->l].a, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + if (F_status_is_error(state->status)) return F_true; + } + else if (data->flag & f_fss_payload_header_map_flag_null_triple_e) { + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + + state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + + if (triples.array[internal->l].b.used || (data->flag & f_fss_payload_header_map_flag_null_triple_e)) { + if (triples.array[internal->l].b.used) { + internal->range.start = 0; + internal->range.stop = triples.array[internal->l].b.used - 1; + + private_fl_fss_basic_write(F_false, triples.array[internal->l].b, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + if (F_status_is_error(state->status)) return F_true; + } + else if (data->flag & f_fss_payload_header_map_flag_null_triple_e) { + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + + state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + + if (triples.array[internal->l].c.used || (data->flag & f_fss_payload_header_map_flag_null_triple_e)) { + if (triples.array[internal->l].c.used) { + internal->range.start = 0; + internal->range.stop = triples.array[internal->l].c.used - 1; + + private_fl_fss_basic_write(F_false, triples.array[internal->l].c, 0, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + if (F_status_is_error(state->status)) return F_true; + } + else if (data->flag & f_fss_payload_header_map_flag_null_triple_e) { + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + + state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; + } + } // for + + // Remove the always added trailing space (except when all triples are NULL and f_fss_payload_header_map_flag_null_triple_e is not set). + if (destinations->array[destinations->used].value.used) { + destinations->array[destinations->used].value.used -= f_fss_extended_next_s.used; + } + } + } + else { + if (data->flag & f_fss_payload_header_map_flag_null_triples_e) { + if (data->flag & f_fss_payload_header_map_flag_join_triples_triple_e) { + data->cache->used = 0; + + state->status = f_memory_array_increase_by(internal->quote_null.used * 3 + f_fss_space_s.used * 2, sizeof(f_char_t), (void **) &data->cache->string, &data->cache->used, &data->cache->size); + if (F_status_is_error(state->status)) return F_true; - private_fl_fss_basic_write(F_false, string_static, internal->quote, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append(f_fss_space_s, data->cache); + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append(internal->quote_null, data->cache); + if (F_status_is_error(state->status)) return F_true; + + state->status = f_string_dynamic_append(f_fss_space_s, data->cache); if (F_status_is_error(state->status)) return F_true; - state->status = f_string_dynamic_append_assure(f_fss_extended_next_s, data->cache); + state->status = f_string_dynamic_append(internal->quote_null, data->cache); if (F_status_is_error(state->status)) return F_true; + + if (private_fl_payload_header_map_cache_write(data, state, internal) == F_true) return F_true; } - else if (data->flag & f_fss_payload_header_map_flag_null_string_e) { + else { + state->status = f_memory_array_increase_by(internal->quote_null.used * 3 + f_fss_extended_next_s.used * 2, sizeof(f_char_t), (void **) &destinations->array[destinations->used].value.string, &destinations->array[destinations->used].value.used, &destinations->array[destinations->used].value.size); + if (F_status_is_error(state->status)) return F_true; + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); if (F_status_is_error(state->status)) return F_true; - } - } - } // for - if (data->flag & f_fss_payload_header_map_flag_join_strings_e) { - if (data->cache->used) { + state->status = f_string_dynamic_append(f_fss_extended_next_s, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; - // Do not include the f_string_space_s that is always added at the end of the loop. - data->cache->used -= f_string_space_s.used; + state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; - internal->range.start = 0; - internal->range.stop = data->cache->used - 1; + state->status = f_string_dynamic_append(f_fss_extended_next_s, &destinations->array[destinations->used].value); + if (F_status_is_error(state->status)) return F_true; - private_fl_fss_basic_write(F_false, *data->cache, internal->quote, &internal->range, &destinations->array[destinations->used].value, state, (void * const) internal); - if (F_status_is_error(state->status)) return F_true; - } - else { - if (data->flag & f_fss_payload_header_map_flag_null_string_e) { state->status = f_string_dynamic_append(internal->quote_null, &destinations->array[destinations->used].value); if (F_status_is_error(state->status)) return F_true; } } } - state->status = f_string_dynamic_strip_null(&destinations->array[destinations->used].value); - if (F_status_is_error(state->status)) return F_true; - - ++destinations->used; state->status = F_okay; return F_false; diff --git a/level_1/fl_fss/c/fss/private-payload.h b/level_1/fl_fss/c/fss/private-payload.h index b0bfbb3..beba621 100644 --- a/level_1/fl_fss/c/fss/private-payload.h +++ b/level_1/fl_fss/c/fss/private-payload.h @@ -198,9 +198,7 @@ extern "C" { #endif // !defined(_di_fl_fss_payload_header_map_) /** - * Process the case where a map is added with the appropriate NULL flag bits set. - * - * This adds the data.quote_null strings for both the map name and the map value, depending on the f_fss_payload_header_map_flag_null_map_name_e and f_fss_payload_header_map_flag_null_map_value_e flags. + * Process the multi-map strings, writing it into the packet with the appropriate escaping as necessary. * * This expects that the appropriate used and flag checks are performed prior to calling this. * @@ -221,6 +219,9 @@ extern "C" { * @param internal * The internal state, f_fss_payload_header_internal_t, created inside of fl_fss_payload_header_map(). * Must not be NULL. + * @param map + * The map to read from. + * Must not be NULL. * @param destinations * A map of strings representing the header names and values after being safely converted into the valid payload header format. * This built header names and values are appended onto this. @@ -240,10 +241,57 @@ extern "C" { * @see fl_fss_payload_header_map() */ #if !defined(_di_fl_fss_payload_header_map_) - extern uint8_t private_fl_payload_header_map_map_name_value_null(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, f_string_maps_t * const destinations) F_attribute_visibility_internal_d; + extern uint8_t private_fl_payload_header_map_map_multi(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, f_string_map_multi_t * const map, f_string_maps_t * const destinations) F_attribute_visibility_internal_d; #endif // !defined(_di_fl_fss_payload_header_map_) /** + * Process the multi-map strings, writing it into the packet with the appropriate escaping as necessary. + * + * This expects that the appropriate used and flag checks are performed prior to calling this. + * + * @param data + * The f_fss_payload_header_state_t pointer. + * Must not be NULL. + * @param state + * The state passed directly from the fl_fss_payload_header_map() parameters. + * + * This alters state.status: + * F_okay on success. + * + * Errors (with error bit) from: f_memory_array_increase_by(). + * Errors (with error bit) from: f_string_dynamic_strip_null(). + * Errors (with error bit) from: private_fl_fss_basic_write(). + * + * Must not be NULL. + * @param internal + * The internal state, f_fss_payload_header_internal_t, created inside of fl_fss_payload_header_map(). + * Must not be NULL. + * @param maps + * The maps to read from. + * Must not be NULL. + * @param destinations + * A map of strings representing the header names and values after being safely converted into the valid payload header format. + * This built header names and values are appended onto this. + * This is updated as appropriate. + * Must not be NULL. + * + * @return + * F_true if the caller should break or exit due to an error or something similar. + * F_false, otherwise. + * + * @see f_memory_array_increase_by() + * @see f_string_dynamic_append() + * @see f_string_dynamic_strip_null() + * + * @see private_fl_fss_basic_write() + * + * @see fl_fss_payload_header_map() + */ +#if !defined(_di_fl_fss_payload_header_maps_) + extern uint8_t private_fl_payload_header_map_map_multis(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, f_string_map_multis_t * const maps, f_string_maps_t * const destinations) F_attribute_visibility_internal_d; +#endif // !defined(_di_fl_fss_payload_header_maps_) + +/** * Process the map strings, writing it into the packet with the appropriate escaping as necessary. * * This expects that the appropriate used and flag checks are performed prior to calling this. @@ -372,6 +420,110 @@ extern "C" { #endif // !defined(_di_fl_fss_payload_header_map_) /** + * Process the quantity, writing it into the packet with the appropriate escaping as necessary. + * + * This expects that the appropriate used and flag checks are performed prior to calling this. + * + * @param headers + * An abstruse map representing individual headers. + * @param data + * The f_fss_payload_header_state_t pointer. + * This modifies data.cache. + * Must not be NULL. + * @param state + * The state passed directly from the fl_fss_payload_header_map() parameters. + * + * This alters state.status: + * F_okay on success. + * + * Errors (with error bit) from: f_memory_array_increase_by(). + * Errors (with error bit) from: f_string_dynamic_append(). + * Errors (with error bit) from: f_string_dynamic_append_assure(). + * Errors (with error bit) from: f_string_dynamic_strip_null(). + * Errors (with error bit) from: private_fl_fss_basic_write(). + * + * Must not be NULL. + * @param internal + * The internal state, f_fss_payload_header_internal_t, created inside of fl_fss_payload_header_map(). + * Must not be NULL. + * @param quantity + * The quantity to process. + * @param destinations + * A map of strings representing the header names and values after being safely converted into the valid payload header format. + * This built header names and values are appended onto this. + * This is updated as appropriate. + * Must not be NULL. + * + * @return + * F_true if the caller should break or exit due to an error or something similar. + * F_false, otherwise. + * + * @see f_memory_array_increase_by() + * @see f_string_dynamic_append() + * @see f_string_dynamic_append_assure() + * @see f_string_dynamic_strip_null() + * + * @see private_fl_fss_basic_write() + * + * @see fl_fss_payload_header_map() + */ +#if !defined(_di_fl_fss_payload_header_map_) + extern uint8_t private_fl_payload_header_map_quantity(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, const f_quantity_t quantity, f_string_maps_t * const destinations) F_attribute_visibility_internal_d; +#endif // !defined(_di_fl_fss_payload_header_map_) + +/** + * Process the quantity, writing it into the packet with the appropriate escaping as necessary. + * + * This expects that the appropriate used and flag checks are performed prior to calling this. + * + * @param headers + * An abstruse map representing individual headers. + * @param data + * The f_fss_payload_header_state_t pointer. + * This modifies data.cache. + * Must not be NULL. + * @param state + * The state passed directly from the fl_fss_payload_header_map() parameters. + * + * This alters state.status: + * F_okay on success. + * + * Errors (with error bit) from: f_string_dynamic_append(). + * Errors (with error bit) from: f_string_dynamic_append_assure(). + * Errors (with error bit) from: private_fl_fss_basic_write(). + * Errors (with error bit) from: private_fl_payload_header_map_cache_write(). + * Errors (with error bit) from: private_fl_payload_header_map_number_unsigned(). + * + * Must not be NULL. + * @param internal + * The internal state, f_fss_payload_header_internal_t, created inside of fl_fss_payload_header_map(). + * Must not be NULL. + * @param quantity + * The quantity to process. + * @param destinations + * A map of strings representing the header names and values after being safely converted into the valid payload header format. + * This built header names and values are appended onto this. + * This is updated as appropriate. + * Must not be NULL. + * + * @return + * F_true if the caller should break or exit due to an error or something similar. + * F_false, otherwise. + * + * @see f_memory_array_increase_by() + * @see f_string_dynamic_append() + * @see f_string_dynamic_append_assure() + * @see f_string_dynamic_strip_null() + * + * @see private_fl_fss_basic_write() + * + * @see fl_fss_payload_header_map() + */ +#if !defined(_di_fl_fss_payload_header_map_) + extern uint8_t private_fl_payload_header_map_quantitys(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, const f_quantitys_t quantitys, f_string_maps_t * const destinations) F_attribute_visibility_internal_d; +#endif // !defined(_di_fl_fss_payload_header_map_) + +/** * Process the range, writing it into the packet with the appropriate escaping as necessary. * * This expects that the appropriate used and flag checks are performed prior to calling this. @@ -528,6 +680,110 @@ extern "C" { extern uint8_t private_fl_payload_header_map_strings(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, f_string_t * const buffers, f_string_maps_t * const destinations) F_attribute_visibility_internal_d; #endif // !defined(_di_fl_fss_payload_header_map_) +/** + * Process the triple, writing it into the packet with the appropriate escaping as necessary. + * + * This expects that the appropriate used and flag checks are performed prior to calling this. + * + * @param headers + * An abstruse map representing individual headers. + * @param data + * The f_fss_payload_header_state_t pointer. + * This modifies data.cache. + * Must not be NULL. + * @param state + * The state passed directly from the fl_fss_payload_header_map() parameters. + * + * This alters state.status: + * F_okay on success. + * + * Errors (with error bit) from: f_memory_array_increase_by(). + * Errors (with error bit) from: f_string_dynamic_append(). + * Errors (with error bit) from: f_string_dynamic_append_assure(). + * Errors (with error bit) from: f_string_dynamic_strip_null(). + * Errors (with error bit) from: private_fl_fss_basic_write(). + * + * Must not be NULL. + * @param internal + * The internal state, f_fss_payload_header_internal_t, created inside of fl_fss_payload_header_map(). + * Must not be NULL. + * @param triple + * The triple to process. + * @param destinations + * A map of strings representing the header names and values after being safely converted into the valid payload header format. + * This built header names and values are appended onto this. + * This is updated as appropriate. + * Must not be NULL. + * + * @return + * F_true if the caller should break or exit due to an error or something similar. + * F_false, otherwise. + * + * @see f_memory_array_increase_by() + * @see f_string_dynamic_append() + * @see f_string_dynamic_append_assure() + * @see f_string_dynamic_strip_null() + * + * @see private_fl_fss_basic_write() + * + * @see fl_fss_payload_header_map() + */ +#if !defined(_di_fl_fss_payload_header_map_) + extern uint8_t private_fl_payload_header_map_triple(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, const f_string_triple_t triple, f_string_maps_t * const destinations) F_attribute_visibility_internal_d; +#endif // !defined(_di_fl_fss_payload_header_map_) + +/** + * Process the triple, writing it into the packet with the appropriate escaping as necessary. + * + * This expects that the appropriate used and flag checks are performed prior to calling this. + * + * @param headers + * An abstruse map representing individual headers. + * @param data + * The f_fss_payload_header_state_t pointer. + * This modifies data.cache. + * Must not be NULL. + * @param state + * The state passed directly from the fl_fss_payload_header_map() parameters. + * + * This alters state.status: + * F_okay on success. + * + * Errors (with error bit) from: f_string_dynamic_append(). + * Errors (with error bit) from: f_string_dynamic_append_assure(). + * Errors (with error bit) from: private_fl_fss_basic_write(). + * Errors (with error bit) from: private_fl_payload_header_map_cache_write(). + * Errors (with error bit) from: private_fl_payload_header_map_number_unsigned(). + * + * Must not be NULL. + * @param internal + * The internal state, f_fss_payload_header_internal_t, created inside of fl_fss_payload_header_map(). + * Must not be NULL. + * @param triple + * The triple to process. + * @param destinations + * A map of strings representing the header names and values after being safely converted into the valid payload header format. + * This built header names and values are appended onto this. + * This is updated as appropriate. + * Must not be NULL. + * + * @return + * F_true if the caller should break or exit due to an error or something similar. + * F_false, otherwise. + * + * @see f_memory_array_increase_by() + * @see f_string_dynamic_append() + * @see f_string_dynamic_append_assure() + * @see f_string_dynamic_strip_null() + * + * @see private_fl_fss_basic_write() + * + * @see fl_fss_payload_header_map() + */ +#if !defined(_di_fl_fss_payload_header_map_) + extern uint8_t private_fl_payload_header_map_triples(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, const f_string_triples_t triples, f_string_maps_t * const destinations) F_attribute_visibility_internal_d; +#endif // !defined(_di_fl_fss_payload_header_map_) + #ifdef __cplusplus } // extern "C" #endif -- 1.8.3.1