]> Kevux Git Server - fll/commitdiff
Update: add fll fss object and content write support
authorKevin Day <kevin@kevux.org>
Fri, 30 Mar 2012 16:24:20 +0000 (11:24 -0500)
committerKevin Day <kevin@kevux.org>
Fri, 30 Mar 2012 16:24:20 +0000 (11:24 -0500)
This adds the functions that allow for writing fss objects and contents.

level_2/fll_fss/c/fss_basic.c
level_2/fll_fss/c/fss_basic.h
level_2/fll_fss/c/fss_basic_list.c
level_2/fll_fss/c/fss_basic_list.h
level_2/fll_fss/c/fss_extended.c
level_2/fll_fss/c/fss_extended.h

index 4cc2d52e589d3e544d7ef43ac568f8707508a14b..38adae2a30103063b1c58f554b74eba45bde4ce2 100644 (file)
@@ -118,6 +118,50 @@ extern "C"{
   }
 #endif // _di_fll_fss_basic_read_
 
+#ifndef _di_fll_fss_basic_write_
+  f_return_status fll_fss_basic_write(const f_dynamic_string object, const f_dynamic_strings contents, f_dynamic_string *buffer) {
+    #ifndef _di_level_2_parameter_checking_
+      if (buffer        == f_null)        return f_invalid_parameter;
+      if (contents.used  > contents.size) return f_invalid_parameter;
+    #endif // _di_level_2_parameter_checking_
+
+    f_status          status   = 0;
+    f_array_length    current  = 0;
+    f_string_location location = f_string_location_initialize;
+
+    location.start = 0;
+    location.stop = object.used - 1;
+
+    status = fl_fss_basic_object_write(object, &location, buffer);
+
+    if (f_macro_test_for_no_data_errors(status)) {
+      return status;
+    }
+
+    if (f_macro_test_for_none_errors(status)) {
+      if (contents.used > 0) {
+        location.start = 0;
+        location.stop = contents.array[0].used - 1;
+        status = fl_fss_basic_content_write(contents.array[0], &location, buffer);
+
+        if (f_macro_test_for_no_data_errors(status)) {
+          return status;
+        }
+      } else {
+        if (buffer->used >= buffer->size) {
+          f_resize_dynamic_string(status, (*buffer), buffer->size + f_fss_default_allocation_step);
+          if (f_macro_test_for_allocation_errors(status)) return status;
+        }
+
+        buffer->string[buffer->used] = f_eol;
+        buffer->used++;
+      }
+    }
+
+    return f_none;
+  }
+#endif // _di_fll_fss_basic_write_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index d879655f8737c27160114c805311a71f7c3b199d..6924728de8ab49d5efcbb1edf045b1aa66d97b25 100644 (file)
@@ -32,6 +32,11 @@ extern "C"{
   extern f_return_status fll_fss_basic_read(f_dynamic_string *buffer, f_string_location *input, f_fss_objects *objects, f_fss_contents *contents);
 #endif // _di_fll_fss_basic_read_
 
+#ifndef _di_fll_fss_basic_write_
+  // write an fss-0000 object and then content
+  extern f_return_status fll_fss_basic_write(const f_dynamic_string object, const f_dynamic_strings contents, f_dynamic_string *buffer);
+#endif // _di_fll_fss_basic_write_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index 93c76c419dbf61090a25bbc09ba2d0857495beba..50688c1cbc2a77c59e960fb63bb69e04f4056dcf 100644 (file)
@@ -118,6 +118,50 @@ extern "C"{
   }
 #endif // _di_fll_fss_basic_list_read_
 
+#ifndef _di_fll_fss_basic_list_write_
+  f_return_status fll_fss_basic_list_write(const f_dynamic_string object, const f_dynamic_strings contents, f_dynamic_string *buffer) {
+    #ifndef _di_level_2_parameter_checking_
+      if (buffer        == f_null)        return f_invalid_parameter;
+      if (contents.used  > contents.size) return f_invalid_parameter;
+    #endif // _di_level_2_parameter_checking_
+
+    f_status          status   = 0;
+    f_array_length    current  = 0;
+    f_string_location location = f_string_location_initialize;
+
+    location.start = 0;
+    location.stop = object.used - 1;
+
+    status = fl_fss_basic_list_object_write(object, &location, buffer);
+
+    if (f_macro_test_for_no_data_errors(status)) {
+      return status;
+    }
+
+    if (f_macro_test_for_none_errors(status)) {
+      if (contents.used > 0) {
+        location.start = 0;
+        location.stop = contents.array[0].used - 1;
+        status = fl_fss_basic_list_content_write(contents.array[0], &location, buffer);
+
+        if (f_macro_test_for_no_data_errors(status)) {
+          return status;
+        }
+      } else {
+        if (buffer->used >= buffer->size) {
+          f_resize_dynamic_string(status, (*buffer), buffer->size + f_fss_default_allocation_step);
+          if (f_macro_test_for_allocation_errors(status)) return status;
+        }
+
+        buffer->string[buffer->used] = f_eol;
+        buffer->used++;
+      }
+    }
+
+    return f_none;
+  }
+#endif // _di_fll_fss_basic_list_write_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index cfe1fe6cbd6685262070d730f3ef77138016c62a..f99ec3d1bf33a7396515a116f687e2c976e20422 100644 (file)
@@ -32,6 +32,11 @@ extern "C"{
   extern f_return_status fll_fss_basic_list_read(f_dynamic_string *buffer, f_string_location *input, f_fss_objects *objects, f_fss_contents *contents);
 #endif // _di_fll_fss_basic_list_read_
 
+#ifndef _di_fll_fss_basic_list_write_
+  // write an fss-0000 object and then content
+  extern f_return_status fll_fss_basic_list_write(const f_dynamic_string object, const f_dynamic_strings contents, f_dynamic_string *buffer);
+#endif // _di_fll_fss_basic_list_write_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index 7fb209e14ba936ef5a55e82dcbf3e9a6c903b032..8792e0d484261021333d9235a9fa4217648e1297 100644 (file)
@@ -118,6 +118,47 @@ extern "C"{
   }
 #endif // _di_fll_fss_extended_read_
 
+#ifndef _di_fll_fss_extended_write_
+  f_return_status fll_fss_extended_write(const f_dynamic_string object, const f_dynamic_strings contents, f_dynamic_string *buffer) {
+    #ifndef _di_level_2_parameter_checking_
+      if (buffer        == f_null)        return f_invalid_parameter;
+      if (contents.used  > contents.size) return f_invalid_parameter;
+    #endif // _di_level_2_parameter_checking_
+
+    f_status          status   = 0;
+    f_array_length    current  = 0;
+    f_string_location location = f_string_location_initialize;
+
+    location.start = 0;
+    location.stop = object.used - 1;
+
+    status = fl_fss_extended_object_write(object, &location, buffer);
+
+    if (f_macro_test_for_no_data_errors(status)) {
+      return status;
+    }
+
+    if (f_macro_test_for_none_errors(status)) {
+      while (current < contents.used) {
+        location.start = 0;
+        location.stop = contents.array[current].used - 1;
+        status = fl_fss_extended_content_write(contents.array[current], &location, buffer);
+
+        if (f_macro_test_for_no_data_errors(status)) {
+          return status;
+        }
+
+        current++;
+      } // while
+
+      // extended always ends each call with a space, and so the last position should be replaced with an eol.
+      buffer->string[buffer->used - 1] = f_eol;
+    }
+
+    return f_none;
+  }
+#endif // _di_fll_fss_extended_write_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif
index 5ad469a305a9a7402b3b33d4d105acac2f2cef45..c97ae7ad3ddc6357bcaeab5e9d911e45f9367643 100644 (file)
@@ -32,6 +32,11 @@ extern "C"{
   extern f_return_status fll_fss_extended_read(f_dynamic_string *buffer, f_string_location *input, f_fss_objects *objects, f_fss_contents *contents);
 #endif // _di_fll_fss_extended_read_
 
+#ifndef _di_fll_fss_extended_write_
+  // write an fss-0000 object and then content
+  extern f_return_status fll_fss_extended_write(const f_dynamic_string object, const f_dynamic_strings contents, f_dynamic_string *buffer);
+#endif // _di_fll_fss_extended_write_
+
 #ifdef __cplusplus
 } // extern "C"
 #endif