From fe776fab2ba96d6cd4e8da4d41eab3c985387c05 Mon Sep 17 00:00:00 2001 From: Kevin Day Date: Sun, 4 Aug 2024 20:41:50 -0500 Subject: [PATCH] Update: With the latest 0.7.x time code and other changes. --- data/build/stand_alone/configs/remove-config.h | 7 +-- data/build/stand_alone/configs/tacocat-config.h | 3 +- .../c/program/kevux/tools/remove/main/convert.c | 52 ++++------------------ .../c/program/kevux/tools/remove/main/operate.c | 4 +- .../kevux/tools/remove/main/print/simulate.c | 2 +- .../c/program/kevux/tools/tacocat/main/process.c | 8 ++-- .../c/program/kevux/tools/tacocat/main/tacocat.c | 6 +-- 7 files changed, 24 insertions(+), 58 deletions(-) diff --git a/data/build/stand_alone/configs/remove-config.h b/data/build/stand_alone/configs/remove-config.h index edad0ad..a0b271d 100644 --- a/data/build/stand_alone/configs/remove-config.h +++ b/data/build/stand_alone/configs/remove-config.h @@ -733,6 +733,7 @@ //#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_ @@ -1507,7 +1508,7 @@ #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_ @@ -1517,10 +1518,10 @@ #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_ diff --git a/data/build/stand_alone/configs/tacocat-config.h b/data/build/stand_alone/configs/tacocat-config.h index 8d68904..18e4944 100644 --- a/data/build/stand_alone/configs/tacocat-config.h +++ b/data/build/stand_alone/configs/tacocat-config.h @@ -836,6 +836,7 @@ //#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_ @@ -1767,7 +1768,7 @@ #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_ diff --git a/sources/c/program/kevux/tools/remove/main/convert.c b/sources/c/program/kevux/tools/remove/main/convert.c index c5ecacc..64d1c42 100644 --- a/sources/c/program/kevux/tools/remove/main/convert.c +++ b/sources/c/program/kevux/tools/remove/main/convert.c @@ -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; diff --git a/sources/c/program/kevux/tools/remove/main/operate.c b/sources/c/program/kevux/tools/remove/main/operate.c index 0ad2474..2f93405 100644 --- a/sources/c/program/kevux/tools/remove/main/operate.c +++ b/sources/c/program/kevux/tools/remove/main/operate.c @@ -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; diff --git a/sources/c/program/kevux/tools/remove/main/print/simulate.c b/sources/c/program/kevux/tools/remove/main/print/simulate.c index 1433377..4012ed5 100644 --- a/sources/c/program/kevux/tools/remove/main/print/simulate.c +++ b/sources/c/program/kevux/tools/remove/main/print/simulate.c @@ -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, diff --git a/sources/c/program/kevux/tools/tacocat/main/process.c b/sources/c/program/kevux/tools/tacocat/main/process.c index dcfbe3d..fa15c2c 100644 --- a/sources/c/program/kevux/tools/tacocat/main/process.c +++ b/sources/c/program/kevux/tools/tacocat/main/process.c @@ -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) { diff --git a/sources/c/program/kevux/tools/tacocat/main/tacocat.c b/sources/c/program/kevux/tools/tacocat/main/tacocat.c index 6f9d524..1a85aa9 100644 --- a/sources/c/program/kevux/tools/tacocat/main/tacocat.c +++ b/sources/c/program/kevux/tools/tacocat/main/tacocat.c @@ -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); } -- 1.8.3.1