diff options
Diffstat (limited to 'src/libs/libopenlmi/openlmi.h')
-rw-r--r-- | src/libs/libopenlmi/openlmi.h | 65 |
1 files changed, 49 insertions, 16 deletions
diff --git a/src/libs/libopenlmi/openlmi.h b/src/libs/libopenlmi/openlmi.h index 7f151cd..a35e01e 100644 --- a/src/libs/libopenlmi/openlmi.h +++ b/src/libs/libopenlmi/openlmi.h @@ -182,8 +182,7 @@ void lmi_set_log_level(int level); * @retval true if succeeds * @retval false if addition fails */ -/* TODO: Rename. Looks like a class. */ -#define LMI_ReturnInstance(cr, w) KOkay(__KReturnInstance((cr), &(w).__base)) +#define lmi_return_instance(cr, w) KOkay(__KReturnInstance((cr), &(w).__base)) enum { _LMI_DEBUG_NONE=0, _LMI_DEBUG_ERROR, _LMI_DEBUG_WARN, @@ -196,28 +195,32 @@ void _lmi_debug(int level, const char *file, int line, const char *format, ...); #define lmi_info(...) _lmi_debug(_LMI_DEBUG_INFO, __FILE__, __LINE__, __VA_ARGS__) #define lmi_warn(...) _lmi_debug(_LMI_DEBUG_WARN, __FILE__, __LINE__, __VA_ARGS__) #define lmi_error(...) _lmi_debug(_LMI_DEBUG_ERROR, __FILE__, __LINE__, __VA_ARGS__) -#define lmi_dump_objectpath(o, lvl) \ +#define lmi_dump_objectpath(o, lvl) \ lmi_##lvl("OP: %s", CMGetCharsPtr((o)->ft->toString(o, NULL), NULL)) -/* Shortcuts for functions and macros from openlmicommon library. */ -#define get_system_creation_class_name lmi_get_system_creation_class_name -#define get_system_name lmi_get_system_name + +#define lmi_return_with_chars(b, code, ...) \ + do { \ + char errmsg[BUFLEN]; \ + snprintf(errmsg, BUFLEN - 1, __VA_ARGS__); \ + CMReturnWithChars(b, code, errmsg); \ + } while (0) /* Status checking helpers. Beware of the returns! */ -#define lmi_check_status(st) \ +#define lmi_return_if_status_not_ok(st) \ do { \ - if (st.rc != CMPI_RC_OK) { \ - return st; \ + if ((st).rc != CMPI_RC_OK) { \ + return (st); \ } \ } while (0) -#define lmi_check_class_check_status(st) \ +#define lmi_return_if_class_check_not_ok(st) \ do { \ - if (st.rc == LMI_RC_ERR_CLASS_CHECK_FAILED) { \ + if ((st).rc == LMI_RC_ERR_CLASS_CHECK_FAILED) { \ CMReturn(CMPI_RC_OK); \ } \ - lmi_check_status(st); \ + lmi_return_if_status_not_ok(st); \ } while (0) #define lmi_return_with_status(b, st, code, msg) \ @@ -227,10 +230,40 @@ void _lmi_debug(int level, const char *file, int line, const char *format, ...); } while(0) -CMPIStatus lmi_check_required(const CMPIBroker *, const CMPIContext *, const CMPIObjectPath *); -CMPIStatus lmi_check_assoc_class(const CMPIBroker *, const char *, const char *, const char *); +/** + * Check required properties and their values. currently, only computer system + * creation class name and computer system name are checked. + * + * @param cb CMPIBroker + * @param ctx CMPIContext + * @param o Objectpath to be checked + * @param csccn_prop_name Computer system creation class name property name + * @param csn_prop_name Computer system name property name + */ +CMPIStatus lmi_check_required_properties(const CMPIBroker *cb, const CMPIContext *ctx, + const CMPIObjectPath *o, + const char *csccn_prop_name, + const char *csn_prop_name); + +/** + * Determine whether a CIM class is of <class_type> or any of <class_type> + * subclasses. + * + * @param cb CMPIBroker + * @param namespace CIMOM namespace + * @param class Class to be checked + * @param class_type Class to be checked against + */ +CMPIStatus lmi_class_path_is_a(const CMPIBroker *cb, const char *namespace, + const char *class, const char *class_type); -const char *lmi_get_string_property_from_objectpath(const CMPIObjectPath *, const char *); -const char *lmi_get_string_property_from_instance(const CMPIInstance *, const char *); +const char *lmi_get_string_property_from_objectpath(const CMPIObjectPath *o, const char *prop); +const char *lmi_get_string_property_from_instance(const CMPIInstance *i, const char *prop); #endif /* OPENLMI_H */ + +/* vi: set et: */ +/* Local Variables: */ +/* indent-tabs-mode: nil */ +/* c-basic-offset: 4 */ +/* End: */ |