common.c
Go to the documentation of this file.
00001 
00024 #include "common.h"
00025 
00031 static const char * const my_rc_e_string[] = {
00032     "Invalid RC",
00033     "Success",
00034     "Invalid input",
00035     "No memory",
00036     "Max RC"
00037 };
00038 
00040 /* Ensure there is a string for each return code declared */
00041 CT_ASSERT(NELEMS(my_rc_e_string) == (MY_RC_E_MAX + 1));
00050 bool
00051 my_rc_e_is_notok (my_rc_e rc)
00052 {
00053     return (MY_RC_E_SUCCESS != rc);
00054 }
00055 
00062 bool
00063 my_rc_e_is_ok (my_rc_e rc)
00064 {
00065     return (MY_RC_E_SUCCESS == rc);
00066 }
00067 
00074 bool
00075 my_rc_e_is_valid (my_rc_e rc)
00076 {
00077     return ((rc >= MY_RC_E_INVALID) && (rc <= MY_RC_E_MAX));
00078 }
00079 
00087 const char *
00088 my_rc_e_get_string (my_rc_e rc)
00089 {
00090     const char* retval = "__Invalid__";
00091 
00092     if (my_rc_e_is_valid(rc)) {
00093         retval = my_rc_e_string[rc];
00094     }
00095 
00096     return (retval);
00097 }
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Defines