OSSP CVS Repository

ossp - Check-in [3509]
Not logged in
[Honeypot]  [Browse]  [Home]  [Login]  [Reports
[Search]  [Ticket]  [Timeline
  [Patchset]  [Tagging/Branching

Check-in Number: 3509
Date: 2003-Jul-11 11:18:20 (local)
2003-Jul-11 09:18:20 (UTC)
User:ms
Branch:
Comment: Replace embedded text strings from code to constants header. Address two functional problems identified by Thomas and Ralf, namely missing error message identifiers and confusing period punctuation with info option.
Tickets:
Inspections:
Files:
ossp-pkg/rc/rc_config.c      1.39 -> 1.40     2 inserted, 2 deleted
ossp-pkg/rc/rc_const.h      1.35 -> 1.36     15 inserted, 0 deleted
ossp-pkg/rc/rc_error.c      1.10 -> 1.11     25 inserted, 24 deleted

ossp-pkg/rc/rc_config.c 1.39 -> 1.40

--- rc_config.c  2003/07/07 13:30:51     1.39
+++ rc_config.c  2003/07/11 09:18:20     1.40
@@ -86,9 +86,9 @@
         for (i = 0; i < RC_NUMOPTS; i++) {
             if (configGetval(i) == NULL); /* NOP */
             else if (!(strcmp(configGetval(i), "1")))
-                fprintf(stderr, "# Option %s is on.\n", configGetname(i));
+                fprintf(stderr, "# Option %s is on\n", configGetname(i));
             else
-                fprintf(stderr, "# Option %s is %s.\n", configGetname(i),\
+                fprintf(stderr, "# Option %s is %s\n", configGetname(i),\
                     configGetval(i));
         }
         fputc('\n', stderr);


ossp-pkg/rc/rc_const.h 1.35 -> 1.36

--- rc_const.h   2003/07/11 08:49:36     1.35
+++ rc_const.h   2003/07/11 09:18:20     1.36
@@ -81,6 +81,21 @@
 #define RC_DFL_DESC "Name of the default section in a rcfile."
 #define RC_ERR_DESC "Name of the error section in a rcfile."
 
+/* Error messages with newline termination */
+#define RC_ERRTXT_ALL  "Error condition in %s:%s():%d.\n"
+#define RC_ERRTXT_USE  "OSSP rc:API usage is wrong.\n"
+#define RC_ERRTXT_MEM  "OSSP rc:Memory allocation failure.\n"
+#define RC_ERRTXT_SYS  "OSSP rc:Underlying system failure.\n"
+#define RC_ERRTXT_IO   "OSSP rc:Input output failure.\n"
+#define RC_ERRTXT_INT  "OSSP rc:Internal failure.\n"
+#define RC_ERRTXT_FNC  "OSSP rc:Function file %s could not be opened.\n"
+#define RC_ERRTXT_LOC  "OSSP rc:Location dir %s could not be opened.\n"
+#define RC_ERRTXT_TMP  "OSSP rc:Temporary dir %s could not be opened.\n"
+#define RC_ERRTXT_RCF  "OSSP rc:One or more rc files could not be opened.\n"
+#define RC_ERRTXT_CFG  "OSSP rc:Configuration failure.\n"
+#define RC_ERRTXT_ROOT "OSSP rc:You must be root to run these commands.\n"
+#define RC_ERRTXT_GEN  "OSSP rc:Generic failure condition of class '%s',.\n"
+
 /* Option friendly names, should not include newline termination */
 #define RC_USE_NAME "usage"
 #define RC_DBG_NAME "debug"


ossp-pkg/rc/rc_error.c 1.10 -> 1.11

--- rc_error.c   2003/07/08 15:09:50     1.10
+++ rc_error.c   2003/07/11 09:18:20     1.11
@@ -30,6 +30,7 @@
 #include <stdlib.h>    /* Just for calling 'exit(3)' once */
 #include "rc.h"        /* Public interfaces               */
 #include "rc_config.h" /* Interface to the configuration  */
+#include "rc_const.h"  /* Error message string constants  */
 
 
 /************************************************
@@ -44,78 +45,78 @@
         if ((rc_return_t)Localerr.ex_value == RC_ERR_TRM)
             exit(0);
         else if ((rc_return_t)Localerr.ex_value == RC_ERR_USE) {
-            fprintf(stderr, "    API usage is wrong.\n");
+            fprintf(stderr, RC_ERRTXT_USE);
             if (configGetval(RC_DBG_VAL))
-                fprintf(stderr, "    Error condition in %s:%s():%d.\n", \
+                fprintf(stderr, RC_ERRTXT_ALL, \
                     Localerr.ex_file, Localerr.ex_func, Localerr.ex_line);
         }
         else if ((rc_return_t)Localerr.ex_value == RC_ERR_MEM) {
-            fprintf(stderr, "    Memory allocation failure.\n");
+            fprintf(stderr, RC_ERRTXT_MEM);
             if (configGetval(RC_DBG_VAL))
-                fprintf(stderr, "    Error condition in %s:%s():%d.\n", \
+                fprintf(stderr, RC_ERRTXT_ALL, \
                     Localerr.ex_file, Localerr.ex_func, Localerr.ex_line);
         }
         else if ((rc_return_t)Localerr.ex_value == RC_ERR_SYS) {
-            fprintf(stderr, "    Underlying system failure.\n");
+            fprintf(stderr, RC_ERRTXT_SYS);
             if (configGetval(RC_DBG_VAL))
-                fprintf(stderr, "    Error condition in %s:%s():%d.\n", \
+                fprintf(stderr, RC_ERRTXT_ALL, \
                     Localerr.ex_file, Localerr.ex_func, Localerr.ex_line);
         }
         else if ((rc_return_t)Localerr.ex_value == RC_ERR_IO) {
-            fprintf(stderr, "    Input output failure.\n");
+            fprintf(stderr, RC_ERRTXT_IO);
             if (configGetval(RC_DBG_VAL))
-                fprintf(stderr, "    Error condition in %s:%s():%d.\n", \
+                fprintf(stderr, RC_ERRTXT_ALL, \
                     Localerr.ex_file, Localerr.ex_func, Localerr.ex_line);
         }
         else if ((rc_return_t)Localerr.ex_value == RC_ERR_INT) {
-            fprintf(stderr, "    Internal failure.\n");
+            fprintf(stderr, RC_ERRTXT_INT);
             if (configGetval(RC_DBG_VAL))
-                fprintf(stderr, "    Error condition in %s:%s():%d.\n", \
+                fprintf(stderr, RC_ERRTXT_ALL, \
                     Localerr.ex_file, Localerr.ex_func, Localerr.ex_line);
         }
         else if ((rc_return_t)Localerr.ex_value == RC_ERR_FNC) {
-            fprintf(stderr, "    Function file %s could not be opened.\n", \
+            fprintf(stderr, RC_ERRTXT_FNC, \
                 configGetval(RC_FNC_VAL));
             if (configGetval(RC_DBG_VAL))
-                fprintf(stderr, "    Error condition in %s:%s():%d.\n", \
+                fprintf(stderr, RC_ERRTXT_ALL, \
                     Localerr.ex_file, Localerr.ex_func, Localerr.ex_line);
         }
         else if ((rc_return_t)Localerr.ex_value == RC_ERR_LOC) {
-            fprintf(stderr, "    Location dir %s could not be opened.\n", \
+            fprintf(stderr, RC_ERRTXT_LOC, \
                 configGetval(RC_LOC_VAL));
             if (configGetval(RC_DBG_VAL))
-                fprintf(stderr, "    Error condition in %s:%s():%d.\n", \
+                fprintf(stderr, RC_ERRTXT_ALL, \
                     Localerr.ex_file, Localerr.ex_func, Localerr.ex_line);
         }
         else if ((rc_return_t)Localerr.ex_value == RC_ERR_TMP) {
-            fprintf(stderr, "    Temporary dir %s could not be opened.\n", \
+            fprintf(stderr, RC_ERRTXT_TMP, \
                 configGetval(RC_TMP_VAL));
             if (configGetval(RC_DBG_VAL))
-                fprintf(stderr, "    Error condition in %s:%s():%d.\n", \
+                fprintf(stderr, RC_ERRTXT_ALL, \
                     Localerr.ex_file, Localerr.ex_func, Localerr.ex_line);
         }
         else if ((rc_return_t)Localerr.ex_value == RC_ERR_RCF) {
-            fprintf(stderr, "    One or more rc files could not be opened.\n");
+            fprintf(stderr, RC_ERRTXT_RCF);
             if (configGetval(RC_DBG_VAL))
-                fprintf(stderr, "    Error condition in %s:%s():%d.\n", \
+                fprintf(stderr, RC_ERRTXT_ALL, \
                     Localerr.ex_file, Localerr.ex_func, Localerr.ex_line);
         }
         else if ((rc_return_t)Localerr.ex_value == RC_ERR_CFG) {
-            fprintf(stderr, "    Configuration failure.\n");
+            fprintf(stderr, RC_ERRTXT_CFG);
             if (configGetval(RC_DBG_VAL))
-                fprintf(stderr, "    Error condition in %s:%s():%d.\n", \
+                fprintf(stderr, RC_ERRTXT_ALL, \
                     Localerr.ex_file, Localerr.ex_func, Localerr.ex_line);
         }
         else if ((rc_return_t)Localerr.ex_value == RC_ERR_ROOT) {
-            fprintf(stderr, "    You must be root to run these commands.\n");
+            fprintf(stderr, RC_ERRTXT_ROOT);
             if (configGetval(RC_DBG_VAL))
-                fprintf(stderr, "    Error condition in %s:%s():%d.\n", \
+                fprintf(stderr, RC_ERRTXT_ALL, \
                     Localerr.ex_file, Localerr.ex_func, Localerr.ex_line);
         }
         else {
-            fprintf(stderr, "    Generic failure condition of class '%s',.\n", (char *)Localerr.ex_class);
+            fprintf(stderr, RC_ERRTXT_GEN, (char *)Localerr.ex_class);
             if (configGetval(RC_DBG_VAL))
-                fprintf(stderr, "    Error condition in %s:%s():%d.\n", \
+                fprintf(stderr, RC_ERRTXT_ALL, \
                     Localerr.ex_file, Localerr.ex_func, Localerr.ex_line);
         }
 

CVSTrac 2.0.1