]> Kevux Git Server - fll/commitdiff
Feature: Add f_simple_packet_t for holding the packet data.
authorKevin Day <kevin@kevux.org>
Sat, 5 Aug 2023 19:44:08 +0000 (14:44 -0500)
committerKevin Day <kevin@kevux.org>
Sat, 5 Aug 2023 19:45:11 +0000 (14:45 -0500)
The f_simple_packet_range_t holds ranges within a string.

This f_simple_packet_t holds the actual values for the packet rather than ranges mapped to some string.

I am omitting unit tests at this time because I am going to do some additional changes involving the allocation and deallocation code project wide.

level_0/f_fss/c/fss/private-simple_packet.c
level_0/f_fss/c/fss/private-simple_packet.h
level_0/f_fss/c/fss/simple_packet.c
level_0/f_fss/c/fss/simple_packet.h

index 704b12c3e0725eb1ab512cc92d50cb23b835ea0b..41d76baf3607ebc4976c5934dde4ad65c2c792d6 100644 (file)
@@ -67,6 +67,102 @@ extern "C" {
   }
 #endif // !defined(_di_f_fss_simple_packet_rangess_decrease_by_) || !defined(_di_f_fss_simple_packet_rangess_resize_)
 
+#if !defined(_di_f_fss_simple_packets_adjust_) || !defined(_di_f_fss_simple_packets_decimate_by_)
+  f_status_t private_f_fss_simple_packets_adjust(const f_number_unsigned_t length, f_fss_simple_packets_t *packets) {
+
+    {
+      f_status_t status = F_none;
+
+      for (f_number_unsigned_t i = length; i < packets->size; ++i) {
+
+        status = f_string_dynamic_adjust(0, &packets->array[i].payload);
+        if (F_status_is_error(status)) return status;
+      } // for
+    }
+
+    return f_memory_array_adjust(length, sizeof(f_fss_simple_packet_t), (void **) &packets->array, &packets->used, &packets->size);
+  }
+#endif // !defined(_di_f_fss_simple_packets_adjust_) || !defined(_di_f_fss_simple_packets_decimate_by_)
+
+#if !defined(_di_f_fss_simple_packets_append_) || !defined(_di_f_fss_simple_packetss_append_)
+  extern f_status_t private_f_fss_simple_packets_append(const f_fss_simple_packet_t source, f_fss_simple_packets_t *destination) {
+
+    const f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_fss_simple_packet_t), (void **) &destination->array, &destination->used, &destination->size);
+    if (F_status_is_error(status)) return status;
+
+    destination->array[destination->used++] = source;
+
+    return F_none;
+  }
+#endif // !defined(_di_f_fss_simple_packets_append_) || !defined(_di_f_fss_simple_packetss_append_)
+
+#if !defined(_di_f_fss_simple_packets_append_) || !defined(_di_f_fss_simple_packets_append_all_) || !defined(_di_f_fss_simple_packetss_append_all_)
+  extern f_status_t private_f_fss_simple_packets_append_all(const f_fss_simple_packets_t source, f_fss_simple_packets_t *destination) {
+
+    {
+      const f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_fss_simple_packet_t), (void **) &destination->array, &destination->used, &destination->size);
+      if (F_status_is_error(status)) return status;
+    }
+
+    for (f_number_unsigned_t i = 0; i < source.used; ++i) {
+      destination->array[destination->used++] = source.array[i];
+    } // for
+
+    return F_none;
+  }
+#endif // !defined(_di_f_fss_simple_packets_append_) || !defined(_di_f_fss_simple_packets_append_all_) || !defined(_di_f_fss_simple_packetss_append_all_)
+
+#if !defined(_di_f_fss_simple_packets_decrease_by_) || !defined(_di_f_fss_simple_packets_resize_)
+  f_status_t private_f_fss_simple_packets_resize(const f_number_unsigned_t length, f_fss_simple_packets_t *packets) {
+
+    {
+      f_status_t status = F_none;
+
+      for (f_number_unsigned_t i = length; i < packets->size; ++i) {
+
+        status = f_string_dynamic_resize(0, &packets->array[i].payload);
+        if (F_status_is_error(status)) return status;
+      } // for
+    }
+
+    return f_memory_array_resize(length, sizeof(f_fss_simple_packet_t), (void **) &packets->array, &packets->used, &packets->size);
+  }
+#endif // !defined(_di_f_fss_simple_packets_decrease_by_) || !defined(_di_f_fss_simple_packets_resize_)
+
+#if !defined(_di_f_fss_simple_packetss_adjust_) || !defined(_di_f_fss_simple_packetss_decimate_by_)
+  f_status_t private_f_fss_simple_packetss_adjust(const f_number_unsigned_t length, f_fss_simple_packetss_t *packetss) {
+
+    {
+      f_status_t status = F_none;
+
+      for (f_number_unsigned_t i = length; i < packetss->size; ++i) {
+
+        status = f_memory_array_adjust(0, sizeof(f_fss_simple_packet_t), (void **) &packetss->array[i].array, &packetss->array[i].used, &packetss->array[i].size);
+        if (F_status_is_error(status)) return status;
+      } // for
+    }
+
+    return f_memory_array_adjust(length, sizeof(f_fss_simple_packets_t), (void **) &packetss->array, &packetss->used, &packetss->size);
+  }
+#endif // !defined(_di_f_fss_simple_packetss_adjust_) || !defined(_di_f_fss_simple_packetss_decimate_by_)
+
+#if !defined(_di_f_fss_simple_packetss_decrease_by_) || !defined(_di_f_fss_simple_packetss_resize_)
+  f_status_t private_f_fss_simple_packetss_resize(const f_number_unsigned_t length, f_fss_simple_packetss_t *packetss) {
+
+    {
+      f_status_t status = F_none;
+
+      for (f_number_unsigned_t i = length; i < packetss->size; ++i) {
+
+        status = f_memory_array_resize(0, sizeof(f_fss_simple_packet_t), (void **) &packetss->array[i].array, &packetss->array[i].used, &packetss->array[i].size);
+        if (F_status_is_error(status)) return status;
+      } // for
+    }
+
+    return f_memory_array_resize(length, sizeof(f_fss_simple_packets_t), (void **) &packetss->array, &packetss->used, &packetss->size);
+  }
+#endif // !defined(_di_f_fss_simple_packetss_decrease_by_) || !defined(_di_f_fss_simple_packetss_resize_)
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index f9639cdef5ab9cc9e9465c05c219dfd8c6e1a91e..c64619de555a240a55b9e1949071acf2da026488 100644 (file)
@@ -120,6 +120,163 @@ extern "C" {
   extern f_status_t private_f_fss_simple_packet_rangess_resize(const f_number_unsigned_t length, f_fss_simple_packet_rangess_t *rangess) F_attribute_visibility_internal_d;
 #endif // !defined(_di_f_fss_simple_packet_rangess_decrease_by_) || !defined(_di_f_fss_simple_packet_rangess_resize_)
 
+/**
+ * Private implementation for resizing the simple packet array.
+ *
+ * Intended to be shared to each of the different implementation variations.
+ *
+ * @param length
+ *   The length to adjust to.
+ * @param packets
+ *   The simple packet array to adjust.
+ *
+ * @return
+ *   Success from f_memory_array_adjust().
+ *
+ *   F_parameter (with error bit) if a parameter is invalid.
+ *
+ *   Errors (with error bit) from: f_memory_array_adjust().
+ *
+ * @see f_memory_array_adjust()
+ *
+ * @see f_fss_simple_packets_decrease_by()
+ * @see f_fss_simple_packets_adjust()
+ */
+#if !defined(_di_f_fss_simple_packets_adjust_) || !defined(_di_f_fss_simple_packets_decimate_by_)
+  extern f_status_t private_f_fss_simple_packets_adjust(const f_number_unsigned_t length, f_fss_simple_packets_t *packets) F_attribute_visibility_internal_d;
+#endif // !defined(_di_f_fss_simple_packets_adjust_) || !defined(_di_f_fss_simple_packets_decimate_by_)
+
+/**
+ * Private implementation for appending the simple packet array.
+ *
+ * Intended to be shared to each of the different implementation variations.
+ *
+ * @param source
+ *   The source simple packet to append.
+ * @param destination
+ *   The destination lengths the source is appended onto.
+ *
+ * @return
+ *   Success from f_memory_array_increase().
+ *
+ *   F_parameter (with error bit) if a parameter is invalid.
+ *
+ *   Errors (with error bit) from: f_memory_array_increase().
+ *
+ * @see f_memory_array_increase()
+ *
+ * @see f_fss_simple_packets_append()
+ * @see f_fss_simple_packetss_append()
+ */
+#if !defined(_di_f_fss_simple_packets_append_) || !defined(_di_f_fss_simple_packetss_append_)
+  extern f_status_t private_f_fss_simple_packets_append(const f_fss_simple_packet_t source, f_fss_simple_packets_t *destination) F_attribute_visibility_internal_d;
+#endif // !defined(_di_f_fss_simple_packets_append_) || !defined(_di_f_fss_simple_packetss_append_)
+
+/**
+ * Private implementation for appending the simple packet array.
+ *
+ * Intended to be shared to each of the different implementation variations.
+ *
+ * @param source
+ *   The source simple packets to append.
+ * @param destination
+ *   The destination lengths the source is appended onto.
+ *
+ * @return
+ *   Success from f_memory_array_increase_by().
+ *
+ *   F_parameter (with error bit) if a parameter is invalid.
+ *
+ *   Errors (with error bit) from: f_memory_array_increase_by().
+ *
+ * @see f_memory_array_increase_by()
+ *
+ * @see f_fss_simple_packets_append_all()
+ * @see f_fss_simple_packetss_append()
+ * @see f_fss_simple_packetss_append_all()
+ */
+#if !defined(_di_f_fss_simple_packets_append_) || !defined(_di_f_fss_simple_packets_append_all_) || !defined(_di_f_fss_simple_packetss_append_all_)
+  extern f_status_t private_f_fss_simple_packets_append_all(const f_fss_simple_packets_t source, f_fss_simple_packets_t *destination) F_attribute_visibility_internal_d;
+#endif // !defined(_di_f_fss_simple_packets_append_) || !defined(_di_f_fss_simple_packets_append_all_) || !defined(_di_f_fss_simple_packetss_append_all_)
+
+/**
+ * Private implementation for resizing the simple packet array.
+ *
+ * Intended to be shared to each of the different implementation variations.
+ *
+ * @param length
+ *   The length to resize to.
+ * @param packets
+ *   The simple packet array to resize.
+ *
+ * @return
+ *   Success from f_memory_array_resize().
+ *
+ *   F_parameter (with error bit) if a parameter is invalid.
+ *
+ *   Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_resize()
+ *
+ * @see f_fss_simple_packets_decrease_by()
+ * @see f_fss_simple_packets_resize()
+ */
+#if !defined(_di_f_fss_simple_packets_decrease_by_) || !defined(_di_f_fss_simple_packets_resize_)
+  extern f_status_t private_f_fss_simple_packets_resize(const f_number_unsigned_t length, f_fss_simple_packets_t *packets) F_attribute_visibility_internal_d;
+#endif // !defined(_di_f_fss_simple_packets_decrease_by_) || !defined(_di_f_fss_simple_packets_resize_)
+
+/**
+ * Private implementation for resizing the simple packets array.
+ *
+ * Intended to be shared to each of the different implementation variations.
+ *
+ * @param length
+ *   The length to adjust to.
+ * @param packetss
+ *   The simple packets array to adjust.
+ *
+ * @return
+ *   Success from f_memory_array_adjust().
+ *
+ *   F_parameter (with error bit) if a parameter is invalid.
+ *
+ *   Errors (with error bit) from: f_memory_array_adjust().
+ *
+ * @see f_memory_array_adjust()
+ *
+ * @see f_fss_simple_packetss_decrease_by()
+ * @see f_fss_simple_packetss_adjust()
+ */
+#if !defined(_di_f_fss_simple_packetss_adjust_) || !defined(_di_f_fss_simple_packetss_decimate_by_)
+  extern f_status_t private_f_fss_simple_packetss_adjust(const f_number_unsigned_t length, f_fss_simple_packetss_t *packetss) F_attribute_visibility_internal_d;
+#endif // !defined(_di_f_fss_simple_packetss_adjust_) || !defined(_di_f_fss_simple_packetss_decimate_by_)
+
+/**
+ * Private implementation for resizing the simple packets array.
+ *
+ * Intended to be shared to each of the different implementation variations.
+ *
+ * @param length
+ *   The length to resize to.
+ * @param packetss
+ *   The simple packets array to resize.
+ *
+ * @return
+ *   Success from f_memory_array_resize().
+ *
+ *   F_parameter (with error bit) if a parameter is invalid.
+ *
+ *   Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_resize()
+ *
+ * @see f_fss_simple_packetss_decrease_by()
+ * @see f_fss_simple_packetss_resize()
+ */
+#if !defined(_di_f_fss_simple_packetss_decrease_by_) || !defined(_di_f_fss_simple_packetss_resize_)
+  extern f_status_t private_f_fss_simple_packetss_resize(const f_number_unsigned_t length, f_fss_simple_packetss_t *packetss) F_attribute_visibility_internal_d;
+#endif // !defined(_di_f_fss_simple_packetss_decrease_by_) || !defined(_di_f_fss_simple_packetss_resize_)
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index 4f02106acf69c05c467bf49978ea670b77724e94..1ac32356dd9c0f06339b23e87599e855bd629e9e 100644 (file)
@@ -5,6 +5,26 @@
 extern "C" {
 #endif
 
+#ifndef _di_f_fss_simple_packet_delete_
+  f_status_t f_fss_simple_packet_delete(f_fss_simple_packet_t * const packet) {
+    #ifndef _di_level_0_parameter_checking_
+      if (!packet) return F_status_set_error(F_parameter);
+    #endif // _di_level_0_parameter_checking_
+
+    return f_string_dynamic_resize(0, &packet->payload);
+  }
+#endif // _di_f_fss_simple_packet_delete_
+
+#ifndef _di_f_fss_simple_packet_destroy_
+  f_status_t f_fss_simple_packet_destroy(f_fss_simple_packet_t * const packet) {
+    #ifndef _di_level_0_parameter_checking_
+      if (!packet) return F_status_set_error(F_parameter);
+    #endif // _di_level_0_parameter_checking_
+
+    return f_string_dynamic_adjust(0, &packet->payload);
+  }
+#endif // _di_f_fss_simple_packet_destroy_
+
 #ifndef _di_f_fss_simple_packet_identify_
   f_status_t f_fss_simple_packet_identify(const f_string_static_t buffer, f_fss_simple_packet_range_t * const range) {
     #ifndef _di_level_0_parameter_checking_
@@ -248,6 +268,197 @@ extern "C" {
   }
 #endif // _di_f_fss_simple_packet_rangess_resize_
 
+#ifndef _di_f_fss_simple_packets_adjust_
+  f_status_t f_fss_simple_packets_adjust(const f_number_unsigned_t length, f_fss_simple_packets_t *packets) {
+    #ifndef _di_level_0_parameter_checking_
+      if (!packets) return F_status_set_error(F_parameter);
+    #endif // _di_level_0_parameter_checking_
+
+    return private_f_fss_simple_packets_adjust(length, packets);
+  }
+#endif // _di_f_fss_simple_packets_adjust_
+
+#ifndef _di_f_fss_simple_packets_append_
+  f_status_t f_fss_simple_packets_append(const f_fss_simple_packet_t source, f_fss_simple_packets_t *destination) {
+    #ifndef _di_level_0_parameter_checking_
+      if (!destination) return F_status_set_error(F_parameter);
+    #endif // _di_level_0_parameter_checking_
+
+    return private_f_fss_simple_packets_append(source, destination);
+  }
+#endif // _di_f_fss_simple_packets_append_
+
+#ifndef _di_f_fss_simple_packets_append_all_
+  f_status_t f_fss_simple_packets_append_all(const f_fss_simple_packets_t source, f_fss_simple_packets_t *destination) {
+    #ifndef _di_level_0_parameter_checking_
+      if (!destination) return F_status_set_error(F_parameter);
+    #endif // _di_level_0_parameter_checking_
+
+    if (!source.used) return F_data_not;
+
+    return private_f_fss_simple_packets_append_all(source, destination);
+  }
+#endif // _di_f_fss_simple_packets_append_all_
+
+#ifndef _di_f_fss_simple_packets_decimate_by_
+  f_status_t f_fss_simple_packets_decimate_by(const f_number_unsigned_t amount, f_fss_simple_packets_t *packets) {
+    #ifndef _di_level_0_parameter_checking_
+      if (!packets) return F_status_set_error(F_parameter);
+    #endif // _di_level_0_parameter_checking_
+
+    return f_memory_array_decimate_by(amount, sizeof(f_fss_simple_packet_t), (void **) &packets->array, &packets->used, &packets->size);
+  }
+#endif // _di_f_fss_simple_packets_decimate_by_
+
+#ifndef _di_f_fss_simple_packets_decrease_by_
+  f_status_t f_fss_simple_packets_decrease_by(const f_number_unsigned_t amount, f_fss_simple_packets_t *packets) {
+    #ifndef _di_level_0_parameter_checking_
+      if (!packets) return F_status_set_error(F_parameter);
+    #endif // _di_level_0_parameter_checking_
+
+    return f_memory_array_decrease_by(amount, sizeof(f_fss_simple_packet_t), (void **) &packets->array, &packets->used, &packets->size);
+  }
+#endif // _di_f_fss_simple_packets_decrease_by_
+
+#ifndef _di_f_fss_simple_packets_increase_
+  f_status_t f_fss_simple_packets_increase(const f_number_unsigned_t step, f_fss_simple_packets_t *packets) {
+    #ifndef _di_level_0_parameter_checking_
+      if (!packets) return F_status_set_error(F_parameter);
+    #endif // _di_level_0_parameter_checking_
+
+    return f_memory_array_increase(step, sizeof(f_fss_simple_packet_t), (void **) &packets->array, &packets->used, &packets->size);
+  }
+#endif // _di_f_fss_simple_packets_increase_
+
+#ifndef _di_f_fss_simple_packets_increase_by_
+  f_status_t f_fss_simple_packets_increase_by(const f_number_unsigned_t amount, f_fss_simple_packets_t *packets) {
+    #ifndef _di_level_0_parameter_checking_
+      if (!packets) return F_status_set_error(F_parameter);
+    #endif // _di_level_0_parameter_checking_
+
+    return f_memory_array_increase_by(amount, sizeof(f_fss_simple_packet_t), (void **) &packets->array, &packets->used, &packets->size);
+  }
+#endif // _di_f_fss_simple_packets_increase_by_
+
+#ifndef _di_f_fss_simple_packets_resize_
+  f_status_t f_fss_simple_packets_resize(const f_number_unsigned_t length, f_fss_simple_packets_t *packets) {
+    #ifndef _di_level_0_parameter_checking_
+      if (!packets) return F_status_set_error(F_parameter);
+    #endif // _di_level_0_parameter_checking_
+
+    return private_f_fss_simple_packets_resize(length, packets);
+  }
+#endif // _di_f_fss_simple_packets_resize_
+
+#ifndef _di_f_fss_simple_packetss_adjust_
+  f_status_t f_fss_simple_packetss_adjust(const f_number_unsigned_t length, f_fss_simple_packetss_t *packetss) {
+    #ifndef _di_level_0_parameter_checking_
+      if (!packetss) return F_status_set_error(F_parameter);
+    #endif // _di_level_0_parameter_checking_
+
+    return private_f_fss_simple_packetss_adjust(length, packetss);
+  }
+#endif // _di_f_fss_simple_packetss_adjust_
+
+#ifndef _di_f_fss_simple_packetss_append_
+  f_status_t f_fss_simple_packetss_append(const f_fss_simple_packets_t source, f_fss_simple_packetss_t *destination) {
+    #ifndef _di_level_0_parameter_checking_
+      if (!destination) return F_status_set_error(F_parameter);
+    #endif // _di_level_0_parameter_checking_
+
+    if (!source.used) return F_data_not;
+
+    f_status_t status = f_memory_array_increase(F_memory_default_allocation_small_d, sizeof(f_fss_simple_packets_t), (void **) &destination->array, &destination->used, &destination->size);
+    if (F_status_is_error(status)) return status;
+
+    status = private_f_fss_simple_packets_append_all(source, &destination->array[destination->used]);
+    if (F_status_is_error(status)) return status;
+
+    ++destination->used;
+
+    return F_none;
+  }
+#endif // _di_f_fss_simple_packetss_append_
+
+#ifndef _di_f_fss_simple_packetss_append_all_
+  f_status_t f_fss_simple_packetss_append_all(const f_fss_simple_packetss_t source, f_fss_simple_packetss_t *destination) {
+    #ifndef _di_level_0_parameter_checking_
+      if (!destination) return F_status_set_error(F_parameter);
+    #endif // _di_level_0_parameter_checking_
+
+    if (!source.used) return F_data_not;
+
+    f_status_t status = f_memory_array_increase_by(source.used, sizeof(f_fss_simple_packets_t), (void **) &destination->array, &destination->used, &destination->size);
+    if (F_status_is_error(status)) return status;
+
+    for (f_number_unsigned_t i = 0; i < source.used; ++i, ++destination->used) {
+
+      destination->array[destination->used].used = 0;
+
+      if (source.array[i].used) {
+        status = private_f_fss_simple_packets_append_all(source.array[i], &destination->array[destination->used]);
+        if (F_status_is_error(status)) return status;
+      }
+    } // for
+
+    return F_none;
+  }
+#endif // _di_f_fss_simple_packetss_append_all_
+
+#ifndef _di_f_fss_simple_packetss_decimate_by_
+  f_status_t f_fss_simple_packetss_decimate_by(const f_number_unsigned_t amount, f_fss_simple_packetss_t *packetss) {
+    #ifndef _di_level_0_parameter_checking_
+      if (!packetss) return F_status_set_error(F_parameter);
+    #endif // _di_level_0_parameter_checking_
+
+    if (!amount) return F_data_not;
+
+    return private_f_fss_simple_packetss_adjust((packetss->size > amount) ? packetss->size - amount : 0, packetss);
+  }
+#endif // _di_f_fss_simple_packetss_decimate_by_
+
+#ifndef _di_f_fss_simple_packetss_decrease_by_
+  f_status_t f_fss_simple_packetss_decrease_by(const f_number_unsigned_t amount, f_fss_simple_packetss_t *packetss) {
+    #ifndef _di_level_0_parameter_checking_
+      if (!packetss) return F_status_set_error(F_parameter);
+    #endif // _di_level_0_parameter_checking_
+
+    if (!amount) return F_data_not;
+
+    return private_f_fss_simple_packetss_resize((packetss->size > amount) ? packetss->size - amount : 0, packetss);
+  }
+#endif // _di_f_fss_simple_packetss_decrease_by_
+
+#ifndef _di_f_fss_simple_packetss_increase_
+  f_status_t f_fss_simple_packetss_increase(const f_number_unsigned_t step, f_fss_simple_packetss_t *packetss) {
+    #ifndef _di_level_0_parameter_checking_
+      if (!packetss) return F_status_set_error(F_parameter);
+    #endif // _di_level_0_parameter_checking_
+
+    return f_memory_array_increase(step, sizeof(f_fss_simple_packets_t), (void **) &packetss->array, &packetss->used, &packetss->size);
+  }
+#endif // _di_f_fss_simple_packetss_increase_
+
+#ifndef _di_f_fss_simple_packetss_increase_by_
+  f_status_t f_fss_simple_packetss_increase_by(const f_number_unsigned_t amount, f_fss_simple_packetss_t *packetss) {
+    #ifndef _di_level_0_parameter_checking_
+      if (!packetss) return F_status_set_error(F_parameter);
+    #endif // _di_level_0_parameter_checking_
+
+    return f_memory_array_increase_by(amount, sizeof(f_fss_simple_packets_t), (void **) &packetss->array, &packetss->used, &packetss->size);
+  }
+#endif // _di_f_fss_simple_packetss_increase_by_
+
+#ifndef _di_f_fss_simple_packetss_resize_
+  f_status_t f_fss_simple_packetss_resize(const f_number_unsigned_t length, f_fss_simple_packetss_t *packetss) {
+    #ifndef _di_level_0_parameter_checking_
+      if (!packetss) return F_status_set_error(F_parameter);
+    #endif // _di_level_0_parameter_checking_
+
+    return private_f_fss_simple_packetss_resize(length, packetss);
+  }
+#endif // _di_f_fss_simple_packetss_resize_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index 22024d7479be116612dfe6f6a45a1e3df8a14ed3..298635ec3ab2eb98d9472223a03be17dbc283032 100644 (file)
@@ -36,6 +36,105 @@ extern "C" {
 #endif // _di_f_fss_simple_packet_d_
 
 /**
+ * A structure representing the Simple Packet.
+ *
+ * Properties:
+ *   - control: The Control Block, which is 1 byte long.
+ *   - size:    The Size Block, which is 4 bytes long.
+ *   - payload: The Payload Block, which is inclusively between 0 and (2^32)-6 bytes long.
+ */
+#ifndef _di_f_fss_simple_packet_t_
+  typedef struct {
+    uint8_t control;
+    uint32_t size;
+    f_string_dynamic_t payload;
+  } f_fss_simple_packet_t;
+
+  #define f_fss_simple_packet_t_initialize { \
+    0, \
+    0, \
+    f_string_dynamic_t_initialize, \
+  }
+
+  #define macro_f_fss_simple_packet_t_initialize_1(control, size, payload) { \
+    control, \
+    size, \
+    payload, \
+  }
+
+  #define macro_f_fss_simple_packet_t_initialize_2(payload) { \
+    0, \
+    0, \
+    payload, \
+  }
+#endif // _di_f_fss_simple_packet_t_
+
+/**
+ * This holds an array of f_fss_simple_packet_t.
+ *
+ * Properties:
+ *   - array: An array of f_fss_simple_packet_t.
+ *   - size:  Total amount of allocated space.
+ *   - used:  Total number of allocated spaces used.
+ */
+#ifndef _di_f_fss_simple_packets_t_
+  typedef struct {
+    f_fss_simple_packet_t *array;
+
+    f_number_unsigned_t size;
+    f_number_unsigned_t used;
+  } f_fss_simple_packets_t;
+
+  #define f_fss_simple_packets_t_initialize { 0, 0, 0 }
+
+  #define macro_f_fss_simple_packets_t_initialize_1(array, size, used) { array, size, used }
+  #define macro_f_fss_simple_packets_t_initialize_2(array, length) { array, length, length }
+
+  #define macro_f_fss_simple_packets_t_resize(status, simple_packets, length) status = f_fss_simple_packets_resize(length, &simple_packets);
+  #define macro_f_fss_simple_packets_t_adjust(status, simple_packets, length) status = f_fss_simple_packets_adjust(length, &simple_packets);
+
+  #define macro_f_fss_simple_packets_t_delete_simple(simple_packets)  f_fss_simple_packets_resize(0, &simple_packets);
+  #define macro_f_fss_simple_packets_t_destroy_simple(simple_packets) f_fss_simple_packets_adjust(0, &simple_packets);
+
+  #define macro_f_fss_simple_packets_t_increase(status, step, simple_packets)      status = f_fss_simple_packets_increase(step, &simple_packets);
+  #define macro_f_fss_simple_packets_t_increase_by(status, simple_packets, amount) status = f_fss_simple_packets_increase_by(amount, &simple_packets);
+  #define macro_f_fss_simple_packets_t_decrease_by(status, simple_packets, amount) status = f_fss_simple_packets_decrease_by(amount, &simple_packets);
+  #define macro_f_fss_simple_packets_t_decimate_by(status, simple_packets, amount) status = f_fss_simple_packets_decimate_by(amount, &simple_packets);
+#endif // _di_f_fss_simple_packets_t_
+
+/**
+ * This holds an array of f_fss_simple_packets_t.
+ *
+ * Properties:
+ *   - array: An array of f_fss_simple_packets_t.
+ *   - size:  Total amount of allocated space.
+ *   - used:  Total number of allocated spaces used.
+ */
+#ifndef _di_f_fss_simple_packetss_t_
+  typedef struct {
+    f_fss_simple_packets_t *array;
+
+    f_number_unsigned_t size;
+    f_number_unsigned_t used;
+  } f_fss_simple_packetss_t;
+
+  #define f_fss_simple_packetss_t_initialize { 0, 0, 0 }
+
+  #define macro_f_fss_simple_packetss_t_initialize_1(array, size, used) { array, size, used }
+  #define macro_f_fss_simple_packetss_t_initialize_2(array, length) { array, length, length }
+
+  #define macro_f_fss_simple_packetss_t_resize(status, simple_packetss, length) status = f_fss_simple_packetss_resize(length, &simple_packetss);
+  #define macro_f_fss_simple_packetss_t_adjust(status, simple_packetss, length) status = f_fss_simple_packetss_adjust(length, &simple_packetss);
+
+  #define macro_f_fss_simple_packetss_t_delete_simple(simple_packetss)  f_fss_simple_packetss_resize(0, &simple_packetss);
+  #define macro_f_fss_simple_packetss_t_destroy_simple(simple_packetss) f_fss_simple_packetss_adjust(0, &simple_packetss);
+
+  #define macro_f_fss_simple_packetss_t_increase(status, step, simple_packetss)      status = f_fss_simple_packetss_increase(step, &simple_packetss);
+  #define macro_f_fss_simple_packetss_t_increase_by(status, simple_packetss, amount) status = f_fss_simple_packetss_increase_by(amount, &simple_packetss);
+  #define macro_f_fss_simple_packetss_t_decrease_by(status, simple_packetss, amount) status = f_fss_simple_packetss_decrease_by(amount, &simple_packetss);
+  #define macro_f_fss_simple_packetss_t_decimate_by(status, simple_packetss, amount) status = f_fss_simple_packetss_decimate_by(amount, &simple_packetss);
+#endif // _di_f_fss_simple_packetss_t_
+/**
  * A set of string ranges intending to designate the different ranges for a Simple Packet representing each Block.
  *
  * Properties:
@@ -130,6 +229,44 @@ extern "C" {
 #endif // _di_f_fss_simple_packet_rangess_t_
 
 /**
+ * Delete a simple packet.
+ *
+ * @param packet
+ *   The simple packet to delete.
+ *
+ * @return
+ *   F_none on success.
+ *
+ *   F_parameter (with error bit) if a parameter is invalid.
+ *
+ *   F_failure (with error bit) on any other error.
+ *
+ * @see f_string_dynamic_resize()
+ */
+#ifndef _di_f_fss_simple_packet_delete_
+  extern f_status_t f_fss_simple_packet_delete(f_fss_simple_packet_t * const packet);
+#endif // _di_f_fss_simple_packet_delete_
+
+/**
+ * Destroy a simple packet.
+ *
+ * @param packet
+ *   The simple packet to destroy.
+ *
+ * @return
+ *   F_none on success.
+ *
+ *   F_parameter (with error bit) if a parameter is invalid.
+ *
+ *   F_failure (with error bit) on any other error.
+ *
+ * @see f_string_dynamic_adjust()
+ */
+#ifndef _di_f_fss_simple_packet_destroy_
+  extern f_status_t f_fss_simple_packet_destroy(f_fss_simple_packet_t * const packet);
+#endif // _di_f_fss_simple_packet_destroy_
+
+/**
  * Identify the ranges representing the different parts of the FSS-000F (Simple Packet).
  *
  * @param buffer
@@ -544,6 +681,399 @@ extern "C" {
   extern f_status_t f_fss_simple_packet_rangess_resize(const f_number_unsigned_t length, f_fss_simple_packet_rangess_t *rangess);
 #endif // _di_f_fss_simple_packet_rangess_resize_
 
+/**
+ * Resize the simple packet array.
+ *
+ * @param length
+ *   The new size to use.
+ * @param packets
+ *   The simple packet array to resize.
+ *
+ * @return
+ *   Success from f_memory_array_resize().
+ *
+ *   F_parameter (with error bit) if a parameter is invalid.
+ *
+ *   Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_resize()
+ */
+#ifndef _di_f_fss_simple_packets_adjust_
+  extern f_status_t f_fss_simple_packets_adjust(const f_number_unsigned_t length, f_fss_simple_packets_t *packets);
+#endif // _di_f_fss_simple_packets_adjust_
+
+/**
+ * Append the single source simple packet onto the destination.
+ *
+ * @param source
+ *   The source packet to append.
+ * @param destination
+ *   The destination simple packet the source is appended onto.
+ *
+ * @return
+ *   F_none on success.
+ *   F_data_not on success, but there is nothing to append (size == 0).
+ *
+ *   Success from f_memory_array_resize().
+ *
+ *   F_parameter (with error bit) if a parameter is invalid.
+ *
+ *   Errors (with error bit) from: f_memory_array_increase().
+ *   Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_increase()
+ * @see f_memory_array_resize()
+ */
+#ifndef _di_f_fss_simple_packets_append_
+  extern f_status_t f_fss_simple_packets_append(const f_fss_simple_packet_t source, f_fss_simple_packets_t *destination);
+#endif // _di_f_fss_simple_packets_append_
+
+/**
+ * Append the source simple packet onto the destination.
+ *
+ * @param source
+ *   The source packets to append.
+ * @param destination
+ *   The destination simple packet the source is appended onto.
+ *
+ * @return
+ *   F_none on success.
+ *   F_data_not on success, but there is nothing to append (size == 0).
+ *
+ *   Success from f_memory_array_resize().
+ *
+ *   F_parameter (with error bit) if a parameter is invalid.
+ *
+ *   Errors (with error bit) from: f_memory_array_increase_by().
+ *   Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_increase_by()
+ * @see f_memory_array_resize()
+ */
+#ifndef _di_f_fss_simple_packets_append_all_
+  extern f_status_t f_fss_simple_packets_append_all(const f_fss_simple_packets_t source, f_fss_simple_packets_t *destination);
+#endif // _di_f_fss_simple_packets_append_all_
+
+/**
+ * Resize the simple packet array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to les than 0.
+ *
+ * @param amount
+ *   A positive number representing how much to decimate the size by.
+ * @param packets
+ *   The simple packet array to resize.
+ *
+ * @return
+ * @return
+ *   Success from f_memory_array_decimate_by().
+ *
+ *   F_parameter (with error bit) if a parameter is invalid.
+ *
+ *   Errors (with error bit) from: f_memory_array_decimate_by().
+ *
+ * @see f_memory_array_decimate_by()
+ */
+#ifndef _di_f_fss_simple_packets_decimate_by_
+  extern f_status_t f_fss_simple_packets_decimate_by(const f_number_unsigned_t amount, f_fss_simple_packets_t *packets);
+#endif // _di_f_fss_simple_packets_decimate_by_
+
+/**
+ * Resize the simple packet array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to les than 0.
+ *
+ * @param amount
+ *   A positive number representing how much to decrease the size by.
+ * @param packets
+ *   The simple packet array to resize.
+ *
+ * @return
+ *   Success from f_memory_array_decrease_by().
+ *
+ *   F_parameter (with error bit) if a parameter is invalid.
+ *
+ *   Errors (with error bit) from: f_memory_array_decrease_by().
+ *
+ * @see f_memory_array_decrease_by()
+ */
+#ifndef _di_f_fss_simple_packets_decrease_by_
+  extern f_status_t f_fss_simple_packets_decrease_by(const f_number_unsigned_t amount, f_fss_simple_packets_t *packets);
+#endif // _di_f_fss_simple_packets_decrease_by_
+
+/**
+ * Increase the size of the simple packet array, but only if necesary.
+ *
+ * If the given length is too large for the buffer, then attempt to packet max buffer size (F_number_t_size_unsigned_d).
+ * If already packet to the maximum buffer size, then the resize will fail.
+ *
+ * @param step
+ *   The allocation step to use.
+ *   Must be greater than 0.
+ * @param packets
+ *   The simple packet array to resize.
+ *
+ * @return
+ *   Success from f_memory_array_increase().
+ *
+ *   F_parameter (with error bit) if a parameter is invalid.
+ *
+ *   Errors (with error bit) from: f_memory_array_increase().
+ *
+ * @see f_memory_array_increase()
+ */
+#ifndef _di_f_fss_simple_packets_increase_
+  extern f_status_t f_fss_simple_packets_increase(const f_number_unsigned_t step, f_fss_simple_packets_t *packets);
+#endif // _di_f_fss_simple_packets_increase_
+
+/**
+ * Resize the simple packet array to a larger size.
+ *
+ * This will resize making the array larger based on the given length.
+ * If the given length is too large for the buffer, then attempt to packet max buffer size (F_number_t_size_unsigned_d).
+ * If already packet to the maximum buffer size, then the resize will fail.
+ *
+ * @param amount
+ *   A positive number representing how much to increase the size by.
+ * @param packets
+ *   The simple packet array to resize.
+ *
+ * @return
+ *   Success from f_memory_array_increase_by().
+ *
+ *   F_parameter (with error bit) if a parameter is invalid.
+ *
+ *   Errors (with error bit) from: f_memory_array_increase_by().
+ *
+ * @see f_memory_array_increase_by()
+ */
+#ifndef _di_f_fss_simple_packets_increase_by_
+  extern f_status_t f_fss_simple_packets_increase_by(const f_number_unsigned_t amount, f_fss_simple_packets_t *packets);
+#endif // _di_f_fss_simple_packets_increase_by_
+
+/**
+ * Resize the simple packet array.
+ *
+ * @param length
+ *   The new size to use.
+ * @param packets
+ *   The simple packet array to adjust.
+ *
+ * @return
+ *   Success from f_memory_array_resize().
+ *
+ *   F_parameter (with error bit) if a parameter is invalid.
+ *
+ *   Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_resize()
+ */
+#ifndef _di_f_fss_simple_packets_resize_
+  extern f_status_t f_fss_simple_packets_resize(const f_number_unsigned_t length, f_fss_simple_packets_t *packets);
+#endif // _di_f_fss_simple_packets_resize_
+
+/**
+ * Resize the simple packets array.
+ *
+ * @param length
+ *   The new size to use.
+ * @param packetss
+ *   The simple packets array to resize.
+ *
+ * @return
+ *   Success from f_memory_array_adjust().
+ *
+ *   F_parameter (with error bit) if a parameter is invalid.
+ *
+ *   Errors (with error bit) from: f_memory_array_adjust().
+ *
+ * @see f_memory_array_adjust()
+ */
+#ifndef _di_f_fss_simple_packetss_adjust_
+  extern f_status_t f_fss_simple_packetss_adjust(const f_number_unsigned_t length, f_fss_simple_packetss_t *packetss);
+#endif // _di_f_fss_simple_packetss_adjust_
+
+/**
+ * Append the single source simple packets onto the destination.
+ *
+ * @param source
+ *   The source simple packets to append.
+ * @param destination
+ *   The destination simple packets the source is appended onto.
+ *
+ * @return
+ *   F_none on success.
+ *   F_data_not on success, but there is nothing to append (size == 0).
+ *
+ *   Success from f_memory_array_resize().
+ *
+ *   F_parameter (with error bit) if a parameter is invalid.
+ *
+ *   Errors (with error bit) from: f_memory_array_increase_by().
+ *   Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_increase_by()
+ * @see f_memory_array_resize()
+ */
+#ifndef _di_f_fss_simple_packetss_append_
+  extern f_status_t f_fss_simple_packetss_append(const f_fss_simple_packets_t source, f_fss_simple_packetss_t *destination);
+#endif // _di_f_fss_simple_packetss_append_
+
+/**
+ * Append the source simple packets onto the destination.
+ *
+ * @param source
+ *   The source simple packets to append.
+ * @param destination
+ *   The destination simple packets the source is appended onto.
+ *
+ * @return
+ *   F_none on success.
+ *   F_data_not on success, but there is nothing to append (size == 0).
+ *
+ *   Success from f_memory_array_resize().
+ *
+ *   F_parameter (with error bit) if a parameter is invalid.
+ *
+ *   Errors (with error bit) from: f_memory_array_increase_by().
+ *   Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_increase_by()
+ * @see f_memory_array_resize()
+ */
+#ifndef _di_f_fss_simple_packetss_append_all_
+  extern f_status_t f_fss_simple_packetss_append_all(const f_fss_simple_packetss_t source, f_fss_simple_packetss_t *destination);
+#endif // _di_f_fss_simple_packetss_append_all_
+
+/**
+ * Resize the simple packets array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ *   A positive number representing how much to decimate the size by.
+ * @param packetss
+ *   The simple packets array to resize.
+ *
+ * @return
+ *   F_data_not on success, but the amount to decrease by is 0.
+ *
+ *   Success from f_memory_array_decimate_by().
+ *
+ *   F_parameter (with error bit) if a parameter is invalid.
+ *
+ *   Errors (with error bit) from: f_memory_array_decimate_by().
+ *
+ * @see f_memory_array_decimate_by()
+ */
+#ifndef _di_f_fss_simple_packetss_decimate_by_
+  extern f_status_t f_fss_simple_packetss_decimate_by(const f_number_unsigned_t amount, f_fss_simple_packetss_t *packetss);
+#endif // _di_f_fss_simple_packetss_decimate_by_
+
+/**
+ * Resize the simple packets array to a smaller size.
+ *
+ * This will resize making the array smaller based on (size - given length).
+ * If the given length is too small, then the resize will fail.
+ * This will not shrink the size to less than 0.
+ *
+ * @param amount
+ *   A positive number representing how much to decrease the size by.
+ * @param packetss
+ *   The simple packets array to resize.
+ *
+ * @return
+ *   F_data_not on success, but the amount to decrease by is 0.
+ *
+ *   Success from f_memory_array_decrease_by().
+ *
+ *   F_parameter (with error bit) if a parameter is invalid.
+ *
+ *   Errors (with error bit) from: f_memory_array_decrease_by().
+ *
+ * @see f_memory_array_decrease_by()
+ */
+#ifndef _di_f_fss_simple_packetss_decrease_by_
+  extern f_status_t f_fss_simple_packetss_decrease_by(const f_number_unsigned_t amount, f_fss_simple_packetss_t *packetss);
+#endif // _di_f_fss_simple_packetss_decrease_by_
+
+/**
+ * Increase the size of the simple packets array, but only if necessary.
+ *
+ * If the given length is too large for the buffer, then attempt to packet max buffer size (F_number_t_size_unsigned_d).
+ * If already packet to the maximum buffer size, then the resize will fail.
+ *
+ * @param step
+ *   The allocation step to use.
+ *   Must be greater than 0.
+ * @param packetss
+ *   The simple packets array to resize.
+ *
+ * @return
+ *   Success from f_memory_array_increase().
+ *
+ *   F_parameter (with error bit) if a parameter is invalid.
+ *
+ *   Errors (with error bit) from: f_memory_array_increase().
+ *
+ * @see f_memory_array_increase()
+ */
+#ifndef _di_f_fss_simple_packetss_increase_
+  extern f_status_t f_fss_simple_packetss_increase(const f_number_unsigned_t step, f_fss_simple_packetss_t *packetss);
+#endif // _di_f_fss_simple_packetss_increase_
+
+/**
+ * Resize the simple packets array to a larger size.
+ *
+ * This will resize making the array larger based on the given length.
+ * If the given length is too large for the buffer, then attempt to packet max buffer size (F_number_t_size_unsigned_d).
+ * If already packet to the maximum buffer size, then the resize will fail.
+ *
+ * @param amount
+ *   A positive number representing how much to increase the size by.
+ * @param packetss
+ *   The simple packets array to resize.
+ *
+ * @return
+ *   Success from f_memory_array_increase_by().
+ *
+ *   F_parameter (with error bit) if a parameter is invalid.
+ *
+ *   Errors (with error bit) from: f_memory_array_increase_by().
+ *
+ * @see f_memory_array_increase_by()
+ */
+#ifndef _di_f_fss_simple_packetss_increase_by_
+  extern f_status_t f_fss_simple_packetss_increase_by(const f_number_unsigned_t amount, f_fss_simple_packetss_t *packetss);
+#endif // _di_f_fss_simple_packetss_increase_by_
+
+/**
+ * Resize the simple packets array.
+ *
+ * @param length
+ *   The new size to use.
+ * @param packetss
+ *   The simple packets array to resize.
+ *
+ * @return
+ *   Success from f_memory_array_resize().
+ *
+ *   F_parameter (with error bit) if a parameter is invalid.
+ *
+ *   Errors (with error bit) from: f_memory_array_resize().
+ *
+ * @see f_memory_array_resize()
+ */
+#ifndef _di_f_fss_simple_packetss_resize_
+  extern f_status_t f_fss_simple_packetss_resize(const f_number_unsigned_t length, f_fss_simple_packetss_t *packetss);
+#endif // _di_f_fss_simple_packetss_resize_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif