]> Kevux Git Server - kevux-tools/commitdiff
Update: With the latest 0.7.x time code and other changes.
authorKevin Day <Kevin@kevux.org>
Mon, 5 Aug 2024 01:41:50 +0000 (20:41 -0500)
committerKevin Day <Kevin@kevux.org>
Mon, 5 Aug 2024 01:41:50 +0000 (20:41 -0500)
data/build/stand_alone/configs/remove-config.h
data/build/stand_alone/configs/tacocat-config.h
sources/c/program/kevux/tools/remove/main/convert.c
sources/c/program/kevux/tools/remove/main/operate.c
sources/c/program/kevux/tools/remove/main/print/simulate.c
sources/c/program/kevux/tools/tacocat/main/process.c
sources/c/program/kevux/tools/tacocat/main/tacocat.c

index edad0ad312b015a240bc73c5d03b6e0a5b14fe9c..a0b271d176490fb95d0d6fa85dd3d11d52eda381 100644 (file)
 //#define _di_f_memory_default_d_
 //#define _di_f_memory_delete_
 #define _di_f_memory_destroy_
+//#define _di_f_memory_increase_step_d_
 //#define _di_f_memory_new_
 #define _di_f_memory_new_aligned_
 //#define _di_f_memory_resize_
 #define _di_f_thread_unlock_
 #define _di_f_time_calendar_string_
 #define _di_f_time_calendar_string_part_
-#define _di_f_time_clock_get_
+//#define _di_f_time_clock_get_
 #define _di_f_time_clock_precision_
 #define _di_f_time_clock_set_
 #define _di_f_time_d_
 #define _di_f_time_of_day_set_
 #define _di_f_time_part_t_
 #define _di_f_time_simple_t_
-#define _di_f_time_sleep_spec_
+//#define _di_f_time_sleep_spec_
 #define _di_f_time_spec_millisecond_
 #define _di_f_time_spec_nanosecond_
-#define _di_f_time_spec_t_
+//#define _di_f_time_spec_t_
 //#define _di_f_time_t_
 #define _di_f_time_utc_get_
 #define _di_f_time_value_t_
index 8d68904597007c16867caa9e04838ed4bb9fe693..18e494436ba265c864fa92ff666e7eed0d3fc666 100644 (file)
 //#define _di_f_memory_default_d_
 //#define _di_f_memory_delete_
 #define _di_f_memory_destroy_
+//#define _di_f_memory_increase_step_d_
 //#define _di_f_memory_new_
 #define _di_f_memory_new_aligned_
 //#define _di_f_memory_resize_
 #define _di_f_time_of_day_set_
 #define _di_f_time_part_t_
 #define _di_f_time_simple_t_
-#define _di_f_time_sleep_spec_
+//#define _di_f_time_sleep_spec_
 //#define _di_f_time_spec_millisecond_
 #define _di_f_time_spec_nanosecond_
 //#define _di_f_time_spec_t_
index c5ecacc2fc0e432809aaf8caf4de8b783b2adaf1..64d1c42e6bbeff858fc9fb09d79d005bc1d5a2e5 100644 (file)
@@ -218,32 +218,12 @@ extern "C" {
           date->type |= kt_remove_flag_date_time_epoch_d;
         }
         else {
-          struct timespec now;
-          int result = 0;
-
-          memset(&now, 0, sizeof(struct timespec));
-
-          // The current year is used for single colon when no year is specified.
-          {
-            result = clock_gettime(CLOCK_REALTIME, &now);
-
-            if (!result) {
-              if (result == EFAULT) {
-                 main->setting.state.status = F_status_set_error(F_buffer);
-              }
-              else if (result == EINVAL) {
-                main->setting.state.status = F_status_set_error(F_parameter);
-              }
-              else if (result == EPERM) {
-                main->setting.state.status = F_status_set_error(F_prohibited);
-              }
-              else {
-                main->setting.state.status = F_status_set_error(F_failure);
-              }
+          f_time_spec_t now;
 
-              return;
-            }
-          }
+          memset(&now, 0, sizeof(f_time_spec_t));
+
+          main->setting.state.status = f_time_clock_get(CLOCK_REALTIME, &now);
+          if (F_status_is_error(main->setting.state.status)) return;
 
           date->start_year = now.tv_sec / kt_remove_time_seconds_in_year_d;
           date->type |= kt_remove_flag_date_time_d;
@@ -382,26 +362,12 @@ extern "C" {
       return;
     }
 
-    struct timespec now;
-
-    memset(&now, 0, sizeof(struct timespec));
+    f_time_spec_t now;
 
-    if (clock_gettime(CLOCK_REALTIME, &now)) {
-      if (errno == EFAULT) {
-         main->setting.state.status = F_status_set_error(F_buffer);
-      }
-      else if (errno == EINVAL) {
-        main->setting.state.status = F_status_set_error(F_parameter);
-      }
-      else if (errno == EPERM) {
-        main->setting.state.status = F_status_set_error(F_prohibited);
-      }
-      else {
-        main->setting.state.status = F_status_set_error(F_failure);
-      }
+    memset(&now, 0, sizeof(f_time_spec_t));
 
-      return;
-    }
+    main->setting.state.status = f_time_clock_get(CLOCK_REALTIME, &now);
+    if (F_status_is_error(main->setting.state.status)) return;
 
     date->start_year = kt_remove_time_year_unix_epoch_d;
     date->start_second = now.tv_sec;
index 0ad2474a492d1bbd03bbef7389a623ec2c0b8a40..2f93405238e951a3cf93276035b464f08271adbb 100644 (file)
@@ -108,9 +108,9 @@ extern "C" {
       const uint8_t flag = kt_remove_operate_file_simulate(main, name);
       if (F_status_is_error(main->setting.state.status)) return;
 
-      // @todo needs empty check to see if directory contents are fully removed (because of removal conditions).
-
       if (!(main->setting.flag & kt_remove_main_flag_simulate_d)) {
+        // @todo needs empty check to see if directory contents are fully removed (because of removal conditions).
+
         if (flag & kt_remove_flag_file_operate_directory_d) {
           kt_remove_operate_file_directory(main, name, flag);
           if (F_status_is_error(main->setting.state.status)) return;
index 14333779d73e9991b9ae4fe3657a368d3b049979..4012ed5577b183335c758ab088a485b431e0ef42 100644 (file)
@@ -214,7 +214,7 @@ extern "C" {
         &main->setting.updated,
       };
 
-      struct timespec times[] = {
+      f_time_spec_t times[] = {
         statistics.st_atim,
         statistics.st_ctim,
         statistics.st_mtim,
index dcfbe3d2d272bcddeef49a36a7b0f371bcac0e32..fa15c2cac165c8a312d7b448f444ebb190fca8f6 100644 (file)
@@ -200,12 +200,12 @@ extern "C" {
           if (main->setting.receive.array[i].retry < kt_tacocat_startup_retry_max_d) {
             kt_tacocat_print_warning_on_busy(&main->program.warning, kt_tacocat_receive_s, main->setting.receive.array[i].network, main->setting.receive.array[i].retry + 1);
 
-            struct timespec time = { 0 };
+            f_time_spec_t time = { 0 };
 
             main->setting.receive.array[i].status = f_time_spec_millisecond(kt_tacocat_startup_retry_delay_second_d, kt_tacocat_startup_retry_delay_millisecond_d, &time);
 
             if (F_status_is_error_not(main->setting.receive.array[i].status)) {
-              nanosleep(&time, 0);
+              f_time_sleep_spec(time, 0);
             }
 
             if (main->program.signal_received) {
@@ -317,12 +317,12 @@ extern "C" {
           if (main->setting.send.array[i].retry < kt_tacocat_startup_retry_max_d) {
             kt_tacocat_print_warning_on_busy(&main->program.warning, kt_tacocat_send_s, main->setting.send.array[i].network, main->setting.send.array[i].retry + 1);
 
-            struct timespec time = { 0 };
+            f_time_spec_t time = { 0 };
 
             main->setting.send.array[i].status = f_time_spec_millisecond(kt_tacocat_startup_retry_delay_second_d, kt_tacocat_startup_retry_delay_millisecond_d, &time);
 
             if (F_status_is_error_not(main->setting.send.array[i].status)) {
-              nanosleep(&time, 0);
+              f_time_sleep_spec(time, 0);
             }
 
             if (main->program.signal_received) {
index 6f9d524e963e7c1adbb2b78296a7bbae3fc29643..1a85aa94db88000981a50c02f08e5d7275f8d612 100644 (file)
@@ -31,11 +31,9 @@ extern "C" {
 
     // Try again, but only once if blocked.
     if (main->setting.state.status == F_status_set_error(F_again)) {
-      {
-        const struct timespec time = { .tv_sec = kt_tacocat_startup_seed_delay_second_d, .tv_nsec = kt_tacocat_startup_seed_delay_nanosecond_d };
+      const f_time_spec_t time = { .tv_sec = kt_tacocat_startup_seed_delay_second_d, .tv_nsec = kt_tacocat_startup_seed_delay_nanosecond_d };
 
-        nanosleep(&time, 0);
-      }
+      f_time_sleep_spec(time, 0);
 
       main->setting.state.status = f_random_seed(F_random_seed_flag_block_not_d);
     }