/* ********************************************************** * Copyright 2007 VMware, Inc. All rights reserved. -- VMware Confidential * **********************************************************/ #ifndef _VMCF_CORE_IMPL_H_ #define _VMCF_CORE_IMPL_H_ /** * @file VMCFCoreImpl.h * Common macros and functions. * * @defgroup VMCFCore VMCFCore: Core Functions and Interfaces * @{ */ #include "VMCFCore.h" #include "VMCFClass.h" #if !defined(CORBA_OBJECT_NIL) # define CORBA_OBJECT_NIL (CORBA_Object)0 #endif #if !defined(CORBA_TRUE) # define CORBA_TRUE (CORBA_boolean)1 #endif #if !defined(CORBA_FALSE) # define CORBA_FALSE (CORBA_boolean)0 #endif /* VMCF/ORB initialization and retrieval */ VMCF_EXTERN CORBA_boolean VMCFCoreImpl_init(CORBA_boolean sslEnabled, void *clientCtx); VMCF_EXTERN CORBA_Object VMCFCoreImpl_getORB(void); /* Global locking */ VMCF_EXTERN void VMCFCoreImpl_lock(void); VMCF_EXTERN void VMCFCoreImpl_unlock(void); /* Server operations */ struct VMCFServer_s; typedef struct VMCFServer_s *VMCFServer; VMCF_EXTERN VMCFServer VMCFCoreImpl_createServer(char *tinfo, void *serverCtx, CORBA_Environment *env); VMCF_EXTERN void VMCFCoreImpl_closeServer(VMCFServer server, CORBA_Environment *env); /* Exception handling */ /** Returns non-zero if an exception was raised. */ #define VMCF_EXCEPTION_RAISED(env) ((env)->_major != CORBA_NO_EXCEPTION) /** Breaks out of a ('do') loop, if the last call raised an exception. */ #define VMCF_BREAK_ON_EXCEPTION(env) { if (VMCF_EXCEPTION_RAISED(env)) break; } /** * Raises a VMCFCore::InvalidArguments exception if the given test fails. * * @param[in] test The condition to test. * @param[out] env The environment where the exception will be set on failure. * @param[in] onfail Optional code statement to execute when the test fails. */ #define VMCF_ASSERT_ARG(test, env, onfail) { \ if (!(test)) { \ VMCFCoreImpl_raiseInvalidArguments(env, NULL); \ onfail; \ } \ } /** * Raises a VMCFCore::NoResources exception if the given pointer is NULL. * * @param[in] ptr The pointer to test. * @param[out] env The environment where the exception will be set on failure. * @param[in] onfail Optional code statement to execute when the test fails. */ #define VMCF_ASSERT_ALLOC(ptr, env, onfail) { \ if ((ptr) == NULL) { \ CORBA_exception_set((env), CORBA_USER_EXCEPTION, \ ex_VMCFCore_NoResources, NULL); \ onfail; \ } \ } VMCF_EXTERN void VMCFCoreImpl_raiseInvalidArguments(CORBA_Environment *env, CORBA_string msg); /* General convenience functions */ /** * Returns whether a CORBA string is empty or not. * * @param str The string to test. */ #define VMCF_IS_EMPTY(str) ((str) == NULL || *(str) == '\0') VMCF_EXTERN void VMCFCoreImpl_releaseObject(void *obj); VMCF_EXTERN CORBA_string VMCFCoreImpl_strdup(const CORBA_string src); /** @} */ #endif /* _VMCF_CORE_IMPL_H_ */