diff options
-rw-r--r-- | include/libcss/errors.h | 2 | ||||
-rw-r--r-- | src/utils/errors.c | 30 | ||||
-rw-r--r-- | test/number.c | 2 | ||||
-rw-r--r-- | test/testutils.h | 33 |
4 files changed, 35 insertions, 32 deletions
diff --git a/include/libcss/errors.h b/include/libcss/errors.h index 55bd379..8e321ce 100644 --- a/include/libcss/errors.h +++ b/include/libcss/errors.h @@ -24,8 +24,6 @@ typedef enum css_error { /* Convert a libcss error value to a string */ const char *css_error_to_string(css_error error); -/* Convert a string to a libcss error value */ -css_error css_error_from_string(const char *str, size_t len); #endif diff --git a/src/utils/errors.c b/src/utils/errors.c index ac7dd42..b5b4792 100644 --- a/src/utils/errors.c +++ b/src/utils/errors.c @@ -48,33 +48,3 @@ const char *css_error_to_string(css_error error) return result; } - -/** - * Convert a string representation of an error name to a LibCSS error code - * - * \param str String containing error name - * \param len Length of string (bytes) - * \return LibCSS error code, or CSS_OK if unknown - */ -css_error css_error_from_string(const char *str, size_t len) -{ - if (strncmp(str, "CSS_OK", len) == 0) { - return CSS_OK; - } else if (strncmp(str, "CSS_NOMEM", len) == 0) { - return CSS_NOMEM; - } else if (strncmp(str, "CSS_BADPARM", len) == 0) { - return CSS_BADPARM; - } else if (strncmp(str, "CSS_INVALID", len) == 0) { - return CSS_INVALID; - } else if (strncmp(str, "CSS_FILENOTFOUND", len) == 0) { - return CSS_FILENOTFOUND; - } else if (strncmp(str, "CSS_NEEDDATA", len) == 0) { - return CSS_NEEDDATA; - } else if (strncmp(str, "CSS_BADCHARSET", len) == 0) { - return CSS_BADCHARSET; - } else if (strncmp(str, "CSS_EOF", len) == 0) { - return CSS_EOF; - } - - return CSS_OK; -} diff --git a/test/number.c b/test/number.c index dd44730..bc5ea52 100644 --- a/test/number.c +++ b/test/number.c @@ -2,6 +2,8 @@ #include <stdlib.h> #include <string.h> +#include "libcss/libcss.h" + #include "utils/utils.h" #include "testutils.h" diff --git a/test/testutils.h b/test/testutils.h index 3e23c07..5471fed 100644 --- a/test/testutils.h +++ b/test/testutils.h @@ -4,6 +4,8 @@ #include <stdbool.h> #include <stdio.h> #include <stdlib.h> +#include <string.h> +#include <sys/types.h> #ifndef UNUSED #define UNUSED(x) ((x) = (x)) @@ -147,4 +149,35 @@ size_t parse_filesize(const char *filename) } +/** + * Convert a string representation of an error name to a LibCSS error code + * + * \param str String containing error name + * \param len Length of string (bytes) + * \return LibCSS error code, or CSS_OK if unknown + */ +css_error css_error_from_string(const char *str, size_t len); +css_error css_error_from_string(const char *str, size_t len) +{ + if (strncmp(str, "CSS_OK", len) == 0) { + return CSS_OK; + } else if (strncmp(str, "CSS_NOMEM", len) == 0) { + return CSS_NOMEM; + } else if (strncmp(str, "CSS_BADPARM", len) == 0) { + return CSS_BADPARM; + } else if (strncmp(str, "CSS_INVALID", len) == 0) { + return CSS_INVALID; + } else if (strncmp(str, "CSS_FILENOTFOUND", len) == 0) { + return CSS_FILENOTFOUND; + } else if (strncmp(str, "CSS_NEEDDATA", len) == 0) { + return CSS_NEEDDATA; + } else if (strncmp(str, "CSS_BADCHARSET", len) == 0) { + return CSS_BADCHARSET; + } else if (strncmp(str, "CSS_EOF", len) == 0) { + return CSS_EOF; + } + + return CSS_OK; +} + #endif |