OSSP CVS Repository

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

Check-in Number: 1367
Date: 2001-Nov-19 17:07:15 (local)
2001-Nov-19 16:07:15 (UTC)
User:simons
Branch:
Comment: Implemented var_strerror().
Tickets:
Inspections:
Files:
ossp-pkg/var/var.c      1.24 -> 1.25     50 inserted, 0 deleted
ossp-pkg/var/var.h      1.11 -> 1.12     2 inserted, 0 deleted

ossp-pkg/var/var.c 1.24 -> 1.25

--- var.c        2001/11/19 16:05:28     1.24
+++ var.c        2001/11/19 16:07:15     1.25
@@ -49,6 +49,56 @@
     "a-zA-Z0-9_"                /* namechars */
 };
 
+/* The var_strerror() routine will map a var_rc_t into a text message. */
+
+const char* var_strerror(var_rc_t rc)
+{
+    static char *var_errors[] = {
+        "OK",                                                                   /* VAR_OK = 0 */
+        "incomplete named character",                                           /* VAR_ERR_INCOMPLETE_NAMED_CHARACTER = -1 */
+        "incomplete hex",                                                       /* VAR_ERR_INCOMPLETE_HEX = -2 */
+        "invalid hex",                                                          /* VAR_ERR_INVALID_HEX = -3 */
+        "octal too large",                                                      /* VAR_ERR_OCTAL_TOO_LARGE = -4 */
+        "invalid octal",                                                        /* VAR_ERR_INVALID_OCTAL = -5 */
+        "incomplete octal",                                                     /* VAR_ERR_INCOMPLETE_OCTAL = -6 */
+        "incomplete grouped hex",                                               /* VAR_ERR_INCOMPLETE_GROUPED_HEX = -7 */
+        "incorrect character class specification",                              /* VAR_ERR_INCORRECT_CLASS_SPEC = -8 */
+        "var_expand() configuration is inconsistent",                           /* VAR_ERR_INVALID_CONFIGURATION = -9 */
+        "out of memory",                                                        /* VAR_ERR_OUT_OF_MEMORY = -10 */
+        "incomplete variable",                                                  /* VAR_ERR_INCOMPLETE_VARIABLE_SPEC = -11 */
+        "undefined variable",                                                   /* VAR_ERR_UNDEFINED_VARIABLE = -12 */
+        "input is neither text nor variable",                                   /* VAR_ERR_INPUT_ISNT_TEXT_NOR_VARIABLE = -13 */
+        "unknown command in variable",                                          /* VAR_ERR_UNKNOWN_COMMAND_CHAR = -14 */
+        "malformated search and replace operation",                             /* VAR_ERR_MALFORMATTED_REPLACE = -16 */
+        "unknown flag specified in search and replace operation",               /* VAR_ERR_UNKNOWN_REPLACE_FLAG = -17 */
+        "invalid regular expression in search and replace operation",           /* VAR_ERR_INVALID_REGEX_IN_REPLACE = -18 */
+        "missing parameter in command",                                         /* VAR_ERR_MISSING_PARAMETER_IN_COMMAND = -19 */
+        "empty search string in search and replace operation",                  /* VAR_ERR_EMPTY_SEARCH_STRING = -20 */
+        "start offset missing in cut operation"                                 /* VAR_ERR_MISSING_START_OFFSET = -21 */
+        "offsets in cut operation delimited by unknown character",              /* VAR_ERR_INVALID_OFFSET_DELIMITER = -22 */
+        "range in cut operation is out of bounds",                              /* VAR_ERR_RANGE_OUT_OF_BOUNDS = -23 */
+        "offset in cut operation is out of bounds",                             /* VAR_ERR_OFFSET_OUT_OF_BOUNDS = -24 */
+        "logic error in cut operation",                                         /* VAR_ERR_OFFSET_LOGIC = -25 */
+        "malformatted transpose operation",                                     /* VAR_ERR_MALFORMATTED_TRANSPOSE = -26 */
+        "source class does not match destination class in transpose operation", /* VAR_ERR_TRANSPOSE_CLASSES_MISMATCH = -27 */
+        "empty character class in transpose operation",                         /* VAR_ERR_EMPTY_TRANSPOSE_CLASS = -28 */
+        "incorrect character class in transpose operation",                     /* VAR_ERR_INCORRECT_TRANSPOSE_CLASS_SPEC = -29 */
+        "malformatted padding operation",                                       /* VAR_ERR_MALFORMATTED_PADDING = -30 */
+        "width parameter missing in padding operation",                         /* VAR_ERR_MISSING_PADDING_WIDTH = -31 */
+        "fill string missing in padding operation",                             /* VAR_ERR_EMPTY_PADDING_FILL_STRING = -32 */
+        "unknown quoted pair in search and replace operation",                  /* VAR_ERR_UNKNOWN_QUOTED_PAIR_IN_REPLACE = -33 */
+        "submatch referred to in replace string does not exist in search string", /* VAR_ERR_SUBMATCH_OUT_OF_RANGE = -34 */
+        "invalid argument",                                                     /* VAR_ERR_INVALID_ARGUMENT = -35 */
+        "incomplete quoted pair"                                                /* VAR_ERR_INCOMPLETE_QUOTED_PAIR = -36 */
+    };
+
+    rc = 0 - rc;
+    if (rc < 0 || rc >= sizeof(var_errors) / sizeof(char *))
+        return "unknown error";
+
+    return var_errors[rc];
+}
+
 /* Routines for manipulation of token buffers. */
 
 #define TOKENBUF_INITIAL_BUFSIZE 64


ossp-pkg/var/var.h 1.11 -> 1.12

--- var.h        2001/11/19 15:56:17     1.11
+++ var.h        2001/11/19 16:07:15     1.12
@@ -158,5 +158,7 @@
     const var_config_t *config, int force_expand);
 //FIXME THL: "force_expand" used here but described and unused above in "var_config_t"
 
+const char* var_strerror(var_rc_t rc);
+
 #endif /* __VAR_H__ */
 

CVSTrac 2.0.1