2011-03-18 Mike Blumenkrantz
* Use stringshare for eina_error messages
+ * add eina_error_find to match an error message with its Eina_Error
EAPI Eina_Error eina_error_get(void);
EAPI void eina_error_set(Eina_Error err);
EAPI const char *eina_error_msg_get(Eina_Error error) EINA_PURE;
+EAPI Eina_Error eina_error_find(const char *msg) EINA_ARG_NONNULL(1) EINA_PURE;
/**
* @}
}
/**
+ * @brief Find the #Eina_Error corresponding to a message string
+ * @param msg The error message string to match (NOT #NULL)
+ * @return The #Eina_Error matching @p msg, or 0 on failure
+ * This function attempts to match @p msg with its corresponding #Eina_Error value.
+ * If no such value is found, 0 is returned.
+ */
+EAPI Eina_Error
+eina_error_find(const char *msg)
+{
+ size_t i;
+
+ EINA_SAFETY_ON_NULL_RETURN_VAL(msg, 0);
+
+ for (i = 0; i < _eina_errors_count; i++)
+ {
+ if (_eina_errors[i].string_allocated)
+ {
+ if (_eina_errors[i].string == msg)
+ return i;
+ }
+ else
+ {
+ if (!strcmp(_eina_errors[i].string, msg))
+ return i;
+ }
+ }
+ return 0;
+}
+/**
* @}
*/