]> Kevux Git Server - fll/commitdiff
Bugfix: actually finish implementing delimit changes.
authorKevin Day <thekevinday@gmail.com>
Wed, 21 Oct 2020 23:30:45 +0000 (18:30 -0500)
committerKevin Day <thekevinday@gmail.com>
Wed, 21 Oct 2020 23:30:45 +0000 (18:30 -0500)
It seems that I forgot to check the other programs and update them to work with the new delimit handling behavior in the appropriate FSS processing functions.

level_3/fake/c/private-build.c
level_3/fake/c/private-make.c
level_3/firewall/c/private-firewall.c
level_3/fss_basic_list_read/c/private-fss_basic_list_read.c
level_3/fss_basic_read/c/private-fss_basic_read.c
level_3/fss_extended_list_read/c/private-fss_extended_list_read.c
level_3/fss_extended_read/c/private-fss_extended_read.c
level_3/init/c/private-init.c

index 4d1f06abfb3b115abf90e5f01671da68c18a539e..d4f77828d803e2a967fa58a195568cece519b1c9 100644 (file)
@@ -1309,15 +1309,25 @@ extern "C" {
       }
       else if (F_status_is_error_not(*status)) {
         f_string_range_t range = f_macro_string_range_t_initialize(buffer.used);
+        f_fss_delimits_t delimits = f_fss_delimits_t_initialize;
 
-        *status = fll_fss_extended_read(&buffer, &range, &objects, &contents, 0, 0);
+        *status = fll_fss_extended_read(&buffer, &range, &objects, &contents, 0, 0, &delimits);
 
         if (F_status_is_error(*status)) {
           fake_print_error_fss(data, F_status_set_fine(*status), "fll_fss_extended_read", data.file_data_build_settings.string, range, F_true);
         }
         else {
-          fake_build_load_setting_process(data, setting_file.used ? path_file : data.file_data_build_settings.string, buffer, objects, contents, setting, status);
+          *status = fl_fss_apply_delimit(delimits, &buffer);
+
+          if (F_status_is_error(*status)) {
+            fll_error_print(data.error, F_status_set_fine(*status), "fl_fss_apply_delimit", F_true);
+          }
+          else {
+            fake_build_load_setting_process(data, setting_file.used ? path_file : data.file_data_build_settings.string, buffer, objects, contents, setting, status);
+          }
         }
+
+        f_macro_fss_delimits_t_delete_simple(delimits);
       }
 
       f_macro_string_dynamic_t_delete_simple(buffer);
index b5b0f8bc80f6c6d46ce2cf2151a7bba990a6ed7a..1777c038778da0717d23398e65ae99884d9c22df 100644 (file)
@@ -203,12 +203,25 @@ extern "C" {
 
     {
       f_string_range_t range = f_macro_string_range_t_initialize(data_make->buffer.used);
+      f_fss_delimits_t delimits = f_fss_delimits_t_initialize;
 
-      *status = fll_fss_basic_list_read(&data_make->buffer, &range, &list_objects, &list_contents);
+      *status = fll_fss_basic_list_read(&data_make->buffer, &range, &list_objects, &list_contents, &delimits);
 
       if (F_status_is_error(*status)) {
         fake_print_error_fss(data, *status, "fll_fss_basic_list_read", data.file_data_build_fakefile.string, range, F_true);
 
+        f_macro_fss_delimits_t_delete_simple(delimits);
+        f_macro_fss_objects_t_delete_simple(list_objects);
+        f_macro_fss_contents_t_delete_simple(list_contents);
+        return;
+      }
+
+      *status = fl_fss_apply_delimit(delimits, &data_make->buffer);
+
+      if (F_status_is_error(*status)) {
+        fll_error_print(data.error, F_status_set_fine(*status), "fl_fss_apply_delimit", F_true);
+
+        f_macro_fss_delimits_t_delete_simple(delimits);
         f_macro_fss_objects_t_delete_simple(list_objects);
         f_macro_fss_contents_t_delete_simple(list_contents);
         return;
@@ -240,6 +253,7 @@ extern "C" {
 
       {
         f_string_range_t content_range = f_string_range_t_initialize;
+        f_fss_delimits_t delimits = f_fss_delimits_t_initialize;
 
         for (f_array_length_t i = 0; i < list_objects.used; i++) {
 
@@ -249,18 +263,26 @@ extern "C" {
           }
 
           if (fl_string_dynamic_partial_compare(name_settings, data_make->buffer, name_settings_range, list_objects.array[i]) == F_equal_to) {
+
             if (!missing_settings) {
               fake_print_warning_settings_object_multiple(data, data.file_data_build_fakefile.string, "list", name_settings.string);
               continue;
             }
 
+            delimits.used = 0;
             content_range = list_contents.array[i].array[0];
 
-            *status = fll_fss_extended_read(&data_make->buffer, &content_range, &settings.objects, &settings.contents, 0, 0);
+            *status = fll_fss_extended_read(&data_make->buffer, &content_range, &settings.objects, &settings.contents, 0, 0, &delimits);
 
             if (F_status_is_error(*status)) {
               fake_print_error_fss(data, F_status_set_fine(*status), "fll_fss_extended_read", data.file_data_build_fakefile.string, content_range, F_true);
+              break;
+            }
+
+            *status = fl_fss_apply_delimit(delimits, &data_make->buffer);
 
+            if (F_status_is_error(*status)) {
+              fll_error_print(data.error, F_status_set_fine(*status), "fl_fss_apply_delimit", F_true);
               break;
             }
 
@@ -279,18 +301,27 @@ extern "C" {
 
           data_make->fakefile.array[data_make->fakefile.used].name = list_objects.array[i];
 
+          delimits.used = 0;
           content_range = list_contents.array[i].array[0];
 
-          *status = fll_fss_extended_read(&data_make->buffer, &content_range, &data_make->fakefile.array[data_make->fakefile.used].objects, &data_make->fakefile.array[data_make->fakefile.used].contents, 0, &data_make->fakefile.array[data_make->fakefile.used].quotess);
+          *status = fll_fss_extended_read(&data_make->buffer, &content_range, &data_make->fakefile.array[data_make->fakefile.used].objects, &data_make->fakefile.array[data_make->fakefile.used].contents, 0, &data_make->fakefile.array[data_make->fakefile.used].quotess, &delimits);
 
           if (F_status_is_error(*status)) {
             fake_print_error_fss(data, F_status_set_fine(*status), "fll_fss_extended_read", data.file_data_build_fakefile.string, content_range, F_true);
+            break;
+          }
+
+          *status = fl_fss_apply_delimit(delimits, &data_make->buffer);
 
+          if (F_status_is_error(*status)) {
+            fll_error_print(data.error, F_status_set_fine(*status), "fl_fss_apply_delimit", F_true);
             break;
           }
 
           data_make->fakefile.used++;
         } // for
+
+        f_macro_fss_delimits_t_delete_simple(delimits);
       }
 
       f_macro_fss_objects_t_delete_simple(list_objects);
index 338c40be26e5b57d0925f801c3f75efd3c4de045..2883d7dddf7ca063ba805a5b18ec39e198031a0b 100644 (file)
@@ -646,12 +646,12 @@ f_return_status firewall_perform_commands(const firewall_local_data_t local, con
               status = F_status_set_error(status);
             }
             else {
-              {
-                f_string_range_t input = f_string_range_t_initialize;
+              f_fss_delimits_t delimits = f_fss_delimits_t_initialize;
 
-                input.stop = local_buffer.used - 1;
+              {
+                f_string_range_t input = f_macro_string_range_t_initialize(local_buffer.used);
 
-                status = fll_fss_basic_read(&local_buffer, &input, &basic_objects, &basic_contents, 0);
+                status = fll_fss_basic_read(&local_buffer, &input, &basic_objects, &basic_contents, 0, &delimits);
               }
 
               if (F_status_set_error(status)) {
@@ -672,7 +672,16 @@ f_return_status firewall_perform_commands(const firewall_local_data_t local, con
 
                 status = F_status_set_error(status);
               }
-              else {
+
+              if (F_status_is_error_not(status)) {
+                status = fl_fss_apply_delimit(delimits, &local_buffer);
+
+                if (F_status_is_error(status)) {
+                  fll_error_print(data.error, F_status_set_fine(status), "fl_fss_apply_delimit", F_true);
+                }
+              }
+
+              if (F_status_is_error_not(status)) {
                 f_string_length_t buffer_counter = 0;
                 f_string_length_t ip_length = 0;
                 f_string_dynamic_t ip_list_action = f_string_dynamic_t_initialize;
@@ -787,6 +796,8 @@ f_return_status firewall_perform_commands(const firewall_local_data_t local, con
                   arguments.used--;
                 }
               }
+
+              f_macro_fss_delimits_t_delete_simple(delimits);
             }
           }
 
@@ -1316,9 +1327,8 @@ f_return_status firewall_default_lock(const firewall_data_t data) {
 
 f_return_status firewall_buffer_rules(const f_string_t filename, const bool optional, firewall_local_data_t *local, firewall_data_t *data) {
   f_file_t file = f_file_t_initialize;
-  f_status_t status = F_none;
 
-  status = f_file_open(filename, 0, &file);
+  f_status_t status = f_file_open(filename, 0, &file);
 
   if (F_status_is_error(status)) {
     status = F_status_set_fine(status);
@@ -1382,12 +1392,13 @@ f_return_status firewall_buffer_rules(const f_string_t filename, const bool opti
 
     return status;
   }
-  else {
-    f_string_range_t input = f_string_range_t_initialize;
 
-    input.stop = local->buffer.used - 1;
+  f_fss_delimits_t delimits = f_fss_delimits_t_initialize;
+
+  {
+    f_string_range_t input = f_macro_string_range_t_initialize(local->buffer.used);
 
-    status = fll_fss_basic_list_read(&local->buffer, &input, &local->chain_objects, &local->chain_contents);
+    status = fll_fss_basic_list_read(&local->buffer, &input, &local->chain_objects, &local->chain_contents, &delimits);
   }
 
   if (F_status_is_error(status)) {
@@ -1405,17 +1416,34 @@ f_return_status firewall_buffer_rules(const f_string_t filename, const bool opti
     else {
       fl_color_print(data->error.to.stream, data->context.set.error, "%sAn unhandled error (%u) has occurred while calling fll_fss_basic_list_read() for the file '%s'.%c", fll_error_print_error, status, filename, f_string_eol[0]);
     }
+  }
+  else {
+    status = fl_fss_apply_delimit(delimits, &local->buffer);
 
-    return status;
+    if (F_status_is_error(status)) {
+      fll_error_print(data->error, F_status_set_fine(status), "fl_fss_apply_delimit", F_true);
+    }
   }
 
+  f_macro_fss_delimits_t_delete_simple(delimits);
+
   return status;
 }
 
 f_return_status firewall_process_rules(f_string_range_t *range, firewall_local_data_t *local, firewall_data_t *data) {
-  f_status_t status = F_none;
+  f_fss_delimits_t delimits = f_fss_delimits_t_initialize;
+
+  f_status_t status = fll_fss_extended_read(&local->buffer, range, &local->rule_objects, &local->rule_contents, 0, 0, &delimits);
+
+  if (F_status_is_error_not(status)) {
+    status = fl_fss_apply_delimit(delimits, &local->buffer);
+
+    if (F_status_is_error(status)) {
+      fll_error_print(data->error, F_status_set_fine(status), "fl_fss_apply_delimit", F_true);
+    }
+  }
 
-  status = fll_fss_extended_read(&local->buffer, range, &local->rule_objects, &local->rule_contents, 0, 0);
+  f_macro_fss_delimits_t_delete_simple(delimits);
 
   if (F_status_is_error_not(status)) {
     status = firewall_perform_commands(*local, *data);
index b490854c0057af4e0732a8b7c24664f82a15471e..fb6b11576afeb89ecdcbf1f7111c1b08fa1983b7 100644 (file)
@@ -174,10 +174,7 @@ extern "C" {
     f_status_t status = F_none;
 
     {
-      f_string_range_t input = f_string_range_t_initialize;
-
-      input.start = 0;
-      input.stop = data->buffer.used - 1;
+      f_string_range_t input = f_macro_string_range_t_initialize(data->buffer.used);
 
       delimits->used = 0;
 
index 3a9ac0705639646da64889f5dec65a19c97605d1..e7a08b4d95ec5597f3a860629c82fcf3f2e18908 100644 (file)
@@ -174,10 +174,7 @@ extern "C" {
     f_status_t status = F_none;
 
     {
-      f_string_range_t input = f_string_range_t_initialize;
-
-      input.start = 0;
-      input.stop = data->buffer.used - 1;
+      f_string_range_t input = f_macro_string_range_t_initialize(data->buffer.used);
 
       delimits->used = 0;
 
index 1e2c3c08d0a753894f2aae027539e5b2a5e71ff4..a91fa91e0a04305a9076906131072a8f7d728873 100644 (file)
@@ -174,10 +174,7 @@ extern "C" {
     f_status_t status = F_none;
 
     {
-      f_string_range_t input = f_string_range_t_initialize;
-
-      input.start = 0;
-      input.stop = data->buffer.used - 1;
+      f_string_range_t input = f_macro_string_range_t_initialize(data->buffer.used);
 
       delimits->used = 0;
 
index d333dea16e972a994f04b153342cf501bc73af87..8116cf72f132cfdb5ec89da8c136455a1e2d7bbf 100644 (file)
@@ -174,10 +174,7 @@ extern "C" {
     f_status_t status = F_none;
 
     {
-      f_string_range_t input = f_string_range_t_initialize;
-
-      input.start = 0;
-      input.stop = data->buffer.used - 1;
+      f_string_range_t input = f_macro_string_range_t_initialize(data->buffer.used);
 
       delimits->used = 0;
 
index eea8c534a9639452ee36a3cbd244c92ff5c31f1d..738c77a885ba88e2a6b90b23d5ceab7d74038da2 100644 (file)
       }
 
       return F_status_set_error(status);
-    } else {
-      f_string_range_t input = f_string_range_t_initialize;
+    }
+
+    f_fss_delimits_t delimits = f_fss_delimits_t_initialize;
 
-      input.stop = buffer->used - 1;
+    {
+      f_string_range_t input = f_macro_string_range_t_initialize(buffer->used);
 
-      status = fll_fss_basic_list_read(buffer, &input, objects, contents);
+      status = fll_fss_basic_list_read(buffer, &input, objects, contents, &delimits);
     }
 
     if (F_status_is_error(status)) {
         fl_color_print(data.error.to.stream, data.context.set.error, "%sAn unhandled error (%u) has occurred while calling fll_fss_basic_list_read() for the file '%s'.%c", fll_error_print_error, status, filename, f_string_eol[0]);
       }
 
+      f_macro_fss_delimits_t_delete_simple(delimits);
+
       return F_status_set_error(status);
     }
+    else {
+      *status = fl_fss_apply_delimit(delimits, &buffer);
+
+      if (F_status_is_error(*status)) {
+        fll_error_print(data.error, F_status_set_fine(*status), "fl_fss_apply_delimit", F_true);
+      }
+    }
+
+    f_macro_fss_delimits_t_delete_simple(delimits);
 
     return status;
   }
 #ifndef _di_init_rules_process_main_
   f_return_status init_rules_process_main(const init_data_t data, const f_string_t filename, f_string_dynamic_t *buffer, f_fss_objects_t *objects, f_fss_contents_t *contents) {
     f_status_t status  = F_none;
+    f_fss_delimits_t delimits = f_fss_delimits_t_initialize;
 
     // @todo: resume replacing code below.
-    status = fll_fss_extended_read(&buffer, input, &local->rule_objects, &local->rule_contents, 0, 0);
+    status = fll_fss_extended_read(&buffer, input, &local->rule_objects, &local->rule_contents, 0, 0, &delimits);
+
+    if (F_status_is_error_not(*status)) {
+      status = fl_fss_apply_delimit(delimits, &buffer);
+    }
+
+    f_macro_fss_delimits_t_delete_simple(delimits);
 
     if (F_status_is_error_not(status)) {
       //status = init_perform_commands(*local, *data); // @fixme
 
       if (F_status_is_error(status)) {
-        status = F_status_set_fine(status);
-
-        if (status == F_memory_allocation || status == F_memory_reallocation) {
+        if (F_status_set_fine(status) == F_memory_allocation || F_status_set_fine(status) == F_memory_reallocation) {
           fl_color_print(data.error.to.stream, data.context.set.error, "%sUnable to allocate memory.", fll_error_print_error);
-        } else if (status == F_failure) {
+        } else if (F_status_set_fine(status) == F_failure) {
           // the error message has already been displayed.
         } else {
           fl_color_print(data.error.to.stream, data.context.set.error, "%sAn unhandled error (%u) has occurred while calling firewall_perform_commands().", fll_error_print_error, status);
         }
-
-        f_macro_fss_objects_t_delete_simple(local->rule_objects);
-        f_macro_fss_contents_t_delete_simple(local->rule_contents);
-        return F_status_set_error(status);
       }
     }
 
     f_fss_objects_t objects = f_fss_objects_t_initialize;
     f_fss_contents_t contents = f_fss_contents_t_initialize;
     f_string_length_t position = 0;
+    f_fss_delimits_t delimits = f_fss_delimits_t_initialize;
 
     // load the main file into memory.
     status = init_rule_buffer(&data, init_rule_core_file, &buffer, &objects, &contents);
       f_macro_string_dynamic_t_delete(buffer);
       f_macro_fss_objects_t_delete(objects);
       f_macro_fss_contents_t_delete(contents);
+      f_macro_fss_delimits_t_delete_simple(delimits);
       return status;
     }
 
     while (position < objects.used) {
       location.start = objects.array[position].start;
       location.stop = objects.array[position].stop;
+      delimits.used = 0;
 
-      status = fll_fss_extended_read(&buffer, &location, &objects, &contents, 0, 0);
+      status = fll_fss_extended_read(&buffer, &location, &objects, &contents, 0, 0, &delimits);
+
+      if (F_status_is_error_not(*status)) {
+        status = fl_fss_apply_delimit(delimits, &buffer);
+      }
 
       position++;
     } // while
     // @fixme: resume here, below is just notes and copy&pasted code as examples/reminders.
 
     /*
-    status = fll_fss_extended_read(&buffer, &location, &objects, &contents, 0, 0);
+    delimits.used = 0;
+
+    status = fll_fss_extended_read(&buffer, &location, &objects, &contents, 0, 0, &delimits);
+
+    if (F_status_is_error_not(status)) {
+      status = fl_fss_apply_delimit(delimits, &buffer);
+    }
 
     if (F_status_is_error(status_process)) {
       if (status == F_memory_allocation || status == F_memory_reallocation) {
 
       // @todo: init_delete_data((*data));
       // @todo: init_delete_stack_memory(&stack_memory);
+      f_macro_fss_delimits_t_delete_simple(delimits);
+
       return status_process;
     }
     */
 
     /*
     f_status_t status  = F_none;
+    delimits.used = 0;
 
-    status = fll_fss_extended_read(buffer, location, objects, contents, 0, 0);
+    status = fll_fss_extended_read(buffer, location, objects, contents, 0, 0, &delimits);
+
+    if (F_status_is_error_not(status)) {
+      status = fl_fss_apply_delimit(delimits, &buffer);
+    }
+
+    if (F_status_is_error(*status)) {
+      fll_error_print(data.error, F_status_set_fine(*status), "fl_fss_apply_delimit", F_true);
+    }
 
     if (F_status_is_error_not(status)) {
       // @todo: process objects and contents.
 
         f_macro_fss_objects_t_delete_simple((*rule_objects));
         f_macro_fss_contents_t_delete_simple((*rule_contents));
+        f_macro_fss_delimits_t_delete_simple(delimits);
         return F_status_set_error(status);
       }
     }
     f_macro_fss_contents_t_delete_simple((*rule_contents));
     */
 /*
+    f_macro_fss_delimits_t_delete_simple(delimits);
     f_macro_string_dynamic_t_delete(buffer);
     f_macro_fss_objects_t_delete(objects);
     f_macro_fss_contents_t_delete(contents);