]> Kevux Git Server - fll/commitdiff
Update: Improve a few initial error printing messages.
authorKevin Day <thekevinday@gmail.com>
Thu, 30 Sep 2021 12:16:39 +0000 (07:16 -0500)
committerKevin Day <thekevinday@gmail.com>
Thu, 30 Sep 2021 12:16:39 +0000 (07:16 -0500)
level_3/controller/c/controller.c
level_3/controller/c/private-common.c
level_3/controller/c/private-common.h
level_3/controller/c/private-controller.c
level_3/controller/c/private-rule.c

index 6802de0199a0c663794f790e11e48d4205346168..d77b7a07d7217b76dd2ff837bbd5a3456d736cae 100644 (file)
@@ -13,7 +13,7 @@ extern "C" {
 #ifndef _di_controller_print_help_
   f_status_t controller_print_help(const controller_main_t main) {
 
-    flockfile(main.output.stream);
+    controller_print_lock(main.output, 0);
 
     fll_program_print_help_header(main.output, main.context, main.program_name_long, controller_version);
 
@@ -48,7 +48,7 @@ extern "C" {
 
     fl_print_format(" Specify an empty string for the %[%s%s%] parameter to disable pid file creation for this program.%c%c", main.output.stream, main.context.set.notable, f_console_symbol_long_enable_s, controller_long_pid, main.context.set.notable, f_string_eol_s[0], f_string_eol_s[0]);
 
-    funlockfile(main.output.stream);
+    controller_print_unlock_flush(main.output, 0);
 
     return F_none;
   }
@@ -134,11 +134,11 @@ extern "C" {
     }
 
     if (main->parameters[controller_parameter_version].result == f_console_result_found) {
-      flockfile(main->output.stream);
+      controller_print_lock(main->output, 0);
 
       fll_program_print_version(main->output, controller_version);
 
-      funlockfile(main->output.stream);
+      controller_print_unlock_flush(main->output, 0);
 
       controller_main_delete(main);
       return F_none;
@@ -179,13 +179,13 @@ extern "C" {
 
     if (main->parameters[controller_parameter_settings].result == f_console_result_found) {
       if (main->error.verbosity != f_console_verbosity_quiet) {
-        flockfile(main->error.to.stream);
+        controller_print_lock(main->error.to, 0);
 
         fl_print_format("%c%[%SThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix ? main->error.prefix : f_string_empty_s, main->error.context);
         fl_print_format("%[%s%s%]", main->error.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, controller_long_settings, main->context.set.notable);
         fl_print_format("%[' was specified, but no value was given.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]);
 
-        funlockfile(main->error.to.stream);
+        controller_print_unlock_flush(main->error.to, 0);
       }
 
       status = F_status_set_error(F_parameter);
@@ -218,13 +218,13 @@ extern "C" {
     if (F_status_is_error_not(status)) {
       if (main->parameters[controller_parameter_pid].result == f_console_result_found) {
         if (main->error.verbosity != f_console_verbosity_quiet) {
-          flockfile(main->error.to.stream);
+          controller_print_lock(main->error.to, 0);
 
           fl_print_format("%c%[%SThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix ? main->error.prefix : f_string_empty_s, main->error.context);
           fl_print_format("%[%s%s%]", main->error.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, controller_long_pid, main->context.set.notable);
           fl_print_format("%[' was specified, but no value was given.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]);
 
-          funlockfile(main->error.to.stream);
+          controller_print_unlock_flush(main->error.to, 0);
         }
 
         status = F_status_set_error(F_parameter);
@@ -270,13 +270,13 @@ extern "C" {
     if (F_status_is_error_not(status)) {
       if (main->parameters[controller_parameter_control].result == f_console_result_found) {
         if (main->error.verbosity != f_console_verbosity_quiet) {
-          flockfile(main->error.to.stream);
+          controller_print_lock(main->error.to, 0);
 
           fl_print_format("%c%[%SThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix ? main->error.prefix : f_string_empty_s, main->error.context);
           fl_print_format("%[%s%s%]", main->error.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, controller_long_control, main->context.set.notable);
           fl_print_format("%[' was specified, but no value was given.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]);
 
-          funlockfile(main->error.to.stream);
+          controller_print_unlock_flush(main->error.to, 0);
         }
 
         status = F_status_set_error(F_parameter);
@@ -307,13 +307,13 @@ extern "C" {
         }
         else {
           if (main->warning.verbosity == f_console_verbosity_debug) {
-            flockfile(main->warning.to.stream);
+            controller_print_lock(main->warning.to, 0);
 
             fl_print_format("%c%[%SThe parameter '%]", main->warning.to.stream, f_string_eol_s[0], main->warning.context, main->warning.prefix ? main->warning.prefix : f_string_empty_s, main->warning.context);
             fl_print_format("%[%s%s%]", main->warning.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, controller_long_control, main->context.set.notable);
             fl_print_format("%[' must be a file directory path but instead is an empty string, falling back to the default.%]%c", main->warning.to.stream, main->warning.context, main->warning.context, f_string_eol_s[0]);
 
-            funlockfile(main->warning.to.stream);
+            controller_print_unlock_flush(main->warning.to, 0);
           }
         }
       }
@@ -322,14 +322,14 @@ extern "C" {
     if (F_status_is_error_not(status) && main->parameters[controller_parameter_daemon].result == f_console_result_found) {
       if (main->parameters[controller_parameter_validate].result == f_console_result_found) {
         if (main->error.verbosity != f_console_verbosity_quiet) {
-          flockfile(main->error.to.stream);
+          controller_print_lock(main->error.to, 0);
 
           fl_print_format("%c%[%SThe parameter '%]", main->error.to.stream, f_string_eol_s[0], main->error.context, main->error.prefix ? main->error.prefix : f_string_empty_s, main->error.context);
           fl_print_format("%[' must not be specified with the parameter '%]", main->error.to.stream, main->error.context, main->error.context);
           fl_print_format("%[%s%s%]", main->error.to.stream, main->context.set.notable, f_console_symbol_long_enable_s, controller_long_daemon, main->context.set.notable);
           fl_print_format("%['.%]%c", main->error.to.stream, main->error.context, main->error.context, f_string_eol_s[0]);
 
-          funlockfile(main->error.to.stream);
+          controller_print_unlock_flush(main->error.to, 0);
         }
 
         status = F_status_set_error(F_parameter);
@@ -415,7 +415,15 @@ extern "C" {
 
       if (F_status_is_error(status_delete) && main->warning.verbosity == f_console_verbosity_debug) {
         if (F_status_set_fine(status_delete) == F_number_not) {
-          controller_error_pid_bad_match_print(main->warning, setting.path_pid.string, 0);
+          controller_print_lock(main->warning.to, 0);
+
+          fl_print_format("%c%[%SThe pid file '%]", main->warning.to.stream, f_string_eol_s[0], main->warning.context, main->warning.prefix ? main->warning.prefix : f_string_empty_s, main->warning.context);
+          fl_print_format("%[%Q%]", main->warning.to.stream, main->warning.notable, setting.path_pid, main->warning.notable);
+          fl_print_format("%[' must not be specified with the parameter '%]", main->warning.to.stream, main->warning.context, main->warning.context);
+          fl_print_format("%[%i%]", main->warning.to.stream, main->warning.notable, main->pid, main->warning.notable);
+          fl_print_format("%[' doesn't contain the expected number, not deleting file.%]%c", main->warning.to.stream, main->warning.context, main->warning.context, f_string_eol_s[0]);
+
+          controller_print_unlock_flush(main->warning.to, 0);
         }
         else {
           fll_error_file_print(main->warning, F_status_set_fine(status_delete), "controller_file_pid_delete", F_true, setting.path_pid.string, "delete", fll_error_file_type_file);
index 3def5d1542f529964c1a430a1b383851d68a9feb..bd6956839caa12bb5b7ebfde6486007944b87f21 100644 (file)
@@ -200,23 +200,6 @@ extern "C" {
     }
   }
 #endif // _di_controller_error_file_print_
-
-#ifndef _di_controller_error_pid_bad_match_print_
-  void controller_error_pid_bad_match_print(const fll_error_print_t print, const f_string_t path, controller_thread_t *thread) {
-
-    if (print.verbosity == f_console_verbosity_quiet) return;
-
-    controller_print_lock(print.to, thread);
-
-    fl_print_format("%c%[%SThe pid file '%]", print.to.stream, f_string_eol_s[0], print.context, print.prefix ? print.prefix : f_string_empty_s, print.context);
-    fl_print_format("%[' must not be specified with the parameter '%]", print.to.stream, print.context, print.context);
-    fl_print_format("%[%S%]", print.to.stream, print.notable, path, print.notable);
-    fl_print_format("%[' doesn't contain the expected number, not deleting file.%]%c", print.to.stream, print.context, print.context, f_string_eol_s[0]);
-
-    controller_print_unlock_flush(print.to, thread);
-  }
-#endif // _di_controller_error_pid_bad_match_print_
-
 #ifndef _di_controller_error_print_
   void controller_error_print(const fll_error_print_t print, const f_status_t status, const f_string_t function, const bool fallback, controller_thread_t *thread) {
 
index c5ded775a2aeb593b82c748a32e3ee79859f3a7d..dd6e187c59e89acc1c5f4842e1d0dde76f5ca91c 100644 (file)
@@ -1607,25 +1607,6 @@ extern "C" {
 /**
  * Print the error, locking the print mutex during the print.
  *
- * This does not check verbosity.
- *
- * @param print
- *   Designates how printing is to be performed.
- * @param path
- *   The path to the PID file.
- * @param thread
- *   (optional) The thread data.
- *   Set to NULL to not use (locking will not be performed).
- *
- * @see fll_error_print()
- */
-#ifndef _di_controller_error_pid_bad_match_print_
-  extern void controller_error_pid_bad_match_print(const fll_error_print_t print, const f_string_t path, controller_thread_t *thread) f_attribute_visibility_internal;
-#endif // _di_controller_error_pid_bad_match_print_
-
-/**
- * Print the error, locking the print mutex during the print.
- *
  * @param print
  *   Designates how printing is to be performed.
  * @param status
index 14211579b9e1530874dada567eb2dbb5b5b6beef..34917a6ac65642855695fdb72c5934d5479782ad 100644 (file)
@@ -428,9 +428,14 @@ extern "C" {
         if (global.main->warning.verbosity == f_console_verbosity_debug) {
           controller_print_lock(global.main->warning.to, global.thread);
 
-          controller_error_file_print(global.main->warning, F_status_set_fine(status), "controller_file_pid_create", F_true, global.setting->path_pid.string, "create", fll_error_file_type_file, 0);
-
-          flockfile(global.main->warning.to.stream);
+          if (F_status_set_fine(status) == F_read_only) {
+            fl_print_format("%c%[%SThe pid file '%]", global.main->warning.to.stream, f_string_eol_s[0], global.main->warning.context, global.main->warning.prefix ? global.main->warning.prefix : f_string_empty_s, global.main->warning.context);
+            fl_print_format("%[%Q%]", global.main->warning.to.stream, global.main->warning.notable, global.setting->path_pid, global.main->warning.notable);
+            fl_print_format("%[' could not be written because the destination is read only.%]%c", global.main->warning.to.stream, global.main->warning.context, global.main->warning.context, f_string_eol_s[0]);
+          }
+          else {
+            controller_error_file_print(global.main->warning, F_status_set_fine(status), "controller_file_pid_create", F_true, global.setting->path_pid.string, "create", fll_error_file_type_file, 0);
+          }
 
           controller_entry_error_print_cache(is_entry, global.main->warning, cache->action);
 
index 69b373b44e01981eb443cbe520d50cd17370f967..61eab06bce22e189ce27a3b15c93773aea132d24 100644 (file)
@@ -2156,6 +2156,7 @@ extern "C" {
                 controller_print_lock(global.main->warning.to, global.thread);
 
                 controller_rule_item_error_print_need_want_wish(global.main->warning, strings[i], dynamics[i]->array[j].string, "was not found");
+
                 controller_rule_error_print_cache(global.main->warning, process->cache.action, F_true);
 
                 controller_print_unlock_flush(global.main->warning.to, global.thread);
@@ -2254,6 +2255,7 @@ extern "C" {
                       controller_print_lock(global.main->warning.to, global.thread);
 
                       controller_rule_item_error_print_need_want_wish(global.main->warning, strings[i], alias_other_buffer, "failed during execution");
+
                       controller_rule_error_print_cache(global.main->warning, process->cache.action, F_true);
 
                       controller_print_unlock_flush(global.main->warning.to, global.thread);