From c1b0cba2bc3061979c97398c4862adff50bc7701 Mon Sep 17 00:00:00 2001 From: John Mark Bell Date: Sat, 4 Apr 2009 00:29:42 +0000 Subject: Move hubbub_error_from_string into testutils.h and remove it from the library. svn path=/trunk/hubbub/; revision=7041 --- include/hubbub/errors.h | 2 -- src/utils/errors.c | 25 ------------------------- 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); -- cgit v1.2.3