diff options
author | John Mark Bell <jmb@netsurf-browser.org> | 2009-04-04 00:29:42 +0000 |
---|---|---|
committer | John Mark Bell <jmb@netsurf-browser.org> | 2009-04-04 00:29:42 +0000 |
commit | c1b0cba2bc3061979c97398c4862adff50bc7701 (patch) | |
tree | b01cf7b7c19c906037d85d76f08a3bfe72e4d5ec | |
parent | 98ad8d8ef83d21fe9305722285f266ca275a39ce (diff) | |
download | libhubbub-c1b0cba2bc3061979c97398c4862adff50bc7701.tar.gz libhubbub-c1b0cba2bc3061979c97398c4862adff50bc7701.tar.bz2 |
Move hubbub_error_from_string into testutils.h and remove it from the library.
svn path=/trunk/hubbub/; revision=7041
-rw-r--r-- | include/hubbub/errors.h | 2 | ||||
-rw-r--r-- | src/utils/errors.c | 25 | ||||
-rw-r--r-- | test/testutils.h | 27 |
3 files changed, 27 insertions, 27 deletions
diff --git a/include/hubbub/errors.h b/include/hubbub/errors.h index f535cf9..607c06b 100644 --- a/include/hubbub/errors.h +++ b/include/hubbub/errors.h @@ -27,8 +27,6 @@ typedef enum hubbub_error { /* Convert a hubbub error value to a string */ const char *hubbub_error_to_string(hubbub_error error); -/* Convert a string to a hubbub error value */ -hubbub_error hubbub_error_from_string(const char *str, size_t len); #endif diff --git a/src/utils/errors.c b/src/utils/errors.c index 6a2560d..766b181 100644 --- a/src/utils/errors.c +++ b/src/utils/errors.c @@ -55,28 +55,3 @@ const char *hubbub_error_to_string(hubbub_error error) return result; } -/** - * Convert a string representation of an error name to a hubbub error code - * - * \param str String containing error name - * \param len Length of string (bytes) - * \return Hubbub error code, or HUBBUB_OK if unknown - */ -hubbub_error hubbub_error_from_string(const char *str, size_t len) -{ - if (strncmp(str, "HUBBUB_OK", len) == 0) { - return HUBBUB_OK; - } else if (strncmp(str, "HUBBUB_NOMEM", len) == 0) { - return HUBBUB_NOMEM; - } else if (strncmp(str, "HUBBUB_BADPARM", len) == 0) { - return HUBBUB_BADPARM; - } else if (strncmp(str, "HUBBUB_INVALID", len) == 0) { - return HUBBUB_INVALID; - } else if (strncmp(str, "HUBBUB_FILENOTFOUND", len) == 0) { - return HUBBUB_FILENOTFOUND; - } else if (strncmp(str, "HUBBUB_NEEDDATA", len) == 0) { - return HUBBUB_NEEDDATA; - } - - return HUBBUB_OK; -} diff --git a/test/testutils.h b/test/testutils.h index c8d7467..45870f9 100644 --- a/test/testutils.h +++ b/test/testutils.h @@ -31,6 +31,33 @@ void __assert2(const char *expr, const char *function, ((void) ((expr) || (__assert2 (#expr, __func__, __FILE__, __LINE__), 0))) +/** + * Convert a string representation of an error name to a hubbub error code + * + * \param str String containing error name + * \param len Length of string (bytes) + * \return Hubbub error code, or HUBBUB_OK if unknown + */ +hubbub_error hubbub_error_from_string(const char *str, size_t len); +hubbub_error hubbub_error_from_string(const char *str, size_t len) +{ + if (strncmp(str, "HUBBUB_OK", len) == 0) { + return HUBBUB_OK; + } else if (strncmp(str, "HUBBUB_NOMEM", len) == 0) { + return HUBBUB_NOMEM; + } else if (strncmp(str, "HUBBUB_BADPARM", len) == 0) { + return HUBBUB_BADPARM; + } else if (strncmp(str, "HUBBUB_INVALID", len) == 0) { + return HUBBUB_INVALID; + } else if (strncmp(str, "HUBBUB_FILENOTFOUND", len) == 0) { + return HUBBUB_FILENOTFOUND; + } else if (strncmp(str, "HUBBUB_NEEDDATA", len) == 0) { + return HUBBUB_NEEDDATA; + } + + return HUBBUB_OK; +} + typedef bool (*line_func)(const char *data, size_t datalen, void *pw); static size_t parse_strlen(const char *str, size_t limit); |