forked from enlightenment/efl
+EAPI Eina_Error eina_error_find(const char *msg)
SVN revision: 57863
This commit is contained in:
parent
bb5a5a5ab4
commit
f0ff4ed477
|
@ -36,3 +36,4 @@
|
|||
2011-03-18 Mike Blumenkrantz
|
||||
|
||||
* Use stringshare for eina_error messages
|
||||
* add eina_error_find to match an error message with its Eina_Error
|
||||
|
|
|
@ -54,6 +54,7 @@ EAPI Eina_Bool eina_error_msg_modify(Eina_Error 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;
|
||||
|
||||
/**
|
||||
* @}
|
||||
|
|
|
@ -459,6 +459,35 @@ eina_error_set(Eina_Error err)
|
|||
_eina_last_error = err;
|
||||
}
|
||||
|
||||
/**
|
||||
* @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;
|
||||
}
|
||||
/**
|
||||
* @}
|
||||
*/
|
||||
|
|
Loading…
Reference in New Issue