The current state is being saved so that I can refactor the f_string_quantity_t and related into f_quantity_t.
* - null_map_value: Types of map and maps has empty strings (such as "") added for NULL values (used is 0) for the map value.
* - null_map_name_value: An enumeration value representing both null_map_name and null_map_value keys being set.
* - null_maps: Types of dynamic and dynamics have empty strings (such as "") added for when null_map_key and null_map_value are not set and both map key and map value have NULL values (used is 0).
+ * - null_range: Types of range and ranges have empty strings (such as "") for when start > stop, aka NULL ranges.
+ * - null_ranges: Types of ranges have empty strings (such as "") added for when the array is empty.
* - null_string: Types of string and strings have empty strings (such as "") for NULL values.
* - null_triple_a: Types of triple and triples has empty strings (such as "") added for NULL values (used is 0) for the "a" property.
* - null_triple_b: Types of triple and triples has empty strings (such as "") added for NULL values (used is 0) for the "b" property.
* - null_triple_c: Types of triple and triples has empty strings (such as "") added for NULL values (used is 0) for the "c" property.
+ * - null_triples: Types of triples have empty strings (such as "") added for when the array is empty.
* - quote_double: Use double quotes (U+0022) when quoting strings.
* - quote_grave: Use grave (U+0060) when quoting strings.
* - quote_single: Use single quotes (U+0027) when quoting strings.
f_fss_payload_header_map_flag_null_map_value_e = 0x1000,
f_fss_payload_header_map_flag_null_map_name_value_e = 0x2000,
f_fss_payload_header_map_flag_null_maps_e = 0x4000,
- f_fss_payload_header_map_flag_null_triple_a_e = 0x8000,
- f_fss_payload_header_map_flag_null_triple_b_e = 0x10000,
- f_fss_payload_header_map_flag_null_triple_c_e = 0x20000,
- f_fss_payload_header_map_flag_null_string_e = 0x40000,
- f_fss_payload_header_map_flag_quote_double_e = 0x80000,
- f_fss_payload_header_map_flag_quote_grave_e = 0x100000,
- f_fss_payload_header_map_flag_quote_single_e = 0x200000,
- f_fss_payload_header_map_flag_last_e = 0x400000,
+ f_fss_payload_header_map_flag_null_range_e = 0x8000,
+ f_fss_payload_header_map_flag_null_ranges_e = 0x10000,
+ f_fss_payload_header_map_flag_null_string_e = 0x20000,
+ f_fss_payload_header_map_flag_null_triple_a_e = 0x40000,
+ f_fss_payload_header_map_flag_null_triple_b_e = 0x80000,
+ f_fss_payload_header_map_flag_null_triple_c_e = 0x100000,
+ f_fss_payload_header_map_flag_null_triples_e = 0x200000,
+ f_fss_payload_header_map_flag_quote_double_e = 0x400000,
+ f_fss_payload_header_map_flag_quote_grave_e = 0x800000,
+ f_fss_payload_header_map_flag_quote_single_e = 0x1000000,
+ f_fss_payload_header_map_flag_last_e = 0x2000000,
}; // enum
#endif // _di_f_fss_payload_header_map_flag_e_
data->cache->used = 0;
if (private_fl_payload_header_map_number_signed(data, state, &internal, headers.array[internal.i].value.is.a_signed) == F_false) {
- private_fl_payload_header_map_cache(data, state, &internal);
- }
-
- if (F_status_is_error_not(state->status)) {
- ++destinations->used;
+ if (private_fl_payload_header_map_cache_write(data, state, &internal) == F_false) {
+ ++destinations->used;
+ }
}
break;
data->cache->used = 0;
if (private_fl_payload_header_map_number_unsigned(data, state, &internal, headers.array[internal.i].value.is.a_unsigned) == F_false) {
- private_fl_payload_header_map_cache(data, state, &internal);
- }
-
- if (F_status_is_error_not(state->status)) {
- ++destinations->used;
+ if (private_fl_payload_header_map_cache_write(data, state, &internal) == F_false) {
+ ++destinations->used;
+ }
}
break;
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;
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;
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_join_maps_e) {
+ 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;
break;
-// @todo resume after here.
case f_abstruse_map_multi_e:
// @todo
break;
break;
case f_abstruse_range_e:
+ if (headers.array[internal.i].value.is.a_range.start <= headers.array[internal.i].value.is.a_range.stop || (data->flag & f_fss_payload_header_map_flag_null_range_e)) {
+ if (private_fl_payload_header_map_range(data, state, &internal, headers.array[internal.i].value.is.a_range, destinations) == F_false) {
+ ++destinations->used;
+ }
+ }
+ else if (data->flag & f_fss_payload_header_map_flag_null_e) {
+ ++destinations->used;
+ }
+
+ break;
+
case f_abstruse_ranges_e:
- // @todo
+ if (headers.array[internal.i].value.is.a_ranges.used || (data->flag & f_fss_payload_header_map_flag_null_ranges_e)) {
+ if (private_fl_payload_header_map_ranges(data, state, &internal, headers.array[internal.i].value.is.a_ranges, destinations) == F_false) {
+ ++destinations->used;
+ }
+ }
+ else if (data->flag & f_fss_payload_header_map_flag_null_e) {
+ ++destinations->used;
+ }
+
break;
+// @todo resume after here.
case f_abstruse_triple_e:
// @todo update this.
data->cache->used = 0;
#endif
/**
+ * Special print strings.
+ *
+ * FL_fss_payload_*_d:
+ * - digit_size_1: A default buffer size to use when allocating space for digit conversions of one digit.
+ * - digit_size_2: A default buffer size to use when allocating space for digit conversions of two digits.
+ */
+#ifndef _di_fl_fss_payload_d_
+ #define FL_payload_digit_size_1_d 32
+ #define FL_payload_digit_size_2_d 64
+#endif // _di_fl_fss_payload_d_
+
+/**
* Write standard header of the FSS-000E (Payload).
*
* This implementation does not handle the following f_abstruse_*_e:
} /* for */ \
\
if (data->cache->used && (data->flag & f_fss_payload_header_map_flag_join_digits_e)) { \
- private_fl_payload_header_map_cache(data, state, &internal); \
+ private_fl_payload_header_map_cache_write(data, state, &internal); \
\
if (F_status_is_error_not(state->status)) { \
++destinations->used; \
#endif
#if !defined(_di_fl_fss_payload_header_map_)
- uint8_t private_fl_payload_header_map_cache(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal) {
+ uint8_t private_fl_payload_header_map_cache_write(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal) {
if (!data->cache->used) 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) {
+ if (data->flag & f_fss_payload_header_map_flag_null_range_e) {
+ 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);
+ 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 + 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);
+ 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;
+ }
+ }
+ }
+ else {
+ data->cache->used = 0;
+
+ if (private_fl_payload_header_map_number_unsigned(data, state, internal, range.start) == F_true) return F_true;
+
+ if (data->flag & f_fss_payload_header_map_flag_join_range_e) {
+ if (private_fl_payload_header_map_number_unsigned(data, state, internal, range.stop) == 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, range.stop) == F_true) return F_true;
+ if (private_fl_payload_header_map_cache_write(data, state, internal) == F_true) 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_ranges(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, const f_ranges_t ranges, f_string_maps_t * const destinations) {
+
+ if (ranges.used) {
+ internal->k = 0;
+
+ for (internal->l = 0; internal->l < ranges.used; ++internal->l) {
+
+ 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;
+ }
+ 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;
+ }
+ } // 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_ranges_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 < ranges.used; ++internal->l) {
+
+ 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) {
+ 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;
+ }
+
+ continue;
+ }
+
+ if (private_fl_payload_header_map_number_unsigned(data, state, internal, ranges.array[internal->l].start) == F_true) return F_true;
+ if (private_fl_payload_header_map_number_unsigned(data, state, internal, ranges.array[internal->l].stop) == F_true) 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_range_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 < ranges.used; ++internal->l) {
+
+ 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;
+
+ 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;
+ }
+
+ continue;
+ }
+
+ data->cache->used = 0;
+
+ if (private_fl_payload_header_map_number_unsigned(data, state, internal, ranges.array[internal->l].start) == F_true) return F_true;
+ if (private_fl_payload_header_map_number_unsigned(data, state, internal, ranges.array[internal->l].stop) == F_true) 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 < ranges.used; ++internal->l) {
+
+ 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);
+ 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;
+
+ continue;
+ }
+
+ data->cache->used = 0;
+
+ if (private_fl_payload_header_map_number_unsigned(data, state, internal, ranges.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, ranges.array[internal->l].stop) == 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;
+ } // for
+
+ // Remove the always added trailing space (except when all ranges are NULL and f_fss_payload_header_map_flag_null_range_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_ranges_e) {
+ if (data->flag & (f_fss_payload_header_map_flag_join_ranges_e | f_fss_payload_header_map_flag_join_ranges_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);
+ 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_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_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;
* @see fl_fss_payload_header_map()
*/
#if !defined(_di_fl_fss_payload_header_map_)
- extern uint8_t private_fl_payload_header_map_cache(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal) F_attribute_visibility_internal_d;
+ extern uint8_t private_fl_payload_header_map_cache_write(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal) F_attribute_visibility_internal_d;
#endif // !defined(_di_fl_fss_payload_header_map_)
/**
#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.
+ *
+ * @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 range
+ * The range 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_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) 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.
+ *
+ * @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 range
+ * The range 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_ranges(f_fss_payload_header_state_t * const data, f_state_t * const state, f_fss_payload_header_internal_t * const internal, const f_ranges_t ranges, f_string_maps_t * const destinations) F_attribute_visibility_internal_d;
+#endif // !defined(_di_fl_fss_payload_header_map_)
+
+/**
* Process the array of NULL terminated 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.